:root {
  --ink: #0a0d12;
  --ink-2: #111620;
  --ink-3: #1a2030;
  --edge: rgba(255,255,255,0.08);
  --edge-strong: rgba(255,255,255,0.16);
  --fg: #e8ecf3;
  --fg-dim: #9aa3b2;
  --fg-mute: #6b7382;
  --accent: #ffb81c;
  --accent-hot: #ff9500;
  --red: #e4002b;
  --gold: #ffb81c;
  --blue: #0057b7;
  --green: #00a651;
  --font-display: 'Fraunces', ui-serif, Georgia, serif;
  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--ink); color: var(--fg); font-family: var(--font-sans); }
body { overflow: hidden; }

a { color: var(--accent); text-decoration: none; border-bottom: 1px dotted rgba(255,184,28,0.4); }
a:hover { color: var(--accent-hot); }

.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 999;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.035 0'/></filter><rect width='200' height='200' filter='url(%23n)'/></svg>");
  mix-blend-mode: overlay; opacity: 0.5;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
  background: linear-gradient(180deg, var(--ink-2) 0%, var(--ink) 100%);
  border-bottom: 1px solid var(--edge);
  position: relative; z-index: 10;
}

.brand { display: flex; align-items: center; gap: 14px; }
.mark {
  width: 36px; height: 36px; color: var(--accent);
  display: grid; place-items: center;
  border: 1px solid var(--edge-strong); border-radius: 8px;
  background: radial-gradient(circle at 30% 30%, rgba(255,184,28,0.14), transparent 60%);
}
.mark svg { width: 22px; height: 22px; }

.brand-text .eyebrow {
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--fg-mute);
}
.brand-text h1 {
  font-family: var(--font-display);
  font-weight: 800; font-size: 22px;
  margin: 2px 0 0; letter-spacing: -0.01em;
  font-variation-settings: "opsz" 96;
}
.brand-text h1 em {
  font-style: italic; font-weight: 400;
  color: var(--accent);
  font-variation-settings: "opsz" 144;
}

.status-strip { display: flex; gap: 14px; align-items: stretch; }
.status-item {
  min-width: 82px; padding: 8px 14px;
  border: 1px solid var(--edge); border-radius: 8px;
  background: rgba(255,255,255,0.015);
}
.stat-label {
  font-family: var(--font-mono); font-size: 9.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--fg-mute); margin-bottom: 2px;
}
.stat-value {
  font-family: var(--font-display); font-weight: 600; font-size: 22px;
  font-variant-numeric: tabular-nums; line-height: 1;
}
.stat-value .unit { font-size: 12px; color: var(--fg-dim); margin-left: 3px; font-weight: 400; }

.status-item.countdown {
  position: relative; color: var(--accent);
  padding-right: 48px;
}
.ring {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  height: calc(100vh - 67px);
  overflow: hidden;
}
.map-pane { position: relative; overflow: hidden; }
#map { width: 100%; height: 100%; background: var(--ink); }

.sidebar {
  background: var(--ink-2);
  border-left: 1px solid var(--edge);
  overflow-y: auto;
  padding: 18px;
  display: flex; flex-direction: column; gap: 16px;
}

.panel {
  border: 1px solid var(--edge);
  background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0));
  border-radius: 10px;
  padding: 16px;
  position: relative;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.pill {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent);
  padding: 4px 8px;
  border: 1px solid rgba(255,184,28,0.25);
  border-radius: 100px;
  background: rgba(255,184,28,0.04);
}
.pill-alt { color: #7dd3fc; border-color: rgba(125,211,252,0.25); background: rgba(125,211,252,0.04); }
.pill-rail { color: #f0abfc; border-color: rgba(240,171,252,0.25); background: rgba(240,171,252,0.04); }

.tick { font-family: var(--font-mono); font-size: 10px; color: var(--fg-mute); }

.narrative {
  font-family: var(--font-display);
  font-size: 16.5px; line-height: 1.45;
  font-weight: 400; margin: 0;
  color: var(--fg);
  font-variation-settings: "opsz" 20;
}
.narrative .hl { color: var(--accent); font-weight: 600; }
.narrative-sub {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-size: 10.5px; letter-spacing: 0.06em;
  color: var(--fg-mute);
}

.lead { font-size: 13px; line-height: 1.5; color: var(--fg-dim); margin: 0 0 12px; }
.equity-rows { display: flex; flex-direction: column; gap: 9px; }
.equity-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: rgba(255,255,255,0.015);
}
.equity-k { font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); letter-spacing: 0.02em; }
.equity-v { font-family: var(--font-display); font-weight: 600; font-size: 15px; font-variant-numeric: tabular-nums; }
.bar {
  display: inline-block; width: 88px; height: 6px;
  background: rgba(255,255,255,0.06); border-radius: 100px; overflow: hidden;
  vertical-align: middle; margin-left: 6px;
}
.bar > span {
  display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #ff6a3d 100%);
  transition: width 0.8s cubic-bezier(.2,.8,.2,1);
}
.footnote {
  margin-top: 12px; font-size: 11px; color: var(--fg-mute); line-height: 1.45;
  border-top: 1px dashed var(--edge); padding-top: 10px;
}

.arrivals { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.arrivals li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px; align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--edge);
  font-size: 12.5px;
}
.arrivals li:last-child { border-bottom: none; }
.arrivals .line-chip {
  display: inline-block; width: 10px; height: 10px; border-radius: 100px;
  background: var(--lc, #fff);
  box-shadow: 0 0 8px var(--lc, #fff);
}
.arrivals .station { font-weight: 500; color: var(--fg); }
.arrivals .dest { color: var(--fg-mute); font-size: 11px; font-family: var(--font-mono); }
.arrivals .eta {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.arrivals .eta.soon { color: var(--accent); }
.arrivals .eta.arriving { color: #ff6a3d; }
.skeleton {
  color: transparent !important;
  background: linear-gradient(90deg, rgba(255,255,255,0.03), rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
  border-radius: 4px; height: 22px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--edge);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-mute);
  letter-spacing: 0.04em;
}
.foot-sub { margin-top: 4px; font-size: 9.5px; }

.legend {
  position: absolute; left: 14px; bottom: 14px;
  background: rgba(10,13,18,0.82); backdrop-filter: blur(10px);
  border: 1px solid var(--edge-strong); border-radius: 8px;
  padding: 10px 12px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-dim);
  letter-spacing: 0.02em;
  z-index: 5;
}
.legend-title {
  font-size: 9px; text-transform: uppercase; letter-spacing: 0.18em;
  color: var(--fg-mute); margin-bottom: 4px;
}
.legend-rows { display: grid; grid-template-columns: repeat(2, auto); gap: 2px 14px; }
.legend-rows > div { display: flex; align-items: center; gap: 6px; }
.sw { width: 16px; height: 3px; background: var(--c, #fff); border-radius: 100px; display: inline-block; }
.sw.arrow {
  width: 0; height: 0; background: transparent;
  border-left: 4px solid transparent; border-right: 4px solid transparent;
  border-bottom: 8px solid var(--accent);
}
.sw.dot { width: 8px; height: 8px; border-radius: 100px; background: #7dd3fc; }
.sw.route { width: 16px; height: 3px; background: #ff3366; border-radius: 100px; }

.map-hint {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  background: rgba(10,13,18,0.82); backdrop-filter: blur(10px);
  border: 1px solid var(--edge-strong); border-radius: 100px;
  padding: 7px 14px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--fg-dim);
  letter-spacing: 0.04em;
  z-index: 5;
  animation: fadeInOut 8s ease-in-out 2s forwards;
}
@keyframes fadeInOut {
  0%, 10% { opacity: 0; transform: translate(-50%, -6px); }
  15%, 85% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, -6px); visibility: hidden; }
}

.maplibregl-popup { font-family: var(--font-sans); }
.maplibregl-popup-content {
  background: var(--ink-2) !important;
  border: 1px solid var(--edge-strong) !important;
  color: var(--fg) !important;
  border-radius: 8px !important;
  padding: 10px 12px !important;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5) !important;
  font-size: 12px !important;
}
.maplibregl-popup-tip { border-top-color: var(--ink-2) !important; border-bottom-color: var(--ink-2) !important; }
.maplibregl-popup-close-button { color: var(--fg-dim) !important; font-size: 16px !important; }
.popup-title {
  font-family: var(--font-display); font-weight: 600; font-size: 14px;
  margin-bottom: 4px;
}
.popup-row { font-family: var(--font-mono); font-size: 11px; color: var(--fg-dim); }
.popup-row b { color: var(--fg); font-weight: 500; }

.maplibregl-ctrl-attrib {
  background: rgba(10,13,18,0.7) !important;
  color: var(--fg-mute) !important;
  font-size: 9.5px !important;
}
.maplibregl-ctrl-attrib a { color: var(--fg-dim) !important; border: none !important; }

@media (max-width: 900px) {
  body { overflow: auto; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .map-pane { height: 55vh; min-height: 420px; }
  .sidebar { max-height: none; border-left: none; border-top: 1px solid var(--edge); }
  .topbar { flex-direction: column; align-items: flex-start; gap: 12px; padding: 12px 16px; }
  .status-strip { width: 100%; overflow-x: auto; }
  .brand-text h1 { font-size: 18px; }
}

/* ==== How This Was Built ==== */
.how-built-toggle {
  position: fixed; bottom: 16px; right: 16px; z-index: 100;
}
.how-built-toggle button {
  display: flex; align-items: center; gap: 6px;
  background: rgba(10,13,18,0.85); backdrop-filter: blur(10px);
  border: 1px solid var(--edge-strong); border-radius: 100px;
  padding: 8px 14px;
  font-family: var(--font-mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-dim);
  cursor: pointer;
  transition: all 0.3s ease;
}
.how-built-toggle button:hover { color: var(--accent); border-color: rgba(255,184,28,0.35); }
.how-built-toggle button.active { color: var(--accent); border-color: var(--accent); }
.how-built-toggle button svg { opacity: 0.7; transition: transform 0.5s ease; }
.how-built-toggle button.active svg { transform: rotate(90deg); opacity: 1; }

.how-section {
  display: none; overflow-y: auto;
  background: var(--ink);
  border-top: 1px solid var(--edge);
}
.how-section.open {
  display: block;
  position: fixed; inset: 0; z-index: 90;
  padding-top: 60px;
  animation: howFadeIn 0.35s ease;
}
@keyframes howFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.how-inner {
  max-width: 820px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}
.how-block {
  margin-bottom: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--edge);
}
.how-block:last-child { border-bottom: none; }
.how-block h3 {
  font-family: var(--font-display);
  font-weight: 600; font-size: 18px;
  color: var(--accent);
  margin: 0 0 12px;
  font-variation-settings: "opsz" 72;
}
.how-block p {
  font-family: var(--font-sans);
  font-size: 13.5px; line-height: 1.65;
  color: var(--fg-dim);
  margin: 0 0 10px;
}
.how-block strong { color: var(--fg); font-weight: 600; }
.how-block code {
  font-family: var(--font-mono); font-size: 12px;
  background: rgba(255,255,255,0.05);
  padding: 2px 5px; border-radius: 3px;
  color: var(--fg);
}
.how-list {
  list-style: none; padding: 0; margin: 10px 0 0;
}
.how-list li {
  font-family: var(--font-sans);
  font-size: 13px; line-height: 1.6;
  color: var(--fg-dim);
  padding: 6px 0 6px 18px;
  position: relative;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.how-list li:last-child { border-bottom: none; }
.how-list li::before {
  content: '';
  position: absolute; left: 0; top: 13px;
  width: 6px; height: 6px;
  background: var(--accent); border-radius: 1px;
  transform: rotate(45deg);
}
.how-list li strong { color: var(--fg); }
.how-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 16px;
}
.how-tags span {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  padding: 4px 10px;
  border: 1px solid var(--edge-strong); border-radius: 100px;
  color: var(--fg-dim);
  background: rgba(255,255,255,0.02);
}
