@font-face { font-family: "Plex"; src: url("fonts/IBMPlexSansCondensed-Regular.ttf"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/IBMPlexSansCondensed-Medium.ttf"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Plex"; src: url("fonts/IBMPlexSansCondensed-SemiBold.ttf"); font-weight: 600; font-display: swap; }

:root {
  --night: #050C22; --deep: #0A1736; --ink: #E9EEF8; --dim: #93A1BE; --faint: #5A6888; --line: rgba(160, 182, 230, .16);
  --gold: #E8C77A; --glass: rgba(8, 17, 42, .82); --r: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); color: var(--ink);
  font: 15px/1.45 "Plex", -apple-system, "Helvetica Neue", sans-serif; -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
body { background: radial-gradient(110% 80% at 50% 45%, #0D1E4A 0%, #071233 48%, #030819 100%); }
canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#ink { z-index: 1; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.noscript { position: fixed; inset: 40% 0 auto; text-align: center; color: var(--dim); }

/* ---------- landing ---------- */
#landing { position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(24px + var(--safe-t)) 22px calc(64px + var(--safe-b)); text-align: center; transition: opacity 1.2s ease; pointer-events: none; }
#landing > * { pointer-events: auto; }
#landing.gone { opacity: 0; }
.kicker { letter-spacing: .22em; text-transform: uppercase; font-size: 11px; color: var(--dim); margin-bottom: 18px; }
#landing h1 { font-weight: 400; font-size: clamp(32px, 6.4vw, 60px); line-height: 1.04; margin: 0 0 12px; letter-spacing: -.01em; }
.lede { color: var(--dim); margin: 0 0 24px; font-size: clamp(15px, 2.2vw, 18px); max-width: 30em; text-wrap: balance; }
.searchbox { position: relative; width: min(520px, 100%); }
.searchbox input { width: 100%; min-height: 44px; border: 1px solid rgba(190, 205, 240, .28); background: rgba(5, 12, 34, .6); border-radius: 999px;
  padding: 10px 18px; outline: none; font-size: 16px; transition: border-color .3s; -webkit-appearance: none; appearance: none; }
.searchbox.big input { padding: 14px 24px; font-size: 18px; min-height: 52px; }
.searchbox input:focus { border-color: rgba(232, 199, 122, .7); }
.searchbox input::placeholder { color: #7D8BAA; }
.results { list-style: none; margin: 6px 0 0; padding: 6px; position: absolute; left: 0; right: 0; z-index: 9; text-align: left;
  background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: var(--r);
  max-height: 52vh; overflow: auto; }
.results:empty { display: none; }
.results li { min-height: 44px; padding: 8px 12px; border-radius: 9px; cursor: pointer; display: flex; gap: 10px; align-items: center; }
.results li.on, .results li:hover { background: rgba(120, 150, 220, .16); }
.results .t { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); min-width: 52px; }
.results .m { color: var(--dim); font-size: 13px; margin-left: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 42%; }
.hints { margin-top: 16px; display: flex; flex-wrap: wrap; gap: 6px 8px; justify-content: center; max-width: 600px; }
.hints button { min-height: 44px; border: 0; background: none; padding: 0; color: var(--dim); font-size: 14px; display: inline-flex; align-items: center; }
.hints button span { border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; transition: color .2s, border-color .2s; }
.hints button:hover span, .hints button:focus-visible span { color: var(--ink); border-color: rgba(190, 205, 240, .45); }
.hints.journeys { margin-top: 4px; }
.hints.journeys > span { width: 100%; color: var(--faint); font-size: 11px; letter-spacing: .16em; text-transform: uppercase; margin-top: 6px; }
.hints.journeys button span { border-color: rgba(232, 199, 122, .25); color: #CDB98A; }
.idle { margin-top: 26px; color: var(--faint); font-size: 13px; letter-spacing: .04em; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.idle i { display: block; width: 120px; height: 1px; background: linear-gradient(90deg, var(--gold) var(--p, 0%), rgba(255, 255, 255, .12) var(--p, 0%)); }
.credit { position: absolute; bottom: calc(18px + var(--safe-b)); left: 8px; right: 8px; text-align: center; color: var(--faint); font-size: 12px; letter-spacing: .08em; }
@media (max-width: 440px) { .credit { font-size: 11px; letter-spacing: .02em; } }

/* ---------- the quiet chrome ---------- */
#hud { position: fixed; z-index: 4; top: calc(8px + var(--safe-t)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; }
#hud .searchbox { width: min(360px, 56vw); margin-left: auto; }
.brand { background: none; border: 0; min-height: 44px; padding: 0 6px; font-size: 15px; letter-spacing: .14em; text-transform: lowercase; color: var(--ink); white-space: nowrap; }
.brand span { color: var(--gold); margin-left: .35em; }
.about { background: none; border: 0; color: var(--dim); font-size: 13px; letter-spacing: .08em; min-height: 44px; min-width: 44px; padding: 0 8px; }

#dock { position: fixed; z-index: 4; left: 50%; transform: translateX(-50%); bottom: calc(12px + var(--safe-b)); display: flex; gap: 6px; align-items: center;
  padding: 4px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  max-width: calc(100vw - 16px); }
.seg { display: flex; border-radius: 999px; }
.seg button { min-height: 44px; border: 0; background: transparent; padding: 0 14px; border-radius: 999px; color: var(--dim); white-space: nowrap; font-size: 14px; transition: background .3s, color .3s; }
.seg button.on { background: rgba(232, 199, 122, .15); color: var(--ink); }
.sel { display: flex; align-items: center; gap: 6px; padding: 0 12px 0 8px; color: var(--dim); font-size: 13px; white-space: nowrap; min-height: 44px; }
.sel select { background: transparent; border: 0; color: var(--ink); font-size: 14px; outline: none; -webkit-appearance: none; appearance: none; padding: 10px 2px; min-height: 44px; cursor: pointer; }
.sel select option { background: var(--deep); }
.sel { position: relative; }
.sel .caret { position: absolute; right: 10px; top: 50%; width: 6px; height: 6px; margin-top: -5px; border: solid var(--dim); border-width: 0 1.2px 1.2px 0; transform: rotate(45deg); pointer-events: none; }
.sel select { padding-right: 16px; }
@media (min-width: 701px) { body.panel #legend { left: 18px; transform: none; width: calc(100vw - min(400px, 40vw) - 60px); justify-content: flex-start; } }
#legend { position: fixed; z-index: 3; left: 50%; transform: translateX(-50%); bottom: calc(68px + var(--safe-b)); font-size: 12px; color: var(--dim);
  display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; pointer-events: none; width: min(900px, 94vw); transition: opacity .6s; }
#legend div { display: flex; align-items: center; gap: 7px; }
#legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; flex: none; }
#legend i.dot { width: 7px; height: 7px; border-radius: 50%; }
#legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 4px, transparent 4px 7px) !important; height: 2px; }
#hint { position: fixed; z-index: 3; right: 20px; top: calc(66px + var(--safe-t)); color: var(--faint); font-size: 12px; letter-spacing: .05em; pointer-events: none; text-align: right; transition: opacity 1s; }
body.panel #hint { opacity: 0; }

/* ---------- the station panel ---------- */
#panel { position: fixed; z-index: 6; top: calc(62px + var(--safe-t)); right: 12px; bottom: calc(72px + var(--safe-b)); width: min(400px, 40vw);
  background: var(--glass); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); border: 1px solid var(--line); border-radius: 18px;
  overflow: auto; padding: 22px 22px 28px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
#panel .close { position: sticky; top: -10px; float: right; margin: -10px -10px 0 8px; border: 0; background: rgba(255, 255, 255, .06); width: 44px; height: 44px; border-radius: 50%; font-size: 20px; line-height: 1; color: var(--dim); }
.p-type { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--dim); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.p-type i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
#panel h2 { font-weight: 500; font-size: 28px; line-height: 1.08; margin: 6px 0 6px; }
.p-meta { color: var(--dim); font-size: 14px; }
.p-aka { color: var(--faint); font-size: 13px; margin-top: 2px; }
.p-desc { margin: 16px 0; font-size: 15.5px; line-height: 1.55; }
.p-desc.wait { color: var(--faint); }
.p-act { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 16px; }
.p-act a, .p-act button { min-height: 44px; display: inline-flex; align-items: center; border: 1px solid var(--line); background: transparent; color: var(--dim); padding: 0 16px; border-radius: 999px; font-size: 13.5px; text-decoration: none; }
.p-act .art { border-color: rgba(232, 199, 122, .45); color: var(--gold); }
.p-act a:hover, .p-act button:hover { color: var(--ink); }
.owner { border-left: 2px solid var(--gold); padding: 8px 0 8px 14px; margin: 14px 0; }
.owner b { color: var(--gold); font-weight: 500; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; display: block; margin-bottom: 4px; }
.owner q { font-style: italic; }
.owner .st { display: block; margin-top: 6px; color: var(--dim); font-size: 13px; }
.dispute { border: 1px dashed rgba(190, 205, 240, .3); border-radius: 12px; padding: 10px 14px; margin: 12px 0; font-size: 14px; }
.dispute > b { font-weight: 500; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); display: block; }
.dispute .ab { margin: 3px 0 8px; }
.dispute .side { display: grid; grid-template-columns: 22px 1fr; gap: 4px; margin: 6px 0; }
.dispute .side em { font-style: normal; color: var(--gold); }
.dispute .side small, .dispute .nt { grid-column: 2; color: var(--dim); font-size: 12.5px; }
#panel h3 { font-weight: 500; font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--dim); margin: 22px 0 6px; border-top: 1px solid var(--line); padding-top: 14px; }
.conn { list-style: none; padding: 0; margin: 0; }
.conn li { display: grid; grid-template-columns: 14px 1fr; gap: 6px; font-size: 14px; }
.conn li i { width: 10px; height: 2px; margin-top: 21px; border-radius: 1px; }
.conn li i.dash { background: repeating-linear-gradient(90deg, var(--c) 0 3px, transparent 3px 5px) !important; }
.conn a { display: block; min-height: 44px; padding: 11px 0 9px; color: var(--ink); text-decoration: none; cursor: pointer; }
.p-meta a.inl, .p-meta a.inl:visited { color: var(--ink); text-decoration: none; border-bottom: 1px solid rgba(190, 205, 240, .25); cursor: pointer; padding: 13px 8px; margin: 0 -8px; }
.conn a u { text-decoration: none; border-bottom: 1px solid rgba(190, 205, 240, .25); }
.conn .rel { color: var(--dim); }
.srcs { padding-left: 18px; margin: 0; font-size: 13px; color: var(--dim); }
.srcs li { margin: 0; }
.srcs a { color: #B9C9EE; display: inline-block; min-height: 44px; padding: 12px 0 0; }
.p-foot { color: var(--faint); font-size: 12px; margin-top: 18px; }
.p-credit { color: var(--faint); font-size: 12px; letter-spacing: .06em; margin-top: 20px; }

/* ---------- phone: a bottom sheet ---------- */
@media (max-width: 700px) {
  #panel { top: auto; left: 8px; right: 8px; width: auto; bottom: calc(66px + var(--safe-b)); max-height: 50vh; border-radius: 20px; padding: 18px 18px 26px; }
  #hud .searchbox { width: auto; flex: 1; }
  .brand { display: none; }
  #legend { bottom: calc(62px + var(--safe-b)); font-size: 10.5px; gap: 0 9px; }
  #hint { display: none; }
  .seg button { padding: 0 9px; font-size: 13.5px; }
  .sel .wide { display: none; }
  .sel { padding: 0 10px 0 4px; }
  #dock { gap: 2px; }
  body.panel #legend { opacity: 0; }
}
@media (max-height: 700px) and (max-width: 700px) { .hints.journeys { display: none; } }
@media (prefers-reduced-motion: reduce) {
  #landing, #focusline, #legend, #hint { transition: none; }
}

/* ---------- touch lock (iOS Safari: page scroll / pinch-zoom must not take the map's gestures) ---------- */
html, body { position: fixed; inset: 0; height: 100%; height: 100dvh; overflow: hidden; overscroll-behavior: none; }
canvas { touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.results, #panel { touch-action: pan-y; overscroll-behavior: contain; }

/* ---------- navigation: home, trail, connect, collapsible panel (owner 21:47: "never stuck") ---------- */
.homebtn { flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: rgba(5, 12, 34, .6); color: var(--ink); display: grid; place-items: center; padding: 0; }
.homebtn svg { width: 22px; height: 22px; }
#trail { position: fixed; z-index: 4; top: calc(58px + var(--safe-t)); left: 10px; right: 10px; display: flex; align-items: center; gap: 2px; overflow: hidden; white-space: nowrap; font-size: 12.5px; color: var(--dim); pointer-events: none; }
#trail button { pointer-events: auto; min-height: 44px; border: 0; background: none; color: var(--dim); padding: 0 6px; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#trail button.here { color: var(--ink); }
#trail .sep { color: var(--faint); }
#connectBar { position: fixed; z-index: 7; left: 50%; transform: translateX(-50%); top: calc(104px + var(--safe-t)); display: flex; align-items: center; gap: 10px; padding: 4px 4px 4px 16px; border-radius: 999px; background: var(--glass); border: 1px solid rgba(232, 199, 122, .45); color: var(--ink); font-size: 14px; max-width: calc(100vw - 16px); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
#connectBar b { font-weight: 500; color: var(--gold); }
#connectBar button { min-height: 40px; min-width: 44px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .07); color: var(--dim); padding: 0 14px; }
#panel .grip { position: sticky; top: -22px; display: block; margin: -16px auto 4px; width: 88px; height: 44px; border: 0; background: none; padding: 0; cursor: grab; touch-action: none; }
#panel .grip i { display: block; width: 40px; height: 4px; border-radius: 2px; background: rgba(190, 205, 240, .35); margin: 0 auto; }
#panel.min { overflow: hidden; }
#panel.min .p-desc, #panel.min .p-act, #panel.min h3, #panel.min ul, #panel.min ol, #panel.min .p-foot, #panel.min .years, #panel.min .routes, #panel.min .owner, #panel.min .dispute, #panel.min .bars, #panel.min .showall { display: none; }
.showall { min-height: 44px; border: 0; background: none; color: var(--gold); padding: 0; font-size: 13.5px; }
.conn .ind { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
#panel h3.conn-h { color: var(--ink); }
.years { display: flex; flex-wrap: wrap; gap: 4px 6px; margin: 4px 0 6px; }
.years button { min-height: 44px; min-width: 44px; border: 1px solid var(--line); background: none; border-radius: 999px; color: var(--dim); padding: 0 12px; font-size: 13px; }
.years button.on { border-color: rgba(232, 199, 122, .55); color: var(--ink); }
.bars { list-style: none; padding: 0; margin: 6px 0; }
.bars li { display: grid; grid-template-columns: minmax(0, 1fr) 90px 38px; align-items: center; gap: 8px; font-size: 14px; }
.bars a { display: block; min-height: 44px; padding: 11px 0 0; color: var(--ink); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bars a u { text-decoration: none; border-bottom: 1px solid rgba(190, 205, 240, .25); }
.bars i { height: 6px; border-radius: 3px; display: block; }
.bars span { color: var(--dim); font-size: 12.5px; text-align: right; }
.path { list-style: none; padding: 0; margin: 10px 0; }
.path .stop { display: grid; grid-template-columns: 14px 1fr; gap: 6px; font-size: 15px; }
.path .stop i { width: 10px; height: 10px; border-radius: 50%; margin-top: 17px; }
.path .stop a { display: block; min-height: 44px; padding: 11px 0 6px; color: var(--ink); text-decoration: none; }
.path .stop a u { text-decoration: none; border-bottom: 1px solid rgba(190, 205, 240, .25); }
.path .hop { margin: 0 0 0 4px; padding: 2px 0 6px 16px; border-left: 2px solid rgba(232, 199, 122, .55); color: var(--dim); font-size: 13.5px; }
.path .hop.ind { border-left-style: dashed; border-left-color: rgba(147, 161, 190, .5); }
.path .hop small { display: block; color: var(--faint); font-size: 12.5px; margin-top: 2px; }
.path .hop a { color: #B9C9EE; display: inline-block; min-height: 44px; min-width: 44px; padding-top: 12px; }
.routes { display: flex; flex-wrap: wrap; gap: 6px; }
.routes button { min-height: 44px; border: 1px solid var(--line); background: none; border-radius: 999px; color: var(--dim); padding: 0 14px; font-size: 13px; }
.routes button.on { border-color: rgba(232, 199, 122, .55); color: var(--ink); }
@media (max-width: 700px) {
  .brand { display: none; }
  #panel.min { max-height: 116px; }
  #trail button { max-width: 28vw; }
  #connectBar { top: auto; bottom: calc(76px + var(--safe-b)); font-size: 13px; }
}
@media (min-width: 701px) {
  #panel.min { bottom: auto; max-height: 132px; }
  #trail { right: auto; max-width: calc(100vw - 640px); left: 180px; top: calc(10px + var(--safe-t)); }
}
#trail button { min-width: 44px; }
.dispute small a { display: inline-block; min-height: 44px; padding-top: 13px; }
