/* 학생 응시 화면. 휴대폰 세로 화면이 기준이다. */

body.student {
  /* 100vh 는 모바일에서 주소창 높이를 포함해 하단 버튼이 잘린다. */
  min-height: 100dvh;
  background: var(--bg);
}

.screen { min-height: 100dvh; }

.wrap-narrow { max-width: 520px; margin: 0 auto; padding: 18px; }
.mt { margin-top: 24px; }
.lead { color: var(--text-muted); margin-bottom: 18px; }
.err { color: var(--danger); font-weight: 600; margin: 10px 0 0; }
.ok-msg {
  color: var(--ok);
  font-weight: 600;
  margin: 10px 0 0;
  background: var(--ok-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.hero { font-size: 1.75rem; letter-spacing: -.01em; }
.sep { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }

#banner-inapp, #banner-offline {
  margin: 0;
  border-radius: 0;
  position: sticky;
  top: 0;
  z-index: 40;
}

/* 로그인 / 가입 전환 */
.seg {
  display: flex;
  gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px;
  margin-bottom: 14px;
}
.seg-btn {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-weight: 700;
  color: var(--text-muted);
  padding: 10px 0;
  min-height: 44px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.seg-btn.on { background: var(--surface); color: var(--brand-dark); box-shadow: var(--shadow); }

/* 내 화면의 시험 목록 */
.exam-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 2px;
  border-bottom: 1px solid var(--border);
}
.exam-item:last-child { border-bottom: 0; }
.exam-main { flex: 1; min-width: 0; }
.exam-name { font-weight: 700; }
.exam-meta { font-size: .84rem; color: var(--text-muted); margin-top: 2px; }

.student .topbar { padding-top: calc(10px + env(safe-area-inset-top)); }

/* 내 학급 — 학년도마다 한 줄 */
.my-year {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
}
.my-year:last-child { border-bottom: 0; }
.my-year-label {
  font-size: .8rem;
  font-weight: 700;
  color: var(--text-faint);
  min-width: 6.6em;
}
.my-chip {
  display: inline-block;
  padding: 3px 11px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: .86rem;
  font-weight: 600;
}
.my-chip.off {
  background: var(--surface-2);
  color: var(--text-faint);
  text-decoration: line-through;
}
.my-drop {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 1.1rem;
  line-height: 1;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 50%;
}
.my-drop:hover { background: var(--danger-soft); color: var(--danger); }

.code-input {
  text-align: center;
  font-family: "Consolas", ui-monospace, monospace;
  font-size: 30px !important;
  letter-spacing: .3em;
  text-transform: uppercase;
  padding: 14px 10px;
  height: 62px;
}

/* ---------- 응시 화면 ---------- */

.quiz-layout {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

.quiz-top {
  flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px 8px;
  padding-top: calc(10px + env(safe-area-inset-top));
}
.quiz-top-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
.quiz-top-row.small { font-size: .82rem; color: var(--text-muted); margin-top: 6px; }
.quiz-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quiz-timer {
  font-family: "Consolas", ui-monospace, monospace;
  font-weight: 700;
  font-size: 1.05rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  flex: none;
}
.quiz-timer.warn { background: var(--warn-soft); color: var(--warn); }
.quiz-timer.danger { background: var(--danger-soft); color: var(--danger); }

.progress { height: 5px; background: var(--border); border-radius: 3px; margin-top: 8px; }
.progress-fill {
  height: 100%;
  width: 0;
  background: var(--brand);
  border-radius: 3px;
  transition: width .2s;
}

.save-state { color: var(--text-faint); }
.save-state.saving { color: var(--warn); }
.save-state.failed { color: var(--danger); font-weight: 700; }

.quiz-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 14px 24px;
  /* 응시 중에는 문제·제시문·보기를 끌어 선택하거나 복사할 수 없게 한다.
     길게 눌렀을 때 뜨는 복사 메뉴(-webkit-touch-callout)도 막는다. */
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* 직접 써야 하는 답안 칸은 평소대로 고르고 지울 수 있어야 한다. */
.quiz-body input,
.quiz-body textarea {
  -webkit-user-select: text;
  -ms-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

.qcard {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  margin: 0 auto 14px;
  max-width: 620px;
}
.qhead {
  display: flex;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: .84rem;
  color: var(--text-muted);
  font-weight: 700;
}
/* 제시문 — 문제와 눈에 띄게 구분해 준다 */
.qpassage {
  background: var(--surface-2);
  border-left: 4px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 1rem;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text);
  max-height: 44vh;
  overflow-y: auto;
}

.qtext {
  font-size: 1.08rem;
  line-height: 1.65;
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* 보기: 터치 영역을 크게. 선택 상태는 색만이 아니라 테두리와 표시로도 구분한다
   (색맹 학생이 구분하지 못하는 일이 없도록). */
.choice {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 14px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  cursor: pointer;
  background: var(--surface);
  min-height: 54px;
}
.choice:hover { border-color: var(--border-strong); }
.choice input { margin-top: 2px; }
.choice-mark {
  flex: none;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 1.4em;
}
.choice-text { flex: 1; line-height: 1.5; white-space: pre-wrap; }
.choice.picked {
  border-color: var(--brand);
  background: var(--brand-soft);
}
.choice.picked .choice-mark { color: var(--brand-dark); }
.choice.picked::after {
  content: "선택함";
  flex: none;
  font-size: .74rem;
  font-weight: 700;
  color: var(--brand-dark);
  align-self: center;
}

.ox-row { display: flex; gap: 12px; }
.ox-row .choice { flex: 1; justify-content: center; font-size: 1.5rem; font-weight: 700; }
.ox-row .choice-text { flex: none; }

.quiz-bottom {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.quiz-bottom .btn { flex: 1; }

.jump-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(52px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.jump-grid button {
  appearance: none;
  font: inherit;
  font-weight: 700;
  padding: 12px 0;
  border-radius: var(--radius-sm);
  border: 2px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
}
.jump-grid button.answered {
  border-color: var(--brand);
  background: var(--brand-soft);
  color: var(--brand-dark);
}
.jump-grid button.current { outline: 3px solid var(--text); outline-offset: 1px; }

/* ---------- 제출 완료 ---------- */

.done-card { text-align: center; padding: 34px 20px; }
.done-mark {
  width: 66px;
  height: 66px;
  line-height: 66px;
  border-radius: 50%;
  background: var(--ok-soft);
  color: var(--ok);
  font-size: 2.1rem;
  font-weight: 700;
  margin: 0 auto 16px;
}
.score-big {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
  margin: 12px 0;
}

.review { margin-bottom: 12px; }
.review .qcard { border-left: 5px solid var(--danger); }
.review .qcard.right { border-left-color: var(--ok); }
.review-tag { font-weight: 700; }
.review-tag.right { color: var(--ok); }
.review-tag.wrong { color: var(--danger); }
.review-line { font-size: .92rem; margin-top: 6px; }
.review-line b { color: var(--text-muted); font-weight: 600; }

@media (min-width: 700px) {
  .quiz-body { padding: 24px; }
}

/* 제시문 사진 — 사료 사진·그래프·지도처럼 글로 옮길 수 없는 자료.
   응시 중에는 끌어 가거나 길게 눌러 저장할 수 없게 막는다.
   (완전한 차단은 아니다. 화면 캡처는 여전히 된다.) */
.qpassage-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 10px auto 2px;
  border-radius: var(--radius-sm);
  background: #fff;
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  pointer-events: none;
}
/* 사진이 들어가면 글만 있을 때보다 높이가 넉넉해야 한다. */
.qpassage:has(.qpassage-img) { max-height: none; }
