:root {
  --bg: #0b1120;
  --bg2: #0f172a;
  --panel: #131c31;
  --panel-hi: #1a2540;
  --line: #24314f;
  --fg: #e7ecf6;
  --muted: #8b98b5;
  --dim: #56627e;
  --accent: #f5b301;
  --accent-ink: #1b1400;
  --accent-fg: #f5b301;            /* accent used as text */
  --text2: #c9d2e6;                /* body text in cards */
  --ok: var(--ok); --warn: var(--warn); --down: var(--down); --down-fg: var(--down-fg);
  --topbar-bg: rgba(11, 17, 32, 0.75);
  --glow-a: rgba(245, 179, 1, 0.07); --glow-b: rgba(76, 110, 245, 0.10);
  --shadow-pop: 0 18px 40px rgba(0, 0, 0, 0.55);
  --shadow-card: 0 18px 50px rgba(0, 0, 0, 0.45);
  --tl-ready: #26324f; --tl-ready-line: #2c3a5b; --tl-hover: #33416a;
  --backdrop: rgba(5, 9, 20, 0.7);
  color-scheme: dark;
  --radius: 10px;
  --side: 270px;      /* sidebar width; the footer uses the same grid */
  --main: 1100px;     /* map width */
  --gap: 24px;
  --inset: 14px;      /* text indent shared by sidebar headings, map names and footer */
}
/* Light mode (toggle in the top bar; first visit follows the device setting).
   The map images are white in both modes. */
:root[data-theme="light"] {
  --bg: #eef1f6;
  --bg2: #f7f9fc;
  --panel: #ffffff;
  --panel-hi: #e8edf5;
  --line: #d3dae6;
  --fg: #172033;
  --muted: #56627a;
  --dim: #7d889e;
  --accent-fg: #9a5b00;
  --text2: #334155;
  --ok: #15994a; --warn: #d9540b; --down: #d42a2a; --down-fg: #b91c1c;
  --topbar-bg: rgba(255, 255, 255, 0.82);
  --glow-a: rgba(245, 179, 1, 0.10); --glow-b: rgba(76, 110, 245, 0.07);
  --shadow-pop: 0 14px 34px rgba(15, 23, 42, 0.16);
  --shadow-card: 0 10px 30px rgba(15, 23, 42, 0.10);
  --tl-ready: #c4cedf; --tl-ready-line: #b3bfd3; --tl-hover: #a9b7cf;
  --backdrop: rgba(15, 23, 42, 0.35);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  min-height: 100vh;
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background:
    radial-gradient(1200px 500px at 70% -10%, var(--glow-a), transparent 60%),
    radial-gradient(900px 600px at -10% 10%, var(--glow-b), transparent 60%),
    var(--bg);
}

button, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Shown only without JavaScript. */
.noscript { margin: 0; padding: 14px 28px; background: var(--panel); border-bottom: 1px solid var(--line); line-height: 1.5; }

/* ---- top bar ---------------------------------------------------------- */

/* Same columns as .layout and footer: the title lines up with the sidebar text,
   the run controls end at the map's right edge. */
.topbar {
  display: grid; grid-template-columns: var(--side) minmax(0, var(--main));
  column-gap: var(--gap); justify-content: center; align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--topbar-bg);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 5;
}
/* One flex row across both columns: the title (never shrinks, may run past the
   sidebar column) on the left, the status and run picker pushed to the right so
   they end at the map's right edge. They can never overlap: if space runs out,
   the status text is cut with an ellipsis instead. */
.topinner { grid-column: 1 / -1; display: flex; align-items: center; gap: 24px; min-width: 0; }
.brand { display: flex; align-items: center; gap: 12px; padding-left: var(--inset); flex: none; }
.topright { margin-left: auto; display: flex; align-items: center; gap: 20px; min-width: 0; }
.runbox { flex: none; }
.bolt { width: 30px; height: 30px; fill: var(--accent); filter: drop-shadow(0 0 8px rgba(245, 179, 1, 0.45)); }
.brand h1 { margin: 0; font-size: 19px; font-weight: 750; letter-spacing: 0.5px; }  /* Thundery wordmark */
.brand h1, .brand p { white-space: nowrap; }  /* never wrap the title */
.brand p { margin: 0; font-size: 12px; color: var(--muted); }

.runbox { display: flex; align-items: center; gap: 10px; }
/* Run picker: one row, every control 28 px tall on one centre line. */
.runbox { --h: 28px; }
.seg { display: flex; gap: 4px; }
.seg button, .chipbtn {
  position: relative; cursor: pointer; border-radius: 7px; padding: 0 11px; height: var(--h); line-height: 1;
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted); font-size: 12px; white-space: nowrap;
}
.seg button:hover:not(:disabled), .chipbtn:hover { color: var(--fg); border-color: var(--dim); }
.seg button.on, .chipbtn.on { background: var(--panel-hi); border-color: var(--accent); color: var(--accent-fg); }
.seg button:disabled { opacity: 0.35; cursor: default; }
.hours button { min-width: 38px; padding: 0; font-variant-numeric: tabular-nums; }
.hours button.incomplete { border-style: dashed; }
.hours button.latest::after {
  content: ""; position: absolute; top: -3px; right: -3px; width: 7px; height: 7px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 6px rgba(245, 179, 1, 0.8);
}
.divider { width: 1px; height: 18px; background: var(--line); }

/* Reference Output chip and its menu */
.refmenu { position: relative; }
.chipbtn { display: inline-flex; align-items: center; gap: 2px; padding-right: 6px; }
.chipbtn svg { width: 16px; height: 16px; fill: currentColor; transition: transform 0.15s; }
.refmenu.open .chipbtn svg { transform: rotate(180deg); }
.menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 20; min-width: 100%;
  display: none; flex-direction: column; padding: 6px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow-pop);
}
.refmenu.open .menu { display: flex; }
.menu-head {
  padding: 4px 8px 6px; font-size: 11px; font-weight: 650; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--dim); white-space: nowrap;
}
.menu button {
  text-align: left; white-space: nowrap; cursor: pointer; padding: 7px 10px; border-radius: 6px;
  border: 0; background: none; color: var(--fg); font-size: 12px;
}
.menu button:hover { background: var(--panel-hi); }
.menu button.on { color: var(--accent-fg); }

.status {
  display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; min-width: 0;
}
.status .ptext { overflow: hidden; text-overflow: ellipsis; }
/* The "New run" slot takes no space (and adds no gap) while empty, so the pill
   ends exactly at the right edge. */
#status:empty { display: none; }
.pipeline { min-width: 0; }
/* Scheduler status pill: green up to date, amber pulsing while busy,
   orange if a run was skipped, red if the scheduler stopped updating. */
.pipeline {
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  height: 28px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg2);
}
.pipeline .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); flex: none; }
.pipeline.ok .dot { background: var(--ok); box-shadow: 0 0 6px rgba(60, 207, 122, 0.7); }
.pipeline.busy .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.pipeline.warn .dot { background: var(--warn); }
.pipeline.down { border-color: rgba(255, 90, 90, 0.5); color: var(--down-fg); }
.pipeline.down .dot { background: var(--down); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* Details box under the pill: on hover or keyboard focus; click pins it open. */
.pipeline { position: relative; cursor: pointer; }
.pop {
  position: absolute; top: calc(100% + 10px); left: 0; z-index: 20;
  width: max-content; min-width: 300px; max-width: min(640px, 90vw);  /* as wide as its longest line */
  padding: 0 0 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); color: var(--fg); white-space: nowrap; cursor: default;
  box-shadow: var(--shadow-pop);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s, visibility 0.15s;
}
.pop::before {  /* notch pointing at the pill */
  content: ""; position: absolute; top: -6px; left: 18px; width: 10px; height: 10px;
  background: var(--panel); border-left: 1px solid var(--line); border-top: 1px solid var(--line);
  transform: rotate(45deg);
}
.pop::after { content: ""; position: absolute; top: -12px; left: 0; right: 0; height: 12px; }  /* hover bridge */
.pipeline:hover .pop, .pipeline:focus-visible .pop, .pipeline.pinned .pop {
  opacity: 1; visibility: visible; transform: none;
}
.pop-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  border-bottom: 1px solid var(--line); font-weight: 650; font-size: 13px;
}
.pop-head .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.pop-head .dot.ok { background: var(--ok); }
.pop-head .dot.busy { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.pop-head .dot.warn { background: var(--warn); }
.pop-head .dot.down { background: var(--down); }
.pop-state { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--muted); }
.pop-state.ok { color: var(--ok); }
.pop-state.busy { color: var(--accent-fg); }
.pop-state.warn { color: var(--warn); }
.pop-state.down { color: var(--down); }
.pop dl {
  display: grid; grid-template-columns: max-content 1fr; gap: 7px 14px;
  margin: 0; padding: 12px 14px 0; font-size: 12px;
}
.pop dt { color: var(--muted); }
.pop dd { margin: 0; font-variant-numeric: tabular-nums; overflow: hidden; text-overflow: ellipsis; }
.pop .muted { color: var(--muted); }
.pop .pbar {  /* how much of an arriving run is on AWS */
  display: inline-block; vertical-align: middle; width: 54px; height: 6px; margin: 0 2px;
  border-radius: 3px; background: var(--bg2); border: 1px solid var(--line); overflow: hidden;
}
.pop .pbar i { display: block; height: 100%; background: var(--accent); }
.pop-failed {
  margin: 12px 14px 0; padding: 8px 10px; border-radius: 8px; font-size: 12px;
  background: rgba(255, 138, 61, 0.08); border: 1px solid rgba(255, 138, 61, 0.35);
}
.pop-sub { color: var(--warn); font-weight: 650; margin-bottom: 4px; }
.pop .fail { display: grid; grid-template-columns: max-content 1fr; gap: 10px; padding: 2px 0; }
.pop .fail span { overflow: hidden; text-overflow: ellipsis; }  /* very long errors end in "…" (full text on hover) */
.pop-foot { margin: 12px 14px 0; font-size: 11px; color: var(--dim); }
.status button {
  border: 1px solid rgba(245, 179, 1, 0.6); background: rgba(245, 179, 1, 0.12); color: var(--accent-fg);
  border-radius: 999px; padding: 0 12px; height: 28px; cursor: pointer; font-size: 12px; font-weight: 600;
  white-space: nowrap; flex: none;  /* one line, same height as the other controls */
}

/* Light/dark toggle: shows the sun in dark mode (switch to light), the moon in light mode. */
.themebtn {
  flex: none; display: grid; place-items: center; width: 28px; height: 28px; padding: 0; cursor: pointer;
  border-radius: 7px; border: 1px solid var(--line); background: var(--bg2); color: var(--muted);
}
.themebtn:hover { color: var(--fg); border-color: var(--dim); }
.themebtn svg { width: 16px; height: 16px; fill: currentColor; }
.themebtn .i-moon { display: none; }
:root[data-theme="light"] .themebtn .i-sun { display: none; }
:root[data-theme="light"] .themebtn .i-moon { display: block; }

/* ---- layout ----------------------------------------------------------- */

.layout {
  display: grid; grid-template-columns: var(--side) minmax(0, var(--main));
  gap: var(--gap); justify-content: center;
  padding: 22px 28px 8px;
}

/* ---- sidebar ---------------------------------------------------------- */

.sidebar { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 86px; align-self: start; }
/* Each group is a dropdown: a heading button (name, count, chevron) and its
   list of maps. All are closed when the page loads. */
.ghead {
  display: flex; align-items: center; gap: 8px; width: 100%; height: 34px;
  padding: 0 10px 0 var(--inset); background: transparent; border: 0; border-radius: 8px;
  cursor: pointer; text-align: left; white-space: nowrap; color: var(--dim);
}
.ghead:hover { background: var(--panel); color: var(--fg); }
.gname {  /* may shrink with an ellipsis, so every count and chevron lines up */
  font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: 1px;
  flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis;
}
.group.has-on .gname { color: var(--accent-fg); }
.gcount {
  flex: none; margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  font-size: 11px; line-height: 18px; text-align: center; color: var(--dim); background: var(--panel);
}
.chev { flex: none; width: 18px; height: 18px; fill: currentColor; transition: transform 0.15s; transform: rotate(-90deg); }
.group.open .chev { transform: none; }
.group .items { display: none; padding: 2px 0 8px; }
.group.open .items { display: block; }
/* A group the run cannot have (no ensemble data for old runs): greyed, with a note. */
.group.unavailable .ghead { cursor: default; opacity: 0.55; }
.group.unavailable .ghead:hover { background: transparent; color: var(--dim); }
.gnote { margin: 0 10px 6px var(--inset); font-size: 11px; line-height: 1.45; color: var(--dim); }
/* Overview link at the top of the map list, set off by a line below. */
.ovlink { margin-bottom: 6px; position: relative; }
.ovlink::after { content: ""; position: absolute; left: var(--inset); right: 10px; bottom: -4px; border-bottom: 1px solid var(--line); }
.ovlink .ovicon { flex: none; margin-left: auto; width: 14px; height: 14px; fill: currentColor; margin-right: 2px; }
.ovlink.on .gname, .ovlink.on .ovicon { color: var(--accent-fg); }
.prod {
  display: flex; flex-direction: column; width: 100%; text-align: left;
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 10px 8px var(--inset); margin-bottom: 2px; cursor: pointer; position: relative;
}
.prod .name, .prod .range {
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;  /* never wrap */
}
.prod .name { font-weight: 550; }
.prod .range { font-size: 11px; color: var(--dim); }
.prod:hover { background: var(--panel); }
.prod.on { background: var(--panel-hi); border-color: var(--line); }
.prod.on::before {
  content: ""; position: absolute; left: 0; top: 9px; bottom: 9px; width: 3px;
  border-radius: 3px; background: var(--accent);
}

/* Light mode: hover tints need to be darker than the white panels. */
:root[data-theme="light"] .ghead:hover, :root[data-theme="light"] .prod:hover { background: var(--panel-hi); }
:root[data-theme="light"] .prod.on { background: var(--panel); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08); }
:root[data-theme="light"] .card { box-shadow: 0 0 0 1px var(--line), var(--shadow-card); }

/* ---- map card --------------------------------------------------------- */

.card {
  position: relative; background: #fff; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 1100 / 850;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.06) inset, var(--shadow-card);
}
#map { display: block; width: 100%; height: auto; }
#message {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 32px; text-align: center; font-size: 16px; color: #1d1d1f;
  background: rgba(255, 255, 255, 0.92);
}
/* Note over the top of the map, e.g. "the run you linked to has expired". */
#notice {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  max-width: calc(100% - 24px); display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 14px; border-radius: 8px; font-size: 13px; line-height: 1.35;
  color: #fff; background: rgba(20, 26, 44, 0.94); border: 1px solid var(--accent);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
}
#notice[hidden] { display: none; }
#notice button {
  flex: none; width: 24px; height: 24px; border: 0; border-radius: 5px; cursor: pointer;
  font-size: 18px; line-height: 1; color: #aab4c8; background: transparent;
}
#notice button:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.spinner {
  position: absolute; top: 14px; right: 14px; width: 22px; height: 22px;
  border: 3px solid rgba(0, 0, 0, 0.12); border-top-color: var(--accent); border-radius: 50%;
  opacity: 0; transition: opacity 0.2s; animation: spin 0.8s linear infinite;
}
.card.loading .spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- daily overview ---------------------------------------------------- */

/* Takes the place of the map and player while open. */
main.ov-open > .card, main.ov-open > .player { display: none; }
/* The welcome box above the overview: same look, lighter content. */
.intro { margin-bottom: 16px; }
.intro-lead { margin: 10px 0 0; font-size: 14px; line-height: 1.55; color: var(--text2); max-width: 900px; }
.overview {
  container-type: inline-size;
  background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px 18px;
  box-shadow: var(--shadow-card);
}
.ov-top { display: flex; align-items: baseline; gap: 8px 14px; flex-wrap: wrap; }
.ov-top h2 { margin: 0; font-size: 20px; }
.ov-run { color: var(--muted); font-size: 13px; }
.ov-updated { font-size: 12px; color: var(--accent-fg); padding: 2px 8px; border-radius: 6px; background: rgba(245, 179, 1, 0.1); white-space: nowrap; }
.ov-days { margin-left: auto; display: flex; gap: 4px; }
.ov-days button {
  height: 28px; padding: 0 12px; border-radius: 7px; border: 1px solid var(--line); background: var(--bg2);
  color: var(--muted); font-size: 12px; cursor: pointer; white-space: nowrap;
}
.ov-days button small { color: var(--dim); margin-left: 4px; }
.ov-days button.on { border-color: var(--accent); color: var(--accent-fg); background: rgba(245, 179, 1, 0.08); }
.ov-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.ov-card {
  background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px 14px 12px;
  display: flex; flex-direction: column;
}
.ov-card h3 {
  margin: 0 0 2px; font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 8px;
}
.ov-card h3 i { width: 8px; height: 8px; border-radius: 50%; }
.ov-big { font-size: 26px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ov-big small { font-size: 14px; color: var(--muted); font-weight: 500; }
.ov-card p { margin: 6px 0 0; font-size: 13px; line-height: 1.5; color: var(--text2); }
/* The link sits at the bottom of the card, so the cards in a row line up. */
.ov-card .linkbtn { align-self: flex-start; margin-top: auto; padding: 12px 0 0; font-size: 12px; color: var(--accent-fg); }
.ov-card .linkbtn:hover { text-decoration: underline; }
.ov-foot { display: flex; align-items: center; gap: 12px 16px; margin-top: 16px; font-size: 12px; color: var(--dim); }
.ov-foot > button {
  margin-left: auto; flex: none; white-space: nowrap; height: 34px; padding: 0 18px; border-radius: 8px; border: 0;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer;
}
/* Two by two in a narrower column (iPad portrait, desktop with a narrow window), one column on phones. */
@container (max-width: 860px) { .ov-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@container (max-width: 520px) {
  .ov-cards { grid-template-columns: 1fr; }
  .ov-days { margin-left: 0; width: 100%; }
  .ov-days button { flex: 1; }
  .ov-foot { flex-direction: column; align-items: stretch; }
  .ov-foot > button { margin-left: 0; width: 100%; }
}
/* Touch screens: tap targets about 44 px (Apple's guideline). */
@media (hover: none) { .ov-days button { height: 36px; padding: 0 14px; } .ov-foot > button { height: 44px; } }
@media (max-width: 760px) { .overview { padding: 18px 16px 16px; } }

/* ---- player ----------------------------------------------------------- */

.player {
  margin-top: 14px; padding: 14px 16px 12px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
}
.player-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 22px; }

.buttons { display: flex; align-items: center; gap: 6px; }
.buttons button {
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg2);
}
.buttons button:hover { border-color: var(--dim); background: var(--panel-hi); }
.buttons svg { width: 18px; height: 18px; fill: currentColor; }
.icon { width: 36px; height: 36px; border-radius: 8px; }
.play {
  width: 48px; height: 48px; border-radius: 50%; margin: 0 4px;
  background: var(--accent) !important; border-color: var(--accent) !important; color: var(--accent-ink);
  box-shadow: 0 0 0 4px rgba(245, 179, 1, 0.12), 0 6px 18px rgba(245, 179, 1, 0.25);
}
.play svg { width: 22px; height: 22px; }
.play .i-pause { display: none; }
.play.playing .i-play { display: none; }
.play.playing .i-pause { display: block; }

.when { min-width: 0; }
.valid {
  font-size: 22px; font-weight: 650; letter-spacing: 0.2px; font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;  /* never wraps */
}
.when .sub { color: var(--muted); font-variant-numeric: tabular-nums; }
.when .dot { margin: 0 8px; color: var(--dim); }
.lead { color: var(--accent-fg); font-weight: 650; }

.speed { display: flex; align-items: center; gap: 4px; color: var(--dim); font-size: 12px; }
.speed span { margin: 0 4px; }
.speed button {
  width: 30px; height: 28px; cursor: pointer; border-radius: 6px;
  border: 1px solid var(--line); background: var(--bg2); color: var(--muted); font-size: 12px;
}
.speed button:hover { color: var(--fg); }
.speed button.on { background: var(--panel-hi); border-color: var(--accent); color: var(--accent-fg); }

/* ---- timeline --------------------------------------------------------- */

.timeline {
  display: flex; gap: 6px; margin-top: 14px; padding-bottom: 16px;
  user-select: none; touch-action: none; cursor: pointer;
}
.timeline:focus-visible { outline-offset: 4px; border-radius: 6px; }
.tl-day { min-width: 0; display: flex; flex-direction: column; }
.tl-dayname {
  font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden;
  padding: 0 0 4px 6px; border-left: 1px solid var(--line);
}
.tl-cells { display: flex; gap: 2px; }
.tl-cell {
  flex: 1; min-width: 0; height: 22px; border-radius: 3px; position: relative;
  background: var(--bg2); border: 1px solid var(--line);
  transition: background 0.15s;
}
.tl-cell.ready { background: var(--tl-ready); border-color: var(--tl-ready-line); }
.tl-cell:hover { background: var(--tl-hover); }
.tl-cell.on {
  background: var(--accent); border-color: var(--accent);
  box-shadow: 0 0 10px rgba(245, 179, 1, 0.55);
}
.tl-cell[data-h]::after {
  content: attr(data-h); position: absolute; top: 25px; left: 50%; transform: translateX(-50%);
  font-size: 10px; color: var(--dim); font-variant-numeric: tabular-nums;
}

/* ---- footer ----------------------------------------------------------- */

/* Same columns as .layout, but only the map column is used: the attribution
   starts at the animation controls' left edge, the key hints end at their right edge. */
footer {
  display: grid; grid-template-columns: var(--side) minmax(0, var(--main));
  column-gap: var(--gap); justify-content: center;
  padding: 14px 28px 26px;
  font-size: 12px; color: var(--muted);
}
footer > * { grid-row: 1; grid-column: 2; white-space: nowrap; }
footer .attribution { justify-self: start; }
footer .sep { margin: 0 4px; color: var(--dim); }
footer .links { justify-self: end; display: flex; align-items: center; gap: 16px; }
.linkbtn {
  border: 0; padding: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--dim); text-underline-offset: 3px;
}
.linkbtn:hover { color: var(--fg); }

/* Keys: hover or focus shows the shortcuts in a box above. */
.keyhelp { position: relative; }
.keyhelp:hover .pop, .keyhelp:focus-visible .pop { opacity: 1; visibility: visible; transform: none; }
.pop.up { top: auto; bottom: calc(100% + 10px); left: auto; right: -8px; min-width: 0; }
.pop.up::before { top: auto; bottom: -6px; left: auto; right: 14px; transform: rotate(225deg); }
.pop.up::after { top: auto; bottom: -12px; }
.pop.up .pop-head { font-size: 12px; }
.pop.up dl { gap: 8px 14px; }
.pop.up dt { text-align: right; }

/* ---- about & disclaimer dialog -------------------------------------------- */

#about {
  width: min(620px, calc(100vw - 40px)); padding: 0; border: 1px solid var(--line);
  border-radius: 14px; background: var(--panel); color: var(--fg);
  box-shadow: var(--shadow-pop);
}
#about::backdrop { background: var(--backdrop); backdrop-filter: blur(3px); }
#about form { margin: 0; }
.about-head {
  display: flex; align-items: center; gap: 10px; padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.about-head .bolt { width: 22px; height: 22px; fill: var(--accent); }
.about-head h2 { margin: 0; font-size: 17px; font-weight: 650; }
.about-head .x {
  margin-left: auto; width: 30px; height: 30px; border-radius: 8px; border: 1px solid transparent;
  background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.about-head .x:hover { border-color: var(--line); color: var(--fg); }
.about-body { padding: 6px 20px 4px; }
.about-body section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.about-body section:last-child { border-bottom: 0; }
.about-body h3 {
  margin: 0 0 6px; font-size: 11px; font-weight: 650; letter-spacing: 0.8px;
  text-transform: uppercase; color: var(--muted);
}
.about-body p { margin: 0 0 8px; font-size: 13px; line-height: 1.55; }
.about-body p:last-child { margin-bottom: 0; }
.about-body ul { margin: 0 0 8px; padding-left: 18px; font-size: 13px; line-height: 1.55; }
.about-body li { margin-bottom: 4px; }
.about-body a { color: var(--accent-fg); }
.about-body section.warn {
  margin: 8px -10px; padding: 12px 10px; border: 1px solid rgba(255, 138, 61, 0.35);
  border-radius: 10px; background: rgba(255, 138, 61, 0.07);
}
.about-body section.warn h3 { color: var(--warn); }
.about-foot { display: flex; justify-content: flex-end; padding: 14px 20px 18px; }
.about-foot .ok {
  border: 0; border-radius: 999px; padding: 8px 20px; cursor: pointer;
  background: var(--accent); color: #1a1200; font-weight: 650; font-size: 13px;
}
.about-foot .ok:hover { filter: brightness(1.08); }
footer a { color: inherit; }
kbd {
  display: inline-block; min-width: 20px; padding: 1px 5px; margin: 0 1px; text-align: center;
  font: 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px;
  background: var(--panel); color: var(--fg);
}

/* ---- narrower windows ------------------------------------------------- */

.mapsbtn { display: none; }  /* desktop: the sidebar lists the maps */

/* Below about 1350 px the subtitle would squeeze the status pill; the full
   name is still in the tab title and the About box. */
@media (max-width: 1350px) {
  .brand p { display: none; }
}

@media (max-width: 1100px) {
  /* One column (tablets in portrait, small laptops). The map list is the
     "current map" button and panel, as on phones (see below). */
  .layout { grid-template-columns: minmax(0, var(--main)); position: relative; }
  .player-row { grid-template-columns: auto 1fr; }
  .speed { grid-column: 1 / -1; }
  footer { grid-template-columns: minmax(0, var(--main)); row-gap: 6px; }
  footer > * { grid-column: 1; }
  footer .links { grid-row: 2; justify-self: start; }
  /* Top bar: title and status pill on one row, the run picker on its own row. */
  .topbar { grid-template-columns: 1fr; }
  .topinner { flex-wrap: wrap; row-gap: 10px; }
  .topright { display: contents; }
  .status { margin-left: auto; }
  .themebtn { order: 1; margin-right: var(--inset); }
  .runbox { order: 2; }
  .runbox { flex-basis: 100%; padding: 0 var(--inset); flex-wrap: wrap; row-gap: 6px; }
  /* Reference chip at the right end of its row, under the status pill's right edge. */
  .refmenu { margin-left: auto; }
  .pipeline .pop { left: auto; right: 0; }  /* the pill is at the right edge now */
  .pipeline .pop::before { left: auto; right: 18px; }

  .mapsbtn {
    display: flex; align-items: center; gap: 10px; width: 100%; height: 44px; padding: 0 12px;
    border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
    font-weight: 600; text-align: left; cursor: pointer;
  }
  .mapsbtn span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .mapsbtn .layers { width: 20px; height: 20px; fill: var(--accent); flex: none; }
  .mapsbtn .chev { transform: none; color: var(--muted); }
  .maps-open .mapsbtn { border-color: var(--accent); }
  .maps-open .mapsbtn .chev { transform: rotate(180deg); }
  /* The map list: hidden until opened, then a panel over the map, laid out like
     the desktop sidebar. */
  .sidebar { display: none; }
  .layout.maps-open .sidebar {
    display: flex; flex-direction: column; gap: 2px;
    position: absolute; top: 72px; left: 50%; transform: translateX(-50%); z-index: 10;
    width: min(420px, calc(100% - 24px)); max-height: 70vh; overflow-y: auto; overscroll-behavior: contain;
    padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
  }
  .ghead { height: 42px; }
  .prod { padding-top: 10px; padding-bottom: 10px; }
}

/* Short screens (landscape tablets, laptops): size the map to the window
   height, so the play controls and timeline stay on screen. */
@media (max-height: 900px) and (min-width: 1101px) {
  /* Only the map card shrinks (centred); the top bar, player and timeline keep
     the full column width, so nothing in them is squeezed or wraps. */
  .card { max-width: calc((100dvh - 280px) * 1100 / 850); margin: 0 auto; }
}
@media (max-height: 900px) and (min-width: 761px) and (max-width: 1100px) {
  :root { --main: min(1100px, calc((100dvh - 380px) * 1100 / 850)); }
}

/* ---- phones ------------------------------------------------------------ */


@media (max-width: 760px) {
  .topbar { position: static; padding: 10px 12px; }
  .topinner { gap: 8px 12px; }
  .brand { padding-left: 0; gap: 10px; }
  .brand p { display: none; }  /* the full name is in the tab title and the About box */
  .bolt { width: 24px; height: 24px; }
  .themebtn { margin-right: 0; }
  .runbox { padding: 0; }
  .runbox .divider { display: none; }
  .refmenu { order: 1; }  /* Reference chip on the day row; the hour chips wrap below */
  .hours { order: 2; }
  .hours button { min-width: 34px; }
  .pop { min-width: 0; max-width: calc(100vw - 24px); }

  .layout { padding: 10px 12px 4px; gap: 10px; }
  .layout.maps-open .sidebar { top: 60px; width: calc(100% - 24px); }

  .card { border-radius: 8px; }
  .player { margin-top: 10px; padding: 12px 10px 10px; }
  .player-row { grid-template-columns: 1fr; justify-items: center; gap: 10px; text-align: center; }
  .when { order: -1; }
  .valid { font-size: 19px; }
  .speed { grid-column: auto; }
  .icon { width: 42px; height: 42px; }
  .play { width: 52px; height: 52px; }
  .timeline { gap: 3px; }
  .tl-cells { gap: 1px; }
  .tl-cell { height: 30px; border-radius: 2px; }
  .tl-cell[data-h]::after { top: 33px; }

  footer { padding: 10px 12px 20px; }
  footer > * { white-space: normal; }
}

/* Touch: horizontal swipes on the map step the loop; scrolling and pinch-zoom stay. */
.card { touch-action: pan-y pinch-zoom; }

/* Touch screens have no hover, so the keyboard help is not useful there. */
@media (hover: none) {
  .keyhelp { display: none; }
}
