:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #16181a;
  background: #fff;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #16181a;
  --muted: #6d7378;
  --line: #e5e7e9;
  --soft: #f6f7f8;
}

* { box-sizing: border-box; }
body { min-width: 320px; margin: 0; background: #fff; }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }
.app-shell { width: min(1260px, calc(100% - 48px)); margin: 0 auto; }
.site-header { height: 68px; display: flex; align-items: center; border-bottom: 1px solid var(--line); }
.site-header h1 { margin: 0; font-size: 20px; line-height: 1; font-weight: 650; letter-spacing: -.55px; }

.controls { display: grid; grid-template-columns: 160px minmax(280px, 1fr) 150px 150px; gap: 22px; align-items: end; padding: 19px 0 20px; border-bottom: 1px solid var(--line); }
.control-group { min-width: 0; padding: 0; margin: 0; border: 0; }
.control-group legend { margin: 0 0 7px; padding: 0; color: #555b60; font-size: 11px; font-weight: 600; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; min-height: 38px; border: 1px solid #d9dcdf; border-radius: 6px; padding: 2px; background: #f8f9fa; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label span { display: grid; height: 32px; place-items: center; border-radius: 4px; color: #646a70; font-size: 12px; }
.segmented input:checked + span { color: var(--ink); background: #fff; box-shadow: 0 1px 3px #0000001a; font-weight: 600; }
.segmented input:focus-visible + span { outline: 2px solid #73797e; outline-offset: 1px; }
.age-tabs { display: flex; gap: 3px; padding: 0 0 7px; }
.age-tabs button { border: 0; border-radius: 4px; padding: 5px 9px; color: #72777c; background: transparent; font-size: 11px; cursor: pointer; }
.age-tabs button[aria-selected="true"] { color: var(--ink); background: #eff0f1; font-weight: 600; }
.age-tabs button:focus-visible { outline: 2px solid #73797e; outline-offset: 1px; }
.age-entry, .date-entry { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.input-unit { position: relative; display: flex; align-items: center; min-width: 0; height: 38px; border: 1px solid #d9dcdf; border-radius: 6px; background: #fff; }
.input-unit:focus-within, .date-entry label:focus-within { border-color: #888e93; box-shadow: 0 0 0 2px #0000000b; }
.input-unit input { width: 100%; min-width: 0; height: 100%; padding: 0 9px; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: 13px; }
.input-unit input::placeholder { color: #a0a5a9; }
.input-unit > span { flex: none; padding: 0 9px 0 2px; color: #777d82; font-size: 11px; }
.date-entry label { display: flex; min-width: 0; flex-direction: column; gap: 4px; color: #70767b; font-size: 9px; }
.date-entry input { width: 100%; height: 30px; min-width: 0; padding: 0 7px; border: 1px solid #d9dcdf; border-radius: 6px; outline: 0; background: #fff; color: var(--ink); font-size: 11px; }
.date-entry input:focus { border-color: #888e93; box-shadow: 0 0 0 2px #0000000b; }
.measurement-control .input-unit { width: 100%; }

.charts { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; padding: 18px 0 36px; }
.chart-tools { display: flex; align-items: center; justify-content: flex-end; gap: 18px; min-height: 30px; }
.dataset-tag { color: #858b90; font-size: 10px; white-space: nowrap; }
.plot-toggle { display: inline-flex; align-items: center; gap: 6px; color: #666d72; font-size: 10px; white-space: nowrap; cursor: pointer; user-select: none; }
.plot-toggle input { width: 14px; height: 14px; margin: 0; accent-color: #202428; }
.plot-toggle input:focus-visible { outline: 2px solid #73797e; outline-offset: 2px; }
.dataset-mode { width: min(345px, 100%); margin-left: auto; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dataset-mode label span, .zoom-mode label span { font-size: 10px; }
.zoom-mode { width: 220px; margin-left: 0; }
.chart-panel { min-width: 0; }
.chart-header { display: flex; align-items: baseline; min-height: 34px; gap: 10px; }
.chart-header h2 { margin: 0; font-size: 15px; font-weight: 650; letter-spacing: -.25px; }
.chart-results { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.chart-result { display: inline-flex; align-items: baseline; gap: 4px; color: #24282b; font-size: 12px; white-space: nowrap; }
.chart-result strong { font-size: 12px; font-weight: 650; }
.result-source { color: #73797e; font-size: 9px; font-weight: 500; }
.selected-result, .selected-result .result-source { color: #2671cf; }
.selected-result[hidden], .original-result[hidden] { display: none; }
.chart-canvas { width: 100%; overflow: hidden; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: #eceef0; stroke-width: 1; }
.chart-axis { stroke: #cfd3d6; stroke-width: 1; }
.chart-tick { fill: #7c8287; font: 10px Inter, ui-sans-serif, system-ui, sans-serif; }
.chart-axis-label { fill: #62686d; font: 9px Inter, ui-sans-serif, system-ui, sans-serif; }
.curve-line { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.curve-line.p50 { stroke: #111315; stroke-width: 2.5; opacity: 1; }
.curve-line.selected-curve { stroke: #2671cf; }
.curve-line.selected-curve.p50 { stroke: #2671cf; }
.legend-item.selected { color: #2671cf; font-weight: 650; }
.legend-line.selected { height: 2.5px; background: #2671cf !important; }
.measurement-dot { fill: #fff; stroke: #111315; stroke-width: 2.5; }
.chart-legend { min-height: 25px; display: flex; align-items: center; justify-content: center; gap: clamp(9px, 1.4vw, 20px); flex-wrap: wrap; padding: 1px 0 3px; color: #676d72; font-size: 10px; }
.legend-item { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.legend-line { width: 17px; height: 2px; border-radius: 2px; }
.legend-item.p50 { color: #141719; font-weight: 700; }
.legend-item.p50 .legend-line { height: 3px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 900px) {
  .app-shell { width: min(760px, calc(100% - 36px)); }
  .controls { grid-template-columns: 1fr 2fr 1fr 1fr; gap: 11px; }
  .chart-tools { flex-wrap: wrap; justify-content: flex-start; gap: 10px 14px; }
  .dataset-mode { margin-left: 0; }
  .charts { gap: 16px; }
  .chart-legend { gap: 8px 12px; }
}
@media (max-width: 650px) {
  .app-shell { width: calc(100% - 28px); }
  .site-header { height: 58px; }
  .site-header h1 { font-size: 18px; }
  .controls { grid-template-columns: 1fr 1fr; gap: 15px 11px; padding: 15px 0 16px; }
  .sex-control { grid-column: 1; }
  .age-control { grid-column: 2; grid-row: span 2; }
  .measurement-control { grid-column: auto; }
  .age-tabs { padding-bottom: 5px; }
  .age-tabs button { padding: 5px 7px; }
  .date-entry { grid-template-columns: 1fr; gap: 5px; }
  .date-entry label { height: auto; }
  .date-entry input { font-size: 10px; }
  .age-entry { gap: 5px; }
  .input-unit { height: 36px; }
  .chart-tools { gap: 9px 12px; }
  .dataset-mode { width: min(345px, 100%); }
  .charts { grid-template-columns: 1fr; gap: 23px; padding-top: 17px; }
  .chart-header { min-height: 30px; }
  .chart-svg { max-height: 285px; }
}
