:root {
  --ink: #11151c;
  --muted: #68707c;
  --panel: #ffffff;
  --soft: #f2f4f6;
  --line: #dfe3e8;
  --db-red: #ec0016;
}

* { box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: #11151c;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

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

.network-app {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #eef0f2;
}

.topbar {
  z-index: 20;
  height: 76px;
  flex: 0 0 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  color: white;
  background: #11151c;
  border-bottom: 1px solid #2f343d;
}

.brand { display: flex; align-items: center; gap: 15px; }

.db-mark {
  width: 48px;
  height: 33px;
  display: grid;
  place-items: center;
  color: var(--db-red);
  background: white;
  border: 3px solid var(--db-red);
  border-radius: 2px;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -2px;
}

.eyebrow {
  margin: 0 0 3px;
  color: #747d89;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.brand .eyebrow { color: #aeb5bf; }
.brand h1 { margin: 0; font-size: 19px; letter-spacing: -.02em; }

.topbar-actions { display: flex; align-items: center; gap: 17px; }
.network-status { display: flex; align-items: center; gap: 9px; color: #c4cad1; font-size: 12px; }
.status-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; box-shadow: 0 0 0 4px rgba(74,222,128,.12); }
.settings-trigger { height: 36px; display: flex; align-items: center; gap: 7px; padding: 0 12px; color: #edf0f4; background: #262c34; border: 1px solid #3b424d; border-radius: 9px; font-size: 11px; font-weight: 750; cursor: pointer; }
.settings-trigger:hover { background: #343b45; }

.workspace { min-height: 0; flex: 1; display: grid; grid-template-columns: 340px minmax(0, 1fr); }

.sidebar {
  z-index: 10;
  min-height: 0;
  padding: 24px 20px 26px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  scrollbar-width: thin;
}

.sidebar-heading { display: flex; align-items: flex-start; justify-content: space-between; padding: 0 5px 18px; }
.sidebar-heading h2 { margin: 0; font-size: 22px; letter-spacing: -.04em; }

.close-sidebar {
  display: none;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: var(--soft);
  font-size: 24px;
  cursor: pointer;
}

.route-list { display: grid; gap: 7px; }

.route-button {
  --route-color: #ec0016;
  width: 100%;
  display: grid;
  grid-template-columns: 42px 1fr 14px;
  align-items: center;
  gap: 11px;
  padding: 10px;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: 150ms ease;
}

.route-button:hover { background: #f6f7f8; }

.route-button:focus-visible, .map-toolbar button:focus-visible,
.station-list button:focus-visible, .service-chip:focus-visible,
.make-trip-button:focus-visible, .active-trip-card button:focus-visible,
.mobile-lines-button:focus-visible, .close-sidebar:focus-visible,
.settings-trigger:focus-visible, .settings-panel button:focus-visible,
.journey-option:focus-visible {
  outline: 3px solid rgba(0,92,184,.48);
  outline-offset: 2px;
}

.route-button.active { background: #f2f4f6; border-color: #e5e8eb; box-shadow: inset 3px 0 0 var(--route-color); }

.route-badge, .large-route-badge {
  display: grid;
  place-items: center;
  color: white;
  background: var(--route-color);
  border-radius: 8px;
  font-weight: 850;
  letter-spacing: -.02em;
}

.route-badge { width: 42px; height: 32px; font-size: 13px; }
.large-route-badge { width: 51px; height: 43px; flex: 0 0 51px; font-size: 17px; }
.route-button-copy { min-width: 0; display: grid; gap: 3px; }
.route-button-copy strong { overflow: hidden; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.route-button-copy small { color: var(--muted); font-size: 11px; }
.route-arrow { color: #8d949d; font-size: 20px; }

.detail-card { margin-top: 22px; padding: 21px; background: #f6f7f8; border: 1px solid #e6e9ec; border-radius: 16px; }
.detail-title-row { display: flex; align-items: center; gap: 13px; }
.detail-kicker { margin: 0 0 4px; color: #737b86; font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.detail-card h3 { margin: 0; font-size: 18px; line-height: 1.15; letter-spacing: -.03em; }
.detail-copy { margin: 17px 0; color: #59616c; font-size: 12px; line-height: 1.55; }

.route-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 18px; }
.route-stats div { padding: 11px 12px; background: white; border: 1px solid #e5e8eb; border-radius: 10px; }
.route-stats dt { color: #7c848e; font-size: 9px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; }
.route-stats dd { margin: 3px 0 0; font-size: 13px; font-weight: 800; }

.station-list { max-height: 225px; overflow-y: auto; border-top: 1px solid #dde1e5; }
.station-list button { width: 100%; display: grid; grid-template-columns: 17px 1fr 20px; align-items: center; gap: 7px; padding: 9px 1px; text-align: left; background: transparent; border: 0; border-bottom: 1px solid #e5e8eb; cursor: pointer; }
.station-list button:hover span:nth-child(2) { text-decoration: underline; }
.station-list button span:nth-child(2) { font-size: 11px; font-weight: 650; }
.station-list button small { color: #9299a2; font-size: 9px; }
.station-line-dot { width: 10px; height: 10px; margin-left: 2px; background: white; border: 3px solid; border-radius: 50%; }

.service-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.service-chip { min-width: 42px; padding: 7px 10px; color: white; border: 0; border-radius: 7px; font-size: 12px; font-weight: 850; cursor: pointer; }

.journey-card { margin-top: 22px; padding: 18px; background: #11151c; color: white; border-radius: 16px; }
.journey-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.journey-heading h3 { margin: 0; font-size: 17px; letter-spacing: -.03em; }
.journey-heading .detail-kicker { color: #9ca5b1; }
.swap-journey { width: 34px; height: 34px; color: white; background: #292f38; border: 1px solid #3b424d; border-radius: 9px; font-size: 18px; cursor: pointer; }
.journey-card label { display: grid; grid-template-columns: 37px 1fr; align-items: center; gap: 8px; margin-top: 8px; }
.journey-card label > span { color: #aeb5bf; font-size: 10px; font-weight: 750; text-transform: uppercase; }
.journey-card select { width: 100%; min-width: 0; height: 36px; padding: 0 31px 0 10px; color: white; background: #252b33; border: 1px solid #3a414b; border-radius: 8px; font-size: 11px; }
.journey-card select:focus-visible, .swap-journey:focus-visible { outline: 3px solid rgba(115,180,255,.55); outline-offset: 2px; }
.journey-options { display: grid; gap: 7px; margin-top: 14px; }
.journey-option { width: 100%; display: grid; grid-template-columns: 29px minmax(0,1fr) auto; align-items: center; gap: 9px; padding: 9px; color: white; text-align: left; background: #20262e; border: 1px solid #343b45; border-radius: 10px; cursor: pointer; transition: 140ms ease; }
.journey-option:hover { background: #292f38; border-color: #474f5a; }
.journey-option.selected { background: #302328; border-color: #8d3943; box-shadow: inset 3px 0 0 var(--db-red); }
.journey-option-icon { width: 29px; height: 29px; display: grid; place-items: center; color: #dce1e7; background: #353c46; border-radius: 8px; font-size: 12px; font-weight: 850; }
.journey-option.selected .journey-option-icon { color: white; background: var(--db-red); }
.journey-option-copy { min-width: 0; display: grid; gap: 2px; }
.journey-option-copy strong { font-size: 10px; }
.journey-option-copy small { overflow: hidden; color: #9fa7b2; font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.journey-option-stats { display: grid; justify-items: end; gap: 2px; }
.journey-option-stats strong { font-size: 11px; }
.journey-option-stats small { color: #9fa7b2; font-size: 8px; white-space: nowrap; }
.journey-summary { display: grid; grid-template-columns: repeat(3,1fr); gap: 6px; margin-top: 13px; }
.journey-summary div { display: grid; gap: 2px; padding: 9px 7px; background: #252b33; border-radius: 8px; }
.journey-summary strong { font-size: 14px; }
.journey-summary span { color: #9fa7b2; font-size: 8px; letter-spacing: .05em; text-transform: uppercase; }
.journey-legs { display: grid; gap: 9px; margin-top: 13px; padding-top: 13px; border-top: 1px solid #343b45; }
.journey-legs:empty { display: none; }
.journey-leg { display: grid; grid-template-columns: 34px 1fr; align-items: center; gap: 9px; }
.journey-leg > span { display: grid; place-items: center; width: 34px; height: 26px; color: white; border-radius: 6px; font-size: 10px; font-weight: 850; }
.journey-leg div { min-width: 0; display: grid; gap: 2px; }
.journey-leg strong { overflow: hidden; color: white; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.journey-leg small { color: #aeb5bf; font-size: 9px; }
.estimate-note { margin: 13px 0 0; color: #8f98a4; font-size: 8px; line-height: 1.4; }

.make-trip-button { width: 100%; height: 40px; display: flex; align-items: center; justify-content: center; gap: 9px; margin-top: 14px; color: #11151c; background: white; border: 0; border-radius: 9px; font-size: 11px; font-weight: 850; cursor: pointer; transition: transform 140ms ease, background 140ms ease; }
.make-trip-button:hover { background: #eef1f4; transform: translateY(-1px); }
.make-trip-button:active { transform: translateY(0); }
.make-trip-button:disabled { color: #7f8792; background: #303640; cursor: not-allowed; transform: none; }
.make-trip-button span { color: var(--db-red); font-size: 9px; }

.map-shell { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #20252c; }
.map-viewport { position: absolute; inset: 0; overflow: hidden; cursor: grab; touch-action: none; background: radial-gradient(circle at 50% 40%, #343b45 0, #262c34 50%, #1c2127 100%); }
.map-viewport:active { cursor: grabbing; }
.map-canvas { position: absolute; left: 0; top: 0; width: 859px; height: 861px; transform-origin: 0 0; user-select: none; will-change: transform; box-shadow: 0 18px 60px rgba(0,0,0,.5); }
.map-canvas img { display: block; pointer-events: none; }
.interaction-layer { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.route-hitbox { --route-color: #ec0016; fill: none; stroke: transparent; stroke-width: 24; stroke-linecap: round; stroke-linejoin: round; cursor: pointer; pointer-events: stroke; transition: stroke 120ms ease; }
.route-hitbox:hover, .route-hitbox:focus-visible { stroke: var(--route-hover); outline: none; }
.selected-route-glow { fill: none; stroke-width: 8; stroke-linecap: round; stroke-linejoin: round; opacity: .76; pointer-events: none; filter: drop-shadow(0 0 3px white) drop-shadow(0 0 5px var(--glow-color)); animation: route-pulse 1.8s ease-in-out infinite; }
@keyframes route-pulse { 0%,100% { opacity: .7; } 50% { opacity: 1; } }

.ambient-train { pointer-events: none; filter: drop-shadow(0 1px 2px rgba(0,0,0,.82)); }
.ambient-train circle { stroke: rgba(17,21,28,.75); stroke-width: 1.5; }
.journey-visual { pointer-events: none; }
.journey-route-outline, .journey-route-highlight { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.journey-route-outline { stroke: rgba(255,255,255,.96); stroke-width: 11; filter: drop-shadow(0 2px 4px rgba(0,0,0,.65)); }
.journey-route-highlight { stroke-width: 6; stroke-dasharray: 8 5; animation: journey-flow 850ms linear infinite; }
@keyframes journey-flow { to { stroke-dashoffset: -13; } }
.journey-train { filter: drop-shadow(0 2px 5px rgba(0,0,0,.85)); }
.journey-train-halo { fill: rgba(255,255,255,.7); stroke: rgba(255,255,255,.96); stroke-width: 1.5; animation: train-halo 1s ease-in-out infinite alternate; }
.journey-train-body { fill: var(--db-red); stroke: #fff; stroke-width: 2; }
.journey-train-window { fill: #fff; }
.journey-train-front { fill: var(--db-red); stroke: #fff; stroke-width: 1.8; stroke-linejoin: round; }
@keyframes train-halo { from { opacity: .45; } to { opacity: .9; } }

.station-target { cursor: pointer; outline: none; }
.station-hitbox { fill: transparent; }
.station-ring { fill: rgba(255,255,255,.18); stroke: transparent; stroke-width: 2; transition: 120ms ease; }
.station-target:hover .station-ring, .station-target:focus-visible .station-ring { fill: white; stroke: #10151c; r: 9; filter: drop-shadow(0 0 5px white); }

.map-toolbar { z-index: 5; position: absolute; top: 18px; right: 18px; display: flex; overflow: hidden; background: rgba(255,255,255,.96); border: 1px solid rgba(0,0,0,.14); border-radius: 10px; box-shadow: 0 5px 18px rgba(0,0,0,.24); }
.map-toolbar button { height: 38px; min-width: 40px; padding: 0 12px; background: transparent; border: 0; border-right: 1px solid #dfe3e6; font-size: 19px; font-weight: 700; cursor: pointer; }
.map-toolbar button:last-child { border-right: 0; }
.map-toolbar button:hover { background: #f0f2f4; }
.map-toolbar .fit-button { font-size: 11px; text-transform: uppercase; }
.map-toolbar .trains-button { min-width: 61px; color: #6b737d; font-size: 10px; text-transform: uppercase; }
.map-toolbar .trains-button.active { color: #11151c; background: #eef1f4; box-shadow: inset 0 -3px 0 var(--db-red); }

.active-trip-card { z-index: 6; position: absolute; top: 18px; left: 18px; max-width: min(480px,calc(100% - 300px)); min-height: 54px; display: grid; grid-template-columns: 34px minmax(0,1fr) auto 31px; align-items: center; gap: 10px; padding: 9px 10px; color: white; background: rgba(17,21,28,.92); border: 1px solid rgba(255,255,255,.16); border-radius: 13px; box-shadow: 0 8px 26px rgba(0,0,0,.35); backdrop-filter: blur(12px); }
.active-trip-card[hidden] { display: none; }
.active-trip-icon { width: 34px; height: 34px; display: grid; place-items: center; color: white; background: var(--db-red); border-radius: 9px; font-size: 11px; }
.active-trip-card > div { min-width: 0; display: grid; gap: 3px; }
.active-trip-card strong, .active-trip-card small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.active-trip-card strong { font-size: 11px; }
.active-trip-card small { color: #aeb5bf; font-size: 9px; }
.active-trip-card button { min-width: 31px; height: 31px; padding: 0 9px; color: white; background: #2a3039; border: 1px solid #3d444e; border-radius: 8px; font-size: 10px; font-weight: 750; cursor: pointer; }
.active-trip-card button:last-child { padding: 0; font-size: 18px; font-weight: 400; }
.active-trip-card button:hover { background: #383f49; }

.map-instructions { z-index: 5; position: absolute; left: 50%; bottom: 17px; display: flex; align-items: center; gap: 10px; padding: 9px 14px; color: #d5d9de; background: rgba(17,21,28,.84); border: 1px solid rgba(255,255,255,.12); border-radius: 999px; font-size: 10px; backdrop-filter: blur(10px); transform: translateX(-50%); white-space: nowrap; pointer-events: none; }
.map-instructions i { width: 3px; height: 3px; background: #8c949f; border-radius: 50%; }
.mobile-lines-button { display: none; }

.settings-backdrop { z-index: 90; position: fixed; inset: 0; background: rgba(8,11,15,.52); backdrop-filter: blur(3px); }
.settings-backdrop[hidden], .settings-panel[hidden] { display: none; }
.settings-panel { z-index: 100; position: fixed; top: 0; right: 0; width: min(390px,100%); height: 100%; padding: 26px; overflow-y: auto; color: var(--ink); background: white; border-left: 1px solid var(--line); box-shadow: -18px 0 60px rgba(0,0,0,.28); }
.settings-heading { display: flex; align-items: flex-start; justify-content: space-between; padding-bottom: 22px; border-bottom: 1px solid var(--line); }
.settings-heading h2 { margin: 0; font-size: 23px; letter-spacing: -.04em; }
.settings-heading button { width: 36px; height: 36px; background: var(--soft); border: 0; border-radius: 50%; font-size: 24px; cursor: pointer; }
.settings-list { display: grid; margin-top: 8px; }
.settings-toggle, .settings-select { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 18px; border-bottom: 1px solid #e8ebee; }
.settings-toggle > span, .settings-select > span { display: grid; gap: 4px; }
.settings-toggle strong, .settings-select strong { font-size: 13px; }
.settings-toggle small, .settings-select small { color: var(--muted); font-size: 10px; line-height: 1.35; }
.settings-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.settings-toggle i { position: relative; width: 42px; height: 24px; flex: 0 0 42px; background: #cbd0d6; border-radius: 999px; cursor: pointer; transition: 150ms ease; }
.settings-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: white; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.28); transition: 150ms ease; }
.settings-toggle input:checked + i { background: var(--db-red); }
.settings-toggle input:checked + i::after { transform: translateX(18px); }
.settings-toggle input:focus-visible + i { outline: 3px solid rgba(0,92,184,.4); outline-offset: 2px; }
.settings-select select { min-width: 110px; height: 36px; padding: 0 9px; color: var(--ink); background: var(--soft); border: 1px solid #dce0e4; border-radius: 8px; font-size: 11px; }
.settings-reset { width: 100%; height: 40px; margin-top: 22px; color: #4d5560; background: var(--soft); border: 1px solid #dfe3e7; border-radius: 9px; font-size: 11px; font-weight: 750; cursor: pointer; }
.settings-reset:hover { color: var(--db-red); background: #fff3f4; border-color: #efc8cc; }
.reduce-motion *, .reduce-motion *::before, .reduce-motion *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
.reduce-motion .ambient-train { display: none; }

@media (max-width: 760px) {
  .topbar { height: 64px; flex-basis: 64px; padding: 0 15px; }
  .db-mark { width: 40px; height: 28px; font-size: 17px; }
  .brand h1 { font-size: 15px; }
  .brand .eyebrow, .network-status { display: none; }
  .topbar-actions { gap: 0; }
  .settings-trigger { width: 38px; padding: 0; justify-content: center; }
  .settings-trigger span { font-size: 15px; }
  .settings-trigger { font-size: 0; }
  .workspace { display: block; position: relative; }
  .sidebar { position: absolute; inset: auto 10px 10px; z-index: 30; max-height: min(78vh,680px); max-height: min(78dvh,680px); border: 0; border-radius: 20px; box-shadow: 0 18px 60px rgba(0,0,0,.45); transform: translateY(calc(100% + 30px)); visibility: hidden; pointer-events: none; transition: transform 240ms ease, visibility 0s linear 240ms; }
  .sidebar.sidebar-open { transform: translateY(0); visibility: visible; pointer-events: auto; transition-delay: 0s; }
  .close-sidebar { display: grid; place-items: center; }
  .map-shell { width: 100%; height: 100%; }
  .map-toolbar { top: 12px; right: 12px; }
  .map-toolbar .trains-button { display: none; }
  .active-trip-card { top: 62px; left: 12px; right: 12px; max-width: none; grid-template-columns: 32px minmax(0,1fr) auto 31px; }
  .map-instructions { bottom: 71px; }
  .map-instructions span:nth-of-type(2), .map-instructions i:nth-of-type(2), .map-instructions span:nth-of-type(3) { display: none; }
  .mobile-lines-button { z-index: 6; position: absolute; left: 50%; bottom: 15px; display: flex; align-items: center; gap: 9px; padding: 9px 16px 9px 10px; color: #15191f; background: white; border: 1px solid rgba(0,0,0,.14); border-radius: 999px; box-shadow: 0 6px 22px rgba(0,0,0,.34); font-size: 12px; font-weight: 750; transform: translateX(-50%); cursor: pointer; }
  .mobile-lines-button span { min-width: 35px; padding: 5px 7px; color: white; border-radius: 6px; font-size: 11px; font-weight: 850; }
  .settings-panel { padding: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .ambient-train { display: none; }
}
