/* RhudMOD track — operations console.
   Palette from the game's own materials: deepslate panels, calcite paper (light theme), oxidised copper as
   the working accent, glowstone amber for warnings, redstone for danger. Type is Bahnschrift (Windows' DIN)
   for the signage feel, Cascadia Mono for every coordinate and clock. No web fonts: nothing external loads. */

:root {
  color-scheme: dark;
  --bg: #161b20;
  --panel: #1c2329;
  --raised: #242d35;
  --sunken: #12171b;
  --line: #2f3943;
  --line-strong: #44515d;
  --ink: #dde3e6;
  --ink-2: #b5c0c7;
  --muted: #8b98a2;
  --accent: #5cc0a7;
  --accent-ink: #0f2a24;
  --accent-soft: rgb(92 192 167 / .14);
  --amber: #e5ad45;
  --amber-soft: rgb(229 173 69 / .16);
  --red: #ef6a5c;
  --red-soft: rgb(239 106 92 / .16);
  --focus: #8fdcc8;
  --map-bg: #10151a;
  --map-grid: rgb(170 190 200 / .07);
  --map-grid-major: rgb(170 190 200 / .14);
  --map-axis: rgb(120 210 190 / .38);
  --map-label: rgb(190 205 212 / .55);
  --map-landmark: rgb(210 220 225 / .5);
  --map-halo: rgb(10 14 17 / .85);
  --map-ink: #e8eef0;
  --shadow: 0 10px 30px rgb(0 0 0 / .45);

  --font: Bahnschrift, "DIN Alternate", "D-DIN", "Barlow", "Roboto Condensed", "Segoe UI", system-ui, sans-serif;
  --mono: "Cascadia Mono", "Cascadia Code", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r-sm: 3px;
  --r: 5px;
  --rail: 196px;
  --topbar: 52px;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #e4e7e2; --panel: #f3f4f0; --raised: #ffffff; --sunken: #dadfd9; --line: #c5ccc6; --line-strong: #9aa59e;
    --ink: #172026; --ink-2: #33414a; --muted: #55626b; --accent: #1b7260; --accent-ink: #ffffff; --accent-soft: rgb(27 114 96 / .12);
    --amber: #8a5800; --amber-soft: rgb(196 132 20 / .18); --red: #b02a1d; --red-soft: rgb(176 42 29 / .12); --focus: #1b7260;
    --map-bg: #eef0eb; --map-grid: rgb(40 60 70 / .08); --map-grid-major: rgb(40 60 70 / .16); --map-axis: rgb(27 114 96 / .5);
    --map-label: rgb(40 55 62 / .62); --map-landmark: rgb(40 55 62 / .55); --map-halo: rgb(245 247 243 / .9); --map-ink: #172026;
    --shadow: 0 10px 30px rgb(30 40 40 / .18);
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #e4e7e2; --panel: #f3f4f0; --raised: #ffffff; --sunken: #dadfd9; --line: #c5ccc6; --line-strong: #9aa59e;
  --ink: #172026; --ink-2: #33414a; --muted: #55626b; --accent: #1b7260; --accent-ink: #ffffff; --accent-soft: rgb(27 114 96 / .12);
  --amber: #8a5800; --amber-soft: rgb(196 132 20 / .18); --red: #b02a1d; --red-soft: rgb(176 42 29 / .12); --focus: #1b7260;
  --map-bg: #eef0eb; --map-grid: rgb(40 60 70 / .08); --map-grid-major: rgb(40 60 70 / .16); --map-axis: rgb(27 114 96 / .5);
  --map-label: rgb(40 55 62 / .62); --map-landmark: rgb(40 55 62 / .55); --map-halo: rgb(245 247 243 / .9); --map-ink: #172026;
  --shadow: 0 10px 30px rgb(30 40 40 / .18);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { accent-color: var(--accent); scrollbar-color: var(--line-strong) transparent; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 var(--font); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: .005em; line-height: 1.2; }
h2 { font-size: 15px; }
h3 { font-size: 13px; color: var(--ink-2); }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }
.sprite { position: absolute; }
.mono, code, kbd, time.mono { font-family: var(--mono); font-size: .92em; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; left: 8px; top: -40px; z-index: 50; background: var(--accent); color: var(--accent-ink); padding: 6px 10px; border-radius: var(--r); }
.skip:focus { top: 8px; }
kbd { border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 3px; padding: 0 4px; font-size: 11px; color: var(--ink-2); }

.boot { display: grid; place-items: center; align-content: center; gap: 10px; height: 100dvh; color: var(--muted); }
.brand-mark { color: var(--accent); flex: none; }

/* ---------- buttons & controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 12px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--raised); color: var(--ink);
  cursor: pointer; white-space: nowrap; font-weight: 500;
}
.btn:hover { border-color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn--primary:hover { filter: brightness(1.08); border-color: var(--accent); }
.btn--ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn--ghost:hover { background: var(--raised); border-color: var(--line); }
.btn--danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 50%, var(--line)); background: transparent; }
.btn--danger-armed { background: var(--red); color: #fff; border-color: var(--red); font-weight: 600; }
.btn--small { min-height: 26px; padding: 0 8px; font-size: 12.5px; }
.btn--icon { width: 32px; padding: 0; }
.btn--wide { width: 100%; }
.btn svg { width: 14px; height: 14px; fill: currentColor; }

.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r); overflow: hidden; background: var(--sunken); }
.seg button {
  min-height: 30px; padding: 0 10px; border: 0; border-right: 1px solid var(--line); background: transparent;
  color: var(--ink-2); cursor: pointer; font-variant-numeric: tabular-nums;
}
.seg button:last-child { border-right: 0; }
.seg button:hover { color: var(--ink); background: var(--raised); }
.seg button[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); box-shadow: inset 0 -2px 0 var(--accent); font-weight: 600; }
.seg button:focus-visible { outline-offset: -2px; }

input:not([type="checkbox"], [type="radio"], [type="range"]), select {
  min-height: 32px; padding: 4px 9px; border-radius: var(--r); border: 1px solid var(--line-strong);
  background: var(--sunken); color: var(--ink); min-width: 0;
}
input::placeholder { color: var(--muted); opacity: .8; }
input:user-invalid { border-color: var(--red); background: var(--red-soft); }
input[type="checkbox"] { width: 15px; height: 15px; margin: 0; }
label.inline { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.ctl { display: inline-flex; align-items: center; gap: 6px; }
.ctl > label { color: var(--muted); font-size: 12.5px; }

.form { display: grid; gap: 14px; }
.field { display: grid; gap: 5px; }
.field label { color: var(--ink-2); font-weight: 500; }
.hint { color: var(--muted); font-size: 12.5px; }
.form__error { color: var(--red); min-height: 1.2em; font-size: 13px; }
.form__error:empty { min-height: 0; }
.form__row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- auth ---------- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px;
  background:
    linear-gradient(var(--map-grid) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, var(--map-grid) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--map-bg);
}
.auth__panel { width: min(380px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 26px 26px 22px; box-shadow: var(--shadow); display: grid; gap: 22px; }
.auth__brand { display: flex; align-items: center; gap: 12px; }
.auth__product { font-size: 18px; font-weight: 600; }
.auth__sub { color: var(--muted); font-size: 13px; }
.auth__title { font-size: 20px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); height: 100dvh; }
.rail { display: flex; flex-direction: column; background: var(--panel); border-right: 1px solid var(--line); min-height: 0; }
.rail__top { display: flex; align-items: center; justify-content: space-between; height: var(--topbar); padding: 0 14px; border-bottom: 1px solid var(--line); }
.rail__menu { display: none; }
.brand { display: flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; }
.brand__name { font-weight: 600; font-size: 15px; }
.brand__tag { color: var(--accent); font-weight: 500; }
.nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--r);
  color: var(--ink-2); text-decoration: none; font-size: 14px; border-left: 2px solid transparent;
}
.nav a svg { width: 15px; height: 15px; fill: currentColor; opacity: .75; flex: none; }
.nav a svg .o { fill: none; stroke: currentColor; stroke-width: 1.4; }
.nav a:hover { background: var(--raised); color: var(--ink); }
.nav a[aria-current="page"] { background: var(--accent-soft); color: var(--ink); border-left-color: var(--accent); font-weight: 600; }
.nav a[aria-current="page"] svg { opacity: 1; color: var(--accent); }
.rail__user { border-top: 1px solid var(--line); padding: 8px; position: relative; }
.user-btn {
  width: 100%; display: grid; text-align: left; gap: 0; padding: 7px 10px; border-radius: var(--r);
  border: 1px solid transparent; background: transparent; cursor: pointer;
}
.user-btn:hover { background: var(--raised); border-color: var(--line); }
.user-btn__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.user-btn__role { color: var(--muted); font-size: 12px; }

.menu {
  margin: 0; inset: auto; position: fixed; min-width: 190px; padding: 5px;
  background: var(--raised); color: var(--ink); border: 1px solid var(--line-strong); border-radius: var(--r);
  box-shadow: var(--shadow);
}
.menu button {
  display: block; width: 100%; text-align: left; padding: 7px 10px; border: 0; border-radius: var(--r-sm);
  background: transparent; cursor: pointer; color: var(--ink);
}
.menu button:hover, .menu button:focus-visible { background: var(--accent-soft); outline: none; }
.menu__group { border-block: 1px solid var(--line); margin: 4px 0; padding: 4px 0; }
.menu__label { display: block; padding: 2px 10px; color: var(--muted); font-size: 12px; }
.menu [aria-checked="true"]::after { content: "  ✓"; color: var(--accent); }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap; min-height: var(--topbar); padding: 8px 18px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.topbar h1 { font-size: 19px; margin-right: auto; }
.topbar h1:focus { outline: none; }
.topbar__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.view { flex: 1; min-height: 0; overflow: auto; padding: 18px; }
.view:focus { outline: none; }
.view--fill { padding: 0; overflow: hidden; display: flex; flex-direction: column; }

/* ---------- generic blocks ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.panel__head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.panel__head h2 { margin-right: auto; }
.panel__body { padding: 14px; }
.stack { display: grid; gap: 16px; align-content: start; min-width: 0; }
.stack > * { min-width: 0; }
.toolbar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.summary { color: var(--ink-2); }
.summary strong { color: var(--ink); }

.state { display: grid; justify-items: start; gap: 6px; padding: 28px 22px; max-width: 60ch; }
.state--center { justify-items: center; text-align: center; margin: auto; }
.state__title { font-size: 16px; font-weight: 600; }
.state__body { color: var(--muted); }
.state--error .state__title { color: var(--red); }
.spinner { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.banner { padding: 7px 12px; border-radius: var(--r); background: var(--red-soft); color: var(--red); font-size: 13px; }
.banner--warn { background: var(--amber-soft); color: var(--amber); }

.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 0 6px; height: 19px; border-radius: 3px;
  font-size: 11.5px; font-weight: 600; border: 1px solid var(--line-strong); color: var(--ink-2); white-space: nowrap; vertical-align: middle;
}
.badge--member { border-color: color-mix(in srgb, var(--accent) 60%, transparent); color: var(--accent); }
.badge--amber { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.badge--grey { color: var(--muted); border-style: dashed; }
.badge--red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge--stance-ally { color: var(--accent); }
.badge--stance-hostile, .badge--stance-pos { color: var(--red); border-color: color-mix(in srgb, var(--red) 55%, transparent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); vertical-align: middle; }
.dot--on { background: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; box-shadow: inset 0 0 0 1px rgb(0 0 0 / .35); }
.pname { font-weight: 600; text-decoration: none; }
a.pname:hover { text-decoration: underline; }

/* stat tiles (Live) */
.tiles { display: flex; gap: 1px; background: var(--line); border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.tile { flex: 1 1 0; min-width: 130px; background: var(--panel); padding: 9px 16px 8px; display: grid; gap: 0; }
.tile__value { font-family: var(--mono); font-size: 24px; line-height: 1.1; font-weight: 600; }
.tile__label { color: var(--muted); font-size: 12.5px; }
.tile--alert .tile__value { color: var(--red); }
.tile--warn .tile__value { color: var(--amber); }

/* ---------- tables ---------- */
.table-wrap { overflow: auto; container-type: inline-size; max-width: 100%; position: relative; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 13.5px; }
table.data caption { text-align: left; padding: 0 0 8px; color: var(--muted); }
table.data th, table.data td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data thead th {
  position: sticky; top: 0; z-index: 1; background: var(--panel); color: var(--muted); font-weight: 500; font-size: 12.5px;
  border-bottom-color: var(--line-strong);
}
table.data th.num, table.data td.num { text-align: right; }
table.data tbody tr:hover { background: var(--raised); }
table.data tbody tr.is-clickable { cursor: pointer; }
table.data tbody tr.is-selected { background: var(--accent-soft); }
table.data td.wrap { white-space: normal; min-width: 18ch; }
.sort-btn { all: unset; cursor: pointer; display: inline-flex; gap: 4px; align-items: center; color: inherit; }
.sort-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.sort-btn::after { content: ""; width: 0; height: 0; border: 4px solid transparent; opacity: .35; border-top-color: currentColor; margin-top: 4px; }
th[aria-sort="ascending"] .sort-btn::after { border-top-color: transparent; border-bottom-color: currentColor; margin-top: -4px; opacity: 1; }
th[aria-sort="descending"] .sort-btn::after { opacity: 1; }
th[aria-sort] { color: var(--ink) !important; }
.countdown--soon { color: var(--amber); }
.countdown--urgent { color: var(--red); font-weight: 600; }
.countdown--past { color: var(--red); }

@container (width < 560px) {
  table.data, table.data thead, table.data tbody, table.data tr, table.data th, table.data td { display: block; }
  table.data thead { display: none; }
  table.data tr { padding: 8px 4px; border-bottom: 1px solid var(--line); }
  table.data td, table.data tbody th { border: 0; padding: 2px 6px; white-space: normal; text-align: left !important; }
  table.data td[data-label]::before { content: attr(data-label) "  "; color: var(--muted); font-size: 12px; }
}

/* ---------- map ---------- */
.map { position: relative; overflow: hidden; background: var(--map-bg); min-height: 200px; isolation: isolate; }
.map__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.map__canvas:active { cursor: grabbing; }
.map__canvas:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.map__tools { position: absolute; top: 10px; right: 10px; display: grid; gap: 4px; z-index: 2; }
.map__tools .btn { width: 32px; height: 32px; padding: 0; min-height: 0; background: color-mix(in srgb, var(--raised) 88%, transparent); font-size: 16px; }
.map__readout {
  position: absolute; left: 10px; bottom: 10px; z-index: 2; font-family: var(--mono); font-size: 11.5px; color: var(--ink-2);
  background: color-mix(in srgb, var(--panel) 82%, transparent); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px 7px;
  pointer-events: none; white-space: nowrap;
}
.map__scale { position: absolute; right: 10px; bottom: 10px; z-index: 2; pointer-events: none; display: grid; justify-items: end; gap: 2px; font-family: var(--mono); font-size: 11px; color: var(--ink-2); }
.map__scale-bar { height: 6px; border: 1.5px solid var(--ink-2); border-top: 0; }
.map__compass { position: absolute; left: 10px; top: 10px; z-index: 2; pointer-events: none; font-family: var(--mono); font-size: 10.5px; color: var(--muted); line-height: 1.2;
  background: color-mix(in srgb, var(--panel) 70%, transparent); border-radius: var(--r-sm); padding: 3px 6px; }
.map__tip {
  position: absolute; z-index: 5; pointer-events: none; max-width: 280px; padding: 7px 9px; border-radius: var(--r);
  background: var(--raised); border: 1px solid var(--line-strong); box-shadow: var(--shadow); font-size: 12.5px; display: grid; gap: 2px;
}
.map__tip strong { font-size: 13.5px; }
.map__tip .mono { color: var(--ink-2); }
.map__tip .tip-sub { color: var(--muted); }
.map__tip .hbar { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-top: 3px; width: 120px; }
.map__tip .hbar > i { display: block; height: 100%; background: var(--accent); }
.map__tip .hbar--low > i { background: var(--red); }
.map__overlay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 3; pointer-events: none; }
.map__overlay > * { pointer-events: auto; background: color-mix(in srgb, var(--panel) 92%, transparent); border: 1px solid var(--line); border-radius: 6px; }

/* map + side panel layout */
.split { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 330px; }
.split > .map { min-height: 0; }
.side { border-left: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.side__section { display: flex; flex-direction: column; min-height: 0; }
.side__section + .side__section { border-top: 1px solid var(--line); }
.side__head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; flex: none; }
.side__head h2 { margin-right: auto; font-size: 14px; }
.side__head .count { font-family: var(--mono); color: var(--muted); font-size: 12px; }
.side__scroll { overflow-y: auto; min-height: 0; flex: 1; }
.page-bar { display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 8px 14px; border-bottom: 1px solid var(--line); background: var(--panel); flex: none; }
.page-bar .status { margin-left: auto; color: var(--muted); font-size: 12.5px; display: inline-flex; gap: 6px; align-items: center; }

.plist { list-style: none; margin: 0; padding: 0; }
.plist li + li { border-top: 1px solid var(--line); }
.prow {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 9px; align-items: center; width: 100%;
  padding: 7px 12px; background: transparent; border: 0; text-align: left; cursor: pointer;
}
.prow:hover { background: var(--raised); }
.prow .swatch { grid-row: span 2; width: 9px; height: 9px; border-radius: 50%; }
.prow__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow__meta { grid-column: 2 / 4; color: var(--muted); font-size: 12px; font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow__aside { font-size: 12px; color: var(--muted); white-space: nowrap; }
.prow.is-elsewhere { opacity: .62; }
.hp { display: inline-block; width: 34px; height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; vertical-align: middle; }
.hp > i { display: block; height: 100%; background: var(--accent); }
.hp--low > i { background: var(--red); }

/* ---------- replay ---------- */
.replay { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 330px; grid-template-rows: minmax(0, 1fr) auto; }
.replay > .map { grid-column: 1; grid-row: 1; }
.replay > .side { grid-column: 2; grid-row: 1 / 3; }
.dock { grid-column: 1; grid-row: 2; border-top: 1px solid var(--line); background: var(--panel); padding: 10px 14px 10px; display: grid; gap: 8px; min-width: 0; }
.dock__row { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; min-width: 0; }
.clock { display: grid; line-height: 1; margin-right: 6px; }
.clock__time { font-family: var(--mono); font-size: 34px; font-weight: 600; letter-spacing: -.01em; color: var(--ink); }
.clock__date { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.play-btn { width: 44px; height: 44px; border-radius: 50%; padding: 0; background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.play-btn svg { width: 18px; height: 18px; }
.play-btn:disabled { background: var(--raised); border-color: var(--line-strong); color: var(--muted); }
.dock .seg button { min-width: 38px; padding: 0 7px; font-family: var(--mono); font-size: 12.5px; }
.scrub { position: relative; display: grid; gap: 0; user-select: none; touch-action: none; }
.scrub__canvas { width: 100%; height: 76px; display: block; cursor: ew-resize; touch-action: none; }
.scrub__range { position: absolute; left: 0; right: 0; top: 18px; width: 100%; margin: 0; height: 22px; opacity: 0; pointer-events: none; }
.scrub__range:focus-visible + .scrub__focus { display: block; }
.scrub__focus { display: none; position: absolute; inset: 15px -3px 34px; border: 2px solid var(--focus); border-radius: 4px; pointer-events: none; }
.shortcuts { color: var(--muted); font-size: 12px; display: flex; gap: 4px 14px; flex-wrap: wrap; }
.trackrow { display: grid; grid-template-columns: auto auto minmax(0, 1fr) auto auto; gap: 0 7px; align-items: center; padding: 5px 10px 5px 12px; }
.trackrow:hover { background: var(--raised); }
.trackrow input { cursor: pointer; }
.trackrow label { display: flex; align-items: center; gap: 7px; min-width: 0; cursor: pointer; }
.trackrow .swatch { width: 10px; height: 10px; border-radius: 50%; }
.trackrow .swatch--sighted { border-radius: 1px; transform: rotate(45deg) scale(.85); }
.trackrow__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trackrow__pos { font-family: var(--mono); font-size: 11px; color: var(--muted); white-space: nowrap; text-align: right; overflow: hidden; text-overflow: ellipsis; }
.trackrow.is-off .trackrow__name { color: var(--muted); font-weight: 400; }

.tbtn { border: 1px solid transparent; background: transparent; color: var(--muted); border-radius: var(--r-sm); padding: 1px 5px; font-size: 11.5px; cursor: pointer; }
.tbtn:hover { border-color: var(--line-strong); color: var(--ink); }
.tbtn[aria-pressed="true"] { background: var(--accent-soft); color: var(--ink); border-color: var(--accent); }
.group-label { padding: 8px 12px 3px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { border-top: 1px solid var(--line); }
.feed button {
  display: grid; grid-template-columns: 58px 10px minmax(0, 1fr); gap: 1px 8px; width: 100%; text-align: left; padding: 6px 12px;
  background: transparent; border: 0; cursor: pointer; align-items: baseline;
}
.feed button:hover { background: var(--raised); }
.feed time { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.feed .ev-mark { width: 8px; height: 8px; border-radius: 50%; align-self: center; }
.feed .ev-text { font-size: 12.5px; color: var(--ink-2); overflow-wrap: anywhere; }
.feed li.is-future .ev-text, .feed li.is-future time { color: var(--muted); }

.feed li.is-future .ev-mark { opacity: .45; }
.feed li.is-current button { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
.feed li.is-current time { color: var(--ink); }
.ev--snitch { background: var(--amber); }
.ev--death { background: var(--red); }
.ev--combat { background: #f08a3c; }
.ev--session { background: var(--accent); }
.chips { display: flex; gap: 4px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px 1px 6px; font-size: 12px; background: transparent; color: var(--ink-2); cursor: pointer; }
.chip[aria-pressed="false"] { opacity: .45; }
.chip .ev-mark { width: 7px; height: 7px; border-radius: 50%; }

/* ---------- heat chart (weekday x hour) ---------- */
.heat { display: grid; gap: 8px; min-width: 0; margin: 0; }
.heat__scroll { overflow-x: auto; min-width: 0; position: relative; }
table.heatgrid { border-collapse: separate; border-spacing: 2px; table-layout: fixed; width: 100%; min-width: 520px; }
table.heatgrid th { font-weight: 400; color: var(--muted); font-size: 11px; font-family: var(--mono); padding: 0; }
table.heatgrid thead th { height: 16px; text-align: left; }
table.heatgrid tbody th { text-align: right; padding-right: 6px; width: 38px; font-family: var(--font); font-size: 12px; }
table.heatgrid thead td { background: transparent; }
table.heatgrid td { height: 20px; border-radius: 2px; padding: 0; background: var(--sunken); }
table.heatgrid td:hover { outline: 1.5px solid var(--ink); outline-offset: 0; }
.heat__legend { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.heat__ramp { width: 120px; height: 8px; border-radius: 2px; }
.heat__tip { min-height: 1.4em; font-size: 12.5px; color: var(--ink-2); font-family: var(--mono); }

/* ---------- player profile ---------- */
.profile { display: grid; gap: 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; }
.profile > * { grid-column: span 12; min-width: 0; }
.p-head { display: flex; align-items: flex-end; gap: 10px 18px; flex-wrap: wrap; }
.p-head__name { font-size: 28px; font-weight: 600; line-height: 1.1; }
.p-head__meta { display: flex; gap: 6px 14px; flex-wrap: wrap; color: var(--muted); align-items: center; }
.counts { display: flex; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 6px; overflow: hidden; flex-wrap: wrap; }
.counts > div { flex: 1 1 110px; background: var(--panel); padding: 8px 14px; display: grid; }
.counts .tile__value { font-size: 22px; }
.minimap { height: 340px; border-radius: 6px; border: 1px solid var(--line); }
.gear { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.gear li { padding: 8px 0; border-top: 1px solid var(--line); display: grid; gap: 3px; }
.gear li:first-child { border-top: 0; }
.gear__slots { display: flex; flex-wrap: wrap; gap: 4px; }
.gear__slot { font-size: 12.5px; padding: 1px 7px; border-radius: 3px; background: var(--sunken); border: 1px solid var(--line); }
.gear__slot span { color: var(--muted); margin-right: 4px; font-size: 11px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { padding: 6px 0; border-top: 1px solid var(--line); display: flex; gap: 10px; align-items: baseline; }
.list-plain li:first-child { border-top: 0; }
.alts { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- pages with map + table ---------- */
.mapgrid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(560px, 46%); }
.mapgrid > .map { min-height: 0; }
.mapgrid__table { border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.mapgrid__table .table-wrap { flex: 1; min-height: 0; }
.legend { display: flex; gap: 6px 14px; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 12.5px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
.heat-legend { position: absolute; left: 10px; top: 10px; z-index: 2; background: color-mix(in srgb, var(--panel) 88%, transparent); border: 1px solid var(--line); border-radius: var(--r); padding: 7px 10px; display: grid; gap: 4px; font-size: 12px; color: var(--ink-2); }
.heat-legend canvas { width: 160px; height: 10px; display: block; border-radius: 2px; }
.heat-legend__scale { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--muted); }

/* ---------- accounts ---------- */
.secret {
  display: grid; gap: 10px; padding: 14px; border-radius: 6px; border: 1px solid color-mix(in srgb, var(--amber) 55%, var(--line));
  background: var(--amber-soft);
}
.secret__pw { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.secret__pw output { font-family: var(--mono); font-size: 17px; padding: 5px 10px; background: var(--sunken); border: 1px solid var(--line-strong); border-radius: var(--r); user-select: all; word-break: break-all; }
.secret__warn { color: var(--amber); font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }

/* ---------- dialog & toast ---------- */
.dialog {
  width: min(420px, calc(100vw - 32px)); padding: 22px; border-radius: 8px; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--ink); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(5 8 10 / .55); }
.dialog h2 { font-size: 18px; }
.toast {
  position: fixed; left: 50%; bottom: 22px; translate: -50% 0; z-index: 100; padding: 9px 14px; border-radius: var(--r);
  background: var(--raised); border: 1px solid var(--line-strong); box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transition: opacity .2s;
}
.toast.is-shown { opacity: 1; }

/* ---------- responsive ---------- */
@media (max-width: 1500px) {
  .mapgrid { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(260px, 1fr) minmax(0, 1fr); }
  .mapgrid__table { border-left: 0; border-top: 1px solid var(--line); }
}
@media (max-width: 1100px) {
  :root { --rail: 168px; }
  .split, .replay { grid-template-columns: minmax(0, 1fr) 280px; }
  .clock__time { font-size: 28px; }
  .two-col { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 1100px) {
  .profile .span-7 { grid-column: span 7; }
  .profile .span-5 { grid-column: span 5; }
  .profile .span-6 { grid-column: span 6; }
}
@media (max-width: 760px) {
  .shell { display: block; height: auto; }
  .rail { position: sticky; top: 0; z-index: 20; border-right: 0; border-bottom: 1px solid var(--line); }
  .rail__top { border-bottom: 0; }
  .rail__menu { display: inline-flex; }
  .rail:not(.is-open) .nav, .rail:not(.is-open) .rail__user { display: none; }
  .nav { max-height: 60dvh; border-top: 1px solid var(--line); }
  .main { min-height: calc(100dvh - var(--topbar)); }
  .topbar { padding: 8px 16px; }
  .view { overflow: visible; padding: 14px 16px; }
  .view--fill { padding: 0; overflow: visible; }
  .split, .replay, .mapgrid { display: flex; flex-direction: column; }
  .split > .map, .replay > .map, .mapgrid > .map { height: 58dvh; flex: none; }
  .side { border-left: 0; border-top: 1px solid var(--line); }
  .side__scroll { max-height: 50dvh; }
  .replay > .side { order: 3; }
  .dock { order: 2; }
  .clock__time { font-size: 26px; }
  .mapgrid__table { border-top: 1px solid var(--line); }
  .mapgrid__table .table-wrap { max-height: none; }
  .tiles { flex-wrap: wrap; }
  .tile { min-width: 0; flex: 1 1 45%; padding: 8px 12px; }
  .tile__value { font-size: 20px; }
  .p-head__name { font-size: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  .toast { transition: none; }
}
@media (forced-colors: active) {
  .seg button[aria-pressed="true"], .tbtn[aria-pressed="true"] { outline: 2px solid CanvasText; }
}

.linkbtn { all: unset; cursor: pointer; color: inherit; }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 2px; }
.linkbtn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.linkbtn.mono { font-family: var(--mono); font-size: .92em; }

/* world switch */
.seg--world button[data-value="zorweth"][aria-pressed="true"] { box-shadow: inset 0 -2px 0 var(--amber); background: var(--amber-soft); }
.seg__count {
  display: inline-block; min-width: 17px; margin-left: 6px; padding: 0 4px; border-radius: 9px; font-family: var(--mono); font-size: 11px;
  line-height: 16px; text-align: center; background: var(--raised); border: 1px solid var(--line-strong); color: var(--ink);
}
.world-note { padding: 6px 12px 10px; }
.world-note button { all: unset; cursor: pointer; color: var(--muted); font-size: 12.5px; text-decoration: underline; text-underline-offset: 2px; }
.world-note button:hover { color: var(--ink); }
.world-note button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.world-tag { color: var(--amber); }
