:root {
  --canvas: #efe9dc;
  --panel: #f7f3ea;
  --road: #cfc7b5;
  --jam: #c73d3c; /* text-safe red (4.9:1); the map uses #E24B4A */
  --slow: #ef9f27;
  --text: #3b3730;
  --text2: #6b645b; /* 4.8:1 on the canvas */
  --line: #ddd5c4;
  --bus: #f5c518;
  --school: #3d3a8c;
  --ontime: #237a52; /* text-safe green; the map ring uses #2F9E6B */
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; height: 100dvh; background: var(--canvas); color: var(--text); font-family: var(--font); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
a { color: var(--text); }

/* 100dvh, so a phone's shrinking address bar never hides the bottom sheet */
#app { position: fixed; inset: 0; height: 100dvh; }

/* ---- maps ---- */
#maps { position: absolute; inset: 0; display: flex; }
.map { position: relative; flex: 1; margin: 0; min-width: 0; }
.map + .map { border-left: 2px solid var(--line); }
.map canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.map canvas:active { cursor: grabbing; }
.map figcaption {
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 118px;
  font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text2); background: var(--canvas); padding: 4px 10px; border-radius: 99px;
  pointer-events: none;
}
.map figcaption:empty { display: none; }
#app.split .map figcaption { top: 16px; bottom: auto; }

/* ---- HUD: designed for the screenshot first ---- */
#hud { position: absolute; top: 20px; left: 24px; pointer-events: none; max-width: min(420px, calc(100vw - 48px)); text-shadow: 0 0 3px var(--canvas), 0 0 10px var(--canvas); }
.brand { display: flex; gap: 10px; align-items: baseline; font-size: 12px; color: var(--text2); margin-bottom: 14px; }
.brand strong { color: var(--text); font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.hero-label { font-size: 13px; font-weight: 600; color: var(--text2); }
.hero-row { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.hero-num { font-size: clamp(48px, 8vw, 84px); font-weight: 800; letter-spacing: -.035em; line-height: 1; font-variant-numeric: tabular-nums; }
.delta { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hero-range { font-size: 12px; color: var(--text2); margin-top: 6px; font-variant-numeric: tabular-nums; min-height: 1em; }
.quiet { margin: 12px 0 0; font-size: 12.5px; color: var(--text2); font-variant-numeric: tabular-nums; }
.quiet b { color: var(--text); font-weight: 700; }
.quiet small { font-weight: 600; color: var(--text2); margin-left: 3px; }
.hero-num { transition: color .4s; }
.delta.good { color: var(--ontime); animation: pop .6s ease-out; }
.delta.bad { color: var(--jam); animation: shake .45s ease-in-out; }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.12); opacity: 1; } 100% { transform: scale(1); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(5px); } 60% { transform: translateX(-3px); } 80% { transform: translateX(2px); } }
.scenario-name { margin-top: 12px; font-size: 12px; font-weight: 600; color: var(--text2); }

#clockbox { position: absolute; top: 16px; right: 24px; text-align: right; pointer-events: none; text-shadow: 0 0 3px var(--canvas), 0 0 8px var(--canvas), 0 0 14px var(--canvas); }
#clock { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
#counters { font-size: 12.5px; font-weight: 600; color: var(--text2); margin-top: 6px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#counters b { color: var(--text); }
#counters .jam { color: var(--jam); }
#counters i { display: inline-block; width: 16px; height: 8px; border-radius: 2px; background: var(--bus); box-shadow: inset 0 0 0 1.2px var(--text); margin-right: 5px; vertical-align: 0; }
#policy-toggle { position: absolute; top: 96px; right: 24px; }

/* ---- moments ticker ---- */
#ticker { position: absolute; left: 24px; bottom: 124px; margin: 0; padding: 0; list-style: none; display: flex; flex-direction: column-reverse; gap: 6px; max-width: min(440px, calc(100vw - 48px)); pointer-events: none; }
#ticker li { background: var(--panel); border-radius: 12px; padding: 8px 12px 8px 14px; font-size: 13.5px; font-weight: 600; line-height: 1.35; box-shadow: 0 0 0 1.5px var(--line), 0 6px 18px rgba(59,55,48,.08); border-left: 4px solid var(--school); animation: slidein .35s ease-out; transition: opacity .4s; }
#ticker li.bad { border-left-color: var(--jam); }
#ticker li.good { border-left-color: var(--ontime); }
#ticker li:nth-child(2) { opacity: .6; }
#ticker li:nth-child(3) { opacity: .3; }
@keyframes slidein { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- end-of-morning card ---- */
#endcard { position: absolute; left: 50%; bottom: 124px; transform: translateX(-50%); width: min(520px, calc(100vw - 24px)); background: var(--text); color: var(--panel); border-radius: 20px; padding: 20px 24px 18px; box-shadow: 0 18px 50px rgba(59,55,48,.3); animation: slidein .4s ease-out; z-index: 4; }
#endcard[hidden] { display: none; }
#endcard .close { position: absolute; top: 8px; right: 8px; color: var(--panel); }
#endcard .close:hover { background: rgba(255,255,255,.1); }
.end-kicker { margin: 0; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--bus); }
.end-line { margin: 8px 0 0; font-size: 22px; font-weight: 800; letter-spacing: -.01em; line-height: 1.25; }
.end-sub { margin: 8px 0 0; font-size: 13.5px; line-height: 1.45; color: #d9d2c3; }
.end-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
#endcard .pill { background: rgba(255,255,255,.1); color: var(--panel); box-shadow: none; }
#endcard .pill.primary { background: var(--bus); color: var(--text); }

/* ---- controls ---- */
.pill { border: 0; background: var(--panel); border-radius: 99px; padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer; box-shadow: inset 0 0 0 1.5px var(--line); }
.pill:hover { box-shadow: inset 0 0 0 1.5px var(--road); }
.pill.primary { background: var(--text); color: var(--panel); box-shadow: none; }
.pill[aria-pressed="true"] { background: var(--text); color: var(--panel); box-shadow: none; }
.icon { border: 0; background: none; cursor: pointer; font-size: 22px; line-height: 1; padding: 6px 8px; border-radius: 8px; }
.icon:hover { background: var(--line); }
.link { border: 0; background: none; padding: 0; font-size: 12px; color: var(--text2); text-decoration: underline; cursor: pointer; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ---- policy panel ---- */
#policy {
  position: absolute; top: 12px; right: 12px; bottom: 124px; width: 360px; overflow: auto;
  background: var(--panel); border-radius: 18px; padding: 18px 20px; box-shadow: 0 0 0 1.5px var(--line);
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-intro { font-size: 13px; color: var(--text2); margin: 6px 0 4px; line-height: 1.45; }
.policy { border-top: 1.5px solid var(--line); padding: 14px 0 6px; margin-top: 12px; }
.policy-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.policy h3 { margin: 0; font-size: 15px; }
.tier { font-size: 10.5px; font-weight: 700; letter-spacing: .02em; padding: 3px 8px; border-radius: 99px; background: var(--canvas); color: var(--text2); white-space: nowrap; }
.row { display: flex; justify-content: space-between; font-size: 13px; margin: 12px 0 6px; font-weight: 600; }
.row output { color: var(--text2); font-weight: 600; }
input[type="range"] { width: 100%; accent-color: var(--text); }
.ticks { display: flex; justify-content: space-between; font-size: 10.5px; color: var(--text2); margin-top: 2px; }
.switch { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; line-height: 1.35; margin: 12px 0 4px; cursor: pointer; }
.switch input { width: 18px; height: 18px; margin: 0; flex: none; accent-color: var(--text); }
.note { font-size: 12px; color: var(--text2); margin: 6px 0 0 28px; line-height: 1.4; }
.evidence { font-size: 12px; color: var(--text2); line-height: 1.45; margin: 10px 0 4px; }
details { margin: 8px 0 0; font-size: 12.5px; }
summary { cursor: pointer; color: var(--text2); font-weight: 600; }
#bell-list { list-style: none; padding: 0; margin: 8px 0 0; columns: 1; }
#bell-list li { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; border-bottom: 1px solid var(--line); }
#bell-list li span:last-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
#bell-list .moved { font-weight: 700; }
.panel-foot { border-top: 1.5px solid var(--line); margin-top: 14px; padding-top: 14px; display: flex; justify-content: flex-end; }
#policy.busy { cursor: progress; }

/* ---- dock ---- */
#dock { position: absolute; left: 12px; right: 12px; bottom: 12px; background: var(--panel); border-radius: 18px; padding: 10px 16px 8px; box-shadow: 0 0 0 1.5px var(--line); }
.dock-row { display: flex; align-items: center; gap: 12px; }
.play { font-size: 15px; width: 38px; height: 38px; border-radius: 99px; background: var(--text); color: var(--panel); flex: none; }
.play:hover { background: var(--text); opacity: .9; }
#scrub-wrap { position: relative; flex: 1; height: 52px; }
#scrub { position: absolute; inset: 0; width: 100%; height: 100%; }
#scrubber { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.dock-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 4px; font-size: 11.5px; color: var(--text2); flex-wrap: wrap; }
.lg { display: inline-block; width: 14px; height: 5px; border-radius: 3px; margin: 0 5px 1px 10px; vertical-align: middle; }
.lg:first-child { margin-left: 0; }
.lg.jam { background: var(--jam); }
.lg.slow { background: var(--slow); }
.lg.bus { background: var(--bus); box-shadow: inset 0 0 0 1.2px var(--text); width: 16px; height: 8px; border-radius: 2px; }
.lg.school { width: 10px; height: 10px; border-radius: 99px; background: var(--school); box-shadow: 0 0 0 2px var(--ontime); }
.lg.dot { width: 6px; height: 6px; background: #fbf8f2; box-shadow: inset 0 0 0 1.2px var(--text2); border-radius: 99px; }
.lg.jam, .lg.slow { box-shadow: 0 0 5px 1px currentColor; }
.lg.jam { color: rgba(226,75,74,.5); }
.lg.slow { color: rgba(239,159,39,.5); }
#legend b.ok { color: var(--ontime); }
#legend b.bad { color: var(--jam); }
.why { margin: 8px 0 0; }
.why summary { font-size: 12px; }

#tip { position: absolute; pointer-events: none; background: var(--text); color: var(--panel); font-size: 12px; line-height: 1.4; padding: 8px 10px; border-radius: 10px; max-width: 260px; }
#tip small { color: #cfc7b5; }
#loading { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 600; color: var(--text2); background: var(--canvas); }
#loading[hidden] { display: none; }

dialog#about { max-width: 620px; width: calc(100vw - 32px); max-height: calc(100vh - 48px); border: 0; border-radius: 18px; background: var(--panel); color: var(--text); padding: 24px 28px; line-height: 1.5; font-size: 14px; }
dialog#about::backdrop { background: rgba(59, 55, 48, .35); }
dialog#about h2 { margin-top: 0; }
dialog#about h3 { font-size: 14px; margin: 18px 0 4px; }
dialog#about .close { position: absolute; top: 14px; right: 14px; }
dialog#about ul { padding-left: 18px; }

/* ---- split view ---- */
#app.split #maps { flex-direction: row; }

/* ---- phones ---- */
@media (max-width: 700px) {
  #hud { top: 12px; left: 16px; }
  .brand { margin-bottom: 8px; }
  .quiet { font-size: 11.5px; }
  #clockbox { top: 12px; right: 16px; }
  #clock { font-size: 24px; }
  #counters { font-size: 11px; }
  #counters .long { display: none; }
  #ticker { left: 12px; right: 12px; bottom: 164px; max-width: none; }
  #ticker li:nth-child(n+2) { display: none; }
  #endcard { bottom: 112px; }
  #follow { display: none; }
  #policy-toggle { top: auto; bottom: 112px; right: 16px; }
  #policy { left: 8px; right: 8px; top: auto; bottom: 8px; width: auto; max-height: 72vh; border-radius: 18px; z-index: 5; }
  #dock { left: 8px; right: 8px; bottom: 8px; padding: 8px 10px 6px; }
  #legend { display: none; }
  .map figcaption { bottom: 108px; }
  #app.split #maps { flex-direction: column; }
  #app.split .map + .map { border-left: 0; border-top: 2px solid var(--line); }
}

/* =====================================================================
   Story mode: the guided experience (phone first)
   ===================================================================== */
#app:not(.story) #story { display: none; }
#app.story #hud, #app.story #policy-toggle, #app.story #policy, #app.story #dock,
#app.story #ticker, #app.story #endcard { display: none; }
#hud .brand .link { pointer-events: auto; margin-left: 6px; }
#app.story #clockbox { top: 60px; }

#story { position: absolute; inset: 0; pointer-events: none; }
#story > * { pointer-events: auto; }
#story [hidden] { display: none !important; }

#topbar { position: absolute; z-index: 2; top: 0; left: 0; right: 0; height: 52px; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 16px; background: linear-gradient(var(--canvas) 55%, transparent); }
#topbar .brand { margin: 0; }
.pill.ghost { background: transparent; box-shadow: inset 0 0 0 1.5px var(--line); padding: 7px 14px; font-size: 13px; }
.pill.big { padding: 13px 20px; font-size: 16px; font-weight: 700; }
.pill:disabled { opacity: .45; cursor: not-allowed; }
.chip { border: 0; background: var(--panel); box-shadow: inset 0 0 0 1.5px var(--line); border-radius: 99px; padding: 6px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.big { padding: 10px 16px; font-size: 14.5px; }
.chip[aria-pressed="true"] { background: var(--text); color: var(--panel); box-shadow: none; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.icon.round { width: 36px; height: 36px; border-radius: 99px; background: var(--text); color: var(--panel); font-size: 13px; }
.kicker { margin: 0 0 6px; font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--school); }
.kicker.good { color: var(--ontime); }
.kicker.bad { color: var(--jam); }

#goal { position: absolute; top: 58px; left: 16px; max-width: calc(100% - 170px); font-size: 12px; line-height: 1.35; color: var(--text2); background: var(--panel); border-radius: 12px; padding: 6px 10px; box-shadow: 0 0 0 1.5px var(--line); }
#goal span { font-weight: 800; color: var(--text); }
#goal.done span { color: var(--ontime); }
#mode-label { position: absolute; top: 118px; right: 16px; font-size: 11px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--school); background: var(--panel); padding: 3px 8px; border-radius: 99px; box-shadow: 0 0 0 1.5px var(--line); }

/* ---- the front door ---- */
#door { position: absolute; inset: 0; display: flex; align-items: flex-end; background: linear-gradient(to top, var(--canvas) 48%, rgba(239,233,220,.75) 70%, rgba(239,233,220,.15)); }
.door-card { width: 100%; max-width: 560px; padding: 24px 20px 28px; }
#hook { margin: 0; font-size: clamp(28px, 7.4vw, 46px); line-height: 1.08; letter-spacing: -.025em; font-weight: 800; }
.door-sub { margin: 12px 0 20px; font-size: 15px; line-height: 1.5; color: var(--text2); }
#door-ride { width: 100%; }
.search { margin-top: 18px; position: relative; }
.search label { display: block; font-size: 13px; font-weight: 600; color: var(--text2); margin-bottom: 6px; }
#door-search { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 14px; border: 0; background: var(--panel); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--text); }
#door-search:focus { outline: none; box-shadow: inset 0 0 0 2px var(--school); }
#door-results { list-style: none; margin: 6px 0 0; padding: 6px; background: var(--panel); border-radius: 14px; box-shadow: 0 0 0 1.5px var(--line), 0 12px 30px rgba(59,55,48,.12); }
#door-results button { display: flex; width: 100%; justify-content: space-between; gap: 10px; border: 0; background: none; padding: 10px; border-radius: 10px; text-align: left; cursor: pointer; font-size: 14.5px; }
#door-results button:hover, #door-results button:focus-visible { background: var(--canvas); }
#door-results span { color: var(--text2); font-size: 12.5px; white-space: nowrap; }
#door-results .empty { padding: 10px; font-size: 13.5px; color: var(--text2); line-height: 1.45; }
.door-why { margin: 16px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text2); }
.door-foot { margin: 10px 0 0; font-size: 12px; color: var(--text2); }

/* ---- sheets: bottom sheet on phones, side panel on desktop ---- */
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 80vh; overflow: auto; background: var(--panel); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(59,55,48,.16); animation: sheetin .35s ease-out; }
@keyframes sheetin { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.sheet-inner { padding: 22px 20px max(26px, calc(env(safe-area-inset-bottom) + 16px)); }
.sheet h2:focus { outline: none; }
.sheet h2 { margin: 0; font-size: 24px; line-height: 1.2; letter-spacing: -.015em; }
.sheet h2 mark { background: var(--bus); padding: 0 6px; border-radius: 6px; color: var(--text); }
.sheet .sub { margin: 10px 0 0; font-size: 14.5px; line-height: 1.55; color: var(--text2); }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; }
.actions.quiet { margin-top: 14px; gap: 18px; }
.actions .link { font-size: 13px; }

.yours { margin-top: 18px; border-top: 1.5px solid var(--line); padding-top: 12px; font-size: 13.5px; }
.yours summary { font-weight: 600; color: var(--text); }
.yours form { display: grid; gap: 6px; margin-top: 10px; }
.yours .row { display: flex; gap: 8px; }
.yours input { width: 120px; font: inherit; font-size: 16px; padding: 8px 10px; border: 0; border-radius: 10px; box-shadow: inset 0 0 0 1.5px var(--line); background: #fff; }
.yours small { color: var(--text2); }
.compare { margin: 10px 0 0; font-weight: 600; }

.move-wrap { margin-top: 12px; }
.move { display: grid; gap: 3px; width: 100%; text-align: left; border: 0; border-radius: 16px; padding: 14px 16px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); cursor: pointer; font: inherit; color: var(--text); transition: box-shadow .15s, background .15s; }
.move.static { cursor: default; }
.move[aria-pressed="true"] { background: #fffaf0; box-shadow: inset 0 0 0 2.5px var(--text); }
.move[aria-pressed="true"] .move-title::after { content: " ✓"; }
.move-title { font-size: 16px; font-weight: 800; }
.move-what { font-size: 13.5px; color: var(--text); }
.move-cost { font-size: 12.5px; color: var(--text2); }
.move-cost::before { content: "Trade-off: "; font-weight: 700; }
.move .chips { margin: 8px 0 0; gap: 6px; }
.why { margin: 6px 4px 0; font-size: 12.5px; color: var(--text2); }
.why p { margin: 6px 0 0; line-height: 1.5; }

.guess { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 18px; }

.versus { display: flex; align-items: center; gap: 16px; margin: 6px 0 14px; }
.versus div { display: grid; }
.versus small { font-size: 12px; color: var(--text2); font-weight: 600; }
.versus b { font-size: 34px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.versus b.good { color: var(--ontime); }
.versus b.bad { color: var(--jam); }
.versus .arrow { font-size: 24px; color: var(--text2); }
.corridor { margin: 12px 0 0; font-size: 13px; color: var(--text2); }
.corridor b { color: var(--text); font-variant-numeric: tabular-nums; }
.celebrate { margin: 14px 0 0; padding: 10px 12px; border-radius: 12px; background: #e8f5ee; color: #1f6e4a; font-weight: 700; font-size: 14px; }
blockquote { margin: 6px 0 0; font-size: 18px; line-height: 1.45; font-weight: 600; border-left: 4px solid var(--bus); padding-left: 14px; }
.status { font-size: 13px; color: var(--text2); min-height: 1em; word-break: break-all; }

/* ---- journey card ---- */
.j-bar { position: relative; height: 12px; border-radius: 99px; background: var(--canvas); box-shadow: inset 0 0 0 1.5px var(--line); margin-top: 12px; overflow: hidden; }
.j-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--bus); border-right: 2px solid var(--text); }
.j-ticks i { position: absolute; top: 2px; bottom: 2px; width: 2px; margin-left: -1px; background: var(--text); opacity: .5; border-radius: 2px; }

#beat { position: absolute; left: 16px; right: 16px; top: 108px; margin: 0 auto; max-width: 460px; background: var(--text); color: var(--panel); border-radius: 14px; padding: 12px 16px; font-size: 15px; font-weight: 700; line-height: 1.4; box-shadow: 0 12px 30px rgba(59,55,48,.25); animation: beatin .4s ease-out; border-left: 5px solid var(--bus); }
#beat.jam { border-left-color: var(--jam); }
#beat.arrive { border-left-color: var(--ontime); }
@keyframes beatin { from { transform: translateY(-10px) scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---- a small celebration ---- */
body.confetti::after { content: "🎉 🚌 🎉 ✨ 🎉 🚌 🎉"; position: fixed; left: 0; right: 0; top: 30%; text-align: center; font-size: 42px; letter-spacing: 12px; pointer-events: none; animation: burst 2.4s ease-out forwards; z-index: 10; }
@keyframes burst { 0% { transform: scale(.4); opacity: 0; } 20% { transform: scale(1.1); opacity: 1; } 100% { transform: translateY(-80px) scale(1); opacity: 0; } }

/* ---- desktop: sheets and the journey become a left-hand panel ---- */
@media (min-width: 900px) {
  #door { align-items: center; background: linear-gradient(to right, var(--canvas) 38%, rgba(239,233,220,.7) 55%, rgba(239,233,220,0) 75%); }
  .door-card { padding: 0 0 0 56px; }
  #door-ride { width: auto; }
  .sheet, .journey { left: 16px; right: auto; top: 64px; bottom: auto; width: 420px; max-height: calc(100vh - 80px); border-radius: 22px; box-shadow: 0 0 0 1.5px var(--line), 0 18px 50px rgba(59,55,48,.12); }
  .sheet-inner { padding: 26px 26px 28px; }
  .guess { grid-template-columns: repeat(3, 1fr); }
  #goal { left: 452px; top: 14px; max-width: none; }
  #topbar .brand { min-width: 420px; }
  #beat { left: 452px; right: 16px; top: 72px; }
  #app.story #clockbox { top: 64px; }
  #mode-label { top: 128px; right: 24px; }
}
@media (max-width: 899px) {
  #beat { top: 152px; }
  #topbar .brand > span { display: none; }   /* the tagline, not the area chip */
  #app.story #clockbox { right: 16px; }
  #app.story #clock { font-size: 24px; }
}
.tradeoff { margin: 12px 0 0; padding: 10px 12px; border-radius: 12px; background: #fdf0e0; color: #7a4a0c; font-size: 14px; line-height: 1.45; }
.linkfield { width: 100%; margin-top: 14px; font: inherit; font-size: 13px; padding: 9px 11px; border: 0; border-radius: 10px; background: #fff; box-shadow: inset 0 0 0 1.5px var(--line); color: var(--text2); }

/* ---- attribution and about ---- */
.attrib { font-size: 10.5px; color: var(--text2); text-decoration: none; white-space: nowrap; }
.attrib:hover { text-decoration: underline; }
#topbar .attrib { margin-left: auto; }
.dock-links { display: inline-flex; gap: 12px; align-items: center; }
dialog#about .pill { display: inline-block; text-decoration: none; margin-top: 6px; }
.about-foot { font-size: 12px; color: var(--text2); margin-bottom: 0; }
@media (max-width: 420px) { #topbar .attrib { font-size: 9.5px; } }

/* ---- people who ask for less motion get none of it ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  body.confetti::after { display: none; }
}
#unsupported { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; background: var(--canvas); font-weight: 600; line-height: 1.5; z-index: 20; }

/* =====================================================================
   City front door
   ===================================================================== */
#app:not(.city) #city { display: none; }
#app.city > :not(#city):not(dialog):not(#loading) { display: none !important; }
#city { position: absolute; inset: 0; overflow-y: auto; background: var(--canvas); }
.city-top { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: linear-gradient(var(--canvas) 70%, rgba(239,233,220,0)); }
.city-top .brand { margin: 0; }
.city-top #city-about { margin-left: auto; }
.city-mapwrap { height: 42vh; min-height: 260px; }
#city-map { width: 100%; height: 100%; display: block; }
.city-panel { padding: 8px 20px 40px; max-width: 560px; }
#city-hook { margin: 0; font-size: clamp(26px, 6.6vw, 42px); line-height: 1.1; letter-spacing: -.022em; font-weight: 800; }
.city-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.city-actions #city-ride { flex: 1 1 auto; }
#city-results { list-style: none; margin: 6px 0 0; padding: 6px; background: var(--panel); border-radius: 14px; box-shadow: 0 0 0 1.5px var(--line), 0 12px 30px rgba(59,55,48,.12); }
#city-results button { display: flex; width: 100%; justify-content: space-between; gap: 10px; border: 0; background: none; padding: 10px; border-radius: 10px; text-align: left; cursor: pointer; font-size: 14.5px; }
#city-results button:hover, #city-results button:focus-visible { background: var(--canvas); }
#city-results span { color: var(--text2); font-size: 12.5px; white-space: nowrap; }
#city-results .empty { padding: 10px; font-size: 13.5px; color: var(--text2); line-height: 1.45; }
#city-search { width: 100%; font: inherit; font-size: 16px; padding: 12px 14px; border-radius: 14px; border: 0; background: var(--panel); box-shadow: inset 0 0 0 1.5px var(--line); color: var(--text); }
#city-search:focus { outline: none; box-shadow: inset 0 0 0 2px var(--school); }
.city-h { margin: 28px 0 8px; font-size: 13px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--text2); }
.city-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.corridor-card { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; border-radius: 14px; padding: 12px 14px; background: var(--panel); box-shadow: inset 0 0 0 1.5px var(--line); cursor: pointer; font: inherit; color: var(--text); }
.corridor-card:hover { box-shadow: inset 0 0 0 2px var(--text); }
.corridor-card .dot { width: 14px; height: 14px; border-radius: 99px; flex: none; }
.corridor-card.live .dot { background: var(--bus); box-shadow: 0 0 0 2px var(--text); }
.corridor-card.planned .dot { border: 2px dashed var(--school); }
.cc-text { display: grid; flex: 1; }
.cc-text small { color: var(--text2); font-size: 12.5px; }
.corridor-card .go { color: var(--text2); font-size: 18px; }
#city-sheet { z-index: 5; }
#city-sheet h3 { margin: 16px 0 4px; font-size: 15px; }
#city-sheet ul { margin: 4px 0 0; padding-left: 20px; font-size: 14.5px; line-height: 1.5; }
#city-sheet p { font-size: 14.5px; line-height: 1.55; }
.corridor-chip { margin-left: 4px; padding: 5px 10px; font-size: 12.5px; }
@media (min-width: 900px) {
  #city { overflow: hidden; }
  .city-top { position: absolute; left: 0; right: 0; background: linear-gradient(var(--canvas) 55%, rgba(239,233,220,0)); }
  .city-mapwrap { position: absolute; inset: 0 0 0 440px; height: auto; }
  .city-panel { position: absolute; top: 56px; left: 0; bottom: 0; width: 440px; overflow-y: auto; padding: 24px 28px 40px 32px; }
  #city-sheet { left: auto; right: 16px; top: 64px; width: 420px; }
}
@media (max-width: 480px) { .city-top .brand span { display: none; } }

/* ---- city map: tooltip, coverage line, school/society search results ---- */
/* the tooltip needs a positioned parent; on desktop the map is already absolute */
@media (max-width: 899px) { .city-mapwrap { position: relative; } }
#city-tip { position: absolute; z-index: 2; max-width: 220px; pointer-events: none; background: var(--text); color: var(--panel); font-size: 12px; line-height: 1.35; padding: 6px 9px; border-radius: 8px; box-shadow: 0 6px 18px rgba(59,55,48,.25); }
#city-tip span { color: #d9d2c3; }
.coverage { margin: 12px 2px 0; font-size: 12.5px; line-height: 1.45; color: var(--text2); }
.sheet .src { margin: 6px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text2); }
#city-results .r-name { display: grid; gap: 1px; }
#city-results .r-name small { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text2); }
#city-results .r-where { color: var(--text2); font-size: 12.5px; white-space: nowrap; align-self: center; }
#city-results .dim b { color: var(--text2); }

/* ---- toast: brief confirmations (link copied) ---- */
#toast { position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); z-index: 6; max-width: min(460px, calc(100vw - 32px)); background: var(--text); color: var(--panel); font-size: 13.5px; font-weight: 600; line-height: 1.4; padding: 10px 14px; border-radius: 12px; box-shadow: 0 10px 30px rgba(59,55,48,.25); animation: slidein .25s ease-out; word-break: break-all; }
#toast[hidden] { display: none; }
@media (min-width: 900px) { #toast { left: 236px; bottom: 24px; transform: none; } }

/* ---- story top bar: back on the left, About on the right, nothing between ---- */
#topbar { gap: 8px; }
#topbar .brand { min-width: 0; display: flex; align-items: baseline; gap: 6px; }
.corridor-chip { flex: none; white-space: nowrap; max-width: min(60vw, 320px); overflow: hidden; text-overflow: ellipsis; }
.corridor-chip:hover { background: var(--canvas); }
#to-explore { flex: none; white-space: nowrap; }
@media (max-width: 560px) {
  /* the wordmark goes: by now you know where you are, and the back control
     plus the area name need the room */
  #topbar .brand strong { display: none; }
  #to-explore .long { display: none; }
  .corridor-chip { margin-left: 0; max-width: calc(100vw - 130px); }
}
/* explore mode on a phone: keep the clock off the back link */
@media (max-width: 560px) { #hud .brand { padding-right: 96px; } }
#toast .linkfield { margin-top: 8px; background: rgba(255,255,255,.12); color: var(--panel); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.25); }

/* ---- what's here now, and what's coming ---- */
.soon-note { margin: 22px 0 0; font-size: 12.5px; font-weight: 600; color: var(--text2); }
.soon-note span { font-weight: 800; color: var(--text); }
.soon-note .soon { color: var(--school); text-transform: uppercase; letter-spacing: .04em; font-size: 11px; }

/* ---- the ride card: a bus ticket. Strip = journey + controls, stub = status ---- */
.journey { position: absolute; left: 0; right: 0; bottom: 0; background: var(--panel); border-radius: 22px 22px 0 0; box-shadow: 0 -10px 40px rgba(59,55,48,.16); animation: sheetin .35s ease-out; overflow: hidden; }
.j-strip { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; background: var(--text); color: var(--panel); padding: 12px 16px; }
.j-strip-text { min-width: 0; }
.j-title { margin: 0; font-size: 15px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; line-height: 1.2; }
.j-who { margin: 3px 0 0; font-size: 12px; color: #d9d2c3; }
.j-who .ill { text-transform: uppercase; letter-spacing: .05em; font-size: 10px; font-weight: 700; }
.j-ctrl { display: flex; gap: 6px; align-items: center; flex: none; }
.j-ctrl .icon.round { width: 32px; height: 32px; background: var(--bus); color: var(--text); font-size: 12px; }
.chip.ghost { background: transparent; color: var(--panel); box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35); padding: 6px 10px; }
.chip.ghost:hover { box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.7); }
.j-toggle { color: var(--panel); font-size: 16px; line-height: 1; padding: 6px; }
.j-toggle:hover { background: rgba(255,255,255,.12); }

.j-stub { padding: 16px 18px max(18px, calc(env(safe-area-inset-bottom) + 10px)); }
.j-hero { margin: 0 0 12px; display: flex; align-items: baseline; gap: 10px; }
.j-hero b { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.j-hero span { font-size: 13px; font-weight: 600; color: var(--text2); }
.j-tear { height: 0; border-top: 2px dashed var(--line); margin: 14px -18px 12px; position: relative; }
.j-tear::before, .j-tear::after { content: ""; position: absolute; top: -9px; width: 16px; height: 16px; border-radius: 99px; background: var(--canvas); }
.j-tear::before { left: -8px; }
.j-tear::after { right: -8px; }
.j-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.j-stats { display: flex; flex-wrap: wrap; gap: 2px 14px; margin: 0; font-size: 13px; color: var(--text2); font-variant-numeric: tabular-nums; }
.j-stats b { color: var(--text); }
.j-stats .jam, .j-stats .jam b { color: var(--jam); }
.journey.mini #j-body { display: none; }
.journey.mini .j-toggle { transform: rotate(180deg); }
.j-mini { margin: 0; padding: 10px 18px max(12px, calc(env(safe-area-inset-bottom) + 8px)); font-size: 14px; font-weight: 700; font-variant-numeric: tabular-nums; }

@media (min-width: 900px) {
  .journey { left: 16px; right: auto; top: 64px; bottom: auto; width: 420px; border-radius: 22px; box-shadow: 0 0 0 1.5px var(--line), 0 18px 50px rgba(59,55,48,.12); }
  .j-strip { border-radius: 22px 22px 0 0; }
}

/* a copy is invisible otherwise: say it on the button, where the eye already is */
.pill.copied, .chip.copied { background: var(--ontime); color: var(--panel); box-shadow: none; }

/* ---- phones: the summary is the payoff, so let it own the space it sits in ---- */
@media (max-width: 560px) {
  .sheet-inner { padding: 26px 20px max(28px, calc(env(safe-area-inset-bottom) + 18px)); }
  .sheet h2 { font-size: 28px; }
  .sheet .sub { font-size: 15px; margin-top: 12px; }
  .sheet .actions { margin-top: 20px; }
  .sheet .actions .pill.big { width: 100%; padding: 15px 20px; }
  .sheet .actions.quiet { margin-top: 16px; gap: 18px; }
}

/* ---- the area door's school list: the same cards the front door uses ---- */
.corridor-card.school .dot { background: var(--school); box-shadow: 0 0 0 2px var(--panel), 0 0 0 3.5px var(--school); width: 10px; height: 10px; }
.corridor-card.school { padding: 11px 14px; }
.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; }

/* ---- the card must never outgrow the window: it clipped its own area name ---- */
@media (max-width: 899px) {
  .door-card { max-height: calc(100% - 200px); overflow-y: auto; overscroll-behavior: contain; }
}
@media (min-width: 900px) {
  .door-card { max-height: calc(100dvh - 96px); overflow-y: auto; overscroll-behavior: contain; }
}

.door-more { display: block; margin: 16px 0 0; font-size: 14.5px; color: var(--text2); }
.door-schools .chips { margin-top: 8px; }
.about-why { margin: 8px 0 0; font-size: 14px; line-height: 1.5; color: var(--text2); }
.chip .km { font-weight: 500; color: var(--text2); }
@media (max-width: 699px) {
  /* "Where do you live?": smaller chips leave the map more room */
  .chips.places { gap: 6px; }
  .chips.places .chip.big { padding: 7px 12px; font-size: 13.5px; }
}
/* end-of-ride summary: one fact per line, then two equal buttons */
.facts { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 10px; }
.facts li { display: flex; gap: 12px; align-items: baseline; font-size: 16px; font-weight: 600; line-height: 1.35; }
.facts .ico { flex: none; width: 22px; text-align: center; font-size: 17px; }
.facts-note { margin: 12px 0 0; font-size: 12.5px; line-height: 1.5; color: var(--text2); }
.actions.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.actions.pair .pill { padding: 12px 10px; font-size: 14.5px; }

/* ---- host page hooks (see src/host.ts) */
.host-next { margin: 12px 0 0; font-size: 14px; }
.host-next a { color: var(--text); font-weight: 600; }
.facts-note.caveat { font-size: 12px; color: var(--text2); }

/* host breadcrumb: <Host> · <product> / <area ▾> (see hostBrand in src/main.ts) */
.host-brand { color: var(--text); font-weight: 800; letter-spacing: .02em; text-decoration: none; white-space: nowrap; pointer-events: auto; }
.crumb-product { color: var(--text2); text-decoration: none; white-space: nowrap; pointer-events: auto; }
a.crumb-product:hover, .host-brand:hover { color: var(--text); text-decoration: underline; }
.crumb-sep { color: var(--text2); opacity: .7; }
.hosted .corridor-chip { margin-left: 0; }
@media (max-width: 560px) {
  /* a phone keeps the host and the area: "NRIReturn / Bellandur ▾" */
  .hosted #topbar .crumb-product, .hosted #topbar .host-brand + .crumb-sep { display: none; }
}
@media (max-width: 480px) {
  /* the city bar has room for the product name; the area bar does not */
  .hosted .city-top .brand .crumb-product, .hosted .city-top .brand .crumb-sep { display: inline; }
}

/* About: the × stays in view while reading; a phone gets a bottom sheet with a
   full-width Close that stays at the bottom */
/* the form is what sticks: a sticky element only sticks within its parent */
dialog#about .about-x { position: sticky; top: 0; float: right; height: 0; z-index: 2; }
dialog#about .close { position: relative; top: -10px; right: -14px; width: 40px; height: 40px; padding: 0; border-radius: 99px; background: var(--panel); box-shadow: 0 0 0 1.5px var(--line); }
dialog#about .about-done { display: none; }
@media (max-width: 640px) {
  dialog#about { width: 100vw; max-width: 100vw; max-height: 88dvh; margin: auto 0 0; border-radius: 18px 18px 0 0; padding: 20px 18px 0; }
  dialog#about .close { width: 44px; height: 44px; font-size: 26px; top: -6px; right: -6px; }
  dialog#about .about-done { display: block; position: sticky; bottom: 0; margin: 8px -18px 0; padding: 14px 18px calc(14px + env(safe-area-inset-bottom)); background: linear-gradient(rgba(0,0,0,0), var(--panel) 35%); }
  dialog#about .about-done .pill { width: 100%; }
}
