:root {
  --bg: #fbfbfa;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5c6370;
  --accent: #2f6f5e;
  --energy: #3f5a86;
  --steps: #8a8f98;
  --cycle: #9a5f7e;
  --lab: #8a6a2f;
  --border: #e6e6e3;
  --radius: 14px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); }

.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;
}

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* Top bar with the persistent demo label */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(251, 251, 250, 0.94);
  backdrop-filter: saturate(1.4) blur(8px);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner, main, footer {
  max-width: 1040px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.topbar-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  min-height: 52px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
.brand-mark { width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }

.demo-label {
  margin: 0;
  padding: 4px 12px;
  border: 1px solid var(--text);
  border-radius: 999px;
  background: var(--surface);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

main > section { padding: 40px 0; border-bottom: 1px solid var(--border); scroll-margin-top: 64px; }
main > section:last-child { border-bottom: 0; }

h1 {
  margin: 0 0 6px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  font-weight: 650;
  letter-spacing: -0.03em;
}

h2 {
  margin: 0 0 6px;
  font-size: clamp(21px, 2.6vw, 26px);
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.lede { margin: 0; font-size: 17px; color: var(--muted); }
.fine { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.sub { margin: 0 0 16px; font-size: 15px; color: var(--muted); max-width: 52em; }

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 20px;
  border: 1px solid var(--text);
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.button:hover { background: var(--accent); border-color: var(--accent); }
.button.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.button.secondary:hover { border-color: var(--text); background: var(--surface); }

.text-button {
  min-height: 36px;
  padding: 6px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Hero: introduction and guided start, kept short so the timeline is in the first view */
main > section.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 420px);
  align-items: center;
  gap: 16px 32px;
  padding: 24px 0 20px;
  border-bottom: 0;
}
.guide {
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.guide-who { margin: 0 0 4px; font-size: 13px; color: var(--muted); }
.guide-who strong { color: var(--text); }
.question { margin: 0 0 12px; font-size: 17px; font-weight: 500; line-height: 1.35; }
.guide .button { min-height: 40px; padding: 8px 18px; font-size: 14px; }

/* Timeline */
main > section.timeline { padding-top: 0; }
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  margin-bottom: 10px;
}
.toolbar-label { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.events { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.event-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 5px 14px 5px 5px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.event-chip:hover { border-color: var(--text); }
.event-chip[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); background: #f3f8f6; }
.event-letter {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.event-chip[aria-pressed="true"] .event-letter { background: var(--accent); }
.muted { color: var(--muted); }

.segmented {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
}
.segmented button {
  min-height: 34px;
  padding: 4px 14px;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--text); color: #fff; }

.selected-note { margin: 0 0 10px; font-size: 14px; color: var(--muted); }
.selected-note strong { color: var(--text); }

.charts {
  padding: 0 12px 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.readout {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 16px;
  min-height: 42px;
  margin: 0 -12px 2px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.readout strong { font-weight: 600; }
.readout .missing { color: var(--muted); font-style: italic; }
.chart-block { padding: 8px 0 4px; }
.chart-block + .chart-block { border-top: 1px solid var(--border); }
.chart-title { margin: 0 0 2px; font-size: 13.5px; font-weight: 600; }
.chart-title .unit { margin-left: 6px; font-weight: 400; color: var(--muted); }
.chart { width: 100%; }
.chart .u-over { cursor: crosshair; }

.timeline-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 24px; margin-top: 8px; }
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--muted); }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.legend-lab { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.key { display: inline-grid; place-items: center; width: 18px; height: 18px; font-size: 10px; font-weight: 700; color: #fff; }
.key-note { border-radius: 50%; background: var(--text); }
.key-lab { border-radius: 4px; background: var(--lab); }
.key-shade { width: 22px; height: 12px; background: rgba(47, 111, 94, 0.16); border: 1px solid rgba(47, 111, 94, 0.35); }

.data-table { margin-top: 10px; }
.data-table summary, .how summary { cursor: pointer; color: var(--accent); font-weight: 500; font-size: 14px; padding: 6px 0; }
.data-table .table-scroll { max-height: 360px; overflow: auto; margin-top: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.data-table thead th { position: sticky; top: 0; background: var(--surface); }

/* Tables */
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; font-size: 13px; color: var(--muted); }
tbody tr:last-child td, tbody tr:last-child th { border-bottom: 0; }
td.num { font-variant-numeric: tabular-nums; }
.not-recorded { color: var(--muted); font-style: italic; }
.value { display: block; font-size: 16px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--text); }
.count { display: block; font-size: 12.5px; font-weight: 400; color: var(--muted); }

/* Comparison */
.compare-table, .lab-table { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; border-collapse: separate; border-spacing: 0; }
.compare-table tbody th, .lab-table tbody th { color: var(--text); font-size: 14px; }
.cycle-line { margin: 12px 0 0; font-size: 14px; color: var(--muted); }
.cycle-line strong { color: var(--text); }
.how { margin-top: 10px; }
.how ul { margin: 6px 0 0; padding-left: 20px; font-size: 14px; color: var(--muted); max-width: 52em; }
.how li { margin: 4px 0; }
.how .table-scroll { margin-top: 8px; }

/* Summary */
.summary-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 28px; align-items: start; }
fieldset { margin: 0 0 18px; padding: 0; border: 0; }
legend { margin-bottom: 6px; font-weight: 600; font-size: 14px; }
fieldset label { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0; font-size: 14.5px; cursor: pointer; }
fieldset input { width: 18px; height: 18px; margin: 1px 0 0; flex-shrink: 0; accent-color: var(--accent); }
.summary-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.status-msg { min-height: 1.4em; margin: 8px 0 0; font-size: 14px; color: var(--muted); }
.copy-fallback { width: 100%; height: 120px; margin-top: 8px; font: 12px/1.5 ui-monospace, Menlo, monospace; }

/* The summary preview: a clean one-page document */
.sheet {
  padding: 32px 36px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 1px 2px rgba(22, 24, 29, 0.04), 0 8px 24px rgba(22, 24, 29, 0.06);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}
.sheet-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 16px; padding-bottom: 14px; border-bottom: 2px solid var(--text); }
.sheet-head h3 { margin: 0; font-size: 20px; letter-spacing: -0.01em; }
.sheet-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.sheet-badge { padding: 3px 10px; border: 1.5px solid var(--text); border-radius: 4px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
.sheet section { padding: 12px 0; border-bottom: 1px solid var(--border); }
.sheet section:last-of-type { border-bottom: 0; }
.sheet h4 { margin: 0 0 6px; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.sheet p { margin: 0; }
.sheet ul { margin: 0; padding-left: 18px; }
.sheet li { margin: 3px 0; }
.sheet .obs { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.sheet .obs th, .sheet .obs td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--border); background: none; }
.sheet .obs th { font-size: 12px; }
.sheet .obs tbody th { color: var(--text); font-size: 13.5px; }
.sheet .obs tr:last-child td, .sheet .obs tr:last-child th { border-bottom: 0; }
.sheet .small { font-size: 12.5px; color: var(--muted); }
.sheet-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }

/* Call to action */
.cta p { margin: 0 0 18px; max-width: 36em; color: var(--muted); }

footer { padding-top: 24px; padding-bottom: 40px; font-size: 13px; color: var(--muted); }
footer p { margin: 0 0 6px; }

.noscript { max-width: 1040px; margin: 0 auto 32px; padding: 0 24px; }

@media (max-width: 820px) {
  main > section.hero { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar-inner, main, footer { padding-left: 16px; padding-right: 16px; }
  main > section { padding: 32px 0; }
  .charts { padding: 0 6px 2px; }
  .readout { margin: 0 -6px 2px; padding: 10px 12px; }
  .demo-label { font-size: 12px; padding: 3px 10px; }
  th, td { padding: 8px 10px; }
  .sheet { padding: 22px 18px; }
}

/* Comparison table stacks into one card per measure on narrow screens */
@media (max-width: 560px) {
  .compare-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .compare-table, .compare-table tbody, .compare-table tr, .compare-table th, .compare-table td { display: block; width: 100%; }
  .compare-table tr { padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .compare-table tbody tr:last-child { border-bottom: 0; }
  .compare-table th, .compare-table td { padding: 3px 0; border: 0; }
  .compare-table tbody th { font-size: 15px; padding-bottom: 4px; }
  .compare-table td::before { content: attr(data-label); display: block; font-size: 12px; color: var(--muted); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* Print: only the summary sheet, on one page */
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .topbar, footer, .noscript,
  main > section:not(.summary),
  .summary > h2, .summary > .sub, .summary-controls { display: none !important; }
  main, .summary, .summary-grid { display: block; max-width: none; margin: 0; padding: 0; border: 0; }
  .sheet { padding: 0; border: 0; border-radius: 0; box-shadow: none; font-size: 10.5pt; }
  .sheet section, .sheet-head, .sheet-foot { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
}
