/* Sam moderation dashboard. Phone first (375 px, one hand), light and dark, system fonts, no remote resources.
   Colours repeat what the words already say (badges always carry text). */
:root {
  color-scheme: light dark;
  --bg: #fbfaff;
  --surface: #ffffff;
  --text: #1d1b26;
  --muted: #5b576b;
  --link: #5a3fd6;
  --rule: #e4e0f0;
  --accent: #5a3fd6;
  --accent-text: #ffffff;
  --danger: #b42318;
  --danger-text: #ffffff;
  --ok-bg: #e3f6ea; --ok-text: #11632f; --ok-border: #8fd0a6;
  --soon-bg: #fff3d6; --soon-text: #7a4b00; --soon-border: #f0c35c;
  --late-bg: #fde4e1; --late-text: #9b1c10; --late-border: #f0a197;
  --done-bg: #eceaf3; --done-text: #3d3a4a; --done-border: #cdc8dc;
  --focus: #5a3fd6;
  --quote: #f4f1ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15131c;
    --surface: #1d1a27;
    --text: #ece9f5;
    --muted: #a7a2b8;
    --link: #b6a4ff;
    --rule: #2e2a3b;
    --accent: #8f78ff;
    --accent-text: #120e22;
    --danger: #ff8a7a;
    --danger-text: #2a0703;
    --ok-bg: #12301e; --ok-text: #8fe0ab; --ok-border: #2d6a43;
    --soon-bg: #362a0c; --soon-text: #ffd27a; --soon-border: #7a5c17;
    --late-bg: #3b1410; --late-text: #ffaea3; --late-border: #85322a;
    --done-bg: #2a2737; --done-text: #cfcadf; --done-border: #4a4560;
    --focus: #b6a4ff;
    --quote: #221d33;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 1.0625rem/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-wrap: anywhere;
}
a { color: var(--link); text-underline-offset: 0.15em; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
h1:focus, h2:focus, h3:focus { outline: none; }
h1 { font-size: 1.5rem; line-height: 1.25; margin: 0.5rem 0 0.75rem; }
h2 { font-size: 1.125rem; line-height: 1.3; margin: 1.75rem 0 0.5rem; }
h3 { font-size: 1.0625rem; line-height: 1.35; margin: 0 0 0.25rem; }
p { margin: 0 0 0.75rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); font-size: 0.9375rem; }

/* Frame */
.topbar {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface);
  border-bottom: 1px solid var(--rule);
  padding: env(safe-area-inset-top) 1rem 0;
}
.topbar-inner { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; max-width: 46rem; margin: 0 auto; min-height: 3.25rem; }
.brand { font-weight: 700; text-decoration: none; color: var(--text); min-height: 44px; display: inline-flex; align-items: center; }
.whoami { max-width: 46rem; margin: 0 auto; padding-bottom: 0.5rem; color: var(--muted); font-size: 0.875rem; }
.offline { max-width: 46rem; margin: 0 auto 0.5rem; padding: 0.5rem 0.75rem; border-radius: 0.5rem; background: var(--late-bg); color: var(--late-text); border: 1px solid var(--late-border); font-weight: 600; }
.page { max-width: 46rem; margin: 0 auto; padding: 0.75rem 1rem calc(3rem + env(safe-area-inset-bottom)); }
.back { margin: 0.25rem 0 0; }
.back a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; text-decoration: none; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; }
.row h2 { margin: 0; }
.queue { margin-top: 1.5rem; }

/* Buttons: every target at least 44 px. */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; min-width: 44px; padding: 0.5rem 1rem;
  border: 1px solid var(--rule); border-radius: 0.75rem;
  background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.button:hover { border-color: var(--accent); }
.button:active { transform: scale(0.98); }
.button[disabled] { opacity: 0.55; cursor: not-allowed; transform: none; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.button.danger { background: var(--surface); border: 2px solid var(--danger); color: var(--danger); }
.confirm .button.danger { background: var(--danger); color: var(--danger-text); }
.button.small { font-size: 0.9375rem; padding: 0.4rem 0.8rem; }
.button.big { width: 100%; min-height: 52px; font-size: 1.0625rem; }
.button.wide { width: 100%; margin-top: 1rem; }
.toggle[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.link-button {
  border: 0; background: none; color: var(--link); font: inherit; font-weight: 600; padding: 0.5rem 0; min-height: 44px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 0.15em;
}

/* Forms */
.stack { display: grid; gap: 0.6rem; max-width: 26rem; }
label { font-weight: 600; }
input, textarea {
  width: 100%; min-height: 48px; padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule); border-radius: 0.6rem; background: var(--surface); color: var(--text);
  font: inherit; font-size: 1.0625rem; /* 17 px: no zoom on iOS */
}
textarea { min-height: 5.5rem; resize: vertical; }
input:focus-visible, textarea:focus-visible { border-color: var(--focus); }
.error { color: var(--late-text); background: var(--late-bg); border: 1px solid var(--late-border); border-radius: 0.6rem; padding: 0.6rem 0.75rem; }
.error p:last-child { margin-bottom: 0.5rem; }
.info:empty { display: none; }
.info { color: var(--muted); }
.toast { background: var(--ok-bg); color: var(--ok-text); border: 1px solid var(--ok-border); border-radius: 0.6rem; padding: 0.6rem 0.75rem; font-weight: 600; }
.empty { padding: 1.5rem 1rem; text-align: center; border: 1px dashed var(--rule); border-radius: 0.75rem; color: var(--muted); }

/* Stats */
.stats h2 { margin-top: 0.5rem; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; margin: 0; }
.stat-grid .fact { background: var(--surface); border: 1px solid var(--rule); border-radius: 0.75rem; padding: 0.5rem 0.75rem; }
.stat-grid dt { font-size: 0.8125rem; color: var(--muted); }
.stat-grid dd { margin: 0; font-weight: 700; font-size: 1.0625rem; }
.stat-grid dd .badge { margin-top: 0.25rem; }

/* Filters */
.filters ul { list-style: none; display: flex; gap: 0.5rem; padding: 0; margin: 1rem 0 0; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0.4rem 1rem; border-radius: 999px;
  border: 1px solid var(--rule); background: var(--surface); color: var(--text); text-decoration: none; font-weight: 600;
}
.chip[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.chip[aria-current="page"]::before { content: "✓"; margin-right: 0.3rem; }

/* Cards */
.cards { list-style: none; padding: 0; margin: 0.75rem 0 0; display: grid; gap: 0.75rem; }
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: 1rem; padding: 0.85rem 0.9rem; }
.card-top { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; margin: 0 0 0.5rem; }
.card-title a { text-decoration: none; color: var(--text); }
.card-title a:hover { text-decoration: underline; }
.card .button { width: 100%; margin-top: 0.25rem; }
.card-author { font-size: 0.9375rem; }
.person { font-weight: 600; }
a.person { display: inline-block; padding: 0.6rem 0; margin: -0.6rem 0; } /* 44 px tall hit area inside text */

/* Badges and states: text first, colour second. */
.badge, .state {
  display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.8125rem; font-weight: 700;
  border: 1px solid; line-height: 1.4;
}
.badge-ok { background: var(--ok-bg); color: var(--ok-text); border-color: var(--ok-border); }
.badge-soon { background: var(--soon-bg); color: var(--soon-text); border-color: var(--soon-border); }
.badge-overdue { background: var(--late-bg); color: var(--late-text); border-color: var(--late-border); }
.badge-done, .badge-unknown { background: var(--done-bg); color: var(--done-text); border-color: var(--done-border); }
.state { background: transparent; color: var(--muted); border-color: var(--rule); }
.state-hidden { color: var(--soon-text); border-color: var(--soon-border); }
.state-deleted { color: var(--late-text); border-color: var(--late-border); }
.state::before { content: "State: "; font-weight: 400; }

/* Evidence */
.quote {
  background: var(--quote); border-left: 4px solid var(--accent); border-radius: 0 0.5rem 0.5rem 0;
  padding: 0.5rem 0.75rem; white-space: pre-wrap; margin-bottom: 0.25rem;
}
.clip { margin-bottom: 0.5rem; }
.evidence { border: 1px solid var(--rule); border-radius: 0.75rem; padding: 0.75rem; background: var(--surface); }
.msg-meta { font-size: 0.875rem; color: var(--muted); margin: 0.25rem 0; }
.convo { list-style: none; padding: 0; margin: 0.5rem 0 0; display: grid; gap: 0.4rem; }
.msg { border-radius: 0.75rem; padding: 0.4rem 0.6rem; background: var(--quote); }
.msg-body { margin: 0; white-space: pre-wrap; }
.msg-reported { border: 2px solid var(--late-border); background: var(--late-bg); }
.msg-reported .msg-meta strong { color: var(--late-text); }
.facts { margin: 0 0 0.75rem; display: grid; gap: 0.35rem; }
.fact { display: grid; grid-template-columns: minmax(7rem, 35%) 1fr; gap: 0.5rem; }
.stat-grid .fact { display: block; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.plain { list-style: none; padding: 0; margin: 0; }
.list { display: grid; gap: 0.5rem; }
.item { border-bottom: 1px solid var(--rule); padding-bottom: 0.5rem; }
details { margin-top: 0.25rem; }
summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; color: var(--link); font-weight: 600; }

/* Decide */
.decide { border-top: 1px solid var(--rule); margin-top: 1.5rem; }
.action-group { margin-bottom: 1rem; display: grid; gap: 0.5rem; }
.group-label { margin: 0; font-weight: 700; color: var(--muted); font-size: 0.9375rem; }
.action p { margin: 0.25rem 0 0; }
.confirm { border: 2px solid var(--accent); border-radius: 1rem; padding: 0.9rem; background: var(--surface); display: grid; gap: 0.6rem; }
.confirm-destructive { border-color: var(--danger); }
.confirm p { margin: 0; }
.button-row { display: grid; gap: 0.5rem; }

@media (min-width: 40rem) {
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .button-row { grid-template-columns: 1fr 1fr; }
  .action-group { grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); }
  .group-label { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) {
  .button:active { transform: none; }
}
