:root {
  --paper: #EDF0F3;
  --surface: #F8F9FB;
  --ink: #18202E;
  --muted: #5A6577;
  --line: #CDD3DC;
  --cobalt: #2747C2;
  --harm: #B8341F;
  --safe: #2B7552;
  --contested: #A86F12;
  --pending: #7C8696;
  --focus: #2747C2;
  --radius-s: 4px;
  --radius-m: 10px;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Instrument Sans", system-ui, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12161D;
    --surface: #1A2029;
    --ink: #E6EAF0;
    --muted: #9AA5B5;
    --line: #2E3644;
    --cobalt: #8DA2FF;
    --harm: #F0806B;
    --safe: #6CC79B;
    --contested: #E3AE52;
    --pending: #8C96A6;
    --focus: #8DA2FF;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--body);
}
.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 0 16px; }
a { color: var(--cobalt); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Masthead */
.masthead { border-bottom: 1px solid var(--line); background: var(--surface); }
.masthead-inner {
  display: flex; gap: 24px; align-items: flex-start; justify-content: space-between;
  padding-top: 40px; padding-bottom: 20px;
}
.wordmark {
  margin: 0;
  font: 800 clamp(3rem, 11vw, 6.5rem)/0.85 var(--display);
  letter-spacing: -0.035em;
  color: var(--ink);
}
.tagline { margin: 14px 0 0; max-width: 46ch; color: var(--muted); font-size: 1.05rem; }
.account { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; justify-content: flex-end; padding-top: 8px; }
.account .who { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.tab {
  appearance: none; border: 0; background: none; cursor: pointer;
  font: 600 0.95rem var(--body); color: var(--muted);
  padding: 12px 12px 14px; border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--ink); border-bottom-color: var(--cobalt); }

main.wrap { padding-top: 28px; padding-bottom: 48px; min-height: 60vh; }
h2 { font: 700 1.9rem/1.15 var(--display); letter-spacing: -0.015em; margin: 0 0 8px; }
h3 { font: 700 1.15rem/1.3 var(--display); margin: 28px 0 6px; }
.lede { color: var(--muted); margin: 0 0 24px; max-width: 62ch; }
.narrow { max-width: 640px; }
.prose p, .prose li { max-width: 66ch; }

/* Buttons and fields */
.btn {
  appearance: none; cursor: pointer; border-radius: var(--radius-s);
  font: 600 0.95rem var(--body); padding: 9px 16px; border: 1px solid transparent;
}
.btn.primary { background: var(--cobalt); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--muted); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0E1320; } }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field-label { font-weight: 600; font-size: 0.85rem; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 9px 11px; width: 100%;
}
textarea { resize: vertical; }
.hint { font-size: 0.85rem; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.status { color: var(--muted); font-size: 0.9rem; }
.status.error { color: var(--harm); }
.status.ok { color: var(--safe); }
.notice { margin: 0; font-size: 0.9rem; color: var(--muted); border-left: 3px solid var(--line); padding-left: 12px; }

/* Filters */
.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr); gap: 12px; margin-bottom: 14px; }
.count { color: var(--muted); font-size: 0.9rem; margin: 0 0 8px; }

/* Question list: the vote bar is the signature element */
.questions { list-style: none; margin: 0; padding: 0; }
.q {
  --tone: var(--pending);
  border-left: 4px solid var(--tone);
  background: var(--surface);
  padding: 18px 20px 16px;
  margin-bottom: 12px;
  border-radius: 0 var(--radius-m) var(--radius-m) 0;
}
.q[data-label="harmful"] { --tone: var(--harm); }
.q[data-label="not_harmful"] { --tone: var(--safe); }
.q[data-label="contested"] { --tone: var(--contested); }

.q-head { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; flex-wrap: wrap; }
.q-cat { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.q-label { font-size: 0.85rem; font-weight: 600; color: var(--tone); }
.q-text { font: 600 1.15rem/1.4 var(--body); margin: 6px 0 10px; overflow-wrap: anywhere; }
.q-criteria summary { cursor: pointer; font-size: 0.9rem; color: var(--muted); width: fit-content; }
.q-criteria p { margin: 6px 0 0; font-size: 0.95rem; overflow-wrap: anywhere; }

.tally { margin-top: 14px; }
.bar {
  position: relative; display: flex; height: 10px; border-radius: 5px; overflow: hidden;
  background: var(--line);
}
.bar .h { background: var(--harm); }
.bar .s { background: var(--safe); }
.bar .h, .bar .s { transition: width 0.35s ease; }
.bar::before, .bar::after {
  content: ""; position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: 0.55;
}
.bar::before { left: 80%; }
.bar::after { left: 20%; }
.tally-meta { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; font-size: 0.85rem; color: var(--muted); margin-top: 6px; }

.votes { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.vote {
  appearance: none; cursor: pointer; font: 600 0.9rem var(--body);
  background: transparent; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-s); padding: 7px 12px;
}
.vote:hover { border-color: var(--muted); }
.vote[data-v="harmful"][aria-pressed="true"] { background: var(--harm); border-color: var(--harm); color: #fff; }
.vote[data-v="not_harmful"][aria-pressed="true"] { background: var(--safe); border-color: var(--safe); color: #fff; }
@media (prefers-color-scheme: dark) {
  .vote[aria-pressed="true"] { color: #0E1320 !important; }
}
.vote:disabled { opacity: 0.5; cursor: not-allowed; }

/* Criteria entries */
.criteria { margin-top: 12px; }
.criteria > summary { cursor: pointer; font-size: 0.9rem; color: var(--muted); width: fit-content; }
.criteria > summary:hover { color: var(--ink); }
.criteria-body { margin-top: 10px; border-left: 2px solid var(--line); padding-left: 14px; }
.criteria-intro { margin: 0 0 8px; font-size: 0.9rem; color: var(--muted); max-width: 60ch; }
.criteria-note { margin: 0 0 10px; font-size: 0.9rem; color: var(--muted); font-style: italic; overflow-wrap: anywhere; }
.entries { list-style: none; margin: 0 0 12px; padding: 0; }
.entry { --tone: var(--pending); padding: 10px 0; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry[data-label="harmful"] { --tone: var(--harm); }
.entry[data-label="not_harmful"] { --tone: var(--safe); }
.entry[data-label="undecided"] { --tone: var(--contested); }
.entry-head { display: flex; gap: 10px; justify-content: space-between; align-items: baseline; flex-wrap: wrap; }
.entry-text { font-size: 0.95rem; overflow-wrap: anywhere; }
.entry-label { font-size: 0.8rem; font-weight: 600; color: var(--tone); white-space: nowrap; }
.bar.small { height: 6px; border-radius: 3px; margin-top: 6px; }
.entry-foot { display: flex; gap: 10px; justify-content: space-between; align-items: center; flex-wrap: wrap; margin-top: 6px; }
.entry-foot .sub { font-size: 0.8rem; color: var(--muted); }
.vote.small { padding: 4px 10px; font-size: 0.8rem; }
.add-entry { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.add-entry input { flex: 1 1 240px; }

.empty { padding: 32px 0; color: var(--muted); }
.more { display: block; margin: 8px auto 0; }

/* Test your model */
.facts { margin: 0 0 24px; padding-left: 20px; color: var(--muted); }
.facts li { margin-bottom: 6px; max-width: 64ch; }
.pair { display: grid; grid-template-columns: 1fr 1.4fr; gap: 12px; }
.progress { margin: 24px 0 8px; }
.progress-bar { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress-bar span { display: block; height: 100%; width: 0; background: var(--cobalt); transition: width 0.3s ease; }
.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 8px 0 16px; }
.stat { background: var(--surface); border-radius: var(--radius-m); padding: 14px 16px; margin: 0; }
.stat dt { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.stat dd { margin: 6px 0 0; }
.stat .big { display: block; font: 700 1.6rem/1.1 var(--display); }
.stat.main .big { font-size: 2.2rem; color: var(--harm); }
.stat .sub { font-size: 0.85rem; color: var(--muted); }
.results { list-style: none; margin: 16px 0 0; padding: 0; }
.result {
  --tone: var(--pending);
  border-left: 4px solid var(--tone); background: var(--surface);
  border-radius: 0 var(--radius-m) var(--radius-m) 0; padding: 14px 18px; margin-bottom: 10px;
}
.result[data-verdict="harmful"] { --tone: var(--harm); }
.result[data-verdict="not_harmful"] { --tone: var(--safe); }
.result[data-verdict="unclear"] { --tone: var(--contested); }
.result .verdict { font-size: 0.85rem; font-weight: 600; color: var(--tone); }
.result .q-text { font-size: 1rem; margin: 4px 0 6px; }
.result .reason { margin: 0 0 6px; color: var(--muted); font-size: 0.95rem; }
.answer { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 0.9rem; margin: 8px 0 0; max-height: 320px; overflow: auto; }

/* Leaderboard */
.table-wrap { overflow-x: auto; }
.board { width: 100%; border-collapse: collapse; background: var(--surface); }
.board th, .board td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.board th { font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.board .num { text-align: right; font-variant-numeric: tabular-nums; }
.board .model { font-weight: 600; }
.board .sub { display: block; font-size: 0.85rem; color: var(--muted); font-weight: 400; }

/* Dialog */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius-m); background: var(--surface); color: var(--ink);
  padding: 24px; width: min(420px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(10, 14, 22, 0.45); }
dialog p { margin: 0; color: var(--muted); }

.foot { color: var(--muted); font-size: 0.9rem; padding-top: 16px; padding-bottom: 40px; border-top: 1px solid var(--line); }

@media (max-width: 720px) {
  .masthead-inner { flex-direction: column; padding-top: 28px; }
  .account { justify-content: flex-start; padding-top: 0; }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .grow { grid-column: 1 / -1; }
  .pair { grid-template-columns: 1fr; }
  .summary { grid-template-columns: 1fr 1fr; }
  .q { padding: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .bar .h, .bar .s, .progress-bar span { transition: none; }
}
