/* Trajectory viewer, styled to match the project page (website/index.html):
   Newsreader headings, Inter for interface text, JetBrains Mono for data,
   thin rules, no rounded cards or tinted panels. */
:root {
  color-scheme: light;
  --ink: #111;
  --muted: #666;
  --rule: #d9d9d9;
  --code-bg: #f5f5f5;
  --blue: #0072B2;
  --orange: #D55E00;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}
* { box-sizing: border-box; border-radius: 0; }
body { margin: 0; padding: 0 24px; background: #fff; color: var(--ink); font: 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--blue); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
main { max-width: 1100px; margin: 0 auto; padding: 48px 0 96px; }
header { margin-bottom: 24px; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 800px; margin-bottom: 12px; font: 400 40px/1.1 var(--serif); letter-spacing: -0.01em; }
h2 { font: 500 20px/1.3 var(--serif); }
.eyebrow { margin-bottom: 12px; color: var(--muted); font-size: 13px; font-weight: 500; font-variant: small-caps; letter-spacing: 0.02em; }
.lede { max-width: 800px; color: var(--ink); font: 17px/1.55 var(--serif); }

.status { margin: 24px 0; padding: 0 0 12px; border-bottom: 1px solid var(--rule); color: var(--muted); font-size: 13px; }
.status.complete, .status.incomplete { color: var(--muted); }

nav { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 24px 0 8px; }
button { padding: 0 0 2px; border: 0; border-bottom: 1px solid transparent; background: none; color: var(--muted); font: 500 13px var(--sans); cursor: pointer; }
button.active { border-bottom-color: var(--ink); color: var(--ink); }

.model-group { padding: 24px 0; border-top: 1px solid var(--rule); }
.model-group h2 { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.model-group h2 span { color: var(--muted); font: 400 13px var(--sans); }
.trace-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 0 24px; border-top: 1px solid var(--ink); }
.trace-link { display: flex; min-width: 0; padding: 8px 0; border-bottom: 1px solid var(--rule); color: var(--ink); flex-direction: column; text-decoration: none; }
.trace-link:hover strong { color: var(--blue); text-decoration: underline; text-underline-offset: 2px; }
.trace-link strong { overflow: hidden; font-family: var(--mono); font-size: 12px; font-weight: 400; text-overflow: ellipsis; white-space: nowrap; }
.trace-link small, .missing { color: var(--muted); font-size: 12px; }

.back { display: inline-block; margin-bottom: 32px; color: var(--muted); font-size: 13px; }

/* Single trajectory */
.viewer { max-width: 1200px; padding-top: 32px; }
.viewer header { margin-bottom: 24px; }
.viewer h1 { font: 400 34px/1.15 var(--serif); }
.chips { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; }
.chip { color: var(--muted); font-size: 13px; }
.chip.good { color: var(--ink); font-weight: 500; }
.chip.mono { font-family: var(--mono); font-size: 12px; }

.chart-card { margin: 24px 0; padding: 16px 0 8px; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--rule); }
.chart-card h2 { margin-bottom: 0; font: 500 13px var(--sans); }
.chart-card p { margin: 2px 0; color: var(--muted); font-size: 12px; }
.chart-card svg { display: block; width: 100%; max-height: 210px; overflow: visible; }
.chart-grid { stroke: #ececec; stroke-width: 1; }
.chart-line { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.chart-dot { fill: var(--blue); stroke: #fff; stroke-width: 2; cursor: pointer; }
.chart-dot:hover { fill: var(--ink); r: 6.5; }
.chart-label { fill: var(--muted); font: 10px var(--mono); }

details { margin: 0; border-top: 1px solid var(--rule); }
summary { padding: 8px 0; cursor: pointer; font: 500 13px var(--sans); }
pre { max-height: 560px; margin: 0 0 12px; padding: 12px 16px; overflow: auto; background: var(--code-bg); white-space: pre-wrap; word-break: break-word; font: 12px/1.55 var(--mono); }

.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 24px; margin: 16px 0 32px; }
.overview-grid details { border-top: 1px solid var(--rule); }

.step-card { margin: 0; padding: 24px 0 8px; scroll-margin-top: 16px; border-top: 1px solid var(--ink); }
.step-card + .step-card { margin-top: 24px; }
.step-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 18px; padding-bottom: 12px; }
.step-heading h2 { margin: 0; font: 500 20px/1.3 var(--serif); }
.action-strip { max-width: 900px; margin-top: 4px; overflow: hidden; color: var(--muted); font: 12px/1.4 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
.utility-badge { flex: none; color: var(--ink); font: 500 13px var(--sans); font-variant-numeric: tabular-nums; }

.exchange { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 32px; }
.exchange-bubble { min-width: 0; }
.bubble-label { margin-bottom: 4px; padding-bottom: 6px; border-bottom: 1px solid var(--ink); color: var(--ink); font-size: 13px; font-weight: 500; }
.exchange details { border-top: 1px solid var(--rule); }
.exchange details:first-of-type { border-top: 0; }
.exchange details.dynamics summary { color: var(--blue); }
.exchange details.state summary { color: var(--orange); }
.exchange pre { max-height: 520px; font-size: 11.5px; }

.action-view, .state-sections { padding: 0 0 12px; }
.action-block, .decision-card, .state-section { margin: 0 0 12px; padding: 0; }
.action-block h3, .decision-card h3, .state-section h3 { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 500; text-transform: capitalize; }
.decision-card, .operating-plan { padding-left: 12px; border-left: 2px solid var(--rule); }
.state-sections { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 24px; }

.tree-grid { display: flex; min-width: 0; flex-direction: column; }
.tree-grid.depth-0 > .tree-row { border-top: 1px solid #eee; }
.tree-row { display: grid; grid-template-columns: minmax(110px, .65fr) minmax(0, 1.35fr); gap: 8px; align-items: start; min-width: 0; padding: 3px 0; }
.tree-key { color: var(--muted); font: 11px/1.45 var(--mono); }
.tree-value { min-width: 0; color: var(--ink); font-size: 12.5px; overflow-wrap: anywhere; }
.tree-value.number, .tree-value.boolean { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; }
.tree-list { display: flex; min-width: 0; flex-direction: column; }
.tree-list-item { display: grid; grid-template-columns: 22px minmax(0, 1fr); gap: 6px; padding: 4px 0; border-top: 1px solid #eee; }
.tree-list-item:first-child { border-top: 0; }
.tree-index { color: var(--muted); font: 11px var(--mono); }

.diff-table { display: flex; flex-direction: column; padding: 0 0 12px; }
.diff-row { display: grid; grid-template-columns: minmax(210px, 1.4fr) minmax(90px, .7fr) 18px minmax(90px, .7fr); gap: 8px; align-items: baseline; padding: 5px 0; border-bottom: 1px solid #eee; }
.diff-row code { color: var(--muted); font: 11px/1.35 var(--mono); overflow-wrap: anywhere; }
.diff-before, .diff-after { font: 12px/1.35 var(--mono); overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.diff-before { color: var(--muted); }
.diff-after { color: var(--orange); }
.diff-arrow { color: var(--muted); text-align: center; }
.diff-note { margin: 8px 0 0; color: var(--muted); font-size: 12px; }

@media (max-width: 850px) {
  body { padding: 0 16px; }
  main { padding-top: 32px; }
  h1 { font-size: 32px; }
  .viewer h1 { font-size: 28px; }
  .exchange, .overview-grid { grid-template-columns: 1fr; }
  .action-strip { white-space: normal; }
  .diff-row { grid-template-columns: 1fr; gap: 2px; }
  .diff-arrow { display: none; }
}
