:root {
  color-scheme: light;
  --ink: #16223d;
  --muted: #60708f;
  --blue: #2259d7;
  --blue-soft: #e9f0ff;
  --red: #ef4444;
  --green: #16856b;
  --green-soft: #e6f5f0;
  --line: #d9e1ed;
  --grid: #edf1f6;
  --surface: #ffffff;
  --background: #f1f5fb;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 5%, rgba(34, 89, 215, .07), transparent 28rem),
    var(--background);
  font-family: "DM Sans", system-ui, sans-serif;
}

button, input { font: inherit; }

.page-shell {
  width: min(1760px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 510px);
  gap: 42px;
  align-items: center;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--blue);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .15em;
}

h1 {
  margin: 0;
  font-size: clamp(44px, 5.3vw, 78px);
  line-height: .96;
  letter-spacing: -.055em;
}

.hero-copy {
  margin: 0;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.65;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  padding: 8px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, .78);
}

.tab {
  min-height: 56px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  transition: color .18s, background .18s, transform .18s;
}

.tab:hover { color: var(--ink); background: #f4f7fb; }
.tab:active { transform: scale(.99); }
.tab:focus-visible { outline: 3px solid rgba(34, 89, 215, .25); outline-offset: 2px; }
.tab.is-active { color: #fff; background: var(--ink); }

.lab-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: 0 22px 60px rgba(22, 34, 61, .09);
}

.lab-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  padding: 24px 30px 22px;
  border-bottom: 1px solid var(--line);
}

h2 { margin: 0 0 4px; font-size: 21px; }
.lab-heading p { margin: 0; color: var(--muted); font-size: 16px; }

.stage-summary { text-align: right; }
.stage-summary span, .selected-reading > span, .milestone span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .12em;
}
.stage-summary strong { color: var(--blue); font-size: 17px; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  min-height: 530px;
}

.chart-column {
  min-width: 0;
  padding: 22px 26px 14px;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 36px 36px;
}

.chart-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin: 0 8px 10px 56px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.curve-key { display: inline-flex; align-items: center; gap: 8px; }
.curve-key i { width: 24px; height: 3px; border-radius: 2px; background: var(--red); }
.chart-legend { display: inline-flex; flex-wrap: wrap; gap: 8px 18px; }
.buffer-key { display: inline-flex; align-items: center; gap: 8px; }
.buffer-key[hidden] { display: none; }
.buffer-key i { width: 24px; height: 12px; border-radius: 2px; background: rgba(22, 133, 107, .12); }

.chart-wrap {
  position: relative;
  height: 440px;
  touch-action: none;
  cursor: crosshair;
}

canvas { display: block; width: 100%; height: 100%; }

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 118px;
  padding: 9px 11px;
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 10px;
  color: #fff;
  background: rgba(22, 34, 61, .95);
  box-shadow: 0 8px 24px rgba(22, 34, 61, .18);
  pointer-events: none;
  transform: translate(12px, -50%);
}
.chart-tooltip strong, .chart-tooltip span { display: block; }
.chart-tooltip strong { font-size: 14px; }
.chart-tooltip span { margin-top: 1px; color: #cfd7e7; font-size: 12px; }
.chart-help { margin: 8px 0 0; color: var(--muted); text-align: center; font-size: 12px; }

.inspector {
  padding: 26px;
  border-left: 1px solid var(--line);
  background: #fbfcfe;
}

.selected-reading {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}
.selected-reading strong { display: block; font-size: 33px; letter-spacing: -.04em; }
.selected-reading p { margin: 2px 0 0; color: var(--muted); }

.species-panel { padding: 22px 0; }
.panel-title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
h3 { margin: 0; font-size: 16px; }
.buffer-badge { padding: 4px 8px; border-radius: 999px; color: var(--green); background: var(--green-soft); font-size: 10px; font-weight: 700; letter-spacing: .09em; }
.species-note { min-height: 42px; margin: 9px 0 14px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.species-list { margin: 0; }
.species-list div { display: flex; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.species-list dt { color: var(--muted); }
.species-list dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.milestone { margin-top: 8px; padding: 14px 15px; border-left: 3px solid var(--blue); background: var(--blue-soft); }
.milestone span { color: var(--blue); }
.milestone p { margin: 0; font-size: 13px; line-height: 1.45; }

.controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 60px;
  padding: 22px 30px 26px;
  border-top: 1px solid var(--line);
}

.control > span, .control small { display: flex; justify-content: space-between; gap: 16px; }
.control > span { margin-bottom: 11px; }
.control b { font-size: 14px; }
.control output { color: var(--blue); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }
.control small { margin-top: 5px; color: var(--muted); font-size: 11px; }

input[type="range"] {
  width: 100%;
  height: 5px;
  margin: 6px 0;
  border-radius: 99px;
  accent-color: var(--blue);
  cursor: pointer;
}
input[type="range"]:focus-visible { outline: 3px solid rgba(34, 89, 215, .25); outline-offset: 5px; }

@media (max-width: 980px) {
  .page-shell { width: min(100% - 28px, 1760px); }
  .hero { grid-template-columns: 1fr; gap: 16px; }
  .hero-copy { max-width: 680px; }
  .workspace { grid-template-columns: 1fr; }
  .inspector { display: grid; grid-template-columns: .8fr 1.2fr; gap: 22px; border-top: 1px solid var(--line); border-left: 0; }
  .selected-reading { border-bottom: 0; }
  .milestone { grid-column: 1 / -1; }
}

@media (max-width: 680px) {
  .page-shell { width: min(100% - 18px, 1760px); padding-top: 18px; }
  h1 { font-size: 43px; }
  .hero-copy { font-size: 16px; }
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .tab { min-height: 48px; font-size: 14px; }
  .lab-heading { align-items: flex-start; padding: 20px; }
  .stage-summary { max-width: 135px; }
  .chart-column { padding: 18px 10px 12px; }
  .chart-toolbar { margin-left: 48px; }
  .chart-wrap { height: 390px; }
  .inspector { display: block; padding: 22px; }
  .selected-reading { padding-bottom: 20px; border-bottom: 1px solid var(--line); }
  .controls { grid-template-columns: 1fr; gap: 24px; padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
