:root {
  --ink: #14213d;
  --paper: #f5f1e8;
  --white: #fffdf8;
  --coral: #ff654f;
  --lime: #b7e43b;
  --sky: #72c9e8;
  --purple: #8b7cf6;
  --amber: #ffb83e;
  --muted: #6d7280;
  --line: rgba(20, 33, 61, .15);
  --plot-min-width: 900px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 82% 8%, rgba(183, 228, 59, .22), transparent 19rem),
    var(--paper);
  font-family: Manrope, system-ui, sans-serif;
}

button, input { font: inherit; }

.site-header {
  height: 56px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { color: var(--ink); font-weight: 800; font-size: 1.25rem; letter-spacing: -.06em; text-decoration: none; }
.brand span { color: var(--coral); padding: 0 .08em; }
.day-stamp { display: flex; align-items: center; gap: 10px; font-size: .68rem; letter-spacing: .12em; }
.day-stamp span { padding: 7px 9px; color: var(--white); background: var(--ink); border-radius: 50%; }

main { width: min(1240px, calc(100% - 40px)); margin: 0 auto; }
.hero { display: grid; grid-template-columns: 1.4fr .6fr; align-items: end; gap: 60px; padding: 38px 0 32px; }
.eyebrow { margin: 0 0 12px; color: #bf4939; font: 500 .72rem DM Mono, monospace; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 0; max-width: 820px; font-size: clamp(3.3rem, 7.5vw, 7.3rem); line-height: .89; letter-spacing: -.075em; }
h1 em { color: var(--coral); font-style: normal; }
.intro { max-width: 390px; margin: 0 0 9px; font-size: 1.04rem; line-height: 1.65; }

.route-tabs { display: grid; grid-template-columns: repeat(2, 1fr); border: 1px solid var(--ink); border-radius: 14px 14px 0 0; overflow: hidden; }
.route-tab { min-height: 68px; padding: 11px 18px; border: 0; border-right: 1px solid var(--ink); color: var(--ink); background: transparent; text-align: left; cursor: pointer; transition: .2s; }
.route-tab:last-child { border-right: 0; }
.route-tab:hover:not(:disabled), .route-tab.active { color: var(--white); background: var(--ink); }
.route-tab:disabled { cursor: not-allowed; opacity: .5; }
.route-tab small { display: block; margin-bottom: 5px; font: 500 .65rem DM Mono, monospace; text-transform: uppercase; letter-spacing: .1em; }
.route-tab strong { display: block; font-size: .95rem; line-height: 1.25; }

.control-strip { display: grid; grid-template-columns: 1fr auto auto; gap: 28px; align-items: center; padding: 11px 18px; color: var(--white); background: var(--ink); border-radius: 0 0 14px 14px; }
.control-kicker { display: block; color: var(--sky); font: .65rem DM Mono, monospace; letter-spacing: .1em; text-transform: uppercase; }
.control-copy strong { display: block; margin-top: 3px; font-size: .88rem; }
.buffer-control { display: flex; padding: 3px; background: rgba(255,255,255,.1); border-radius: 9px; }
.buffer-control button { min-width: 46px; padding: 7px 9px; border: 0; color: var(--white); background: transparent; border-radius: 7px; cursor: pointer; font: 500 .72rem DM Mono, monospace; }
.buffer-control button.active { color: var(--ink); background: var(--lime); }
.delay-view { display: flex; padding: 3px; background: rgba(255,255,255,.1); border-radius: 9px; }
.delay-view button { padding: 7px 9px; border: 0; color: var(--white); background: transparent; border-radius: 7px; cursor: pointer; white-space: nowrap; font: 500 .62rem DM Mono, monospace; }
.delay-view button.active { color: var(--ink); background: var(--coral); }

.board-card { margin: 16px 0; background: var(--white); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 18px 50px rgba(20,33,61,.08); overflow: hidden; }
.board-head { display: flex; justify-content: space-between; align-items: end; gap: 30px; padding: 17px 22px; border-bottom: 1px solid var(--line); }
.board-head h2 { margin: 0; font-size: 1.6rem; letter-spacing: -.04em; }
.legend { display: flex; flex-wrap: wrap; gap: 15px; color: var(--muted); font: .65rem DM Mono, monospace; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; }
.legend .good { background: #4a9c69; }.legend .watch { background: var(--amber); }.legend .risk { background: var(--coral); }.legend .unknown { background: #a8abb2; }

.timeline-scroller { overflow-x: auto; }
.timeline { position: relative; width: 100%; min-width: var(--plot-min-width); padding-bottom: 5px; }
.axis { position: sticky; top: 0; z-index: 3; height: 38px; background: var(--white); border-bottom: 1px solid var(--line); }
.axis-plot { width: 100%; height: 100%; }
.axis-plot, .plot { position: relative; background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(9.0909% - 1px), var(--line) calc(9.0909% - 1px), var(--line) 9.0909%); }
.tick { position: absolute; top: 11px; transform: translateX(-50%); color: var(--muted); font: .66rem DM Mono, monospace; }
.now-overlay { position: absolute; z-index: 4; inset: 0 0 5px; pointer-events: none; }
.now-line { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--coral); box-shadow: 0 0 0 1px rgba(255,253,248,.75); }
.now-line b { position: absolute; top: 3px; left: 5px; padding: 3px 5px; color: var(--white); background: var(--coral); border-radius: 4px; font: 600 .55rem DM Mono, monospace; white-space: nowrap; }
.group-label { padding: 6px 12px; border-bottom: 1px solid var(--line); background: #f5f1e8; font: 600 .68rem DM Mono, monospace; letter-spacing: .08em; text-transform: uppercase; }
.group-label { display: flex; align-items: center; justify-content: space-between; }
.group-label button { padding: 3px 7px; border: 1px solid rgba(20,33,61,.25); color: var(--ink); background: transparent; border-radius: 5px; cursor: pointer; font: 500 .57rem DM Mono, monospace; text-transform: uppercase; }
.service-row { position: relative; min-height: 40px; border-bottom: 1px solid rgba(20,33,61,.08); cursor: pointer; transition: opacity .2s, background .2s, box-shadow .2s; }
.service-row.collapsed, .service-row.impossible { display: none; }
.service-row:last-child { border-bottom: 0; }
.service-row:hover { background: rgba(114,201,232,.12); }
.service-row.selected { background: rgba(183,228,59,.18); box-shadow: inset 4px 0 0 var(--coral); }
.service-row:focus-within { box-shadow: inset 0 0 0 2px var(--ink); }
.service-row.dim { opacity: .22; }
.service-row.connectable { background: rgba(183,228,59,.13); }
.service-row.missed { opacity: .28; }
.plot { min-height: 40px; }
.rtt-link { position: sticky; z-index: 3; right: 7px; float: right; width: 51px; height: 28px; margin-top: -34px; display: grid; place-items: center; color: var(--ink); background: rgba(255,253,248,.92); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 2px 8px rgba(20,33,61,.1); font: 700 .58rem DM Mono, monospace; text-decoration: none; }
.rtt-link:hover { color: var(--white); background: var(--purple); }
.train-bar { position: absolute; top: 3px; height: 34px; min-width: 6px; padding: 3px 6px; display: flex; flex-direction: column; align-items: stretch; justify-content: center; border: 0; color: var(--ink); background: var(--sky); border-radius: 7px; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(20,33,61,.18); transition: transform .16s, filter .16s; overflow: visible; white-space: nowrap; font: 500 .59rem DM Mono, monospace; }
.train-bar:hover, .train-bar.selected { z-index: 2; transform: translateY(-2px); filter: saturate(1.25); box-shadow: 0 5px 0 var(--ink); }
.train-bar.good { background: #a8dda8; }.train-bar.watch { background: #ffd37d; }.train-bar.risk { background: #ff8f7f; }.train-bar.unknown { color: #464b57; background: #d9d8d4; }
.train-bar::before, .train-bar::after { content: ""; position: absolute; top: 13px; width: 7px; height: 7px; background: var(--ink); border: 2px solid var(--white); border-radius: 50%; }
.train-bar::before { left: -4px; }.train-bar::after { right: -4px; }
.bar-times { display: flex; justify-content: space-between; gap: 4px; }
.bar-operator { overflow: hidden; font-size: .5rem; line-height: 1.05; text-align: center; text-overflow: ellipsis; }
.train-bar.segment { padding-inline: 5px; }
.risk-tag { position: absolute; right: -7px; top: -10px; transform: translateX(100%); z-index: 2; padding: 3px 6px; color: var(--white); background: var(--ink); border-radius: 5px; font-size: .57rem; }
.delay-shadow { display: none; position: absolute; top: 3px; height: 34px; border: 2px dashed var(--coral); background: rgba(255,101,79,.08); border-radius: 0 7px 7px 0; pointer-events: none; }
.delay-shadow.visible { display: block; z-index: 1; min-width: 2px; }
.delay-shadow b { position: absolute; left: 100%; top: 5px; padding-left: 4px; color: var(--coral); font: 600 .56rem DM Mono, monospace; white-space: nowrap; }
.connection-flag { position: absolute; left: 3px; top: -8px; padding: 2px 5px; color: var(--ink); background: var(--lime); border-radius: 4px; font: 600 .55rem DM Mono, monospace; text-transform: uppercase; }

.selection-note { min-height: 58px; padding: 10px 22px; display: flex; align-items: center; gap: 12px; border-top: 1px solid var(--line); background: #f7f4ed; }
.selection-note p { margin: 0; font-size: .83rem; }
.selection-icon { width: 30px; height: 30px; display: grid; place-items: center; flex: 0 0 auto; color: white; background: var(--coral); border-radius: 50%; font-size: 1rem; }

.data-note { margin: 30px 0; padding: 18px 22px; display: grid; grid-template-columns: auto 1fr auto; gap: 18px; align-items: center; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); }
.data-badge { width: 52px; height: 52px; display: grid; place-items: center; color: var(--white); background: var(--purple); border-radius: 50% 50% 8px 50%; font: 500 .85rem DM Mono, monospace; }
.data-note h2 { margin: 0 0 6px; font-size: 1.1rem; }
.data-note p { max-width: 720px; margin: 0; color: var(--muted); font-size: .8rem; line-height: 1.55; }
.data-note a { color: var(--ink); font-weight: 800; font-size: .78rem; }
footer { min-height: 70px; padding: 18px max(24px, calc((100vw - 1240px) / 2)); display: flex; justify-content: space-between; align-items: center; gap: 20px; color: rgba(255,255,255,.7); background: var(--ink); font: .65rem DM Mono, monospace; }

.empty-state { min-height: 370px; display: grid; place-items: center; text-align: center; }
.empty-state .big { display: block; margin-bottom: 12px; font-size: 4rem; }
.error { padding: 40px; color: #7e2318; }

@media (max-width: 800px) {
  :root { --plot-min-width: 760px; }
  main { width: min(100% - 24px, 1240px); }
  .hero { grid-template-columns: 1fr; gap: 18px; padding: 28px 5px 24px; }
  .intro { font-size: .92rem; }
  .route-tabs { grid-template-columns: 1fr; }
  .route-tab { min-height: 56px; border-right: 0; border-bottom: 1px solid var(--ink); }
  .route-tab:last-child { border-bottom: 0; }
  .control-strip { grid-template-columns: 1fr; gap: 14px; }
  .board-head { align-items: start; flex-direction: column; }
  .data-note { grid-template-columns: auto 1fr; }
  .data-note a { grid-column: 2; }
  footer { align-items: start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
