/* handsup design system. See docs/design.md (토큰, DOM 계약).
   - CSP style-src 'self': 인라인 style 속성 금지. 동적 값은 CSSOM(el.style.setProperty('--pct', '62%'))만 쓴다.
   - 역할 스코프는 조상 클래스(.audience / .present / .admin). 실서비스는 body에, 목업은 섹션에 붙인다.
   - 상태는 is-* 클래스. 라이트/다크는 청중·관리만, 발표 화면은 고대비 단일 테마. */

/* ---------- 1. 토큰 ---------- */
:root {
  color-scheme: light dark;

  --c-bg: #f5f5f2;
  --c-surface: #ffffff;
  --c-surface-2: #eeede9;
  --c-fg: #16181d;
  --c-muted: #5b616b;
  --c-border: #d8d7d2;
  --c-accent: #c24e0e;
  --c-accent-fg: #ffffff;
  --c-accent-soft: #fdebe0;
  --c-bar: #c24e0e;
  --c-bar-track: #eceae5;
  --c-ok: #1d7348;
  --c-ok-soft: #e1f2e8;
  --c-warn: #8a5800;
  --c-warn-soft: #fcf0d4;
  --c-danger: #b42318;
  --c-danger-soft: #fde6e3;
  --c-focus: #2463d1;

  --font-sans: system-ui, -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --font-num: ui-rounded, system-ui, -apple-system, "Apple SD Gothic Neo", sans-serif;
  --fs-xs: 0.8125rem;   /* 13px 메타 */
  --fs-sm: 0.9375rem;   /* 15px 보조 */
  --fs-md: 1.0625rem;   /* 17px 본문 */
  --fs-lg: 1.25rem;     /* 20px 카드 제목 */
  --fs-xl: 1.5rem;      /* 24px 문항 */
  --fs-2xl: 2rem;       /* 32px 비율 */
  --fs-3xl: 2.75rem;    /* 44px 관리 핵심 비율 */
  --fw-regular: 400;
  --fw-bold: 700;
  --fw-black: 800;
  --lh: 1.5;
  --lh-tight: 1.25;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --radius: 14px;
  --radius-sm: 8px;
  --radius-pill: 999px;
  --tap: 56px;          /* 최소 터치 높이 (F-41) */
  --tap-sm: 44px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04);
  --dur: 160ms;
}

/* 다크: OS 설정 또는 목업용 .theme-dark 조상 */
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) {
    --c-bg: #0f1115;
    --c-surface: #181b21;
    --c-surface-2: #22262e;
    --c-fg: #eceef2;
    --c-muted: #a2a8b3;
    --c-border: #2f343d;
    --c-accent: #ff8a4c;
    --c-accent-fg: #1b0d04;
    --c-accent-soft: #3a2316;
    --c-bar: #ff8a4c;
    --c-bar-track: #2a2e36;
    --c-ok: #52c78f;
    --c-ok-soft: #14301f;
    --c-warn: #f0c04f;
    --c-warn-soft: #33290f;
    --c-danger: #ff6b5e;
    --c-danger-soft: #3b1714;
    --c-focus: #7aa7ff;
    --shadow: none;
  }
}
.theme-dark {
  color-scheme: dark;
  --c-bg: #0f1115;
  --c-surface: #181b21;
  --c-surface-2: #22262e;
  --c-fg: #eceef2;
  --c-muted: #a2a8b3;
  --c-border: #2f343d;
  --c-accent: #ff8a4c;
  --c-accent-fg: #1b0d04;
  --c-accent-soft: #3a2316;
  --c-bar: #ff8a4c;
  --c-bar-track: #2a2e36;
  --c-ok: #52c78f;
  --c-ok-soft: #14301f;
  --c-warn: #f0c04f;
  --c-warn-soft: #33290f;
  --c-danger: #ff6b5e;
  --c-danger-soft: #3b1714;
  --c-focus: #7aa7ff;
  --shadow: none;
}

/* 발표 화면: 프로젝터 고대비 단일 테마. OS 다크 설정을 무시한다 */
.present {
  color-scheme: light;
  --c-bg: #ffffff;
  --c-surface: #ffffff;
  --c-surface-2: #f1f1ee;
  --c-fg: #000000;
  --c-muted: #3b4048;
  --c-border: #c9c9c4;
  --c-accent: #c24e0e;
  --c-accent-fg: #ffffff;
  --c-bar: #1f2a44;
  --c-bar-top: #c24e0e;
  --c-bar-track: #e6e5e0;
  --c-accent-soft: #fdebe0;
  --c-ok: #1d7348;
  --c-ok-soft: #e1f2e8;
  --c-warn: #8a5800;
  --c-warn-soft: #fcf0d4;
  --c-danger: #b42318;
  --c-danger-soft: #fde6e3;
  --c-focus: #2463d1;
  --shadow: none;
}

/* ---------- 2. 기본 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: var(--fw-regular) var(--fs-md) / var(--lh) var(--font-sans);
  color: var(--c-fg);
  background: var(--c-bg);
  -webkit-tap-highlight-color: transparent;
  word-break: keep-all;
  overflow-wrap: anywhere;
}
h1, h2, h3, p, ul, ol { margin: 0; }
h1, h2, .poll-q, .p-question, .idle-title { text-wrap: balance; }
ul, ol { padding: 0; list-style: none; }
img { display: block; max-width: 100%; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--c-focus); outline-offset: 2px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
[hidden] { display: none !important; }

#app, .app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 0 var(--sp-4) calc(var(--sp-6) + env(safe-area-inset-bottom));
}

/* ---------- 3. 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--tap-sm);
  padding: 0 var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: background var(--dur), border-color var(--dur), opacity var(--dur);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: 0.38; cursor: not-allowed; transform: none; }
.btn-lg { min-height: var(--tap); font-size: var(--fs-md); border-radius: var(--radius); }
.btn-block { width: 100%; }
.btn-primary { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-fg); }
.btn-ok { background: var(--c-ok); border-color: var(--c-ok); color: #fff; }
.btn-danger { background: var(--c-danger); border-color: var(--c-danger); color: #fff; }
.btn-ghost { background: transparent; }
.btn-danger-ghost { background: transparent; border-color: var(--c-danger); color: var(--c-danger); }
.theme-dark .btn-ok, .theme-dark .btn-danger { color: #0f1115; }
@media (prefers-color-scheme: dark) {
  :root:not(.theme-light) .btn-ok, :root:not(.theme-light) .btn-danger { color: #0f1115; }
}

/* ---------- 4. 공통 조각 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: var(--sp-3);
  min-height: 52px;
  margin: 0 calc(-1 * var(--sp-4));
  padding: calc(var(--sp-2) + env(safe-area-inset-top)) var(--sp-4) var(--sp-2);
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
}
.topbar-title {
  flex: 1; min-width: 0;
  font-size: var(--fs-sm); font-weight: var(--fw-bold);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* 연결 상태 배지 */
.conn {
  display: inline-flex; align-items: center; gap: 6px;
  flex: none;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  background: var(--c-surface-2); color: var(--c-muted);
}
.conn::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: currentColor;
}
.conn.is-online { background: var(--c-ok-soft); color: var(--c-ok); }
.conn.is-connecting, .conn.is-retrying { background: var(--c-warn-soft); color: var(--c-warn); }
.conn.is-retrying::before, .conn.is-connecting::before { animation: blink 1s steps(2, start) infinite; }
.conn.is-offline { background: var(--c-danger-soft); color: var(--c-danger); }
@keyframes blink { to { visibility: hidden; } }

.pill {
  display: inline-flex; align-items: center;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
  background: var(--c-surface-2); color: var(--c-muted);
  white-space: nowrap;
}
.pill.is-open { background: var(--c-ok-soft); color: var(--c-ok); }
.pill.is-closed { background: var(--c-surface-2); color: var(--c-fg); }
.pill.is-revealed { background: var(--c-accent-soft); color: var(--c-accent); }
.pill.is-live { background: var(--c-accent); color: var(--c-accent-fg); }
.pill.is-answered { background: var(--c-ok-soft); color: var(--c-ok); }
.pill.is-hidden { background: var(--c-danger-soft); color: var(--c-danger); }

.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--sp-4);
}
.section { margin-top: var(--sp-5); }
.section-title {
  display: flex; align-items: center; gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--c-muted);
}
.muted { color: var(--c-muted); }
.stack > * + * { margin-top: var(--sp-3); }

/* 안내·오류 띠 */
.notice {
  margin-top: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--c-surface-2);
  font-size: var(--fs-sm);
}
.notice.is-warn { background: var(--c-warn-soft); color: var(--c-warn); }
.notice.is-error { background: var(--c-danger-soft); color: var(--c-danger); }
.notice .btn { margin-top: var(--sp-2); }

/* 토스트: #app 밖 .toasts(role=status, aria-live=polite)에 .toast 추가, 3초 후 제거 */
.toasts {
  position: fixed; left: 0; right: 0; z-index: 50;
  bottom: calc(var(--sp-4) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; align-items: center; gap: var(--sp-2);
  padding: 0 var(--sp-4);
  pointer-events: none;
}
.admin .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); }
.toast {
  max-width: 520px;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  background: var(--c-fg); color: var(--c-bg);
  font-size: var(--fs-sm); font-weight: var(--fw-bold);
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
  animation: toast-in var(--dur) ease-out;
}
.toast.is-error { background: var(--c-danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* 전체 화면 안내 (연결 중, 없는 이벤트) */
.screen-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--sp-3);
  min-height: 70vh;
  text-align: center;
}
.screen-center h1 { font-size: var(--fs-xl); line-height: var(--lh-tight); }
.screen-center p { color: var(--c-muted); }
.spinner {
  width: 32px; height: 32px;
  border: 3px solid var(--c-border); border-top-color: var(--c-accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 탭 (청중 상단, 관리 하단) */
.tabs {
  display: flex; gap: var(--sp-1);
  padding: var(--sp-1);
  border-radius: var(--radius);
  background: var(--c-surface-2);
}
.tab {
  position: relative;
  flex: 1;
  min-height: var(--tap-sm);
  border: 0; border-radius: calc(var(--radius) - 4px);
  background: transparent;
  font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--c-muted);
  cursor: pointer;
}
.tab.is-active { background: var(--c-surface); color: var(--c-fg); box-shadow: var(--shadow); }
.tab .dot {
  position: absolute; top: 8px; margin-left: 4px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--c-accent);
}

/* 세그먼트 (정렬 P1) */
.seg { display: inline-flex; border: 1px solid var(--c-border); border-radius: var(--radius-pill); overflow: hidden; }
.seg button {
  min-height: 32px; padding: 0 12px; border: 0; background: transparent;
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--c-muted); cursor: pointer;
}
.seg button.is-active { background: var(--c-fg); color: var(--c-bg); }

/* ---------- 5. 투표 ---------- */
.poll-head { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.poll-q {
  margin-top: var(--sp-2);
  font-size: var(--fs-xl); font-weight: var(--fw-bold); line-height: var(--lh-tight);
}
.poll-sub { margin-top: var(--sp-2); font-size: var(--fs-sm); color: var(--c-muted); }

.options { margin-top: var(--sp-4); display: grid; gap: var(--sp-3); }
.option {
  display: flex; align-items: center; gap: var(--sp-3);
  width: 100%;
  min-height: 64px;
  padding: var(--sp-3) var(--sp-4);
  border: 2px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
  font-size: var(--fs-lg); font-weight: var(--fw-bold); text-align: left;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color var(--dur), background var(--dur);
}
.option::before {
  content: ""; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--c-border);
  background: var(--c-surface);
}
.option.is-selected { border-color: var(--c-accent); background: var(--c-accent-soft); }
.option.is-selected::before {
  border-color: var(--c-accent);
  background: var(--c-accent);
  box-shadow: inset 0 0 0 4px var(--c-surface);
}
.option.is-pending { opacity: 0.6; }   /* ack 대기 */
.option:disabled { cursor: default; opacity: 0.55; }
.option:disabled.is-selected { opacity: 1; }

.voted {
  display: flex; align-items: center; gap: var(--sp-3);
  margin-top: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  background: var(--c-ok-soft); color: var(--c-ok);
  font-weight: var(--fw-bold);
}
.voted::before {
  content: "✓"; flex: none;
  display: grid; place-items: center;
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--c-ok); color: var(--c-surface);
}
.voted small { display: block; font-weight: var(--fw-regular); font-size: var(--fs-xs); }

.waiting-box {
  margin-top: var(--sp-4);
  padding: var(--sp-5) var(--sp-4);
  border: 2px dashed var(--c-border);
  border-radius: var(--radius);
  text-align: center; color: var(--c-muted);
}
.waiting-box strong { display: block; color: var(--c-fg); font-size: var(--fs-lg); }

/* 결과 막대: .result 에 --pct (0%~100%) 를 CSSOM으로 설정 */
.results { margin-top: var(--sp-4); display: grid; gap: var(--sp-3); }
.result { --pct: 0%; }
.result-row { display: flex; align-items: baseline; gap: var(--sp-2); }
.result-label { flex: 1; min-width: 0; font-weight: var(--fw-bold); }
.result-pct { font-family: var(--font-num); font-size: var(--fs-2xl); font-weight: var(--fw-black); line-height: 1; font-variant-numeric: tabular-nums; }
.result-count { font-size: var(--fs-xs); color: var(--c-muted); font-variant-numeric: tabular-nums; min-width: 3.5em; text-align: right; }
.bar {
  margin-top: 6px;
  height: 12px;
  border-radius: var(--radius-pill);
  background: var(--c-bar-track);
  overflow: hidden;
}
.bar-fill {
  width: var(--pct);
  height: 100%;
  border-radius: inherit;
  background: var(--c-bar);
  transition: width 400ms ease-out;
}
.result.is-mine .result-label::after {
  content: "내 선택";
  margin-left: var(--sp-2);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--c-accent-soft); color: var(--c-accent);
  font-size: var(--fs-xs);
  vertical-align: 2px;
}
.results-total { margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--c-muted); text-align: right; }

/* ---------- 6. Q&A ---------- */
.ask { padding: var(--sp-3); }
.ask-input {
  display: block; width: 100%;
  min-height: 88px;
  padding: var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  font-size: 16px; /* iOS 확대 방지 */
  line-height: var(--lh);
  resize: vertical;
}
.ask-input:disabled { opacity: 0.5; }
.ask-foot { display: flex; align-items: center; gap: var(--sp-3); margin-top: var(--sp-2); }
.ask-hint { flex: 1; font-size: var(--fs-xs); color: var(--c-muted); }
.ask-count { font-size: var(--fs-xs); color: var(--c-muted); font-variant-numeric: tabular-nums; }
.ask-count.is-over { color: var(--c-danger); font-weight: var(--fw-bold); }

.qlist { display: grid; gap: var(--sp-2); }
.qlist-head { display: flex; align-items: center; justify-content: space-between; margin: var(--sp-5) 0 var(--sp-3); }
.qlist-head h2 { font-size: var(--fs-sm); color: var(--c-muted); }
.q {
  display: flex; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-3) var(--sp-3) var(--sp-4);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  background: var(--c-surface);
}
.q-body { flex: 1; min-width: 0; }
.q-text { white-space: pre-wrap; }
.q-meta { display: flex; align-items: center; gap: var(--sp-2); margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--c-muted); }
.q.is-mine { border-color: var(--c-accent); }
.q.is-answered { background: var(--c-surface-2); }
.q.is-answered .q-text { color: var(--c-muted); }
.q.is-hidden { border-style: dashed; opacity: 0.6; }
.q.is-hidden .q-text { text-decoration: line-through; }
.q.is-displayed { border: 2px solid var(--c-accent); box-shadow: 0 0 0 3px var(--c-accent-soft); }

.like {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: none;
  width: 56px; min-height: 56px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-size: var(--fs-xs); font-weight: var(--fw-bold); color: var(--c-muted);
  cursor: pointer;
  touch-action: manipulation;
}
.like::before { content: "♥"; font-size: 18px; line-height: 1; }
.like-count { font-variant-numeric: tabular-nums; }
.like.is-liked { border-color: var(--c-accent); background: var(--c-accent-soft); color: var(--c-accent); }
.like:disabled { cursor: default; opacity: 0.5; }
.like.is-static { border-color: transparent; background: transparent; cursor: default; }

.empty { padding: var(--sp-6) var(--sp-4); text-align: center; color: var(--c-muted); font-size: var(--fs-sm); }

/* ---------- 7. 청중 ---------- */
.audience .tabs { margin-top: var(--sp-3); }
.audience .card { margin-top: var(--sp-4); }

/* ---------- 8. 관리 ---------- */
.admin #app, .admin .app { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

.statusbar { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-3); }
.stat {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
}
.stat-label { font-size: var(--fs-xs); color: var(--c-muted); }
.stat-num { font-family: var(--font-num); font-size: var(--fs-lg); font-weight: var(--fw-black); font-variant-numeric: tabular-nums; }
.stat .conn { margin-top: 2px; }
.stat.is-alert { border-color: var(--c-danger); background: var(--c-danger-soft); }

/* 발표 표시 대상 바 (F-54) */
.display-bar {
  position: sticky; top: 52px; z-index: 9;
  display: flex; align-items: center; gap: var(--sp-3);
  margin: var(--sp-3) calc(-1 * var(--sp-4)) 0;
  padding: var(--sp-2) var(--sp-4);
  background: var(--c-fg); color: var(--c-bg);
}
.display-bar-label { font-size: var(--fs-xs); opacity: 0.75; }
.display-bar-target { flex: 1; min-width: 0; font-size: var(--fs-sm); font-weight: var(--fw-bold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.display-bar .btn { border-color: currentColor; background: transparent; color: inherit; min-height: 40px; }
.display-bar.is-none { background: var(--c-surface-2); color: var(--c-muted); }

/* 관리 투표 카드 */
.apoll { margin-top: var(--sp-4); }
.apoll.is-open { border: 2px solid var(--c-ok); }
.apoll.is-displayed { box-shadow: 0 0 0 3px var(--c-accent-soft); }
.apoll-no { font-family: var(--font-num); font-weight: var(--fw-black); }
.apoll-slide { font-size: var(--fs-xs); color: var(--c-muted); margin-left: auto; }
.apoll .poll-q { font-size: var(--fs-lg); }
.apoll .result-pct { font-size: var(--fs-2xl); }
/* D1~D3 판단 기준 선택지 (PollView.focus → li.is-focus) */
.apoll .result.is-focus .result-pct { font-size: var(--fs-3xl); color: var(--c-accent); }
.apoll .result.is-focus .result-label::after {
  content: "판단 기준";
  margin-left: var(--sp-2);
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--c-accent-soft); color: var(--c-accent);
  font-size: var(--fs-xs);
  vertical-align: 2px;
}
.apoll-total { display: flex; justify-content: space-between; margin-top: var(--sp-3); font-size: var(--fs-sm); color: var(--c-muted); }
.apoll-total strong { color: var(--c-fg); font-variant-numeric: tabular-nums; }
.apoll .results.is-private .bar-fill { background: var(--c-muted); } /* 공개 전: 회색 막대, 나만 보는 값 */

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-4); }
.actions .btn { min-height: var(--tap); font-size: var(--fs-md); }
.actions .act-reveal { grid-column: 1 / -1; }
.actions .act-show, .actions .act-reset { min-height: var(--tap-sm); font-size: var(--fs-sm); }

/* 2단계 확인 (투표 초기화, 전체 초기화) */
.confirm {
  grid-column: 1 / -1;
  padding: var(--sp-3);
  border-radius: var(--radius-sm);
  background: var(--c-danger-soft); color: var(--c-danger);
  font-size: var(--fs-sm);
}
.confirm-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); margin-top: var(--sp-2); }
.confirm-actions .btn { min-height: var(--tap-sm); }

.q-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-top: var(--sp-2); }
.q-actions .btn { min-height: 40px; padding: 0 var(--sp-3); font-size: var(--fs-xs); }
.q-actions .act-display.is-active { background: var(--c-accent); border-color: var(--c-accent); color: var(--c-accent-fg); }

.switch-row { display: flex; align-items: center; gap: var(--sp-3); }
.switch-row > div { flex: 1; }

.danger-zone { border-color: var(--c-danger); }
.danger-zone h2 { color: var(--c-danger); font-size: var(--fs-md); }

/* 토큰 입력 */
.auth { margin-top: min(15vh, 120px); }
.auth h1 { font-size: var(--fs-xl); }
.auth p { margin-top: var(--sp-2); color: var(--c-muted); font-size: var(--fs-sm); }
.field { display: block; margin-top: var(--sp-4); }
.field-label { display: block; margin-bottom: var(--sp-1); font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.token-input {
  width: 100%; min-height: var(--tap);
  padding: 0 var(--sp-3);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-size: 16px;
  font-family: ui-monospace, Menlo, monospace;
}
.token-input.is-invalid { border-color: var(--c-danger); }
.form-error { margin-top: var(--sp-2); color: var(--c-danger); font-size: var(--fs-sm); font-weight: var(--fw-bold); }
.auth .btn { margin-top: var(--sp-4); }

/* 하단 탭 (한 손 조작) */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: var(--sp-2) var(--sp-4) calc(var(--sp-2) + env(safe-area-inset-bottom));
  background: var(--c-bg);
  border-top: 1px solid var(--c-border);
}
.bottom-nav .tabs { max-width: 528px; margin: 0 auto; }
.bottom-nav .tab { min-height: var(--tap); }

/* ---------- 9. 발표 화면 ----------
   .stage 가 크기 컨테이너. 모든 치수는 --u (16:9 기준 1u = 화면 폭 1%) 로 계산한다.
   실서비스: body.present #app.stage = 100vw×100vh. 목업: aspect-ratio 16/9 상자. */
body.present { background: #000; }
.present .stage, .present #app.stage {
  --u: min(1cqw, 1.7778cqh);
  position: relative;
  container-type: size;
  width: 100vw; height: 100vh; height: 100dvh;
  max-width: none; min-height: 0;
  margin: 0; padding: 0;
  overflow: hidden;
  background: var(--c-bg);
  color: var(--c-fg);
  cursor: none;
}
.present .slide {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  padding: calc(var(--u) * 4) calc(var(--u) * 5) calc(var(--u) * 4);
  font-size: calc(var(--u) * 2.4);
  line-height: var(--lh-tight);
}
.present .p-kicker { font-size: calc(var(--u) * 1.8); font-weight: var(--fw-bold); color: var(--c-muted); }
.present .p-question {
  margin-top: calc(var(--u) * 1);
  max-width: 78%;
  font-size: calc(var(--u) * 4.2); font-weight: var(--fw-black);
  letter-spacing: -0.01em;
}

/* 발표 결과 */
.present .results { flex: 1; align-content: center; gap: calc(var(--u) * 2.2); margin-top: calc(var(--u) * 2); max-width: 78%; }
.present .result-label { font-size: calc(var(--u) * 3); }
.present .result-pct { font-size: calc(var(--u) * 5.6); }
.present .result-count { font-size: calc(var(--u) * 1.8); color: var(--c-muted); min-width: 5em; }
.present .bar { height: calc(var(--u) * 2.2); margin-top: calc(var(--u) * 0.6); border-radius: calc(var(--u) * 0.4); }
.present .bar-fill { border-radius: 0; }
.present .result.is-top .bar-fill { background: var(--c-bar-top); }
.present .result.is-top .result-pct { color: var(--c-bar-top); }
.present .result.is-mine .result-label::after { content: none; }
.present .results-total { font-size: calc(var(--u) * 2); text-align: left; margin-top: 0; }

/* 공개 전: 막대 없이 참여 수만 (F-26, F-27) */
.present .p-count {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
}
.present .p-count-num {
  font-family: var(--font-num);
  font-size: calc(var(--u) * 16); font-weight: var(--fw-black); line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--c-accent);
}
.present .p-count-label { margin-top: calc(var(--u) * 1); font-size: calc(var(--u) * 3); font-weight: var(--fw-bold); }
.present .p-options { display: flex; flex-wrap: wrap; gap: calc(var(--u) * 1.2); margin-top: calc(var(--u) * 2); max-width: 78%; }
.present .p-options li {
  padding: calc(var(--u) * 0.6) calc(var(--u) * 1.6);
  border: calc(var(--u) * 0.2) solid var(--c-border);
  border-radius: calc(var(--u) * 0.6);
  font-size: calc(var(--u) * 2.2); font-weight: var(--fw-bold);
}
.present .p-status { font-size: calc(var(--u) * 2); font-weight: var(--fw-bold); color: var(--c-muted); }
.present .p-status.is-open { color: var(--c-ok); }

/* 질문 1개 (F-34) */
.present .p-quote {
  flex: 1;
  display: flex; flex-direction: column; justify-content: center;
  max-width: 80%;
}
.present .p-quote-text {
  font-size: calc(var(--u) * 4.4); font-weight: var(--fw-bold); line-height: 1.35;
  white-space: pre-wrap;
}
.present .p-quote-text.is-long { font-size: calc(var(--u) * 3.2); }   /* 150자 초과 */
.present .p-quote-meta { margin-top: calc(var(--u) * 2); font-size: calc(var(--u) * 2.2); color: var(--c-muted); }

/* 대기 화면: 큰 QR + 주소 (F-51) */
.present .idle {
  position: absolute; inset: 0;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: calc(var(--u) * 6);
  padding: calc(var(--u) * 6);
}
.present .idle-title { font-size: calc(var(--u) * 3.6); font-weight: var(--fw-black); line-height: 1.25; }
.present .idle-cta { margin-top: calc(var(--u) * 3); font-size: calc(var(--u) * 2.4); color: var(--c-muted); }
.present .idle-url { margin-top: calc(var(--u) * 1); font-size: calc(var(--u) * 4.4); white-space: nowrap; font-weight: var(--fw-black); color: var(--c-accent); letter-spacing: -0.01em; }
.present .qr-lg {
  width: calc(var(--u) * 34); height: calc(var(--u) * 34);
  image-rendering: pixelated;
  background: #fff;
}

/* 구석 QR + 주소 (F-52) */
.present .corner {
  position: absolute; right: calc(var(--u) * 2); bottom: calc(var(--u) * 2);
  display: flex; flex-direction: column; align-items: center; gap: calc(var(--u) * 0.5);
  padding: calc(var(--u) * 0.8);
  background: #fff;
  border: calc(var(--u) * 0.15) solid var(--c-border);
  border-radius: calc(var(--u) * 0.8);
}
.present .qr-sm { width: calc(var(--u) * 13); height: calc(var(--u) * 13); image-rendering: pixelated; }
.present .corner-url { font-size: calc(var(--u) * 1.5); font-weight: var(--fw-black); }
.present .idle ~ .corner { display: none; }

/* 발표 화면 연결 배지: 정상일 때 숨김, 문제일 때만 좌하단 작게 */
.present .stage > .conn {
  position: absolute; left: calc(var(--u) * 1.5); bottom: calc(var(--u) * 1.5);
  padding: calc(var(--u) * 0.3) calc(var(--u) * 1);
  font-size: calc(var(--u) * 1.2);
}
.present .stage > .conn.is-online { display: none; }
.present .stage.is-stale .slide { opacity: 0.85; }

/* 발표 화면 전체 안내 (연결 중, 없는 이벤트) */
.present .screen-center { position: absolute; inset: 0; min-height: 0; gap: calc(var(--u) * 1.5); }
.present .screen-center h1 { font-size: calc(var(--u) * 4); }
.present .screen-center p { font-size: calc(var(--u) * 2); }
.present .spinner { width: calc(var(--u) * 4); height: calc(var(--u) * 4); border-width: calc(var(--u) * 0.4); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
