/* 클래스톡 공통 스타일 */
:root {
  --navy: #1f3a5f;
  --blue: #2f6fd6;
  --blue-soft: #e8f0fc;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2430;
  --muted: #667085;
  --line: #d9dee7;
  --green: #1a8a4a;
  --green-soft: #e3f5ea;
  --orange: #c26a00;
  --orange-soft: #fff3e0;
  --red: #c62828;
  --red-soft: #fdecec;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: "Pretendard", "Malgun Gothic", "Apple SD Gothic Neo", "Noto Sans KR", system-ui, sans-serif;
  font-size: 16px; line-height: 1.55; color: var(--text); background: var(--bg);
  word-break: keep-all; overflow-wrap: anywhere;
}
body.learner { font-size: 18px; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.3; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .88em; }

/* 버튼 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.btn:hover { background: #f7f9fc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #245dbb; }
.btn.navy { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn.danger { color: var(--red); border-color: #f0c2c2; }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: .9em; border-radius: 8px; }
.btn.lg { min-height: 56px; font-size: 1.1em; width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }

/* 입력 */
.input, textarea.input, select.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border: 1px solid var(--line);
  border-radius: 10px; background: #fff;
}
textarea.input { min-height: 120px; resize: vertical; }
.input:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-weight: 600; margin-bottom: 6px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; margin-right: 18px; }
.check input { width: 20px; height: 20px; }

/* 카드·배지 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: .82em; font-weight: 600; background: #eef1f5; color: #475467; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.plain::before { display: none; }
.badge.live, .badge.open, .badge.online { background: var(--green-soft); color: var(--green); }
.badge.ready, .badge.draft { background: var(--orange-soft); color: var(--orange); }
.badge.ended, .badge.closed, .badge.offline { background: #eef1f5; color: #667085; }
.badge.type { background: var(--blue-soft); color: var(--blue); }

/* 알림 */
#toasts { position: fixed; top: 64px; left: 50%; transform: translateX(-50%); z-index: 1000; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
.toast { padding: 12px 16px; border-radius: 10px; background: #1c2430; color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.2); font-weight: 600; animation: pop .2s ease-out; pointer-events: auto; }
.toast.ok { background: var(--green); }
.toast.err { background: var(--red); }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
#offline { position: fixed; bottom: 0; left: 0; right: 0; background: var(--red); color: #fff; text-align: center; padding: 10px; font-weight: 700; z-index: 999; }

/* 표 */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { padding: 10px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
table.list th { font-size: .88em; color: var(--muted); font-weight: 600; background: #fafbfc; }
table.list td.actions { text-align: right; white-space: nowrap; }
table.list td.actions .btn + .btn { margin-left: 6px; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

/* 업로드 영역 */
.dropzone { border: 2px dashed #b8c3d4; border-radius: var(--radius); padding: 26px 16px; text-align: center; background: #fbfcfe; cursor: pointer; transition: .15s; }
.dropzone.over { border-color: var(--blue); background: var(--blue-soft); }
.progress { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.progress-item { font-size: .9em; }
.bar { height: 8px; border-radius: 99px; background: #e6eaf0; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .2s; }

/* 가로 막대그래프 */
.chart { display: flex; flex-direction: column; gap: 12px; }
.chart-row .chart-label { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 4px; font-weight: 600; }
.chart-row .chart-track { height: 28px; border-radius: 8px; background: #edf1f7; overflow: hidden; }
.chart-row .chart-fill { height: 100%; background: var(--blue); border-radius: 8px; min-width: 2px; transition: width .4s; }

/* 응답 카드 */
.answers { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.answer { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.answer .who { font-weight: 700; display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.answer .who time { font-weight: 400; color: var(--muted); font-size: .85em; }
.answer .txt { white-space: pre-wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 4px 10px; border-radius: 99px; background: #eef1f5; font-size: .9em; }
.chip.on { background: var(--green-soft); color: var(--green); }

.q-body { white-space: pre-wrap; font-size: 1.1em; }
.q-image { max-width: 100%; max-height: 420px; border-radius: 10px; border: 1px solid var(--line); margin-top: 10px; display: block; }
.file-link { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; cursor: pointer; margin-top: 10px; font-weight: 600; }
.file-link:hover { background: var(--blue-soft); }
.file-link .size { font-weight: 400; color: var(--muted); font-size: .85em; }

/* ===== 로그인 ===== */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px; background: linear-gradient(160deg, #1f3a5f 0%, #2f6fd6 100%); }
.login-card { width: 100%; max-width: 420px; background: #fff; border-radius: 18px; padding: 32px 26px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.brand { text-align: center; margin-bottom: 22px; }
.brand h1 { font-size: 1.9em; color: var(--navy); margin: 0; letter-spacing: -.5px; }
.brand p { margin: 4px 0 0; color: var(--muted); }
.tabs { display: grid; grid-template-columns: 1fr 1fr; background: #eef1f5; border-radius: 12px; padding: 4px; margin-bottom: 22px; }
.tabs button { min-height: 44px; border: 0; background: transparent; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; }
.tabs button.on { background: #fff; color: var(--navy); box-shadow: var(--shadow); }
.hint { font-size: .88em; color: var(--muted); margin: -6px 0 14px; }
.waiting { text-align: center; padding: 10px 0; }
.spinner { width: 34px; height: 34px; border: 4px solid #dfe6f1; border-top-color: var(--blue); border-radius: 50%; margin: 6px auto 14px; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 공통 상단 막대 ===== */
.topbar { position: sticky; top: 0; z-index: 50; background: var(--navy); color: #fff; }
.topbar .inner { max-width: 1280px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar .logo { font-weight: 800; font-size: 1.2em; letter-spacing: -.3px; }
.topbar .room { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.topbar .room .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.topbar .spacer { flex: 1; }
.topbar .meta { font-size: .85em; opacity: .85; }
.topbar .btn { min-height: 36px; background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.25); color: #fff; }
.topbar .btn:hover { background: rgba(255,255,255,.22); }
.topbar .badge { background: rgba(255,255,255,.15); color: #fff; }
.topbar .badge.live { background: #2fb36a; color: #fff; }

/* ===== 교수자 ===== */
.tnav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 56px; z-index: 40; }
.tnav .inner { max-width: 1280px; margin: 0 auto; padding: 0 12px; display: flex; gap: 4px; overflow-x: auto; }
.tnav button { border: 0; background: none; padding: 14px 16px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; white-space: nowrap; }
.tnav button.on { color: var(--blue); border-bottom-color: var(--blue); }
.tnav .count { display: inline-block; min-width: 20px; padding: 0 6px; margin-left: 4px; border-radius: 99px; background: #eef1f5; font-size: .8em; }
#resp-select, #sub-filter { width: auto; max-width: 100%; }
/* 학습자 접속 안내 */
.join-card { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.join-card .join-info { flex: 1; min-width: 240px; }
.join-card .join-url { font-size: 1.5em; font-weight: 800; color: var(--navy); word-break: break-all; margin: 4px 0 12px; }
.qr { background: #fff; padding: 8px; border: 1px solid var(--line); border-radius: 10px; line-height: 0; }
.qr img, .qr canvas { display: block; }
.join-big { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; text-align: center; }
.join-big .jb-title { font-size: clamp(26px, 3vw, 44px); font-weight: 800; }
.join-big .jb-url { font-size: clamp(30px, 4.6vw, 72px); font-weight: 800; color: #9fd0ff; word-break: break-all; }
.join-big .qr { padding: 18px; border-radius: 18px; }
.join-big .jb-sub { font-size: clamp(18px, 1.8vw, 26px); opacity: .85; }

main.page { max-width: 1280px; margin: 0 auto; padding: 20px 16px 80px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 1.3em; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row .grow { flex: 1; min-width: 200px; }
.split { display: grid; grid-template-columns: 340px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }
.qlist { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 220px); overflow-y: auto; }
.qitem { border: 1px solid var(--line); border-radius: 10px; padding: 12px; background: #fff; cursor: pointer; text-align: left; width: 100%; }
.qitem:hover { border-color: #9fb6dc; }
.qitem.on { border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-soft); }
.qitem .top { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.qitem .preview { color: #344054; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.opt-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.opt-row .num { width: 26px; text-align: center; font-weight: 700; color: var(--muted); }
.stat-big { font-size: 1.6em; font-weight: 800; color: var(--navy); }
.stats { display: flex; gap: 24px; flex-wrap: wrap; align-items: flex-end; }
.stats .lbl { font-size: .85em; color: var(--muted); }
hr.sep { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }

/* 결과 크게 보기 */
.bigview { position: fixed; inset: 0; background: #0f1d33; color: #fff; z-index: 500; overflow-y: auto; padding: 36px 5vw; }
.bigview .bv-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 28px; }
.bigview .bv-q { font-size: clamp(26px, 3.4vw, 46px); font-weight: 800; white-space: pre-wrap; line-height: 1.35; }
.bigview .bv-meta { font-size: clamp(18px, 1.6vw, 24px); opacity: .8; margin-top: 10px; }
.bigview .btn { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.3); color: #fff; }
.bigview .chart { gap: 22px; }
.bigview .chart-row .chart-label { font-size: clamp(20px, 2vw, 30px); }
.bigview .chart-row .chart-track { height: clamp(34px, 4vw, 56px); background: rgba(255,255,255,.1); }
.bigview .chart-row .chart-fill { background: #5aa0ff; }
.bigview .answers { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.bigview .answer { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.15); color: #fff; font-size: clamp(18px, 1.5vw, 24px); }
.bigview .answer .who time { color: rgba(255,255,255,.6); }

/* ===== 학습자 ===== */
.l-main { max-width: 680px; margin: 0 auto; padding: 16px 16px 110px; }
.l-hello { margin: 4px 0 14px; }
.l-hello h2 { font-size: 1.25em; margin: 0; }
.bottom-nav { position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); z-index: 60; padding-bottom: env(safe-area-inset-bottom); }
.bottom-nav button { border: 0; background: none; min-height: 62px; font-weight: 700; color: var(--muted); cursor: pointer; position: relative; font-size: .95em; }
.bottom-nav button.on { color: var(--blue); }
.bottom-nav button .dot { position: absolute; top: 12px; left: calc(50% + 22px); width: 10px; height: 10px; border-radius: 50%; background: var(--red); }
.qcard .q-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.choices { display: flex; flex-direction: column; gap: 10px; margin: 16px 0; }
.choice { display: flex; gap: 12px; align-items: center; text-align: left; min-height: 58px; padding: 12px 16px; border: 2px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font-weight: 600; }
.choice .mark { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid #b8c3d4; display: flex; align-items: center; justify-content: center; font-size: .8em; color: #fff; }
.choice.multi .mark { border-radius: 7px; }
.choice[aria-pressed="true"] { border-color: var(--blue); background: var(--blue-soft); }
.choice[aria-pressed="true"] .mark { background: var(--blue); border-color: var(--blue); }
.choice:disabled { cursor: default; }
.submit-status { margin-top: 12px; padding: 10px 14px; border-radius: 10px; background: var(--green-soft); color: var(--green); font-weight: 700; }
.submit-status.closed { background: #eef1f5; color: var(--muted); }
.notice { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 12px; background: var(--orange-soft); color: var(--orange); font-weight: 700; margin-bottom: 14px; }
.wait-box { text-align: center; padding: 48px 20px; color: var(--muted); }
.wait-box .big { font-size: 1.2em; font-weight: 700; color: var(--text); margin-bottom: 6px; }
details.past { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
details.past summary { padding: 14px 16px; cursor: pointer; font-weight: 600; list-style: none; display: flex; gap: 8px; align-items: center; }
details.past summary::-webkit-details-marker { display: none; }
details.past summary::after { content: "▾"; margin-left: auto; color: var(--muted); }
details.past[open] summary::after { content: "▴"; }
details.past .inner { padding: 0 16px 16px; }
.my-answer { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: #f7f9fc; border: 1px solid var(--line); }
.my-answer .lbl { font-size: .85em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.flist { display: flex; flex-direction: column; gap: 10px; }
.fitem { display: flex; align-items: center; gap: 12px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.fitem .fname { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.fitem .fsub { font-size: .82em; color: var(--muted); font-weight: 400; }
.h-sub { font-size: 1.05em; margin: 22px 0 10px; }
