:root {
  color-scheme: dark;
  font-family: system-ui, sans-serif;
  background: #101713;
  color: #ecf3ed;
  --muted: #aebdb3;
  --border: #35473c;
  --surface: #18231c;
  --accent: #b4ebc7;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100svh; background: radial-gradient(ellipse at 12% 0, #213a2c, transparent 32rem), #101713; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid #bef4cd; outline-offset: 4px; }
.site-header, main { width: min(75rem, calc(100% - 3rem)); margin-inline: auto; }
.site-header { display: flex; align-items: center; justify-content: space-between; min-height: 3.65rem; border-bottom: 1px solid var(--border); }
.wordmark { display: flex; align-items: center; gap: .5rem; font-size: .9rem; font-weight: 700; }
.wordmark img { filter: brightness(0) invert(1); }
.back { font-size: .8rem; font-weight: 650; color: var(--muted); }
.back span { margin-inline-start: .2rem; }
main { margin-block: 1.5rem 2.5rem; }
.page-heading { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
h1 { margin: 0; font: 400 clamp(2.5rem, 6vw, 4rem)/1 Georgia, serif; letter-spacing: -.045em; }
button { border: 1px solid transparent; border-radius: .5rem; min-height: 2.75rem; padding-inline: 1rem; background: var(--accent); color: #132719; font: 700 .88rem system-ui, sans-serif; cursor: pointer; }
button:hover:not(:disabled) { background: #d1f7dc; }
button:disabled { opacity: .7; cursor: progress; }
button[data-mode="stop"] { color: #eef5ef; background: #24382b; border-color: #536b5b; }
button[data-mode="stop"]:hover:not(:disabled) { background: #3b5545; border-color: #749380; }
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem); align-items: start; gap: .9rem; }
.board, .dispatch { margin: 0; min-width: 0; border: 1px solid var(--border); border-radius: .8rem; background: var(--surface); }
.board { overflow: hidden; }
.board-toolbar { display: flex; align-items: center; gap: .9rem; min-height: 2.7rem; padding: .55rem .8rem; }
.signal { display: inline-flex; align-items: center; gap: .4rem; margin-inline-end: auto; color: var(--muted); font-weight: 700; font-size: .78rem; }
.signal::before { display: block; content: ''; width: .44rem; height: .44rem; border-radius: 50%; background: currentColor; }
.signal[data-phase="starting"] { color: #f4d39b; }
.signal[data-phase="live"] { color: var(--accent); }
.signal[data-phase="error"] { color: #ffc5b3; }
.counter { color: var(--muted); white-space: nowrap; font-size: .75rem; }
.counter strong { margin-inline-start: .15rem; color: #f4f8f5; font-variant-numeric: tabular-nums; }
.map-stage { display: grid; place-items: center; background: #bac4aa; overflow: hidden; }
.map-surface { position: relative; width: min(100%, 80svh); aspect-ratio: 604 / 484; }
#rail { display: block; width: 100%; height: 100%; object-fit: contain; }
#trains { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
figcaption { padding: .55rem .8rem; display: flex; flex-wrap: wrap; justify-content: space-between; gap: .2rem .8rem; color: var(--muted); font-size: .72rem; }
#legend { color: #d8e6db; }
.dispatch { padding: .85rem; }
.dispatch-heading { display: flex; justify-content: space-between; align-items: baseline; column-gap: .8rem; }
.dispatch h2 { margin: 0; font-size: .94rem; }
#model { color: var(--accent); font-size: .73rem; font-weight: 750; white-space: nowrap; }
.event { margin: .65rem 0 0; color: #d4e3d8; font-size: .82rem; line-height: 1.4; overflow-wrap: anywhere; }
.train-list { list-style: none; padding: 0; margin: .7rem 0 0; border-top: 1px solid var(--border); }
.train-row { min-height: 2.55rem; display: grid; grid-template-columns: 1.25rem 1fr auto; align-items: center; column-gap: .45rem; border-bottom: 1px solid var(--border); }
.train-number { display: grid; place-items: center; width: 1.2rem; height: 1.2rem; border-radius: 50%; color: #0e1b14; background: #c7d4cb; font: 800 .7rem system-ui, sans-serif; }
.train-row[data-visible="true"] .train-number { background: var(--accent); }
.train-row[data-moving="true"] .train-number { background: #ffd179; }
.train-state { font-size: .77rem; font-weight: 650; }
.train-command { color: var(--muted); font-size: .72rem; }
details { margin-top: .7rem; color: var(--muted); font-size: .74rem; }
summary { cursor: pointer; }
dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .6rem; margin-bottom: 0; }
dd { margin: 0; overflow-wrap: anywhere; }
.error { grid-column: 1 / -1; margin: 0; border: 1px solid #935e51; background: #2d1b17; padding: .7rem .8rem; border-radius: .5rem; color: #ffd1c2; font-size: .8rem; }
@media (max-width: 760px) {
  .site-header, main { width: calc(100% - 1.5rem); }
  .site-header { min-height: 3.2rem; }
  main { margin-block-start: .95rem; }
  .page-heading { margin-bottom: .8rem; }
  .workbench { grid-template-columns: minmax(0, 1fr); gap: .65rem; }
  .map-surface { width: 100%; }
  .board-toolbar { gap: .6rem; padding-inline: .55rem; }
  .counter { font-size: .7rem; }
  .signal { font-size: .71rem; }
  figcaption { padding-inline: .55rem; }
  .dispatch { padding: .65rem; }
  .event { margin-top: .35rem; }
  .error { grid-column: 1; grid-row: 2; }
}
