:root {
  --bg: #0d1116;
  --surface: #151b22;
  --surface-2: #1d252e;
  --surface-3: #27313c;
  --line: #2a343f;
  --text: #e7ebf0;
  --muted: #8c98a6;
  --accent: #5aa9ff;
  --accent-ink: #07213d;
  --speaking: #3fd08a;
  --danger: #ea5a5f;
  --danger-ink: #fff;
  --host: #e3ab45;
  /* 수업 도구 */
  --star: #ffcf4a;
  --star-ink: #2b1d00;
  --hand: #ff9d5c;
  --hand-ink: #2b1200;
  --pick: #ff8fb1;
  --pick-ink: #2e0a17;
  --timer: var(--accent);
  --opt-1: #f06a6f;
  --opt-2: var(--accent);
  --opt-3: var(--host);
  --opt-4: var(--speaking);
  --radius: 12px;
  --font: "Pretendard", "Pretendard Variable", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.muted { color: var(--muted); font-weight: 400; }

/* ---------- 버튼 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover:not(:disabled) { background: #7bbcff; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: var(--danger-ink); }
.btn-danger:hover:not(:disabled) { background: #f27479; }
.btn-ghost { background: transparent; }

.icon-btn {
  width: 32px; height: 32px; border: 0; border-radius: 8px;
  background: transparent; font-size: 22px; line-height: 1; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }

/* ---------- 로비 ---------- */
.lobby {
  min-height: 100%;
  display: grid; place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, rgba(90,169,255,.10), transparent 60%),
    radial-gradient(700px 480px at 100% 110%, rgba(63,208,138,.06), transparent 60%),
    var(--bg);
}
.lobby-card {
  width: 100%; max-width: 420px;
  padding: 32px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.lobby-title { margin: 0 0 6px; font-size: 26px; letter-spacing: -.02em; }
.lobby-sub { margin: 0 0 22px; color: var(--muted); font-size: 14px; }

.notice {
  margin: 0 0 18px; padding: 11px 14px;
  border-radius: 10px;
  background: rgba(90,169,255,.10);
  border: 1px solid rgba(90,169,255,.35);
  font-size: 14px;
}
.notice.warn { background: rgba(234,90,95,.10); border-color: rgba(234,90,95,.45); }

.field { display: block; margin-bottom: 16px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input {
  width: 100%; padding: 11px 13px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.field input::placeholder { color: #55616e; }
.field input:focus-visible { outline-offset: 0; border-color: var(--accent); }
.hint { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; }
.form-error { margin: 0 0 12px; color: #ff8d91; font-size: 13px; }
.lobby-divider {
  display: flex; align-items: center; gap: 12px;
  margin: 20px 0 16px;
  color: var(--muted); font-size: 12px;
}
.lobby-divider::before, .lobby-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---------- 회의 레이아웃 ---------- */
.meeting {
  height: 100vh; height: 100dvh;
  display: flex; flex-direction: column;
}

.topbar {
  flex: none;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { flex-wrap: wrap; justify-content: flex-end; }
.room-title { margin: 0; font-size: 16px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 40vw; }
.count-label { color: var(--muted); font-size: 13px; }
.host-tools { display: flex; gap: 8px; padding-left: 12px; border-left: 1px solid var(--line); }

.rec {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(234,90,95,.16); color: #ff8d91;
  font-size: 12px; font-weight: 800; letter-spacing: .08em;
}
.rec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: blink 1.4s ease-in-out infinite; }
@keyframes blink { 50% { opacity: .25; } }

.main { flex: 1; min-height: 0; display: flex; }
.video-area {
  position: relative;
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  padding: 12px; gap: 12px;
}

/* 영상 영역 위 상단 오버레이(소리 켜기 안내, 발표 배너). 자기 영역 밖의 클릭은 막지 않는다. */
.overlay-top {
  position: absolute; z-index: 6; top: 20px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  width: max-content; max-width: calc(100% - 32px);
  pointer-events: none;
}
.audio-banner {
  pointer-events: auto;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 8px 8px 16px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 8px 30px rgba(0,0,0,.4);
  font-size: 14px;
}
.audio-sink { position: absolute; width: 0; height: 0; overflow: hidden; }

/* 격자 */
.grid {
  flex: 1; min-height: 0;
  display: grid; gap: 12px;
  grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr));
  grid-template-rows: repeat(var(--rows, 1), minmax(0, 1fr));
}

/* 화면 공유 모드: 큰 무대 + 가로 스트립 */
.stage {
  flex: 1; min-height: 0;
  display: flex;
}
.stage .tile { flex: 1; background: #05080b; }
.stage .tile video { object-fit: contain; }
.grid.strip {
  flex: none; height: 128px;
  display: flex; gap: 10px; overflow-x: auto; overflow-y: hidden;
  padding-bottom: 2px;
}
.grid.strip .tile { flex: none; width: 200px; height: 100%; }
.grid.strip .tile-name { font-size: 12px; }
.grid.strip .avatar { width: 44px; height: 44px; font-size: 18px; }

/* 타일 */
.tile {
  position: relative; overflow: hidden;
  min-width: 0; min-height: 0;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: border-color .15s, box-shadow .15s;
}
.tile video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; background: #05080b;
}
.tile.mirror video { transform: scaleX(-1); }
.tile.no-video video { visibility: hidden; }
.tile.speaking { border-color: var(--speaking); box-shadow: 0 0 0 3px rgba(63,208,138,.22); }

.avatar {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 76px; height: 76px; border-radius: 50%;
  display: none; place-items: center;
  background: var(--surface-3); color: var(--accent);
  font-size: 30px; font-weight: 700;
}
.tile.no-video .avatar { display: grid; }

.tile-meta {
  position: absolute; left: 8px; bottom: 8px; right: 8px;
  display: flex; align-items: center; gap: 6px;
  pointer-events: none;
}
.tile-name {
  max-width: 100%;
  padding: 3px 9px; border-radius: 7px;
  background: rgba(8,11,15,.66);
  backdrop-filter: blur(6px);
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tile-mic {
  flex: none;
  width: 26px; height: 26px; border-radius: 7px;
  display: none; place-items: center;
  background: rgba(234,90,95,.9);
}
.tile.mic-off .tile-mic { display: grid; }
.tile-mic svg { width: 15px; height: 15px; }

.badge {
  flex: none;
  padding: 2px 7px; border-radius: 6px;
  font-size: 11px; font-weight: 700;
  background: rgba(227,171,69,.18); color: var(--host);
  border: 1px solid rgba(227,171,69,.4);
}

/* ---------- 사이드 패널 ---------- */
.panel {
  flex: none; width: 340px;
  display: flex; flex-direction: column; min-height: 0;
  margin: 12px 12px 12px 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--line);
}
.panel-head h3 { margin: 0; font-size: 15px; }

.chat-list {
  flex: 1; min-height: 0; overflow-y: auto;
  margin: 0; padding: 14px; list-style: none;
  display: flex; flex-direction: column; gap: 10px;
}
.msg { max-width: 88%; display: flex; flex-direction: column; gap: 3px; align-self: flex-start; }
.msg.mine { align-self: flex-end; align-items: flex-end; }
.msg-head { font-size: 12px; color: var(--muted); }
.msg-head b { color: var(--text); font-weight: 600; margin-right: 6px; }
.msg-body {
  padding: 8px 12px; border-radius: 12px 12px 12px 4px;
  background: var(--surface-3);
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.msg.mine .msg-body { background: var(--accent); color: var(--accent-ink); border-radius: 12px 12px 4px 12px; }
.msg.system { align-self: center; max-width: 100%; font-size: 12px; color: var(--muted); }
.chat-empty { margin: auto; color: var(--muted); font-size: 13px; text-align: center; }

.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); align-items: flex-end; }
.chat-form textarea {
  flex: 1; resize: none; max-height: 110px;
  padding: 9px 12px; background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px;
  field-sizing: content;
}
.chat-form textarea:focus-visible { outline-offset: 0; border-color: var(--accent); }

.people-actions { padding: 12px 12px 4px; }
.people-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 8px 8px 12px; list-style: none; }
.person {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 8px; border-radius: 10px;
  flex-wrap: wrap;
}
.person:hover { background: var(--surface-2); }
.person.speaking .person-name { color: var(--speaking); }
.person-name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-mic { flex: none; width: 18px; height: 18px; color: var(--muted); }
.person-mic.off { color: var(--danger); }
.person-actions { flex-basis: 100%; display: flex; gap: 6px; padding-left: 0; }

/* ---------- 컨트롤 바 ---------- */
.controls {
  flex: none;
  display: flex; justify-content: center; gap: 10px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.ctl {
  position: relative;
  width: 78px; padding: 8px 0 7px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px;
  transition: background .15s, border-color .15s;
}
.ctl:hover { background: var(--surface-3); }
.ctl svg {
  width: 22px; height: 22px;
  fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.ctl .slash { display: none; stroke: var(--danger); stroke-width: 2.2; }
.ctl.off { background: rgba(234,90,95,.14); border-color: rgba(234,90,95,.5); }
.ctl.off .slash { display: block; }
.ctl.off svg { color: #ff8d91; }
.ctl.on-accent { background: rgba(90,169,255,.16); border-color: var(--accent); color: var(--accent); }
.ctl-label { font-size: 11.5px; font-weight: 600; }
.ctl-leave { background: var(--danger); border-color: var(--danger); color: #fff; }
.ctl-leave:hover { background: #f27479; }
.ctl-leave svg { fill: currentColor; stroke: none; }
.ctl:disabled { opacity: .5; }

.badge-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 20px; height: 20px; padding: 0 6px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--danger); color: #fff;
  font-size: 11px; font-weight: 800;
  border: 2px solid var(--surface);
}

/* ---------- 토스트 ---------- */
.toasts {
  position: fixed; z-index: 50; left: 50%; bottom: 96px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  width: min(92vw, 420px); pointer-events: none;
}
.toast {
  padding: 10px 16px; border-radius: 10px;
  background: var(--surface-3); border: 1px solid var(--line);
  box-shadow: 0 8px 28px rgba(0,0,0,.45);
  font-size: 14px; text-align: center;
  animation: toast-in .2s ease-out;
}
.toast.error { background: #3a1d20; border-color: rgba(234,90,95,.6); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- 반응형 ---------- */
@media (max-width: 900px) {
  .panel {
    position: fixed; z-index: 20; top: 56px; right: 8px; bottom: 92px;
    width: min(360px, calc(100vw - 16px)); margin: 0;
    box-shadow: 0 20px 60px rgba(0,0,0,.6);
  }
  .host-tools { border-left: 0; padding-left: 0; }
  .room-title { max-width: 30vw; }
}
@media (max-width: 640px) {
  .ctl { width: auto; flex: 1 1 0; min-width: 0; max-width: 60px; }
  .ctl-label { font-size: 10px; max-width: 100%; padding: 0 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .controls { gap: 6px; }
  .grid.strip { height: 104px; }
  .grid.strip .tile { width: 160px; }
  .count-label { display: none; }
}

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

.stage-note {
  position: absolute; inset: 0; display: none; place-items: center;
  color: var(--muted); font-size: 16px; font-weight: 600;
}
.stage .tile.no-video .stage-note { display: grid; }

/* ======================================================================
 * 수업 도구
 * ==================================================================== */
.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;
}

/* ---------- 타일 표시 (손들기 순번, 스티커, 발표) ---------- */
.tile-flags {
  /* 상단 중앙의 발표 배너에 가리지 않도록 오른쪽 아래에 둔다. */
  position: absolute; z-index: 2; bottom: 8px; right: 8px;
  display: flex; gap: 6px;
  pointer-events: none;
}
.flag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 28px; padding: 0 10px 0 6px;
  border-radius: 999px;
  font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
}
.flag svg { width: 18px; height: 18px; flex: none; }
.flag-hand { background: var(--hand); color: var(--hand-ink); }
.flag-hand svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.flag-star { background: var(--star); color: var(--star-ink); }
.flag-star svg { fill: currentColor; }
.flag.bump { animation: flag-bump .55s cubic-bezier(.3,1.6,.5,1); }
@keyframes flag-bump { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }

/* 발표 당첨: 카메라가 켜져 있으면 배경이 영상에 가려지므로 안쪽 빛(::after)으로 영상 위에도 강조한다. */
.tile.picked {
  border-color: var(--pick);
  background: linear-gradient(160deg, rgba(255,143,177,.5), rgba(255,207,74,.28)), var(--surface-2);
  box-shadow: 0 0 0 4px rgba(255,143,177,.45), 0 0 36px 8px rgba(255,143,177,.4);
  animation: picked-glow 1.8s ease-in-out infinite;
}
.tile.picked::after {
  content: ''; position: absolute; inset: 0; z-index: 1;
  border-radius: inherit; pointer-events: none;
  box-shadow: inset 0 0 0 3px var(--pick), inset 0 0 70px 14px rgba(255,143,177,.5);
}
@keyframes picked-glow {
  50% { box-shadow: 0 0 0 5px rgba(255,143,177,.65), 0 0 56px 16px rgba(255,143,177,.55); }
}

/* ---------- 이모지 반응 ---------- */
.react-wrap { position: relative; display: flex; }
.react-wrap .ctl { flex: 1; }
.react-bar {
  position: absolute; z-index: 30; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
  display: flex; gap: 4px; padding: 6px;
  background: var(--surface-3); border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 12px 36px rgba(0,0,0,.5);
}
.react-bar button {
  width: 48px; height: 48px; border-radius: 50%;
  background: transparent; border: 0;
  font-size: 28px; line-height: 1;
  transition: transform .12s, background .12s;
}
.react-bar button:hover, .react-bar button:focus-visible { background: rgba(255,255,255,.1); transform: scale(1.18); }
.react-bar button:active { transform: scale(.9); }

.reaction-layer { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
/* Google Meet 처럼 아래에서 천천히 올라오며 옅어진다. 위로 가는 움직임(.reaction-float)과
   좌우 흔들림(.reaction-emoji)을 나눠야 두 움직임이 서로 덮어쓰지 않는다. */
.reaction-float {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  transform: translate(-50%, -100%);
  opacity: 0;
  animation: reaction-rise 4s cubic-bezier(.33,.2,.45,1) forwards;
  will-change: transform, opacity;
}
.reaction-emoji {
  font-size: 44px; line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,.4));
  animation: reaction-sway 4s ease-in-out forwards;
}
.reaction-name {
  max-width: 140px; padding: 2px 8px; border-radius: 999px;
  background: rgba(8,11,15,.6);
  font-size: 11px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@keyframes reaction-rise {
  0%   { opacity: 0; transform: translate(-50%, -100%); }
  10%  { opacity: 1; }
  55%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, calc(-100% - var(--rise))); }
}
@keyframes reaction-sway {
  0%   { translate: 0 0; }
  30%  { translate: var(--sway) 0; }
  65%  { translate: calc(var(--sway) * -0.6) 0; }
  100% { translate: calc(var(--sway) * 0.3) 0; }
}

/* 누가 보냈는지는 보낸 사람 타일 왼쪽 위에 잠깐 표시한다. */
.tile-react {
  position: absolute; z-index: 3; top: 8px; left: 8px;
  font-size: 30px; line-height: 1;
  filter: drop-shadow(0 3px 8px rgba(0,0,0,.5));
  opacity: 0; transform: scale(.4);
  transition: opacity .2s, transform .25s cubic-bezier(.3,1.6,.5,1);
  pointer-events: none;
}
.tile-react.show { opacity: 1; transform: scale(1); }

.fireworks { position: absolute; inset: 0; z-index: 7; pointer-events: none; overflow: hidden; }
.firework { position: absolute; width: 0; height: 0; }
.firework i {
  position: absolute; left: -5px; top: -5px;
  width: 11px; height: 11px; border-radius: 50%;
  opacity: 0;
  animation: firework 1.2s ease-out forwards;
}
.firework i:nth-child(3n) { width: 6px; height: 16px; border-radius: 3px; }
@keyframes firework {
  0%   { transform: rotate(var(--a)) translateY(0) scale(1.3); opacity: 1; }
  70%  { opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(-1 * var(--d))) scale(.4); opacity: 0; }
}
.tile-pick {
  position: absolute; z-index: 2; top: 8px; right: 8px;
  display: none;
  padding: 3px 10px; border-radius: 999px;
  background: var(--pick); color: var(--pick-ink);
  font-size: 12px; font-weight: 800;
  pointer-events: none;
}
.tile.picked .tile-pick { display: block; }
.grid.strip .flag { height: 22px; font-size: 12px; padding: 0 8px 0 4px; }
.grid.strip .flag svg { width: 14px; height: 14px; }

/* 칭찬 스티커 애니메이션 */
.star-burst {
  position: absolute; z-index: 3; inset: 0;
  display: grid; place-items: center;
  pointer-events: none;
}
.star-burst svg {
  width: 40%; max-width: 150px; aspect-ratio: 1;
  fill: var(--star);
  filter: drop-shadow(0 8px 28px rgba(255,207,74,.65));
  animation: star-pop 1.5s cubic-bezier(.2,1.2,.3,1) forwards;
}
.star-burst i {
  position: absolute; left: 50%; top: 50%;
  width: 10px; height: 10px; margin: -5px 0 0 -5px;
  border-radius: 2px;
  background: var(--star);
  opacity: 0;
  animation: spark 1.1s .12s ease-out forwards;
}
.star-burst i:nth-child(even) { background: #fff6d6; width: 7px; height: 7px; border-radius: 50%; }
@keyframes star-pop {
  0%   { transform: scale(.2) rotate(-35deg); opacity: 0; }
  30%  { transform: scale(1.18) rotate(8deg); opacity: 1; }
  55%  { transform: scale(1) rotate(0); opacity: 1; }
  100% { transform: scale(.85) translateY(-28%); opacity: 0; }
}
@keyframes spark {
  0%   { transform: rotate(var(--a)) translateY(0) scale(1); opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(calc(-1 * var(--d, 100px))) scale(.3); opacity: 0; }
}

/* ---------- 호스트 이탈 유예 배너 ---------- */
.away-banner {
  max-width: 100%;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(21,27,34,.94);
  border: 2px solid var(--danger);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  font-size: 15px; font-weight: 700; text-align: center;
  font-variant-numeric: tabular-nums;
}

/* ---------- 발표 배너 ---------- */
.pick-banner {
  display: flex; align-items: center; gap: 12px;
  max-width: 100%;
  padding: 8px 24px 8px 8px;
  border-radius: 999px;
  background: rgba(21,27,34,.94);
  border: 2px solid var(--pick);
  box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 0 6px rgba(255,143,177,.14);
  backdrop-filter: blur(8px);
}
.pick-icon {
  flex: none; width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--pick); color: var(--pick-ink);
}
.pick-icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.pick-label { flex: none; color: var(--pick); font-size: 15px; font-weight: 800; }
.pick-name {
  min-width: 0;
  font-size: 26px; font-weight: 800; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pick-banner.pop { animation: pick-pop .7s cubic-bezier(.2,1.5,.4,1); }
@keyframes pick-pop {
  0%   { transform: translateY(-16px) scale(.6); opacity: 0; }
  55%  { transform: translateY(0) scale(1.08); opacity: 1; }
  100% { transform: none; }
}

/* ---------- 공유 타이머 칩 (상단바) ---------- */
/* 공유 타이머: 위쪽 가운데 알약. 남은 시간은 줄어드는 원판(Time Timer 식)으로도 보여 준다. */
.timer-pill {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 18px 6px 6px; border-radius: 999px;
  background: rgba(21,27,34,.94); color: var(--text);
  border: 2px solid var(--timer);
  box-shadow: 0 12px 40px rgba(0,0,0,.5);
  backdrop-filter: blur(8px);
}
.timer-dial {
  --left: 1;
  flex: none; width: 34px; height: 34px; border-radius: 50%;
  background: conic-gradient(var(--timer) calc(var(--left) * 360deg), rgba(255,255,255,.1) 0);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.12);
}
.timer-text { font-size: 26px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.timer-pill.urgent { --timer: var(--danger); animation: urgent-pulse 1s ease-in-out infinite; }
.timer-pill.urgent .timer-text { color: #ff8d91; }
.timer-pill.done { --timer: var(--danger); background: var(--danger); color: var(--danger-ink); }
.timer-pill.done .timer-text { font-size: 20px; }
@keyframes urgent-pulse { 50% { box-shadow: 0 12px 40px rgba(0,0,0,.5), 0 0 0 7px rgba(234,90,95,.25); } }

/* 시작·마지막 5초·종료 순간에만 화면 가운데에 크게 띄운다. 클릭은 막지 않는다. */
.timer-burst {
  position: absolute; z-index: 8; left: 50%; top: 50%; transform: translate(-50%, -50%);
  pointer-events: none;
  display: grid; place-items: center;
  font-weight: 900; font-variant-numeric: tabular-nums; color: #fff;
  text-shadow: 0 4px 24px rgba(0,0,0,.5);
}
.timer-burst.msg {
  padding: 18px 40px; border-radius: 999px;
  background: rgba(13,17,22,.82); border: 3px solid var(--timer);
  font-size: 44px; white-space: nowrap;
}
.timer-burst.msg.done { background: var(--danger); border-color: rgba(255,255,255,.6); }
.timer-burst.count {
  width: 180px; height: 180px; border-radius: 50%;
  background: rgba(13,17,22,.72); border: 4px solid var(--danger);
  font-size: 110px; line-height: 1;
}
.timer-burst.msg.play { animation: burst-msg 1.8s ease-out forwards; }
.timer-burst.msg.done.play { animation-duration: 2.2s; }
.timer-burst.count.play { animation: burst-count .9s ease-out forwards; }
@keyframes burst-msg {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.7); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  20%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -110%) scale(.6); }
}
@keyframes burst-count {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.5); }
  20% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 1; transform: translate(-50%, -50%) scale(.94); }
}

/* ---------- 컨트롤 바: 손들기 ---------- */
.ctl.hand-up { background: rgba(255,157,92,.16); border-color: var(--hand); color: var(--hand); }
.ctl.hand-up svg { animation: hand-wave 1.6s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes hand-wave { 0%, 60%, 100% { transform: rotate(0); } 70% { transform: rotate(-12deg); } 85% { transform: rotate(10deg); } }
.badge-hand { background: var(--hand); color: var(--hand-ink); }

/* ---------- 참가자 패널: 발화량 / 스티커 버튼 ---------- */
.talk {
  flex-basis: 100%;
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums;
}
.talk-time { flex: none; min-width: 92px; }
.talk-bar {
  flex: 1; height: 6px; border-radius: 999px;
  background: var(--surface-3); overflow: hidden;
}
.talk-fill {
  display: block; height: 100%; width: 0;
  border-radius: inherit; background: var(--speaking);
  transition: width .3s ease;
}
.talk-pct { flex: none; width: 34px; text-align: right; }
.person.speaking .talk-time { color: var(--speaking); }
.badge-quiet {
  background: rgba(255,157,92,.16); color: var(--hand);
  border-color: rgba(255,157,92,.5);
}
.person.quiet { box-shadow: inset 3px 0 0 var(--hand); }
.person.quiet .talk-time { color: var(--hand); }
.btn-star svg { width: 15px; height: 15px; fill: var(--star); }
.btn-star:hover:not(:disabled) { border-color: rgba(255,207,74,.6); }

/* ---------- 수업 도구 패널 ---------- */
.tools-body { flex: 1; min-height: 0; overflow-y: auto; }
.tool { padding: 14px 16px 16px; border-bottom: 1px solid var(--line); }
.tool:last-child { border-bottom: 0; }
.tool-title {
  display: flex; align-items: center; gap: 7px;
  margin: 0 0 12px;
  font-size: 13px; font-weight: 700; color: var(--text);
}
.tool-title svg { width: 17px; height: 17px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-error { margin: 8px 0 0; }

.tool-status {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-bottom: 10px; padding: 8px 8px 8px 12px;
  border-radius: 10px; background: var(--surface-2);
}
.timer-state { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.timer-state.on { color: var(--accent); font-size: 15px; font-weight: 800; }
.timer-state.urgent { color: #ff8d91; }
.timer-state.done { color: var(--danger); }
.chip-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin-bottom: 8px; }
.inline-form { display: flex; gap: 6px; }
.input {
  flex: 1; min-width: 0; width: 100%;
  padding: 7px 10px;
  background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px;
  font-size: 13px;
}
.input::placeholder { color: #55616e; }
.input:focus-visible { outline-offset: 0; border-color: var(--accent); }
.input[aria-invalid="true"] { border-color: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

.hand-queue {
  list-style: none; margin: 0; padding: 0;
  display: flex; flex-direction: column; gap: 4px;
  max-height: 184px; overflow-y: auto;
}
.queue-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2); }
.queue-item:first-child { box-shadow: inset 0 0 0 1px rgba(255,157,92,.5); }
.queue-empty { padding: 2px 0; color: var(--muted); font-size: 13px; }
.q-num {
  flex: none; width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--hand); color: var(--hand-ink);
  font-size: 12px; font-weight: 800;
}
.q-name { min-width: 0; font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pick-result {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  margin-top: 10px; padding: 6px 6px 6px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,143,177,.5); background: rgba(255,143,177,.10);
}
.pick-result-text { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pick-result b { color: var(--pick); }

/* 퀴즈 출제 폼 */
.quiz-form { display: flex; flex-direction: column; gap: 12px; }
.qf-field { display: flex; flex-direction: column; gap: 6px; }
.qf-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
.quiz-form textarea.input { resize: vertical; min-height: 56px; line-height: 1.4; }
.quiz-form fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.quiz-form legend { padding: 0; margin-bottom: 6px; }
.qf-opt { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.quiz-form input[type="radio"], .quiz-form input[type="checkbox"] { flex: none; width: 16px; height: 16px; margin: 0; accent-color: var(--speaking); }
.check-line { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }

.opt-num {
  flex: none; width: 24px; height: 24px; border-radius: 7px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 800; color: #0b0f14;
  background: var(--opt-1);
}
.opt-num[data-n="1"] { background: var(--opt-2); }
.opt-num[data-n="2"] { background: var(--opt-3); }
.opt-num[data-n="3"] { background: var(--opt-4); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg span, .seg button {
  display: block; border: 0; border-radius: 0;
  padding: 6px 14px;
  background: var(--surface-2);
  font-size: 13px; font-weight: 600;
}
.seg label + label span, .seg button + button { border-left: 1px solid var(--line); }
.seg input:checked + span, .seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }

/* 퀴즈 실시간 결과 (호스트) */
.quiz-host-q { margin: 0 0 8px; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.quiz-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; font-size: 13px; }
.quiz-progress { font-weight: 700; }
.quiz-left { color: var(--muted); font-variant-numeric: tabular-nums; }
.quiz-left.urgent { color: #ff8d91; font-weight: 700; }
.pill {
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 700;
  border: 1px solid transparent;
}
.pill-open { background: rgba(63,208,138,.14); color: var(--speaking); border-color: rgba(63,208,138,.4); }
.pill-closed { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.pill-revealed { background: rgba(255,207,74,.14); color: var(--star); border-color: rgba(255,207,74,.45); }
.quiz-view-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 12px; }
.quiz-view-row .seg button { padding: 4px 10px; font-size: 12px; }
.quiz-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.qr { padding: 8px 10px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid transparent; }
.qr.correct { border-color: rgba(63,208,138,.6); background: rgba(63,208,138,.07); }
.qr-head { display: flex; align-items: center; gap: 8px; }
.qr-text { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.qr-mark {
  flex: none; display: inline-flex; align-items: center; gap: 2px;
  color: var(--speaking); font-size: 11px; font-weight: 800;
}
.qr-mark svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.qr-count { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.bar { display: block; margin-top: 7px; height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--opt-1); transition: width .45s cubic-bezier(.2,.8,.2,1); }
.bar[data-n="1"] > i { background: var(--opt-2); }
.bar[data-n="2"] > i { background: var(--opt-3); }
.bar[data-n="3"] > i { background: var(--opt-4); }
.name-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 7px; }
.name-chip {
  max-width: 100%;
  padding: 1px 8px; border-radius: 999px;
  background: var(--surface-3);
  font-size: 12px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.quiz-missing { margin-top: 10px; padding: 8px 10px; border-radius: 10px; border: 1px dashed var(--line); }
.quiz-missing-label { font-size: 12px; font-weight: 700; color: var(--hand); }

/* ---------- 퀴즈 카드 (참가자) ---------- */
.quiz-card {
  position: absolute; z-index: 7; left: 50%; bottom: 20px; transform: translateX(-50%);
  width: min(620px, calc(100% - 32px)); max-height: calc(100% - 40px);
  display: flex; flex-direction: column;
  background: rgba(21,27,34,.97);
  border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0,0,0,.6);
  overflow: hidden;
}
.quiz-card.enter { animation: card-in .45s cubic-bezier(.2,1.3,.4,1); }
@keyframes card-in { from { opacity: 0; transform: translate(-50%, 24px) scale(.96); } }
.quiz-card-head { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.quiz-card .spacer { flex: 1; }
.quiz-tag { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 15px; font-weight: 800; color: var(--star); }
.quiz-tag svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.quiz-state { font-size: 13px; font-weight: 600; color: var(--muted); }
.quiz-clock {
  padding: 2px 10px; border-radius: 999px;
  background: rgba(90,169,255,.14); color: var(--accent);
  font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.quiz-clock.urgent { background: rgba(234,90,95,.18); color: #ff8d91; }
.quiz-toggle { display: grid; place-items: center; }
.quiz-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.quiz-card.collapsed { width: auto; max-width: calc(100% - 32px); }
.quiz-card.collapsed .quiz-card-head { border-bottom: 0; }
.quiz-card.collapsed .quiz-card-body { display: none; }
.quiz-card.collapsed .quiz-toggle svg { transform: rotate(180deg); }
.quiz-card-body { min-height: 0; overflow-y: auto; padding: 16px; }
.quiz-q { margin: 0 0 14px; font-size: 21px; font-weight: 800; line-height: 1.35; letter-spacing: -.01em; overflow-wrap: anywhere; }
.quiz-opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.quiz-opt {
  --c: var(--opt-1);
  position: relative;
  display: flex; flex-direction: column; align-items: stretch; gap: 0;
  min-height: 68px; padding: 12px 14px;
  text-align: left;
  border: 2px solid var(--line); border-radius: 14px;
  background: var(--surface-2);
  font-size: 17px; font-weight: 700;
  transition: transform .12s, border-color .15s, background .15s, opacity .2s;
}
.quiz-opt[data-n="1"] { --c: var(--opt-2); }
.quiz-opt[data-n="2"] { --c: var(--opt-3); }
.quiz-opt[data-n="3"] { --c: var(--opt-4); }
.quiz-opt:hover:not(:disabled) { border-color: var(--c); background: var(--surface-3); }
.quiz-opt:active:not(:disabled) { transform: scale(.97); }
.quiz-opt:disabled { opacity: 1; cursor: default; }
.opt-main { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.quiz-opt .opt-num { width: 34px; height: 34px; border-radius: 10px; font-size: 17px; background: var(--c); }
.opt-text { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.3; }
.opt-mark {
  flex: none; align-self: flex-start;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--text);
  font-size: 11px; font-weight: 800;
}
.opt-mark.ok { background: var(--speaking); color: #04210f; }
.opt-mark.no { background: rgba(234,90,95,.2); color: #ff8d91; }
.quiz-opt.chosen {
  border-color: var(--c);
  background: color-mix(in srgb, var(--c) 18%, var(--surface-2));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 28%, transparent);
}
.quiz-opt.correct { border-color: var(--speaking); box-shadow: 0 0 0 3px rgba(63,208,138,.35); }
.quiz-opt.wrong { border-color: var(--danger); }
.quiz-opt.dim { opacity: .5; }
.opt-result { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.opt-result .bar { flex: 1; margin-top: 0; height: 10px; }
.opt-result .bar > i { background: var(--c); }
.opt-count { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.quiz-opt .name-chips { margin-top: 6px; }
.quiz-hint { margin: 14px 0 0; text-align: center; font-size: 15px; font-weight: 700; color: var(--muted); }
.quiz-hint.good { color: var(--speaking); font-size: 18px; }
.quiz-hint.bad { color: #ff8d91; }
.quiz-card[data-status="REVEALED"] .quiz-opt.correct.chosen { animation: correct-pop .6s cubic-bezier(.3,1.6,.5,1); }
@keyframes correct-pop { 40% { transform: scale(1.04); } }

/* ---------- 수업 도구 반응형 ---------- */
@media (max-width: 640px) {
  .overlay-top { top: 12px; }
  .pick-banner { padding: 6px 16px 6px 6px; gap: 8px; }
  .away-banner { padding: 8px 14px; font-size: 14px; border-radius: 16px; }
  .pick-icon { width: 34px; height: 34px; }
  .pick-name { font-size: 20px; }
  .quiz-card { bottom: 12px; width: calc(100% - 16px); max-height: calc(100% - 24px); }
  .quiz-card-body { padding: 12px; }
  .quiz-q { font-size: 18px; }
  .quiz-opt { min-height: 56px; padding: 10px; font-size: 15px; }
  .react-wrap { flex: 1 1 0; min-width: 0; max-width: 60px; }
  .react-wrap .ctl { max-width: none; }
  /* 버튼 위에 붙이면 좁은 화면 가장자리에서 잘리므로 화면 가운데로 띄운다. */
  .react-bar { position: fixed; bottom: calc(86px + env(safe-area-inset-bottom)); }
  .react-bar button { width: 42px; height: 42px; font-size: 24px; }
  .reaction-emoji { font-size: 34px; }
  .timer-pill { gap: 8px; padding: 4px 14px 4px 4px; }
  .timer-dial { width: 28px; height: 28px; }
  .timer-text { font-size: 21px; }
  .timer-burst.msg { font-size: 30px; padding: 14px 28px; }
  .timer-burst.count { width: 130px; height: 130px; font-size: 78px; }
}
@media (max-width: 480px) {
  .quiz-opts { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .chip-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
