/* Phasm telemetry dashboard. One file, no build step. Light and dark from
   prefers-color-scheme; html[data-theme] overrides it. */

:root {
  --bg: #f6f6f7;
  --surface: #ffffff;
  --surface-2: #f1f1f3;
  --surface-3: #e9e9ec;
  --line: #e3e3e7;
  --line-strong: #d1d1d6;
  --text: #18181b;
  --text-2: #4b4b53;
  --text-3: #6b6b74;
  --accent: #4f46e5;
  --accent-soft: #eef0ff;
  --accent-text: #4338ca;
  --ok: #15803d;
  --ok-soft: #e8f6ee;
  --warn: #b45309;
  --warn-soft: #fdf3e3;
  --bad: #c42b2b;
  --bad-soft: #fdecec;
  --info: #1d63c9;
  --info-soft: #e9f1fc;
  --frame-bg: #0d0d10;
  --shadow: 0 1px 2px rgba(16, 16, 24, .05), 0 1px 1px rgba(16, 16, 24, .03);
  --shadow-lg: 0 18px 50px rgba(16, 16, 24, .18);
  --radius: 10px;
  --radius-sm: 7px;
  --rail: 232px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e0e11;
    --surface: #17171b;
    --surface-2: #1e1e23;
    --surface-3: #26262c;
    --line: #2a2a31;
    --line-strong: #3a3a42;
    --text: #f2f2f4;
    --text-2: #c4c4cc;
    --text-3: #9a9aa4;
    --accent: #8b8cf7;
    --accent-soft: #23234a;
    --accent-text: #a5a6ff;
    --ok: #4ade80;
    --ok-soft: #12291c;
    --warn: #fbbf24;
    --warn-soft: #2d2410;
    --bad: #f87171;
    --bad-soft: #321718;
    --info: #60a5fa;
    --info-soft: #14243b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e0e11;
  --surface: #17171b;
  --surface-2: #1e1e23;
  --surface-3: #26262c;
  --line: #2a2a31;
  --line-strong: #3a3a42;
  --text: #f2f2f4;
  --text-2: #c4c4cc;
  --text-3: #9a9aa4;
  --accent: #8b8cf7;
  --accent-soft: #23234a;
  --accent-text: #a5a6ff;
  --ok: #4ade80;
  --ok-soft: #12291c;
  --warn: #fbbf24;
  --warn-soft: #2d2410;
  --bad: #f87171;
  --bad-soft: #321718;
  --info: #60a5fa;
  --info-soft: #14243b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-lg: 0 18px 50px rgba(0, 0, 0, .6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 22px; line-height: 1.25; }
h2 { font-size: 14px; }
p { margin: 0; }
pre, code, .mono { font-family: var(--mono); font-size: 12.5px; }
.icon { flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
[hidden] { display: none !important; }

.muted { color: var(--text-3); }
.small { font-size: 12.5px; }
.ok-text { color: var(--ok); }
.warn-text { color: var(--warn); }
.bad-text { color: var(--bad); }
.accent-text { color: var(--accent-text); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.pad { padding: 4px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.boot { padding: 40px; color: var(--text-3); }

/* ------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  font-weight: 550; cursor: pointer; white-space: nowrap; box-shadow: var(--shadow);
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { height: 28px; padding: 0 9px; font-size: 12.5px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); background: var(--accent); }
:root[data-theme="dark"] .btn.primary { color: #0e0e11; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.primary { color: #0e0e11; } }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn.link { border: 0; background: none; box-shadow: none; color: var(--text-3); font-weight: 500; }
.btn.link:hover { color: var(--text); background: none; }
.btn.block { width: 100%; height: 40px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm); border: 1px solid transparent;
  background: none; color: var(--text-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.big { width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; }
.icon-btn.big:hover { background: var(--accent); filter: brightness(1.08); }
:root[data-theme="dark"] .icon-btn.big { color: #0e0e11; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .icon-btn.big { color: #0e0e11; } }

input[type="text"], input[type="email"], input[type="password"], input[type="search"], input[type="number"], select, textarea {
  height: 36px; padding: 0 11px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); min-width: 0;
}
textarea { height: auto; padding: 8px 11px; resize: vertical; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input.narrow { width: 80px; }
.select { min-width: 130px; }
.search { flex: 1 1 260px; max-width: 420px; }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field input, .field select { width: 100%; }
.field.grow { flex: 1 1 220px; }
.field-label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.form-error { color: var(--bad); font-size: 13px; min-height: 0; margin: 0 0 10px; }
.form-error:empty { display: none; }
.toggle { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--text-2); user-select: none; }
.toggle input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text-2);
  font-size: 12.5px; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--text-3); }
.chip.on { background: var(--accent-soft); border-color: transparent; color: var(--accent-text); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-3); border-radius: 9px; }
.segmented button {
  height: 28px; padding: 0 12px; border: 0; border-radius: 7px; background: none; color: var(--text-2);
  font-size: 12.5px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.segmented button:hover { color: var(--text); }
.segmented button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.badge {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px; border-radius: 6px;
  font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--text-2); white-space: nowrap;
}
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent-text); }
.badge.live { background: var(--ok-soft); color: var(--ok); }
.badge.muted { background: var(--surface-2); color: var(--text-3); }

.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: transparent; flex: none; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 0 0 var(--ok); animation: pulse 1.8s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(34, 160, 90, .5); } 70% { box-shadow: 0 0 0 7px rgba(34, 160, 90, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 160, 90, 0); } }
@media (prefers-reduced-motion: reduce) { .live-dot.on { animation: none; } }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--text-3); }
.dot.ok { background: var(--ok); }

/* ---------------------------------------------------------------- gate */

.gate { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.gate-card {
  width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 14px; box-shadow: var(--shadow-lg); padding: 28px;
}
.gate-card h1 { font-size: 20px; margin: 18px 0 6px; }
.gate-card > p.muted { margin-bottom: 18px; }
.gate-brand { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.gate-foot { margin-top: 18px; font-size: 12px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; background: url("icon.svg") center / cover no-repeat; flex: none; }
.code { width: 100%; height: 52px; text-align: center; font: 600 26px/1 var(--mono); letter-spacing: .32em; margin-bottom: 12px; }
.enroll { margin-top: 6px; }
.steps { padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 18px; }
.steps li::marker { color: var(--text-3); font-weight: 600; }
.steps strong { display: inline-block; margin-bottom: 4px; }
.qr-row { display: flex; gap: 16px; align-items: flex-start; margin-top: 10px; flex-wrap: wrap; }
.qr { width: 176px; height: 176px; background: #fff; border-radius: 10px; padding: 8px; border: 1px solid var(--line); flex: none; }
.qr-side { flex: 1 1 160px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.secret { display: flex; align-items: center; gap: 6px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 6px 6px 6px 10px; max-width: 100%; }
.secret code { overflow-wrap: anywhere; font-size: 12.5px; }
.key-text { font-size: 13px; }
.note { margin-top: 14px; padding: 9px 11px; border-radius: var(--radius-sm); background: var(--warn-soft); color: var(--warn); font-size: 12.5px; }

/* --------------------------------------------------------------- shell */

.app { display: grid; grid-template-columns: var(--rail) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px;
  padding: 16px 12px; border-right: 1px solid var(--line); background: var(--surface);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 14px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text .muted { font-size: 12px; }
.nav-list { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 10px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 550; border: 0; background: none; cursor: pointer; width: 100%; text-align: left;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--accent-soft); color: var(--accent-text); }
.rail-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.who { display: flex; align-items: center; gap: 8px; padding: 2px 10px; font-size: 12.5px; color: var(--text-3); min-width: 0; }
.who-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { min-width: 0; outline: none; }
.tabbar { display: none; }

.page { max-width: 1240px; margin: 0 auto; padding: 28px 32px 48px; }
.page.wide { max-width: 1600px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-sub { margin-top: 3px; }
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-size: 13px; font-weight: 550; margin-bottom: 10px; }
.back:hover { color: var(--text); text-decoration: none; }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 18px; margin-bottom: 16px; min-width: 0;
}
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .grid-2 { margin-top: 16px; }

.loading { display: flex; align-items: center; gap: 10px; color: var(--text-3); padding: 24px 4px; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 40px 16px; }
.empty-title { font-weight: 600; margin-bottom: 4px; color: var(--text-2); }
.error-box { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--bad-soft); color: var(--bad); margin: 8px 0; }
.label { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 14px 0 6px; }

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

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpis.small { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.kpi {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: var(--text); min-width: 0;
}
a.kpi:hover { border-color: var(--line-strong); text-decoration: none; background: var(--surface-2); }
.kpi-label { font-size: 12.5px; color: var(--text-3); font-weight: 550; }
.kpi-value { font-size: 24px; font-weight: 650; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi-value.small { font-size: 16px; }
.kpi-hint { font-size: 12px; }

.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 82px minmax(0, 1fr) 132px 44px; gap: 12px; align-items: center; }
.funnel-label { font-weight: 550; color: var(--text-2); font-size: 13px; }
.funnel-bar { height: 22px; background: var(--surface-2); border-radius: 6px; overflow: hidden; }
.funnel-fill { display: block; height: 100%; background: var(--accent); border-radius: 6px; opacity: .85; min-width: 0; }
.funnel-num { font-size: 13px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.funnel-drop { font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; }
.chart { display: flex; flex-direction: column; gap: 6px; }
.bars { width: 100%; height: 140px; display: block; }
.bars .bar { fill: var(--accent); opacity: .85; }
.bars .bar:hover { opacity: 1; }
.bars .bar.zero { fill: var(--line-strong); }
.bar-labels { display: flex; justify-content: space-between; font-size: 12px; }

.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 4px; color: var(--text); width: 100%;
  border: 0; background: none; text-align: left; cursor: pointer;
}
.card.flush .list-row { padding: 12px 16px; }
.list-row:hover { text-decoration: none; background: var(--surface-2); }
.list-icon { display: inline-flex; width: 30px; height: 30px; border-radius: 8px; align-items: center; justify-content: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.list-icon.bad { background: var(--bad-soft); color: var(--bad); }
.list-icon.warn { background: var(--warn-soft); color: var(--warn); }
.list-icon.accent { background: var(--accent-soft); color: var(--accent-text); }
.list-main { display: flex; flex-direction: column; min-width: 0; }
.list-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.live-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.live-card, .live-tile { display: flex; flex-direction: column; gap: 6px; color: var(--text); min-width: 0; }
.live-card:hover, .live-tile:hover { text-decoration: none; }
.live-card:hover .thumb-box, .live-tile:hover .thumb-box { border-color: var(--accent); }
.thumb-box {
  position: relative; aspect-ratio: 16 / 10; background: var(--frame-bg); border-radius: var(--radius-sm);
  overflow: hidden; border: 1px solid var(--line); display: flex; align-items: center; justify-content: center;
}
.thumb { width: 100%; height: 100%; object-fit: contain; display: block; }
.thumb:not([src]) { visibility: hidden; }
.no-thumb { position: absolute; }
.live-pill {
  position: absolute; top: 7px; left: 7px; display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 7px; border-radius: 999px; background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; font-weight: 650;
}
.live-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.live-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.live-grid .empty { grid-column: 1 / -1; }

/* -------------------------------------------------------------- sessions */

.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.filter-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chip.removable { gap: 6px; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-3); padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: var(--surface); white-space: nowrap;
}
.table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: var(--surface-2); }
.table tr.dim td { opacity: .55; }
.table td.msg { white-space: normal; min-width: 220px; max-width: 520px; color: var(--text-2); }
.card:not(.flush) .table th, .card:not(.flush) .table td { padding-left: 6px; padding-right: 6px; }
.c-dot { width: 18px; padding-right: 0 !important; }
.c-who { max-width: 260px; }
.c-who .ellipsis { max-width: 240px; }
.tester { color: var(--text); font-weight: 600; }
.tester:hover { color: var(--accent-text); }
.fdots { display: inline-flex; gap: 3px; align-items: center; }
.fdot { width: 8px; height: 8px; border-radius: 50%; background: var(--surface-3); border: 1px solid var(--line-strong); }
.fdot.on { background: var(--accent); border-color: var(--accent); }
.sigs { display: inline-flex; gap: 8px; }
.sig { display: inline-flex; align-items: center; gap: 3px; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.sig.warn { color: var(--warn); }
.sig.bad { color: var(--bad); }
.sig.accent { color: var(--accent-text); }
.runs { font-variant-numeric: tabular-nums; font-weight: 600; }
.list-status:empty { display: none; }
.more-row { display: flex; justify-content: center; margin-top: 8px; }
.scards { display: none; }

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

.player-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.player-title { min-width: 0; }
.player-title h1 { font-size: 19px; }
.player-title h1 .tester { font-weight: 650; }
.player-sub { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.narrative {
  margin: 0 0 14px; padding: 11px 14px; border-radius: var(--radius-sm); background: var(--surface);
  border: 1px solid var(--line); border-left: 3px solid var(--accent); color: var(--text-2);
}
.player-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 16px; align-items: start; }
.stage { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.frame-box { position: relative; aspect-ratio: 16 / 10; background: var(--frame-bg); max-height: 70vh; width: 100%; }
.frame { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.frame:not([src]) { visibility: hidden; }
.ripples { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.no-frame { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #9a9aa4; font-size: 13px; text-align: center; padding: 16px; }
.no-frame:empty { display: none; }
.scrub { padding: 14px 16px 2px; }
.scrub-track { position: relative; height: 26px; cursor: pointer; touch-action: none; }
.scrub-track::before { content: ""; position: absolute; left: 0; right: 0; top: 11px; height: 4px; border-radius: 2px; background: var(--surface-3); }
.scrub-fill { position: absolute; left: 0; top: 11px; height: 4px; border-radius: 2px; background: var(--accent); pointer-events: none; }
.scrub-idle { position: absolute; top: 9px; height: 8px; border-radius: 2px; background: repeating-linear-gradient(135deg, var(--line-strong) 0 3px, transparent 3px 6px); opacity: .9; pointer-events: none; }
.scrub-knob {
  position: absolute; top: 6px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%;
  background: var(--surface); border: 3px solid var(--accent); box-shadow: var(--shadow); pointer-events: none;
}
.tick { position: absolute; top: 2px; width: 3px; height: 8px; margin-left: -1px; border-radius: 2px; background: var(--text-3); }
.tick.k-error, .tick.k-crash { background: var(--bad); height: 22px; top: 2px; opacity: .85; }
.tick.k-crash { width: 4px; }
.tick.k-rage, .tick.k-dead, .tick.k-stall { background: var(--warn); }
.tick.k-llm { background: #8b5cf6; }
.tick.k-result { background: var(--ok); top: 17px; }
.tick.k-run { background: var(--info); top: 17px; }
.tick.k-report { background: #db2777; height: 22px; width: 4px; }
.tick.k-export { background: #0d9488; top: 17px; }
.tick.k-nav, .tick.k-stage { opacity: .6; }
.scrub-hover {
  position: absolute; bottom: 30px; transform: translateX(-50%); white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis;
  background: var(--text); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 6px; pointer-events: none; z-index: 2;
}
.controls { display: flex; align-items: center; gap: 6px; padding: 8px 14px 12px; flex-wrap: wrap; }
.clock { font: 600 13px var(--mono); color: var(--text-2); margin-left: 6px; font-variant-numeric: tabular-nums; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; min-width: 0; height: min(78vh, 820px); position: sticky; top: 16px;
}
.panel-tabs { display: flex; gap: 2px; padding: 6px; border-bottom: 1px solid var(--line); overflow-x: auto; flex: none; }
.panel-tabs button {
  border: 0; background: none; height: 30px; padding: 0 10px; border-radius: 7px; color: var(--text-3);
  font-weight: 600; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.panel-tabs button:hover { color: var(--text); background: var(--surface-2); }
.panel-tabs button.on { color: var(--text); background: var(--surface-3); }
.panel-body { overflow-y: auto; padding: 6px 0; flex: 1; min-height: 0; }
.panel-body > .loading, .panel-body > .empty, .panel-body > .error-box { margin: 8px 14px; }
.panel-body > .note { margin: 6px 12px; }
.time {
  border: 0; background: none; color: var(--text-3); font: 500 12px var(--mono); padding: 0; cursor: pointer;
  font-variant-numeric: tabular-nums; flex: none; min-width: 40px; text-align: left;
}
.time:hover { color: var(--accent-text); }
.events, .net, .ai, .diffs, .console, .plain { list-style: none; margin: 0; padding: 0; }
.ev { display: grid; grid-template-columns: 44px auto minmax(0, 1fr); gap: 8px; align-items: baseline; padding: 4px 14px; cursor: pointer; border-left: 2px solid transparent; }
.ev:hover { background: var(--surface-2); }
.ev.current { background: var(--accent-soft); border-left-color: var(--accent); }
.ev-name { font: 600 12px var(--mono); color: var(--text-2); white-space: nowrap; }
.ev-name.bad { color: var(--bad); }
.ev-name.ok { color: var(--ok); }
.ev-name.accent { color: #db2777; }
.ev-name.info { color: var(--info); }
.ev-name.muted { color: var(--text-3); font-weight: 500; }
.ev-props { font: 12px var(--mono); color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-row { border-bottom: 1px solid var(--line); }
.net-line { display: grid; grid-template-columns: 44px 44px minmax(0, 1fr) 34px 60px; gap: 8px; align-items: baseline; padding: 6px 14px; cursor: pointer; font-size: 12.5px; }
.net-line:hover { background: var(--surface-2); }
.net-method { font: 600 11.5px var(--mono); color: var(--text-3); }
.net-path { font: 12px var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.net-status { font: 600 12px var(--mono); text-align: right; }
.net-detail { padding: 4px 14px 12px; }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 4px 14px; margin: 0; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.code-block {
  margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line);
  max-height: 320px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; line-height: 1.5;
}
.code-block.tall { max-height: 60vh; }
.ai-row { padding: 9px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ai-row:hover { background: var(--surface-2); }
.ai-line { display: flex; gap: 8px; align-items: center; margin-bottom: 4px; }
.ai-text { font-size: 12.5px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow-wrap: anywhere; }
.diffs li { padding: 8px 14px; border-bottom: 1px solid var(--line); }
.diff-head { margin-bottom: 4px; }
.diff { display: grid; grid-template-columns: minmax(80px, max-content) minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; font: 12px var(--mono); align-items: baseline; padding: 2px 0; }
.diff-key { color: var(--text-2); font-weight: 600; }
.diff-from { color: var(--bad); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--bad) 50%, transparent); overflow-wrap: anywhere; }
.diff-to { color: var(--ok); overflow-wrap: anywhere; }
.log { display: grid; grid-template-columns: 44px 62px minmax(0, 1fr); gap: 8px; padding: 4px 14px; align-items: baseline; }
.log-level { font: 600 11px var(--mono); text-transform: uppercase; color: var(--text-3); }
.log-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12px; color: var(--text-2); }
.lv-warning .log-level { color: var(--warn); }
.lv-critical .log-level, .lv-error .log-level, .lv-crash .log-level { color: var(--bad); }
.lv-crash { background: var(--bad-soft); }
.info { padding: 6px 14px 14px; }
.info .kv { font-size: 13px; }
.plain li { padding: 3px 0; font-size: 13px; }
.report-line { display: flex; gap: 8px; }

/* --------------------------------------------------------- issues, reports */

.issues { display: flex; flex-direction: column; }
.issue { display: flex; gap: 14px; align-items: center; padding: 14px 18px; color: var(--text); border-bottom: 1px solid var(--line); min-width: 0; }
.issue:last-child { border-bottom: 0; }
.issue:hover { background: var(--surface-2); text-decoration: none; }
.issue-icon { display: inline-flex; width: 32px; height: 32px; border-radius: 8px; align-items: center; justify-content: center; flex: none; background: var(--surface-2); color: var(--text-3); }
.issue-icon.bad { background: var(--bad-soft); color: var(--bad); }
.issue-main { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
.issue-title { display: flex; gap: 8px; align-items: center; min-width: 0; flex-wrap: wrap; }
.issue-title strong { overflow-wrap: anywhere; }
.issue-stats { display: grid; grid-template-columns: repeat(5, auto); gap: 18px; align-items: baseline; font-size: 13px; white-space: nowrap; }
.status-edit { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.note-input { max-width: 640px; }

.reports { display: flex; flex-direction: column; gap: 14px; }
.report {
  display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 18px; padding: 16px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.report-thumb { align-self: start; }
.report-body { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.report-top { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.report-note {
  margin: 0; font-size: 16px; line-height: 1.45; color: var(--text); padding-left: 12px; border-left: 3px solid #db2777;
  overflow-wrap: anywhere; white-space: pre-wrap;
}
.report-meta { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.report-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* -------------------------------------------------------------- settings */

.account { display: flex; justify-content: space-between; gap: 16px; align-items: center; flex-wrap: wrap; }
.key-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.key-form .field { margin-bottom: 0; }
.key-form .toggle { height: 36px; }
.copy-area { width: 100%; font: 12px var(--mono); }

/* ----------------------------------------------------------- modal, toast */

.overlay {
  position: fixed; inset: 0; background: rgba(10, 10, 14, .5); display: flex; align-items: center; justify-content: center;
  padding: 16px; z-index: 50; backdrop-filter: blur(2px);
}
.modal {
  width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow-lg);
}
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px 10px 20px; }
.modal-head h2 { font-size: 16px; overflow-wrap: anywhere; }
.modal-body { padding: 0 20px 18px; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding: 0 20px 18px; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 9px; font-weight: 550; font-size: 13px;
  transition: opacity .18s, transform .18s; z-index: 60; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--bad); color: #fff; }
.toast.warn { background: var(--warn); color: #fff; }

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

@media (max-width: 1180px) {
  .player-grid { grid-template-columns: minmax(0, 1fr); }
  .panel { height: 520px; position: static; }
  .issue-stats { grid-template-columns: repeat(3, auto); }
  .issue-stats .stat:nth-child(n+4) { display: none; }
}

@media (max-width: 1024px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis.small { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  :root { --rail: 200px; }
}

@media (max-width: 768px) {
  body { font-size: 14px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { display: none; }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: var(--surface); border-top: 1px solid var(--line); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .tab { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 5px 0; color: var(--text-3); font-size: 11px; font-weight: 600; }
  .tab:hover { text-decoration: none; }
  .tab.active { color: var(--accent-text); }
  .main { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .page, .page.wide { padding: 18px 16px 28px; }
  h1 { font-size: 20px; }
  .page-head { margin-bottom: 14px; }
  .kpi { padding: 11px 12px; }
  .kpi-value { font-size: 20px; }
  .kpis.small { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .card { padding: 14px; }
  .funnel-row { grid-template-columns: 64px minmax(0, 1fr) 40px; }
  .funnel-drop { display: none; }
  .funnel-num .muted { display: none; }
  .search { flex-basis: 100%; max-width: none; }
  .filter-row .chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
  .filters .chips::-webkit-scrollbar { display: none; }
  .desktop-only { display: none !important; }
  .scards { display: flex; flex-direction: column; }
  .scard { display: flex; flex-direction: column; gap: 6px; padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); }
  .scard:hover { background: var(--surface-2); text-decoration: none; }
  .scard-top { display: flex; align-items: center; gap: 8px; min-width: 0; }
  .scard-top strong { flex: 1; }
  .scard-mid { display: flex; gap: 10px; flex-wrap: wrap; }
  .scard-bot { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
  .issue { padding: 12px 14px; flex-wrap: wrap; }
  .issue-stats { grid-template-columns: repeat(3, auto); gap: 12px; padding-left: 46px; }
  .report { grid-template-columns: minmax(0, 1fr); padding: 14px; }
  .player-head { align-items: flex-start; }
  .player-head .page-actions { width: 100%; }
  .player-head .page-actions .btn { flex: 1; }
  .frame-box { max-height: none; }
  .controls { padding: 8px 10px 12px; }
  .panel { height: 60vh; }
  .net-line { grid-template-columns: 40px 38px minmax(0, 1fr) 30px; }
  .net-line > :last-child { display: none; }
  .diff { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .diff > .muted { display: none; }
  .modal { max-height: calc(100vh - 32px); }
  .gate-card { padding: 22px 18px; }
  .qr-row { flex-direction: column; align-items: center; }
  .qr-side { align-items: stretch; width: 100%; }
  .table td.msg { min-width: 160px; }
  .toast { bottom: calc(80px + env(safe-area-inset-bottom)); }
}
