:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --ink: #23201c;
  --muted: #7a7268;
  --line: #e8e0d4;
  --accent: #e2543a;
  --accent-ink: #ffffff;
  --accent-soft: #fde6df;
  --good: #2f8a5b;
  --good-soft: #dff2e7;
  --veto: #8b8178;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(35, 32, 28, 0.06), 0 4px 16px rgba(35, 32, 28, 0.05);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #181614;
    --card: #23201d;
    --ink: #f2ede6;
    --muted: #a39a8f;
    --line: #36312b;
    --accent: #f06a4f;
    --accent-ink: #1a0f0c;
    --accent-soft: #3d231c;
    --good: #5cc48c;
    --good-soft: #1e3328;
    --veto: #8f867c;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 "Bricolage Grotesque", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100dvh;
}
main { max-width: 560px; margin: 0 auto; padding: 24px 16px 96px; }

h1 { font-size: clamp(26px, 7vw, 34px); line-height: 1.1; letter-spacing: -0.02em; margin: 8px 0 6px; }
.eyebrow { font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); margin: 0; }
.sub { color: var(--muted); margin: 0 0 20px; font-size: 15px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }

label.field { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
input[type="text"], select {
  width: 100%; font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; outline: none;
}
input[type="text"]:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

button { font: inherit; cursor: pointer; border: 0; border-radius: 12px; }
.btn { background: var(--accent); color: var(--accent-ink); font-weight: 700; padding: 14px 18px; width: 100%; font-size: 17px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); font-weight: 600; }
.btn.small { width: auto; padding: 8px 12px; font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.icon-btn { background: transparent; color: var(--muted); width: 40px; height: 40px; font-size: 20px; flex: none; }

.toggle { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; }
.toggle + .toggle { border-top: 1px solid var(--line); }
.toggle small { display: block; color: var(--muted); font-size: 13px; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }

.error { color: var(--accent); font-size: 14px; min-height: 1.2em; margin: 8px 0 0; }

/* ----- Poll page ----- */
.status { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 18px; }
.pill { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--card); border: 1px solid var(--line); color: var(--muted); }
.pill.live::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); margin-right: 6px; vertical-align: 1px; }
.pill.offline::before { background: var(--veto); }

.opts { list-style: none; padding: 0; margin: 0 0 14px; display: grid; gap: 10px; }
.opt {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px 8px 14px 14px; box-shadow: var(--shadow); transition: border-color .15s;
}
.opt .bar { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); transition: width .35s ease; z-index: 0; }
.opt > *:not(.bar) { position: relative; z-index: 1; }
.opt.mine { border-color: var(--accent); }
.opt.lead .label::after { content: " 👑"; }
.opt.vetoed { opacity: 0.55; }
.opt.vetoed .label { text-decoration: line-through; }
.opt.vetoed .bar { background: transparent; }
.opt.winner { border-color: var(--good); }
.opt.winner .bar { background: var(--good-soft); }

.check {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center; font-size: 16px; font-weight: 800; color: transparent; background: var(--card);
}
.opt.mine .check { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.opt .main { flex: 1; min-width: 0; background: none; text-align: left; padding: 0; color: inherit; display: flex; align-items: center; gap: 12px; }
.opt .label { font-weight: 650; font-size: 17px; overflow-wrap: anywhere; }
.opt .who { font-size: 13px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.opt .count { font-weight: 800; font-size: 20px; min-width: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.veto-btn { background: transparent; color: var(--veto); font-size: 13px; padding: 8px 8px; border-radius: 10px; flex: none; }
.veto-btn.on { background: var(--ink); color: var(--bg); }

.hint { color: var(--muted); font-size: 14px; margin: 4px 2px 16px; }

.winner-card { text-align: center; padding: 28px 16px; }
.winner-card .big { font-size: clamp(32px, 10vw, 48px); font-weight: 800; letter-spacing: -0.02em; line-height: 1.05; margin: 6px 0 4px; overflow-wrap: anywhere; }
.winner-card .emoji { font-size: 44px; }

.sheet {
  position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; align-items: end; z-index: 10;
}
.sheet .card { margin: 0; border-radius: 20px 20px 0 0; padding: 22px 16px calc(22px + env(safe-area-inset-bottom)); max-width: 560px; width: 100%; justify-self: center; }
.sheet h2 { margin: 0 0 4px; font-size: 22px; }

.footer-actions { display: grid; gap: 10px; margin-top: 18px; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20;
}
.toast.show { opacity: 1; }
a { color: var(--accent); }
