:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #1c2430;
  --muted: #66707d;
  --line: #e3e7ec;
  --accent: #3b6ef5;
  --up: #1a9d63;
  --down: #d1495b;
  --divisive: #d99000;
  --radius: 12px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

h1 { font-size: 26px; margin: 0 0 4px; }
.sub { color: var(--muted); margin: 0 0 28px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 18px;
}

.q-label { font-weight: 600; margin-bottom: 10px; }
.q-hint { color: var(--muted); font-size: 13px; font-weight: 400; }

textarea {
  width: 100%;
  min-height: 84px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
}
textarea:focus { outline: 2px solid var(--accent); border-color: transparent; }

.counter { text-align: right; font-size: 12px; color: var(--muted); margin-top: 4px; }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 8px;
  padding: 8px 14px;
}
button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
  padding: 11px 20px;
}
button:disabled { opacity: .5; cursor: not-allowed; }

.err { color: var(--down); margin-top: 12px; min-height: 20px; }
.budget { color: var(--muted); font-size: 13px; font-weight: 400; }

/* results — Q1-3 answers */
.answer {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.answer:first-of-type { border-top: none; }
.answer .text { flex: 1; white-space: pre-wrap; }
.vote-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 46px;
  padding: 4px 8px;
  line-height: 1.1;
}
.vote-btn.on { border-color: var(--accent); color: var(--accent); background: #eef3ff; }
.vote-btn .n { font-weight: 700; font-size: 15px; }
.vote-btn .cap { font-size: 11px; color: var(--muted); }

/* results — Q4 items */
.item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.item:first-of-type { border-top: none; }
.item .label { flex: 1; }
.pill { min-width: 40px; text-align: center; padding: 5px 8px; }
.pill.up.on { border-color: var(--up); color: var(--up); background: #e9f7f0; }
.pill.down.on { border-color: var(--down); color: var(--down); background: #fbecee; }
.score { min-width: 54px; text-align: right; color: var(--muted); font-size: 13px; }

.center { text-align: center; }
a.btnlink { text-decoration: none; }

/* admin Q4 vote table — real columns, aligned across every row */
table.q4 { width: 100%; border-collapse: collapse; }
table.q4 td {
  padding: 9px 6px; border-top: 1px solid var(--line);
  white-space: nowrap;
}
table.q4 tr:first-child td { border-top: none; }
table.q4 td.word { width: 100%; white-space: normal; }
table.q4 td.metric {
  text-align: right;
  color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums;
}
/* fixed-width number box so digits AND the arrow line up row to row */
table.q4 td.metric .n {
  display: inline-block; min-width: 2.2ch; text-align: right; margin-left: 4px;
}
table.q4 td.metric.net { padding-right: 16px; padding-left: 22px; }
table.q4 td.metric.net .n { min-width: 3.2ch; font-weight: 700; color: var(--ink); }

/* whole row very lightly tinted by category; Quiet stays neutral */
table.q4 tr.cat-liked td    { background: color-mix(in srgb, var(--up) 9%, transparent); }
table.q4 tr.cat-disliked td { background: color-mix(in srgb, var(--down) 9%, transparent); }
table.q4 tr.cat-divisive td { background: color-mix(in srgb, var(--divisive) 13%, transparent); }

/* admin question tabs */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 22px 0 14px; }
.tab {
  padding: 7px 18px; border: 1px solid var(--line); background: var(--card);
  border-radius: 8px; font-weight: 600; color: var(--muted);
}
.tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }

.login { display: flex; gap: 8px; margin-bottom: 20px; }
.login input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px; font: inherit; }

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171c; --card: #1d2129; --ink: #e7ebf0; --muted: #97a1ad;
    --line: #2c323c; --accent: #5a86ff; --divisive: #e0a92a;
  }
  .vote-btn.on { background: #23304f; }
  .pill.up.on { background: #17362a; }
  .pill.down.on { background: #3a1f24; }
}
