:root {
  color-scheme: light;
  --cream: #fff8ed;
  --paper: #fffdf8;
  --plum: #522943;
  --ink: #332231;
  --petal: #e8cbda;
  --muted: #665766;
  --line: #cfbdc5;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--cream);
  line-height: 1.55;
}
* { box-sizing: border-box; }
body { margin: 0; }
a { color: var(--plum); text-underline-offset: .2em; }
button, input, select, textarea { font: inherit; }
button, input, select { min-height: 44px; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .6; }
:focus-visible { outline: 3px solid #a04779; outline-offset: 4px; }
.site-header, main, footer { max-width: 1180px; margin-inline: auto; }
.site-header { padding: 25px 32px 15px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.site-header a { font-weight: bold; text-decoration: none; }
.site-header span { color: var(--muted); font-size: .875rem; }
main { padding: 0 32px; }
.intro { padding: 23px 0 29px; max-width: 760px; }
h1, h2, h3, legend { font-family: Georgia, 'Times New Roman', serif; font-weight: normal; }
h1 { font-size: clamp(2.3rem, 5.3vw, 3.6rem); line-height: 1.08; letter-spacing: -.035em; margin: 0 0 17px; }
.intro p { max-width: 64ch; margin: 0 0 10px; }
.intro-note { color: var(--muted); font-size: .875rem; }
h2 { font-size: 1.9rem; line-height: 1.2; margin: 0 0 12px; }
h3 { font-size: 1.35rem; margin: 0 0 8px; line-height: 1.25; }
p { max-width: 75ch; }
.workbench { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(320px, .85fr); background: var(--paper); border: 1px solid var(--line); border-radius: 20px 20px 4px 4px; overflow: clip; scroll-margin-top: 16px; }
form { padding: 27px 30px 32px; min-width: 0; }
.example-status { background: #f5e7ed; color: var(--plum); border-left: 3px solid var(--plum); padding: 10px 13px; font-size: .85rem; margin-bottom: 22px; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
fieldset > legend { font-size: 1.65rem; line-height: 1.25; margin-bottom: 8px; }
.field-note { font-size: .825rem; color: var(--muted); line-height: 1.5; margin: 0 0 17px; }
label { display: block; font-size: .875rem; line-height: 1.4; }
input, select, textarea { font-size: 1rem; background: #fff; color: var(--ink); border: 1px solid #9c8595; border-radius: 5px; width: 100%; padding: 10px 11px; margin-top: 7px; }
input:focus, select:focus { border-color: var(--plum); }
input[type=number] { appearance: textfield; }
input::-webkit-inner-spin-button, input::-webkit-outer-spin-button { appearance: none; margin: 0; }
.input-unit { display: block; position: relative; }
.input-unit input { padding-right: 35px; }
.input-unit > span { position: absolute; right: 12px; top: 20px; color: var(--muted); pointer-events: none; }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 18px; }
.basis-label { margin-top: 19px; }
#basis-help { margin-top: 9px; }
.label-values { margin-bottom: 26px; }
.replacement-group { border-top: 1px solid var(--line); padding-top: 24px; }
.replacement-group > legend { float: left; width: 100%; }
.replacement-group > .field-note { clear: both; padding-top: 6px; }
.yarn-row { border-left: 4px solid var(--plum); padding-left: 17px; margin: 18px 0 24px; }
.yarn-row:nth-child(2) { border-left-color: #916c27; }
.yarn-row:nth-child(3) { border-left-color: #486c64; }
.yarn-row > legend { font-family: inherit; font-size: .95rem; font-weight: bold; padding: 0 0 0 2px; margin-bottom: 9px; }
.yarn-row-heading { display: flex; align-items: end; gap: 14px; margin-bottom: 15px; }
.yarn-row-heading > label { flex: 1; min-width: 0; }
.remove-yarn, .quiet-button, .example-button { background: transparent; border: 1px solid #bda3b0; color: var(--plum); border-radius: 5px; padding: 9px 13px; font-size: .875rem; }
.remove-yarn { padding-inline: 8px; }
.quiet-button { border-style: dashed; }
.allowance { margin-top: 24px; display: grid; grid-template-columns: 145px minmax(0, 1fr); gap: 18px; align-items: end; }
.allowance .field-note { margin-bottom: 4px; }
.form-error { color: #8b233f; font-weight: bold; font-size: .875rem; margin: 15px 0; }
.form-error:empty { display: none; }
.calculate-button { background: var(--plum); color: #fff; border: 0; border-radius: 6px; padding: 11px 17px; margin-top: 20px; }
.result-panel { background: var(--plum); color: var(--cream); padding: 30px; align-self: start; height: fit-content; position: sticky; top: 0; min-width: 0; border-radius: 0 0 0 20px; }
.result-panel h2 { font-size: 2rem; }
.result-intro { font-size: .875rem; color: #efd8e5; margin: 0 0 21px; }
.thread-mark { display: flex; gap: 6px; height: 10px; margin: 0 0 20px; }
.thread-mark span { width: 55px; border-top: 3px solid var(--petal); border-radius: 50%; transform: rotate(-5deg); }
.thread-mark span:nth-child(2) { border-color: #e0b977; transform: rotate(5deg); }
.thread-mark span:nth-child(3) { border-color: #b9d2cb; }
.working-length { font-size: .875rem; padding-bottom: 21px; border-bottom: 1px solid #90667e; margin: 0; }
.shopping-yarn { padding: 22px 0; border-bottom: 1px solid #90667e; }
.shopping-yarn h3 { color: var(--petal); font-size: 1.25rem; overflow-wrap: anywhere; }
.ball-count { font-size: 1.55rem; font-weight: bold; margin: 6px 0; line-height: 1.3; }
.ball-label { margin: 0 0 18px; font-size: .875rem; }
dl { margin: 0; }
dt { color: #efd8e5; font-size: .775rem; margin-top: 10px; }
dd { margin: 2px 0 0; font-size: .925rem; font-variant-numeric: tabular-nums; }
#copy-result { width: 100%; background: var(--cream); color: var(--plum); border: 0; border-radius: 6px; padding: 12px 15px; margin-top: 24px; font-weight: bold; }
.copy-status { font-size: .875rem; margin: 10px 0; }
.copy-status:empty { display: none; }
.copy-status textarea { font-size: .8rem; min-height: 170px; }
.result-caution { font-size: .8rem; color: #efd8e5; margin: 18px 0 0; }
.result-panel :focus-visible { outline-color: #efd8e5; }
.examples { padding: 46px 0; }
.examples > div p { margin: 0 0 20px; color: var(--muted); }
.examples ol { padding-left: 25px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); column-gap: 37px; row-gap: 22px; margin: 0; }
.examples li { padding-left: 4px; }
.examples li::marker { color: var(--plum); font: italic 1.25rem Georgia, serif; }
.examples p { font-size: .9rem; margin: 0 0 15px; }
.method { padding: 36px 0 43px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 55px; }
.method h2 { font-size: 1.65rem; }
.method p, .method li { font-size: .9rem; }
.method ul { padding-left: 22px; }
.method li + li { margin-top: 12px; }
.formula { background: #f1e0e8; padding: 15px; border-left: 3px solid var(--plum); }
footer { border-top: 1px solid var(--line); padding: 23px 32px 35px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 24px; font-size: .8rem; color: var(--muted); }
footer span { flex: 1; }
.skip-link { position: absolute; top: -100px; left: 15px; background: #fff; padding: 12px; z-index: 5; }
.skip-link:focus { top: 10px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.notice { border: 2px solid var(--plum); padding: 16px; }
@media (max-width: 820px) {
  .site-header { padding-inline: 22px; }
  .site-header span { display: none; }
  main { padding-inline: 22px; }
  .workbench { grid-template-columns: minmax(0, 1fr); }
  .result-panel { position: static; border-radius: 0; }
  .examples ol { grid-template-columns: 1fr; }
  .examples li { max-width: 65ch; }
  .method { grid-template-columns: 1fr; gap: 24px; }
  footer { padding-inline: 22px; }
}
@media (max-width: 420px) {
  main { padding-inline: 14px; }
  .site-header { padding-inline: 16px; }
  form, .result-panel { padding: 23px 17px; }
  .field-grid { gap: 14px 11px; }
  .yarn-row { padding-left: 11px; }
  .allowance { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .allowance label { max-width: 150px; }
  .intro { padding-top: 14px; }
  .intro p { font-size: .9rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; } }
