/* Chromium 84 / iOS Safari 호환: flex gap, aspect-ratio, :is() 등 최신 문법 미사용 */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", "Segoe UI", sans-serif;
  font-size: 14px; color: #1d2433; background: #f3f5f9;
}
.hidden { display: none !important; }
.muted { color: #6b7385; }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }

.topbar { display: flex; align-items: center; padding: 8px 14px; background: #1d3a6e; color: #fff; }
.brand { font-weight: 700; letter-spacing: .5px; }
.who { margin-left: 12px; opacity: .85; font-size: 13px; }
.conn { margin-left: auto; font-size: 12px; padding: 2px 8px; border-radius: 10px; }
.conn-ok { background: #2e7d4f; }
.conn-wait { background: #9a6b00; }
.conn-bad { background: #a33; }

main { padding: 12px; max-width: 1100px; margin: 0 auto; }
.card { background: #fff; border: 1px solid #dfe3ec; border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
h2 { margin: 0 0 8px; font-size: 18px; }
h3 { margin: 0 0 10px; font-size: 15px; }
.row-between { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; margin-bottom: 10px; }
.actions .btn { margin-left: 6px; }
.actions.right { margin-top: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1.4fr; grid-column-gap: 12px; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

.btn { font: inherit; padding: 6px 14px; border: 1px solid #b9c1d3; background: #fff; border-radius: 6px; cursor: pointer; color: #1d2433; }
.btn:hover { background: #f0f3f8; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: #2456b3; border-color: #2456b3; color: #fff; }
.btn.primary:hover { background: #1d4796; }
.btn.danger { color: #a32020; border-color: #e0b4b4; }
.btn.block { display: block; width: 100%; margin-top: 10px; }
.btn.big { padding: 12px; font-size: 16px; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-weight: 700; margin-right: 8px; background: #e6e9f0; }
.badge.open { background: #d8f0e1; color: #1d6b3d; }
.badge.closed { background: #f6dede; color: #8b1f1f; }

.alert { background: #fff4d6; border: 1px solid #f0d58a; border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
.alert.ok { background: #e3f4e8; border-color: #a9d9b7; }
.error-text { color: #b42318; min-height: 1.2em; }

#pin-form input { font-size: 18px; padding: 6px 10px; width: 180px; letter-spacing: 4px; margin-right: 6px; }

/* 문항 행 (교사 정답 / 학생 답안 공용) */
.qrow { display: flex; align-items: center; padding: 6px 0; border-bottom: 1px dashed #e5e8ef; }
.qrow:last-child { border-bottom: 0; }
.qnum { width: 52px; font-weight: 700; }
.opt { width: 40px; height: 40px; margin-right: 8px; border-radius: 50%; border: 2px solid #b9c1d3; background: #fff; font-size: 18px; cursor: pointer; color: #1d2433; }
.opt.sel { background: #2456b3; border-color: #2456b3; color: #fff; }
.opt:disabled { cursor: default; }
.opt.sel:disabled { opacity: 1; }

table { border-collapse: collapse; width: 100%; }
th, td { padding: 6px 6px; border-bottom: 1px solid #eef0f5; text-align: center; white-space: nowrap; }
th { font-size: 12px; color: #6b7385; font-weight: 600; }
td.name { text-align: left; }
.table-wrap { overflow-x: auto; }
.o { color: #1d6b3d; font-weight: 700; }
.x { color: #b42318; font-weight: 700; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #c3c8d4; }
.dot.on { background: #2e9e5b; }
.bar { position: relative; height: 14px; background: #eef0f5; border-radius: 7px; min-width: 70px; }
.bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: #4a7bd6; border-radius: 7px; }
.bar-label { font-size: 12px; margin-left: 6px; }
.dist span { display: inline-block; min-width: 30px; text-align: center; }
.dist span.key { font-weight: 700; color: #1d6b3d; }

.modal { position: fixed; left: 0; top: 0; right: 0; bottom: 0; background: rgba(20, 28, 45, .45); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal-box { background: #fff; border-radius: 10px; padding: 18px 20px; width: 90%; max-width: 380px; }
.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 8px 14px; border-radius: 8px; z-index: 11; max-width: 90%; }
#modal-text { white-space: pre-line; line-height: 1.5; }
.btn.small { padding: 3px 8px; font-size: 12px; }
/* 2차: 세트 탭, 학생 결과 표시 */
.tabs { margin: 0 0 10px; }
.tabs .btn { margin: 0 6px 6px 0; }
.tabs .btn.cur { background: #1d3a6e; border-color: #1d3a6e; color: #fff; }
.btn.count.cur { background: #2456b3; border-color: #2456b3; color: #fff; }
.mark { margin-left: 8px; font-size: 13px; font-weight: 700; min-width: 90px; }
.mark.o { color: #1d6b3d; }
.mark.x { color: #b42318; }
.opt.wrong { border-color: #e3a3a3; color: #b42318; text-decoration: line-through; }
.opt.right { background: #2e7d4f; border-color: #2e7d4f; color: #fff; }
.opt.right:disabled { opacity: 1; }
td.res { font-weight: 700; }
td.res .o { color: #1d6b3d; }
td.res .x { color: #b42318; }
td.res .arrow { color: #9aa1b1; font-weight: 400; margin: 0 2px; }
.alert.err { background: #fde8e8; border-color: #f0b4b4; }
/* 작은 EDU 창(전자칠판과 함께 띄우는 경우)용 촘촘한 배치 */
@media (max-width: 600px), (max-height: 520px) {
  .topbar { padding: 4px 10px; }
  .brand { font-size: 12px; }
  .who { font-size: 11px; }
  main { padding: 6px; }
  .card { padding: 6px 8px; margin-bottom: 6px; }
  .qrow { padding: 3px 0; }
  .qnum { width: 36px; font-size: 13px; }
  .opt { width: 34px; height: 34px; font-size: 16px; margin-right: 5px; }
  .mark { min-width: 0; margin-left: 4px; font-size: 12px; }
  .btn.big { padding: 8px; font-size: 15px; }
  .btn.block { margin-top: 6px; }
  .alert { padding: 5px 8px; margin-bottom: 6px; font-size: 13px; }
  #s-help { display: none; }
}
@media (max-width: 380px) {
  .opt { width: 30px; height: 30px; font-size: 15px; margin-right: 3px; }
  .qnum { width: 30px; }
}

/* ===== 태블릿 분할 화면(왼쪽 EDU · 오른쪽 손필기)용 ===== */
/* 터치: 더블탭 확대·글자 선택·탭 하이라이트 방지 */
.btn, .opt { touch-action: manipulation; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; }
/* 세로로 긴 반쪽 창: 높이에 여유가 있으면 학생 버튼을 크게(손가락 터치 44px 이상) */
@media (max-width: 760px) and (min-height: 540px) {
  #v-student .qrow { padding: 9px 0; }
  #v-student .qnum { width: 44px; font-size: 16px; }
  #v-student .opt { width: 50px; height: 50px; font-size: 24px; margin-right: 7px; }
  #v-student .mark { font-size: 13px; margin-left: 6px; }
  #v-student .btn.big { padding: 14px; font-size: 17px; }
  #v-student #s-title { font-size: 16px; }
}
@media (max-width: 480px) and (min-height: 540px) {
  #v-student .opt { width: 44px; height: 44px; font-size: 21px; margin-right: 5px; }
  #v-student .qnum { width: 36px; }
}
/* 교사 화면이 반쪽 창일 때: 표 글자·여백 축소, 세트 탭 가로 스크롤 */
@media (max-width: 760px) {
  #v-teacher th, #v-teacher td { padding: 4px 3px; font-size: 12px; }
  #v-teacher .bar { min-width: 40px; }
  #v-teacher .dist span { min-width: 22px; }
  #v-teacher .tabs { white-space: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  #v-teacher .row-between .actions { margin-top: 4px; }
  #t-key .opt { width: 36px; height: 36px; font-size: 17px; }
}
