/* Live Poll — midnight black, deep azure, coral rose */
:root {
  --ink: #0A0D14;          /* midnight black */
  --panel: #0D111B;
  --surface: #121826;
  --surface-2: #1C2438;
  --track: #151C2C;
  --line: #263048;
  --text: #EEF1F7;
  --text-2: #C3CBDA;
  --muted: #9AA4B8;
  --faint: #8791A6;
  --azure: #1D5BD6;        /* deep azure */
  --azure-soft: #7FA6FF;
  --azure-tint: #14244A;
  --azure-ring: #4F86FF;
  --coral: #F2727F;        /* coral rose */
  --coral-tint: #2A1820;
  --green: #3DD68C;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --display: 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--text); font-family: var(--font); }
body { min-height: 100vh; -webkit-font-smoothing: antialiased; }
a { color: var(--coral); }
a:hover { color: #F7A0A8; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--azure-ring); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.display { font-family: var(--display); }

/* ---------- shared pieces ---------- */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo { flex-shrink: 0; width: 32px; height: 32px; border-radius: 9px; background: var(--azure); display: grid; place-items: center; }
.logo svg { width: 55%; height: 55%; }
.brand-name { font-family: var(--display); font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 13px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 13px; color: var(--text-2); white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.dot.live { background: var(--green); }
.dot.coral { background: var(--coral); }
.dot.pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

.eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--azure-soft); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font-size: 15px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); color: var(--text); }
.btn svg { width: 18px; height: 18px; flex-shrink: 0; }
.btn-primary { background: var(--coral); border-color: var(--coral); color: var(--ink); }
.btn-primary:hover { background: #F58A95; color: var(--ink); }
.btn-azure { background: var(--azure); border-color: var(--azure); color: #fff; }
.btn-azure:hover { background: #2A68E3; color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--azure-soft); }
.btn-ghost:hover { background: var(--surface); color: var(--azure-soft); }
.btn-danger { color: var(--coral); }
.btn:disabled { background: var(--surface-2); border-color: var(--surface-2); color: var(--faint); }
.icon-btn { width: 44px; padding: 0; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; letter-spacing: .06em; padding: 5px 10px; border-radius: 999px; }
.badge.open { background: var(--green); color: var(--ink); }
.badge.closed { background: var(--coral); color: var(--ink); }
.badge.blank { background: #2A3350; color: var(--text); }

.notice { padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: 14px; line-height: 1.5; }
.notice.error { border-color: #7A2E38; background: #22121A; color: #FFC2C8; }
.notice.ok { border-color: #1E5E43; background: #0F2219; color: #A9F0CB; }

/* ---------- results (shared by host, projector, phones) ---------- */
.results { display: flex; flex-direction: column; gap: 14px; }
.r-row { display: grid; grid-template-columns: 1.6em minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; }
.r-letter { font-family: var(--display); font-weight: 700; color: var(--azure-soft); }
.r-label { min-width: 0; overflow-wrap: anywhere; }
.r-value { text-align: right; font-weight: 600; white-space: nowrap; }
.r-value small { color: var(--faint); font-weight: 400; font-size: .85em; }
.r-bar { grid-column: 2 / 4; height: 12px; border-radius: 6px; background: var(--track); overflow: hidden; }
.r-fill { height: 100%; width: 0; border-radius: inherit; background: var(--azure); transition: width .6s ease; }
.r-fill.lead { background: var(--coral); }
.r-avg { display: flex; align-items: baseline; gap: 10px; }
.r-avg b { font-family: var(--display); font-size: 2.4em; line-height: 1; }
.r-cloud { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .2em .7em; line-height: 1.15; padding: 8px 0; }
.r-cloud span { font-family: var(--display); font-weight: 600; overflow-wrap: anywhere; }
.r-cloud .c0 { color: var(--coral); }
.r-cloud .c1 { color: var(--azure-soft); }
.r-cloud .c2 { color: var(--text); }
.r-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.r-card { padding: 14px 16px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); line-height: 1.45; overflow-wrap: anywhere; }
.r-empty { color: var(--faint); }

/* ---------- login ---------- */
.login { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.login form { width: min(400px, 100%); display: flex; flex-direction: column; gap: 18px; padding: 32px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); }
.login h1 { margin: 0; font-family: var(--display); font-size: 26px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field > label, .label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.input { width: 100%; min-height: 48px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--ink); color: var(--text); font-size: 16px; }
textarea.input { padding: 14px; min-height: 0; resize: vertical; line-height: 1.4; }
.input::placeholder { color: #6B7690; }

/* ---------- attendee phone ---------- */
body.attendee { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }
.a-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 16px 20px; padding-top: max(16px, env(safe-area-inset-top)); border-bottom: 1px solid #1C2438; }
.a-main { flex: 1; width: 100%; max-width: 560px; margin: 0 auto; padding: 26px 20px 20px; display: flex; flex-direction: column; gap: 18px; }
.a-foot { text-align: center; padding: 14px 20px; padding-bottom: max(18px, env(safe-area-inset-bottom)); font-size: 12px; color: var(--faint); }
.a-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.a-q { margin: 0; font-family: var(--display); font-weight: 700; font-size: clamp(24px, 6.6vw, 32px); line-height: 1.16; letter-spacing: -.01em; overflow-wrap: anywhere; }
.a-hint { font-size: 14px; color: var(--muted); margin: -6px 0 0; }
.choices { display: flex; flex-direction: column; gap: 12px; }
.choice { display: flex; align-items: center; gap: 14px; width: 100%; min-height: 60px; padding: 12px 16px; border-radius: 14px; background: var(--surface); border: 2px solid #232C42; color: var(--text); font-size: 16px; font-weight: 500; text-align: left; }
.choice .key { flex-shrink: 0; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--azure-soft); font-family: var(--display); font-weight: 700; font-size: 15px; }
.choice[aria-pressed="true"] { background: var(--azure-tint); border-color: var(--azure-ring); }
.choice[aria-pressed="true"] .key { background: var(--azure); color: #fff; }
.choice span:last-child { overflow-wrap: anywhere; }
.rating { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.rating .choice { justify-content: center; padding: 0; font-family: var(--display); font-size: 22px; font-weight: 700; min-height: 64px; }
.rating-ends { display: flex; justify-content: space-between; font-size: 13px; color: var(--faint); margin-top: -8px; }
.counter { text-align: right; font-size: 12px; color: var(--faint); margin-top: -10px; }
.a-submit { width: 100%; min-height: 56px; border-radius: 14px; font-size: 17px; }
.spacer { flex: 1; }
.a-center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; text-align: center; padding: 20px 8px; }
.a-center h2 { margin: 0; font-family: var(--display); font-size: 26px; }
.a-center p { margin: 0; color: var(--muted); line-height: 1.5; max-width: 34ch; }
.a-center p strong { color: var(--text); }
.ring { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: var(--coral-tint); border: 2px solid var(--coral); }
.ring svg { width: 34px; height: 34px; }
.ring.azure { background: var(--azure-tint); border-color: var(--azure-ring); }
.a-results { width: 100%; text-align: left; padding: 18px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.a-results .r-cloud { font-size: 15px; }

/* ---------- projector ---------- */
html.screen { font-size: min(1.25vw, 2.2222vh); } /* 24px on 1920×1080, scales to any projector */
body.screen { height: 100vh; overflow: hidden; cursor: default; }
body.screen.idle { cursor: none; }
.s-wrap { position: relative; height: 100vh; display: flex; flex-direction: column; padding: 3rem 4rem 0; gap: 2rem; overflow: hidden; }
.s-wrap::before, .s-wrap::after { content: ''; position: absolute; border-radius: 50%; border: 2px solid #1A2540; pointer-events: none; }
.s-wrap::before { right: -9rem; top: -11rem; width: 30rem; height: 30rem; }
.s-wrap::after { right: -5rem; top: -7rem; width: 22rem; height: 22rem; }
.s-top { position: relative; display: flex; justify-content: space-between; align-items: center; gap: 2rem; }
.s-top .logo { width: 1.7rem; height: 1.7rem; border-radius: .5rem; }
.s-top .brand { gap: .7rem; }
.s-top .brand-name { font-size: 1.1rem; }
.s-meta { display: flex; gap: .8rem; }
.s-meta .pill { font-size: .95rem; padding: .5rem 1rem; gap: .6rem; }
.s-meta .pill b { color: var(--text); }
.s-meta .dot { width: .5rem; height: .5rem; }
.s-stage { position: relative; flex: 1; min-height: 0; display: flex; }
.s-split { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 4rem; align-items: center; }
.s-stack { flex: 1; display: flex; flex-direction: column; gap: 2rem; min-height: 0; }
.s-qblock { display: flex; flex-direction: column; gap: 1.2rem; }
.s-qblock .eyebrow { font-size: .92rem; }
.s-q { margin: 0; font-family: var(--display); font-weight: 700; font-size: 3.5rem; line-height: 1.04; letter-spacing: -.02em; overflow-wrap: anywhere; }
.s-q.long { font-size: 2.6rem; }
.s-stack .s-q { font-size: 2.8rem; }
.s-sub { margin: 0; font-size: 1.1rem; color: var(--muted); }
.s-stage .results { gap: 1.1rem; font-size: 1.15rem; }
.s-stage .r-row { gap: .3rem .8rem; }
.s-stage .r-value { font-family: var(--display); font-size: 1.4rem; }
.s-stage .r-bar { height: 1.4rem; border-radius: .45rem; }
.s-stage .r-avg { font-size: 1.1rem; margin-bottom: .4rem; }
.s-stage .r-avg b { font-size: 3.4rem; }
.s-stage .r-cloud { flex: 1; font-size: 1rem; align-content: center; }
.s-stage .r-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; font-size: 1.05rem; align-content: start; }
.s-stage .r-card { padding: 1rem 1.2rem; border-radius: .7rem; }
.s-waiting { display: flex; align-items: center; gap: 1rem; font-size: 1.3rem; color: var(--muted); }
.s-lobby { flex: 1; display: flex; align-items: center; justify-content: center; gap: 5rem; }
.s-lobby .qr { width: 18rem; height: 18rem; border-radius: 1.2rem; padding: .8rem; background: #fff; }
.s-lobby h1 { margin: 0 0 1rem; font-family: var(--display); font-size: 4.4rem; line-height: 1; letter-spacing: -.02em; }
.s-lobby p { margin: 0; font-size: 1.4rem; color: var(--muted); }
.s-lobby .s-url { display: block; margin-top: .6rem; font-size: 2.8rem; color: var(--text); }
.s-foot { position: relative; margin: 0 -4rem; padding: 1.1rem 4rem; background: var(--surface); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.s-foot .join { display: flex; align-items: center; gap: 1.2rem; }
.s-foot .qr { width: 4.2rem; height: 4.2rem; border-radius: .5rem; background: #fff; padding: .2rem; }
.s-foot .join span { display: block; }
.s-foot .muted { font-size: .92rem; }
.s-url { font-family: var(--display); font-weight: 600; font-size: 1.7rem; }
.s-status { font-size: 1rem; }
.s-status .badge { font-size: .85rem; padding: .4rem .9rem; }
.s-blank .s-top, .s-blank .s-foot, .s-blank .s-stage { visibility: hidden; }
.s-blank .s-wrap::before, .s-blank .s-wrap::after { display: none; }
.s-hint { position: fixed; left: 50%; bottom: 1.4rem; transform: translateX(-50%); padding: .6rem 1.2rem; border-radius: 999px; background: rgba(18,24,38,.92); border: 1px solid var(--line); font-size: .85rem; color: var(--text-2); transition: opacity .4s; z-index: 5; }
.s-offline { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); z-index: 6; }

/* ---------- host + editor (app shell) ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-between; align-items: center; padding: 14px 24px; border-bottom: 1px solid #1C2438; background: var(--panel); }
.topbar .sep { color: #4A5570; }
.topbar .crumb { font-size: 15px; color: var(--text-2); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.toolbar form { margin: 0; }
.body { flex: 1; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 280px; max-width: 360px; padding: 22px 16px; display: flex; flex-direction: column; gap: 8px; background: var(--panel); border-right: 1px solid #1C2438; }
.side-head { display: flex; justify-content: space-between; align-items: center; padding: 0 6px 6px; }
.side-head h2 { margin: 0; font-size: 13px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.side-head span { font-size: 13px; color: var(--faint); }
.qitem { display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--text); text-align: left; }
.qitem:hover { background: var(--surface); }
.qitem[aria-current="true"] { background: var(--azure-tint); border-color: var(--azure-ring); }
.qnum { flex-shrink: 0; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); font-size: 13px; font-weight: 700; }
.qitem[aria-current="true"] .qnum { background: var(--azure); color: #fff; }
.qtext { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.qtext b { font-size: 14px; font-weight: 500; line-height: 1.35; overflow-wrap: anywhere; }
.qtext small { font-size: 12px; color: var(--faint); }
.live-tag { flex-shrink: 0; font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--ink); background: var(--coral); border-radius: 6px; padding: 4px 7px; }
.main { flex: 999 1 560px; min-width: 0; padding: 26px; display: flex; flex-direction: column; gap: 22px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 26px; display: flex; flex-direction: column; gap: 18px; }
.card-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.card h1 { margin: 0; font-family: var(--display); font-weight: 700; font-size: 32px; line-height: 1.15; letter-spacing: -.01em; overflow-wrap: anywhere; }
.card-foot { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; padding-top: 14px; border-top: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.card-foot strong { color: var(--text); }
.card .results { font-size: 15px; }
.card .r-cloud { font-size: 15px; background: var(--panel); border-radius: 12px; padding: 18px; }
.card .r-card { background: var(--panel); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.tile { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; min-height: 92px; padding: 16px 18px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-align: left; }
.tile small { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .85; }
.tile b { font-family: var(--display); font-size: 20px; }
.tile kbd { margin-top: auto; font-family: var(--font); font-size: 11px; opacity: .7; }
.tile[aria-pressed="true"].t-voting { background: var(--azure); border-color: var(--azure); color: #fff; }
.tile[aria-pressed="true"].t-results { background: var(--coral); border-color: var(--coral); color: var(--ink); }
.tile[aria-pressed="true"].t-blank { background: #2A3350; border-color: #3A4566; }
.tile:disabled { opacity: .45; }
.nav { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }
.nav .group { display: flex; flex-wrap: wrap; gap: 10px; }
.nav .btn { min-height: 52px; font-size: 16px; }
.empty { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.empty p { margin: 0; color: var(--muted); }
.kbd-help { font-size: 13px; color: var(--faint); }
.kbd-help kbd { display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); font-family: var(--font); font-size: 12px; text-align: center; }

/* editor */
.ed-item { display: flex; align-items: center; gap: 6px; border-radius: 12px; border: 1px solid transparent; }
.ed-item[aria-current="true"] { background: var(--azure-tint); border-color: var(--azure-ring); }
.ed-item .qitem { flex: 1; min-width: 0; border: none; background: transparent; padding: 10px 6px 10px 10px; }
.ed-item .qitem:hover { background: transparent; }
.ed-item .moves { display: flex; flex-direction: column; padding-right: 4px; }
.ed-item .moves button { width: 36px; height: 30px; border: none; background: transparent; color: var(--faint); border-radius: 6px; display: grid; place-items: center; }
.ed-item .moves button:hover:not(:disabled) { background: var(--surface-2); color: var(--text); }
.ed-item .moves button:disabled { opacity: .25; }
.ed-item .moves svg { width: 16px; height: 16px; }
.add-q { margin-top: 6px; min-height: 48px; border-radius: 12px; border: 1.5px dashed #34405E; background: transparent; color: var(--azure-soft); font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 8px; }
.add-q svg { width: 16px; height: 16px; }
.ed-form { max-width: 760px; display: flex; flex-direction: column; gap: 24px; }
.ed-form .q-input { font-family: var(--display); font-size: 22px; font-weight: 600; }
.pills { display: flex; flex-wrap: wrap; gap: 10px; }
.pills button { min-height: 44px; padding: 0 18px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text-2); font-size: 15px; font-weight: 600; }
.pills button[aria-pressed="true"] { background: var(--azure); border-color: var(--azure); color: #fff; }
.opt-row { display: flex; align-items: center; gap: 12px; }
.opt-row .key { flex-shrink: 0; width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2); color: var(--azure-soft); display: grid; place-items: center; font-family: var(--display); font-weight: 700; }
.opt-row .input { background: var(--surface); }
fieldset { border: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
legend { padding: 0; margin-bottom: 10px; font-size: 14px; font-weight: 600; color: var(--text-2); }
.settings { padding-top: 20px; border-top: 1px solid #1C2438; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; font-size: 15px; }
.check input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--azure); flex-shrink: 0; }
.check select { min-height: 40px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); }
.ed-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; }

@media (max-width: 640px) {
  .main { padding: 18px; }
  .card { padding: 20px; }
  .card h1 { font-size: 26px; }
  .topbar { padding: 12px 16px; }
  .side { max-width: none; border-right: none; border-bottom: 1px solid #1C2438; }
}
