@layer reset, base, layout, components, state, print;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  html { text-size-adjust: 100%; }
  body, h1, h2, h3, p, ul, ol, dl, dd, fieldset { margin: 0; }
  ul, ol { padding: 0; }
  img, svg { display: block; max-width: 100%; }
  button, input, select, textarea { font: inherit; }
  button { cursor: pointer; }
  [hidden] { display: none !important; }
}

@layer base {
  :root {
    color-scheme: light dark;
    --paper: #eef4fb;
    --surface: #ffffff;
    --surface-soft: #f3f7fb;
    --ink: #0b1933;
    --ink-muted: #526078;
    --rule: #d8e1ed;
    --border: #8b98aa;
    --navy: #061a3a;
    --navy-soft: #0b2b59;
    --accent: #1267d7;
    --accent-fill: #e8f1fd;
    --result: #087a52;
    --result-fill: #e6f5ef;
    --good: #087a52;
    --good-fill: #e6f5ef;
    --panel-shadow: 0 12px 34px rgb(8 33 70 / .09);
    --caution: #8a4006;
    --caution-fill: #fcf0e2;
    --bad: #a91e16;
    --bad-fill: #fdecea;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --display: clamp(2.4rem, 1.55rem + 4vw, 4rem);
    --h1: clamp(1.55rem, 1.3rem + 1.15vw, 2rem);
    --h2: 1.25rem;
    --body: 1rem;
    --sm: .875rem;
    --xs: .75rem;
    --gutter: 1rem;
    --s1: .25rem;
    --s2: .5rem;
    --s3: .75rem;
    --s4: 1rem;
    --s5: 1.25rem;
    --s6: 1.5rem;
    --s8: 2rem;
    --s10: 2.5rem;
    --s12: 3rem;
    --r-sm: .375rem;
    --r-md: .625rem;
    --tap: 2.75rem;
    --dur: 180ms;
    --ease: cubic-bezier(.2, 0, 0, 1);
    --s-1: var(--s1);
    --s-2: var(--s2);
    --s-3: var(--s3);
    --s-4: var(--s4);
    --s-5: var(--s5);
    --s-6: var(--s6);
    --fs-xs: var(--xs);
    --fs-sm: var(--sm);
    --bw-hair: 1px;
    --bw-control: 1px;
    --bw-emphasis: 2px;
  }

  @media (prefers-color-scheme: dark) {
    :root {
      --paper: #08111f;
      --surface: #111f32;
      --surface-soft: #172941;
      --ink: #f4f8ff;
      --ink-muted: #a9b7cb;
      --rule: #2c415d;
      --border: #71829a;
      --navy: #030d1f;
      --navy-soft: #0b2146;
      --accent: #67aaff;
      --accent-fill: #102d52;
      --result: #57d2a0;
      --result-fill: #113729;
      --good: #57d2a0;
      --good-fill: #113729;
      --panel-shadow: 0 12px 34px rgb(0 0 0 / .28);
      --caution: #f2a355;
      --caution-fill: #241a0e;
      --bad: #f27a72;
      --bad-fill: #2a1614;
    }
  }

  @media (min-width: 640px) { :root { --gutter: 1.5rem; } }
  @media (prefers-reduced-motion: reduce) { :root { --dur: 0ms; } }

  html { background: var(--paper); scroll-behavior: smooth; }
  body {
    min-width: 20rem;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font);
    font-size: var(--body);
    line-height: 1.55;
  }
  h1 { font-size: var(--h1); line-height: 1.15; letter-spacing: -.025em; }
  h2 { font-size: var(--h2); line-height: 1.3; letter-spacing: -.012em; }
  h3 { font-size: 1.0625rem; line-height: 1.35; }
  a { color: var(--accent); text-underline-offset: .18em; }
  a:hover { text-decoration-thickness: 2px; }
  button, input, select { color: var(--ink); }
  button, input, select, summary { min-height: var(--tap); }
  input, select { font-size: 1rem; }
  button:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible, a:focus-visible, [tabindex="0"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
  }
  ::selection { background: var(--accent-fill); color: var(--ink); }
}

@layer layout {
  .container { width: 100%; max-width: 70rem; margin-inline: auto; padding-inline: var(--gutter); }
  .content-width { max-width: 47rem; }
  .site-header {
    display: flex;
    flex-direction: column;
    gap: var(--s4);
    justify-content: space-between;
    padding-block: var(--s6) var(--s5);
    border-bottom: 1px solid var(--rule);
  }
  .header-copy { display: grid; gap: var(--s1); }
  .scope-line { max-width: 48rem; color: var(--ink-muted); }
  .calculator {
    display: grid;
    gap: var(--s6);
    padding-block: var(--s6) var(--s12);
  }
  .controls { min-width: 0; }
  .fit-section, .charts-section { padding-block: var(--s12); }
  .fit-section { border-top: 1px solid var(--rule); }
  .section-heading { display: grid; gap: var(--s2); margin-bottom: var(--s6); }
  .section-heading > p:last-child { color: var(--ink-muted); max-width: 48rem; }
  .fit-card { display: grid; gap: var(--s6); }
  .fit-inputs { display: grid; gap: var(--s4); }
  .charts-section { display: grid; gap: var(--s8); }
  .site-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--s3) var(--s5);
    padding-block: var(--s6);
    border-top: 1px solid var(--rule);
    color: var(--ink-muted);
    font-size: var(--sm);
  }
  .site-footer nav { display: flex; gap: var(--s4); }
  .site-footer button { margin-left: auto; }

  @media (min-width: 640px) {
    .site-header { padding-block: var(--s8) var(--s6); }
    .calculator { padding-block: var(--s8) 4rem; }
    .fit-card { grid-template-columns: minmax(0, 1fr) minmax(18rem, .85fr); }
    .fit-inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .maker-range { grid-column: 1 / -1; }
  }

  @media (min-width: 1024px) {
    .site-header { flex-direction: row; align-items: end; }
    .calculator { grid-template-columns: minmax(20rem, 5fr) minmax(0, 7fr); gap: var(--s10); align-items: start; }
    .controls { grid-column: 1; }
    .result { grid-column: 2; grid-row: 1; position: sticky; top: var(--s4); }
    .fit-card { grid-template-columns: minmax(0, 1.05fr) minmax(22rem, .95fr); }
  }
}

@layer components {
  .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
  .skip-link {
    position: fixed;
    z-index: 100;
    inset: .75rem auto auto .75rem;
    padding: .65rem .85rem;
    border: 2px solid var(--accent);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    transform: translateY(-200%);
  }
  .skip-link:focus { transform: translateY(0); }
  .site-label, .section-kicker, .control-heading, .result__eyebrow {
    color: var(--ink-muted);
    font-size: var(--xs);
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
  }

  .segmented {
    display: inline-grid;
    grid-template-columns: 1fr 1fr;
    width: min(100%, 19rem);
    padding: 0;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
  }
  .segmented label { position: relative; min-width: 0; }
  .segmented input { position: absolute; opacity: 0; pointer-events: none; }
  .segmented span {
    display: grid;
    min-height: var(--tap);
    place-items: center;
    padding-inline: var(--s3);
    border: 2px solid transparent;
    border-radius: calc(var(--r-sm) - 1px);
    color: var(--ink-muted);
    font-size: var(--sm);
    font-weight: 650;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  .segmented input:checked + span { border-color: var(--accent); background: var(--accent-fill); color: var(--ink); }
  .segmented input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

  .banner, .noscript-note {
    margin-top: var(--s4);
    padding: var(--s3) var(--s4);
    border: 1px solid var(--bad);
    border-radius: var(--r-sm);
    background: var(--bad-fill);
  }
  .banner { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
  .banner > div { display: grid; gap: var(--s1); }
  .banner button, .noscript-note { font-size: var(--sm); }

  .presets-wrap { display: grid; gap: var(--s2); margin-bottom: var(--s5); }
  .presets {
    display: flex;
    gap: var(--s2);
    overflow-x: auto;
    padding: 2px 2rem var(--s2) 2px;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
  }
  .preset {
    flex: 0 0 auto;
    min-height: var(--tap);
    padding-inline: var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    scroll-snap-align: start;
    transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease);
  }
  .preset:hover { background: var(--surface-soft); }
  .preset[aria-pressed="true"] { border: 2px solid var(--accent); background: var(--accent-fill); }

  .field { min-width: 0; }
  .field__label, .choice-group legend, .maker-range legend {
    display: block;
    margin-bottom: var(--s2);
    color: var(--ink);
    font-size: var(--sm);
    font-weight: 700;
  }
  .optional { color: var(--ink-muted); font-weight: 500; }
  .field__control {
    width: 100%;
    min-height: var(--tap);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
  }
  input.field__control { padding: .55rem .7rem; }
  select.field__control { padding: .45rem 2rem .45rem .65rem; }
  .number-input { text-align: right; font-variant-numeric: tabular-nums; }
  .number-row { display: flex; align-items: center; gap: var(--s2); min-width: 0; }
  .unit-suffix { flex: 0 0 auto; min-width: 2.2rem; color: var(--ink-muted); font-size: var(--sm); font-variant-numeric: tabular-nums; }
  .stepper { display: grid; grid-template-columns: var(--tap) minmax(6rem, 1fr) var(--tap); width: 100%; }
  .stepper__btn {
    width: var(--tap);
    min-height: var(--tap);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--ink);
    font-size: 1.25rem;
  }
  .stepper__btn:first-child { border-radius: var(--r-sm) 0 0 var(--r-sm); }
  .stepper__btn:last-child { border-radius: 0 var(--r-sm) var(--r-sm) 0; }
  .stepper .field__control { border-inline: 0; border-radius: 0; }
  .stepper__btn:hover, button:not(:disabled):hover { background: var(--surface-soft); }
  .field__help, .field__error { min-height: 1.25rem; margin-top: var(--s1); font-size: var(--xs); line-height: 1.35; }
  .field__help { color: var(--ink-muted); }
  .field__error { color: var(--bad); font-weight: 650; }
  .field[data-invalid="true"] .field__control { border: 2px solid var(--bad); }
  .field[data-invalid="true"] .field__error::before { content: "! "; }

  .quick-result {
    display: grid;
    gap: 1px;
    margin-block: var(--s3) var(--s4);
    padding: var(--s3) var(--s4);
    border-left: 3px solid var(--accent);
    background: var(--accent-fill);
  }
  .quick-result__label { color: var(--ink-muted); font-size: var(--xs); }
  .quick-result strong { font-size: 1.35rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
  .quick-result > span:last-child { color: var(--ink-muted); font-size: var(--sm); }

  .refinements { border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); }
  .refinements summary { display: flex; align-items: center; justify-content: space-between; padding-block: var(--s3); font-weight: 700; cursor: pointer; }
  .refinements summary::after { content: "+"; font-size: 1.25rem; transition: transform var(--dur) var(--ease); }
  .refinements[open] summary::after { transform: rotate(45deg); }
  .refinements__body { display: grid; gap: var(--s5); padding: var(--s2) 0 var(--s5); }
  .choice-group, .maker-range { padding: 0; border: 0; }
  .chipset { display: flex; flex-wrap: wrap; gap: var(--s2); }
  .chip { position: relative; }
  .chip input { position: absolute; opacity: 0; }
  .chip span {
    display: grid;
    min-height: var(--tap);
    place-items: center;
    padding-inline: var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
  }
  .chip input:checked + span { border: 2px solid var(--accent); background: var(--accent-fill); }
  .chip input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
  .choice-stack { display: grid; gap: var(--s2); }
  .choice-row {
    display: grid;
    grid-template-columns: 1.25rem 1fr;
    gap: var(--s2);
    align-items: start;
    min-height: var(--tap);
    padding: var(--s2) var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
  }
  .choice-row:has(input:checked) { border: 2px solid var(--accent); background: var(--accent-fill); }
  .choice-row input { margin-top: .2rem; accent-color: var(--accent); }
  .choice-row span { display: grid; }
  .choice-row small { color: var(--ink-muted); }
  .height-pair, .boot-row { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; gap: var(--s2); align-items: center; }
  .boot-row { grid-template-columns: minmax(8rem, .9fr) minmax(6rem, 1fr); }

  .result {
    min-width: 0;
    min-height: 26rem;
    padding: var(--s5);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    background: var(--surface);
  }
  .result__headline {
    margin-top: var(--s1);
    font-size: var(--display);
    font-weight: 760;
    line-height: 1;
    letter-spacing: -.045em;
    font-variant-numeric: tabular-nums;
  }
  .result__conversion, .result__sizes, .confidence-row p, .privacy-line { color: var(--ink-muted); }
  .result__conversion { margin-top: var(--s1); font-variant-numeric: tabular-nums; }
  .result__pick { margin-top: var(--s3); font-size: 1.12rem; font-weight: 700; font-variant-numeric: tabular-nums; }
  .result__sizes { margin-top: var(--s1); font-size: var(--sm); font-variant-numeric: tabular-nums; }
  .stale-marker { margin-top: var(--s3); color: var(--caution); font-size: var(--sm); font-weight: 700; }
  .model-specific { margin-top: var(--s4); padding: var(--s3); border: 1px solid var(--caution); border-radius: var(--r-sm); background: var(--caution-fill); }
  .model-specific p { margin-top: var(--s1); font-size: var(--sm); }

  .ruler-wrap { margin-top: var(--s5); padding-top: var(--s4); border-top: 1px solid var(--rule); }
  .ruler { width: 100%; height: auto; aspect-ratio: 640 / 150; overflow: visible; }
  .ruler text { fill: var(--ink-muted); font-family: var(--font); font-size: 12px; font-variant-numeric: tabular-nums; }
  .ruler__baseline, .ruler__tick { stroke: var(--border); stroke-width: 1; }
  .ruler__tick--major { stroke: var(--ink-muted); stroke-width: 1.5; }
  .ruler__range { fill: url(#ruler-hatch); stroke: var(--ink-muted); stroke-width: 1.5; }
  .ruler__zone { fill: var(--accent-fill); stroke: var(--accent); stroke-width: 2; }
  .ruler__pick { fill: var(--accent); stroke: var(--accent); }
  .ruler__pick-line { stroke: var(--accent); stroke-width: 1.5; }
  .ruler__height { fill: var(--surface); stroke: var(--ink-muted); stroke-width: 1.5; }
  .ruler__height-line { stroke: var(--ink-muted); stroke-width: 1; stroke-dasharray: 3 2; }
  .ruler__hatch-line { stroke: var(--ink-muted); stroke-width: 1; opacity: .45; }
  .ruler-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-top: var(--s2); list-style: none; color: var(--ink-muted); font-size: var(--xs); }
  .ruler-legend li { display: inline-flex; align-items: center; gap: var(--s1); }
  .legend-swatch { display: inline-block; width: .9rem; height: .65rem; border: 1px solid var(--ink-muted); }
  .legend-swatch--range { background: repeating-linear-gradient(45deg, transparent 0 3px, var(--rule) 3px 4px); }
  .legend-swatch--zone { border-color: var(--accent); background: var(--accent-fill); }
  .legend-swatch--pick { width: 0; height: 0; border: .35rem solid transparent; border-top-color: var(--accent); border-bottom: 0; }
  .legend-swatch--height { width: .65rem; height: .65rem; border-radius: 50%; background: transparent; }

  .waist {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4);
    margin-top: var(--s5);
    padding: var(--s4) 0;
    border-top: 1px solid var(--rule);
    border-bottom: 1px solid var(--rule);
  }
  .waist h3 { margin-top: var(--s1); }
  .waist p:last-child { margin-top: var(--s1); color: var(--ink-muted); font-size: var(--sm); }
  .secondary-button, .actions button, .fit-section button, .site-footer button, .banner button {
    min-height: var(--tap);
    padding-inline: var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
  }
  button:disabled { border-color: var(--rule); color: var(--ink-muted); cursor: not-allowed; }

  .breakdown { margin-top: var(--s5); }
  .breakdown > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s3); padding-block: .45rem; border-bottom: 1px dotted var(--rule); }
  .breakdown dt { color: var(--ink-muted); font-size: var(--sm); }
  .breakdown dd { max-width: 20rem; text-align: right; font-size: var(--sm); font-weight: 650; font-variant-numeric: tabular-nums; }
  .confidence-row { display: grid; gap: var(--s2); margin-top: var(--s5); }
  .confidence-badge { width: fit-content; padding: .25rem .55rem; border: 1px solid var(--border); border-radius: var(--r-sm); font-size: var(--sm); font-weight: 700; }
  .confidence-badge[data-level="high"] { border-color: var(--good); background: var(--good-fill); color: var(--good); }
  .confidence-badge[data-level="medium"] { border-color: var(--caution); background: var(--caution-fill); color: var(--caution); }
  .privacy-line, .maker-note { margin-top: var(--s4); font-size: var(--sm); }
  .maker-note { padding-left: var(--s3); border-left: 3px solid var(--accent); }
  .actions { display: flex; flex-wrap: wrap; gap: var(--s2); margin-top: var(--s5); }
  .actions button:first-child { border-color: var(--accent); background: var(--accent); color: var(--surface); }
  .status { min-height: 1.25rem; margin-top: var(--s1); color: var(--ink-muted); font-size: var(--sm); }

  .fit-card {
    padding: var(--s5);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    background: var(--surface);
  }
  .maker-range__row { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: var(--s2) var(--s3); align-items: center; }
  .maker-range__row label { color: var(--ink-muted); font-size: var(--sm); }
  .fit-output { min-width: 0; padding-top: var(--s4); border-top: 1px solid var(--rule); }
  .fit-output h3 { margin-top: var(--s1); font-size: 1.35rem; }
  .verdict-list { display: grid; gap: var(--s2); margin-top: var(--s4); list-style: none; }
  .verdict { display: grid; grid-template-columns: 1.25rem 1fr; gap: var(--s2); padding: var(--s3); border: 1px solid var(--border); border-radius: var(--r-sm); }
  .verdict > span:last-child { display: grid; }
  .verdict small { margin-top: 2px; color: var(--ink-muted); }
  .verdict__symbol { font-weight: 900; }
  .verdict[data-verdict="good"] { border-color: var(--good); background: var(--good-fill); }
  .verdict[data-verdict="good"] .verdict__symbol { color: var(--good); }
  .verdict[data-verdict="caution"] { border-color: var(--caution); background: var(--caution-fill); }
  .verdict[data-verdict="caution"] .verdict__symbol { color: var(--caution); }
  .verdict[data-verdict="bad"] { border-color: var(--bad); background: var(--bad-fill); }
  .verdict[data-verdict="bad"] .verdict__symbol { color: var(--bad); }
  .fit-priority { margin-top: var(--s4); color: var(--ink-muted); font-size: var(--sm); }

  .chart-block { display: grid; gap: var(--s3); }
  .chart-scroll { max-width: 100%; overflow-x: auto; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .chart { width: 100%; min-width: 39rem; border-collapse: collapse; font-variant-numeric: tabular-nums; }
  .chart caption { padding: var(--s2) 0; color: var(--ink-muted); text-align: left; font-size: var(--sm); }
  .chart th, .chart td { padding: .65rem .7rem; border-bottom: 1px solid var(--rule); text-align: left; white-space: nowrap; }
  .chart thead th { position: sticky; top: 0; z-index: 1; background: var(--surface); color: var(--ink-muted); font-size: var(--sm); }
  .chart tbody th { font-weight: 650; }
  .chart__row--match { background: var(--accent-fill); box-shadow: inset 3px 0 0 var(--accent); }
  .chart__row--match td:last-child { color: var(--accent); font-weight: 750; }

  @media (min-width: 640px) {
    .result { min-height: 28rem; padding: var(--s6); }
    .maker-range__row { grid-template-columns: auto minmax(7rem, 1fr) auto minmax(7rem, 1fr); }
    .fit-output { padding: 0 0 0 var(--s5); border-top: 0; border-left: 1px solid var(--rule); }
  }

  @media (min-width: 1024px) {
    .quick-result { display: none; }
    .unit-choice { flex: 0 0 19rem; }
  }

  @media (max-width: 639px) {
    .waist { align-items: flex-start; flex-direction: column; }
    .waist .secondary-button { width: 100%; }
    .actions { display: grid; grid-template-columns: 1fr 1fr; }
    .actions button:first-child { grid-column: 1 / -1; }
    .actions button { width: 100%; }
    .breakdown dd { max-width: 12rem; }
    .site-footer { align-items: flex-start; flex-direction: column; }
    .site-footer button { margin-left: 0; }
  }
}

@layer state {
  .result[data-state="empty"] .ruler-wrap,
  .result[data-state="empty"] .waist,
  .result[data-state="empty"] .breakdown,
  .result[data-state="empty"] .confidence-row,
  .result[data-state="empty"] .privacy-line,
  .result[data-state="empty"] .maker-note { display: none; }
  .result[data-state="no-result"] .ruler-wrap,
  .result[data-state="no-result"] .waist,
  .result[data-state="no-result"] .breakdown { display: none; }
  .result[data-state="invalid"] { border-color: var(--caution); }
  .result[data-stale="true"] > :not(.result__eyebrow, .stale-marker, .actions, .status) { opacity: .56; transition: opacity var(--dur) var(--ease); }
  .result[data-state="success"], .result[data-state="partial"] { border-color: var(--border); }
  .result[data-state="no-result"] { border-color: var(--caution); background: var(--caution-fill); }
  .quick-result[data-state="invalid"], .quick-result[data-state="no-result"] { border-left-color: var(--caution); background: var(--caution-fill); }
  .waist[data-verdict="good"] { border-color: var(--good); }
  .waist[data-verdict="caution"] { border-color: var(--caution); }
  .waist[data-verdict="bad"] { border-color: var(--bad); }
  [aria-busy="true"] { cursor: progress; }

  @media (forced-colors: active) {
    .preset[aria-pressed="true"], .segmented input:checked + span, .chip input:checked + span { border-color: Highlight; background: Highlight; color: HighlightText; }
    .ruler__range { fill: url(#ruler-hatch); stroke: CanvasText; forced-color-adjust: none; }
    .ruler__zone { fill: transparent; stroke: Highlight; }
    .chart__row--match { outline: 2px solid Highlight; outline-offset: -2px; box-shadow: none; }
    .verdict { border-color: CanvasText; }
  }
}

@layer print {
  @media print {
    @page { margin: 12mm; }
    :root {
      --paper: white;
      --surface: white;
      --surface-soft: white;
      --ink: black;
      --ink-muted: black;
      --rule: #bbbbbb;
      --border: black;
      --accent: black;
      --accent-fill: white;
      --good: black;
      --good-fill: white;
      --caution: black;
      --caution-fill: white;
      --bad: black;
      --bad-fill: white;
    }
    html, body { background: white; color: black; }
    .skip-link, .unit-choice, .banner, .noscript-note, .controls, .size-options, .actions, .status,
    .charts-section, .site-footer,
    .section-heading, .fit-inputs { display: none !important; }
    .site-header { padding: 0 0 5mm; border-bottom: 1px solid black; }
    .scope-line { font-size: 9pt; }
    .calculator { display: block; padding: 5mm 0; }
    .result { min-height: 0; padding: 5mm; border: 1px solid black; break-inside: avoid; }
    .result__headline { font-size: 34pt; }
    .ruler-wrap { margin-top: 4mm; padding-top: 3mm; }
    .ruler__zone { fill: url(#ruler-hatch); stroke: black; }
    .fit-section { padding: 5mm 0 0; border-top: 0; }
    .fit-card { display: block; padding: 4mm; border: 1px solid black; break-inside: avoid; }
    .fit-output { padding: 0; border: 0; }
    .verdict { padding: 2mm; border: 1px solid black; background: white; color: black; print-color-adjust: exact; }
    .privacy-line { display: none; }
    .maker-note { margin-top: 3mm; font-size: 9pt; }
  }
}

@layer components {
.brand {
  display: inline-flex;
  width: fit-content;
  align-items: center;
  gap: var(--s2);
  color: var(--ink);
  font-size: var(--sm);
  font-weight: 780;
  text-decoration: none;
}
.brand__mark { width: 1.45rem; height: 1.45rem; color: var(--accent); }
.brand__mark path { fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 2; }
.header-copy { gap: var(--s2); }
.header-copy h1 { max-width: 24ch; font-size: clamp(1.8rem, 1.35rem + 1.8vw, 2.75rem); }
.scope-line { max-width: 43rem; }

.control-heading-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s3); }
.control-heading-row > span { color: var(--ink-muted); font-size: var(--xs); text-align: right; }
.presets { padding: 0; overflow: visible; scrollbar-width: auto; }
.presets--primary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s2); }
.preset {
  display: grid;
  align-content: center;
  gap: 1px;
  min-width: 0;
  min-height: 4rem;
  padding: .65rem .75rem;
  text-align: left;
}
.preset strong { font-size: var(--sm); line-height: 1.25; }
.preset span { color: var(--ink-muted); font-size: var(--xs); line-height: 1.25; }
.preset[aria-pressed="true"] span { color: var(--ink); }
.special-presets { margin-top: var(--s2); border-top: 1px solid var(--rule); }
.special-presets--refinement { margin-top: 0; padding-bottom: var(--s2); border-top: 0; border-bottom: 1px solid var(--rule); }
.special-presets summary {
  display: flex;
  min-height: var(--tap);
  align-items: center;
  gap: var(--s2);
  padding-block: var(--s2);
  color: var(--ink);
  cursor: pointer;
  font-size: var(--sm);
  font-weight: 700;
}
.special-presets summary small { margin-left: auto; color: var(--ink-muted); font-weight: 500; }
.special-presets summary::after { content: "+"; color: var(--ink-muted); font-size: 1.1rem; }
.special-presets[open] summary::after { content: "−"; }
.presets--special { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); padding-bottom: var(--s2); }

.field--weight { padding: var(--s4); border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); }
.field--weight .field__label { font-size: 1rem; }
.weight-range-shell { margin-top: var(--s3); }
.weight-range {
  --weight-progress: 52%;
  width: 100%;
  min-height: 2rem;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: pointer;
}
.weight-range::-webkit-slider-runnable-track {
  height: .42rem;
  border: 1px solid var(--border);
  border-radius: .25rem;
  background: linear-gradient(to right, var(--accent) 0 var(--weight-progress), var(--surface-soft) var(--weight-progress) 100%);
}
.weight-range::-moz-range-track {
  height: .42rem;
  border: 1px solid var(--border);
  border-radius: .25rem;
  background: var(--surface-soft);
}
.weight-range::-moz-range-progress { height: .42rem; background: var(--accent); }
.weight-range::-webkit-slider-thumb {
  width: 1.35rem;
  height: 1.35rem;
  margin-top: -.51rem;
  appearance: none;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  outline: 1px solid var(--accent);
}
.weight-range::-moz-range-thumb {
  width: 1.05rem;
  height: 1.05rem;
  border: 3px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
  outline: 1px solid var(--accent);
}
.weight-range:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.weight-range__labels { display: flex; justify-content: space-between; gap: var(--s3); color: var(--ink-muted); font-size: .6875rem; }
.weight-example { display: flex; gap: var(--s2); align-items: baseline; margin-top: var(--s1); color: var(--ink-muted); font-size: var(--xs); }
.weight-example strong { padding: .12rem .38rem; border: 1px solid var(--caution); border-radius: var(--r-sm); background: var(--caution-fill); color: var(--caution); }

.refinements { margin-top: var(--s4); }
.refinements summary { gap: var(--s2); }
.refinements summary small { margin-left: auto; color: var(--ink-muted); font-size: var(--xs); font-weight: 500; }

.result {
  position: relative;
  overflow: clip;
  padding-top: calc(var(--s5) + .5rem);
  border-color: var(--border);
}
.result::before {
  position: absolute;
  inset: 0 0 auto;
  height: .42rem;
  background: repeating-linear-gradient(90deg, var(--accent) 0 2px, transparent 2px 11px);
  content: "";
}
.result__hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--s5); align-items: start; }
.result__range-block { min-width: 0; }
.result__start-card {
  display: grid;
  min-width: 7.5rem;
  min-height: 7.25rem;
  place-content: center;
  padding: var(--s3);
  border: 1px solid var(--accent);
  border-radius: var(--r-md);
  background: var(--accent-fill);
  text-align: center;
}
.result__start-card > span { color: var(--ink-muted); font-size: var(--xs); font-weight: 700; text-transform: uppercase; }
.result__start-card strong { font-size: 2.6rem; line-height: 1; letter-spacing: -.045em; font-variant-numeric: tabular-nums; }
.result__start-card small { color: var(--ink-muted); font-size: var(--sm); }
.result__start-card[data-mode="text"] strong { font-size: 1.65rem; letter-spacing: -.02em; }
.result[data-example="true"] .result__eyebrow { color: var(--caution); }

.size-options { display: grid; gap: var(--s2); margin-top: var(--s4); padding: var(--s3); border: 1px solid var(--rule); border-radius: var(--r-sm); background: var(--surface-soft); }
.size-options__label { color: var(--ink-muted); font-size: var(--xs); font-weight: 700; }
.size-options__buttons { display: flex; flex-wrap: wrap; gap: var(--s2); }
.size-options button {
  display: inline-flex;
  min-height: var(--tap);
  align-items: baseline;
  gap: .2rem;
  padding-inline: var(--s3);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink);
}
.size-options button:hover { border-color: var(--accent); background: var(--accent-fill); }
.size-options button strong { font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.size-options button span { color: var(--ink-muted); font-size: var(--xs); }

.actions { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.actions button { width: 100%; padding-inline: var(--s2); }
.actions #check-board { border-color: var(--accent); background: var(--accent); color: var(--surface); }
.actions #copy-result { border-color: var(--border); background: var(--surface); color: var(--ink); }

.fit-section, .charts-section { scroll-margin-top: var(--s4); }
.fit-section { padding-block: var(--s8); }
.fit-card { border-color: var(--border); }
.fit-inputs input::placeholder { color: var(--ink-muted); font-size: .78rem; opacity: .8; }
.fit-output { position: relative; }
.fit-output::before { position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--accent); content: ""; }

.chart-tabs {
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  width: min(100%, 20rem);
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.chart-tabs button {
  min-height: var(--tap);
  border: 2px solid transparent;
  border-radius: calc(var(--r-sm) - 2px);
  background: transparent;
  color: var(--ink-muted);
}
.chart-tabs button[aria-selected="true"] { border-color: var(--accent); background: var(--accent-fill); color: var(--ink); font-weight: 750; }
.chart-block { padding: var(--s4); border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface); }

@media (min-width: 640px) {
  .presets { overflow-x: visible; scroll-snap-type: none; }
}

@media (max-width: 639px) {
  .site-header { gap: var(--s3); }
  .scope-line { font-size: var(--sm); line-height: 1.4; }
  .control-heading-row { align-items: flex-start; flex-direction: column; gap: 0; }
  .control-heading-row > span { text-align: left; }
  .presets--primary .preset { min-height: 3.5rem; padding: .5rem .65rem; }
  .presets--special { grid-template-columns: 1fr; }
  .special-presets summary small { max-width: 10rem; text-align: right; }
  .field--weight { padding: var(--s3); }
  .field--weight .field__help { display: none; }
  .weight-example { margin-top: 0; }
  .result__hero { grid-template-columns: minmax(0, 1fr) 6.25rem; gap: var(--s3); }
  .result__start-card { min-width: 0; min-height: 6.25rem; padding: var(--s2); }
  .result__start-card strong { font-size: 2rem; }
  .result__headline { font-size: clamp(1.75rem, 9vw, 2.25rem); letter-spacing: -.04em; white-space: nowrap; }
  .ruler-wrap { margin-inline: -.5rem; }
  .ruler { width: calc(100% + 1rem); max-width: none; }
  .ruler text { fill: var(--ink); font-size: 20px; font-weight: 700; }
  .ruler__baseline, .ruler__tick { stroke-width: 1.5; }
  .ruler__tick--major { stroke: var(--ink); stroke-width: 2.4; }
  .ruler__pick-line { stroke-width: 2.5; }
  .ruler__height { stroke-width: 2; }
  .actions { grid-template-columns: 1fr 1fr; }
  .actions #check-board, .actions #print-result { grid-column: 1 / -1; }
  .fit-section { padding-block: var(--s6); }
  .fit-output::before { display: none; }
  .chart-block { padding: var(--s3); }
  .chart { min-width: 0; table-layout: fixed; }
  .chart th, .chart td { padding: .55rem .32rem; white-space: normal; font-size: .78rem; line-height: 1.3; }
  #weight-chart th:nth-child(1), #weight-chart td:nth-child(1) { width: 35%; }
  #weight-chart th:nth-child(2), #weight-chart td:nth-child(2) { width: 28%; }
  #weight-chart th:nth-child(3), #weight-chart td:nth-child(3) { width: 37%; }
  #weight-chart th:nth-child(4), #weight-chart td:nth-child(4) { display: none; }
  #height-chart th, #height-chart td { width: 33.333%; }
}
}

/* Shared single-page controls retained after the visual-instrument refactor. */
@layer components {
  .choice-compare__heading { display: grid; gap: var(--s1); margin-bottom: var(--s4); }
  .choice-compare__heading h3,
  .choice-compare__heading p { margin: 0; }
  .choice-compare__heading > p:last-child { color: var(--ink-muted); font-size: var(--sm); }
  .choice-compare__options { display: grid; gap: var(--s2); grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .choice-compare__options button {
    display: grid;
    gap: var(--s1);
    min-height: 4.25rem;
    padding: var(--s3);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface);
    color: var(--ink);
    text-align: start;
  }
  .choice-compare__options button span { color: var(--accent); font-weight: 700; font-variant-numeric: tabular-nums; }
  .choice-compare__options button small { color: var(--ink-muted); font-size: var(--xs); line-height: 1.4; }

  .width-spectrum { grid-column: 1 / -1; width: 100%; margin-top: var(--s3); }
  .width-spectrum__track {
    position: relative;
    height: 18px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: linear-gradient(to right, var(--accent-fill) 0 25%, var(--surface) 25% 50%, var(--accent-fill) 50% 75%, var(--surface) 75%);
  }
  .width-spectrum__marker {
    position: absolute;
    top: 1px;
    left: 0;
    width: 14px;
    height: 14px;
    transform: translateX(calc(var(--width-position, 50) * 1% - 7px));
    border: 2px solid var(--surface);
    border-radius: 50%;
    background: var(--accent);
    transition: transform var(--dur) var(--ease);
  }
  .width-spectrum__labels { display: grid; grid-template-columns: repeat(4, 1fr); margin-top: var(--s1); color: var(--ink-muted); font-size: var(--xs); }
  .width-spectrum__labels span:nth-child(2),
  .width-spectrum__labels span:nth-child(3) { text-align: center; }
  .width-spectrum__labels span:last-child { text-align: end; }
  .width-spectrum > p { margin: var(--s2) 0 0; color: var(--ink-muted); font-size: var(--xs); }

  .next-step {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--s4);
    margin-top: var(--s6);
    padding: var(--s4);
    border: 1px solid var(--rule);
    border-radius: var(--r-sm);
    background: var(--accent-fill);
  }
  .next-step > div { display: grid; gap: var(--s1); }
  .next-step span { color: var(--ink-muted); font-size: var(--sm); }
  .next-step button {
    flex: 0 0 auto;
    min-height: var(--tap);
    padding-inline: var(--s4);
    border: 1px solid var(--ink);
    border-radius: var(--r-sm);
    background: var(--ink);
    color: var(--surface);
  }
  .text-button {
    min-height: var(--tap);
    padding: 0 var(--s1);
    border: 0;
    background: transparent;
    color: var(--ink);
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 3px;
  }
}

@layer state {
  .choice-compare[hidden],
  .width-spectrum[hidden] { display: none; }
}

@media (max-width: 639px) {
  @layer components {
    .choice-compare__options { grid-template-columns: 1fr; }
    .next-step { align-items: stretch; flex-direction: column; }
    .next-step button { width: 100%; }
  }
}

@media (forced-colors: active) {
  @layer components {
    .choice-compare__options button[aria-pressed="true"] { border-color: Highlight; }
    .width-spectrum__marker { background: Highlight; }
  }
}

@layer print {
  @media print {
    .choice-compare,
    .next-step { display: none !important; }
  }
}

/* P7 visual instrument pass — reference-derived, data-first, no decorative 3D. */
@layer layout {
  .container { max-width: 94rem; }

  .site-header {
    width: 100%;
    max-width: none;
    align-items: center;
    gap: var(--s3);
    padding-block: .9rem;
    padding-inline: max(var(--gutter), calc((100vw - 94rem) / 2 + var(--gutter)));
    border: 0;
    background: var(--navy);
    color: #fff;
  }

  .calculator { gap: var(--s4); padding-block: var(--s4) var(--s8); }

  @media (min-width: 1100px) {
    .calculator {
      grid-template-columns: minmax(20rem, 22.5rem) minmax(0, 1fr);
      gap: var(--s5);
    }
    .result { position: static; }
  }
}

@layer components {
  .svg-definitions {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
  }

  .site-header .brand,
  .site-header h1 { color: #fff; }
  .site-header .header-copy { gap: .2rem; }
  .site-header .header-copy h1 { max-width: none; font-size: clamp(1.7rem, 1.28rem + 1.35vw, 2.35rem); }
  .site-header .brand__mark { color: #7db6ff; }
  .site-header .scope-line { max-width: 52rem; color: #c8d6e9; font-size: .9rem; line-height: 1.35; }
  .site-header .segmented { border-color: #6f86a7; background: var(--navy-soft); }
  .site-header .segmented span { color: #d7e3f3; }
  .site-header .segmented input:checked + span { border-color: #84baff; background: #163d75; color: #fff; }

  .controls,
  .result,
  .anatomy-panel,
  .width-panel,
  .fit-card,
  .chart-block {
    border: 1px solid var(--rule);
    background: var(--surface);
    box-shadow: var(--panel-shadow);
  }

  .controls {
    min-width: 0;
    padding: var(--s5);
    border-radius: var(--r-md);
  }

  .panel-heading {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: var(--s3);
    align-items: start;
  }
  .panel-heading--controls { margin-bottom: var(--s4); }
  .panel-heading--result { margin-bottom: var(--s3); padding-bottom: var(--s2); border-bottom: 1px solid var(--rule); }
  .panel-heading h2,
  .panel-heading p { margin: 0; }
  .panel-heading h2,
  .panel-title { color: var(--ink); font-size: 1rem; font-weight: 800; letter-spacing: -.01em; }
  .panel-heading > div > p:last-child { margin-top: 2px; color: var(--ink-muted); font-size: var(--xs); }

  .step-badge {
    display: grid;
    width: 1.55rem;
    height: 1.55rem;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: var(--xs);
    font-weight: 800;
  }

  .panel-status {
    padding: .25rem .48rem;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    color: var(--ink-muted);
    font-size: var(--xs);
    font-weight: 750;
  }
  .panel-status[data-level="high"] { border-color: var(--result); background: var(--result-fill); color: var(--result); }
  .panel-status[data-level="medium"] { border-color: var(--caution); background: var(--caution-fill); color: var(--caution); }

  .presets-wrap { margin-bottom: var(--s4); }
  .presets--primary .preset { min-height: 3.55rem; }
  .field--weight { border-color: var(--rule); box-shadow: none; }

  .result {
    padding: var(--s4) var(--s5) var(--s5);
    overflow: hidden;
    border-radius: var(--r-md);
  }
  .result::before { display: none; }
  .result__hero { align-items: stretch; }
  .result__headline { color: var(--ink); }
  .result__start-card { min-width: 6.75rem; min-height: 6.25rem; border-color: var(--result); background: var(--result-fill); }
  .result__start-card strong { color: var(--result); }

  .board-shape__body { fill: currentColor; stroke: currentColor; stroke-width: 1.4; }
  .board-shape__center { fill: none; stroke: currentColor; stroke-width: 1; opacity: .24; }
  .board-shape__holes { fill: var(--surface); stroke: currentColor; stroke-width: .7; }

  .scale-scene {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(12.5rem, 15rem);
    grid-template-areas: "visual compare" "note compare";
    gap: var(--s2) var(--s3);
    margin-top: var(--s3);
    padding: var(--s3);
    border: 1px solid var(--rule);
    border-radius: var(--r-md);
    background: var(--surface-soft);
  }
  .scale-scene__visual { grid-area: visual; display: grid; grid-template-columns: 2.75rem minmax(0, 1fr); min-height: 17.25rem; }
  .scale-scene__note { grid-area: note; margin: 0; color: var(--ink-muted); font-size: var(--xs); }

  .scale-axis { position: relative; min-height: 17.25rem; border-right: 1px solid var(--border); color: var(--ink-muted); font-size: .68rem; font-variant-numeric: tabular-nums; }
  .scale-axis span { position: absolute; right: .42rem; transform: translateY(50%); }
  .scale-axis [data-axis-value="200"] { bottom: 93%; }
  .scale-axis [data-axis-value="180"] { bottom: 80%; }
  .scale-axis [data-axis-value="160"] { bottom: 67%; }
  .scale-axis [data-axis-value="140"] { bottom: 54%; }
  .scale-axis [data-axis-value="120"] { bottom: 41%; }
  .scale-axis [data-axis-value="100"] { bottom: 28%; }
  .scale-axis b { position: absolute; top: 0; left: .25rem; color: var(--ink); font-size: .65rem; }

  .scale-stage {
    position: relative;
    min-height: 17.25rem;
    overflow: hidden;
    border-bottom: 2px solid var(--border);
    background: repeating-linear-gradient(to top, transparent 0 38px, color-mix(in srgb, var(--rule) 70%, transparent) 38px 39px);
  }

  .scale-line {
    position: absolute;
    z-index: 1;
    right: 0;
    left: 0;
    border-top: 1px dashed var(--result);
    color: var(--result);
    pointer-events: none;
  }
  .scale-line b { position: absolute; left: .3rem; bottom: .15rem; padding: 0 .22rem; background: var(--surface-soft); font-size: .65rem; }

  .scene-rider {
    position: absolute;
    z-index: 2;
    bottom: 0;
    left: 4%;
    display: flex;
    width: 5.2rem;
    min-height: 11rem;
    align-items: center;
    flex-direction: column;
    justify-content: end;
    color: var(--navy);
    opacity: .38;
    transition: height var(--dur) var(--ease), opacity var(--dur) var(--ease);
  }
  .scene-rider[data-scaled="true"] { opacity: .88; }
  .scene-rider__figure { width: 100%; height: 100%; overflow: visible; fill: currentColor; }
  .scene-rider__label { position: absolute; top: .2rem; left: 50%; width: 7rem; transform: translate(-50%, -100%); color: var(--ink-muted); font-size: .63rem; text-align: center; }

  .scene-boards {
    position: absolute;
    z-index: 2;
    right: 1%;
    bottom: 0;
    left: 28%;
    display: flex;
    height: 100%;
    align-items: end;
    justify-content: space-around;
    gap: var(--s2);
  }
  .scene-board { display: grid; height: 100%; min-width: 4rem; justify-items: center; align-content: end; color: #b9c3d0; }
  .scene-board__shape { width: 3.2rem; height: 12rem; overflow: visible; transition: height var(--dur) var(--ease), color var(--dur) var(--ease), transform var(--dur) var(--ease); }
  .scene-board--target { color: var(--result); }
  .scene-board--target .scene-board__shape { width: 3.65rem; }
  .scene-board__number { margin-bottom: .3rem; color: var(--ink); font-size: .68rem; white-space: nowrap; }
  .scene-board__number strong { font-size: .9rem; font-variant-numeric: tabular-nums; }
  .scene-board small { margin-top: .25rem; color: var(--ink-muted); font-size: .62rem; font-weight: 700; }
  .scale-scene[data-model-specific="true"] .scene-board { color: #b9c3d0; }
  .scale-scene[data-model-specific="true"] .scene-board--target .scene-board__shape { width: 3.2rem; }

  .choice-compare {
    grid-area: compare;
    margin: 0;
    padding: 0 0 0 var(--s3);
    border: 0;
    border-left: 1px solid var(--rule);
  }
  .choice-compare__heading { margin-bottom: var(--s3); }
  .choice-compare__heading h3 { font-size: .95rem; }
  .choice-compare__heading > p:last-child { font-size: .72rem; }
  .choice-compare__options { grid-template-columns: 1fr; gap: var(--s2); }
  .choice-compare__options button {
    grid-template-columns: minmax(4.8rem, .75fr) minmax(4.2rem, .65fr);
    min-height: 3.9rem;
    align-items: center;
    gap: .2rem .5rem;
    padding: .55rem .65rem;
    border-color: var(--rule);
    background: var(--surface);
  }
  .choice-compare__options button small { grid-column: 1 / -1; font-size: .67rem; }
  .choice-compare__options button[aria-pressed="true"] { border-color: var(--result); background: var(--result-fill); }
  .choice-compare__options button span { color: var(--result); }

  .ruler-wrap { margin-top: var(--s3); padding-top: var(--s3); }
  .ruler { aspect-ratio: 640 / 150; max-height: 7.5rem; }

  .visual-guide { padding-block: var(--s4) var(--s8); }
  .visual-guide__heading { margin-bottom: var(--s4); }
  .visual-guide__grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(19rem, .75fr); gap: var(--s4); }
  .anatomy-panel,
  .width-panel { min-width: 0; padding: var(--s4); border-radius: var(--r-md); }
  .visual-panel__header { display: flex; align-items: start; justify-content: space-between; gap: var(--s4); }
  .visual-panel__header h3,
  .visual-panel__header p { margin: 0; }
  .visual-panel__header h3 { margin-top: 2px; }

  .anatomy-modes { display: inline-flex; padding: 2px; border: 1px solid var(--border); border-radius: var(--r-sm); background: var(--surface-soft); }
  .anatomy-modes button { min-height: 2.2rem; padding-inline: .65rem; border: 1px solid transparent; border-radius: calc(var(--r-sm) - 2px); background: transparent; color: var(--ink-muted); font-size: var(--xs); }
  .anatomy-modes button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-fill); color: var(--ink); font-weight: 750; }

  .anatomy-diagram { width: 100%; min-height: 17rem; margin-top: var(--s3); color: var(--accent); }
  .anatomy-diagram__board { color: #c8d1dc; }
  .anatomy-diagram__board--base { color: #d8dee7; }
  .anatomy-diagram__view-label { fill: var(--ink); font-size: 13px; font-weight: 750; }
  .anatomy-measure { opacity: .16; transition: opacity var(--dur) var(--ease); }
  .anatomy-measure line,
  .anatomy-measure path { fill: none; stroke: var(--accent); stroke-width: 1.8; }
  .anatomy-measure text { fill: var(--accent); font-size: 12px; font-weight: 750; }
  #measure-arrow path { fill: var(--accent); }
  .anatomy-diagram[data-mode="length"] [data-anatomy-group="length"],
  .anatomy-diagram[data-mode="width"] [data-anatomy-group="width"],
  .anatomy-diagram[data-mode="shape"] [data-anatomy-group="shape"] { opacity: 1; }
  .anatomy-copy { min-height: 2.7rem; margin: 0; color: var(--ink-muted); font-size: var(--sm); }

  .width-panel { display: flex; flex-direction: column; }
  .width-board-grid { display: flex; flex: 1; align-items: end; justify-content: space-around; gap: var(--s2); margin-top: var(--s5); }
  .width-board { display: grid; min-width: 3.5rem; justify-items: center; gap: .18rem; color: #b8c2cf; text-align: center; }
  .width-board svg { height: 9rem; overflow: visible; color: inherit; }
  .width-board:nth-child(1) svg { width: 2.15rem; }
  .width-board:nth-child(2) svg { width: 2.55rem; }
  .width-board:nth-child(3) svg { width: 2.95rem; }
  .width-board:nth-child(4) svg { width: 3.35rem; }
  .width-board strong { color: var(--ink); font-size: .78rem; }
  .width-board span { color: var(--ink-muted); font-size: .65rem; }
  .width-board[data-current="true"] { color: var(--result); }
  .width-board[data-current="true"] strong { color: var(--result); }
  .width-board[data-current="true"] svg { filter: drop-shadow(0 5px 8px rgb(8 122 82 / .18)); }
  .width-visual-copy { margin: var(--s4) 0 var(--s3); color: var(--ink-muted); font-size: var(--sm); }
  .width-panel .secondary-button { align-self: start; }

  .fit-card { gap: var(--s4); }
  .fit-visual { display: grid; place-items: center; min-height: 15rem; padding: var(--s3); border-inline: 1px solid var(--rule); color: #b9c3d0; }
  .fit-visual[data-active="true"] { color: var(--result); }
  .fit-visual__board-wrap { position: relative; display: grid; place-items: center; min-width: 8rem; }
  .fit-visual__board { width: 3.5rem; height: 11rem; overflow: visible; transition: height var(--dur) var(--ease), width var(--dur) var(--ease); }
  .fit-visual__length,
  .fit-visual__waist { position: absolute; padding: .18rem .35rem; border-radius: var(--r-sm); background: var(--surface); color: var(--ink-muted); font-size: .68rem; font-weight: 750; white-space: nowrap; }
  .fit-visual__length { top: 50%; left: -1rem; transform: translate(-100%, -50%); }
  .fit-visual__waist { right: -1rem; bottom: 35%; transform: translateX(100%); }
  .fit-visual > p { margin: var(--s2) 0 0; color: var(--ink-muted); font-size: .66rem; text-align: center; }

  .verdict-list { gap: var(--s3); }
  .verdict { position: relative; overflow: hidden; padding: var(--s3); border-color: var(--rule); background: var(--surface); }
  .verdict__meter { position: relative; grid-column: 1 / -1; height: .55rem; margin-top: var(--s2); border-radius: .3rem; background: var(--surface-soft); }
  .verdict__meter-range { position: absolute; top: 0; bottom: 0; border-radius: inherit; background: var(--result-fill); }
  .verdict__meter-marker { position: absolute; top: -.2rem; width: 2px; height: .95rem; background: currentColor; }
  .verdict__meter-marker::before { position: absolute; top: -.22rem; left: 50%; width: .42rem; height: .42rem; transform: translateX(-50%); border: 2px solid var(--surface); border-radius: 50%; background: currentColor; content: ""; }

  .range-map { display: grid; gap: .25rem; margin-block: var(--s3) var(--s4); padding: var(--s4); border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--surface-soft); }
  .range-map__header,
  .range-map__row { display: grid; grid-template-columns: minmax(6.2rem, .78fr) minmax(9rem, 2fr) minmax(4.8rem, .62fr); gap: var(--s2); align-items: center; }
  .range-map__header { padding-bottom: .35rem; color: var(--ink-muted); font-size: .67rem; font-weight: 750; }
  .range-map__header span:last-child { text-align: right; }
  .range-map__bars { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .3rem var(--s4); }
  .range-map__row { padding: .25rem .4rem; border-radius: var(--r-sm); font-size: .7rem; }
  .range-map__row[data-current="true"] { background: var(--result-fill); color: var(--result); font-weight: 750; }
  .range-map__track { position: relative; height: .62rem; border-radius: .32rem; background: #dfe7f1; }
  .range-map__bar { position: absolute; top: 0; bottom: 0; border-radius: inherit; background: #afc5e3; }
  .range-map__row[data-current="true"] .range-map__bar { background: var(--result); }
  .range-map__value { text-align: right; font-variant-numeric: tabular-nums; }
  .range-map__axis { display: grid; grid-template-columns: repeat(5, 1fr); padding-left: calc(6.2rem + var(--s2)); color: var(--ink-muted); font-size: .62rem; }
  .range-map__axis span:not(:first-child):not(:last-child) { text-align: center; }
  .range-map__axis span:last-child { text-align: right; }
  .range-map__feel { display: flex; justify-content: space-between; color: var(--ink-muted); font-size: .65rem; }
  .exact-chart-label { margin: var(--s3) 0 0; color: var(--ink-muted); font-size: var(--xs); font-weight: 750; text-transform: uppercase; }

}

@layer state {
  .result[data-state="empty"] .scale-scene,
  .result[data-state="no-result"] .scale-scene { display: none; }
  .result[data-example="true"] .next-step,
  .result[data-example="true"] .actions,
  .result[data-example="true"] .status { display: none; }
  .scale-scene[hidden],
  .range-map[hidden] { display: none; }
}

@media (min-width: 900px) {
  @layer components {
    .fit-card { grid-template-columns: minmax(0, 1fr) minmax(9rem, .42fr) minmax(20rem, .95fr); }
    .fit-output { padding-left: var(--s4); }
    .range-map__bars { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  }
}

@media (max-width: 1099px) {
  @layer components {
    .scale-scene { grid-template-columns: 1fr; grid-template-areas: "visual" "compare" "note"; }
    .choice-compare { padding: var(--s3) 0 0; border-top: 1px solid var(--rule); border-left: 0; }
    .choice-compare__options { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .visual-guide__grid { grid-template-columns: 1fr; }
    .fit-visual { border-inline: 0; border-block: 1px solid var(--rule); }
  }
}

@media (max-width: 899px) {
  @layer components {
    .fit-card { grid-template-columns: 1fr; }
    .fit-output { padding: var(--s4) 0 0; border-top: 1px solid var(--rule); border-left: 0; }
    .range-map__bars { grid-template-columns: 1fr; }
  }
}

@media (max-width: 639px) {
  @layer components {
    .site-header { gap: .5rem; padding-block: .55rem; }
    .site-header .header-copy h1 { font-size: 1.5rem; line-height: 1.08; }
    .site-header .scope-line { font-size: .82rem; line-height: 1.3; }
    .site-header .unit-choice { width: 100%; }
    .controls,
    .result { padding: var(--s4); }
    .panel-heading--controls { margin-bottom: .65rem; }
    .panel-heading--controls > div > p { display: none; }
    .presets-wrap { margin-bottom: var(--s3); }
    .presets--primary .preset { min-height: 3.1rem; }
    .panel-heading { grid-template-columns: auto minmax(0, 1fr); }
    .panel-heading .panel-status { grid-column: 2; width: fit-content; }
    .result__hero { grid-template-columns: minmax(0, 1fr) 5.7rem; }
    .result__start-card { min-width: 0; min-height: 5.35rem; }
    .quick-result { margin-block: .6rem .75rem; padding: .6rem .75rem; }
    .scale-scene { margin-inline: -.2rem; padding: var(--s3); }
    .scale-scene__visual { grid-template-columns: 2.25rem minmax(0, 1fr); min-height: 16.5rem; }
    .scale-axis,
    .scale-stage { min-height: 16.5rem; }
    .scene-rider { left: 1%; width: 4rem; }
    .scene-boards { left: 22%; }
    .scene-board { min-width: 3.2rem; }
    .scene-board__shape { width: 2.55rem; }
    .scene-board--target .scene-board__shape { width: 2.9rem; }
    .choice-compare__options { grid-template-columns: 1fr; }
    .choice-compare__options button { grid-template-columns: minmax(4.5rem, .65fr) minmax(4.7rem, .65fr) 1.4fr; min-height: var(--tap); }
    .choice-compare__options button small { grid-column: auto; text-align: right; }
    .visual-guide { padding-block: var(--s3) var(--s6); }
    .visual-panel__header { align-items: stretch; flex-direction: column; }
    .anatomy-modes { width: 100%; }
    .anatomy-modes button { flex: 1; }
    .anatomy-diagram { min-height: 13.5rem; }
    .width-board-grid { gap: .25rem; }
    .width-board { min-width: 0; }
    .width-board svg { height: 7rem; }
    .width-board strong { font-size: .68rem; }
    .width-board span { display: none; }
    .fit-visual { min-height: 12rem; }
    .range-map { padding: var(--s3); overflow: hidden; }
    .range-map__bars { grid-template-columns: 1fr; }
    .range-map__header,
    .range-map__row { grid-template-columns: minmax(5.5rem, .85fr) minmax(7.2rem, 1.7fr) minmax(4.3rem, .65fr); gap: .35rem; }
    .range-map__axis { padding-left: calc(5.5rem + .35rem); }
  }
}

@media (forced-colors: active) {
  @layer components {
    .scene-board--target,
    .width-board[data-current="true"],
    .range-map__row[data-current="true"] { color: Highlight; }
    .anatomy-measure line,
    .anatomy-measure path { stroke: Highlight; }
    .range-map__bar { background: CanvasText; }
  }
}

@layer print {
  @media print {
    .scale-scene,
    .visual-guide,
    .fit-visual,
    .range-map { break-inside: avoid; box-shadow: none; }
    .anatomy-modes,
    .width-panel .secondary-button { display: none !important; }
  }
}
