:root {
  --bg: #0b1020;
  --bg-2: #121a33;
  --card: #161f3d;
  --line: #26325c;
  --text: #f2f4fa;
  --muted: #9aa6c8;
  --orange: #f7941d;
  --orange-2: #ffb347;
  --blue: #3b82f6;
  --blue-2: #7ab3ff;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --pro: var(--orange);
  --con: var(--blue);
  --radius: 14px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
body { min-height: 100dvh; display: flex; flex-direction: column; -webkit-font-smoothing: antialiased; }
a { color: var(--blue-2); }
button { font: inherit; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--red); }
.center { text-align: center; }
.inline { display: inline; }
[hidden] { display: none !important; }

/* ---------- brand header (voter) ---------- */
.brand { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.brand .logo { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-name { font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { color: var(--muted); font-size: 0.85rem; }
.conn { margin-left: auto; color: var(--muted); font-size: 0.8rem; }
.conn.on { color: var(--green); }
.conn.off { color: var(--red); }
.foot { padding: 10px 16px 20px; color: var(--muted); font-size: 0.8rem; text-align: center; margin-top: auto; }

/* ---------- voter ---------- */
main { padding: 16px; width: 100%; max-width: 640px; margin: 0 auto; }
main.narrow { max-width: 420px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 14px; }
.card h1 { font-size: 1.4rem; margin: 0 0 8px; }
.card h2 { font-size: 1.1rem; margin: 0 0 8px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.motion { font-size: 1.05rem; line-height: 1.4; margin: 8px 0 0; }
.prompt { font-size: 1.35rem; font-weight: 700; line-height: 1.3; margin: 4px 0 16px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; color: var(--muted); }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-size: 1rem;
}
textarea { min-height: 90px; resize: vertical; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); cursor: pointer; font-weight: 600; }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #1a1000; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 0.85rem; border-radius: 8px; }
.btn.xs { padding: 3px 8px; font-size: 0.75rem; border-radius: 6px; }

.vote-grid { display: grid; gap: 12px; }
.vote-btn { padding: 22px 16px; font-size: 1.35rem; font-weight: 800; border-radius: 16px; border: 2px solid var(--line); background: var(--bg-2); color: var(--text); cursor: pointer; transition: transform 0.05s; min-height: 76px; }
.vote-btn:active { transform: scale(0.98); }
.vote-btn.pro { border-color: var(--pro); }
.vote-btn.con { border-color: var(--con); }
.vote-btn.for { border-color: var(--orange); }
.vote-btn.against { border-color: var(--blue); }
.vote-btn.undecided { border-color: var(--muted); }
.vote-btn.selected.pro, .vote-btn.selected.for { background: var(--orange); color: #1a1000; }
.vote-btn.selected.con, .vote-btn.selected.against { background: var(--blue); color: #fff; }
.vote-btn.selected.undecided { background: var(--muted); color: #0b1020; }
.vote-btn small { display: block; font-size: 0.85rem; font-weight: 500; opacity: 0.8; margin-top: 4px; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.pill.open { background: rgba(34,197,94,0.15); color: var(--green); }
.pill.closed { background: rgba(154,166,200,0.15); color: var(--muted); }
.pill.pro { background: rgba(247,148,29,0.15); color: var(--orange); }
.pill.con { background: rgba(59,130,246,0.15); color: var(--blue-2); }
.pill.draw { background: rgba(154,166,200,0.15); color: var(--muted); }
.confirm { margin-top: 12px; color: var(--green); font-weight: 600; }

.bars { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.bar { display: grid; grid-template-columns: 90px 1fr 56px; align-items: center; gap: 10px; font-size: 0.95rem; }
.bar .track { height: 18px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; border-radius: 999px; background: var(--muted); transition: width 0.6s ease; }
.bar.pro .fill, .bar.for .fill { background: var(--orange); }
.bar.con .fill, .bar.against .fill { background: var(--blue); }
.bar .pct { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.bar .lbl { font-weight: 600; }

.scoreboard { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; text-align: center; }
.scoreboard .side { display: flex; flex-direction: column; gap: 2px; }
.scoreboard .side .n { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.scoreboard .side.pro .n { color: var(--orange); }
.scoreboard .side.con .n { color: var(--blue-2); }
.scoreboard .side .who { font-size: 0.85rem; color: var(--muted); }
.scoreboard .vs { color: var(--muted); font-size: 0.8rem; }
.rounds-dots { display: flex; gap: 6px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bg-2); border: 1px solid var(--line); }
.dot.pro { background: var(--orange); border-color: var(--orange); }
.dot.con { background: var(--blue); border-color: var(--blue); }
.dot.draw { background: var(--muted); }
.dot.open { border-color: var(--green); box-shadow: 0 0 0 3px rgba(34,197,94,0.25); }

.winner { text-align: center; padding: 8px 0; }
.winner .lbl { color: var(--muted); font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.08em; }
.winner .who { font-size: 2rem; font-weight: 900; margin: 4px 0; }
.winner.pro .who { color: var(--orange); }
.winner.con .who { color: var(--blue-2); }
.swing { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.swing .box { background: var(--bg-2); border-radius: 10px; padding: 10px; text-align: center; }
.swing .box .v { font-size: 1.5rem; font-weight: 800; }
.swing .box.pro .v { color: var(--orange); }
.swing .box.con .v { color: var(--blue-2); }
.swing .box .k { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 10px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); cursor: pointer; font-weight: 600; }
.chip.selected { background: var(--orange); border-color: var(--orange); color: #1a1000; }
.ask-toggle { width: 100%; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--card); border: 1px solid var(--line); padding: 10px 16px; border-radius: 10px; z-index: 50; }
.toast.err { border-color: var(--red); }

/* ---------- screen (16:9 projector) ---------- */
body.screen { overflow: hidden; }
#screen { height: 100dvh; display: grid; grid-template-rows: auto 1fr auto; padding: 2.2vh 3vw; gap: 1.5vh; }
.scr-top { display: flex; align-items: center; justify-content: space-between; }
.scr-brand { display: flex; align-items: center; gap: 1.2vw; }
.scr-brand img { width: 7vh; height: 7vh; border-radius: 1vh; object-fit: cover; }
.scr-title { font-size: 3.2vh; font-weight: 800; }
.scr-sub { font-size: 2.2vh; color: var(--muted); }
.scr-timer { text-align: right; }
.scr-timer-label { font-size: 2.2vh; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.scr-timer-val { font-size: 8vh; font-weight: 900; font-variant-numeric: tabular-nums; line-height: 1; color: var(--text); }
.scr-timer.warn .scr-timer-val { color: var(--amber); }
.scr-timer.done .scr-timer-val { color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.scr-main { display: flex; flex-direction: column; justify-content: center; align-items: stretch; gap: 3vh; }
.scr-kicker { font-size: 3vh; color: var(--orange); text-transform: uppercase; letter-spacing: 0.15em; font-weight: 700; }
.scr-q { font-size: 6.5vh; font-weight: 800; line-height: 1.15; }
.scr-q.long { font-size: 5vh; }
.scr-motion { font-size: 4.5vh; line-height: 1.25; font-weight: 600; }
.scr-sides { display: grid; grid-template-columns: 1fr 1fr; gap: 3vw; }
.scr-side { padding: 3vh; border-radius: 2vh; border: 0.5vh solid var(--line); text-align: center; }
.scr-side.pro { border-color: var(--orange); }
.scr-side.con { border-color: var(--blue); }
.scr-side .tag { font-size: 2.6vh; text-transform: uppercase; letter-spacing: 0.15em; font-weight: 800; }
.scr-side.pro .tag { color: var(--orange); }
.scr-side.con .tag { color: var(--blue-2); }
.scr-side .name { font-size: 4vh; font-weight: 700; margin-top: 1vh; }
.scr-side .title { font-size: 2.4vh; color: var(--muted); }
.scr-lobby-qr { display: grid; grid-template-columns: auto 1fr; gap: 4vw; align-items: center; }
.scr-lobby-qr img { width: 42vh; height: 42vh; border-radius: 2vh; background: #fff; padding: 1.5vh; }
.scr-big-url { font-size: 7vh; font-weight: 900; color: var(--orange); letter-spacing: 0.02em; }
.scr-how { font-size: 3.2vh; color: var(--muted); margin-top: 1.5vh; line-height: 1.3; }
.scr-bottom { display: flex; align-items: flex-end; justify-content: space-between; }
.scr-join { display: flex; align-items: center; gap: 1.5vw; }
.scr-join img { width: 14vh; height: 14vh; background: #fff; border-radius: 1.2vh; padding: 0.6vh; }
.scr-join-label { font-size: 2.2vh; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.scr-url { font-size: 4vh; font-weight: 800; color: var(--orange); }
.scr-status { font-size: 3.4vh; font-weight: 800; padding: 1.4vh 2.4vw; border-radius: 999px; border: 0.4vh solid var(--line); color: var(--muted); }
.scr-status.open { border-color: var(--green); color: var(--green); animation: glow 1.6s infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 1vh rgba(34,197,94,0.18); } }
.scr-offline { position: fixed; top: 1vh; right: 1vw; font-size: 1.8vh; color: var(--amber); }
.scr-reveal { display: grid; grid-template-columns: 1fr 1fr; gap: 3vw; align-items: start; }
.scr-reveal .panel { background: var(--card); border-radius: 2vh; padding: 2.5vh; }
.scr-reveal h3 { margin: 0 0 1.5vh; font-size: 2.6vh; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.scr-reveal .bar { grid-template-columns: 18vh 1fr 12vh; font-size: 3vh; }
.scr-reveal .bar .track { height: 4vh; }
.scr-winner { text-align: center; }
.scr-winner .who { font-size: 12vh; font-weight: 900; line-height: 1; }
.scr-winner.pro .who { color: var(--orange); }
.scr-winner.con .who { color: var(--blue-2); }
.scr-winner .why { font-size: 3vh; color: var(--muted); margin-top: 1.5vh; }
.scr-qa-name { font-size: 3vh; color: var(--muted); margin-top: 2vh; }

/* ---------- admin ---------- */
body.admin main { max-width: 1280px; }
.adm-top { display: flex; align-items: center; justify-content: space-between; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--bg-2); flex-wrap: wrap; gap: 8px; }
.adm-brand { display: flex; align-items: center; gap: 10px; }
.adm-brand img { width: 32px; height: 32px; border-radius: 6px; }
.adm-nav { display: flex; gap: 14px; align-items: center; font-size: 0.9rem; }
.adm-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
@media (max-width: 900px) { .adm-grid { grid-template-columns: 1fr; } }
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-width: 110px; }
.stat .k { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.stat .v { font-size: 1.3rem; font-weight: 800; }
.item { display: grid; grid-template-columns: 48px 1fr auto; gap: 10px; align-items: start; padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--bg-2); }
.item.current { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(247,148,29,0.25); }
.item.open { border-color: var(--green); }
.item.void { opacity: 0.5; }
.item .num { font-weight: 800; color: var(--muted); text-align: center; padding-top: 4px; font-size: 0.8rem; letter-spacing: 0.04em; }
.item .prompt-a { font-weight: 600; line-height: 1.3; }
.item .prompt-a[contenteditable]:focus { outline: 1px solid var(--blue); border-radius: 4px; padding: 2px; }
.item .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 6px; font-size: 0.85rem; color: var(--muted); }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; max-width: 240px; }
.mini-bars { display: flex; gap: 4px; margin-top: 6px; height: 8px; border-radius: 999px; overflow: hidden; background: var(--bg); }
.mini-bars span { display: block; height: 100%; }
.mini-bars .pro, .mini-bars .for { background: var(--orange); }
.mini-bars .con, .mini-bars .against { background: var(--blue); }
.mini-bars .undecided { background: var(--muted); }
.q { padding: 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: var(--bg-2); }
.q.starred { border-color: var(--orange); }
.q.asked { opacity: 0.55; }
.q .qt { line-height: 1.35; }
.q .qm { font-size: 0.8rem; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.timer-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timer-box .big { font-size: 2rem; font-weight: 900; font-variant-numeric: tabular-nums; min-width: 100px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
table.t { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.t th, table.t td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { color: var(--muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; }
.kbd { font-family: ui-monospace, Menlo, monospace; font-size: 0.8rem; background: var(--bg); padding: 2px 6px; border-radius: 4px; border: 1px solid var(--line); }

/* ---------- run-of-show timeline ---------- */
.tl { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 10px; margin-bottom: 14px; }
.tl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.tl-head h2 { margin: 0; }
.tl-delta { font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-delta.ok { color: var(--green); } .tl-delta.behind { color: var(--amber); } .tl-delta.late { color: var(--red); } .tl-delta.ahead { color: var(--blue-2); }
.tl svg { width: 100%; height: 74px; display: block; overflow: visible; }
.tl .seg { rx: 4; ry: 4; cursor: default; }
.tl .seg:hover, .tl .seg.hover { filter: brightness(1.2); }
.tl .seg.done { opacity: 0.45; }
.tl .tick { stroke: var(--line); stroke-width: 1; }
.tl .tick-lbl { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.tl .seg-lbl { fill: #ffffff; font-size: 11px; font-weight: 700; pointer-events: none; }
.tl .now { stroke: #ffffff; stroke-width: 2; }
.tl .now-lbl { fill: #ffffff; font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tl-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.78rem; color: var(--muted); margin-top: 6px; align-items: center; }
.tl-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.tl-tip { position: fixed; z-index: 60; pointer-events: none; background: #0b1020; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 0.82rem; min-width: 180px; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.tl-tip .t { font-weight: 700; margin-bottom: 2px; }
.tl-tip .m { color: var(--muted); }
