:root {
  --page: #f3f5f5;
  --surface: #ffffff;
  --surface-muted: #f7f8f8;
  --ink: #172126;
  --ink-soft: #526169;
  --muted: #748087;
  --border: #d8dfe1;
  --border-strong: #aeb9bd;
  --header: #172126;
  --header-soft: #233138;
  --teal: #007c78;
  --teal-soft: #dff1ef;
  --blue: #2870a8;
  --green: #087a52;
  --amber: #a76200;
  --red: #b42318;
  --radius: 6px;
  --page-width: 1440px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}
button, input, select { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
a { color: var(--teal); }
h1, h2, h3, h4, p { margin-top: 0; }
h1, h2, h3, h4 { letter-spacing: 0; }
h1 { margin-bottom: 2px; font-size: 18px; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 20px; line-height: 1.25; }
h3 { margin-bottom: 0; font-size: 15px; line-height: 1.3; }
h4 { margin-bottom: 0; font-size: 13px; }
.page-width { width: min(calc(100% - 32px), var(--page-width)); margin-inline: auto; }
.sr-only { 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; top: 8px; left: 8px; padding: 8px 12px; background: #ffffff; border: 2px solid var(--teal); transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.app-header { background: var(--header); color: #ffffff; border-bottom: 1px solid #34434a; }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.brand-block { display: flex; min-width: 0; align-items: center; gap: 12px; }
.brand-block > svg { width: 24px; height: 24px; color: #38bcb1; flex: none; }
.brand-block p { margin: 0; color: #aebbc1; font-size: 11px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dataset-link { display: inline-flex; align-items: center; gap: 7px; min-height: 36px; padding: 7px 11px; color: #ffffff; text-decoration: none; border: 1px solid #526169; border-radius: var(--radius); font-weight: 650; }
.dataset-link svg { width: 16px; height: 16px; }
.dataset-link:hover { border-color: #ffffff; }

.stat-band { background: var(--header-soft); color: #ffffff; border-bottom: 1px solid #3a494f; }
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat { min-height: 78px; padding: 13px 18px; border-right: 1px solid #3a494f; }
.stat:first-child { border-left: 1px solid #3a494f; }
.stat span, .stat strong { display: block; }
.stat span { color: #b8c4c8; font-size: 10px; font-weight: 700; text-transform: uppercase; }
.stat strong { margin-top: 3px; font-size: 23px; line-height: 1.2; font-variant-numeric: tabular-nums; }

.view-nav { position: sticky; z-index: 20; top: 0; background: var(--surface); border-bottom: 1px solid var(--border); }
.view-tabs { min-height: 52px; display: flex; align-items: stretch; gap: 6px; }
.view-tabs button { position: relative; display: inline-flex; align-items: center; gap: 7px; min-width: 130px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--ink-soft); padding: 0 16px; font-weight: 700; }
.view-tabs button svg { width: 16px; height: 16px; }
.view-tabs button:hover { background: var(--surface-muted); color: var(--ink); }
.view-tabs button[aria-selected="true"] { color: var(--teal); border-bottom-color: var(--teal); }

.view { padding-block: 24px 38px; }
.section-heading { min-height: 60px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 16px; }
.eyebrow { margin: 0 0 3px; color: var(--muted); font-size: 10px; font-weight: 750; text-transform: uppercase; }
.definition-note { max-width: 420px; display: flex; align-items: baseline; gap: 9px; padding: 9px 12px; background: var(--teal-soft); border-left: 4px solid var(--teal); color: var(--ink-soft); }
.definition-note strong { color: var(--ink); white-space: nowrap; }

.overview-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(270px, 1fr); gap: 14px; align-items: stretch; }
.chart-panel { min-width: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.chart-panel.full { grid-column: 1 / -1; }
.panel-heading { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.panel-badge, .pattern-badge { flex: none; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface-muted); padding: 5px 8px; color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.chart-frame { width: 100%; padding: 8px 12px 10px; overflow: hidden; }
.chart-frame svg { display: block; width: 100%; height: auto; max-height: 300px; }
.depth-frame svg { max-height: 340px; }
.chart-axis { stroke: #aeb9bd; stroke-width: 1; }
.chart-gridline { stroke: #e5e9ea; stroke-width: 1; }
.chart-label { fill: #69767c; font-size: 11px; font-family: inherit; }
.chart-value-label { fill: #526169; font-size: 10px; font-family: inherit; font-weight: 700; }
.chart-bar { fill: #2870a8; }
.chart-bar.prefix { fill: #007c78; }
.chart-bar.point { fill: #a76200; }
.chart-bar:hover { filter: brightness(0.88); }
.depth-heading { align-items: flex-start; }
.legend { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 16px; color: var(--ink-soft); font-size: 11px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { width: 18px; height: 3px; background: var(--teal); }
.legend-line.correct { background: var(--green); }
.legend-line.incorrect { background: var(--red); }

.composition { min-height: 318px; display: flex; flex-direction: column; justify-content: center; gap: 18px; padding: 22px; }
.composition-row { display: grid; grid-template-columns: 74px minmax(0, 1fr) 72px; gap: 10px; align-items: center; }
.composition-row > span:first-child { color: var(--ink-soft); font-weight: 700; }
.composition-row strong { text-align: right; font-variant-numeric: tabular-nums; }
.composition-track { height: 16px; background: #e7ebec; border-radius: 3px; overflow: hidden; }
.composition-fill { height: 100%; min-width: 1px; background: var(--amber); }
.composition-row.zero .composition-fill { background: var(--red); }
.composition-row.full .composition-fill { background: var(--green); }
.composition-total { padding-top: 13px; border-top: 1px solid var(--border); color: var(--muted); font-size: 12px; }

.trajectory-view { display: grid; grid-template-columns: 330px minmax(0, 1fr); min-height: calc(100vh - 194px); padding: 0; }
.trajectory-sidebar { background: var(--surface); border-right: 1px solid var(--border); min-height: inherit; }
.sidebar-heading { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.sidebar-heading h2 { font-size: 17px; }
.sidebar-heading output { border-radius: var(--radius); background: var(--header-soft); color: #ffffff; padding: 4px 8px; font-size: 11px; font-weight: 700; }
.filters { padding: 13px; border-bottom: 1px solid var(--border); }
.search-control { position: relative; display: block; }
.search-control svg { position: absolute; left: 10px; top: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.search-control input { width: 100%; height: 36px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #ffffff; padding: 0 10px 0 34px; color: var(--ink); }
.filter-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 9px; }
.filter-grid label > span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.filter-grid select { width: 100%; height: 34px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-muted); padding-inline: 7px; color: var(--ink); }
.reset-button { min-height: 32px; display: inline-flex; align-items: center; gap: 6px; margin-top: 9px; border: 1px solid var(--border); border-radius: var(--radius); background: #ffffff; color: var(--ink-soft); padding: 5px 9px; font-size: 12px; font-weight: 700; }
.reset-button svg { width: 14px; height: 14px; }
.reset-button:hover { border-color: var(--border-strong); color: var(--ink); }
.trajectory-list { height: calc(100vh - 390px); min-height: 400px; overflow-y: auto; }
.trajectory-item { width: 100%; min-height: 80px; display: grid; grid-template-columns: minmax(0, 1fr) 76px; gap: 10px; align-items: center; border: 0; border-bottom: 1px solid var(--border); background: #ffffff; color: var(--ink); padding: 10px 13px; text-align: left; }
.trajectory-item:hover { background: var(--surface-muted); }
.trajectory-item[aria-selected="true"] { background: var(--teal-soft); box-shadow: inset 4px 0 0 var(--teal); }
.trajectory-item strong, .trajectory-item small, .trajectory-item span { display: block; }
.trajectory-item strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12px; }
.trajectory-item span { margin-top: 3px; color: var(--ink-soft); font-size: 11px; }
.trajectory-item small { margin-top: 3px; color: var(--muted); font-size: 10px; text-transform: capitalize; }
.mini-chart { width: 76px; height: 34px; }
.mini-chart polyline { fill: none; stroke: var(--teal); stroke-width: 2; vector-effect: non-scaling-stroke; }
.mini-chart line { stroke: #d8dfe1; stroke-width: 1; }

.trajectory-workspace { min-width: 0; padding: 20px; }
.trajectory-title-row { display: flex; min-height: 58px; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 12px; }
.trajectory-title-row h2 { font-size: 18px; }
.trajectory-title-row p:last-child { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.trace-switch { display: flex; gap: 5px; flex: none; }
.trace-switch button { min-width: 76px; min-height: 34px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--ink-soft); padding: 5px 9px; font-size: 11px; font-weight: 700; }
.trace-switch button[aria-pressed="true"] { background: var(--teal); border-color: var(--teal); color: #ffffff; }
.problem-section, .trajectory-chart-section, .reasoning-section, .point-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.problem-section { padding: 15px 17px; }
.problem-section h3 { margin-bottom: 8px; }
.problem-text { max-height: 220px; overflow: auto; color: var(--ink-soft); white-space: pre-wrap; overflow-wrap: anywhere; }
.math-content .katex-display { overflow-x: auto; overflow-y: hidden; }
.trajectory-chart-section { margin-top: 12px; }
.trajectory-chart-frame svg { max-height: 350px; }
.trajectory-line { fill: none; stroke: var(--teal); stroke-width: 3; vector-effect: non-scaling-stroke; }
.trajectory-whisker { stroke: #6d9e9a; stroke-width: 3; opacity: 0.65; vector-effect: non-scaling-stroke; }
.trajectory-point { fill: #ffffff; stroke: var(--teal); stroke-width: 3; cursor: pointer; vector-effect: non-scaling-stroke; }
.trajectory-point:hover, .trajectory-point.selected { fill: var(--teal); stroke: #ffffff; }
.endpoint-diamond { fill: var(--amber); stroke: #ffffff; stroke-width: 2; vector-effect: non-scaling-stroke; }
.reasoning-section { margin-top: 12px; }
.reasoning-heading { min-height: 78px; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.reasoning-heading p:last-child { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.reasoning-modes { display: inline-grid; grid-template-columns: repeat(3, minmax(0, 1fr)); flex: none; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.reasoning-modes button { min-height: 34px; border: 0; border-right: 1px solid var(--border); background: var(--surface-muted); color: var(--ink-soft); padding: 5px 11px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.reasoning-modes button:last-child { border-right: 0; }
.reasoning-modes button:hover { background: #edf1f1; color: var(--ink); }
.reasoning-modes button[aria-pressed="true"] { background: var(--teal); color: #ffffff; }
.reasoning-modes button:focus-visible { position: relative; z-index: 1; outline: 2px solid var(--blue); outline-offset: -2px; }
.reasoning-meta { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; border-bottom: 1px solid var(--border); background: var(--surface-muted); }
.reasoning-meta > div { min-width: 0; padding: 9px 13px; border-right: 1px solid var(--border); }
.reasoning-meta > div:last-child { border-right: 0; }
.reasoning-meta dt { color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.reasoning-meta dd { margin: 2px 0 0; overflow: hidden; color: var(--ink-soft); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.reasoning-body { position: relative; min-height: 220px; background: #fbfcfc; }
.reasoning-state, .reasoning-empty { min-height: 220px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 24px; color: var(--muted); text-align: center; }
.reasoning-state[hidden], .reasoning-empty[hidden], .reasoning-text[hidden], .reasoning-tail[hidden] { display: none; }
.reasoning-state-indicator { width: 16px; height: 16px; flex: none; border: 2px solid #b8c5c8; border-top-color: var(--teal); border-radius: 50%; animation: reasoning-spin 0.8s linear infinite; }
.reasoning-state[data-kind="error"] { color: var(--red); }
.reasoning-state[data-kind="error"] .reasoning-state-indicator { display: grid; place-items: center; border: 1px solid var(--red); border-radius: 50%; animation: none; font-size: 10px; font-weight: 800; }
.reasoning-text { width: 100%; max-height: 520px; min-height: 220px; margin: 0; overflow: auto; padding: 16px 18px 22px; border: 0; background: #fbfcfc; color: #26343a; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-size: 12.5px; line-height: 1.65; letter-spacing: 0; overflow-wrap: anywhere; tab-size: 2; white-space: pre-wrap; }
.reasoning-text:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.reasoning-tail { border-top: 1px solid #d3a052; background: #fffaf1; }
.reasoning-tail-label { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 18px; border-bottom: 1px solid #ead8ba; color: var(--amber); }
.reasoning-tail-label strong { font-size: 11px; text-transform: uppercase; }
.reasoning-tail-label span { color: #755425; font-size: 11px; font-variant-numeric: tabular-nums; }
.reasoning-tail-text { min-height: 120px; background: #fffaf1; color: #4f402d; }
.trajectory-list-footer { display: flex; flex-direction: column; align-items: stretch; gap: 9px; padding: 12px 13px 14px; border-bottom: 1px solid var(--border); background: var(--surface-muted); }
.trajectory-list-footer span { color: var(--muted); font-size: 11px; text-align: center; font-variant-numeric: tabular-nums; }
.load-more-button { min-height: 34px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: #ffffff; color: var(--ink); font-size: 12px; font-weight: 700; }
.load-more-button:hover { border-color: var(--teal); color: var(--teal); }
@keyframes reasoning-spin { to { transform: rotate(360deg); } }
.point-section { margin-top: 12px; }
.point-heading { min-height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.point-controls { display: flex; gap: 5px; }
.icon-button { width: 34px; height: 34px; display: inline-grid; place-items: center; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-muted); color: var(--ink); }
.icon-button svg { width: 17px; height: 17px; }
.icon-button:disabled { opacity: 0.35; cursor: default; }
.point-stats { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); margin: 0; border-bottom: 1px solid var(--border); }
.point-stats > div { padding: 10px 12px; border-right: 1px solid var(--border); }
.point-stats > div:last-child { border-right: 0; }
.point-stats dt { color: var(--muted); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.point-stats dd { margin: 3px 0 0; font-size: 15px; font-weight: 750; font-variant-numeric: tabular-nums; }
.point-distribution { padding: 13px 16px 4px; }
.subheading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.subheading span { color: var(--muted); font-size: 11px; }
.compact-chart { padding-inline: 0; }
.compact-chart svg { max-height: 230px; }

.method-view { max-width: 1180px; min-height: calc(100vh - 252px); }
.method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border: 1px solid var(--border); background: var(--surface); }
.method-grid section { position: relative; min-height: 190px; padding: 22px 24px 20px 68px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.method-grid section:nth-child(2n) { border-right: 0; }
.method-grid section:nth-last-child(-n + 2) { border-bottom: 0; }
.method-grid p { margin: 9px 0 0; color: var(--ink-soft); }
.method-index { position: absolute; top: 21px; left: 22px; color: var(--teal); font-size: 12px; font-weight: 800; }
.run-details { display: grid; grid-template-columns: repeat(4, 1fr); margin: 14px 0 0; border: 1px solid var(--border); background: var(--surface); }
.run-details > div { padding: 13px 15px; border-right: 1px solid var(--border); }
.run-details > div:last-child { border-right: 0; }
.run-details dt { color: var(--muted); font-size: 10px; font-weight: 700; text-transform: uppercase; }
.run-details dd { margin: 4px 0 0; font-weight: 700; overflow-wrap: anywhere; }

footer { background: var(--surface); border-top: 1px solid var(--border); color: var(--muted); }
.footer-inner { min-height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 18px; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }

@media (max-width: 1050px) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .stat:nth-child(4), .stat:nth-child(5) { border-top: 1px solid #3a494f; }
  .stat:nth-child(4) { border-left: 1px solid #3a494f; }
  .trajectory-view { grid-template-columns: 290px minmax(0, 1fr); }
  .point-stats { grid-template-columns: repeat(3, 1fr); }
  .point-stats > div:nth-child(3) { border-right: 0; }
  .point-stats > div:nth-child(-n + 3) { border-bottom: 1px solid var(--border); }
  .depth-heading { flex-direction: column; }
  .legend { justify-content: flex-start; }
}

@media (max-width: 800px) {
  .page-width { width: min(calc(100% - 20px), var(--page-width)); }
  .stat-grid { width: 100%; grid-template-columns: repeat(2, 1fr); }
  .stat { border-top: 1px solid #3a494f; }
  .stat:first-child, .stat:nth-child(2) { border-top: 0; }
  .stat:nth-child(odd) { border-left: 1px solid #3a494f; }
  .stat strong { font-size: 20px; }
  .view-tabs { width: 100%; }
  .view-tabs button { flex: 1; min-width: 0; justify-content: center; padding-inline: 8px; }
  .overview-grid { grid-template-columns: 1fr; }
  .chart-panel.full { grid-column: auto; }
  .section-heading { flex-direction: column; }
  .definition-note { max-width: none; width: 100%; }
  .trajectory-view { display: block; }
  .trajectory-sidebar { border-right: 0; border-bottom: 1px solid var(--border); min-height: 0; }
  .trajectory-list { height: 290px; min-height: 0; }
  .trajectory-workspace { padding: 14px 10px 24px; }
  .reasoning-heading { align-items: flex-start; flex-direction: column; }
  .reasoning-modes { width: 100%; }
  .reasoning-modes button { white-space: normal; }
  .method-grid { grid-template-columns: 1fr; }
  .method-grid section, .method-grid section:nth-child(2n), .method-grid section:nth-last-child(-n + 2) { border-right: 0; border-bottom: 1px solid var(--border); }
  .method-grid section:last-child { border-bottom: 0; }
  .run-details { grid-template-columns: repeat(2, 1fr); }
  .run-details > div:nth-child(2) { border-right: 0; }
  .run-details > div:nth-child(-n + 2) { border-bottom: 1px solid var(--border); }
}

@media (max-width: 520px) {
  .header-inner { min-height: 58px; }
  .brand-block > svg { display: none; }
  .brand-block h1 { font-size: 15px; }
  .dataset-link { width: 36px; min-width: 36px; padding: 0; justify-content: center; font-size: 0; }
  .stat { min-height: 68px; padding: 10px; }
  .view-tabs button { font-size: 11px; }
  .view-tabs button svg { width: 14px; height: 14px; }
  .view { padding-top: 16px; }
  .panel-heading { min-height: 62px; padding: 10px 12px; }
  .panel-badge { display: none; }
  .composition { min-height: 260px; padding: 16px; }
  .composition-row { grid-template-columns: 58px minmax(0, 1fr) 60px; }
  .trajectory-title-row { flex-direction: column; }
  .trace-switch { width: 100%; }
  .trace-switch button { flex: 1; }
  .reasoning-meta { grid-template-columns: 1fr; }
  .reasoning-meta > div { border-right: 0; border-bottom: 1px solid var(--border); }
  .reasoning-meta > div:last-child { border-bottom: 0; }
  .reasoning-text { max-height: 440px; padding-inline: 13px; font-size: 12px; }
  .point-stats { grid-template-columns: repeat(2, 1fr); }
  .point-stats > div, .point-stats > div:nth-child(3) { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
  .point-stats > div:nth-child(2n) { border-right: 0; }
  .point-stats > div:nth-last-child(-n + 2) { border-bottom: 0; }
  .method-grid section { padding: 20px 18px 18px 56px; }
  .method-index { left: 17px; top: 20px; }
  .run-details { grid-template-columns: 1fr; }
  .run-details > div, .run-details > div:nth-child(2), .run-details > div:nth-child(-n + 2) { border-right: 0; border-bottom: 1px solid var(--border); }
  .run-details > div:last-child { border-bottom: 0; }
  .footer-inner { min-height: 70px; flex-direction: column; align-items: flex-start; justify-content: center; gap: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
