:root {
  --bg: #0f1419;
  --panel: #151b23;
  --panel-2: #1c242e;
  --line: #2a3441;
  --text: #e6edf3;
  --muted: #8b98a8;
  --accent: #4fb3ff;
  --ontime: #3ddc84;
  --minor: #f5d547;
  --major: #ff9f43;
  --severe: #ff5c5c;
  --waiting: #9aa7b6;
  /* the delay colours when used for text */
  --ontime-text: var(--ontime); --minor-text: var(--minor); --major-text: var(--major);
  --severe-text: var(--severe); --waiting-text: var(--waiting);
  --text-2: #c4cdd6; --line-soft: #1f2731; --line-strong: #3b4a5c;
  --panel-3: #18212b; --sel: #1d2b3a; --sel-strong: #26384b;
  --glass: rgba(21, 27, 35, .95); --hover: rgba(255, 255, 255, .05); --tip: #0b0f14;
  --attribution: rgba(15, 20, 25, .75); --attribution-link: #9cc9ff;
  /* on the map */
  --map-bg: #0b0f14; --rail: #e6ecf2; --road-m: #9a7a3e; --road-n: #67707b; --road-r: #545c66;
  --place-city: #ffffff; --place-town: #e3e9ef; --place-village: #b9c3cd; --place-outline: rgba(12, 16, 21, .92);
  --station: #dfe7ef; --station-none: #5b6673; --dot: #0f1419; --luas-stop: #3a4654; --luas-stop-edge: #c9d3dd;
  --vehicle-edge: #f2f5f8; --sched: #b39dfa; --label-halo: #000; --shadow: rgba(0, 0, 0, .7); --pin-upcoming: #b9c3cd;
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
}

:root[data-theme="light"] {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-2: #eef2f6;
  --line: #d5dce4;
  --text: #17202a;
  --muted: #586675;
  --accent: #0a66c2;
  --ontime: #27b36a;
  --minor: #e9bd13;
  --major: #f58a1f;
  --severe: #ee5050;
  --waiting: #8894a1;
  --ontime-text: #0b7541; --minor-text: #7d5c00; --major-text: #a34a00; --severe-text: #c02323; --waiting-text: #586675;
  --text-2: #37444f; --line-soft: #e5eaef; --line-strong: #aab6c2;
  --panel-3: #f7f9fb; --sel: #e0edfa; --sel-strong: #d3e5f8;
  --glass: rgba(255, 255, 255, .95); --hover: rgba(0, 0, 0, .05); --tip: #ffffff;
  --attribution: rgba(255, 255, 255, .8); --attribution-link: #0a66c2;
  --map-bg: #dfe5ea; --rail: #3b4652; --road-m: #c99a3d; --road-n: #a3adb7; --road-r: #bcc4cc;
  --place-city: #10171e; --place-town: #26323d; --place-village: #4b5865; --place-outline: rgba(255, 255, 255, .92);
  --station: #2c3640; --station-none: #95a1ad; --dot: #ffffff; --luas-stop: #ffffff; --luas-stop-edge: #55616d;
  --vehicle-edge: #1b242d; --sched: #7350d6; --label-halo: #fff; --shadow: rgba(0, 0, 0, .35); --pin-upcoming: #8793a0;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { display: flex; overflow: hidden; }

#map { flex: 1; height: 100%; background: var(--map-bg); }

/* ---- side panel ---- */
#panel {
  width: 360px; flex-shrink: 0; height: 100%;
  display: flex; flex-direction: column;
  background: var(--panel); border-right: 1px solid var(--line);
  z-index: 1000;
}
#panel header { padding: 16px 16px 10px; border-bottom: 1px solid var(--line); }
.title { display: flex; align-items: baseline; justify-content: space-between; }
h1 { font-size: 18px; margin: 0; font-weight: 650; letter-spacing: .2px; }
h1 span {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ontime-text);
  margin-left: 6px; vertical-align: 2px;
}
h1 span::before {
  content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: var(--ontime); margin-right: 5px; vertical-align: 1px;
  animation: pulse 2s infinite;
}
#clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
#stats { display: flex; gap: 6px; margin: 12px 0 6px; flex-wrap: wrap; }
.stat {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 10px; font-size: 12px; color: var(--muted);
}
.stat b { display: block; color: var(--text); font-size: 17px; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); font-size: 12px; }
#status.error { color: var(--severe-text); }

.controls { padding: 10px 16px; border-bottom: 1px solid var(--line); }
#search {
  width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--bg); color: var(--text); font-size: 13px; outline: none;
}
#search:focus { border-color: var(--accent); }
.filters { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.filters button {
  font: inherit; font-size: 12px; padding: 4px 9px; border-radius: 999px; cursor: pointer;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
}
.filters button.on { background: var(--panel-2); color: var(--text); border-color: var(--line-strong); }

#list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#list li {
  padding: 9px 16px; border-bottom: 1px solid var(--line-soft); cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 8px;
}
#list li:hover { background: var(--panel-2); }
#list li.selected { background: var(--sel); }
#list .route { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list .route code { color: var(--muted); margin-right: 6px; font-size: 12px; }
#list .where { grid-column: 1 / -1; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.badge {
  font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 999px;
  color: #0b0f14; background: var(--c, var(--waiting)); white-space: nowrap; align-self: start;
}

#detail { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel-3); max-height: 45%; overflow-y: auto; }
#detail .head { display: flex; justify-content: space-between; align-items: start; gap: 8px; }
#detail h2 { font-size: 15px; margin: 0 0 2px; }
#detail .actions { display: flex; gap: 6px; }
#detail .actions button {
  font: inherit; font-size: 12px; padding: 3px 8px; border-radius: 6px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
}
#detail .actions button.on { border-color: var(--accent); color: var(--accent); }
#detail .msg { font-size: 12px; color: var(--muted); margin: 6px 0 8px; white-space: pre-line; }
.stops { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.stops li { display: grid; grid-template-columns: 14px 1fr 40px 44px 34px; gap: 6px; padding: 3px 0; align-items: center; }
.stops li .dot { width: 9px; height: 9px; border-radius: 50%; border: 2px solid var(--muted); }
.stops li.passed { color: var(--muted); }
.stops li.passed .dot { background: var(--muted); }
.stops li.current .dot { background: var(--accent); border-color: var(--accent); }
.stops li.current { color: var(--text); font-weight: 600; }
.stops .t { font-variant-numeric: tabular-nums; text-align: right; }
.stops .late { color: var(--major-text); }
.stops .hdr { color: var(--muted); font-size: 11px; }

#panel footer { padding: 10px 16px; border-top: 1px solid var(--line); line-height: 1.4; }

/* ---- station board ---- */
#station { padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel-3); max-height: 60%; overflow-y: auto; }
#station .head { display: flex; justify-content: space-between; align-items: start; gap: 8px; margin-bottom: 8px; }
#station h2 { font-size: 15px; margin: 0 0 2px; }
#station .x, #detail #back {
  font: inherit; font-size: 12px; padding: 3px 8px; border-radius: 6px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--line);
}
#station .error { color: var(--severe-text); font-size: 12px; }
#station .board-head, #station tr { display: grid; grid-template-columns: 46px 1fr 42px 50px; gap: 6px; align-items: baseline; }
#station .board-head { font-size: 11px; color: var(--muted); padding: 0 4px 2px; }
#station .dir h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .8px; color: var(--accent);
  margin: 10px 0 4px; padding-bottom: 3px; border-bottom: 1px solid var(--line); font-weight: 600;
}
#station table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
#station tr { padding: 4px; border-radius: 6px; }
#station table.luas tr { grid-template-columns: 60px 1fr; }
#station tr.live { cursor: pointer; }
#station tr.live:hover { background: var(--panel-2); }
#station td.due { font-weight: 650; font-variant-numeric: tabular-nums; }
#station td.dest span { display: block; font-size: 11px; color: var(--muted); }
#station tr:not(.live) td.dest span::after { content: " · not running yet"; }
#station td.t { text-align: right; font-variant-numeric: tabular-nums; }
#station td.late { color: var(--major-text); }

.stops a.stn { color: inherit; cursor: pointer; text-decoration: none; }
.stops a.stn:not(.plain):hover { color: var(--accent); text-decoration: underline; }
#list li.station-hit code { color: var(--accent); font-size: 10px; letter-spacing: .6px; }

/* ---- legend ---- */
#legend {
  position: absolute; right: 12px; bottom: 24px; z-index: 900;
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 12px; font-size: 12px; color: var(--muted); backdrop-filter: blur(4px);
}
#legend div { display: flex; align-items: center; gap: 8px; padding: 2px 0; }
#legend i { width: 11px; height: 11px; border-radius: 50%; background: var(--c); display: inline-block; }
#legend i.hollow { background: transparent; border: 2px solid var(--waiting); }
#legend i.stale { background: var(--waiting); opacity: .45; }
#legend .sep { border-top: 1px solid var(--line); margin: 5px 0 3px; padding: 0; }
#legend i.shape-arrow { width: 0; height: 0; border-radius: 0; background: none;
  border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 11px solid var(--muted); }
#legend i.shape-bus { width: 8px; height: 8px; margin: 0 1.5px; border-radius: 2px; background: var(--ontime); border: 1.3px solid var(--vehicle-edge); }
#legend i.shape-luas { width: 7px; height: 7px; border-radius: 1px; border: 1.3px solid var(--vehicle-edge); margin-right: -2px; transform: rotate(45deg); }
#legend i.shape-sched { width: 8px; height: 8px; margin: 0 1.5px; border-radius: 2px; background: transparent; border: 1.5px dashed var(--sched); }
#legend i.shape-luas.red { background: #e4002b; }
#legend i.shape-luas.green { background: #00a651; margin-right: 0; }
/* Buses and trams are smaller than trains, and their labels only show close in. */
.train.vehicle .label { display: none; font-size: 10px; left: 8px; top: -7px; }
.show-vehicle-labels .train.vehicle .label { display: block; }

/* ---- train markers ---- */
.train-icon { pointer-events: auto; }
.train {
  position: absolute; left: 0; top: 0; width: 0; height: 0;
}
.train .body {
  position: absolute; left: -7px; top: -7px; width: 14px; height: 14px;
  will-change: transform;
}
.train .body svg { width: 14px; height: 14px; display: block; overflow: visible; filter: drop-shadow(0 0 3px var(--shadow)); }
/* Trains a touch bigger than buses and trams at country zoom. */
.train:not(.vehicle) .body { transform-origin: 50% 50%; left: -8px; top: -8px; width: 16px; height: 16px; }
.train:not(.vehicle) .body svg { width: 16px; height: 16px; }

/* ---- icon badges (zoomed in) ---- */
.train .tag, .train .pointer { display: none; }
.badges .train .body, .badges .train .label { display: none !important; }
.badges .train .tag {
  display: inline-flex; align-items: center; gap: 3px;
  position: absolute; left: 0; top: 0; transform: translate(-50%, -50%);
  height: 18px; padding: 0 6px 0 4px; border-radius: 6px;
  background: var(--c); color: #fff; border: 1.5px solid rgba(11, 15, 20, .85);
  font-size: 11px; font-weight: 700; white-space: nowrap; line-height: 1;
  box-shadow: 0 1px 4px rgba(0,0,0,.55);
}
.badges .train.dark-text .tag { color: #0b0f14; }
.badges .train .tag .glyph svg { width: 12px; height: 12px; display: block; fill: currentColor; }
.badges .train.hollow .tag { background: var(--panel); color: var(--c); border-color: var(--c); }
.badges .train.scheduled .tag { border-style: dashed; border-width: 1.5px; }
.badges .train .pointer { display: block; position: absolute; left: 0; top: 0; width: 0; height: 0; }
.badges .train .pointer i {
  position: absolute; left: -4px; top: -4px; width: 0; height: 0;
  border-left: 4px solid transparent; border-right: 4px solid transparent; border-bottom: 7px solid var(--c);
  filter: drop-shadow(0 0 1px rgba(0,0,0,.9));
}
.badges .train.no-heading .pointer { display: none; }
.badges .train.selected .tag { outline: 2px solid var(--accent); outline-offset: 1px; }
.badges .train.vehicle .tag { height: 16px; font-size: 10.5px; padding: 0 5px 0 3px; }
.train .label {
  position: absolute; left: 10px; top: -8px; font-size: 11px; font-weight: 600;
  color: var(--text); text-shadow: 0 0 3px var(--label-halo), 0 0 2px var(--label-halo); white-space: nowrap;
  pointer-events: none; display: none;
}
.show-labels .train .label { display: block; }
.train.selected .body::after {
  content: ""; position: absolute; inset: -7px; border-radius: 50%;
  border: 2px solid var(--accent); animation: pulse 1.6s infinite;
}
.train.selected .label { display: block; color: var(--accent); }
.train.stale { opacity: .4; }

@keyframes pulse { 0% { opacity: 1; } 50% { opacity: .35; } 100% { opacity: 1; } }

/* Leaflet tweaks */
/* Dark basemaps hide side streets: lift them at city zoom (MapTiler etc.). */
.city-zoom .basemap:not(.invert):not(.light) { filter: brightness(1.9) contrast(1.15); }
/* Standard OSM tiles, turned into a dark basemap. */
.basemap.invert { filter: invert(1) hue-rotate(180deg) brightness(.82) contrast(.92) saturate(.35); }
/* Standard OSM tiles are colourful: mute them so the traffic stands out. */
.basemap.muted { filter: saturate(.45) brightness(1.04); }
.leaflet-container { font: inherit; }
.leaflet-tooltip.station-tip {
  background: var(--glass); color: var(--text); border: 1px solid var(--line);
  box-shadow: none; font-size: 12px; padding: 3px 7px;
}
.leaflet-tooltip.station-tip::before { display: none; }
.leaflet-control-attribution { background: var(--attribution) !important; color: var(--muted) !important; }
.leaflet-control-attribution a { color: var(--attribution-link) !important; }

@media (max-width: 760px) {
  body { flex-direction: column-reverse; }
  #panel { width: 100%; height: 42%; border-right: none; border-top: 1px solid var(--line); }
  #map { height: 58%; }
  #legend { display: none; }
}

/* ---- service alerts ---- */
#alerts {
  position: absolute; right: 12px; top: 12px; z-index: 910; width: 330px;
  max-height: calc(100% - 300px); min-height: 0; display: flex; flex-direction: column;
  background: var(--glass); border: 1px solid var(--line); border-radius: 10px;
  backdrop-filter: blur(4px); font-size: 13px; overflow: hidden;
}
#alerts[hidden] { display: none; }
#alerts-toggle {
  all: unset; cursor: pointer; display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; font-weight: 600; color: var(--text);
}
#alerts-toggle b { background: #f5a524; color: #15110a; border-radius: 9px; padding: 0 7px; font-size: 12px; }
#alerts-toggle .chev { margin-left: auto; width: 7px; height: 7px; border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted); transform: rotate(45deg); margin-top: -3px; }
#alerts.collapsed .chev { transform: rotate(-135deg); margin-top: 3px; }
#alerts.collapsed #alerts-list, #alerts.collapsed .alerts-foot { display: none; }
.warn, #legend i.shape-alert, .alert-pin {
  display: inline-grid; place-items: center; width: 18px; height: 16px; font: 800 11px/1 system-ui, sans-serif;
  color: #15110a; background: #f5a524; clip-path: polygon(50% 0, 100% 100%, 0 100%); padding-top: 3px; box-sizing: border-box;
}
#legend i.shape-alert { width: 13px; height: 12px; border-radius: 0; font-size: 8px; padding-top: 2px; }
#alerts-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; border-top: 1px solid var(--line); }
#alerts-list li { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
#alerts-list li:hover { background: var(--panel-2); }
#alerts-list li.sel { background: var(--panel-2); box-shadow: inset 3px 0 0 #f5a524; }
#alerts-list li.upcoming { opacity: .75; }
#alerts-list .a-head { display: flex; gap: 8px; align-items: flex-start; }
#alerts-list .a-head svg { fill: currentColor; flex: none; width: 15px; height: 15px; margin-top: 1px; color: var(--muted); }
#alerts-list .a-title { font-weight: 600; line-height: 1.3; }
#alerts-list .a-meta { color: var(--muted); font-size: 12px; margin: 3px 0 0 23px; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
#alerts-list .a-route { background: var(--panel-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; color: var(--text); }
#alerts-list .a-text { display: none; white-space: pre-line; color: var(--text-2); font-size: 12.5px; line-height: 1.45; margin: 7px 0 2px 23px; }
#alerts-list li.sel .a-text { display: block; }
#alerts-list .a-source { color: var(--muted); font-size: 11px; margin-top: 6px; }
#alerts-list .a-route.bus-transfer { background: #f5a524; border-color: #f5a524; color: #15110a; font-weight: 600; }
#alerts-list .a-none { color: var(--muted); cursor: default; }
.alerts-foot { padding: 6px 12px 8px; font-size: 11px; }
.alert-pin { filter: drop-shadow(0 0 2px rgba(0,0,0,.9)); cursor: pointer; }
.alert-pin.upcoming { background: var(--pin-upcoming); }
.alert-pin.sel { transform: scale(1.35); }
@media (max-width: 760px) {
  #alerts { left: 12px; right: 12px; width: auto; max-height: 50%; }
}

/* ---- delay history ---- */
.hist-note { font-size: 11px; margin-top: 6px; }
.stops .usual { font-weight: 600; }
#station td.dest em { font-style: normal; }
.hist { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.hist h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 8px; font-weight: 600; }
.hist h4 { font-size: 11.5px; color: var(--muted); margin: 12px 0 4px; font-weight: 600; }
.hist .muted { font-size: 12px; }
.hist-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.hist-stats div { background: var(--panel-2); border-radius: 6px; padding: 6px 8px; font-size: 11px; color: var(--muted); }
.hist-stats b { display: block; font-size: 17px; color: var(--text); font-variant-numeric: tabular-nums; }
.hours { display: flex; align-items: flex-end; gap: 2px; height: 58px; margin-top: 4px; padding-bottom: 13px; position: relative; }
.hours .bar { flex: 1; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; position: relative; }
.hours .bar i { display: block; border-radius: 2px 2px 0 0; min-height: 2px; }
.hours .bar span { position: absolute; bottom: -13px; left: 0; font-size: 9.5px; color: var(--muted); }
#station table.worst tr { grid-template-columns: 42px 1fr 78px; }
.hours .bar.empty::before { content: ""; position: absolute; bottom: 0; left: 0; right: 0; height: 1px; background: var(--line); }
#station table.worst td span { display: block; font-size: 11px; color: var(--muted); }
#station table.worst td.t b { font-size: 13px; }
.tip-sub { color: var(--muted); font-size: 11px; }
#legend .lg-h { font-size: 11px; color: var(--muted); }
#legend #legend-punct { display: block; padding: 0; }
#legend #legend-punct[hidden] { display: none; }

/* ---- Delays page ---- */
.d-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.d-seg button { font: inherit; font-size: 13px; padding: 6px 12px; border: 0; background: transparent; color: var(--muted); cursor: pointer; }
.d-seg button + button { border-left: 1px solid var(--line); }
.d-seg button:hover { color: var(--text); }
.d-seg button[aria-pressed="true"] { background: var(--sel-strong); color: var(--text); font-weight: 600; }
#views { display: flex; margin-top: 12px; }
#views button { flex: 1; }
.page { position: absolute; left: 360px; right: 0; top: 0; bottom: 0; z-index: 1001; overflow-y: auto; background: var(--bg); padding: 20px 24px 32px; }
.page[hidden], #d-tip[hidden] { display: none; }
.page > * { max-width: 980px; margin-left: auto; margin-right: auto; }
.page :focus-visible, #views :focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.d-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.d-head h2 { font-size: 20px; margin: 0 0 2px; }
#d-map, #punct-off { font: inherit; font-size: 12.5px; padding: 6px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); cursor: pointer; }
#punct-off { font-size: 11px; padding: 1px 7px; }
.d-filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.d-filters label { font-size: 13px; color: var(--muted); }
.d-filters select { font: inherit; font-size: 13px; margin-left: 4px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); }
.d-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
.d-tiles div, .d-card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; }
.d-tiles div { padding: 10px 14px; font-size: 12.5px; color: var(--muted); }
.d-tiles b { display: block; font-size: 24px; color: var(--text); }
.d-card { padding: 14px 16px; margin-bottom: 14px; }
.d-card h3 { font-size: 14px; margin: 0 0 12px; }
.d-card h3 span { color: var(--muted); font-weight: 400; margin-left: 6px; }
.d-chart { position: relative; padding: 18px 0 0 38px; }
.d-grid { position: absolute; left: 38px; right: 0; top: 18px; height: 180px; }
.d-grid span { position: absolute; left: 0; right: 0; border-top: 1px solid var(--line); }
.d-grid em { position: absolute; right: 100%; top: -8px; padding-right: 8px; font: 11px/16px inherit; font-style: normal; font-size: 11px; line-height: 16px; color: var(--muted); font-variant-numeric: tabular-nums; }
.d-cols { position: relative; display: flex; }
.d-col { flex: 1; min-width: 0; display: block; padding: 0; border: 0; background: none; font: inherit; color: inherit; }
.d-plot { display: flex; position: relative; height: 180px; align-items: flex-end; justify-content: center; padding: 0 1px; }
.d-plot i { display: block; width: 100%; max-width: 24px; min-height: 2px; background: #3987e5; border-radius: 4px 4px 0 0; }
.d-col.today .d-plot i { opacity: .6; }
.d-col:hover .d-plot { background: var(--hover); }
.d-plot b { position: absolute; left: 50%; transform: translateX(-50%); font-size: 11.5px; padding-bottom: 2px; white-space: nowrap; }
.d-x { display: flex; justify-content: center; height: 22px; padding-top: 6px; font-size: 11px; color: var(--muted); white-space: nowrap; }
.d-scroll { overflow-x: auto; }
#delays table { width: 100%; border-collapse: collapse; font-size: 13px; }
#delays th, #delays td { padding: 6px 8px; text-align: right; border-top: 1px solid var(--line); font-variant-numeric: tabular-nums; }
#delays thead th { border-top: 0; font-size: 11.5px; font-weight: 500; color: var(--muted); }
#delays th:first-child, #delays th:nth-child(2) { text-align: left; }
#delays tbody th { font-weight: 400; white-space: nowrap; padding: 0; }
#delays tbody th button { font: inherit; width: 100%; text-align: left; padding: 9px 8px; border: 0; background: none; color: var(--text); cursor: pointer; }
#delays tbody th button:hover { color: var(--accent); }
#delays tr.sel { background: var(--sel); }
#delays tr.sel th button { font-weight: 650; }
.d-mini { width: 34%; min-width: 140px; }
.d-mini > div { display: flex; }
.d-mini .d-plot { height: 26px; }
.d-mini .d-plot i { border-radius: 2px 2px 0 0; max-width: 12px; }
#d-tip { position: fixed; z-index: 1200; pointer-events: none; background: var(--tip); border: 1px solid var(--line-strong); border-radius: 8px; padding: 7px 10px; font-size: 12px; }
#d-tip b, #d-tip span { display: block; white-space: nowrap; }
#d-tip span { color: var(--text-2); }

/* ---- Settings page ---- */
.s-theme { display: flex; flex-wrap: wrap; gap: 10px; min-width: 0; padding-top: 4px; }
.s-theme legend { float: left; width: 100%; font-size: 14px; font-weight: 600; padding: 10px 0 2px; }
.s-theme label { flex: 1 1 130px; max-width: 200px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: 13px; }
.s-theme label:hover { border-color: var(--line-strong); }
.s-theme label:has(:checked) { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.s-theme label:has(:focus-visible) { outline: 2px solid var(--accent); outline-offset: 3px; }
.s-theme input { accent-color: var(--accent); margin: 0 6px 0 2px; vertical-align: -1px; }
/* A small picture of the site: side panel, map and a railway. */
.swatch { display: block; height: 72px; margin-bottom: 8px; border-radius: 6px; border: 1px solid var(--line); position: relative; overflow: hidden; }
.swatch.light, .swatch.auto { background: linear-gradient(90deg, #fff 34%, #d5dce4 34% 35%, #dfe5ea 35%); }
.swatch.dark, .swatch.auto::after { background: linear-gradient(90deg, #151b23 34%, #2a3441 34% 35%, #0b0f14 35%); }
.swatch::before { content: ""; position: absolute; left: 45%; right: 10%; top: 55%; border-top: 2px solid #8894a1; transform: rotate(-24deg); z-index: 1; }
.swatch.auto::after { content: ""; position: absolute; inset: 0; clip-path: polygon(100% 0, 100% 100%, 0 100%); }

@media (max-width: 760px) {
  /* On a phone the page takes the whole screen but for the title and switch. */
  .page { left: 0; bottom: 104px; padding: 14px 12px 24px; }
  body.page-open #panel { height: 104px; }
  body.page-open #panel > :not(header), body.page-open #stats, body.page-open #status { display: none; }
  body.page-open #map { height: calc(100% - 104px); }
}

/* ---- phone sheet (sheet.js) ---- */
#sheet-toggle { display: none; }
@media (max-width: 760px) {
  #map { height: auto; min-height: 0; }
  #search { font-size: 16px; }  /* smaller makes iPhones zoom in */
  body:not(.page-open) #panel { overflow-y: auto; }
  body:not(.page-open) #panel > * { flex-shrink: 0; }
  #list { flex: none; overflow: visible; }
  #panel header { padding-top: 4px; }
  body.page-open #panel header { padding-top: 16px; }

  body:not(.page-open) #sheet-toggle {
    display: block; position: sticky; top: 0; z-index: 2; width: 100%; padding: 11px 0; border: 0;
    background: var(--panel); cursor: pointer; touch-action: manipulation;
  }
  #sheet-toggle i { display: block; width: 14px; height: 14px; margin: -4px auto 4px; border: solid var(--muted);
    border-width: 0 3px 3px 0; transform: rotate(45deg); }
  .sheet-collapsed #sheet-toggle i { transform: rotate(-135deg); margin: 4px auto -4px; }
  #sheet-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

  /* A station or train has the sheet to itself. */
  body:not(.page-open) #panel:has(> #station:not([hidden]), > #detail:not([hidden])) { height: 62%; overflow: hidden; }
  body:not(.page-open) #panel:has(> #station:not([hidden]), > #detail:not([hidden])) > :not(#sheet-toggle, #station, #detail) { display: none; }
  body:not(.page-open) #panel > :is(#station, #detail):not([hidden]) { flex: 1; min-height: 0; max-height: none; border-bottom: 0; }
  #station .x, #detail #back, #detail .actions button { padding: 8px 12px; }
  #station tr { padding: 8px 4px; }
  #station table { font-size: 14px; }
  #station .board-head, #station tr { grid-template-columns: 54px 1fr 44px 62px; }
  #station td.due, #station td.t { white-space: nowrap; }

  /* Collapsed: just the title, or the station's or train's name. */
  body.sheet-collapsed:not(.page-open) #panel,
  body.sheet-collapsed:not(.page-open) #panel:has(> #station:not([hidden]), > #detail:not([hidden])) { height: 92px; overflow: hidden; }
  body.sheet-collapsed:not(.page-open) #panel > header > :not(.title) { display: none; }
}
