:root {
  color-scheme: light;
  --blueprint: #132745;
  --blueprint-link: #c1ddff;
  --ink: #152640;
  --muted: #496078;
  --line: #c3d1de;
  --canvas: #eef3f7;
  --paper: #fff;
  --wash: #f6f9fc;
  --accent: #224d83;
  --tint: #e9f1fc;
  --warn-ink: #745222;
  --warn-fill: #fcf0db;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
  --sans: Aptos, system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body { margin: 0; color: var(--ink); background: var(--canvas); font: 1rem/1.55 var(--sans); }
button, input, select { font: inherit; }
a { color: var(--accent); text-underline-offset: .2em; }
p, h1, h2, h3, h4, dl, ol, ul { margin: 0; }
code, .mono { font-family: var(--mono); }
:focus-visible { outline: 3px solid #235eb1; outline-offset: 3px; }
.top :focus-visible { outline-color: var(--blueprint-link); }
.skip { position: fixed; z-index: 4; top: .7rem; left: .7rem; padding: .56rem 1rem; background: var(--paper); transform: translateY(-190%); }
.skip:focus { transform: none; }
.shell { width: min(76rem, calc(100% - 4rem)); margin-inline: auto; }

.top { background: var(--blueprint); color: #f5f9ff; }
.header { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 0 1rem; min-height: 4.1rem; border-bottom: 1px solid #405577; }
.header nav { display: flex; gap: 1.25rem; }
.header a, .hero-link { display: inline-flex; align-items: center; min-height: 2.75rem; color: #f5f9ff; font-weight: 620; text-decoration: none; }
.header a:hover, .hero-link:hover { color: var(--blueprint-link); text-decoration: underline; }
.brand { gap: .56rem; }
.brand-icon { display: inline-flex; align-items: end; gap: 2px; padding-right: .1rem; }
.brand-icon i { width: 3px; height: .78rem; background: #a8c7f0; }
.brand-icon i:nth-child(2) { height: .58rem; }
.brand-icon i:nth-child(3) { height: .37rem; }
.hero { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-block: clamp(2.3rem, 6vw, 5rem) clamp(2.5rem, 6vw, 4.1rem); }
.hero h1 { max-width: 16ch; font-size: clamp(2.5rem, 6vw, 5.1rem); font-weight: 625; line-height: 1.02; letter-spacing: -.067em; }
.hero p { max-width: 53ch; margin-top: .85rem; color: #c1d4ed; font-size: clamp(1rem, 1.5vw, 1.125rem); }
.hero-link { flex-shrink: 0; gap: .4rem; align-self: end; color: var(--blueprint-link); border-block-start: 1px solid #7091be; }

.viewer { margin-block-start: clamp(1.3rem, 4vw, 2.4rem); background: var(--paper); border: 1px solid var(--line); }
.viewer-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: .7rem 1.1rem; padding: clamp(.9rem, 2.4vw, 1.45rem); }
.viewer-head > div { min-width: 0; }
.viewer h2, .guide h2 { font-size: clamp(1.6rem, 3vw, 2.25rem); line-height: 1.15; letter-spacing: -.043em; }
.viewer-head p, .overview p, .history-head p { margin-top: .28rem; color: var(--muted); font-size: .87rem; overflow-wrap: anywhere; }
.viewer-actions { display: grid; grid-template-columns: repeat(2, max-content); gap: .45rem; }
.viewer-actions #file-note { grid-column: 1 / -1; margin-top: 0; font-size: .75rem; }
.page-controls { display: flex; flex-wrap: wrap; gap: .45rem; }
button, select, input { min-height: 2.75rem; border: 1px solid #7188a1; border-radius: .18rem; color: var(--ink); background: var(--paper); }
button { padding: .42rem .7rem; cursor: pointer; font-size: .86rem; font-weight: 650; }
button:enabled:hover { background: var(--tint); }
button.primary { color: var(--paper); background: var(--accent); border-color: var(--accent); }
button.primary:enabled:hover { background: var(--blueprint); }
button:disabled { cursor: default; opacity: .48; }
input, select { min-width: 0; max-width: 100%; padding: .3rem .56rem; }
input::placeholder { color: var(--muted); }
label { display: block; margin-bottom: .23rem; color: var(--muted); font-size: .77rem; font-weight: 650; }
.notice, .blank { padding: .68rem clamp(.9rem, 2.4vw, 1.45rem); border-top: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.notice:empty { padding: 0; border: 0; }
.notice[data-error] { color: var(--warn-ink); background: var(--warn-fill); }

.overview { padding: .95rem clamp(.9rem, 2.4vw, 1.45rem); border-block: 1px solid var(--line); background: var(--wash); }
.viewer h3 { font-size: 1.5rem; line-height: 1.2; letter-spacing: -.035em; }
.stages { display: flex; flex-wrap: wrap; gap: .65rem .9rem; padding: .85rem 0 .1rem; list-style: none; }
.stages > li { flex: 1 1 9.4rem; min-width: 0; border-top: 2px solid #9eb8d7; padding: .37rem 0 .02rem; }
.stage-name { display: block; color: var(--accent); font: 650 .79rem/1.45 var(--mono); overflow-wrap: anywhere; }
.stage-count { display: block; margin-top: .23rem; color: var(--muted); font-size: .75rem; }
.stage-count strong { color: var(--ink); font: 650 1.34rem/1.1 var(--mono); }

.transitions { display: grid; grid-template-columns: minmax(13rem, .8fr) minmax(0, 1.65fr); align-items: start; gap: .8rem 1.5rem; padding: 1rem clamp(.9rem, 2.4vw, 1.45rem); border-bottom: 1px solid var(--line); }
.transition-controls { display: flex; flex-direction: column; align-items: start; gap: .5rem; min-width: 0; }
.transition-controls > div { width: 100%; min-width: 0; }
.transition-controls label { margin-top: .4rem; }
.transition-controls select { max-width: 100%; width: 100%; }
.transition-results { min-width: 0; }
#transition-path { margin-bottom: .42rem; color: var(--muted); font: 650 .78rem/1.45 var(--mono); overflow-wrap: anywhere; }
#transition-metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
#transition-metrics > div { min-width: 0; padding: .65rem .6rem .55rem; border-top: 2px solid #b5c8de; background: var(--wash); }
#transition-metrics dt { color: var(--muted); font-size: .77rem; font-weight: 620; }
#transition-metrics dd { margin: .2rem 0 0; color: var(--accent); font: 650 clamp(1.2rem, 3vw, 1.65rem)/1.1 var(--mono); overflow-wrap: anywhere; }
#unknown-summary { margin-top: .6rem; color: var(--muted); font-size: .82rem; }
#unknown-summary[data-missing] { padding: .45rem .55rem; color: var(--warn-ink); background: var(--warn-fill); }

.history-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: .75rem 1.2rem; padding: 1rem clamp(.9rem, 2.4vw, 1.45rem); }
.filter-bar { display: flex; flex-wrap: wrap; gap: .5rem .7rem; }
.filter-bar > div { min-width: min(12rem, 100%); }
.filter-bar input, .filter-bar select { width: 100%; }
.spot { border-top: 1px solid var(--line); }
.spot:nth-child(even) { background: var(--wash); }
.spot > summary { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .9fr) minmax(0, .9fr) minmax(2rem, .32fr); align-items: center; gap: .6rem; padding: .67rem clamp(.9rem, 2.4vw, 1.45rem); min-height: 3.3rem; cursor: pointer; list-style: none; overflow-wrap: anywhere; }
.spot > summary::-webkit-details-marker { display: none; }
.spot > summary:hover { background: var(--tint); }
.spot > summary:focus-visible { outline-offset: -3px; }
.spot-name { display: grid; font: 650 .88rem/1.4 var(--mono); }
.spot-name span { margin-top: .18rem; color: var(--muted); font-size: .73rem; font-weight: 450; }
.spot-meta { display: grid; gap: .1rem; color: var(--ink); font-size: .82rem; }
.spot-meta b { color: var(--muted); font-size: .7rem; font-weight: 620; }
.spot-meta .missing { color: var(--warn-ink); }
.event-total { justify-self: end; color: var(--accent); font-size: .77rem; white-space: nowrap; }
.event-total::after { display: inline-block; margin-left: .35rem; content: "+"; font: 700 1.05rem/1 var(--mono); }
.spot[open] .event-total::after { content: "−"; }
.spot-events { display: grid; gap: .55rem; padding: 0 clamp(.9rem, 2.4vw, 1.45rem) .85rem; list-style: none; }
.event, .no-events { padding: .58rem .7rem; border-inline-start: 3px solid #9eb8d7; color: var(--muted); background: var(--tint); font-size: .83rem; overflow-wrap: anywhere; }
.event[data-missing] { border-color: #ba8b46; background: var(--warn-fill); color: var(--warn-ink); }
.event h4 { color: inherit; font-size: .87rem; }
.event p + p { margin-top: .14rem; }
.event strong { color: var(--ink); }
.history-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .45rem; padding: .6rem clamp(.9rem, 2.4vw, 1.45rem); border-top: 1px solid var(--line); }
#visible-range { color: var(--muted); font-size: .82rem; }
.provenance { padding: 0 clamp(.9rem, 2.4vw, 1.45rem) .24rem; border-top: 1px solid var(--line); }
.provenance summary { cursor: pointer; min-height: 2.75rem; padding-block: .7rem; color: var(--accent); font-size: .84rem; font-weight: 650; }
.provenance dl { display: grid; grid-template-columns: minmax(8rem, 13rem) minmax(0, 1fr); gap: .3rem .75rem; padding-bottom: .65rem; font-size: .78rem; }
.provenance dt { color: var(--muted); overflow-wrap: anywhere; }
.provenance dd { margin: 0; font-family: var(--mono); overflow-wrap: anywhere; }

.guide { display: grid; grid-template-columns: minmax(0, .7fr) minmax(0, 1.5fr); padding-block: clamp(2.6rem, 7vw, 4.7rem); gap: 1.15rem 3.1rem; }
.guide h3 { margin-bottom: .3rem; font-size: 1.02rem; }
.guide p { max-width: 65ch; color: var(--muted); }
.guide p + p { margin-top: .4rem; }
.guide-heading p { margin-top: .4rem; }
.guide-sections > section + section { border-top: 1px solid var(--line); padding-top: .9rem; margin-top: 1rem; }
pre { margin: .42rem 0; padding: .7rem .8rem; background: var(--paper); border: 1px solid var(--line); font-size: .85rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.footer { padding: .8rem 0 1.1rem; border-top: 1px solid var(--line); color: var(--muted); font-size: .8rem; }

@media (max-width: 46rem) {
  .shell { width: calc(100% - 2rem); }
  .hero { display: block; }
  .hero-link { margin-top: .8rem; }
  .transitions, .guide { grid-template-columns: 1fr; }
  .transition-controls > div { width: min(100%, 28rem); }
}

@media (max-width: 35rem) {
  .shell { width: calc(100% - 1.3rem); }
  .header { gap: 0 .4rem; }
  .header a { font-size: .84rem; }
  .header nav { gap: .6rem; }
  .hero { padding-block: 1.65rem 1.5rem; }
  .hero-link { display: none; }
  .stages > li { flex-basis: calc(50% - .6rem); }
  #transition-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-bar { width: 100%; }
  .filter-bar > div { width: 100%; }
  .spot > summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spot-name { grid-column: 1 / 2; grid-row: 1; }
  .event-total { grid-column: 2 / 3; grid-row: 1; }
  .provenance dl { grid-template-columns: 1fr; }
}
