/* Sun, Rain, Night
   One committed visual world: no light/dark switching, every color explicit. */

:root {
  /* Instruments: fixed */
  --amber:      #F2B84B;
  --amber-dim:  #A8803A;
  --cream:      #EFE7D6;
  --cream-dim:  #B3AA99;
  --ink:        #0C0E13;
  --dash:       #15181F;
  --dash-lip:   #22262F;
  --card:       rgba(15,18,24,0.90);
  --card-edge:  rgba(239,231,214,0.14);
  --post:       #8A8F97;

  /* Signs: MUTCD conventions */
  --sg-guide:   #17542F;
  --sg-warn:    #F0C420;
  --sg-work:    #E06A1E;
  --sg-rec:     #5C4326;
  --sg-light-ink: #fff;
  --sg-dark-ink:  #14110A;

  /* World: written by js/world.js every scroll frame */
  --sky-top:  #08101F;
  --sky-bot:  #33405E;
  --haze:     #33405E;
  --ground:   #141A24;
  --asphalt:  #141821;
  --paint:    #6B7686;
  --orb:      #BFD0E8;
  --orb-x:    77%;
  --orb-y:    78%;
  --orb-r:    22px;
  --orb-glow: 0.30;
  --stars:    0.80;
  --lights:   0.75;
  --curve:    0deg;
  --swing:    0;
  --grade:    0;
  --hz:       53%;
  --pitch:    81deg;
  --dash-shift: 0px;
  --flash:    0;
  --rays:     0;
  --ray-turn: 0deg;
  --wet:      0;
  --sign-glow: 0;
  --snow:     0;
  --below:    0;
  --bolt-x:   50%;

  --drive: .35s linear;
  --gutter: clamp(16px, 4vw, 44px);

  --f-sign: "Overpass", "Highway Gothic", "Helvetica Neue", Arial, system-ui, sans-serif;
  --f-mono: "Overpass Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --f-read: "Newsreader", "Iowan Old Style", Georgia, "Times New Roman", serif;

  color-scheme: dark;
  scroll-behavior: smooth;
  padding-top: 0;
  padding-bottom: 0;
}

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

body {
  margin: 0;
  background: var(--ink);
  color: var(--cream);
  font-family: var(--f-read);
  font-size: 17px;
  line-height: 1.62;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip {
  position: fixed; left: var(--gutter); top: 10px; z-index: 20;
  padding: 8px 14px; background: var(--amber); color: #14110A;
  font: 700 12px/1 var(--f-sign); letter-spacing: .12em; text-transform: uppercase;
  text-decoration: none; border-radius: 3px;
  transform: translateY(-200%);
}
.skip:focus { transform: none; }

/* ═══════════════  OUT THE WINDSHIELD  ═══════════════ */

.world { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }

.sky {
  position: absolute; inset: -8% -12%;
  background: linear-gradient(to bottom, var(--sky-top) 0%, var(--sky-top) 32%, var(--sky-bot) 100%);
  transform: rotate(calc(var(--curve) * -0.05));
  transition: transform var(--drive);
}
.stars { position: absolute; left: 0; top: 0; width: 100%; height: 64%; opacity: var(--stars); }
.orb {
  position: absolute; left: var(--orb-x); top: var(--orb-y);
  width: calc(var(--orb-r) * 2); height: calc(var(--orb-r) * 2);
  margin: calc(var(--orb-r) * -1) 0 0 calc(var(--orb-r) * -1);
  border-radius: 50%;
  background: radial-gradient(circle, var(--orb) 0 54%,
    color-mix(in srgb, var(--orb) 46%, transparent) 76%, transparent 100%);
  box-shadow:
    0 0 calc(var(--orb-r) * 1.6) calc(var(--orb-r) * 0.5) color-mix(in srgb, var(--orb) 55%, transparent),
    0 0 calc(var(--orb-r) * 5)   calc(var(--orb-r) * 1.6) color-mix(in srgb, var(--orb) 22%, transparent);
  opacity: var(--orb-glow);
}

.ridges {
  position: absolute; left: -14%; right: -14%;
  bottom: calc(var(--hz) - 3%); height: 44%;
  transition: bottom var(--drive);
}
.ridge { position: absolute; inset: auto 0 0 0; width: 100%; height: 100%; display: block; transition: transform var(--drive); }
.r3 { transform: translate(calc(var(--swing) * 30px), calc(var(--grade) * -12px)) scale(1.02); }
.r2 { transform: translate(calc(var(--swing) * 56px), calc(var(--grade) * -22px)); }
.r1 { transform: translate(calc(var(--swing) * 92px), calc(var(--grade) * -36px)); }

.haze {
  position: absolute; left: -12%; right: -12%;
  bottom: calc(var(--hz) - 4%); height: 20%;
  background: linear-gradient(to bottom, transparent, color-mix(in srgb, var(--haze) 46%, transparent) 60%, transparent);
  transition: bottom var(--drive);
}
.ground, .roadbox, .beams, .roadfog {
  position: absolute; left: 0; right: 0; bottom: 0; height: var(--hz);
  transition: height var(--drive);
}
.ground {
  left: -12%; right: -12%;
  background: linear-gradient(to bottom, var(--ground), color-mix(in srgb, var(--ground) 76%, #000));
}
.roadbox { overflow: hidden; perspective: 300px; perspective-origin: 50% 0%; }
.road {
  position: absolute; left: -60%; right: -60%; bottom: 0; height: 900%; /* long enough to meet the horizon even on the steepest descent */
  transform-origin: 50% 100%;
  transform: rotateX(var(--pitch)) skewX(var(--curve));
  transition: transform var(--drive);
  background-image:
    repeating-linear-gradient(to bottom, var(--paint) 0 40px, transparent 40px 128px),
    linear-gradient(var(--paint), var(--paint)),
    linear-gradient(var(--paint), var(--paint)),
    linear-gradient(to right,
      transparent 0 32%,
      color-mix(in srgb, var(--asphalt) 86%, #000) 32%,
      var(--asphalt) 50%,
      color-mix(in srgb, var(--asphalt) 86%, #000) 68%,
      transparent 68% 100%);
  background-size: 11px 128px, 8px 100%, 8px 100%, 100% 100%;
  background-position: 50% var(--dash-shift), 33.2% 0, 66.8% 0, 0 0;
  background-repeat: repeat-y, no-repeat, no-repeat, no-repeat;
}
/* Sunrise: glow behind the mountains, beams from the sun, clouds lit from below,
   and a warm edge along each ridge. All scale with --rays (1 at dawn, softer at dusk). */
@property --ray-turn { syntax: "<angle>"; inherits: true; initial-value: 0deg; }
.dawnglow {
  position: absolute; left: -10%; right: -10%;
  bottom: calc(var(--hz) - 8%); height: 55%;
  background: radial-gradient(55% 60% at calc((var(--orb-x) + 10%) / 1.2) 100%,
    rgba(255,176,104,0.85), rgba(255,138,110,0.42) 42%, rgba(240,120,130,0.12) 68%, transparent 80%);
  opacity: var(--rays);
  transition: bottom var(--drive);
}
.rays {
  position: absolute; inset: 0;
  background: repeating-conic-gradient(from var(--ray-turn) at var(--orb-x) var(--orb-y),
    rgba(255,222,170,0.13) 0deg 2deg, transparent 2deg 8deg);
  -webkit-mask-image: radial-gradient(circle at var(--orb-x) var(--orb-y), #000 0, rgba(0,0,0,0.45) 12%, transparent 34%);
  mask-image: radial-gradient(circle at var(--orb-x) var(--orb-y), #000 0, rgba(0,0,0,0.45) 12%, transparent 34%);
  mix-blend-mode: screen;
  opacity: var(--rays);
  animation: rays-turn 90s linear infinite;
}
@keyframes rays-turn { to { --ray-turn: 360deg; } }
.dawnclouds {
  position: absolute; left: 0; right: 0;
  top: calc(100% - var(--hz) - 40%); height: 30%;
  background:
    radial-gradient(20% 5% at 26% 42%, rgba(255,196,168,0.62), transparent 70%),
    radial-gradient(14% 3.6% at 44% 30%, rgba(255,178,160,0.45), transparent 70%),
    radial-gradient(24% 5.5% at 88% 58%, rgba(255,206,168,0.60), transparent 70%),
    radial-gradient(11% 3% at 10% 66%, rgba(255,186,158,0.42), transparent 70%),
    radial-gradient(17% 4% at 64% 74%, rgba(255,214,176,0.55), transparent 70%);
  opacity: var(--rays);
  transition: top var(--drive);
}
.ridge .rim {
  fill: none; stroke: #FFC99A; stroke-width: 1.6; vector-effect: non-scaling-stroke;
  opacity: calc(var(--rays) * 0.8);
}

/* Snow on the far peaks when the road is high. */
.ridge .snow {
  fill: color-mix(in srgb, #F3F6F9 82%, var(--haze));
  opacity: var(--snow); transition: opacity .6s linear;
}

/* Below sea level: fog settles into the valley. */
.valleyfog {
  position: absolute; left: -12%; right: -12%;
  bottom: calc(var(--hz) - 22%); height: 23%;
  background: linear-gradient(to top, transparent 0%, color-mix(in srgb, var(--haze) 50%, #D9DFE5) 55%, transparent 100%);
  opacity: calc(var(--below) * 0.85);
  transition: bottom var(--drive), opacity .6s linear;
}

/* Wet asphalt: sky sheen in the distance, puddles rolling toward you, headlight streaks. */
.wet {
  position: absolute; inset: 0;
  -webkit-mask-image: linear-gradient(to right, transparent 32%, #000 32%, #000 68%, transparent 68%);
  mask-image: linear-gradient(to right, transparent 32%, #000 32%, #000 68%, transparent 68%);
  background-image:
    radial-gradient(1.6% 24% at 45.4% 100%, rgba(242,184,75,0.55), transparent 70%),
    radial-gradient(1.6% 24% at 54.6% 100%, rgba(242,184,75,0.55), transparent 70%),
    linear-gradient(to bottom, color-mix(in srgb, var(--sky-bot) 60%, transparent) 0%, transparent 38%),
    radial-gradient(ellipse 4.5% 16% at 41% 30%, color-mix(in srgb, var(--sky-bot) 55%, transparent), transparent 70%),
    radial-gradient(ellipse 3% 12% at 58% 72%, color-mix(in srgb, var(--sky-bot) 50%, transparent), transparent 70%),
    radial-gradient(ellipse 2.4% 10% at 48% 52%, color-mix(in srgb, var(--sky-bot) 40%, transparent), transparent 70%);
  background-size: 100% 100%, 100% 100%, 100% 100%, 100% 512px, 100% 512px, 100% 512px;
  background-position: 0 0, 0 0, 0 0,
    0 calc(var(--dash-shift) * 4), 0 calc(var(--dash-shift) * 4), 0 calc(var(--dash-shift) * 4);
  background-repeat: no-repeat, no-repeat, no-repeat, repeat-y, repeat-y, repeat-y;
  opacity: var(--wet);
}

/* Lightning: the bolt sits behind the ridges; the flash lights the whole scene. */
.bolt { position: absolute; left: 0; top: 0; width: 100%; height: 64%; }
.birds { position: absolute; left: 0; top: 0; width: 100%; height: 64%; }
.flash {
  position: absolute; inset: 0; opacity: var(--flash);
  background: radial-gradient(130% 90% at var(--bolt-x) 0%,
    rgba(214,224,255,0.95), rgba(170,185,230,0.45) 55%, rgba(120,135,180,0.15));
  mix-blend-mode: screen;
}
/* Fixed box; the horizon inside it is computed so the bitmap never rescales. */
.trees { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 64%; }
.beams {
  background: radial-gradient(64% 80% at 50% 108%,
    rgba(242,184,75,0.30) 0%, rgba(242,184,75,0.12) 38%, rgba(242,184,75,0) 72%);
  mix-blend-mode: screen; opacity: var(--lights);
}
.roadfog {
  background: linear-gradient(to bottom, color-mix(in srgb, var(--haze) 88%, transparent) 0%, transparent 32%);
}
.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(132% 96% at 50% 40%, transparent 40%, rgba(4,6,10,0.74) 100%);
}
/* Rain on the windshield: in front of the plaques, behind the dashboard. */
.rain {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 3; pointer-events: none; opacity: 0;
}

/* If the world never starts, the page is still a page. */
body.no-world .world { display: none; }

/* ═══════════════  BANNER  ═══════════════ */

.banner {
  position: fixed; left: 50%; top: calc(58px + env(safe-area-inset-top, 0px));
  transform: translateX(-50%); z-index: 10;
  width: min(calc(100% - 2 * var(--gutter)), 620px);
  display: flex; gap: 14px; align-items: center; justify-content: space-between;
  padding: 10px 12px 10px 16px;
  background: #1B1710; border: 1px solid var(--amber-dim); border-radius: 3px;
  font: 13px/1.45 var(--f-sign); color: var(--cream);
  box-shadow: 0 14px 34px rgba(0,0,0,0.5);
}
body.editing .banner { top: auto; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }

/* ═══════════════  DASHBOARD  ═══════════════ */

.cowl {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  padding: 11px var(--gutter);
  padding-bottom: calc(11px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, rgba(10,12,16,0.45), var(--dash) 36%, #090B10 100%);
  border-top: 1px solid var(--dash-lip);
  border-radius: 44% 44% 0 0 / 20px 20px 0 0;
  display: flex; align-items: center; gap: clamp(10px, 2.4vw, 26px);
  font-family: var(--f-sign);
  box-shadow: 0 -18px 40px rgba(0,0,0,0.45);
}
.gauge { display: flex; flex-direction: column; gap: 1px; }
.gauge-label {
  font-size: 9px; letter-spacing: .2em; text-transform: uppercase;
  color: var(--amber-dim); font-weight: 600; white-space: nowrap;
}
.gauge-val {
  font-family: var(--f-mono); font-weight: 700; line-height: 1;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.g-odo .gauge-val { font-size: clamp(21px, 4.6vw, 29px); color: var(--amber); text-shadow: 0 0 16px rgba(242,184,75,0.4); }
.gauge-val small { font-size: .46em; letter-spacing: .1em; color: var(--amber-dim); margin-left: 3px; }
.g-elev { border-left: 1px solid var(--dash-lip); padding-left: clamp(10px, 2.4vw, 22px); }
.g-elev .gauge-val { font-size: 15px; color: var(--cream); }
.cowl-mid {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px;
  border-left: 1px solid var(--dash-lip); padding-left: clamp(10px, 2.4vw, 22px);
}
.cowl-stage {
  font-size: clamp(12.5px, 2.6vw, 15px); font-weight: 600; color: var(--cream);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cowl-sub {
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--cream-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chips { display: flex; gap: 7px; }
.chip {
  display: flex; align-items: center; gap: 6px; padding: 6px 10px;
  border: 1px solid var(--dash-lip); border-radius: 3px; background: rgba(0,0,0,0.32);
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase; font-weight: 600;
  color: var(--cream-dim); white-space: nowrap; font-variant-numeric: tabular-nums;
}
.lamp { width: 8px; height: 8px; border-radius: 50%; background: var(--orb); box-shadow: 0 0 9px var(--orb); }
.grade-arrow { color: var(--amber); font-style: normal; }

@media (max-width: 720px) {
  .g-elev, .chip.c-grade { display: none; }
}
@media (max-width: 460px) {
  .cowl { gap: 10px; }
  .chip { padding: 5px 7px; letter-spacing: .1em; }
}

/* ═══════════════  ROUTE RAIL  ═══════════════ */

.rail {
  position: fixed; right: calc(var(--gutter) - 8px); top: 50%;
  transform: translateY(-50%); z-index: 5;
  font-family: var(--f-sign);
  max-height: calc(100vh - 180px); overflow-y: auto; scrollbar-width: none;
}
.rail ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.rail a {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 4px 6px; text-decoration: none; color: var(--cream-dim);
  font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  opacity: .5; transition: opacity .25s, color .25s;
}
.rail a::after { content: ""; width: 14px; height: 2px; background: currentColor; border-radius: 1px; transition: width .25s; }
.rail-label { opacity: 0; transition: opacity .25s; background: rgba(8,10,14,0.85); padding: 3px 7px; border-radius: 2px; }
.rail a:hover, .rail a:focus-visible { opacity: 1; color: var(--cream); }
.rail a:hover .rail-label, .rail a:focus-visible .rail-label, .rail a.here .rail-label { opacity: 1; }
.rail a.here { opacity: 1; color: var(--amber); }
.rail a.here::after { width: 26px; }

/* ═══════════════  BUTTONS  ═══════════════ */

.btn {
  font: 700 10.5px/1.2 var(--f-sign);
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--cream); background: rgba(14,17,22,0.92);
  border: 1px solid var(--card-edge); border-radius: 3px;
  padding: 8px 13px; cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.btn:hover { border-color: var(--amber); color: var(--amber); }
.btn:disabled { opacity: .4; cursor: default; border-color: var(--card-edge); color: var(--cream); }
.btn.solid { background: var(--amber); color: #14110A; border-color: var(--amber); }
.btn.solid:hover { background: #FFD177; color: #14110A; }
.btn.warn:hover, .btn.armed { border-color: #E8795A; color: #E8795A; }
.btn.tiny { padding: 6px 10px; font-size: 9.5px; }

.editToggle {
  position: fixed; top: calc(14px + env(safe-area-inset-top, 0px)); right: var(--gutter);
  z-index: 9;
}

/* ═══════════════  EDIT BAR  ═══════════════ */

.editbar {
  position: fixed; left: 0; right: 0; top: 0; z-index: 8;
  max-height: 70vh; overflow-y: auto;
  padding: 12px var(--gutter);
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-right: calc(var(--gutter) + 80px);
  background: linear-gradient(to bottom, #0B0E13 70%, rgba(11,14,19,0.96));
  border-bottom: 1px solid var(--dash-lip);
  box-shadow: 0 14px 34px rgba(0,0,0,0.5);
  font-family: var(--f-sign);
  display: flex; flex-direction: column; gap: 10px;
}
.editbar-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.editbar-row > span:not(.spacer):not(.bar-label):not(.bar-note):not(.draft-status):not(.datamsg) { display: flex; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }
.bar-label { font-size: 9.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--amber-dim); font-weight: 700; }
.bar-note { font-size: 11.5px; color: var(--cream-dim); }
.draft-status { font-size: 11.5px; color: var(--cream-dim); font-variant-numeric: tabular-nums; }
.draft-status.dirty { color: var(--amber); }

.profwrap { position: relative; }
.prof { display: block; width: 100%; height: 124px; touch-action: none; }
.prof .grid { stroke: rgba(239,231,214,0.10); stroke-width: 1; stroke-dasharray: 3 4; }
.prof .gridtext { fill: var(--cream-dim); font: 8px var(--f-mono); opacity: .7; }
.prof .area { fill: rgba(242,184,75,0.16); }
.prof .area.below { fill: rgba(96,150,210,0.22); }
.prof .sealine { stroke: rgba(239,231,214,0.45); stroke-width: 1; }
.prof .gridtext.sea { fill: var(--cream); opacity: .9; }
.prof .line { fill: none; stroke: var(--amber); stroke-width: 2; stroke-linejoin: round; }
.prof .knob { fill: var(--amber); stroke: #0B0E13; stroke-width: 2; cursor: ns-resize; }
.prof .knob.on, .prof .knob:focus-visible { fill: #FFD177; }
.prof .knob:focus-visible { outline: none; stroke: var(--cream); }
.prof .agetext { fill: var(--cream-dim); font: 8px var(--f-mono); text-anchor: middle; }
.prof .valtext { fill: var(--amber); font: 700 10px var(--f-mono); text-anchor: middle; }

.datapanel { display: flex; flex-direction: column; gap: 8px; }
.datapanel textarea {
  width: 100%; height: 150px; resize: vertical;
  background: #080A0E; color: var(--cream); border: 1px solid var(--card-edge);
  border-radius: 3px; padding: 10px;
  font: 11px/1.45 var(--f-mono);
}
.datamsg { font-size: 11.5px; color: var(--amber); }
.unlock input[type="password"] {
  background: #080A0E; color: var(--cream); border: 1px solid var(--amber-dim);
  border-radius: 3px; padding: 6px 8px; font: 13px var(--f-sign); width: min(260px, 100%);
}
#btnPublish { padding-inline: 16px; }

@media (max-width: 720px) {
  .editbar { padding-right: var(--gutter); padding-top: calc(56px + env(safe-area-inset-top, 0px)); }
  .editbar .bar-note { display: none; }
}

/* ═══════════════  CONTENT  ═══════════════ */

main { position: relative; z-index: 2; padding: 0 var(--gutter) 150px; outline: none; }
body.editing main { padding-top: 220px; }
body.editing .stop { scroll-margin-top: 240px; }

.noscript { max-width: 40ch; margin: 30vh auto; text-align: center; }

.opener {
  max-width: 660px; margin: 0 auto; text-align: center;
  padding-block: clamp(64px, 14vh, 130px) clamp(80px, 16vh, 150px);
}
.eyebrow {
  font: 600 10.5px/1.4 var(--f-sign); letter-spacing: .3em; text-transform: uppercase;
  color: var(--amber); margin: 0 0 20px;
}
h1 {
  font: 800 clamp(40px, 11vw, 78px)/.94 var(--f-sign);
  letter-spacing: -.025em; text-transform: uppercase;
  margin: 0 0 24px; text-wrap: balance;
  color: var(--cream); text-shadow: 0 2px 30px rgba(0,0,0,.55);
}
h1 em { font-style: normal; color: var(--amber); }
.standfirst {
  font-size: clamp(17px, 2.4vw, 20px); color: var(--cream);
  margin: 0 auto 26px; max-width: 54ch; text-wrap: pretty;
  text-shadow: 0 1px 14px rgba(0,0,0,.6);
}
.byline { font: 11px/1.5 var(--f-sign); letter-spacing: .2em; text-transform: uppercase; color: var(--cream-dim); margin: 0; }

.note {
  max-width: 640px; margin: 38px auto 0; text-align: left;
  border-left: 2px solid var(--amber); padding: 14px 16px 16px 18px;
  background: linear-gradient(to right, rgba(12,14,19,0.82), rgba(12,14,19,0.55));
  font-size: 15.5px; line-height: 1.6; color: var(--cream-dim);
}
.note p { margin: 0 0 12px; }
.note b { color: var(--cream); font-weight: 500; }
.note p.legend-title {
  margin: 16px 0 8px; font: 700 9.5px/1 var(--f-sign); letter-spacing: .2em;
  text-transform: uppercase; color: var(--amber-dim);
}
.legend {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 8px 16px;
}
.legend-item { display: flex; align-items: center; gap: 10px; background: none; box-shadow: none; }
.legend-chip {
  flex: none; width: 98px; text-align: center;
  font: 700 9.5px/1 var(--f-sign); letter-spacing: .12em; text-transform: uppercase;
  padding: 5px 6px 4px; border-radius: 2px;
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.legend-meaning { font: 13px/1.35 var(--f-sign); color: var(--cream-dim); }

.scrollcue { margin-top: 44px; font: 10.5px var(--f-sign); letter-spacing: .24em; text-transform: uppercase; color: var(--cream-dim); }
.scrollcue i { display: block; font-style: normal; font-size: 18px; margin-top: 6px; animation: bob 2.4s ease-in-out infinite; }
@keyframes bob { 0%, 100% { transform: translateY(0); opacity: .5; } 50% { transform: translateY(7px); opacity: 1; } }

/* ── Signpost ── */

.stop {
  min-height: 94vh; display: flex; align-items: center;
  padding-block: 50px 110px; max-width: 1020px; margin: 0 auto;
  scroll-margin-top: 14vh;
}
.stop.right { justify-content: flex-end; }
.stop.left { justify-content: flex-start; }
.rig { width: min(100%, 478px); padding-top: 21px; }
/* Wide screens: signs stand on the shoulders, clear of the road, not over it. */
@media (min-width: 881px) {
  .stop { max-width: none; }
  .rig { width: clamp(330px, 28vw, 440px); }
  .stop.right { padding-right: 110px; } /* clear of the route rail's age label */
}

.signface {
  position: relative; border-radius: 7px; padding: 15px 20px;
  display: flex; align-items: center; gap: 16px;
  font-family: var(--f-sign);
  background: var(--sg); color: var(--ink-on);
  box-shadow: inset 0 0 0 2px var(--ink-on), inset 0 0 0 5px var(--sg),
    /* Retroreflective: at night the face catches the headlights and glows. */
    0 0 calc(var(--sign-glow) * 34px) calc(var(--sign-glow) * 3px) color-mix(in srgb, var(--sg) 60%, transparent);
  print-color-adjust: exact; -webkit-print-color-adjust: exact;
}
.signface, .exit { transition: filter .6s linear, box-shadow .6s linear; }
.signface { filter: drop-shadow(0 16px 26px rgba(0,0,0,0.5)) brightness(calc(1 + var(--sign-glow) * 0.2)); }
.dest {
  flex: 1; min-width: 0; margin: 0;
  font-size: clamp(19px, 3.6vw, 27px); font-weight: 700;
  line-height: 1.08; letter-spacing: -.012em; text-wrap: balance;
  overflow-wrap: anywhere; outline: none;
}
.dest:empty::before { content: attr(data-placeholder); opacity: .55; }
.mile {
  font: 700 13px/1.15 var(--f-mono); letter-spacing: .04em;
  text-align: right; white-space: nowrap; opacity: .92;
  font-variant-numeric: tabular-nums;
}
.mile b { display: block; font-size: 22px; letter-spacing: 0; }
.mile b.worded { font-size: 15px; line-height: 1.2; max-width: 9ch; white-space: normal; text-wrap: balance; }
.exit {
  position: absolute; top: -21px; right: -2px;
  font: 700 9.5px/1.5 var(--f-mono); letter-spacing: .14em;
  padding: 3px 9px; border-radius: 5px 5px 0 0;
  background: var(--sg); color: var(--ink-on); box-shadow: inset 0 0 0 2px var(--ink-on);
}
.kind {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.sg-guide   { --sg: var(--sg-guide);   --ink-on: var(--sg-light-ink); }
.sg-rec     { --sg: var(--sg-rec);     --ink-on: var(--sg-light-ink); }
.sg-warn    { --sg: var(--sg-warn);    --ink-on: var(--sg-dark-ink); }
.sg-work    { --sg: var(--sg-work);    --ink-on: var(--sg-dark-ink); }
.legend-chip { background: var(--sg); color: var(--ink-on); box-shadow: inset 0 0 0 1.5px var(--ink-on); }

.posts { display: flex; justify-content: center; gap: 120px; height: 28px; }
.posts i {
  display: block; width: 9px; height: 100%;
  background: linear-gradient(to right, #4A4E55, var(--post) 38%, #C3C8CF 52%, var(--post) 66%, #43474E);
  box-shadow: 0 3px 7px rgba(0,0,0,.55);
}

.plaque {
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 3px;
  padding: clamp(18px, 2.8vw, 26px);
  backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
  box-shadow: 0 18px 44px rgba(0,0,0,0.44);
}
.body p { margin: 0 0 .9em; max-width: 65ch; white-space: pre-line; text-wrap: pretty; }
.body p:last-child { margin-bottom: 0; }
.body-edit { display: none; }

.tags { list-style: none; padding: 0; margin: 15px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tags:empty { display: none; }
.tag {
  font: 600 9.5px/1.4 var(--f-sign); letter-spacing: .14em; text-transform: uppercase;
  color: var(--cream-dim); border: 1px solid rgba(239,231,214,0.18); border-radius: 2px; padding: 3px 8px;
}

.snap { margin: 0 0 15px; }
.snap img { display: block; width: 100%; border-radius: 2px; border: 1px solid rgba(239,231,214,0.2); background: #080A0E; }
.snap figcaption { font: 11.5px/1.45 var(--f-sign); color: var(--cream-dim); margin-top: 7px; letter-spacing: .02em; }
.snap.missing img { display: none; }
.snap.missing::before {
  content: "Photo not found in assets/. Add the file before publishing.";
  display: block; padding: 18px; border: 1px dashed #E8795A; color: #E8795A;
  font: 11px var(--f-sign); letter-spacing: .08em;
}
.snap.missing:not(:is(body.editing *)) { display: none; }
.photoslot { display: none; }
body.editing .photoslot {
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 15px; height: 64px;
  border: 1px dashed rgba(239,231,214,0.28); border-radius: 2px;
  background: rgba(239,231,214,0.04);
  font: 10px var(--f-sign); letter-spacing: .18em; text-transform: uppercase; color: var(--cream-dim);
}

/* ── Per-event controls (edit mode) ── */

.controls {
  display: none; margin-top: 16px; padding-top: 15px;
  border-top: 1px solid var(--card-edge);
  flex-wrap: wrap; gap: 10px; align-items: flex-end;
  font-family: var(--f-sign);
}
body.editing .controls { display: flex; }
.field { display: flex; flex-direction: column; gap: 3px; }
.field label { font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--amber-dim); font-weight: 700; }
.field select, .field input {
  background: #080A0E; color: var(--cream); border: 1px solid var(--card-edge);
  border-radius: 3px; padding: 6px 8px; font: 13px var(--f-sign);
}
.field input[type="number"] { width: 92px; font-family: var(--f-mono); }
.field input.age-input { width: 150px; }
.field input.age-input[aria-invalid="true"] { border-color: #E8795A; }
.field .hint { font-size: 10px; color: var(--cream-dim); letter-spacing: .02em; min-height: 1.2em; }
.field.grow { flex: 1 1 180px; }
.field.grow input { width: 100%; }
.control-row { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.page-controls {
  max-width: 640px; margin: 22px auto 0; text-align: left;
  background: var(--card); border: 1px solid var(--card-edge); border-radius: 3px; padding: 14px 16px;
}
.page-controls .field.grow { flex: 1 1 260px; }

body.editing .dest,
body.editing .body-edit { cursor: text; border-bottom: 1px dashed rgba(242,184,75,0.45); min-height: 1.3em; }
body.editing .dest:focus,
body.editing .body-edit:focus { border-bottom-color: var(--amber); background: rgba(242,184,75,0.08); }
body.editing .dest.too-long { border-bottom: 2px solid #E8795A; }
body.editing .body { display: none; }
body:not(.editing) .plaque:not(:has(.body, .tag, .snap)) { display: none; }
body.editing .body-edit { display: block; white-space: pre-wrap; outline: none; padding-bottom: 4px; }
.body-edit:empty::before { content: attr(data-placeholder); font-style: italic; color: var(--cream-dim); }

.closer { max-width: 600px; margin: 0 auto; padding-block: clamp(70px, 14vh, 140px) 60px; text-align: center; }
.closer h2 { font: 800 clamp(26px, 6vw, 40px)/1.1 var(--f-sign); text-transform: uppercase; letter-spacing: -.02em; margin: 0 0 16px; text-wrap: balance; }
.closer p { color: var(--cream-dim); margin: 0 auto; max-width: 48ch; text-shadow: 0 1px 12px rgba(0,0,0,.6); }

@media (max-width: 880px) {
  .rail { display: none; }
  .rig { width: 100%; }
  .stop { min-height: 82vh; }
  .posts { gap: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; --drive: 0s; }
  .rays { animation: none; }
  .scrollcue i { animation: none; }
}

/* ═══════════════  PRINT  ═══════════════ */

@media print {
  @page { margin: 16mm 16mm 18mm; }
  :root { --sign-glow: 0 !important; }

  .world, .rain, .rail, .cowl, .editbar, .editToggle, .banner, .skip,
  .scrollcue, .controls, .photoslot, .body-edit, .note, .snap.missing {
    display: none !important;
  }
  :root { scroll-behavior: auto; }
  body { background: #fff; color: #15171C; font-size: 11pt; line-height: 1.5; }
  main, body.editing main { padding: 0 !important; }

  .opener { padding: 0 0 14pt; margin: 0 0 12pt; text-align: left; max-width: none; border-bottom: 1.5pt solid #15171C; }
  .eyebrow { color: #55585F; margin-bottom: 6pt; font-size: 8.5pt; }
  h1 { color: #15171C; text-shadow: none; font-size: 26pt; margin-bottom: 8pt; }
  h1 br { display: none; }
  h1 em { color: #8A6420; }
  .standfirst { color: #15171C; text-shadow: none; font-size: 11pt; margin: 0 0 6pt; max-width: none; }
  .byline { color: #55585F; font-size: 8.5pt; }

  .stop, body.editing .stop {
    min-height: 0; display: block; max-width: none; margin: 0;
    padding: 0 0 14pt; break-inside: avoid; page-break-inside: avoid;
  }
  .rig { width: 100%; padding-top: 14pt; }
  .signface { filter: none; border-radius: 4pt; padding: 8pt 12pt; }
  .dest { font-size: 14pt; }
  body.editing .dest { border: 0; }
  .mile { font-size: 8pt; }
  .mile b { font-size: 13pt; }
  .exit { top: -14pt; font-size: 7pt; }
  /* Sign type as text, so color is never the only carrier. */
  .kind {
    position: static; width: auto; height: auto; clip: auto; overflow: visible;
    font: 700 7.5pt var(--f-sign); letter-spacing: .14em; text-transform: uppercase;
    opacity: .85; margin-left: 4pt;
  }
  .posts { display: none; }
  .plaque {
    background: #fff; color: #15171C; border: 1px solid #C8C6C0; border-top: 0;
    backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none;
    border-radius: 0 0 3pt 3pt; padding: 10pt 12pt;
  }
  .plaque:not(:has(.body, .tag, .snap)) { display: none; }
  .body p { color: #15171C; }
  body.editing .body { display: block; }
  .tag { color: #55585F; border-color: #C8C6C0; }
  .snap { break-inside: avoid; }
  .snap img { max-height: 90mm; width: auto; border-color: #C8C6C0; }
  .snap figcaption { color: #55585F; }
  .closer { display: none; }
}
