:root {
  color-scheme: light dark;
  --bg: #eef3ff; --panel: #ffffff; --soft: #f6f8ff; --ink: #0b1f55; --text: #1b2440; --muted: #5d6a8f;
  --line: #dfe7ff; --accent: #2f5fd6; --accent-2: #5b8cff; --deep: #2148ad; --on-accent: #ffffff; --tint: #dfe7ff;
  --task: #fff6dd; --task-line: #e9cf86; --task-ink: #6b4e00;
  --ok: #1f8a52; --ok-strong: #17703f; --warn: #b37400; --off: #7d87a3; --err: #c4321f; --err-ink: #ffffff;
  --a0: #b0501a; --a1: #1f6f4c; --a2: #7440a8; --a3: #176a86;
  --a4: #a3345f; --a5: #5d6b12; --a6: #3a50b8; --a7: #8a5a14;
  --radius: 18px; --shadow: 0 1px 2px rgba(11, 31, 85, 0.06), 0 6px 20px rgba(11, 31, 85, 0.07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1330; --panel: #111c40; --soft: #16234d; --ink: #e8eeff; --text: #dfe6ff; --muted: #9daad3;
    --line: #24346a; --accent: #5b8cff; --accent-2: #8fb0ff; --deep: #2f5fd6; --on-accent: #0b1f55; --tint: #1c2b5c;
    --task: #2a2412; --task-line: #6f5a1c; --task-ink: #f0d88a;
    --ok: #63c58c; --ok-strong: #1f7a45; --warn: #e0b055; --off: #5f6b91; --err: #f2b8b5; --err-ink: #3d0a07;
    --a0: #f0a070; --a1: #7fd0a6; --a2: #c9a2f0; --a3: #7cc8e2;
    --a4: #f29bbb; --a5: #c3d36a; --a6: #a3b4ff; --a7: #e6bd72;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 6px 20px rgba(0, 0, 0, 0.25);
  }
}

#analytics { flex: 1; min-height: 0; overflow-y: auto; padding: 16px max(18px, calc((100% - 1120px) / 2)); }
#analytics .view-head { flex-wrap: wrap; }
.ax-tools { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.ax-tools button, .ax-replay button { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); border-radius: 999px; padding: 5px 12px; cursor: pointer; }
.ax-tools button:hover, .ax-replay button:hover { border-color: var(--accent); }
.ax-numbers { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 12px; }
.ax-num { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px; min-width: 0; }
.ax-num b { display: block; font-size: 28px; line-height: 1.15; color: var(--ink); font-variant-numeric: tabular-nums;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ax-num span { font-size: 12.5px; color: var(--muted); }
.ax-card { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px;
  margin-bottom: 12px; min-width: 0; }
.ax-card h3 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 0 0 8px; }
.ax-card .meta { font-size: 12.5px; color: var(--muted); margin: 6px 0 0; }
.ax-hero { position: relative; }
.ax-hero canvas { display: block; width: 100%; height: 380px; cursor: default; touch-action: pan-y; }
.ax-replay { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.ax-replay input { flex: 1; min-width: 0; accent-color: var(--accent); }
.ax-replay output { min-width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
.ax-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0 12px; }
.ax-wide { grid-column: 1 / -1; }
.ax-card svg { display: block; width: 100%; overflow: visible; }
.ax-card svg text { fill: var(--text); font-size: 11px; font-family: inherit; }
.ax-card svg text.ax-muted { fill: var(--muted); }
.ax-card svg text.ax-big { font-size: 15px; font-weight: 600; fill: var(--ink); }
.ax-flow { fill: none; stroke-dasharray: 5 9; animation: ax-flow 1.4s linear infinite; }
@keyframes ax-flow { to { stroke-dashoffset: -28; } }
.ax-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--muted); margin-top: 6px; }
.ax-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.ax-machines { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; }
.ax-machine { flex: 0 0 auto; min-width: 180px; max-width: 260px; border: 1px solid var(--line); border-radius: 14px; padding: 8px 10px; }
.ax-machine b { color: var(--ink); font-size: 13.5px; }
.ax-machine .meta { margin: 2px 0 6px; }
.ax-chip { display: flex; align-items: center; gap: 6px; font-size: 12.5px; margin: 3px 0; min-width: 0; }
.ax-chip .avatar { width: 22px; height: 22px; flex: 0 0 22px; font-size: 9px; }
.ax-chip span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; background: var(--off); }
.ax-dot.on { background: var(--ok); } .ax-dot.listen { background: var(--accent); }
.ax-heat { display: flex; flex-direction: column; gap: 8px; }
.ax-group h4 { margin: 0 0 4px; font-size: 12px; color: var(--muted); font-weight: 600; }
.ax-tiles { display: flex; flex-wrap: wrap; gap: 4px; }
.ax-tile { flex: 1 1 auto; min-width: 70px; height: 42px; border-radius: 8px; padding: 4px 7px; font-size: 11.5px;
  color: var(--ink); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; border: 1px solid var(--line); }
.ax-tile small { display: block; color: var(--muted); font-size: 10.5px; }
.ax-bars { display: grid; grid-template-columns: minmax(70px, max-content) minmax(0, 1fr) max-content; gap: 4px 8px;
  align-items: center; font-size: 12.5px; }
.ax-bars .bar { height: 10px; border-radius: 5px; background: var(--accent); min-width: 2px; }
.ax-bars .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ax-bars .val { color: var(--muted); font-variant-numeric: tabular-nums; }
.ax-empty { font-size: 13px; color: var(--muted); margin: 4px 0; }
.ax-demo-note { margin: 0 0 12px; padding: 8px 12px; border-radius: 12px; background: var(--task); color: var(--task-ink);
  border: 1px solid var(--task-line); font-size: 13.5px; }
.ax-tools button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.ax-code canvas, #ax-code canvas { display: block; width: 100%; cursor: default; }
.ax-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
@media (max-width: 760px) {
  .ax-grid { grid-template-columns: minmax(0, 1fr); }
  .ax-hero canvas { height: 300px; }
  .ax-num b { font-size: 22px; }
  .ax-numbers { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { .ax-flow { animation: none; } }
body.ax-present #analytics { position: fixed; inset: 0; z-index: 200; background: var(--bg); padding: 22px 32px; }
body.ax-present .ax-grid { display: block; }
body.ax-present .ax-panel:not(.ax-current) { display: none; }
body.ax-present .ax-num b { font-size: 44px; }
body.ax-present .ax-num span { font-size: 16px; }
body.ax-present .ax-card h3 { font-size: 18px; }
body.ax-present .ax-card svg text { font-size: 15px; }
body.ax-present .ax-hero canvas { height: calc(100vh - 300px); }
body.ax-present .ax-replay, body.ax-present #analytics .back { display: none; }
