:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16202b;
  --muted: #5b6875;
  --line: #dde2e8;
  --accent: #0f6e78;
  --accent-ink: #ffffff;
  --accent-soft: #e2f1f2;
  --bar: #0f6e78;
  --bar-track: #e8ecf0;
  --danger: #b42318;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1419;
    --surface: #182029;
    --text: #e8edf2;
    --muted: #9aa7b4;
    --line: #2a3541;
    --accent: #4fbdc6;
    --accent-ink: #062226;
    --accent-soft: #173238;
    --bar: #4fbdc6;
    --bar-track: #24303b;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
button, input, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
[hidden] { display: none !important; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 0.6rem 1rem;
  cursor: pointer;
  min-height: 44px;
}
.btn:hover { border-color: var(--accent); }
.btn:focus-visible, .choice:focus-within, textarea:focus-visible, input:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 45%, transparent);
  outline-offset: 2px;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- audience (phone) ---------- */
.phone { max-width: 560px; margin: 0 auto; padding: 16px 16px 48px; }
.phone header { padding: 8px 0 16px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.phone header h1 { font-size: 1.05rem; }
.section { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.75rem; font-weight: 600; color: var(--accent); }
.phone h2 { font-size: 1.35rem; margin: 6px 0 4px; }
.choices { display: grid; gap: 10px; margin: 18px 0; padding: 0; border: 0; }
.choice {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius);
  padding: 14px 14px; cursor: pointer; min-height: 52px;
}
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; flex: none; }
textarea, input[type="text"] {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 12px; resize: vertical;
}
textarea { min-height: 130px; }
.counter { text-align: right; font-size: 0.8rem; color: var(--muted); }
.actions { display: flex; gap: 10px; justify-content: space-between; margin-top: 8px; }
.actions .btn.primary { flex: 1; }
.notice {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 20px; text-align: center; margin-top: 12px;
}
.notice h2 { margin-bottom: 6px; }
.error { color: var(--danger); font-size: 0.9rem; min-height: 1.4em; margin: 4px 0 0; }
.progress { height: 6px; background: var(--bar-track); border-radius: 3px; overflow: hidden; margin: 6px 0 18px; }
.progress span { display: block; height: 100%; background: var(--accent); transition: width 0.3s; }

/* ---------- results (shared) ---------- */
.bars { display: grid; gap: 14px; }
.bar-row { display: grid; gap: 4px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; }
.bar-label .pct { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.bar-label .pct small { font-weight: 400; color: var(--muted); margin-left: 6px; }
.bar-track { height: 14px; background: var(--bar-track); border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--bar); border-radius: 7px; transition: width 0.5s ease; min-width: 2px; }
.wall { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; align-content: start; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; overflow-wrap: anywhere;
}
.card .tag { display: block; margin-top: 8px; font-size: 0.75rem; color: var(--muted); }
.card.is-hidden { opacity: 0.4; }
.card .hide {
  position: absolute; top: 6px; right: 6px; border: 0; background: none; cursor: pointer;
  color: var(--muted); font-size: 0.8rem; padding: 4px 6px; border-radius: 6px; opacity: 0;
}
.card:hover .hide, .card .hide:focus-visible { opacity: 1; }
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.tabs .btn { min-height: 36px; padding: 0.3rem 0.8rem; font-size: 0.9rem; }
.empty { color: var(--muted); padding: 24px 0; }

/* ---------- presenter screen ---------- */
.stage {
  display: grid; grid-template-columns: 1fr 300px; gap: 32px;
  min-height: 100vh; padding: 36px 40px 96px; font-size: clamp(16px, 1.25vw, 22px);
}
.stage main { display: flex; flex-direction: column; min-width: 0; }
.stage h1 { font-size: 2.1em; margin: 8px 0 6px; }
.stage .meta { margin-bottom: 28px; }
.stage .bars { gap: 18px; }
.stage .bar-track { height: 22px; border-radius: 11px; }
.reveal {
  margin-top: 28px; padding: 16px 20px; border-left: 5px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 var(--radius) var(--radius) 0; font-weight: 600;
}
.stage aside {
  display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center;
  position: sticky; top: 36px; align-self: start;
}
.qr { background: #fff; padding: 12px; border-radius: var(--radius); width: 100%; }
.qr img { display: block; width: 100%; height: auto; }
.join-url { font-size: 1.05em; font-weight: 700; overflow-wrap: anywhere; }
.stat { font-size: 2.4em; font-weight: 800; line-height: 1; }
.toolbar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: 0 6px 24px rgb(0 0 0 / 0.12);
  font-size: 15px; transition: opacity 0.3s;
}
.toolbar.idle { opacity: 0; }
.toolbar .btn { min-height: 38px; padding: 0.35rem 0.8rem; }
.toolbar .pos { align-self: center; padding: 0 6px; font-variant-numeric: tabular-nums; color: var(--muted); }
.hidden-results { color: var(--muted); font-size: 1.4em; padding: 40px 0; }

@media (max-width: 900px) {
  .stage { grid-template-columns: 1fr; padding: 20px 16px 120px; }
  .stage aside { position: static; flex-direction: row; text-align: left; }
  .qr { width: 120px; flex: none; }
}

/* ---------- admin ---------- */
.admin { max-width: 980px; margin: 0 auto; padding: 24px 16px 64px; }
.admin header { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 24px; }
.admin .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.admin .panel h3 { margin: 4px 0 4px; font-size: 1.1rem; }
.admin .panel .meta { margin-bottom: 14px; }
.admin .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.admin .wall { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); font-size: 0.95rem; }
.admin .others { margin-top: 14px; }
.keygate { max-width: 420px; margin: 15vh auto; padding: 0 16px; display: grid; gap: 12px; }
