:root {
  --bg: #ffffff;
  --surface: #f4f6f9;
  --text: #14181d;
  --muted: #687280;
  --line: #e3e7ed;
  --accent: #2f6fb2;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 111, 178, 0.10);
  --accent-mid: rgba(47, 111, 178, 0.18);
  --warn: #a15c00;
  --warn-soft: rgba(201, 120, 0, 0.12);
  --danger: #b42318;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #181c22;
    --text: #e8ebef;
    --muted: #9aa4af;
    --line: #272d36;
    --accent: #6aa6e6;
    --accent-ink: #0b1420;
    --accent-soft: rgba(106, 166, 230, 0.12);
    --accent-mid: rgba(106, 166, 230, 0.22);
    --warn: #f0b45a;
    --warn-soft: rgba(240, 180, 90, 0.12);
    --danger: #f97066;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main {
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { margin: 0; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.pad { padding: 48px 0; }
.stack > * + * { margin-top: 12px; }

/* Top bar */
.bar { display: flex; align-items: center; justify-content: space-between; min-height: 40px; margin-bottom: 8px; }
.brand { font-weight: 600; font-size: 15px; letter-spacing: 0.01em; }
.link { background: none; border: 0; padding: 8px 0; color: var(--accent); font-size: 15px; }
.link.quiet { color: var(--muted); }

/* Poll heading */
.day { margin: 12px 0 4px; font-size: 26px; font-weight: 650; letter-spacing: -0.01em; }
.status { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: 15px; margin-bottom: 16px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.dot.off { background: var(--muted); }

.banner {
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 16px;
  margin-bottom: 16px;
}
.banner .label { font-size: 13px; opacity: 0.85; text-transform: uppercase; letter-spacing: 0.06em; }
.banner .winner { font-size: 24px; font-weight: 650; margin-top: 2px; }
.banner.tied, .banner.none { background: var(--warn-soft); color: var(--text); }
.banner.tied .label, .banner.none .label { color: var(--warn); opacity: 1; }
.banner .actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* Options */
.options { list-style: none; margin: 0; padding: 0; }
.options li + li { margin-top: 8px; }
.options li.rest { margin-top: 20px; }
.options li.rest::before { content: ""; display: block; height: 1px; background: var(--line); margin-bottom: 20px; }
.row {
  display: flex;
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
  position: relative;
}
.row .fill { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); transition: width 0.3s ease; pointer-events: none; }
.row.mine { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.row.mine .fill { background: var(--accent-mid); }
.row.won { border-color: var(--accent); }
.vote {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  min-height: 52px;
  padding: 12px 14px;
  background: none; border: 0; text-align: left;
  position: relative;
}
.vote:disabled { cursor: default; }
.vote .name { font-weight: 500; }
.row.mine .vote .name { font-weight: 650; }
.check {
  width: 20px; height: 20px; flex: none; border-radius: 50%;
  border: 1.5px solid var(--line);
  display: grid; place-items: center;
}
.row.mine .check { background: var(--accent); border-color: var(--accent); }
.row.mine .check::after { content: ""; width: 6px; height: 10px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
.tag { font-size: 12px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }
.count {
  min-width: 56px;
  background: none; border: 0; border-left: 1px solid var(--line);
  font-variant-numeric: tabular-nums; font-weight: 600;
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 4px;
}
.count .chev { font-size: 11px; color: var(--muted); transition: transform 0.15s; }
.count[aria-expanded="true"] .chev { transform: rotate(180deg); }
.voters { padding: 6px 14px 2px 44px; color: var(--muted); font-size: 14px; }
.voters .remove { margin-left: 8px; }

.flash { animation: flash 0.6s ease; }
@keyframes flash { from { background: var(--accent-mid); } to { background: transparent; } }

/* Add option */
.add { margin-top: 12px; }
.add-btn { width: 100%; min-height: 48px; border: 1px dashed var(--line); background: none; border-radius: var(--radius); color: var(--muted); }
.inline-form { display: flex; gap: 8px; }
.inline-form input { flex: 1; min-width: 0; }

input[type="text"], input[type="password"], input[type="time"], input:not([type]) {
  min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg);
}
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn {
  min-height: 48px; padding: 0 18px;
  border-radius: var(--radius); border: 1px solid var(--accent);
  background: var(--accent); color: var(--accent-ink); font-weight: 600;
}
.btn.ghost { background: none; color: var(--accent); }
.btn.small { min-height: 38px; padding: 0 12px; font-size: 14px; font-weight: 500; }
.btn.danger { border-color: var(--danger); color: var(--danger); background: none; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.block { width: 100%; }

/* Footer */
.foot { display: flex; flex-wrap: wrap; gap: 4px 18px; justify-content: center; margin-top: 32px; padding-top: 16px; border-top: 1px solid var(--line); }
.foot .link { font-size: 14px; color: var(--muted); }

/* Login */
.login { padding-top: 10vh; }
.login h1 { font-size: 26px; font-weight: 650; margin-bottom: 4px; }
.names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.names button { min-height: 52px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); font-weight: 500; }
.pin-dots { display: flex; justify-content: center; gap: 16px; margin: 24px 0; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--muted); }
.pin-dots span.on { background: var(--text); border-color: var(--text); }
.pad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 300px; margin: 0 auto; }
.pad-grid button { height: 64px; border-radius: 50%; border: 0; background: var(--surface); font-size: 24px; font-weight: 500; width: 64px; justify-self: center; }
.pad-grid button.blank { visibility: hidden; }
.pad-grid button.back { background: none; font-size: 15px; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; min-height: 20px; }

/* Lists (history, admin) */
.card { background: var(--surface); border-radius: var(--radius); padding: 14px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list button.rowlink { all: unset; display: flex; width: 100%; gap: 12px; align-items: center; cursor: pointer; }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 28px 0 8px; }
.h2 { font-size: 22px; font-weight: 650; margin: 8px 0 4px; }
.pill { font-size: 12px; border-radius: 999px; padding: 2px 8px; background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.pill.on { color: var(--accent); border-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; color: var(--muted); }
.field input { color: var(--text); font-size: 16px; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.toggle input { width: 20px; height: 20px; accent-color: var(--accent); }
textarea { width: 100%; min-height: 180px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); color: var(--text); font: inherit; }
.actions-row { display: flex; flex-wrap: wrap; gap: 8px; }
.guest-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.guest-name { font-weight: 600; }

#toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text); color: var(--bg);
  padding: 10px 16px; border-radius: 999px; font-size: 14px;
  max-width: calc(100% - 32px);
}
