:root {
  color-scheme: light;
  --bg: #fffdf8;
  --surface: #ffffff;
  --surface-2: #f6f1e8;
  --line: #ded8cb;
  --line-strong: #746f66;
  --text: #201e1a;
  --muted: #746f66;
  --accent: #df562d;
  --accent-dark: #bd4525;
  --accent-soft: #f9e3dc;
  --accent-2: #397468;
  --accent-2-soft: #e6f0ed;
  --purple: #7f5a78;
  --max: 1180px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
.shell { width: min(calc(100% - 40px), var(--max)); margin: 0 auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 max(20px, calc((100vw - var(--max)) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255,253,248,.9);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center; width: 36px; height: 36px;
  border-radius: 10px; background: var(--text); color: #fff; font-weight: 900;
}
.brand > span:last-child { display: flex; align-items: baseline; gap: 8px; }
.brand small { color: var(--muted); font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; }
nav { display: flex; gap: 28px; color: var(--muted); font-size: .9rem; }
nav a:hover, nav a:focus-visible { color: var(--text); }

.hero { padding: 92px 0 70px; }
.eyebrow, .section-kicker {
  color: var(--accent-dark); font-size: .75rem; font-weight: 800; letter-spacing: .16em; text-transform: uppercase;
}
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 900px; margin: 22px 0; font-size: clamp(3rem, 7.2vw, 6.8rem); line-height: .94; letter-spacing: -.065em; }
h1 em { color: var(--accent); font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
.hero-copy { max-width: 710px; color: var(--muted); font-size: clamp(1.05rem, 1.7vw, 1.3rem); }
.hero-actions { display: flex; gap: 12px; margin: 32px 0 64px; }
.button, .icon-button {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 9px; background: transparent; color: var(--text); cursor: pointer;
}
.button:hover, .icon-button:hover, .button:focus-visible, .icon-button:focus-visible { border-color: var(--accent); outline: none; }
.button-primary { border-color: var(--text); background: var(--text); color: #fff; font-weight: 800; }

.rewrite-summary {
  display: grid; grid-template-columns: 1fr auto 1fr auto 1.25fr; align-items: stretch; gap: 18px;
  padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
}
.rewrite-summary > div { display: flex; flex-direction: column; gap: 6px; padding: 14px; }
.rewrite-summary span { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.rewrite-summary code { color: var(--text); font-size: .9rem; }
.rewrite-summary small { color: var(--muted); }
.rewrite-summary .summary-featured { border-radius: 10px; background: var(--accent-soft); }
.summary-arrow { align-self: center; color: var(--accent) !important; font-size: 1.4rem !important; }

.demo-section { padding: 88px 0; background: var(--surface-2); border-block: 1px solid var(--line); }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 30px; margin: 10px 0 32px; }
h2 { margin-bottom: 10px; font-size: clamp(2rem, 4vw, 3.5rem); line-height: 1.06; letter-spacing: -.045em; }
.section-heading p, .results-intro { max-width: 680px; margin-bottom: 0; color: var(--muted); }
.recorded-badge { flex: 0 0 auto; padding: 7px 11px; border: 1px solid var(--line); border-radius: 999px; color: var(--accent-2); font-size: .78rem; }

.plan-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.plan-tabs button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-height: 104px; padding: 18px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text); cursor: pointer; text-align: left;
}
.plan-tabs button:hover, .plan-tabs button:focus-visible { border-color: var(--line-strong); outline: none; }
.plan-tabs button[aria-selected="true"] { border-color: var(--text); background: var(--surface); box-shadow: 0 4px 16px rgba(28,25,20,.07), inset 0 3px 0 var(--accent); }
.plan-tabs span { color: var(--accent-dark); font-size: .72rem; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.plan-tabs strong { font-size: 1.03rem; }
.plan-tabs small { color: var(--muted); }

.plan-card { overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.expression-row { display: flex; align-items: center; gap: 18px; min-height: 66px; padding: 14px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
.expression-row span { color: var(--accent-dark); font-size: .72rem; font-weight: 900; letter-spacing: .13em; }
.expression-row code { overflow-x: auto; white-space: nowrap; color: var(--text); font-size: .9rem; }
.stage-list { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 1fr); gap: 0; overflow-x: auto; margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--line); }
.stage-list li { position: relative; min-height: 100px; padding: 18px 16px; border-right: 1px solid var(--line); color: var(--muted); cursor: pointer; }
.stage-list li::before { content: attr(data-index); display: block; margin-bottom: 10px; color: var(--muted); font-size: .7rem; font-weight: 800; }
.stage-list li strong { display: block; color: var(--text); font-size: .88rem; }
.stage-list li small { display: block; margin-top: 3px; }
.stage-list li.active { background: var(--accent-soft); }
.stage-list li.active::after { content: ""; position: absolute; inset: auto 12px 0; height: 3px; background: var(--accent); }
.inspector-grid { display: grid; grid-template-columns: .8fr 1.2fr; min-height: 310px; }
.inspector-copy { padding: 30px; border-right: 1px solid var(--line); }
.inspector-label { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.inspector-copy h3 { margin: 12px 0 10px; font-size: 1.8rem; }
.inspector-copy p { min-height: 76px; color: var(--muted); }
.stage-controls { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.icon-button:disabled { cursor: not-allowed; opacity: .35; }
.source-view { align-self: center; padding: 32px; }
.source-view-header { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.source-view-header div { display: flex; flex-direction: column; }
.source-view-header span { color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .1em; }
.source-view-header > strong { color: var(--accent-dark); font-size: .88rem; }
.timeline-labels { display: flex; justify-content: space-between; margin-bottom: 7px; color: var(--muted); font-size: .75rem; }
.timeline { position: relative; height: 46px; }
.timeline-track { position: absolute; inset: 13px 0; border-radius: 999px; background: var(--line); }
.timeline-window { position: absolute; top: 9px; bottom: 9px; border: 2px solid var(--accent-2); border-radius: 6px; background: var(--accent-2-soft); min-width: 5px; }
.timeline-event { position: absolute; top: 4px; width: 5px; height: 38px; border-radius: 3px; background: var(--accent); box-shadow: 0 0 0 3px rgba(223,86,45,.16); }
.timeline-legend { display: flex; gap: 18px; margin-top: 12px; color: var(--muted); font-size: .78rem; }
.timeline-legend span { display: flex; align-items: center; gap: 7px; }
.timeline-legend i { display: block; width: 18px; height: 6px; border-radius: 3px; }
.legend-window { background: var(--accent-2); }
.legend-event { background: var(--accent); }

.evidence-grid {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  border-top: 1px solid var(--line);
}
.evidence-panel { min-width: 0; padding: 26px; }
.evidence-panel.is-wide { grid-column: 1 / -1; border-right: 0; }
.transcript-panel { border-right: 1px solid var(--line); }
.video-panel { border-bottom: 1px solid var(--line); }
.output-panel { grid-column: 1 / -1; border-top: 1px solid var(--line); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 18px; margin-bottom: 18px; }
.panel-heading div { display: flex; flex-direction: column; }
.panel-heading span { color: var(--muted); font-size: .72rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.panel-heading > span { flex: 0 0 auto; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--accent-2); letter-spacing: 0; text-transform: none; }
.panel-heading h3 { margin: 2px 0 0; font-size: 1.25rem; }
.candidate-rationale { margin-bottom: 14px; padding: 12px 14px; border-left: 3px solid var(--purple); background: #f4edf2; color: var(--text); font-size: .85rem; }
.transcript-scroll { height: 320px; overflow-y: auto; padding-right: 8px; scrollbar-color: var(--line-strong) transparent; }
.transcript-segment { display: grid; grid-template-columns: 58px 1fr; gap: 12px; padding: 9px 10px; border-radius: 7px; color: var(--muted); font-size: .84rem; }
.transcript-segment + .transcript-segment { margin-top: 2px; }
.transcript-segment time { color: var(--muted); font-variant-numeric: tabular-nums; }
.transcript-segment.candidate { background: #f4edf2; color: var(--text); }
.transcript-segment.prediction { box-shadow: inset 3px 0 0 var(--accent-2); }
.video-frame { overflow: hidden; position: relative; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 10px; background: #02040a; }
.video-frame video { display: block; width: 100%; height: 100%; object-fit: contain; }
.media-fallback { display: grid; position: absolute; inset: 0; place-items: center; padding: 26px; color: var(--muted); text-align: center; }
.media-fallback[hidden] { display: none; }
.detail-timeline { position: relative; height: 58px; margin-top: 16px; border-radius: 7px; background: var(--surface-2); border: 1px solid var(--line); }
.detail-timeline::before, .detail-timeline::after { position: absolute; bottom: 5px; color: var(--muted); font-size: .68rem; }
.detail-timeline::before { content: "0:00"; left: 6px; }
.detail-timeline::after { content: "2:10"; right: 6px; }
.detail-marker { position: absolute; border-radius: 4px; min-width: 3px; }
.detail-marker.reference { top: 9px; height: 14px; background: var(--accent); }
.detail-marker.prediction { top: 28px; height: 14px; border: 2px solid var(--accent-2); background: var(--accent-2-soft); cursor: pointer; }
.detail-marker.prediction:hover, .detail-marker.prediction:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.detail-legend { display: flex; gap: 18px; margin-top: 8px; color: var(--muted); font-size: .75rem; }
.detail-legend span { display: flex; align-items: center; gap: 6px; }
.detail-legend i { width: 18px; height: 6px; border-radius: 4px; }
.legend-reference { background: var(--accent); }
.legend-prediction { border: 2px solid var(--accent-2); background: var(--accent-2-soft); }
.media-credit { margin: 12px 0 0; color: var(--muted); font-size: .72rem; }
.prediction-list { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.prediction-card { min-width: 0; padding: 15px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.prediction-card button { display: block; width: 100%; padding: 0; border: 0; background: none; color: inherit; cursor: pointer; text-align: left; }
.prediction-card button:hover strong, .prediction-card button:focus-visible strong { color: var(--accent-dark); }
.prediction-card button:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
.prediction-card span { color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.prediction-card strong { display: block; margin: 5px 0; font-variant-numeric: tabular-nums; }
.prediction-card p { overflow: hidden; display: -webkit-box; margin: 0; color: var(--muted); font-size: .78rem; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.evidence-panel.is-inactive { display: none; }

.results-section { padding: 90px 0; }
.results-intro { margin-bottom: 30px; }
.metric-spotlight { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 34px; }
.metric-spotlight article { padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.metric-spotlight span, .metric-spotlight small { display: block; color: var(--muted); }
.metric-spotlight strong { display: block; margin: 7px 0; color: var(--accent); font-size: 2rem; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 810px; font-size: .88rem; }
caption { padding-bottom: 12px; color: var(--muted); text-align: left; }
th, td { padding: 13px 12px; border-bottom: 1px solid var(--line); text-align: right; }
th:first-child, td:first-child { text-align: left; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; }
tr.highlight td { background: var(--accent-soft); font-weight: 700; }
td.best { color: var(--accent-dark); font-weight: 800; }

.paper-section { padding: 0 0 90px; }
.paper-card { display: flex; justify-content: space-between; align-items: center; gap: 30px; padding: 36px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.paper-card h2 { max-width: 820px; margin-top: 8px; font-size: clamp(1.5rem, 3vw, 2.4rem); }
.paper-card p { margin-bottom: 0; color: var(--muted); }
footer { padding: 24px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: .82rem; }
footer .shell { display: flex; justify-content: space-between; }

@media (max-width: 820px) {
  nav { gap: 16px; }
  .rewrite-summary { grid-template-columns: 1fr; }
  .summary-arrow { transform: rotate(90deg); justify-self: center; }
  .plan-tabs { grid-template-columns: 1fr; }
  .plan-tabs button { min-height: 84px; }
  .inspector-grid { grid-template-columns: 1fr; }
  .inspector-copy { border-right: 0; border-bottom: 1px solid var(--line); }
  .evidence-grid { grid-template-columns: 1fr; }
  .transcript-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .output-panel { grid-column: auto; }
  .prediction-list { grid-template-columns: 1fr; }
  .metric-spotlight { grid-template-columns: repeat(2, 1fr); }
  .paper-card, .section-heading { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 520px) {
  .site-header { min-height: 62px; }
  .brand small, nav a:nth-child(2) { display: none; }
  .hero { padding-top: 62px; }
  .hero-actions { flex-direction: column; }
  .hero-actions .button { width: 100%; }
  .metric-spotlight { grid-template-columns: 1fr; }
  .source-view, .inspector-copy { padding: 22px; }
  .source-view-header { flex-direction: column; }
  footer .shell { flex-direction: column; gap: 4px; }
}

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