:root {
  --bg: #f4f4f1;
  --panel: #ffffff;
  --ink: #1b1b1b;
  --muted: #6b6b6b;
  --line: #d9d9d4;
  --accent: #f0d722; /* BVG yellow */
  --plan-bg: #ffffff;
  font-family: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  font-size: 14px;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); overflow: hidden; }
body { display: flex; flex-direction: column; }

#toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px;
  padding: 6px 12px; background: #1b1b1b; color: #fff; z-index: 2;
}
.brand { font-weight: 700; letter-spacing: .02em; background: var(--accent); color: #000; padding: 2px 8px; border-radius: 3px; }
.group { display: flex; align-items: center; gap: 4px; }
#toolbar button, #toolbar select, #toolbar input[type=datetime-local] {
  font: inherit; color: #fff; background: #333; border: 1px solid #555; border-radius: 4px; padding: 3px 8px; height: 28px;
}
#toolbar button:hover { background: #444; }
#toolbar button.on { background: var(--accent); color: #000; border-color: var(--accent); }
#toolbar input[type=datetime-local] { color-scheme: dark; }
#modes button { padding: 2px 4px; display: flex; align-items: center; gap: 3px; opacity: .45; }
#modes button.on { opacity: 1; background: #333; color: #fff; border-color: #888; }
#modes img, #modes .modeicon { width: 20px; height: 20px; display: block; }
#clock { font-variant-numeric: tabular-nums; font-size: 15px; min-width: 17ch; text-align: center; font-weight: 600; }
#mapopts label { display: flex; gap: 4px; align-items: center; color: #ccc; }

main { flex: 1; display: flex; min-height: 0; }
#stage { position: relative; flex: 1; min-width: 0; background: var(--plan-bg); }
#stage.map { background: #e8e6e1; }
#svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; user-select: none; }
#stage.dragging #svg { cursor: grabbing; }
#vsvg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; will-change: transform; }
#vsvg .veh { pointer-events: auto; }
#tiles.grey { filter: grayscale(1) brightness(1.08) contrast(.85); opacity: .75; }
#lines path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
#lines.dim path { opacity: .12; }
#lines.dim path.hl { opacity: 1; }
#stations circle { fill: #fff; stroke: #1b1b1b; }
#stations circle.minor { stroke-width: 1; }
#labels text, #termini text { font-size: 11px; paint-order: stroke; stroke: #fff; stroke-width: 3px; stroke-linejoin: round; fill: #1b1b1b; pointer-events: none; }
#labels text.major { font-weight: 700; }
#termini text { stroke: none; font-weight: 700; font-size: 11px; }
#stations circle:hover { stroke-width: 2.5; cursor: pointer; }

.veh { cursor: pointer; }
.veh .dot { stroke: #fff; stroke-width: 1.2; }
.veh .badge, .veh .btext { display: none; }
#vehicles.labelled .veh .dot { display: none; }
#vehicles.labelled .veh .badge, #vehicles.labelled .veh .btext { display: inline; }
.veh .badge { stroke: #fff; stroke-width: 1; }
.veh .btext { font-size: 9.5px; font-weight: 700; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.veh.sel .dot, .veh.sel .badge { stroke: #000; stroke-width: 2.5; }
.veh .arrow { fill: #1b1b1b; }
#vehicles:not(.labelled) .veh .arrow { display: none; }

#attribution { position: absolute; right: 0; bottom: 0; background: rgba(255,255,255,.8); font-size: 11px; padding: 1px 6px; }
#attribution a { color: inherit; }
#status { position: absolute; left: 10px; bottom: 10px; background: rgba(27,27,27,.85); color: #fff; padding: 4px 10px; border-radius: 4px; font-size: 12px; pointer-events: none; }
#status:empty { display: none; }
#zoomctl { position: absolute; left: 10px; top: 10px; display: flex; flex-direction: column; gap: 2px; }
#zoomctl button { width: 30px; height: 30px; font-size: 17px; border: 1px solid #999; background: #fff; border-radius: 4px; cursor: pointer; }

#panel { width: 320px; background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.tabs { display: flex; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; font: inherit; padding: 8px; border: 0; background: none; cursor: pointer; border-bottom: 3px solid transparent; }
.tabs button.on { border-bottom-color: var(--accent); font-weight: 700; }
#panel section { overflow: auto; padding: 8px 12px; flex: 1; }
#linefilter { width: 100%; font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 8px; }
#stats { font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
#stats b { color: var(--ink); }
#legend h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 6px; display: flex; align-items: center; gap: 6px; }
#legend h3 img, #legend h3 .modeicon { width: 18px; height: 18px; }
.badges { display: flex; flex-wrap: wrap; gap: 4px; }
.lb { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 20px; padding: 0 5px; font-weight: 700; font-size: 12px; border-radius: 2px; cursor: pointer; border: 0; line-height: 1; white-space: nowrap; }
.lb.S { border-radius: 10px; }
.lb.icon { background: none !important; padding: 0; min-width: 0; }
.lb.icon img { height: 20px; display: block; }
.lb.sel { outline: 2px solid #000; outline-offset: 1px; }

#info h2 { font-size: 16px; margin: 4px 0 8px; display: flex; align-items: center; gap: 8px; }
#info .sub { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
#info table { width: 100%; border-collapse: collapse; font-size: 13px; }
#info td { padding: 3px 4px; border-bottom: 1px solid #eee; vertical-align: middle; }
#info td.t { font-variant-numeric: tabular-nums; width: 3.5em; }
#info tr.past { color: #aaa; }
#info tr.cur td { font-weight: 700; }
#info tr.cur td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
#info .actions { display: flex; gap: 6px; margin: 8px 0; }
#info .actions button { font: inherit; font-size: 12px; padding: 3px 8px; border: 1px solid var(--line); background: #fafafa; border-radius: 4px; cursor: pointer; }
#info .actions button.on { background: var(--accent); }
.hint { color: var(--muted); }
#info td a { color: inherit; text-decoration: none; cursor: pointer; }
#info td a:hover { text-decoration: underline; }

@media (max-width: 760px) {
  main { flex-direction: column; }
  #panel { width: auto; height: 38%; border-left: 0; border-top: 1px solid var(--line); }
  #when { display: none; }
}

#views .sep { color: #999; font-size: 12px; margin: 0 2px 0 8px; }
#stations circle.hit { fill: transparent; stroke: none; cursor: pointer; }
#stations circle.hit:hover { fill: rgba(240, 215, 34, .45); }

#bucket { background: #fffbe0; border: 1px solid var(--accent); border-radius: 6px; padding: 6px 8px 8px; margin-bottom: 8px; }
#bucket .bhead { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-bottom: 6px; }
#bucket .clear { font: inherit; font-size: 11px; text-transform: none; letter-spacing: 0; border: 1px solid var(--line); background: #fff; border-radius: 4px; padding: 1px 6px; cursor: pointer; }
#bucket .lb { position: relative; }
#bucket .lb::after { content: "×"; position: absolute; top: -6px; right: -6px; width: 13px; height: 13px; line-height: 12px; font-size: 11px; border-radius: 50%; background: #1b1b1b; color: #fff; text-align: center; }

#views button.ghost { background: transparent; border-style: dashed; color: #bbb; }
#info pre { background: #f4f4f1; padding: 8px; border-radius: 4px; font-size: 11.5px; white-space: pre-wrap; }

.anchor { cursor: grab; }
.anchor circle { stroke: #fff; stroke-width: 2; }
.anchor.ov circle { stroke: #000; stroke-width: 2.5; }
.anchor.drag circle { stroke: #f0d722; stroke-width: 3; }
.anchor text { font-size: 11px; font-weight: 600; paint-order: stroke; stroke: #fff; stroke-width: 3px; fill: #1b1b1b; pointer-events: none; }
#labels .anchor { pointer-events: auto; }
#stage.reviewing .veh { pointer-events: none; opacity: .35; }
.anchor.est circle { stroke: #1b1b1b; stroke-width: 1.5; stroke-dasharray: 3 2; fill-opacity: .55; }
#stage.reviewing { user-select: none; -webkit-user-select: none; }
.anchor { touch-action: none; }
#toolbar button[hidden] { display: none; }
