:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #66665f;
  --border: #e2e1dc;
  --accent: #2f5fd0;
  --row-hover: #f1f1ed;

  --active-bg: #dff3e4;    --active-fg: #1d6b35;
  --undecided-bg: #fdf0d5; --undecided-fg: #875a00;
  --parked-bg: #e3ecfb;    --parked-fg: #2a4f9c;
  --to-archive-bg: #ecebe6; --to-archive-fg: #55544d;
  --to-delete-bg: #fbe2df; --to-delete-fg: #a3321f;
  --deleted-bg: #000;      --deleted-fg: #fff;   /* same in dark mode */

  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161615;
    --surface: #1e1e1c;
    --text: #e9e8e3;
    --muted: #a09f97;
    --border: #34332f;
    --accent: #8aaaf5;
    --row-hover: #262623;

    --active-bg: #1f3a27;    --active-fg: #9fdcb0;
    --undecided-bg: #3d3116; --undecided-fg: #f0cd82;
    --parked-bg: #1f2d4a;    --parked-fg: #a9c1f5;
    --to-archive-bg: #2e2d29; --to-archive-fg: #c2c0b7;
    --to-delete-bg: #45221c; --to-delete-fg: #f3aa9c;

    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}

.page-header, main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 16px;
}

.page-header { padding-top: 28px; }

h1 { margin: 0 0 4px; font-size: 1.6rem; }
h2 { font-size: 1.15rem; margin: 0 0 8px; }

.subtitle { margin: 0 0 12px; color: var(--muted); }

a { color: var(--accent); }

code {
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
  font-size: 0.9em;
  background: var(--row-hover);
  padding: 1px 4px;
  border-radius: 4px;
}

.legend {
  margin-bottom: 20px;
  color: var(--muted);
}
.legend summary { cursor: pointer; }
.legend ul { margin: 8px 0 0; padding-left: 20px; }

/* Summary chips */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 12px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.chip strong { margin-left: 4px; }
.chip[aria-pressed="true"] { border-color: currentColor; box-shadow: inset 0 0 0 1px currentColor; }

/* Controls */
.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 12px;
}

.control { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.control-search { flex: 1 1 240px; }

.control input, .control select, .reset {
  font: inherit;
  font-size: 0.95rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
}
.control input { width: 100%; }
.reset { cursor: pointer; }
.reset:hover { background: var(--row-hover); }

.count { margin: 0 0 8px; color: var(--muted); font-size: 0.9rem; }

/* Table */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

table { border-collapse: collapse; width: 100%; min-width: 980px; }

th, td {
  text-align: left;
  vertical-align: top;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
}

thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

th button {
  all: unset;
  cursor: pointer;
  color: inherit;
}
th button::after { content: " ↕"; opacity: 0.35; }
th[aria-sort="ascending"] button::after { content: " ↑"; opacity: 1; }
th[aria-sort="descending"] button::after { content: " ↓"; opacity: 1; }
th button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

tbody tr:hover { background: var(--row-hover); }
tbody tr:last-child td { border-bottom: none; }

td.name { white-space: nowrap; font-weight: 600; }
td.date { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.text { min-width: 220px; }
td.muted { color: var(--muted); }

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 0.8rem;
  white-space: nowrap;
}

.s-active     { background: var(--active-bg);     color: var(--active-fg); }
.s-undecided  { background: var(--undecided-bg);  color: var(--undecided-fg); }
.s-parked     { background: var(--parked-bg);     color: var(--parked-fg); }
.s-to-archive { background: var(--to-archive-bg); color: var(--to-archive-fg); }
.s-to-delete  { background: var(--to-delete-bg);  color: var(--to-delete-fg); }
.s-deleted    { background: var(--deleted-bg);    color: var(--deleted-fg); }

.empty { padding: 24px; text-align: center; color: var(--muted); }

.questions { margin: 28px 0 40px; }
.questions ul { margin: 0; padding-left: 20px; }
.questions li { margin-bottom: 4px; }
