:root {
  color-scheme: light dark;
  --bg: #f6f6f4;
  --surface: #ffffff;
  --text: #1c1d1f;
  --muted: #62666d;
  --line: #dcdcd7;
  --accent: #1f5fbf;
  --accent-ink: #ffffff;
  --warn-bg: #fdf3d7;
  --warn-text: #6b4e00;
  --info-bg: #e7eefa;
  --info-text: #1d4179;
  --error: #b3261e;
  --code-bg: #eeeeea;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161a;
    --surface: #1e2025;
    --text: #e8e8e6;
    --muted: #a0a4ab;
    --line: #33363d;
    --accent: #7aa7ec;
    --accent-ink: #10141c;
    --warn-bg: #3b3013;
    --warn-text: #f2d98c;
    --info-bg: #1d2a40;
    --info-text: #b6cdf2;
    --error: #f2b8b5;
    --code-bg: #2a2c32;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 16px; font-weight: 650; margin: 0; }
h2 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
code, pre { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
pre { background: var(--code-bg); padding: 10px 12px; border-radius: 6px; overflow-x: auto; margin: 10px 0 0; white-space: pre-wrap; word-break: break-all; }
button, input, select { font: inherit; color: inherit; }
input, select { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; min-height: 36px; max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; width: min(360px, 100%); display: grid; gap: 10px; }
.card input { width: 100%; }
.primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 6px; padding: 8px 14px; min-height: 38px; font-weight: 600; cursor: pointer; }
.ghost { background: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.error { color: var(--error); margin: 0; font-size: 14px; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; flex: 1 1 auto; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 6px 12px; cursor: pointer; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters label { display: grid; gap: 3px; font-size: 12px; color: var(--muted); min-width: 0; }
.filters select, .filters input { color: var(--text); font-size: 14px; }
#f-path, #f-ad, #f-snapshot { max-width: 260px; }

.notices { padding: 0 16px; }
.notice { margin-top: 12px; padding: 9px 12px; border-radius: 6px; font-size: 14px; }
.notice.warn { background: var(--warn-bg); color: var(--warn-text); }
.notice.info { background: var(--info-bg); color: var(--info-text); }

.view { padding: 14px 16px 40px; }
.stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin-bottom: 12px; align-items: baseline; }
.stat b { font-size: 18px; font-weight: 650; font-variant-numeric: tabular-nums; margin-right: 4px; }
.stat span { color: var(--muted); font-size: 13px; }
.toggle { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; cursor: pointer; }
.toggle input { min-height: 0; }

.stage { position: relative; margin: 0 auto; border: 1px solid var(--line); background: var(--surface); line-height: 0; }
.stage img { display: block; width: 100%; height: auto; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.legend { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 12px; margin: 0 0 10px; }
.legend canvas { width: 160px; height: 10px; border-radius: 3px; }

.empty { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 22px; max-width: 720px; margin: 8px auto; }
.empty p { margin: 0; color: var(--muted); }
.loading { color: var(--muted); padding: 20px 0; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 8px 10px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { font-size: 12px; font-weight: 600; color: var(--muted); }
th:first-child, td:first-child { text-align: left; }
td.wide { white-space: normal; min-width: 200px; max-width: 360px; overflow-wrap: anywhere; }
td.wide small { display: block; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
tr:last-child td { border-bottom: 0; }
.tag-low { color: var(--warn-text); background: var(--warn-bg); border-radius: 4px; padding: 0 5px; font-size: 11px; margin-left: 6px; white-space: nowrap; }
.table-note { color: var(--muted); font-size: 13px; margin: 10px 0 0; }
.table-note + div .stage, .table-note + div { margin-top: 10px; }
