:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6f6d67;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --accent: #1c5cab;
  --accent-ink: #ffffff;
  --accent-soft: #cde2fb;
  --danger: #b42f2f;
  --good: #006300;
  --warn-bg: #fdf1d6;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #262624;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #9a988f;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --accent-ink: #0b0b0b;
    --accent-soft: #184f95;
    --danger: #e66767;
    --good: #0ca30c;
    --warn-bg: #3a2f14;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #262624;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #9a988f;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --accent: #3987e5;
  --accent-ink: #0b0b0b;
  --accent-soft: #184f95;
  --danger: #e66767;
  --good: #0ca30c;
  --warn-bg: #3a2f14;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
}
h1, h2, h3 { margin: 0; font-weight: 600; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0; }
code, pre { font-family: var(--mono); font-size: 12.5px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
[hidden] { display: none !important; }

/* --- header --- */
.top {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.top-row, .tabs {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.top-row { min-height: 52px; flex-wrap: wrap; row-gap: 4px; padding-top: 6px; padding-bottom: 6px; }
.brand { font-weight: 600; font-size: 15px; }
.me { margin-left: auto; display: flex; gap: 10px; align-items: center; color: var(--ink-2); }
.tabs { gap: 2px; overflow-x: auto; scrollbar-width: none; }
.tabs a {
  padding: 10px 12px;
  color: var(--ink-2);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs a:hover { color: var(--ink); }
.tabs a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 11.5px;
  font-weight: 600;
  text-align: center;
}
.pill {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.pill.shadow { background: var(--warn-bg); }

/* --- layout --- */
.view { max-width: 1200px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
.card > h2 + * { margin-top: 12px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stack { display: grid; gap: 10px; }
.row-flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.section-title { font-size: 13px; color: var(--ink-2); font-weight: 600; margin: 4px 0 -4px; }

/* --- controls --- */
button, select, input, textarea { font: inherit; color: inherit; }
.btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-link { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; }
select, input[type="search"], input[type="text"], textarea {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 10px;
  min-width: 0;
}
textarea { width: 100%; resize: vertical; line-height: 1.45; }
textarea.mono { font-family: var(--mono); font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.segmented button { border: 0; background: var(--surface); padding: 5px 12px; cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border); }
.segmented button[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters input[type="search"] { flex: 1 1 200px; }

/* --- mode card --- */
.mode-card { display: flex; gap: 16px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.mode-card.shadow { background: var(--warn-bg); }
.mode-title { font-size: 17px; font-weight: 600; }
.mode-card p { color: var(--ink-2); max-width: 640px; margin-top: 4px; }

/* --- stat tiles --- */
.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile-label { color: var(--ink-2); font-size: 12.5px; }
.tile-value { font-size: 26px; font-weight: 600; margin-top: 2px; }
.tile-note { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* --- chart --- */
.chart { position: relative; }
.chart svg { display: block; width: 100%; overflow: visible; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--ink-2); font-size: 12.5px; margin-bottom: 8px; }
.legend span, .dot-label { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }
.s-kept { background: var(--series-1); fill: var(--series-1); }
.s-flagged { background: var(--series-2); fill: var(--series-2); }
.s-removed { background: var(--series-3); fill: var(--series-3); }
.s-unchecked { background: var(--series-4); fill: var(--series-4); }
.chart svg path, .chart svg text, .chart svg line { pointer-events: none; } /* hover belongs to the day band */
.bar-hit { fill: transparent; cursor: default; }
.bar-hit.active { fill: var(--surface-2); }
.axis-text { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.base-line { stroke: var(--axis); stroke-width: 1; }
.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  font-size: 12.5px;
  min-width: 160px;
  z-index: 3;
}
.tooltip .tt-row { display: flex; justify-content: space-between; gap: 12px; }
.tooltip .tt-total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; font-weight: 600; }
.hbar { display: grid; grid-template-columns: minmax(110px, 180px) 1fr auto; gap: 10px; align-items: center; }
.hbar-track { height: 10px; }
.hbar-fill { height: 10px; border-radius: 0 4px 4px 0; background: var(--series-1); min-width: 2px; }
.hbar-value { font-variant-numeric: tabular-nums; color: var(--ink-2); }

/* --- tables --- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.log-row { cursor: pointer; }
tr.log-row:hover td { background: var(--surface-2); }
tr.log-row[aria-expanded="true"] td { background: var(--surface-2); border-bottom-color: transparent; }
td.nowrap { white-space: nowrap; }
td.snippet { color: var(--ink-2); max-width: 340px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tr.detail td { background: var(--surface-2); padding: 4px 10px 16px; }
.detail-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.post-text { white-space: pre-wrap; word-break: break-word; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; }
pre.json { white-space: pre-wrap; word-break: break-word; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; font-size: 12.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.badge { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tag {
  display: inline-block;
  font-size: 11.5px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--ink-2);
  white-space: nowrap;
}
.tag.shadow { background: var(--warn-bg); }
.tag.bad { color: var(--danger); border-color: currentColor; }
.review-line { font-size: 12.5px; color: var(--ink-2); }

/* --- review queue --- */
.flag-card { display: grid; gap: 10px; }
.flag-reasons { margin: 0; padding-left: 18px; }
.done-note { font-weight: 600; }

/* --- rules --- */
.profile-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.field-head { display: flex; gap: 8px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.field-head label { font-weight: 600; }
.field-head label .tag { margin-left: 8px; font-weight: 400; }
.verdict { display: grid; gap: 6px; }
.verdict .ok { color: var(--good); font-weight: 600; }
.verdict .bad { color: var(--danger); font-weight: 600; }

.example { display: grid; gap: 6px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.example.off { opacity: 0.55; }
.spacer { flex: 1; }

/* --- misc --- */
.login { max-width: 460px; margin: 80px auto; padding: 0 16px; display: grid; gap: 12px; text-align: center; }
.empty { color: var(--muted); padding: 24px 0; text-align: center; }
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  max-width: calc(100vw - 32px);
  z-index: 10;
}
.inline-confirm { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

@media (max-width: 640px) {
  .tile-value { font-size: 22px; }
  .hbar { grid-template-columns: 110px 1fr auto; }
  .me #me-name { display: none; }
}
