/* Layout concept: Grafana-style operations console. Fixed top bar, left section nav, collapsible rows of panels with a header bar each,
   stat tiles with sparklines. Dark is the home theme; light and "auto" follow the same tokens. Panels only ever use the tokens below. */
:root {
  color-scheme: light;
  --page: #f2f3f5;
  --surface-1: #ffffff;
  --panel-head: #fafbfc;
  --bar: #ffffff;
  --text-primary: #1f2329;
  --text-secondary: #4b525c;
  --text-muted: #6d7480;
  --grid: #dde0e5;
  --track: #e8eaee;
  --hover: #f0f2f5;
  --s1: #3274d9; --s2: #e5640f; --s3: #2f8a3c; --s4: #b98b00; --s5: #8f3bb8; --other: #8b919b;
  --good: #1a7f37; --warning: #b98b00; --serious: #d9631a; --critical: #d1242f;
  --accent: #3274d9;
  --radius: 6px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --page: #0e1014; --surface-1: #171a1f; --panel-head: #1a1d23; --bar: #13161a;
    --text-primary: #d9dae0; --text-secondary: #a9acb8; --text-muted: #7b8090;
    --grid: #272b33; --track: #23272e; --hover: #1f232a;
    --s1: #5794f2; --s2: #ff9830; --s3: #73bf69; --s4: #f2cc0c; --s5: #b877d9; --other: #6b7280;
    --good: #73bf69; --warning: #f2cc0c; --serious: #ff9830; --critical: #f2495c; --accent: #6e9fff;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0e1014; --surface-1: #171a1f; --panel-head: #1a1d23; --bar: #13161a;
  --text-primary: #d9dae0; --text-secondary: #a9acb8; --text-muted: #7b8090;
  --grid: #272b33; --track: #23272e; --hover: #1f232a;
  --s1: #5794f2; --s2: #ff9830; --s3: #73bf69; --s4: #f2cc0c; --s5: #b877d9; --other: #6b7280;
  --good: #73bf69; --warning: #f2cc0c; --serious: #ff9830; --critical: #f2495c; --accent: #6e9fff;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--page); scroll-padding-top: 64px; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--page); color: var(--text-primary);
  font: 13px/1.45 var(--font); font-feature-settings: "cv11", "ss01";
  -webkit-text-size-adjust: 100%;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
.muted { color: var(--text-muted); }
.sec { color: var(--text-secondary); }
.spacer { flex: 1; }
button.ghost {
  font: inherit; color: var(--text-secondary); background: transparent; border: 1px solid var(--grid);
  border-radius: 4px; padding: 3px 9px; cursor: pointer; line-height: 1.3;
}
button.ghost:hover { color: var(--text-primary); background: var(--hover); }
button.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; }
button:focus-visible, summary:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; height: 48px;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px));
  background: var(--bar); border-bottom: 1px solid var(--grid);
}
/* which proxy container answers (js/instance.js sets data-instance on <html>): a thin tinted line under the header, no layout shift */
:root { --inst-blue: #3b82f6; --inst-green: #22c55e; }
html[data-instance="blue"] { --inst: var(--inst-blue); }
html[data-instance="green"] { --inst: var(--inst-green); }
html[data-instance] .topbar { box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--inst) 70%, transparent); }
/* "Why sessions ended" (panels/reasons.js): one stacked bar, then the groups side by side with their reasons as compact rows */
.why-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px 24px; margin-top: 14px; }
.why-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13.5px; }
.why-head b { font-weight: 600; }
.why-head span { margin-left: auto; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.why-row { position: relative; }
.why-dot { position: absolute; left: 3px; top: 50%; width: 8px; height: 8px; border-radius: 2px; transform: translateY(-50%); }
.why-row { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0 2px 16px; font-size: 12.5px; color: var(--text-secondary); }
.why-row .why-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.why-row span:last-child { flex: none; font-variant-numeric: tabular-nums; }
.tier-rows { display: grid; gap: 6px; margin: 6px 0 14px; }
.tier-row { display: flex; align-items: baseline; gap: 12px; }
.tier-row .num-mid { flex: none; min-width: 52px; font-size: 26px; font-weight: 600; line-height: 1.1; letter-spacing: -0.01em; text-align: right; font-variant-numeric: tabular-nums; }
.tier-row .tier-label { font-size: 13.5px; }
.tier-row.dim .tier-label { color: var(--text-secondary); }
.tier-row.dim .num-mid { font-size: 20px; opacity: 0.85; }
.inst { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; padding: 1px 9px; border-radius: 999px; white-space: nowrap; color: var(--text-secondary); border: 1px solid color-mix(in srgb, var(--inst) 55%, var(--grid)); background: var(--surface-1); cursor: default; }
.inst[hidden] { display: none; }
.inst i { width: 7px; height: 7px; border-radius: 50%; background: var(--inst); }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand svg { flex: none; color: var(--s2); }
h1 { font-size: 15px; font-weight: 600; margin: 0; letter-spacing: -0.005em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { display: inline-flex; align-items: center; gap: 7px; border-radius: 999px; padding: 2px 11px 2px 4px; font-weight: 500; font-size: 12px; background: var(--surface-1); border: 1px solid var(--grid); white-space: nowrap; }
.pill svg { flex: none; width: 16px; height: 16px; }
.live { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: 12px; white-space: nowrap; }
.live i { width: 7px; height: 7px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent); animation: beat 2.4s ease-out infinite; }
@keyframes beat { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 55%, transparent); } 70%, 100% { box-shadow: 0 0 0 7px transparent; } }
@media (prefers-reduced-motion: reduce) { .live i { animation: none; } }
header #uptime:not(:empty)::after { content: ' ·'; margin-left: 2px; }
@media (max-width: 700px) { .topbar .live, .topbar #uptime { display: none; } }

/* ---- shell: nav + content ---- */
.app { display: grid; grid-template-columns: 200px minmax(0, 1fr); align-items: start; }
#nav { position: sticky; top: 48px; align-self: start; height: calc(100vh - 48px); overflow-y: auto; padding: 14px 8px 20px max(10px, env(safe-area-inset-left, 0px)); border-right: 1px solid var(--grid); background: var(--bar); }
#nav .nav-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); padding: 0 10px 8px; }
#nav a { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border-radius: 4px; color: var(--text-secondary); text-decoration: none; font-size: 13px; border-left: 2px solid transparent; }
#nav a:hover { background: var(--hover); color: var(--text-primary); }
#nav a[aria-current="true"] { background: var(--hover); color: var(--text-primary); border-left-color: var(--accent); }
#nav a svg { flex: none; opacity: .75; }
#nav a.nav-out { margin-top: 10px; border-top: 1px solid var(--grid); border-radius: 0 0 4px 4px; padding-top: 10px; }
main { min-width: 0; max-width: 1680px; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 48px 16px; }
@media (max-width: 900px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  #nav { position: sticky; top: 48px; z-index: 15; display: flex; gap: 4px; height: auto; overflow-x: auto; overflow-y: hidden; padding: 6px 12px; border-right: 0; border-bottom: 1px solid var(--grid); }
  #nav .nav-title { display: none; }
  #nav a { white-space: nowrap; border-left: 0; border-bottom: 2px solid transparent; border-radius: 4px 4px 0 0; padding: 5px 10px; }
  #nav a[aria-current="true"] { border-bottom-color: var(--accent); }
  main { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
}
.issues { margin: 0 0 12px; padding: 9px 12px; border-radius: var(--radius); background: var(--surface-1); border: 1px solid var(--grid); border-left: 3px solid var(--warning); color: var(--text-secondary); }
.issues:empty { display: none; }
.issues b { color: var(--text-primary); }
.issues + .issues { margin-top: -4px; }

/* ---- rows and the panel grid ---- */
.row { margin-bottom: 8px; }
.row-head {
  display: flex; align-items: center; gap: 8px; width: 100%; margin: 14px 0 8px; padding: 4px 2px; background: none; border: 0; border-radius: 4px;
  font: inherit; font-size: 14px; font-weight: 500; color: var(--text-primary); cursor: pointer; text-align: left;
}
.row-head:hover { background: var(--hover); }
.row-head svg { flex: none; color: var(--text-muted); transition: transform .15s; }
.row.collapsed .row-head svg { transform: rotate(-90deg); }
.row.collapsed > .grid { display: none; }
.row > .row-head:first-child { margin-top: 4px; }
.grid { display: grid; gap: 8px; }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1000px) { .cols-3, .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .cols-2, .cols-3, .cols-4 { grid-template-columns: minmax(0, 1fr); } }

/* ---- panel ---- */
.card { background: var(--surface-1); border: 1px solid var(--grid); border-radius: var(--radius); padding: 12px; min-width: 0; }
.card-head {
  display: flex; align-items: flex-start; gap: 8px; margin: -12px -12px 12px; padding: 9px 12px;
  background: var(--panel-head); border-bottom: 1px solid var(--grid); border-radius: var(--radius) var(--radius) 0 0;
}
.card-head .spacer { flex: 1; }
.card h2 { font-size: 13px; font-weight: 600; margin: 0; color: var(--text-primary); letter-spacing: 0; }
.card .sub { color: var(--text-muted); font-size: 11.5px; margin-top: 1px; line-height: 1.35; }
.chart { position: relative; min-height: 40px; }
.chart svg { display: block; overflow: visible; }
.chart text { fill: var(--text-muted); font-size: 10.5px; font-family: var(--font); }
.card > .muted:only-child { padding: 6px 0; }

/* hero: the live number */
.hero { position: relative; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 32px; padding: 18px 22px 30px; min-height: 112px; }
.hero-main { display: flex; align-items: baseline; gap: 10px; }
.hero > * { position: relative; z-index: 1; }
.hero .num { font-size: 60px; line-height: 1; font-weight: 600; letter-spacing: -0.035em; font-variant-numeric: tabular-nums; }
.hero .label { font-size: 14px; color: var(--text-secondary); }
.hero .facts { color: var(--text-secondary); font-size: 14px; }
.hero .facts b { color: var(--text-primary); font-weight: 600; }
.hero .live-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--good); align-self: center; }
.hero .spark, .tile .spark { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; z-index: 0; pointer-events: none; }
.hero .spark { height: 34px; }

/* stat tiles */
.tiles { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
@media (max-width: 1500px) { .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1200px) { .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 560px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } .hero .num { font-size: 48px; } }
.tile { position: relative; overflow: hidden; padding: 12px 14px 44px; min-height: 124px; }
.tile > *:not(.spark) { position: relative; z-index: 1; }
.tile .label { color: var(--text-secondary); font-size: 12px; font-weight: 500; }
.tile .value { font-size: 28px; font-weight: 600; line-height: 1.15; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; }
.tile .note { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; }
.tile .spark { height: 32px; }
.tile.empty { background: transparent; border-style: dashed; }
.tile .delta { font-size: 11.5px; font-weight: 500; margin-left: 6px; }
.tile .delta.up { color: var(--good); } .tile .delta.down { color: var(--critical); }
.num-big { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }

.section-title { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--text-muted); margin: 18px 2px 8px; }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
th, td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
th { color: var(--text-muted); font-weight: 500; font-size: 11px; letter-spacing: .03em; background: var(--panel-head); }
tbody tr:hover td { background: var(--hover); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }
tr:last-child td { border-bottom: 0; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 10px; color: var(--text-secondary); font-size: 11.5px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex: none; }

/* bar gauge lists */
.hbar { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 3px 10px; padding: 5px 0; }
.hbar .name { color: var(--text-primary); min-width: 0; overflow-wrap: anywhere; font-size: 12.5px; }
.hbar .track { grid-column: 1 / -1; order: 3; height: 6px; background: var(--track); border-radius: 3px; position: relative; overflow: hidden; }
.hbar .fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.hbar .val { color: var(--text-secondary); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; font-size: 12px; }
/* a bar that belongs to the one above it (the "finished" share under a place): indented, with a guide line, so the two read as a pair */
.hbar.sub { margin-left: 14px; padding-left: 10px; border-left: 2px solid color-mix(in srgb, var(--good) 55%, transparent); }
.hbar.sub .name { color: var(--text-secondary); white-space: nowrap; overflow-wrap: normal; }
.hbar.sub { grid-template-columns: auto minmax(0, 1fr); }
.hbar.sub .val { white-space: normal; min-width: 0; }
@media (max-width: 600px) { .hbar.sub { margin-left: 6px; padding-left: 8px; } }
.replay-fps { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; cursor: pointer; font-size: 12px; }
.replay-fps[hidden] { display: none; }

.split { display: flex; height: 12px; gap: 2px; border-radius: 3px; overflow: hidden; margin: 6px 0 4px; background: var(--track); }
.split i { display: block; height: 100%; min-width: 2px; }
.state { display: inline-flex; align-items: center; gap: 6px; }

.who { margin-top: 12px; border-top: 1px solid var(--grid); padding-top: 10px; }
.who .srv { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; padding: 4px 0; align-items: start; }
.who .srv b { font-weight: 600; }
.who .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { border: 1px solid var(--grid); background: var(--track); border-radius: 4px; padding: 1px 8px; font-size: 11.5px; color: var(--text-secondary); white-space: nowrap; font-family: var(--mono); }
.chip i { font-style: normal; color: var(--text-muted); margin-left: 6px; }
details.more { margin-top: 10px; }
details.more summary { cursor: pointer; color: var(--text-secondary); font-size: 12px; }

#tip { position: fixed; z-index: 30; pointer-events: none; background: var(--panel-head); color: var(--text-primary); border: 1px solid var(--grid);
  border-radius: 4px; padding: 7px 10px; font-size: 12px; box-shadow: 0 6px 20px rgba(0,0,0,.35); display: none; max-width: 280px; }
#tip b { font-weight: 600; }
#tip .row { display: flex; gap: 8px; align-items: center; margin: 0; }
footer { margin-top: 20px; color: var(--text-muted); font-size: 12px; }
footer p { margin: 4px 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; font-size: 13px; }
.kv dt { color: var(--text-muted); } .kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.tabs { display: inline-flex; flex: none; border: 1px solid var(--grid); border-radius: 4px; overflow: hidden; background: var(--surface-1); }
.tabs button.ghost { border: 0; border-radius: 0; padding: 2px 9px; font-size: 11.5px; }
.tabs button.ghost + button.ghost { border-left: 1px solid var(--grid); }
.tabs button[aria-pressed="true"] { background: var(--accent); color: #fff; }
.card-head > button.ghost { font-size: 11.5px; padding: 2px 9px; }

.map { position: relative; }
.map svg { display: block; width: 100%; height: auto; overflow: visible; }
.map.zoom svg { overflow: hidden; max-height: 520px; }
.map .land { fill: var(--track); stroke: var(--surface-1); stroke-width: .6; }
.map .land.hit { fill: var(--s1); }
.map .land:hover, .map .dot:hover { stroke: var(--text-primary); stroke-width: 1; }
.map .dot { fill: var(--s2); fill-opacity: .72; stroke: var(--surface-1); stroke-width: .8; }
.map-legend { display: flex; align-items: center; gap: 8px; color: var(--text-muted); font-size: 11.5px; margin: 6px 0 2px; }
.map-legend i { display: block; width: 120px; height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--track), var(--s1)); }
.map-legend .dotkey { display: inline-flex; align-items: center; gap: 5px; margin-left: 12px; }
.map-legend .dotkey b { width: 9px; height: 9px; border-radius: 50%; background: var(--s2); opacity: .72; display: inline-block; }
.cols-in { display: grid; gap: 4px 24px; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 10px; }
@media (max-width: 820px) { .cols-in { grid-template-columns: minmax(0, 1fr); } }
.cols-in.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 820px) { .cols-in.two { grid-template-columns: minmax(0, 1fr); } }
.col-title .muted { text-transform: none; letter-spacing: 0; font-weight: 400; }
.col-title { font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--text-muted); margin: 10px 0 0; display: flex; align-items: center; gap: 8px; }
.col-title .tabs { margin-left: auto; }

.statline { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; margin: 2px 0 8px; }

/* ---- sessions page ---- */
.fresh-pill { position: fixed; z-index: 12; left: 50%; top: 64px; transform: translateX(-50%); font: 600 12px var(--font); color: #fff; background: var(--accent); border: 0; border-radius: 999px; padding: 6px 14px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.35); }
tr.fresh td { animation: fresh 2.4s ease-out; }
@keyframes fresh { from { background: color-mix(in srgb, var(--accent) 28%, transparent); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { tr.fresh td { animation: none; } }
.sessions-main { max-width: 1900px; margin: 0 auto; padding: 16px max(16px, env(safe-area-inset-right, 0px)) 48px max(16px, env(safe-area-inset-left, 0px)); }
.topbar .back { color: var(--text-secondary); text-decoration: none; font-size: 13px; margin-left: 8px; }
.topbar .back:hover { color: var(--text-primary); }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.filters input { font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--grid); border-radius: 4px; padding: 5px 10px; min-width: 260px; flex: 1 1 260px; max-width: 420px; }
.filters input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.tablecard { padding: 0; }
.tablecard .scroll { max-height: calc(100vh - 170px); overflow: auto; }
table.sessions { font-size: 12.5px; }
table.sessions thead th { position: sticky; top: 0; z-index: 2; box-shadow: 0 1px 0 var(--grid); }
table.sessions td { vertical-align: middle; padding: 6px 10px; }
.clip { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip.url { max-width: 300px; font-family: var(--mono); font-size: 11.5px; color: var(--text-secondary); }
.mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-secondary); }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px 2px 7px; border-radius: 999px; font-weight: 500; font-size: 12px; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); border: 1px solid color-mix(in srgb, var(--c) 35%, transparent); }
.status i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }
.pl-name { font-family: var(--mono); font-size: 12px; }
.uid { font: 11px var(--mono); color: var(--text-muted); background: none; border: 0; padding: 0; cursor: pointer; }
.uid:hover { color: var(--text-primary); text-decoration: underline dotted; }
.tag { font-size: 10.5px; color: var(--s5); border: 1px solid color-mix(in srgb, var(--s5) 45%, transparent); border-radius: 3px; padding: 0 4px; margin-left: 4px; }
.sentinel { height: 1px; }
.state-line { padding: 10px 14px 14px; }
.gate { max-width: 420px; margin: 12vh auto 0; display: flex; flex-direction: column; gap: 10px; }
.gate input { font: inherit; color: var(--text-primary); background: var(--page); border: 1px solid var(--grid); border-radius: 4px; padding: 7px 10px; }
.gate-error { color: var(--critical); min-height: 1.4em; }
@media (max-width: 700px) { .tablecard .scroll { max-height: none; } }

.progress-tiles { gap: 8px; align-content: start; }
.progress-tiles .tile { min-height: 0; padding-bottom: 12px; }
.progress-tiles .tile .value { margin-top: 2px; }
.nowrap { white-space: nowrap; }
.nth { font-size: 11px; color: var(--text-muted); margin-left: 4px; }
.nth.first { color: var(--good); }

/* session page (recording timeline) */
.session-view { max-width: 1100px; margin: 0 auto; display: grid; gap: 14px; padding: 14px 16px 40px; }
.session-view .card { padding: 14px 16px; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 18px; }
.facts .k { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.facts .v { font-size: 13.5px; margin-top: 1px; overflow-wrap: anywhere; }
.chart-row { display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 8px; margin-top: 6px; }
.chart-row .lab { font-size: 11.5px; color: var(--text-muted); text-align: right; line-height: 1.25; }
.chart-row svg { width: 100%; display: block; overflow: visible; }
.chart-wrap { position: relative; }
.chart-wrap .cursor { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--text-muted); opacity: .55; pointer-events: none; display: none; }
.chart-wrap .playhead { position: absolute; top: -3px; bottom: 0; width: 2px; margin-left: -1px; background: var(--warning); border-radius: 1px; pointer-events: none; display: none; z-index: 2; transition: left .25s linear; }
.chart-wrap .playhead.on { display: block; }
.chart-wrap .playhead::before { content: ''; position: absolute; top: 0; left: 50%; transform: translate(-50%, -100%); border: 5px solid transparent; border-top-color: var(--warning); border-bottom: 0; }
.chart-read { font: 11.5px var(--mono); color: var(--text-secondary); min-height: 16px; margin: 8px 0 0 72px; }
.place-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 8px 0 0 72px; font-size: 11.5px; color: var(--text-secondary); }
.place-legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }
.session-view h2 { font-size: 13px; margin: 0 0 8px; }
a.rec-link { color: var(--s1); text-decoration: none; font-weight: 500; white-space: nowrap; }
a.rec-link:hover { text-decoration: underline; }

/* sessions header: link status */
.live-col { display: flex; flex-direction: column; line-height: 1.25; }
.live-ping { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; opacity: 0.8; }
.live-ping:empty { display: none; }
.live.stale { color: var(--critical); font-weight: 500; }
.live.stale i, .live.paused i, .live.connecting i { animation: none; box-shadow: none; }
.live.stale i { background: var(--critical); }
.live.paused i, .live.connecting i { background: var(--text-muted); }
.sessions-page .topbar .live { display: inline-flex; margin-right: 12px; }

/* sessions table: fill the window (no empty band under it); the table box is the only thing that scrolls */
body.sessions-fill { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
body.sessions-fill .sessions-main { flex: 1; min-height: 0; width: 100%; box-sizing: border-box; display: flex; flex-direction: column; padding-top: 12px; padding-bottom: 12px; }
body.sessions-fill .tablecard { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.sessions-fill .tablecard[hidden], body.sessions-fill .filters[hidden], body.sessions-fill .gate[hidden] { display: none; }
/* the SQL query view of the sessions page */
.sqlbox { padding: 12px; display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.sqlbox[hidden] { display: none; }
.sql-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sql-head select { font: inherit; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--grid); border-radius: 4px; padding: 4px 8px; max-width: 100%; }
.sqlbox textarea { font-family: var(--mono); font-size: 12.5px; color: var(--text-primary); background: var(--surface-1); border: 1px solid var(--grid); border-radius: 4px; padding: 8px 10px; resize: vertical; width: 100%; box-sizing: border-box; }
.sqlbox textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sql-error { color: var(--critical); font-size: 12.5px; white-space: pre-wrap; }
.sql-error:empty { display: none; }
.sql-result { max-height: 60vh; overflow: auto; }
.sql-result th, .sql-result td { white-space: nowrap; }
.sql-help { font-size: 12.5px; color: var(--text-secondary); }
.sql-help code { font-family: var(--mono); font-size: 11.5px; }
.sql-help p { margin: 6px 0; }
body.sessions-fill .tablecard .scroll { flex: 1; min-height: 0; max-height: none; }

/* live sessions: one tile per open session, border colour = hash of the user id */
.live-main { max-width: 1900px; }
.live-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; align-content: start; }
.replay-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.replay-head h2 { margin: 0; }
.replay-stage { aspect-ratio: 16 / 9; min-height: 360px; max-height: 85vh; width: 100%; border-radius: 8px; background: var(--surface-2, rgba(127,127,127,.12)); display: grid; place-items: center; overflow: hidden; text-align: center; padding: 0 16px; }
.replay-stage iframe { width: 100%; height: 100%; border: 0; display: block; background: #000; }
/* the player's own screen shape (js/session.js): the stage keeps the aspect ratio, the frame inside has the player's size in CSS pixels and is scaled to fit */
.replay-stage.fitted { aspect-ratio: var(--ar); width: min(100%, calc(85vh * var(--arn))); min-height: 0; max-height: none; margin: 0 auto; padding: 0; display: block; position: relative; }
.replay-stage.fitted iframe { position: absolute; top: 0; left: 0; max-width: none; transform-origin: 0 0; }
.lt-wrap { min-width: 0; display: grid; transition: opacity .55s ease, transform .55s ease; }
.lt-wrap.entering { opacity: 0; transform: scale(.97); }
.lt-wrap.leaving { opacity: 0; transform: scale(.95); pointer-events: none; }
@media (prefers-reduced-motion: reduce) { .lt-wrap { transition: none; } }
.lt { background: var(--surface-1); border: 2px solid var(--b, var(--grid)); border-radius: 8px; padding: 9px 11px 8px; min-width: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; font-size: 12.5px; }
.lt-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; min-width: 0; }
.lt-head .muted, .lt-head .lt-time { flex: none; }
/* the clocks that tick (js/live.js): full brightness; the player's own local time is dimmed */
.lt-time { font-variant-numeric: tabular-nums; color: var(--text-primary); }
.lt-sub { margin-left: 6px; font-size: 12px; font-weight: 500; }
.lt-dim { color: var(--text-muted); opacity: .75; font-size: 12px; }
.lt-row { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lt-head b { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.lt-place { font-weight: 600; letter-spacing: .02em; }
.lt-row .mono { font: 12px var(--mono); }
.lt-stats { display: flex; gap: 12px; font-variant-numeric: tabular-nums; }
.lt-foot { display: flex; justify-content: space-between; gap: 8px; font-size: 11.5px; border-top: 1px solid var(--grid); padding-top: 4px; margin-top: 2px; }
.lt-clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; max-width: 100%; }

.tz { font-size: 11px; line-height: 1.2; }
.lt-clock { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ---- live wall (/dashboard/wall): the game client in a frame under a slim bar */
.wall-page { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.wall-main { flex: 1; min-height: 0; display: flex; flex-direction: column; position: relative; max-width: none; width: 100%; padding: 0; box-sizing: border-box; } /* no margins: the frame fills the page under the bar, like the sessions table */
.wall-stage { flex: 1; min-height: 0; background: #000; }
.wall-stage iframe { width: 100%; height: 100%; border: 0; display: block; }
.wall-main .state-line { position: absolute; left: 0; right: 0; top: 14px; text-align: center; pointer-events: none; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7); color: #fff; }
.wall-max select { margin-left: 4px; }
.wall-emu { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; cursor: pointer; }
.wall-emu[hidden] { display: none; }
.wall-main .gate { margin: 40px auto; }
