/* ================================================================
   OpenRailTracker  —  styles.css
   Layout: .app { display:flex } → .sidebar + .map-pane
   ================================================================ */

@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg: #000000;
  --sidebar-bg: #090b0f;
  --surface: #0f1319;
  --surface-hi: #161c24;
  --surface-lo: #0b1016;
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.14);
  --text: #f2f5fb;
  --muted: #adb5c3;
  --dim: #737c8b;
  --tool-bg: #11161d;
  --tool-bg-hover: #1a2330;
  --tool-fg: #d8e3f5;
  --tool-fg-hover: #ffffff;
  --tool-border: rgba(255, 255, 255, 0.14);
  --tool-active-bg: rgba(255, 255, 255, 0.18);
  --tool-active-border: rgba(255, 255, 255, 0.26);

  --primary: #7fb3ff;
  --primary-rgb: 127, 179, 255;
  --accent: #84d7ff;
  --green: #5be7a9;
  --yellow: #ffd56e;
  --orange: #ffb066;
  --red: #ff7f88;
  --purple: #b8a2ff;

  --shadow: 0 14px 34px rgba(0, 0, 0, 0.22);
  --shadow-lg: 0 20px 44px rgba(0, 0, 0, 0.26);
  --radius: 14px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --sidebar-w: 360px;
  --panel-gap: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --tile-stripe: none;
}

body.light {
  --bg: #f0f0f0;
  --sidebar-bg: #e8e8e8;
  --surface: rgba(240, 240, 240, 0.98);
  --surface-hi: rgba(248, 248, 248, 1.0);
  --surface-lo: rgba(232, 232, 232, 0.95);
  --border: rgba(0, 0, 0, 0.10);
  --border-hi: rgba(0, 0, 0, 0.20);
  --text: #111111;
  --muted: #555555;
  --dim: #888888;
  --tool-bg: rgba(255, 255, 255, 0.92);
  --tool-bg-hover: var(--accent);
  --tool-fg: #3c4654;
  --tool-fg-hover: #111111;
  --tool-border: rgba(0, 0, 0, 0.18);
  --tool-active-bg: color-mix(in srgb, var(--accent) 18%, white);
  --tool-active-border: color-mix(in srgb, var(--accent) 42%, rgba(0, 0, 0, 0.12));
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.22);
  --tile-stripe: none;
}

body.theme-deep-black {
  --bg: #010102;
  --sidebar-bg: #050507;
  --surface: rgba(11, 12, 16, 0.98);
  --surface-hi: rgba(19, 21, 26, 0.99);
  --surface-lo: rgba(7, 8, 11, 0.97);
  --border: rgba(255, 255, 255, 0.08);
  --border-hi: rgba(255, 255, 255, 0.14);
  --text: #f6f8ff;
  --muted: #b1b8ca;
  --dim: #798196;
  --tool-bg: rgba(14, 15, 20, 0.92);
  --tool-bg-hover: rgba(255, 255, 255, 0.14);
  --tool-fg: #e8eeff;
  --tool-fg-hover: #ffffff;
  --tool-border: rgba(255, 255, 255, 0.14);
  --tool-active-bg: rgba(255, 255, 255, 0.2);
  --tool-active-border: rgba(255, 255, 255, 0.3);
  --primary: #8ca5ff;
  --primary-rgb: 140, 165, 255;
  --accent: #91d0ff;
}

body.theme-obsidian-indigo {
  --bg: #070b14;
  --sidebar-bg: #0b1020;
  --surface: rgba(14, 21, 40, 0.98);
  --surface-hi: rgba(21, 31, 56, 0.99);
  --surface-lo: rgba(10, 15, 30, 0.97);
  --border: rgba(154, 173, 255, 0.2);
  --border-hi: rgba(191, 204, 255, 0.32);
  --text: #edf2ff;
  --muted: #afbbda;
  --dim: #7482a6;
  --tool-bg: rgba(16, 24, 45, 0.9);
  --tool-bg-hover: rgba(255, 255, 255, 0.14);
  --tool-fg: #e8eeff;
  --tool-fg-hover: #ffffff;
  --primary: #7d8dff;
  --primary-rgb: 125, 141, 255;
  --accent: #74c0fc;
}

body.theme-graphite-noir {
  --bg: #0b0d10;
  --sidebar-bg: #0f1115;
  --surface: rgba(19, 22, 28, 0.98);
  --surface-hi: rgba(28, 32, 40, 0.99);
  --surface-lo: rgba(14, 16, 21, 0.97);
  --border: rgba(175, 186, 205, 0.18);
  --border-hi: rgba(210, 219, 233, 0.3);
  --text: #eef2f8;
  --muted: #a9b2c3;
  --dim: #737d8f;
  --tool-bg: rgba(20, 23, 30, 0.9);
  --tool-bg-hover: rgba(255, 255, 255, 0.14);
  --tool-fg: #e3eaf6;
  --tool-fg-hover: #ffffff;
  --primary: #8ea0b8;
  --primary-rgb: 142, 160, 184;
  --accent: #9db4d0;
}

body.theme-deep-ocean {
  --bg: #04101b;
  --sidebar-bg: #071522;
  --surface: rgba(10, 23, 36, 0.98);
  --surface-hi: rgba(15, 33, 50, 0.99);
  --surface-lo: rgba(7, 17, 28, 0.97);
  --border: rgba(122, 193, 229, 0.2);
  --border-hi: rgba(157, 217, 247, 0.33);
  --text: #e9f6ff;
  --muted: #9fc2d6;
  --dim: #678ca2;
  --tool-bg: rgba(11, 28, 44, 0.9);
  --tool-bg-hover: rgba(255, 255, 255, 0.14);
  --tool-fg: #d9effd;
  --tool-fg-hover: #ffffff;
  --primary: #3f9bd4;
  --primary-rgb: 63, 155, 212;
  --accent: #62b9ea;
}

body.theme-midnight-plum {
  --bg: #100a16;
  --sidebar-bg: #160f1e;
  --surface: rgba(26, 18, 35, 0.98);
  --surface-hi: rgba(38, 26, 50, 0.99);
  --surface-lo: rgba(18, 12, 24, 0.97);
  --border: rgba(202, 156, 255, 0.18);
  --border-hi: rgba(223, 189, 255, 0.3);
  --text: #f3eaff;
  --muted: #c2a8de;
  --dim: #8f76ab;
  --tool-bg: rgba(28, 20, 38, 0.9);
  --tool-bg-hover: rgba(255, 255, 255, 0.14);
  --tool-fg: #ebdcff;
  --tool-fg-hover: #ffffff;
  --primary: #9a6bde;
  --primary-rgb: 154, 107, 222;
  --accent: #c191ff;
}

body.theme-emerald-night {
  --bg: #05100c;
  --sidebar-bg: #081712;
  --surface: rgba(10, 24, 18, 0.98);
  --surface-hi: rgba(16, 35, 27, 0.99);
  --surface-lo: rgba(7, 18, 14, 0.97);
  --border: rgba(123, 214, 173, 0.18);
  --border-hi: rgba(163, 241, 206, 0.3);
  --text: #e9faf1;
  --muted: #9fcab5;
  --dim: #69947f;
  --tool-bg: rgba(10, 27, 20, 0.9);
  --tool-bg-hover: rgba(255, 255, 255, 0.14);
  --tool-fg: #d8f2e6;
  --tool-fg-hover: #ffffff;
  --primary: #3ea77b;
  --primary-rgb: 62, 167, 123;
  --accent: #66cda1;
}

body.theme-mono-graphite {
  --bg: #0e1012;
  --sidebar-bg: #111315;
  --surface: rgba(22, 24, 27, 0.98);
  --surface-hi: rgba(32, 35, 39, 0.99);
  --surface-lo: rgba(16, 18, 21, 0.97);
  --border: rgba(205, 210, 217, 0.18);
  --border-hi: rgba(225, 230, 236, 0.3);
  --text: #f2f4f7;
  --muted: #b6bcc6;
  --dim: #7a828d;
  --tool-bg: rgba(21, 24, 28, 0.9);
  --tool-bg-hover: rgba(255, 255, 255, 0.14);
  --tool-fg: #e8ebef;
  --tool-fg-hover: #ffffff;
  --primary: #9ca3af;
  --primary-rgb: 156, 163, 175;
  --accent: #d1d5db;
}

body.theme-mono-ash {
  --bg: #d9dde2;
  --sidebar-bg: #cfd4db;
  --surface: rgba(223, 227, 233, 0.98);
  --surface-hi: rgba(237, 240, 245, 0.99);
  --surface-lo: rgba(207, 212, 219, 0.95);
  --border: rgba(42, 47, 55, 0.14);
  --border-hi: rgba(42, 47, 55, 0.24);
  --text: #1f242b;
  --muted: #4b5563;
  --dim: #6b7280;
  --tool-bg: rgba(245, 247, 250, 0.9);
  --tool-bg-hover: rgba(223, 228, 234, 0.95);
  --tool-fg: #2b313a;
  --tool-fg-hover: #12161b;
  --tool-border: rgba(42, 47, 55, 0.2);
  --tool-active-bg: rgba(75, 85, 99, 0.18);
  --tool-active-border: rgba(75, 85, 99, 0.34);
  --primary: #4b5563;
  --primary-rgb: 75, 85, 99;
  --accent: #6b7280;
  --shadow: 0 10px 28px rgba(20, 24, 29, 0.14);
  --shadow-lg: 0 18px 44px rgba(20, 24, 29, 0.19);
}

body.theme-mono-paper {
  --bg: #f7f7f6;
  --sidebar-bg: #efefed;
  --surface: rgba(250, 250, 249, 0.98);
  --surface-hi: rgba(255, 255, 254, 0.99);
  --surface-lo: rgba(239, 239, 237, 0.95);
  --border: rgba(51, 51, 51, 0.14);
  --border-hi: rgba(51, 51, 51, 0.24);
  --text: #171717;
  --muted: #404040;
  --dim: #737373;
  --tool-bg: rgba(255, 255, 255, 0.9);
  --tool-bg-hover: rgba(243, 243, 242, 0.95);
  --tool-fg: #262626;
  --tool-fg-hover: #000000;
  --tool-border: rgba(51, 51, 51, 0.2);
  --tool-active-bg: rgba(82, 82, 82, 0.16);
  --tool-active-border: rgba(82, 82, 82, 0.32);
  --primary: #3f3f46;
  --primary-rgb: 63, 63, 70;
  --accent: #52525b;
  --shadow: 0 8px 24px rgba(23, 23, 23, 0.12);
  --shadow-lg: 0 14px 36px rgba(23, 23, 23, 0.17);
}

body.theme-contrast-dark {
  --bg: #000000;
  --sidebar-bg: #000000;
  --surface: #000000;
  --surface-hi: #111111;
  --surface-lo: #000000;
  --border: rgba(255, 255, 255, 0.78);
  --border-hi: rgba(255, 255, 255, 0.95);
  --text: #ffffff;
  --muted: #f2f2f2;
  --dim: #d4d4d4;
  --tool-bg: #000000;
  --tool-bg-hover: #1a1a1a;
  --tool-fg: #ffffff;
  --tool-fg-hover: #ffffff;
  --tool-border: rgba(255, 255, 255, 0.88);
  --tool-active-bg: #262626;
  --tool-active-border: #ffffff;
  --primary: #00e5ff;
  --primary-rgb: 0, 229, 255;
  --accent: #ffff00;
  --shadow: 0 0 0 rgba(0, 0, 0, 0);
  --shadow-lg: 0 0 0 rgba(0, 0, 0, 0);
}

body.theme-contrast-light {
  --bg: #ffffff;
  --sidebar-bg: #ffffff;
  --surface: #ffffff;
  --surface-hi: #ffffff;
  --surface-lo: #f5f5f5;
  --border: rgba(0, 0, 0, 0.82);
  --border-hi: rgba(0, 0, 0, 0.96);
  --text: #000000;
  --muted: #111111;
  --dim: #333333;
  --tool-bg: #ffffff;
  --tool-bg-hover: #e5e5e5;
  --tool-fg: #000000;
  --tool-fg-hover: #000000;
  --tool-border: rgba(0, 0, 0, 0.9);
  --tool-active-bg: #d4d4d4;
  --tool-active-border: #000000;
  --primary: #0033ff;
  --primary-rgb: 0, 51, 255;
  --accent: #cc0000;
  --shadow: 0 0 0 rgba(0, 0, 0, 0);
  --shadow-lg: 0 0 0 rgba(0, 0, 0, 0);
}

body.theme-clean-slate {
  --bg: #e8eef5;
  --sidebar-bg: #dfe7f0;
  --surface: rgba(236, 243, 251, 0.98);
  --surface-hi: rgba(246, 250, 255, 0.99);
  --surface-lo: rgba(223, 231, 240, 0.95);
  --border: rgba(53, 73, 98, 0.14);
  --border-hi: rgba(53, 73, 98, 0.25);
  --text: #132338;
  --muted: #4e637c;
  --dim: #70849b;
  --tool-bg: rgba(255, 255, 255, 0.9);
  --tool-bg-hover: rgba(217, 229, 244, 0.95);
  --tool-fg: #2c3f57;
  --tool-fg-hover: #132338;
  --tool-border: rgba(53, 73, 98, 0.2);
  --tool-active-bg: rgba(108, 157, 222, 0.18);
  --tool-active-border: rgba(108, 157, 222, 0.36);
  --primary: #4a78b7;
  --primary-rgb: 74, 120, 183;
  --accent: #6c9dde;
  --shadow: 0 10px 28px rgba(31, 46, 69, 0.16);
  --shadow-lg: 0 18px 44px rgba(31, 46, 69, 0.2);
}

body.theme-clean-glacier {
  --bg: #f3f8ff;
  --sidebar-bg: #eaf2fd;
  --surface: rgba(248, 252, 255, 0.98);
  --surface-hi: rgba(255, 255, 255, 1);
  --surface-lo: rgba(235, 243, 252, 0.95);
  --border: rgba(76, 103, 134, 0.14);
  --border-hi: rgba(76, 103, 134, 0.24);
  --text: #102034;
  --muted: #4d6480;
  --dim: #748aa3;
  --tool-bg: rgba(255, 255, 255, 0.92);
  --tool-bg-hover: rgba(224, 236, 250, 0.95);
  --tool-fg: #2d4562;
  --tool-fg-hover: #102034;
  --tool-border: rgba(76, 103, 134, 0.2);
  --tool-active-bg: rgba(131, 173, 225, 0.2);
  --tool-active-border: rgba(131, 173, 225, 0.38);
  --primary: #4f86c6;
  --primary-rgb: 79, 134, 198;
  --accent: #83ade1;
  --shadow: 0 10px 28px rgba(33, 53, 80, 0.15);
  --shadow-lg: 0 18px 44px rgba(33, 53, 80, 0.19);
}

body.theme-pastel-mint {
  --bg: #ecfaf4;
  --sidebar-bg: #e2f4eb;
  --surface: rgba(238, 250, 244, 0.98);
  --surface-hi: rgba(248, 255, 251, 0.99);
  --surface-lo: rgba(226, 244, 235, 0.95);
  --border: rgba(58, 102, 84, 0.14);
  --border-hi: rgba(58, 102, 84, 0.24);
  --text: #17372d;
  --muted: #46665c;
  --dim: #6f8b82;
  --tool-bg: rgba(255, 255, 255, 0.86);
  --tool-bg-hover: rgba(221, 245, 235, 0.95);
  --tool-fg: #2b5646;
  --tool-fg-hover: #17372d;
  --tool-border: rgba(58, 102, 84, 0.18);
  --primary: #4f9f83;
  --primary-rgb: 79, 159, 131;
  --accent: #78c7ad;
  --shadow: 0 10px 28px rgba(23, 55, 45, 0.13);
  --shadow-lg: 0 18px 44px rgba(23, 55, 45, 0.17);
}

body.theme-pastel-lilac {
  --bg: #f3efff;
  --sidebar-bg: #e9e3fb;
  --surface: rgba(244, 240, 255, 0.98);
  --surface-hi: rgba(251, 249, 255, 0.99);
  --surface-lo: rgba(233, 227, 251, 0.95);
  --border: rgba(84, 72, 120, 0.14);
  --border-hi: rgba(84, 72, 120, 0.24);
  --text: #2a2240;
  --muted: #62577d;
  --dim: #897ca3;
  --tool-bg: rgba(255, 255, 255, 0.86);
  --tool-bg-hover: rgba(236, 229, 253, 0.95);
  --tool-fg: #4a3f6f;
  --tool-fg-hover: #2a2240;
  --tool-border: rgba(84, 72, 120, 0.18);
  --primary: #8471c6;
  --primary-rgb: 132, 113, 198;
  --accent: #a590e3;
  --shadow: 0 10px 28px rgba(42, 34, 64, 0.13);
  --shadow-lg: 0 18px 44px rgba(42, 34, 64, 0.17);
}

body.theme-pastel-peach {
  --bg: #fff3ed;
  --sidebar-bg: #fbe8de;
  --surface: rgba(255, 244, 236, 0.98);
  --surface-hi: rgba(255, 250, 247, 0.99);
  --surface-lo: rgba(251, 232, 222, 0.95);
  --border: rgba(127, 80, 57, 0.14);
  --border-hi: rgba(127, 80, 57, 0.24);
  --text: #3c271d;
  --muted: #7c5b4a;
  --dim: #a5806c;
  --tool-bg: rgba(255, 255, 255, 0.88);
  --tool-bg-hover: rgba(252, 227, 214, 0.95);
  --tool-fg: #6a4738;
  --tool-fg-hover: #3c271d;
  --tool-border: rgba(127, 80, 57, 0.18);
  --primary: #d27e5b;
  --primary-rgb: 210, 126, 91;
  --accent: #ebb093;
  --shadow: 0 10px 28px rgba(60, 39, 29, 0.12);
  --shadow-lg: 0 18px 44px rgba(60, 39, 29, 0.16);
}

body.theme-metro-legacy {
  --bg: #071019;
  --sidebar-bg: rgba(8, 16, 28, 0.58);
  --surface: rgba(12, 21, 37, 0.72);
  --surface-hi: rgba(16, 27, 46, 0.82);
  --surface-lo: rgba(10, 18, 31, 0.62);
  --border: rgba(255, 255, 255, 0.09);
  --border-hi: rgba(255, 255, 255, 0.16);
  --text: #eef4ff;
  --muted: #afbdd4;
  --dim: #7f8ea7;
  --tool-bg: rgba(12, 20, 34, 0.62);
  --tool-bg-hover: rgba(255, 255, 255, 0.14);
  --tool-fg: #d8e3f5;
  --tool-fg-hover: #ffffff;
  --tool-border: rgba(255, 255, 255, 0.14);
  --tool-active-bg: rgba(255, 255, 255, 0.18);
  --tool-active-border: rgba(255, 255, 255, 0.26);
  --primary: #7fb3ff;
  --accent: #84d7ff;
  --green: #5be7a9;
  --yellow: #ffd56e;
  --orange: #ffb066;
  --red: #ff7f88;
  --purple: #b8a2ff;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 26px 64px rgba(0, 0, 0, 0.34);
}

/* ── Initial Loader ────────────────────────────────────────── */
.initial-loader {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  transition: opacity 0.8s var(--ease), visibility 0.8s;
}

.initial-loader.fade-out {
  opacity: 0;
  visibility: hidden;
}

.loader-content {
  text-align: center;
  animation: loader-in 0.6s var(--ease) both;
}

.loader-app-name {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  color: var(--text);
  margin-bottom: 28px;
  background: linear-gradient(135deg, #fff, var(--primary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

@keyframes loader-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.loader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 20px;
  animation: spin 1s linear infinite;
  box-shadow: 0 0 15px rgba(127, 179, 255, 0.2);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loader-content p {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.02em;
}

.loader-subtext {
  display: block;
  font-size: 0.9rem;
  color: var(--dim);
  margin-top: 8px;
}

body.theme-metra {
  --bg: #071227;
  --sidebar-bg: rgba(11, 28, 60, 0.84);
  --surface: rgba(15, 42, 88, 0.9);
  --surface-hi: rgba(20, 56, 114, 0.94);
  --surface-lo: rgba(11, 32, 68, 0.86);
  --border: rgba(255, 255, 255, 0.12);
  --border-hi: rgba(255, 255, 255, 0.2);
  --text: #f4f8ff;
  --muted: #bfd0ea;
  --dim: #88a2cb;
  --tool-bg: rgba(16, 48, 102, 0.88);
  --tool-bg-hover: rgba(255, 255, 255, 0.12);
  --tool-fg: #f4f8ff;
  --tool-fg-hover: #ffffff;
  --tool-border: rgba(255, 255, 255, 0.14);
  --tool-active-bg: rgba(255, 255, 255, 0.16);
  --tool-active-border: rgba(255, 255, 255, 0.24);
  --primary: #2f67c8;
  --accent: #f37726;
  --green: #4bd18d;
  --yellow: #f7b955;
  --orange: #f37726;
  --red: #d1443f;
  --purple: #7ca2ff;
}

body.theme-silver-blue {
  --bg: #0b1320;
  --sidebar-bg: #0f1b2d;
  --surface: rgba(20, 31, 48, 0.98);
  --surface-hi: rgba(33, 49, 71, 0.99);
  --surface-lo: rgba(15, 24, 38, 0.97);
  --border: rgba(148, 163, 184, 0.22);
  --border-hi: rgba(191, 219, 254, 0.34);
  --text: #e6edf5;
  --muted: #9fb3c8;
  --dim: #6f849a;
  --primary: #7ea7d8;
  --accent: #a7c5e8;
  --green: #48c78e;
  --yellow: #cbd5e1;
  --orange: #d1d5db;
  --red: #ef6b73;
  --purple: #9b8ef5;
}

body.theme-pumpkin-stripe {
  --bg: #17110d;
  --sidebar-bg: #1e1410;
  --surface: rgba(35, 22, 15, 0.98);
  --surface-hi: rgba(52, 30, 18, 0.99);
  --surface-lo: rgba(29, 18, 13, 0.97);
  --border: rgba(255, 166, 77, 0.2);
  --border-hi: rgba(255, 194, 122, 0.34);
  --text: #fff1e6;
  --muted: #d9b08c;
  --dim: #9e7a5b;
  --primary: #3f2a1d;
  --accent: #ff8c32;
  --green: #66c18c;
  --yellow: #ffb84d;
  --orange: #ff8c32;
  --red: #f26b4f;
  --purple: #bf8bff;
}

body.theme-heritage-green {
  --bg: #091411;
  --sidebar-bg: #0e1b16;
  --surface: rgba(14, 27, 22, 0.98);
  --surface-hi: rgba(20, 38, 31, 0.99);
  --surface-lo: rgba(11, 21, 18, 0.97);
  --border: rgba(116, 194, 154, 0.18);
  --border-hi: rgba(167, 243, 208, 0.3);
  --text: #edf7f1;
  --muted: #a2c3b1;
  --dim: #6c8f7e;
  --primary: #2f7a57;
  --accent: #7dd3a7;
  --green: #34d399;
  --yellow: #d9f99d;
  --orange: #f59e0b;
  --red: #ef5350;
  --purple: #a78bfa;
}

body.theme-warbonnet-red {
  --bg: #180d10;
  --sidebar-bg: #1f1014;
  --surface: rgba(34, 16, 21, 0.98);
  --surface-hi: rgba(52, 22, 28, 0.99);
  --surface-lo: rgba(28, 14, 18, 0.97);
  --border: rgba(255, 163, 163, 0.16);
  --border-hi: rgba(254, 202, 202, 0.3);
  --text: #fff0f1;
  --muted: #d6a5a9;
  --dim: #98686e;
  --primary: #ffd166;
  --accent: #ef4444;
  --green: #4ade80;
  --yellow: #ffd166;
  --orange: #fb923c;
  --red: #ef4444;
  --purple: #c084fc;
}

body.theme-night-limited {
  --bg: #090b12;
  --sidebar-bg: #0d1018;
  --surface: rgba(12, 16, 26, 0.98);
  --surface-hi: rgba(19, 25, 39, 0.99);
  --surface-lo: rgba(10, 13, 21, 0.97);
  --border: rgba(111, 132, 186, 0.16);
  --border-hi: rgba(147, 197, 253, 0.24);
  --text: #edf2ff;
  --muted: #9ca8c7;
  --dim: #66718e;
  --primary: #4f74ff;
  --accent: #facc15;
  --green: #22c55e;
  --yellow: #facc15;
  --orange: #f97316;
  --red: #fb7185;
  --purple: #8b5cf6;
}

body.theme-cascade-evergreen {
  --bg: #08110e;
  --sidebar-bg: #0c1814;
  --surface: rgba(13, 24, 20, 0.98);
  --surface-hi: rgba(20, 35, 29, 0.99);
  --surface-lo: rgba(10, 19, 16, 0.97);
  --border: rgba(120, 181, 153, 0.18);
  --border-hi: rgba(167, 243, 208, 0.3);
  --text: #eef8f3;
  --muted: #a5c4b7;
  --dim: #6f8d81;
  --primary: #2f7a57;
  --accent: #59c28a;
  --green: #22c55e;
  --yellow: #d9f99d;
  --orange: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
}

body.theme-desert-gold {
  --bg: #16110a;
  --sidebar-bg: #1d170e;
  --surface: rgba(28, 22, 13, 0.98);
  --surface-hi: rgba(42, 33, 19, 0.99);
  --surface-lo: rgba(22, 17, 11, 0.97);
  --border: rgba(232, 188, 106, 0.18);
  --border-hi: rgba(253, 224, 71, 0.3);
  --text: #fff7e6;
  --muted: #d8bf95;
  --dim: #9f855e;
  --primary: #7c5b20;
  --accent: #d8a43b;
  --green: #84cc16;
  --yellow: #facc15;
  --orange: #fb923c;
  --red: #ef5350;
  --purple: #a78bfa;
}

body.theme-keystone-cream {
  --bg: #f3eee4;
  --sidebar-bg: #e8e0d2;
  --surface: rgba(243, 238, 228, 0.98);
  --surface-hi: rgba(250, 246, 239, 0.99);
  --surface-lo: rgba(232, 224, 210, 0.95);
  --border: rgba(79, 59, 44, 0.12);
  --border-hi: rgba(79, 59, 44, 0.22);
  --text: #221c16;
  --muted: #6b5d4f;
  --dim: #948476;
  --primary: #6c4f3d;
  --accent: #c18a53;
  --green: #2f855a;
  --yellow: #d6a44d;
  --orange: #dd6b20;
  --red: #c05621;
  --purple: #805ad5;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.22);
  --tile-stripe: none;
}

body.theme-sunset-copper {
  --bg: #19100d;
  --sidebar-bg: #21140f;
  --surface: rgba(34, 21, 15, 0.98);
  --surface-hi: rgba(49, 28, 19, 0.99);
  --surface-lo: rgba(26, 17, 12, 0.97);
  --border: rgba(255, 153, 102, 0.18);
  --border-hi: rgba(255, 190, 118, 0.32);
  --text: #fff1eb;
  --muted: #d8b0a3;
  --dim: #9d7467;
  --primary: #a44e2d;
  --accent: #ff8f5a;
  --green: #4ade80;
  --yellow: #fbbf24;
  --orange: #f97316;
  --red: #ef4444;
  --purple: #c084fc;
}

body.theme-midnight-orange {
  --bg: #0c0f15;
  --sidebar-bg: #11151d;
  --surface: rgba(16, 21, 30, 0.98);
  --surface-hi: rgba(25, 31, 43, 0.99);
  --surface-lo: rgba(13, 17, 24, 0.97);
  --border: rgba(251, 146, 60, 0.18);
  --border-hi: rgba(253, 186, 116, 0.3);
  --text: #edf2f7;
  --muted: #a7b0bd;
  --dim: #6f7784;
  --primary: #2b3f5c;
  --accent: #fb923c;
  --green: #34d399;
  --yellow: #facc15;
  --orange: #fb923c;
  --red: #f87171;
  --purple: #a78bfa;
}

body.theme-prairie-steel {
  --bg: #12161b;
  --sidebar-bg: #171c22;
  --surface: rgba(22, 28, 34, 0.98);
  --surface-hi: rgba(31, 38, 47, 0.99);
  --surface-lo: rgba(18, 22, 29, 0.97);
  --border: rgba(156, 163, 175, 0.18);
  --border-hi: rgba(203, 213, 225, 0.3);
  --text: #eef2f6;
  --muted: #a7b1bb;
  --dim: #717b86;
  --primary: #64748b;
  --accent: #cbd5e1;
  --green: #4ade80;
  --yellow: #facc15;
  --orange: #fb923c;
  --red: #f87171;
  --purple: #a78bfa;
}

body.theme-streamliner-teal {
  --bg: #081316;
  --sidebar-bg: #0c1a1f;
  --surface: rgba(12, 27, 31, 0.98);
  --surface-hi: rgba(18, 38, 44, 0.99);
  --surface-lo: rgba(9, 20, 24, 0.97);
  --border: rgba(103, 232, 249, 0.16);
  --border-hi: rgba(165, 243, 252, 0.28);
  --text: #ecfbfd;
  --muted: #a4c8cc;
  --dim: #6b8d93;
  --primary: #0f766e;
  --accent: #2dd4bf;
  --green: #34d399;
  --yellow: #fde047;
  --orange: #fb923c;
  --red: #fb7185;
  --purple: #818cf8;
}

body.theme-royal-maroon {
  --bg: #140d12;
  --sidebar-bg: #1a1017;
  --surface: rgba(28, 17, 24, 0.98);
  --surface-hi: rgba(40, 22, 33, 0.99);
  --surface-lo: rgba(20, 13, 18, 0.97);
  --border: rgba(244, 114, 182, 0.14);
  --border-hi: rgba(253, 164, 175, 0.28);
  --text: #fff0f6;
  --muted: #d7a7bb;
  --dim: #976a7f;
  --primary: #7c2d5c;
  --accent: #be185d;
  --green: #4ade80;
  --yellow: #fbbf24;
  --orange: #fb923c;
  --red: #fb7185;
  --purple: #c084fc;
}

body.theme-frost-white {
  --bg: #edf4fb;
  --sidebar-bg: #e4edf7;
  --surface: rgba(237, 244, 251, 0.98);
  --surface-hi: rgba(248, 251, 255, 0.99);
  --surface-lo: rgba(228, 237, 247, 0.95);
  --border: rgba(71, 85, 105, 0.12);
  --border-hi: rgba(71, 85, 105, 0.22);
  --text: #17212b;
  --muted: #516172;
  --dim: #7b8794;
  --primary: #6b8caf;
  --accent: #8fb7d8;
  --green: #16a34a;
  --yellow: #d4a43d;
  --orange: #ea580c;
  --red: #dc2626;
  --purple: #7c3aed;
  --shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.22);
  --tile-stripe: none;
}

body.theme-neon-coral {
  --bg: #150d14;
  --sidebar-bg: #1d111a;
  --surface: rgba(32, 17, 28, 0.98);
  --surface-hi: rgba(47, 23, 38, 0.99);
  --surface-lo: rgba(24, 13, 21, 0.97);
  --border: rgba(251, 113, 133, 0.18);
  --border-hi: rgba(253, 164, 175, 0.3);
  --text: #fff1f5;
  --muted: #d9a7b7;
  --dim: #95697a;
  --primary: #fb7185;
  --accent: #ff7a59;
  --green: #34d399;
  --yellow: #facc15;
  --orange: #ff7a59;
  --red: #fb7185;
  --purple: #c084fc;
}

body.theme-sunline-yellow {
  --bg: #181208;
  --sidebar-bg: #21190d;
  --surface: rgba(33, 25, 13, 0.98);
  --surface-hi: rgba(48, 36, 17, 0.99);
  --surface-lo: rgba(25, 19, 10, 0.97);
  --border: rgba(250, 204, 21, 0.18);
  --border-hi: rgba(253, 224, 71, 0.32);
  --text: #fff9e6;
  --muted: #d7c186;
  --dim: #97824f;
  --primary: #8a6a12;
  --accent: #facc15;
  --green: #84cc16;
  --yellow: #facc15;
  --orange: #f59e0b;
  --red: #ef4444;
  --purple: #a78bfa;
}

body.theme-shortline-red {
  --bg: #150b0b;
  --sidebar-bg: #1b1010;
  --surface: rgba(29, 16, 16, 0.98);
  --surface-hi: rgba(42, 22, 22, 0.99);
  --surface-lo: rgba(22, 13, 13, 0.97);
  --border: rgba(239, 68, 68, 0.18);
  --border-hi: rgba(252, 165, 165, 0.3);
  --text: #fff2f2;
  --muted: #d2aaaa;
  --dim: #8f6c6c;
  --primary: #991b1b;
  --accent: #ef4444;
  --green: #4ade80;
  --yellow: #facc15;
  --orange: #fb923c;
  --red: #ef4444;
  --purple: #c084fc;
}

body.theme-hopper-green {
  --bg: #0b110a;
  --sidebar-bg: #11170f;
  --surface: rgba(18, 24, 15, 0.98);
  --surface-hi: rgba(27, 35, 20, 0.99);
  --surface-lo: rgba(13, 18, 11, 0.97);
  --border: rgba(132, 204, 22, 0.16);
  --border-hi: rgba(190, 242, 100, 0.28);
  --text: #f4faea;
  --muted: #b0c290;
  --dim: #78875f;
  --primary: #4d7c0f;
  --accent: #84cc16;
  --green: #84cc16;
  --yellow: #eab308;
  --orange: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
}

body.theme-diesel-blue {
  --bg: #0a1018;
  --sidebar-bg: #0f1622;
  --surface: rgba(16, 23, 35, 0.98);
  --surface-hi: rgba(24, 34, 49, 0.99);
  --surface-lo: rgba(12, 18, 28, 0.97);
  --border: rgba(96, 165, 250, 0.18);
  --border-hi: rgba(147, 197, 253, 0.3);
  --text: #edf5ff;
  --muted: #a3b6d1;
  --dim: #6c7d96;
  --primary: #2563eb;
  --accent: #60a5fa;
  --green: #22c55e;
  --yellow: #facc15;
  --orange: #fb923c;
  --red: #fb7185;
  --purple: #818cf8;
}

body.theme-boxcar-brown {
  --bg: #140e0b;
  --sidebar-bg: #1a120f;
  --surface: rgba(28, 19, 15, 0.98);
  --surface-hi: rgba(40, 27, 20, 0.99);
  --surface-lo: rgba(21, 15, 11, 0.97);
  --border: rgba(180, 83, 9, 0.16);
  --border-hi: rgba(251, 146, 60, 0.28);
  --text: #fff4eb;
  --muted: #ceb29d;
  --dim: #8d715c;
  --primary: #92400e;
  --accent: #c2410c;
  --green: #4ade80;
  --yellow: #fbbf24;
  --orange: #c2410c;
  --red: #ef4444;
  --purple: #a78bfa;
}

/* ── Animations ─────────────────────────────────────────────── */
@keyframes fadeIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-6px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes slideInSheet {
  from {
    opacity: 0;
    transform: translateY(24px)
  }

  to {
    opacity: 1;
    transform: translateY(0)
  }
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1
  }

  50% {
    opacity: 0.35
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg)
  }
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.88)
  }

  to {
    opacity: 1;
    transform: scale(1)
  }
}

/* ── Reset ──────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior-x: none;
}

body {
  font-family: "Manrope", system-ui, -apple-system, sans-serif;
  background:
    radial-gradient(circle at top right, rgba(84, 180, 255, 0.05), transparent 24%),
    radial-gradient(circle at bottom left, rgba(120, 255, 214, 0.03), transparent 22%),
    linear-gradient(180deg, #020305 0%, #05070b 46%, #010203 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  touch-action: auto;
  line-height: 1.5;
}

body.theme-metro-legacy {
  background:
    radial-gradient(circle at top right, rgba(84, 180, 255, 0.16), transparent 24%),
    radial-gradient(circle at bottom left, rgba(120, 255, 214, 0.1), transparent 22%),
    linear-gradient(180deg, #06101b 0%, #08131e 46%, #050d16 100%);
}

body.theme-metra {
  background:
    radial-gradient(circle at top right, rgba(243, 119, 38, 0.14), transparent 22%),
    radial-gradient(circle at bottom left, rgba(47, 103, 200, 0.18), transparent 26%),
    linear-gradient(180deg, #08182f 0%, #0a2140 46%, #071225 100%);
}

button,
input,
select {
  font-family: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
  touch-action: manipulation;
}

/* ================================================================
   APP SHELL  —  flex row (sidebar | map)
   ================================================================ */
.app {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* ================================================================
   SIDEBAR  —  subway station board feel
   ================================================================ */
.sidebar {
  width: var(--sidebar-current-width, var(--sidebar-w));
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)),
    var(--sidebar-bg);
  background-image: var(--tile-stripe);
  border-right: 1px solid var(--border);
  overflow: hidden;
  z-index: 30;
  transition: transform 0.28s var(--ease), opacity 0.2s ease;
  position: absolute;
  inset: var(--panel-gap) auto var(--panel-gap) var(--panel-gap);
  height: auto;
  max-width: min(380px, calc(100% - (var(--panel-gap) * 2)));
  box-shadow: var(--shadow-lg);
  border-radius: 24px;
  backdrop-filter: blur(22px) saturate(1.12);
  -webkit-backdrop-filter: blur(22px) saturate(1.12);
}

body.safari-sidebar-stable .sidebar,
body.safari-sidebar-stable .drawer-toggle {
  transition: none !important;
}

.sidebar[data-dock="right"] {
  inset: var(--panel-gap) var(--panel-gap) var(--panel-gap) auto;
  border-right: none;
  border-left: 1px solid var(--border);
}

.sidebar[data-dock="bottom"] {
  top: auto;
  left: 50%;
  right: auto;
  bottom: calc(var(--panel-gap) + var(--safe-bottom));
  width: min(560px, calc(100% - (var(--panel-gap) * 2)));
  max-width: calc(100% - (var(--panel-gap) * 2));
  height: min(52vh, 560px);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.sidebar.sidebar-collapsed {
  pointer-events: none;
  opacity: 0;
}

.sidebar.sidebar-collapsed[data-dock="left"] {
  transform: translateX(calc(-100% - 20px));
}

.sidebar.sidebar-collapsed[data-dock="right"] {
  transform: translateX(calc(100% + 20px));
}

.sidebar.sidebar-collapsed[data-dock="bottom"] {
  transform: translate(-50%, calc(100% + 24px));
}

.sidebar.sidebar-collapsed .floating-search,
.sidebar.sidebar-collapsed .quick-strip,
.sidebar.sidebar-collapsed .support-strip,
.sidebar.sidebar-collapsed .filter-panel,
.sidebar.sidebar-collapsed .floating-list,
.sidebar.sidebar-collapsed .brand,
.sidebar.sidebar-collapsed .count-badge {
  display: none !important;
}

.sidebar.sidebar-collapsed .sidebar-header {
  justify-content: center;
  padding-inline: 8px;
}

/* ── Sidebar Header ─────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.brand h1 {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: -0.03em;
  color: var(--text);
  white-space: nowrap;
}

.brand h1 .app-version {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  vertical-align: middle;
}

.brand-description {
  font-size: 11px;
  line-height: 1.5;
  color: var(--dim);
  margin: 4px 0 10px 0;
  max-width: 220px;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(132, 215, 255, 0.16);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(132, 215, 255, 0.18);
  width: fit-content;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.header-tools {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}

.tool-btn {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: 1px solid var(--tool-border);
  background: var(--surface-lo);
  color: var(--tool-fg);
  font-size: 15px;
  display: grid;
  place-items: center;
  transition: all 0.15s var(--ease);
}

.tool-btn:hover {
  background: var(--tool-bg-hover);
  color: var(--tool-fg-hover);
  border-color: rgba(255, 255, 255, 0.2);
}

.tool-btn[data-active="true"] {
  background: rgba(132, 215, 255, 0.12);
  color: var(--accent);
  border-color: rgba(132, 215, 255, 0.26);
}

.tool-btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  pointer-events: none;
}

.tool-btn:hover svg {
  stroke: #111;
}

/* ── Search Bar ─────────────────────────────────────────────── */
.floating-search {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

.floating-search.active {
  display: flex;
}

.search-icon {
  width: 16px;
  height: 16px;
  stroke: var(--dim);
  fill: none;
  flex-shrink: 0;
}

.floating-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
}

.floating-search input::placeholder {
  color: var(--dim);
}

.filter-toggle {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-lo);
  color: var(--dim);
  font-size: 13px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.15s var(--ease);
}

.filter-toggle:hover {
  background: var(--surface-hi);
  color: var(--text);
}

.filter-toggle[data-active="true"] {
  background: rgba(252, 204, 10, 0.12);
  color: var(--accent);
  border-color: rgba(252, 204, 10, 0.4);
}

.filter-toggle svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  pointer-events: none;
}

/* ── Quick Strip ────────────────────────────────────────────── */
.quick-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-lo);
  flex-shrink: 0;
}

.quick-chip {
  padding: 3px 11px;
  border-radius: 3px;
  border: 1px solid var(--border);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transition: all 0.12s var(--ease);
}

.quick-chip:hover {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.quick-chip[data-active="true"] {
  background: var(--accent);
  color: #111;
  border-color: var(--accent);
}

.quick-chip.ghost {
  background: transparent;
  color: var(--dim);
  border-color: transparent;
}

.quick-chip.ghost:hover {
  background: var(--surface);
  color: var(--muted);
}

.quick-ratio {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  color: var(--dim);
  white-space: nowrap;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ── Filter Panel ───────────────────────────────────────────── */
.filter-panel {
  display: none;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-lo);
  flex-shrink: 0;
}

.filter-panel.active {
  display: flex;
}

.filter-panel select {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border-hi);
  border-radius: 5px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.filter-panel select:focus {
  border-color: var(--accent);
}

/* ── Train List ─────────────────────────────────────────────── */
.train-list-wrap {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.train-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.train-list::-webkit-scrollbar {
  width: 3px;
}

.train-list::-webkit-scrollbar-track {
  background: transparent;
}

.train-list::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.sidebar-detail-close {
  margin-left: auto;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
}

.train-list.sidebar-list-hidden {
  display: none;
}

.sidebar-train-detail-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 10px 10px 14px;
}

.sidebar-train-detail {
  gap: 10px;
}

.sidebar-train-detail .detail-head {
  padding: 12px 14px;
  border-radius: 14px;
}

.sidebar-train-detail .detail-brand h3 {
  font-size: 22px;
}

.sidebar-train-detail .train-stops-panel {
  max-height: 46vh;
}

.train-list-empty {
  padding: 14px 12px;
  font-size: 12px;
  line-height: 1.45;
  color: var(--muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-lo);
}

/* ── Train Card  ——  subway station board row ───────────────── */
.train-card {
  border-radius: 18px;
  border: 1px solid var(--border);
  border-left: 0;
  padding: 12px 12px 12px 13px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.015)), var(--surface-lo);
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  animation: slideUp 0.18s ease both;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), transform 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

.train-card:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02)), var(--surface);
  border-color: var(--border-hi);
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.18);
}

.train-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Subway bullet circle */
.train-card-id {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--line-color, #444);
  border: 2px solid rgba(255, 255, 255, 0.18);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 900;
  color: #fff;
  flex-shrink: 0;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.train-card-title-wrap {
  min-width: 0;
}

.train-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--name-color, var(--text));
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.25;
}

.train-card-sub {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.35;
}

.train-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}

.kpi {
  padding: 6px 9px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.kpi span {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  font-weight: 700;
}

.kpi strong {
  font-size: 12px;
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.train-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
}

.train-meta span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meta-updated {
  margin-left: auto;
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

/* Delay badges */
.badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 800;
  width: fit-content;
  line-height: 1.4;
}

.badge.delay-green {
  background: rgba(0, 147, 60, 0.22);
  color: #4ade80;
}

.badge.delay-yellow {
  background: rgba(252, 204, 10, 0.20);
  color: #fccc0a;
}

.badge.delay-orange {
  background: rgba(255, 99, 25, 0.22);
  color: #ff6319;
}

.badge.delay-red {
  background: rgba(238, 53, 46, 0.22);
  color: #ee352e;
}

.badge.delay-unknown {
  background: rgba(150, 150, 150, 0.15);
  color: #a0a0a0;
}

.badge.badge-speed {
  background: rgba(148, 163, 184, 0.16);
  border: 1px solid rgba(148, 163, 184, 0.3);
  color: var(--text);
  text-transform: none;
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}

/* Save btn */
.save-btn {
  width: 100%;
  height: 26px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--dim);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.12s var(--ease);
}

.save-btn:hover {
  background: rgba(252, 204, 10, 0.10);
  color: var(--accent);
  border-color: rgba(252, 204, 10, 0.35);
}

/* Compact mode */
body.compact-cards .train-kpis,
body.compact-cards .train-meta {
  display: none;
}

/* ── Status Indicator ───────────────────────────────────────── */
.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  border: 1px solid transparent;
  line-height: 1.3;
}

.status-indicator::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

.status-indicator.live {
  color: #4ade80;
  background: rgba(0, 147, 60, 0.15);
  border-color: rgba(0, 147, 60, 0.3);
}

.status-indicator.live::before {
  background: #00933c;
  animation: pulse 1.5s infinite;
}

.status-indicator.scheduled {
  color: #a0a0a0;
  background: rgba(160, 160, 160, 0.10);
  border-color: rgba(160, 160, 160, 0.2);
}

.status-indicator.scheduled::before {
  background: #606060;
}

/* ================================================================
   MAP PANE
   ================================================================ */
.map-pane {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-width: 0;
  width: 100%;
}

.map {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* Ensure map renders properly */
.map>canvas {
  display: block;
}

.maplibregl-canvas-container,
.maplibregl-canvas {
  touch-action: none;
}

.sidebar,
.train-list,
.modal-content,
.settings-content,
.railcam-content {
  touch-action: pan-y;
}

/* ── Map Action Buttons ─────────────────────────────────────── */
.map-actions {
  position: absolute;
  top: calc(var(--map-actions-top, 12px) + var(--safe-top));
  left: calc(var(--map-actions-left, 12px) + var(--safe-left));
  right: var(--map-actions-right, auto);
  bottom: var(--map-actions-bottom, auto);
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 40;
  transition:
    left 0.28s var(--ease),
    right 0.28s var(--ease),
    top 0.28s var(--ease),
    bottom 0.28s var(--ease);
}

.map-actions .map-btn:first-child {
  margin-top: 2px;
}

.maplibregl-ctrl-top-right {
  top: calc(10px + var(--safe-top));
  right: calc(10px + var(--safe-right));
}

.maplibregl-ctrl-bottom-right {
  right: calc(10px + var(--safe-right));
  bottom: calc(74px + var(--safe-bottom));
}

.map-corner-brand {
  position: absolute;
  top: calc(12px + var(--safe-top));
  right: calc(14px + var(--safe-right));
  z-index: 40;
  pointer-events: none;
  user-select: none;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 7px;
  color: #fff;
  font-size: clamp(15px, 1.5vw, 20px);
  font-weight: 900;
  letter-spacing: -0.03em;
  line-height: 1;
  text-align: right;
  text-shadow:
    0 2px 10px rgba(0, 0, 0, 0.45),
    0 1px 2px rgba(0, 0, 0, 0.72);
}

.map-corner-brand-name {
  color: #fff;
}

.map-corner-brand-beta {
  font-size: 0.56em;
  font-weight: 400;
  letter-spacing: 0.16em;
  color: rgba(255, 255, 255, 0.78);
}

.map-btn {
  width: 40px;
  height: 40px;
  border-radius: 14px;
  border: 1px solid var(--tool-border);
  background: var(--tool-bg);
  color: var(--tool-fg);
  font-size: 16px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  transition: all 0.16s var(--ease), transform 0.16s cubic-bezier(0.34, 1.4, 0.64, 1);
  position: relative;
}

.map-btn:hover {
  background: var(--tool-bg-hover);
  color: var(--tool-fg-hover);
  border-color: rgba(255, 255, 255, 0.22);
  transform: translateY(-1px);
}

.map-btn:active {
  transform: scale(0.94);
}

.map-btn[data-active="true"] {
  background: rgba(132, 215, 255, 0.12);
  color: var(--accent);
  border-color: rgba(132, 215, 255, 0.24);
}

.map-btn[data-active="true"]:hover {
  background: var(--tool-bg-hover);
  color: var(--tool-fg-hover);
  transform: scale(1.08);
}

.map-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  pointer-events: none;
  transition: transform 0.15s var(--ease);
}

.map-btn:hover svg {
  stroke: currentColor;
}

/* "3D" text button — bold label instead of SVG icon */
.map-btn-text {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  font-family: var(--font-mono, ui-monospace, monospace);
}

.map-btn-text--rxr {
  font-size: 10px;
  letter-spacing: 0.12em;
}

.map-btn-text:hover {
  color: #111;
}

/* Map style cycle button — shows current style as a tiny badge */
.map-btn[data-style]::after {
  content: attr(data-style);
  position: absolute;
  bottom: 3px;
  right: 4px;
  font-size: 6px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--accent);
  pointer-events: none;
}

/* satellite = special accent colour */
.map-btn[data-style="satellite"]::after {
  color: #38bdf8;
}

.map-btn[data-style="topo"]::after {
  color: #4ade80;
}

.map-btn[data-style="light"]::after {
  color: #f8fafc;
}

/* ── Sync Flash Dot ─────────────────────────────────────────── */
@keyframes sync-flash-fade {
  0%   { opacity: 0; transform: scale(0.7); }
  12%  { opacity: 1; transform: scale(1.15); }
  30%  { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(0.85); }
}

.sync-flash {
  position: absolute;
  right: calc(16px + var(--safe-right));
  bottom: calc(16px + var(--safe-bottom));
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px 2px rgba(74, 222, 128, 0.5);
  z-index: 40;
  pointer-events: none;
  opacity: 0;
}

.sync-flash--active {
  animation: sync-flash-fade 2.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.map-version-pill {
  position: absolute;
  right: calc(16px + var(--safe-right));
  bottom: calc(28px + var(--safe-bottom));
  z-index: 40;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(10, 14, 22, 0.94), rgba(10, 14, 22, 0.82));
  color: var(--tool-fg);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: all 0.16s var(--ease);
}

.map-version-pill:hover {
  background: linear-gradient(180deg, rgba(17, 24, 39, 0.96), rgba(15, 23, 42, 0.86));
  color: var(--tool-fg-hover);
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}


.support-strip {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  flex-shrink: 0;
}

#open-booking {
  background: #f97316 !important;
  color: #fff !important;
}

#open-booking:hover {
  background: #ea580c !important;
}

.booking-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.booking-service-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.08);
  background: var(--booking-bg, #1f4fa3);
  color: var(--booking-fg, #fff);
  border-radius: 8px;
  padding: 14px 12px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.16s ease, filter 0.16s ease;
}

.booking-service-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.donate-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, #ffd84d 0%, #f3bd00 100%);
  color: #111111;
  border: 1px solid rgba(128, 90, 0, 0.58);
  box-shadow: 0 10px 24px rgba(243, 189, 0, 0.18);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  pointer-events: auto;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), filter 0.15s var(--ease), background 0.15s var(--ease);
}

.donate-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(243, 189, 0, 0.24);
  filter: brightness(1.03);
}

/* ── Contrib Pill ───────────────────────────────────────────── */
.contrib-pill {
  display: none;
  position: absolute;
  left: var(--contrib-left, 12px);
  right: var(--contrib-right, auto);
  bottom: calc(var(--contrib-bottom, 12px) + var(--safe-bottom));
  max-width: min(520px, calc(100vw - 28px));
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  z-index: 40;
  pointer-events: auto;
  transition:
    left 0.28s var(--ease),
    right 0.28s var(--ease),
    bottom 0.28s var(--ease);
}

.contrib-title {
  display: block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
  font-weight: 800;
  margin-bottom: 3px;
}

.contrib-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 8px;
}

.contrib-powered,
.contrib-separator {
  font-size: 10px;
  color: var(--dim);
}

.contrib-powered a {
  color: var(--accent);
  text-decoration: none;
}

.contrib-links a {
  font-size: 10px;
  color: var(--muted);
  text-decoration: none;
}

.contrib-links a:hover {
  color: var(--accent);
}

.contrib-links span {
  color: var(--dim);
  font-size: 10px;
}

.contrib-api-warning {
  font-size: 10px;
  line-height: 1.4;
  color: var(--orange);
  max-width: min(320px, 92vw);
}

.contrib-legal-link {
  display: none;
}

/* ── Delay Queue ───────────────────────────────────────────── */
.delay-queue {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 264px;
  z-index: 10;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-hi);
  border-radius: 8px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: fadeIn 0.25s var(--ease);
}

.dq-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  user-select: none;
}

.dq-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: #ee352e;
  transition: color 0.2s;
}

.delay-queue:not(.has-delays) .dq-icon {
  color: var(--dim);
}

.dq-title {
  flex: 1;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text);
}

.dq-count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: rgba(150, 150, 150, 0.12);
  color: var(--dim);
  font-size: 10px;
  font-weight: 800;
  display: grid;
  place-items: center;
  transition: background 0.2s, color 0.2s;
}

.dq-count.has-delays {
  background: rgba(238, 53, 46, 0.22);
  color: #ee352e;
  animation: pulse 2.5s infinite;
}

.dq-toggle {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  display: grid;
  place-items: center;
  border-radius: 4px;
  transition: color 0.15s, transform 0.2s var(--ease);
  padding: 0;
}

.dq-toggle:hover {
  color: var(--text);
}

.dq-toggle svg {
  width: 12px;
  height: 12px;
  stroke: currentColor;
}

.delay-queue.collapsed .dq-toggle {
  transform: rotate(180deg);
}

.dq-body {
  max-height: 300px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hi) transparent;
  transition: max-height 0.2s var(--ease);
}

.delay-queue.collapsed .dq-body {
  max-height: 0;
  overflow: hidden;
}

.dq-empty {
  padding: 14px 12px;
  text-align: center;
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.03em;
}

.dq-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  cursor: pointer;
  transition: background 0.12s;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.dq-item:last-child {
  border-bottom: none;
}

.dq-item:hover {
  background: rgba(255, 255, 255, 0.06);
}

.dq-bullet {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 9px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.dq-info {
  flex: 1;
  min-width: 0;
}

.dq-name {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dq-op {
  display: block;
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1px;
}

.dq-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}

.dq-badge.delay-yellow {
  background: rgba(252, 204, 10, 0.20);
  color: #fccc0a;
}

.dq-badge.delay-orange {
  background: rgba(255, 99, 25, 0.22);
  color: #ff6319;
}

.dq-badge.delay-red {
  background: rgba(238, 53, 46, 0.22);
  color: #ee352e;
}

.dq-badge.delay-green {
  background: rgba(0, 147, 60, 0.22);
  color: #4ade80;
}

.dq-badge.delay-unknown {
  background: rgba(150, 150, 150, 0.15);
  color: #a0a0a0;
}

/* light mode overrides */
body.light .delay-queue {
  background: rgba(240, 240, 240, 0.96);
}

body.light .dq-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

body.light .dq-item {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

/* mobile */
@media (max-width: 768px) {
  .delay-queue {
    width: 200px;
    top: 8px;
    right: 8px;
  }

  .dq-body {
    max-height: 180px;
  }
}

/* ── Train Tooltip ──────────────────────────────────────────── */
.train-tooltip {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  padding: 0;
  border-radius: 12px;
  background: rgba(10, 10, 10, 0.96);
  border: 1px solid var(--border-hi);
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.04);
  max-width: 280px;
  min-width: 220px;
  opacity: 0;
  transform: translate(-50%, calc(-100% - 12px)) scale(0.92);
  transition: opacity 0.12s ease, transform 0.12s cubic-bezier(0.34, 1.3, 0.64, 1);
  line-height: 1.45;
  backdrop-filter: blur(8px);
}

/* ── Overlap Feature Selector ───────────────────────────────── */
.overlap-popup-container .maplibregl-popup-content {
  background: rgba(15, 15, 15, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.8);
  border-radius: 6px;
  padding: 12px;
  backdrop-filter: blur(12px);
  color: #fff;
  min-width: 220px;
}
.overlap-popup-container .maplibregl-popup-tip {
  border-top-color: rgba(15, 15, 15, 0.96);
}
.overlap-popup-header {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #fff;
}
.overlap-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  padding: 8px 10px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  margin-bottom: 8px;
  transition: all 0.15s ease;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
}
.overlap-btn:last-child {
  margin-bottom: 0;
}
.overlap-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}
.overlap-badge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
  min-width: 44px;
  height: 24px;
}

.train-tooltip.visible {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 12px)) scale(1);
}

.train-tooltip strong {
  color: var(--accent);
}

.train-tooltip-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}

.train-tooltip-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.train-tooltip-head strong {
  font-size: 14px;
  line-height: 1.2;
}

.train-tooltip-head span {
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.03em;
}

.train-tooltip-sub {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.35;
}

.train-tooltip-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.train-tooltip-grid div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.train-tooltip-grid span {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--dim);
}

.train-tooltip-grid strong {
  font-size: 11px;
  color: var(--text);
}

.train-tooltip-foot {
  padding-top: 2px;
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--muted);
}

.train-tooltip-alert {
  padding: 8px 9px;
  border-radius: 8px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
  color: #fecaca;
  font-size: 10px;
  line-height: 1.45;
}

/* ================================================================
   TRAIN MARKERS
   ================================================================ */
.train-bullet-marker {
  min-width: 30px;
  height: 18px;
  padding: 0 6px;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  color: #fff;
  font-size: 9px;
  font-weight: 900;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  line-height: 1;
  gap: 1px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
  cursor: pointer;
  pointer-events: auto;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.42);
  transition: box-shadow 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.4, 0.64, 1);
  position: relative;
  backdrop-filter: blur(8px) saturate(1.08);
  -webkit-backdrop-filter: blur(8px) saturate(1.08);
  will-change: transform;
  transform-origin: center center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.train-bullet-marker:hover {
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.4);
  transform: translateY(-1px);
}

.train-marker-alert-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #ef4444;
  border: 1.5px solid rgba(8, 12, 20, 0.96);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.28), 0 0 12px rgba(239, 68, 68, 0.45);
}

.train-popup-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 280px;
  max-width: 340px;
  color: var(--text);
}

.train-popup-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
  padding-right: 38px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.train-popup-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.train-popup-brand-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.train-popup-header strong {
  font-size: 16px;
  line-height: 1.15;
}

.train-popup-header span {
  font-size: 11px;
  color: var(--muted);
}

.train-popup-brand-copy strong,
.train-popup-brand-copy span,
.train-popup-subhead {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.train-popup-subhead {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
  margin-top: -2px;
}

.train-popup-highlights {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.train-popup-highlight {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)), var(--surface-lo);
  border: 1px solid var(--border-hi);
}

.train-popup-highlight span {
  font-size: 9px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.train-popup-highlight strong {
  font-size: 12px;
  color: var(--text);
}

.train-popup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.train-popup-grid div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.train-popup-grid span {
  font-size: 9px;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.train-popup-grid strong {
  font-size: 12px;
}

.train-popup-alert {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 9px 10px;
  border-radius: 9px;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.28);
}

.train-popup-alert strong {
  color: #f87171;
  font-size: 11px;
}

.train-popup-alert span {
  color: var(--text);
  font-size: 11px;
  line-height: 1.45;
}

.train-popup-stops {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.train-popup-stops-head {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--dim);
}

.train-popup-stops-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.train-popup-stops-loading,
.train-popup-stops-empty {
  font-size: 11px;
  color: var(--muted);
}

.train-popup-stop-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.train-popup-stop-row:last-child {
  padding-bottom: 0;
  border-bottom: none;
}

.train-popup-stop-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.train-popup-stop-main strong {
  font-size: 12px;
  color: var(--text);
}

.train-popup-stop-platform {
  font-size: 10px;
  color: var(--muted);
}

.train-popup-stop-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: flex-end;
  text-align: right;
  flex-shrink: 0;
}

.train-popup-stop-meta span:first-child {
  font-size: 11px;
  color: var(--text);
}

.train-popup-stop-meta span:last-child {
  font-size: 10px;
  color: var(--muted);
}

.train-popup-actions {
  display: flex;
  gap: 8px;
}

.train-popup-actions .btn-secondary {
  flex: 1;
}

.train-map-popup-compact .maplibregl-popup-content {
  padding: 14px 14px 12px !important;
  border-radius: 18px !important;
}

.train-map-popup-compact .maplibregl-popup-content::before {
  left: 14px;
  right: 14px;
}

.train-map-popup-compact .train-popup-card {
  min-width: min(248px, calc(100vw - 96px));
  max-width: min(280px, calc(100vw - 96px));
  gap: 10px;
}

.train-map-popup-compact .train-popup-header {
  padding-right: 32px;
  padding-bottom: 10px;
}

.train-map-popup-compact .train-popup-header strong {
  font-size: 15px;
}

.train-map-popup-compact .train-popup-subhead {
  font-size: 10px;
}

.train-map-popup-compact .train-popup-highlights,
.train-map-popup-compact .train-popup-grid {
  gap: 6px;
}

.train-map-popup-compact .train-popup-highlight,
.train-map-popup-compact .train-popup-grid div {
  padding: 10px;
  border-radius: 12px;
}

.train-map-popup-compact .train-popup-stops {
  gap: 8px;
}

.train-map-popup-compact .train-popup-stop-row {
  gap: 8px;
  padding: 8px 0;
}

.train-map-popup-compact .train-popup-stop-main strong,
.train-map-popup-compact .train-popup-stop-meta span:first-child {
  font-size: 11px;
}

.train-map-popup-compact .train-popup-stop-platform,
.train-map-popup-compact .train-popup-stop-meta span:last-child {
  font-size: 9px;
}

.incident-popup-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 220px;
}

.incident-popup-kicker {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.incident-popup-card strong {
  font-size: 15px;
  line-height: 1.2;
}

.incident-popup-sub {
  font-size: 11px;
  color: var(--muted);
}

.incident-popup-card p {
  margin: 0;
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
}

.train-popup-images {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 8px;
}

.train-popup-image-card {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.train-popup-image-card img,
.train-popup-image-card video {
  width: 100%;
  height: 86px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.train-popup-image-card figcaption {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.35;
}

.bullet-prefix {
  font-size: 8px;
  opacity: 0.9;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.bullet-num {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.bullet-num--full {
  font-size: 8px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

/* ================================================================
   MODALS  (position:fixed, full viewport)
   ================================================================ */
.detail-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.detail-modal.active {
  display: flex;
  animation: fadeIn 0.2s ease;
}

/* ── Fares & Pricing ─────────────────────────────────────── */
.fares-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 0;
  animation: slideUp 0.3s var(--ease);
}

.fare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface-hi);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: transform 0.2s var(--ease), border-color 0.2s;
}

.fare-row:hover {
  border-color: var(--primary);
  transform: translateY(-2px);
}

.fare-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fare-type {
  font-weight: 700;
  color: var(--text);
  font-size: 1.05rem;
}

.fare-note {
  font-size: 0.8rem;
  color: var(--dim);
}

.fare-price {
  text-align: right;
  display: flex;
  align-items: baseline;
  gap: 4px;
}

.fare-currency {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--muted);
}

.fare-amount {
  font-size: 1.4rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -0.02em;
}

.fare-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.btn-book {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.2s var(--ease);
  box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

.btn-book:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(var(--primary-rgb), 0.4);
  filter: brightness(1.1);
}

.btn-book svg {
  opacity: 0.9;
}

.btn-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  margin-right: 8px;
  background: rgba(127, 179, 255, 0.1);
  color: var(--primary);
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  transition: all 0.2s;
  border: none;
  cursor: pointer;
}

.btn-back-link:hover {
  background: var(--primary);
  color: #fff;
}

.fare-disclaimer {
  margin-top: 16px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.12);
  border-left: 3px solid var(--border);
  font-size: 0.8rem;
  color: var(--dim);
  line-height: 1.4;
  border-radius: 0 8px 8px 0;
}

.modal-content {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02)), var(--surface-hi);
  border-radius: 24px;
  padding: 26px;
  max-width: 760px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.14);
  position: relative;
  animation: slideInSheet 0.28s cubic-bezier(0.34, 1.2, 0.64, 1) both;
  backdrop-filter: blur(22px) saturate(1.08);
  -webkit-backdrop-filter: blur(22px) saturate(1.08);
}

.cluster-content {
  max-width: 480px;
  padding: 20px;
}

.cluster-tabs {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 8px;
}

.cluster-tab {
  background: transparent;
  border: none;
  font-size: 14px;
  font-weight: 700;
  color: var(--dim);
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.15s ease;
}

.cluster-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.cluster-tab.active {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.cluster-pane {
  display: none;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}

.cluster-pane.active {
  display: flex;
}

.modal-content::-webkit-scrollbar {
  width: 3px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: var(--border-hi);
  border-radius: 999px;
}

.modal-content::before {
  display: none;
}

.close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(9, 12, 18, 0.92);
  color: var(--text);
  font-size: 30px;
  line-height: 1;
  padding: 0 0 4px;
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.16s var(--ease);
  z-index: 2;
}

.close-btn:hover {
  background: rgba(239, 68, 68, 0.18);
  color: #fff;
  border-color: rgba(239, 68, 68, 0.42);
  transform: scale(1.04);
}

/* ── Train Detail ─────────────────────────────────────────── */
.train-detail,
.station-board {
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 0 0 14px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.detail-brand {
  display: flex;
  align-items: center;
  gap: 0;
}

.detail-brand--stack {
  width: 100%;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.detail-brand-copy {
  min-width: 0;
}

.detail-brand-meta {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
  line-height: 1.35;
}

.detail-endpoint-line {
  margin-top: 4px;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.3;
  display: flex;
  align-items: center;
  gap: 7px;
}

.detail-brand h3 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 2px;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.detail-brand p {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
  font-weight: 500;
  line-height: 1.35;
}

.detail-live-hint {
  margin-top: 4px;
  font-size: 11px;
  color: var(--dim);
}

.detail-logo,
.detail-logo-fallback {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  background: var(--surface-lo);
  flex-shrink: 0;
}

.detail-logo {
  object-fit: contain;
  padding: 3px;
}

.detail-logo--compact,
.detail-logo-fallback.detail-logo--compact {
  width: 30px;
  height: 30px;
  border-radius: 7px;
}

.detail-logo.logo-source-metra,
.detail-logo-fallback.logo-source-metra {
  background: #ffffff;
  border-color: rgba(11, 92, 171, 0.22);
}

.detail-logo.logo-source-metra {
  padding: 4px 3px;
}

.detail-logo-fallback {
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  background: var(--logo-color, var(--primary));
  border-radius: 50%;
  /* subway bullet logo */
  letter-spacing: -0.02em;
}

.detail-tags {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.detail-tags--header {
  justify-content: flex-start;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  margin-top: 4px;
}

.detail-grid div {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 15px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02)), var(--surface-lo);
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 16px;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
  animation: popIn 0.2s ease both;
}

.detail-grid div:hover {
  background: var(--surface);
  border-color: var(--border-hi);
}

.detail-grid span {
  color: var(--dim);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.detail-grid strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  line-height: 1.35;
}

.detail-actions-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.detail-actions-row .btn-secondary {
  min-height: 42px;
}

.detail-actions-row--primary {
  margin-top: 2px;
}

.detail-sync-note {
  margin-top: 8px;
  font-size: 11px;
  color: var(--dim);
}

.detail-alert-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  margin-top: 2px;
  color: #f87171;
}

.detail-primary-section {
  margin-top: 8px;
}

.detail-hero-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.detail-hero-caption {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.btn-secondary {
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.14s var(--ease), border-color 0.14s var(--ease), background 0.14s var(--ease), color 0.14s var(--ease);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.08);
  transform: translateY(-1px);
}

.btn-secondary--alert-active {
  border-color: rgba(239, 68, 68, 0.32);
  color: #fecaca;
  background: rgba(127, 29, 29, 0.14);
  animation: pulse 1.2s ease-in-out infinite;
}

.btn-secondary--alert-active:hover {
  border-color: rgba(239, 68, 68, 0.7);
  color: #ffffff;
  background: rgba(153, 27, 27, 0.32);
}

.credits-content {
  max-width: 820px;
}

.credits-note,
.credits-empty {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.credits-list {
  display: grid;
  gap: 12px;
}

.credits-entry {
  padding: 14px 16px;
  border: 1px solid var(--border-hi);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
}

.credits-entry-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin-bottom: 8px;
}

.credits-entry-title,
.credits-entry-license {
  text-decoration: none;
}

.credits-entry-title {
  color: var(--text);
  font-weight: 800;
  font-size: 14px;
}

.credits-entry-license {
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.credits-entry-copy,
.credits-entry-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.credits-entry-note {
  margin-top: 8px;
  color: var(--dim);
}

.spec-reference-wrap {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.spec-reference-image {
  width: min(100%, 520px);
  max-height: 220px;
  object-fit: cover;
  border-radius: 10px;
  border: 1px solid var(--border-hi);
  background: var(--surface-lo);
}

.service-alert-content {
  width: min(760px, calc(100vw - 24px));
}

.service-alert-shell {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.service-alert-head {
  margin-bottom: 2px;
}

.service-alert-headline {
  display: grid;
  gap: 6px;
}

.service-alert-headline span {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.service-alert-headline h3 {
  margin: 0;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.service-alert-headline p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.service-alert-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.service-alert-section-head {
  font-size: 11px;
  font-weight: 800;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.service-alert-history {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.service-alert-entry {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.035);
}

.service-alert-entry--active {
  border-color: rgba(239, 68, 68, 0.28);
  background: rgba(127, 29, 29, 0.16);
}

.service-alert-entry--critical {
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.2);
}

.service-alert-entry--major {
  border-color: rgba(251, 146, 60, 0.36);
  background: rgba(124, 45, 18, 0.14);
}

.service-alert-entry--minor {
  border-color: rgba(250, 204, 21, 0.3);
  background: rgba(120, 53, 15, 0.12);
}

.service-alert-entry--info {
  border-color: rgba(96, 165, 250, 0.3);
  background: rgba(30, 58, 138, 0.12);
}

.service-alert-entry-title {
  font-size: 11px;
  font-weight: 800;
  color: #f87171;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.service-alert-entry-body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
}

.service-alert-entry-meta {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.service-alert-entry-meta a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.service-alert-entry-meta a:hover {
  text-decoration: underline;
}

.service-alert-empty {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 13px;
}

.train-stops-panel {
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.02)), var(--surface-lo);
  padding: 12px;
  max-height: 42vh;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.stops-title-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.stops-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

.stops-meta {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 8px;
}

.train-diagram-panel {
  border: 1px solid var(--border-hi);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)), var(--surface-lo);
  padding: 16px;
}

.train-diagram-panel--empty {
  border-style: dashed;
}

.train-diagram-profile {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.train-diagram-profile+.train-diagram-profile {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.train-diagram-profile-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.train-diagram-profile-head strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
}

.train-diagram-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.train-diagram-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.train-diagram-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--dim);
}

.train-diagram-source {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.train-diagram-source:hover {
  text-decoration: underline;
}

.train-diagram-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.train-diagram-subtitle {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
}

.train-diagram-title {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.22);
  background: rgba(250, 204, 21, 0.08);
  color: #facc15;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.train-diagram-track {
  position: relative;
  padding: 18px 0 8px;
}

.train-diagram-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 38px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
}

.train-diagram-cars {
  position: relative;
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.train-diagram-car {
  position: relative;
  z-index: 1;
  min-width: 82px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.train-diagram-car::before {
  content: "";
  width: 82px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(148, 163, 184, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.train-diagram-car--locomotive::before,
.train-diagram-car--dmu::before {
  background: linear-gradient(180deg, rgba(37, 99, 235, 0.34), rgba(29, 78, 216, 0.18));
  border-color: rgba(59, 130, 246, 0.34);
}

.train-diagram-car--cab::before {
  background: linear-gradient(180deg, rgba(16, 185, 129, 0.28), rgba(5, 150, 105, 0.15));
  border-color: rgba(16, 185, 129, 0.3);
}

.train-diagram-car--cafe::before,
.train-diagram-car--observation::before {
  background: linear-gradient(180deg, rgba(245, 158, 11, 0.28), rgba(217, 119, 6, 0.15));
  border-color: rgba(245, 158, 11, 0.32);
}

.train-diagram-car--sleeper::before,
.train-diagram-car--baggage::before {
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.26), rgba(126, 34, 206, 0.14));
  border-color: rgba(168, 85, 247, 0.3);
}

.train-diagram-short {
  position: absolute;
  top: 9px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: #f8fafc;
}

.train-diagram-label {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
}

.train-diagram-note {
  margin-top: 8px;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.45;
}

/* ── Future Connections Panel ─────────────────────────────────── */
.train-future-connections-panel {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-lo);
  padding: 12px;
}

.future-connections-title {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 10px;
}

.future-connections-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.future-connection-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  background: var(--surface);
  border-radius: 6px;
  border: 1px solid var(--border);
  transition: border-color 0.12s var(--ease), background 0.12s var(--ease);
}

.future-connection-item:hover {
  border-color: var(--accent);
  background: var(--surface-hi);
}

.fc-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.fc-status {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--dim);
}

.fc-status.under-construction {
  color: #facc15;
}

.fc-status.planned {
  color: #60a5fa;
}

.fc-route {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

.stops-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.mini-spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-top-color: var(--accent);
  animation: spin 0.7s linear infinite;
}

.stop-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stop-time-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 58px;
}

.stop-row:last-child {
  border-bottom: none;
}

.stop-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stop-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.stop-platform {
  font-size: 10px;
  color: var(--muted);
}

.stop-platform--predicted {
  color: #facc15;
}

.stop-time {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.stop-time--actual {
  color: var(--text);
  font-weight: 700;
}

.stop-status-text {
  font-size: 11px;
  color: var(--dim);
  line-height: 1.35;
}

.stop-eta {
  font-size: 11px;
  font-weight: 700;
  color: var(--text);
}

.train-card-alert {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  font-size: 11px;
  line-height: 1.45;
  display: grid;
  gap: 4px;
}

.train-card-alert-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.train-card-alert-text {
  color: var(--text);
}

.train-card-alert--critical {
  background: rgba(127, 29, 29, 0.28);
  border-color: rgba(248, 113, 113, 0.45);
}

.train-card-alert--major {
  background: rgba(124, 45, 18, 0.24);
  border-color: rgba(251, 146, 60, 0.38);
}

.train-card-alert--minor {
  background: rgba(120, 53, 15, 0.22);
  border-color: rgba(250, 204, 21, 0.34);
}

.train-card-alert--info {
  background: rgba(30, 58, 138, 0.2);
  border-color: rgba(96, 165, 250, 0.32);
}

.technical-info-panel {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-lo);
  overflow: hidden;
}

.technical-info-panel summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
}

.technical-info-panel summary::-webkit-details-marker {
  display: none;
}

.technical-info-grid {
  margin: 0;
  padding: 0 12px 12px;
}

.stop-eta.late {
  color: #ee352e;
}

.stop-eta.early,
.stop-eta.ontime {
  color: #4ade80;
}

.detail-hero {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin-bottom: 4px;
}

.board-row {
  display: grid;
  grid-template-columns: 0.9fr 1.2fr 1fr 0.9fr;
  gap: 6px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}

.board-row span {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.station-arrivals-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.station-arrival-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.station-arrival-section-header {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 4px;
}

.station-arrival-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.station-arrival-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  align-items: center;
}

.station-arrival-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.station-arrival-id {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.01em;
  line-height: 1.2;
}

.station-arrival-route {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.station-arrival-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
}

.station-arrival-times {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.station-arrival-time {
  font-size: 13px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.station-arrival-status {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.station-arrival-time--on-time,
.station-arrival-status--on-time {
  color: #4ade80;
}

.station-arrival-time--late,
.station-arrival-status--late {
  color: #f97316;
}

.station-arrival-time--early,
.station-arrival-status--early {
  color: #22d3ee;
}

.station-arrival-time--canceled,
.station-arrival-status--canceled {
  color: #ef4444;
}

.row-status {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
  font-weight: 800;
  color: var(--text) !important;
}

.empty-state {
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ── Train Detail Visual Refresh ─────────────────────────────── */
#detail-modal .modal-content {
  max-width: 780px;
  padding: 28px 24px 22px;
  border-radius: 28px;
  border-color: var(--border);
  background: var(--surface);
}

#detail-modal {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
}

#detail-modal .modal-content {
  margin: 0 0 0 auto;
  width: min(500px, 40vw);
  max-width: min(500px, 100vw);
  height: 100dvh;
  max-height: 100dvh;
  border-radius: 22px 0 0 22px;
  border-right: none;
  transform: translateX(100%);
  transition: transform 0.24s var(--ease);
  animation: none;
}

#detail-modal.active .modal-content {
  transform: translateX(0);
}

.detail-sheet-grabber {
  display: none;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 4px 0 10px;
}

.detail-sheet-grabber span {
  display: inline-block;
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.34);
}

#detail-modal .close-btn {
  width: 40px;
  height: 40px;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(8, 12, 18, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.train-detail {
  gap: 16px;
}

.train-detail .detail-head {
  align-items: flex-start;
  padding: 16px 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.02)), var(--surface-lo);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
}

.train-detail .detail-brand {
  flex: 1;
  min-width: 0;
}

.train-detail .detail-brand h3 {
  margin: 0;
  font-size: 28px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}

.train-detail .detail-brand p {
  margin-top: 4px;
  color: var(--dim);
}

.train-detail .detail-tags {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
  align-items: center;
  align-content: center;
  min-width: 0;
}

.train-detail .badge,
.train-detail .status-indicator {
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 10px;
  letter-spacing: 0.06em;
}

.train-detail .detail-route-hero {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.train-detail .detail-route-title {
  font-size: 13px;
}

.train-detail .detail-route-endpoints {
  font-size: 11px;
}

.train-detail .detail-primary-section {
  margin-top: 0;
}

.detail-route-hero {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-lo);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.detail-route-title {
  font-size: 14px;
  font-weight: 700;
  font-style: italic;
  color: var(--text);
}

.detail-route-endpoints {
  font-size: 12px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 7px;
}

.train-detail .stops-title {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.train-detail .train-stops-panel {
  margin-top: 0;
  padding: 12px 14px;
  border-radius: 16px;
  border-color: rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.015)), var(--surface-lo);
  max-height: 44vh;
}

.train-detail .stop-row {
  padding: 11px 0;
  gap: 12px;
  border-bottom-color: rgba(255, 255, 255, 0.08);
}

.train-detail .stop-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.train-detail .stop-platform {
  font-size: 11px;
  color: var(--dim);
}

.train-detail .stop-status-text {
  font-size: 10px;
}

.train-detail .stop-time,
.train-detail .stop-eta {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.train-detail .stop-time {
  color: var(--text);
}

.train-detail .detail-grid {
  gap: 12px;
  margin-top: 2px;
}

.train-detail .detail-grid div {
  gap: 7px;
  padding: 14px;
  border-radius: 16px;
  border-color: rgba(255, 255, 255, 0.08);
  background: var(--surface-lo);
}

.train-detail .detail-summary-grid strong {
  font-size: 24px;
  line-height: 1.05;
  letter-spacing: -0.02em;
}

.train-detail .detail-sync-note {
  margin-top: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.train-detail .detail-actions-row {
  margin-top: 2px;
}

.train-detail .detail-actions-row .btn-secondary {
  min-height: 40px;
  border-radius: 10px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

.train-detail .detail-actions-row .btn-secondary:hover:not(:disabled) {
  border-color: rgba(252, 204, 10, 0.42);
  background: rgba(252, 204, 10, 0.08);
  color: #ffe58f;
}

.train-detail .detail-actions-row .btn-secondary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.train-detail .technical-info-panel {
  margin-top: 4px;
  border-radius: 12px;
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(8, 12, 18, 0.54);
}

.train-detail .technical-info-panel summary {
  padding: 11px 14px;
  color: var(--dim);
}

.train-detail .technical-info-grid {
  padding: 0 12px 12px;
}

.train-detail .technical-info-grid strong {
  font-size: 13px;
}

/* ── Railcams ─────────────────────────────────────────────────── */
.railcam-content {
  width: min(1120px, calc(100vw - 40px));
  max-height: min(86vh, 860px);
}

.railcam-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 420px);
  gap: 18px;
}

.railcam-stage,
.railcam-browser {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)), var(--surface);
}

.railcam-stage {
  padding: 18px;
}

.railcam-stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.railcam-stage-kicker {
  display: inline-block;
  font-size: 10px;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}

.railcam-content h3 {
  font-size: 24px;
  font-weight: 800;
  margin: 0;
  padding-right: 30px;
  letter-spacing: -0.03em;
}

.railcam-stage-pill,
.railcam-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.railcam-stage-pill {
  color: #7dd3fc;
  background: rgba(14, 165, 233, 0.12);
  border: 1px solid rgba(14, 165, 233, 0.28);
}

.railcam-badge--free {
  color: #86efac;
  background: rgba(34, 197, 94, 0.14);
  border: 1px solid rgba(34, 197, 94, 0.28);
}

.railcam-player-frame,
.railcam-player-empty {
  border-radius: 16px;
  border: 1px solid var(--border-hi);
  overflow: hidden;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 40%),
    linear-gradient(160deg, rgba(13, 13, 14, 0.92), rgba(7, 12, 24, 0.98));
}

.railcam-player-frame {
  aspect-ratio: 16 / 9;
  position: relative;
}

.railcam-player-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  pointer-events: none;
}

.railcam-player-frame.interactive iframe,
.railcam-floating-player-frame.interactive iframe {
  pointer-events: auto;
}

.railcam-player-shield {
  position: absolute;
  inset: 0;
  z-index: 2;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.railcam-player-empty {
  min-height: 360px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 26px;
  gap: 8px;
}

.railcam-player-empty strong {
  display: block;
  font-size: 18px;
}

.railcam-player-empty span {
  color: var(--muted);
  font-size: 14px;
  max-width: 320px;
}

.railcam-meta {
  margin-top: 14px;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-lo);
}

.railcam-meta-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.railcam-kicker {
  display: inline-block;
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.railcam-meta h4 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.railcam-meta p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

.railcam-meta-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.railcam-meta-grid div {
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.railcam-meta-grid span {
  display: block;
  color: var(--dim);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 6px;
}

.railcam-meta-grid strong {
  display: block;
  font-size: 13px;
  line-height: 1.45;
}

.railcam-meta-actions {
  display: flex;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

.railcam-browser {
  padding: 16px;
  overflow: hidden;
}

.railcam-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-bottom: 12px;
}

.railcam-controls input,
.railcam-controls select {
  background: var(--surface-lo);
  border: 1px solid var(--border-hi);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--text);
  outline: none;
}

.railcam-controls input:focus,
.railcam-controls select:focus {
  border-color: var(--accent);
}

.railcam-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(66vh, 720px);
  overflow-y: auto;
  padding-right: 4px;
}

.railcam-group h4 {
  font-size: 10px;
  font-weight: 800;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 6px 0 8px;
}

.railcam-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface-lo);
  transition: border-color 0.16s var(--ease), transform 0.16s var(--ease), box-shadow 0.16s var(--ease);
}

.railcam-card.active {
  border-color: rgba(250, 204, 21, 0.5);
  box-shadow: 0 0 0 1px rgba(250, 204, 21, 0.18);
}

.railcam-card:hover {
  transform: translateY(-1px);
  border-color: var(--accent);
}

.railcam-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
}

.railcam-card-copy strong {
  display: block;
  font-size: 14px;
  font-weight: 800;
}

.railcam-card-sub {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.railcam-card-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.railcam-card-btn,
.railcam-external-link {
  min-width: 72px;
  justify-content: center;
}

.railcam-empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.railcam-map-marker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(250, 204, 21, 0.46);
  background: rgba(12, 16, 26, 0.94);
  color: #f8fafc;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.34);
  cursor: pointer;
}

.railcam-map-marker.active {
  border-color: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.16), 0 10px 28px rgba(0, 0, 0, 0.34);
}

.railcam-map-marker-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: linear-gradient(180deg, #facc15, #f59e0b);
  box-shadow: 0 0 0 3px rgba(250, 204, 21, 0.2);
}

.railcam-map-marker-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: #facc15;
}

.railcam-choice-popup {
  display: grid;
  gap: 10px;
  min-width: 220px;
}

.railcam-choice-popup-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.railcam-choice-popup-list {
  display: grid;
  gap: 8px;
}

.railcam-choice-popup-item {
  border: 1px solid var(--border-hi);
  background: rgba(255, 255, 255, 0.04);
  border-radius: 10px;
  color: var(--text);
  padding: 9px 10px;
  text-align: left;
  cursor: pointer;
  display: grid;
  gap: 2px;
}

.railcam-choice-popup-item strong {
  font-size: 13px;
  line-height: 1.2;
}

.railcam-choice-popup-item span {
  font-size: 11px;
  color: var(--muted);
}

.railcam-choice-popup-item:hover {
  border-color: rgba(250, 204, 21, 0.65);
  background: rgba(250, 204, 21, 0.12);
}

.railcam-floating-window {
  position: fixed;
  top: 86px;
  left: calc(100vw - 460px);
  width: min(420px, calc(100vw - 24px));
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0.01)), var(--surface-hi);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  z-index: 215;
  display: none;
}

.railcam-window-host {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 215;
}

.railcam-window-host .railcam-floating-window {
  pointer-events: auto;
}

.railcam-floating-window.active {
  display: block;
}

.railcam-floating-window-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  cursor: grab;
  user-select: none;
}

.railcam-floating-window-head:active {
  cursor: grabbing;
}

.railcam-floating-window-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.railcam-floating-window-copy strong {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.railcam-floating-window-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.railcam-floating-window-action,
.railcam-floating-window-close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(11, 14, 20, 0.92);
  color: #f8fafc;
  font-size: 26px;
  line-height: 1;
  padding: 0 0 2px;
  cursor: pointer;
}

.railcam-floating-window-action {
  font-size: 17px;
  font-weight: 900;
  padding: 0;
}

.railcam-floating-window-body {
  padding: 0 14px 14px;
}

.railcam-floating-player-frame {
  aspect-ratio: 16 / 9;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--border-hi);
  background: #000;
  position: relative;
}

.railcam-floating-player-frame iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  pointer-events: none;
}

.railcam-floating-player-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.railcam-floating-player-meta a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.release-content {
  width: min(560px, calc(100vw - 24px));
}

.tool-help-content {
  width: min(680px, calc(100vw - 24px));
}

.tool-help-shell {
  display: grid;
  gap: 16px;
}

.tool-help-shell h3 {
  margin: 0;
  font-size: clamp(24px, 3vw, 32px);
  line-height: 1.1;
}

.tool-help-shell p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.tool-help-block {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
}

.tool-help-block h4 {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.tool-help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.tool-help-grid div {
  display: grid;
  gap: 2px;
}

.tool-help-grid strong {
  font-size: 13px;
  color: var(--text);
}

.tool-help-grid span {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

.marker-legend-grid {
  display: grid;
  gap: 10px;
}

.marker-legend-item {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
}

.marker-legend-item strong {
  display: block;
  font-size: 13px;
}

.marker-legend-item span {
  font-size: 12px;
  color: var(--muted);
}

.marker-legend-pill {
  min-width: 52px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 0.28);
  color: #fff;
}

.marker-legend-pill--line {
  background: #2563eb;
}

.marker-legend-pill--delay {
  background: #f97316;
}

.marker-legend-pill--cam {
  background: rgba(12, 16, 26, 0.94);
  color: #facc15;
  border-color: rgba(250, 204, 21, 0.46);
}

.marker-legend-pill--green {
  background: #22c55e;
}

.marker-legend-pill--yellow {
  background: #facc15;
  color: #1f2937;
}

.marker-legend-pill--orange {
  background: #fb923c;
}

.marker-legend-pill--red {
  background: #ef4444;
}

.marker-legend-pill--gray {
  background: #6b7280;
}

.marker-legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
}

.marker-legend-dot--alert {
  background: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.25);
}

.tool-help-block--important ul {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.tool-help-block--important li {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.tool-help-block--important strong {
  color: var(--text);
}

@media (max-width: 720px) {
  .tool-help-grid {
    grid-template-columns: 1fr;
  }
}

.simple-info-popup__actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.simple-info-popup__actions .btn-secondary {
  flex: 1;
}

.simple-info-popup__track-btn.active,
.train-popup-track-btn.active,
#btn-track-train.active {
  background: rgba(34, 197, 94, 0.18);
  border-color: rgba(34, 197, 94, 0.45);
  color: #dcfce7;
}

.release-shell {
  display: grid;
  gap: 18px;
}

.release-kicker {
  display: inline-flex;
  width: fit-content;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(255, 215, 0, 0.12);
  border: 1px solid rgba(255, 215, 0, 0.18);
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.release-shell h3 {
  margin: 0;
  font-size: clamp(28px, 4vw, 36px);
  line-height: 1.05;
}

.release-shell p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

#release-updated-at {
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.02em;
}

.release-spotlight {
  display: grid;
}

.release-spotlight-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 10px;
  border-left: 4px solid rgba(250, 204, 21, 0.78);
  border-top: 1px solid rgba(250, 204, 21, 0.2);
  border-right: 1px solid rgba(250, 204, 21, 0.2);
  border-bottom: 1px solid rgba(250, 204, 21, 0.2);
  background: rgba(34, 24, 8, 0.6);
  box-shadow: none;
}

.release-spotlight-kicker {
  display: inline-flex;
  width: fit-content;
  padding: 2px 0;
  border-radius: 0;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #ffe08a;
  border: none;
  background: transparent;
}

.release-spotlight-card strong {
  font-size: 17px;
  line-height: 1.2;
  color: #fff8de;
}

.release-spotlight-card p {
  font-size: 13px;
  line-height: 1.55;
  color: #fff1cf;
}

.release-notes-log {
  display: grid;
  gap: 14px;
}

.release-note-section {
  padding: 12px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.release-note-section:first-child {
  border-top: none;
  padding-top: 0;
}

.release-note-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.release-note-section ul {
  margin: 0;
  padding: 0 0 0 18px;
  display: grid;
  gap: 7px;
}

.release-note-section li {
  margin: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.55;
}

.release-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.release-grid div {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
}

.release-grid span {
  display: block;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.release-grid strong {
  display: block;
  font-size: 14px;
  line-height: 1.45;
}

.release-thanks {
  border-radius: 16px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  padding: 16px;
  background: rgba(14, 20, 33, 0.67);
  display: grid;
  gap: 10px;
  text-align: left;
}

.release-thanks strong {
  font-size: 13px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.release-thanks p {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  line-height: 1.4;
}

.release-metra-logo {
  width: 100px;
  height: auto;
  margin-top: 2px;
  align-self: flex-start;
}

.release-btn {
  justify-self: start;
}

.release-donate {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 212, 77, 0.22);
  background: linear-gradient(180deg, rgba(255, 212, 77, 0.1), rgba(255, 188, 0, 0.05));
  border-radius: 12px;
}

.release-donate-kicker {
  display: block;
  font-size: 11px;
  color: #ffd84d;
  font-weight: 900;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.release-donate-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.release-donate-btn {
  min-width: 150px;
}

.release-start-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 148px;
  padding: 7px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease);
}

.release-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-lg);
  background: rgba(255, 255, 255, 0.1);
}

.release-thanks {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  border-radius: 12px;
}

.release-thanks-kicker {
  display: block;
  font-size: 11px;
  color: var(--muted);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.release-thanks-logo {
  display: block;
  width: min(180px, 100%);
  height: auto;
  max-height: 88px;
  object-fit: contain;
}

.release-thanks-copy {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--muted);
}

@media (max-width: 980px) {
  .railcam-shell {
    grid-template-columns: 1fr;
  }

  .railcam-content {
    width: min(100vw - 24px, 760px);
  }

  .railcam-player-empty {
    min-height: 240px;
  }

  .railcam-floating-window {
    width: min(420px, calc(100vw - 16px));
  }

  .release-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .railcam-content {
    width: calc(100vw - 12px);
  }

  .railcam-stage,
  .railcam-browser {
    padding: 14px;
    border-radius: 16px;
  }

  .railcam-card {
    grid-template-columns: 1fr;
  }

  .railcam-card-actions,
  .railcam-meta-actions {
    width: 100%;
  }

  .railcam-card-btn,
  .railcam-external-link,
  .railcam-meta-actions .btn-secondary {
    flex: 1;
  }

  .railcam-meta-grid {
    grid-template-columns: 1fr;
  }

  .railcam-floating-window {
    left: 8px !important;
    right: 8px;
    width: auto;
    top: auto !important;
    bottom: 8px;
  }

  .railcam-floating-player-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .release-content {
    width: calc(100vw - 12px);
  }
}

/* ── Settings ─────────────────────────────────────────────────── */
.settings-content h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 14px;
  padding-right: 30px;
  letter-spacing: -0.01em;
}

.settings-grid {
  display: flex;
  flex-direction: column;
}

.settings-section-label {
  margin-top: 14px;
  padding: 10px 0 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
}

.settings-grid .settings-section-label:first-child {
  margin-top: 0;
  padding-top: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.settings-title {
  font-size: 13px;
  font-weight: 600;
}

.settings-row select {
  background: var(--surface-lo);
  border: 1px solid var(--border-hi);
  border-radius: 5px;
  padding: 5px 8px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.settings-row select:focus {
  border-color: var(--accent);
}

.settings-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--accent);
}

.settings-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.settings-row input[type="text"],
.settings-row textarea,
.settings-row input[type="file"] {
  background: var(--surface-lo);
  border: 1px solid var(--border-hi);
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  width: 58%;
}

.settings-row textarea {
  resize: vertical;
  min-height: 64px;
}


.sighting-content h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 14px;
  padding-right: 30px;
  letter-spacing: -0.01em;
}

/* ── ORT 2.0 Shell Overrides ───────────────────────────────── */
.topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: calc(var(--topbar-height, 68px) + var(--safe-top));
  padding: calc(14px + var(--safe-top)) 18px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border);
  z-index: 70;
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.topbar-brand-name {
  color: var(--text);
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  font-weight: 800;
  letter-spacing: -0.04em;
}

.topbar-brand-version {
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.account-toggle {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
}

.account-toggle-avatar,
.account-placeholder-icon {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, var(--surface-hi), var(--surface));
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 800;
}

.sidebar,
.account-sidebar {
  inset: calc(var(--topbar-height, 68px) + var(--safe-top)) auto var(--panel-gap) var(--panel-gap);
  width: min(var(--sidebar-width, 460px), calc(100% - (var(--panel-gap) * 2)));
  max-width: none;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 18px 18px;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  box-shadow: var(--shadow-lg);
}

.account-sidebar {
  position: absolute;
  right: 0;
  left: auto;
  width: min(var(--account-drawer-width, 460px), calc(100% - (var(--panel-gap) * 2)));
  display: flex;
  flex-direction: column;
  z-index: 55;
  transform: translateX(calc(100% + 18px));
  transition: transform 0.28s var(--ease);
}

.account-sidebar.account-sidebar-open {
  transform: translateX(0);
}

.account-sidebar-header,
.sidebar-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.brand h1 {
  font-size: 1rem;
  letter-spacing: -0.03em;
}

.brand-description {
  max-width: 250px;
  margin: 4px 0 0;
  color: var(--muted);
}

.account-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px;
}

.account-sidebar-kicker {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 5px;
}

.account-sidebar-header h2 {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.account-sidebar-body {
  padding: 18px;
  overflow: auto;
}

.account-placeholder {
  min-height: 220px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 12px;
  padding: 22px;
}

.account-placeholder h3 {
  font-size: 1rem;
  font-weight: 800;
}

.account-placeholder p {
  color: var(--muted);
  line-height: 1.55;
}

.drawer-toggle {
  position: absolute;
  top: calc(var(--topbar-height, 68px) + 8px + var(--safe-top));
  left: calc(var(--drawer-handle-left, 12px) + var(--safe-left));
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  z-index: 65;
  box-shadow: var(--shadow);
  transition: left 0.28s var(--ease), transform 0.2s var(--ease), background 0.2s var(--ease);
}

.drawer-toggle:hover {
  transform: translateY(1px);
  background: var(--surface-hi);
}

.drawer-toggle-icon {
  font-size: 1rem;
  font-weight: 800;
}

.map-pane {
  width: 100%;
  height: 100%;
  padding-top: 0;
}

.map {
  height: 100%;
  min-height: 100%;
}

.map-corner-brand {
  display: none;
}

.floating-search,
.quick-strip,
.filter-panel,
.support-strip {
  background: var(--surface);
}

.quick-look-board {
  display: grid;
  gap: 12px;
  padding: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--surface-lo);
  max-height: min(56vh, 820px);
  overflow-y: auto;
}

body.compact-cards .train-list-wrap {
  display: none;
}

body:not(.compact-cards) .quick-look-board {
  display: none;
}

.quick-look-card {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-hi);
  padding: 18px 18px 16px;
  color: var(--text);
}

.quick-look-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.quick-look-card-head h3 {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.quick-look-card-head h3 span {
  color: var(--accent);
}

.quick-look-card-head p {
  color: var(--muted);
  font-size: 0.92rem;
}

.quick-look-primary {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 14px;
}

.quick-look-primary strong {
  font-size: 3rem;
  line-height: 0.95;
  font-weight: 800;
}

.quick-look-primary span {
  font-size: 1rem;
  color: var(--text);
}

.quick-look-breakdown {
  display: grid;
  gap: 10px;
}

.quick-look-breakdown div {
  display: grid;
  grid-template-columns: 52px 18px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
}

.quick-look-breakdown strong {
  font-size: 1.7rem;
  text-align: right;
}

.quick-look-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  display: inline-block;
}

.quick-look-dot.on-time { background: #18d25d; }
.quick-look-dot.late { background: #ffc21d; }
.quick-look-dot.very-late { background: #ff4b00; }
.quick-look-dot.extreme { background: #4a4a4a; }

.train-list-wrap {
  background: var(--sidebar-bg);
}

.list-header {
  padding: 14px 16px 8px;
}

.list-header h2 {
  font-size: 0.76rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.train-list {
  padding: 10px 12px 14px;
  gap: 10px;
}

.train-card {
  border-radius: 16px;
  border: 1px solid var(--border);
  padding: 12px;
  background: var(--surface);
  box-shadow: none;
}

.train-card:hover {
  transform: translateY(-1px);
  background: var(--surface-hi);
  box-shadow: var(--shadow);
}

.train-card-id {
  border-radius: 12px;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.train-kpis {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.kpi {
  border-radius: 12px;
  background: var(--surface-lo);
  border: 1px solid var(--border);
  padding: 8px 10px;
}

.kpi strong {
  font-size: 0.92rem;
}

.map-btn,
.tool-btn {
  border-radius: 12px;
}

.map-btn {
  background: var(--surface);
  border-color: var(--border);
}

.detail-modal {
  background: rgba(0, 0, 0, 0.62);
}

.modal-content,
.settings-content,
.railcam-content,
.service-alert-content,
.credits-content,
.cluster-content,
.departure-board-content,
.sighting-content,
.release-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
}

.settings-content {
  max-width: 720px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 18px;
}

.settings-section-label {
  grid-column: 1 / -1;
  margin-top: 8px;
}

.settings-row {
  min-height: 56px;
}

.settings-row select,
.settings-row input[type="text"],
.settings-row textarea,
.settings-row input[type="file"] {
  border-radius: 10px;
  background: var(--surface-lo);
}

@media (max-width: 1024px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  .topbar {
    padding-inline: 12px;
  }

  .topbar-brand {
    gap: 8px;
  }

  .topbar-brand-version {
    font-size: 0.68rem;
  }

  .sidebar,
  .account-sidebar {
    bottom: 8px;
  }

  .drawer-toggle {
    top: calc(var(--topbar-height, 60px) + 8px + var(--safe-top));
    width: 36px;
    height: 36px;
  }

  .sidebar {
    border-radius: 0 0 18px 18px;
  }

  .quick-look-card {
    padding: 15px;
  }

  .quick-look-card-head h3 {
    font-size: 1.15rem;
  }

  .quick-look-primary strong {
    font-size: 2.35rem;
  }

  .quick-look-breakdown strong {
    font-size: 1.25rem;
  }

  .train-list {
    padding-bottom: 28px;
  }

  .train-card,
  .quick-look-card,
  .map-btn,
  .tool-btn,
  .drawer-toggle,
  .modal-content {
    box-shadow: none;
  }
}

.topbar-brand-version,
.settings-section-label,
.list-header h2 {
  color: color-mix(in srgb, var(--accent) 72%, var(--text) 28%);
}

.sighting-form .settings-actions {
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.sighting-status {
  min-height: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

.sighting-marker {
  width: 26px;
  height: 26px;
  position: relative;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.03em;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.8);
  user-select: none;
  -webkit-user-select: none;
}

.sighting-marker.company-marker {
  width: 64px;
  min-width: 64px;
  max-width: 64px;
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.sighting-company-label {
  display: inline-block;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  max-width: 100%;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
}

.sighting-corner-tag {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 13px;
  height: 13px;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 900;
  background: #111827;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.sighting-marker.heritage {
  background: #f59e0b;
  border-color: #d97706;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.sighting-marker.special-interest {
  background: #3b82f6;
  border-color: #2563eb;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

.sighting-marker.defect-detector {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #ef4444;
  border-color: #b91c1c;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

.bigboy-marker {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 86px;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: linear-gradient(135deg, #facc15, #f59e0b);
  color: #111827;
  font-weight: 900;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.bigboy-marker__label {
  font-size: 12px;
  line-height: 1;
}

.bigboy-popup {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bigboy-popup__title {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
}

.bigboy-popup__id {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}

.bigboy-popup__meta {
  font-size: 12px;
  color: var(--text-dim);
}

.bigboy-popup__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.bigboy-popup__grid div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.bigboy-popup__grid span {
  color: var(--text-dim);
}

.bigboy-popup__grid strong {
  color: var(--text);
  font-weight: 700;
  text-align: right;
}

.sighting-media {
  width: 100%;
  max-width: 260px;
  border-radius: 6px;
  border: 1px solid var(--border-hi);
  margin-top: 6px;
}

/* Sighting Popup Styles */
.sighting-popup-content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.sighting-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sighting-type-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: #f59e0b;
  color: #111;
  width: fit-content;
}

.sighting-type-badge.special-interest {
  background: #3b82f6;
  color: #fff;
}

.sighting-type-badge.defect-detector {
  background: #ef4444;
  color: #fff;
}

.sighting-train {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.4;
}

.sighting-uploader {
  font-size: 11px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sighting-uploader::before {
  content: "👤";
  font-size: 12px;
}

.sighting-location {
  font-size: 11px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}

.sighting-location::before {
  content: "📍";
  font-size: 12px;
}

.sighting-media-container {
  margin-top: 8px;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.sighting-media-container video,
.sighting-media-container img {
  max-width: 100%;
  max-height: 300px;
  display: block;
  margin: 0 auto;
}

.sighting-media-empty {
  padding: 10px 12px;
  font-size: 12px;
  color: var(--dim);
}

.sighting-notes {
  font-size: 12px;
  color: var(--text);
  line-height: 1.5;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
}

.sighting-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 10px;
  color: var(--dim);
}

.sighting-id::before {
  content: "ID: ";
}

.sighting-time::before {
  content: "• ";
}

.btn-primary {
  padding: 8px 18px;
  border-radius: 5px;
  background: var(--accent);
  color: #111;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: opacity 0.12s var(--ease);
}

.btn-primary:hover {
  opacity: 0.85;
}

/* ── Departure Board  ——  flip-board style ─────────────────── */
.departure-board-content h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 12px;
  padding-right: 30px;
  letter-spacing: -0.01em;
}

.board-filters {
  margin-bottom: 8px;
}

.board-filters select {
  background: var(--surface-lo);
  border: 1px solid var(--border-hi);
  border-radius: 5px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  cursor: pointer;
}

.board-filters select:focus {
  border-color: var(--accent);
}

.departure-board-grid {
  display: grid;
  grid-template-columns: 68px 68px 1fr 74px 1fr 80px 46px;
  gap: 5px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  align-items: center;
}

.departure-board-header span {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}

.departure-board-row span {
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

/* Live rows get the MTA green left stripe */
.departure-board-row.live {
  border-left: 3px solid var(--green);
  padding-left: 5px;
}

.departure-board-empty {
  padding: 16px 0;
  color: var(--muted);
  font-size: 13px;
}

.flip-cell {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── MapLibre Overrides ───────────────────────────────────────── */
.maplibregl-popup-content {
  background: var(--surface) !important;
  border: 1px solid var(--border) !important;
  color: var(--text) !important;
  border-radius: 18px !important;
  padding: 16px 16px 14px !important;
  font-size: 12px !important;
  box-shadow: var(--shadow) !important;
  position: relative !important;
  overflow: hidden !important;
}

.maplibregl-popup-content,
.maplibregl-popup-content p,
.maplibregl-popup-content span,
.maplibregl-popup-content div,
.maplibregl-popup-content strong,
.maplibregl-popup-content small,
.maplibregl-popup-content li,
.maplibregl-popup-content button {
  color: var(--text) !important;
}

.train-map-popup .maplibregl-popup-content {
  background: var(--surface) !important;
  border-color: var(--border) !important;
}

.train-map-popup .maplibregl-popup-content::before {
  display: none;
}

.maplibregl-popup-close-button {
  position: absolute !important;
  top: 12px !important;
  right: 12px !important;
  left: auto !important;
  width: 34px !important;
  height: 34px !important;
  border-radius: 999px !important;
  border: 1px solid rgba(255, 255, 255, 0.12) !important;
  background: var(--surface-hi) !important;
  color: var(--text) !important;
  font-size: 28px !important;
  line-height: 28px !important;
  padding: 0 0 2px !important;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease !important;
}

.maplibregl-popup-close-button:hover {
  background: var(--surface) !important;
  border-color: var(--border-hi) !important;
  transform: scale(1.04) !important;
}

.maplibregl-popup-tip {
  border-top-color: var(--surface) !important;
}

.maplibregl-popup-content>* {
  position: relative;
  z-index: 1;
}

.simple-info-popup {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 230px;
}

.simple-info-popup__title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
}

.simple-info-popup__id {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.simple-info-popup__meta,
.simple-info-popup__updated {
  font-size: 12px;
  color: var(--text-dim);
}

.simple-info-popup__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
}

.simple-info-popup__grid div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
}

.simple-info-popup__grid span {
  color: var(--text-dim);
}

.simple-info-popup__grid strong {
  color: var(--text);
  text-align: right;
}

.maplibregl-ctrl-group {
  border-radius: 6px !important;
  overflow: hidden;
  box-shadow: var(--shadow) !important;
  background: rgba(10, 10, 10, 0.88) !important;
  border: 1px solid var(--border-hi) !important;
}

.maplibregl-ctrl-group button {
  background: transparent !important;
  border-color: var(--border-hi) !important;
  filter: invert(1);
}

.maplibregl-marker {
  transition: none !important;
  will-change: auto;
}

/* ================================================================
   HEADING ARROW  —  directional indicator on live train markers
   ================================================================ */
.heading-arrow {
  position: absolute;
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 7px solid rgba(255, 255, 255, 0.94);
  top: -8px;
  left: 50%;
  margin-left: -3px;
  transform-origin: 3px 17px;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55));
}

/* ================================================================
   LOCATION DOT  —  "locate me" blue pulsing marker
   ================================================================ */
.location-dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #3b82f6;
  border: 3px solid #fff;
  box-shadow: 0 0 0 5px rgba(59, 130, 246, 0.35), 0 6px 18px rgba(0, 0, 0, 0.35);
  animation: location-pulse 2s ease-in-out infinite;
  position: relative;
}

.location-dot::after {
  content: "YOU";
  position: absolute;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(10, 10, 10, 0.92);
  border: 1px solid rgba(59, 130, 246, 0.5);
  color: #dbeafe;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}



@keyframes location-pulse {

  0%,
  100% {
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.35);
  }

  50% {
    box-shadow: 0 0 0 14px rgba(59, 130, 246, 0), 0 6px 18px rgba(0, 0, 0, 0.35);
  }
}

/* ================================================================
   ROUTE HOVER POPUP
   ================================================================ */
.route-popup-inner {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.route-popup-inner strong {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.route-popup-inner span {
  font-size: 11px;
  color: var(--text-dim);
}

/* ================================================================
   SCALE BAR
   ================================================================ */
.maplibregl-ctrl-scale {
  background: rgba(10, 10, 10, 0.82) !important;
  border: 1px solid var(--border-hi) !important;
  border-top: none !important;
  color: var(--text) !important;
  font-size: 10px !important;
  padding: 2px 6px !important;
  border-radius: 0 0 4px 4px !important;
}

/* ── Delay Detail Modal ────────────────────────────────────────── */
.dq-detail-modal {
  align-items: center;
}

.dq-detail-content {
  border-radius: 14px;
  max-width: 480px;
  padding-bottom: 24px;
}

.dq-detail-content::before {
  background: #ee352e;
}

.dq-detail-hero {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.dq-detail-bullet {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 900;
  color: #fff;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.dq-detail-heading {
  flex: 1;
  min-width: 0;
}

.dq-detail-heading h3 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.015em;
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dq-detail-heading p {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dq-detail-badge {
  flex-shrink: 0;
  font-size: 13px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: 0.02em;
}

.dq-detail-section {
  margin-bottom: 14px;
}

.dq-detail-section-title {
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--dim);
  margin-bottom: 8px;
}

.dq-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.dq-tl-row {
  display: grid;
  grid-template-columns: 80px 1fr 90px 90px;
  gap: 6px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 12px;
}

.dq-tl-row:last-child {
  border-bottom: none;
}

.dq-tl-label {
  color: var(--muted);
  font-size: 11px;
}

.dq-tl-stop {
  font-weight: 600;
}

.dq-tl-sched {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.dq-tl-actual {
  font-weight: 700;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.dq-tl-actual.late {
  color: #ee352e;
}

.dq-tl-actual.early {
  color: #4ade80;
}

.dq-tl-actual.ontime {
  color: #4ade80;
}

.dq-reason-box {
  background: rgba(238, 53, 46, 0.10);
  border: 1px solid rgba(238, 53, 46, 0.25);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text);
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.dq-reason-box svg {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  margin-top: 1px;
  color: #ee352e;
}

.dq-reason-box.no-reason {
  background: rgba(150, 150, 150, 0.07);
  border-color: rgba(150, 150, 150, 0.15);
  color: var(--dim);
}

.dq-reason-box.no-reason svg {
  color: var(--dim);
}

.dq-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.dq-kpi {
  background: var(--surface-lo);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.dq-kpi span {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--dim);
}

.dq-kpi strong {
  font-size: 13px;
  font-weight: 700;
}

.dq-detail-actions {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.dq-detail-actions .btn-primary {
  flex: 1;
  padding: 10px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: #111;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}

.dq-detail-actions .btn-primary:hover {
  opacity: 0.85;
}

.dq-detail-actions .btn-secondary {
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-hi);
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.dq-detail-actions .btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

body.light .dq-tl-row {
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

body.light .dq-reason-box {
  background: rgba(238, 53, 46, 0.06);
}

body.light .dq-reason-box.no-reason {
  background: rgba(0, 0, 0, 0.04);
}

/* ================================================================
   SIDEBAR TOGGLE / FLOATING LIST
   ================================================================ */
.floating-list {
  position: relative;
  transition: opacity 0.2s ease;
  overflow: hidden;
  flex: 1;
  min-height: 0;
}

.floating-list.open {
  height: auto;
  border-top: 1px solid var(--border);
  opacity: 1;
}

.floating-list:not(.open) {
  height: auto;
  border-top: 1px solid var(--border);
  opacity: 1;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
}

.list-header h2 {
  font-size: 11px;
  font-weight: 800;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0;
}

/* ================================================================
   MOBILE  ≤ 768px
   ================================================================ */
@media (max-width: 768px) {
  .app {
    flex-direction: row;
  }

  .map-pane {
    flex: 1;
    min-height: 100vh;
  }

  .sidebar {
    top: calc(var(--topbar-height, 60px) + var(--safe-top));
    bottom: calc(var(--safe-bottom) + 8px);
    height: auto;
    max-width: calc(100% - 16px);
    max-height: calc(100dvh - var(--topbar-height, 60px) - var(--safe-top) - var(--safe-bottom) - 8px);
    border-radius: 0 0 18px 18px;
  }

  .sidebar[data-dock="bottom"] {
    width: calc(100% - 16px);
    bottom: calc(8px + var(--safe-bottom));
    height: min(62vh, 560px);
    border-radius: 22px 22px 0 0;
  }

  .sidebar-header {
    padding: 10px 12px 8px;
    border-bottom-width: 2px;
  }

  .brand h1 {
    font-size: 13px;
  }

  .count-badge {
    font-size: 9px;
  }

  .map-actions {
    gap: 4px;
  }

  .map-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .maplibregl-ctrl-bottom-right {
    right: calc(10px + var(--safe-right));
    bottom: calc(82px + var(--safe-bottom));
  }

  .map-corner-brand {
    top: calc(12px + var(--safe-top));
    right: calc(12px + var(--safe-right));
    gap: 6px;
    font-size: 14px;
  }

  .status-pill {
    right: calc(8px + var(--safe-right));
    bottom: calc(8px + var(--safe-bottom));
    font-size: 9px;
    padding: 4px 9px;
  }

  .support-strip {
    padding: 6px 10px;
  }

  .donate-btn {
    padding: 6px 10px;
    font-size: 10px;
  }

  .contrib-pill {
    display: none;
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .train-detail .detail-grid {
    grid-template-columns: 1fr;
  }

  .detail-actions-row {
    grid-template-columns: 1fr;
  }

  .train-detail .detail-actions-row {
    grid-template-columns: 1fr;
  }

  .detail-summary-grid {
    grid-template-columns: 1fr 1fr;
  }

  .modal-content {
    padding: 22px 18px 18px;
    max-height: 84vh;
    border-radius: 24px 24px 0 0;
    border-bottom: none;
  }

  #detail-modal {
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: transparent;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    pointer-events: none;
  }

  #detail-modal .modal-content {
    width: 100%;
    max-width: 100%;
    height: min(86dvh, 780px);
    max-height: min(86dvh, 780px);
    margin: 0;
    padding: 10px 14px 14px;
    border-radius: 22px 22px 0 0;
    border-bottom: none;
    transform: translateY(0);
    transition: transform 0.24s var(--ease), max-height 0.26s var(--ease), height 0.26s var(--ease);
    pointer-events: auto;
    background: var(--surface);
    border-top: 1px solid var(--border-hi);
    isolation: isolate;
  }

  #detail-modal .detail-summary-grid,
  #detail-modal .detail-sync-note,
  #detail-modal .technical-info-panel {
    display: none;
  }

  #detail-modal .detail-actions-row {
    margin-top: 4px;
    grid-template-columns: 1fr;
  }

  #detail-modal .detail-actions-row .btn-secondary {
    min-height: 48px;
    font-size: 15px;
  }

  #detail-modal .detail-head {
    border: none;
    border-radius: 0;
    padding: 0 38px 6px 0;
    background: transparent;
  }

  #detail-modal .detail-brand h3 {
    font-size: 24px;
    letter-spacing: -0.03em;
  }

  #detail-modal .train-stops-panel {
    border-radius: 12px;
    max-height: 54vh;
  }

  #detail-modal.active[data-sheet-state="expanded"] .modal-content {
    height: min(86dvh, 780px);
    max-height: min(86dvh, 780px);
    overflow-y: auto;
    transform: translateY(0);
  }

  #detail-modal.active[data-sheet-state="peek"] .modal-content {
    height: var(--detail-sheet-peek-height, clamp(208px, 31dvh, 290px));
    max-height: var(--detail-sheet-peek-height, clamp(208px, 31dvh, 290px));
    overflow: hidden;
    transform: translateY(2px);
  }

  #detail-modal.active[data-sheet-state="peek"] .train-card-alert,
  #detail-modal.active[data-sheet-state="peek"] .detail-primary-section,
  #detail-modal.active[data-sheet-state="peek"] .detail-sync-note,
  #detail-modal.active[data-sheet-state="peek"] .detail-actions-row {
    display: none;
  }

  #detail-modal .detail-sheet-grabber {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }

  .detail-modal {
    align-items: flex-end;
    padding: 8px;
  }

  #detail-modal .close-btn {
    width: 42px;
    height: 42px;
    top: 24px;
    right: 12px;
    z-index: 8;
    background: rgba(8, 12, 18, 0.96);
    border-color: rgba(255, 255, 255, 0.22);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  #detail-modal .detail-head {
    padding-right: 56px;
  }

  .train-detail {
    gap: 8px;
  }

  .train-detail .detail-head {
    padding: 12px 12px 10px;
    border-radius: 14px;
  }

  .train-detail .detail-tags {
    gap: 6px;
  }

  .train-detail .badge,
  .train-detail .status-indicator {
    padding: 4px 9px;
    font-size: 10px;
  }

  .train-detail .train-stops-panel {
    padding: 10px 10px 8px;
  }

  .detail-route-title {
    font-size: 12px;
  }

  .detail-route-endpoints {
    font-size: 11px;
  }

  .stop-time-col {
    min-width: 48px;
  }

  .stop-status-text {
    font-size: 10px;
  }

  .train-detail .stop-row {
    padding: 9px 0;
    gap: 10px;
  }

  .train-detail .stop-name {
    font-size: 13px;
  }

  .train-detail .stop-time,
  .train-detail .stop-eta {
    font-size: 12px;
  }

  .departure-board-grid {
    grid-template-columns: 60px 60px 1fr 1fr 70px 40px;
    font-size: 11px;
  }

  .train-map-popup .maplibregl-popup-content {
    padding: 14px 14px 12px !important;
    border-radius: 18px !important;
  }

  .train-map-popup .maplibregl-popup-content::before {
    left: 14px;
    right: 14px;
  }

  .train-popup-card {
    min-width: min(244px, calc(100vw - 88px));
    max-width: min(276px, calc(100vw - 88px));
    gap: 10px;
  }

  .train-popup-header {
    padding-right: 30px;
    padding-bottom: 10px;
  }

  .train-popup-header strong {
    font-size: 15px;
  }

  .train-popup-subhead {
    font-size: 10px;
  }

  .train-popup-highlights,
  .train-popup-grid {
    gap: 6px;
  }

  .train-popup-highlight,
  .train-popup-grid div {
    padding: 10px;
  }

  .train-popup-stops {
    gap: 8px;
  }

  .train-popup-stop-row {
    gap: 8px;
    padding: 8px 0;
  }
}

/* ================================================================
   TABLET  769 – 1024px
   ================================================================ */
@media (min-width: 769px) and (max-width: 1024px) {
  :root {
    --sidebar-w: 300px;
  }
}

/* ================================================================
   REDUCED MOTION
   ================================================================ */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
