/* ============================================================================
   입문반 졸업시험 — 중급반 리디자인과 통일된 디자인 언어 (20260704)
   9세트 통과 트래커 신설, 연습 전/중 상태 분리(exam-active), 10문장 진행 바,
   실시간 통계·기록 테이블 유지. JS의 id/onclick·퀴즈 오버레이는 그대로.
   ========================================================================== */
:root {
  --ink: #171a2b;
  --text: #3a3f55;
  --muted: #767b92;
  --faint: #a2a7bb;
  --line: #e7e9f1;
  --line-strong: #d7dae6;
  --paper: #f4f5f9;
  --card: #ffffff;
  --wash: #fafafd;
  --violet: #5b3df0;
  --violet-deep: #4529ce;
  --violet-tint: #efecfe;
  --violet-wash: #f8f7ff;
  --green: #0e8a63;
  --green-tint: #e6f5ef;
  --amber: #b45309;
  --amber-tint: #fdf3e7;
  --red: #c2453f;
  --red-tint: #fdeceb;
  --r-ctl: 10px;
  --r-card: 16px;
  --shadow-card: 0 10px 30px rgba(23, 26, 43, .05);
  --shadow-pop: 0 22px 60px rgba(23, 26, 43, .22);
  --sidebar-width: 240px;
  --font-sans: Pretendard, "Apple SD Gothic Neo", -apple-system, BlinkMacSystemFont, "Segoe UI", "Malgun Gothic", sans-serif;
  --font-num: "Space Grotesk", Pretendard, sans-serif;
  --primary: var(--violet);
  --primary-dark: var(--violet-deep);
  --success: var(--green);
  --danger: var(--red);
  --text-dark: var(--ink);
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; padding: 0; font-family: var(--font-sans); color: var(--text); background: var(--paper); letter-spacing: -0.02em; overflow: hidden; display: flex; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(91, 61, 240, .28); outline-offset: 2px; }
a { color: inherit; text-decoration: none; }
svg { display: block; width: 1em; height: 1em; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.num { font-family: var(--font-num); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }

.main-content { flex: 1; min-width: 0; height: 100vh; overflow-y: auto; padding: 34px clamp(20px, 3.2vw, 44px) 48px; }

/* 사이드바 */
.sidebar { position: sticky; top: 0; z-index: 30; display: flex; flex-direction: column; gap: 14px; width: var(--sidebar-width); height: 100vh; padding: 22px 14px 16px; border-right: 1px solid var(--line); background: var(--card); overflow-y: auto; flex-shrink: 0; }
.sidebar-top { display: flex; align-items: center; justify-content: space-between; padding: 0 6px; }
.logo { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: 1rem; font-weight: 800; letter-spacing: -0.03em; }
.sidebar-close-btn, .mobile-menu-btn { display: none; border: 0; background: transparent; color: var(--ink); }
.nav-list.nav-groups { display: grid; gap: 4px; align-content: start; flex: 1; }
.nav-section { border: 0; }
.nav-section-title { display: flex; align-items: center; justify-content: space-between; padding: 9px 8px 5px; color: var(--faint); font-size: 0.6562rem; font-weight: 800; letter-spacing: .08em; list-style: none; cursor: pointer; }
.nav-section-title::-webkit-details-marker { display: none; }
.nav-section-arrow { font-size: 0.75rem; transition: transform .18s ease; }
.nav-section[open] .nav-section-arrow { transform: rotate(180deg); }
.nav-section-list { display: grid; gap: 1px; }
.nav-item { display: flex; align-items: center; gap: 9px; min-height: 36px; padding: 6px 10px; border-radius: 9px; color: var(--text); font-size: 0.8125rem; font-weight: 500; transition: background-color .13s ease, color .13s ease; }
.nav-item:hover { background: var(--wash); color: var(--ink); }
.nav-item.active { color: var(--violet-deep); background: var(--violet-tint); font-weight: 700; }
.nav-icon { width: 18px; text-align: center; font-size: 0.875rem; filter: grayscale(.25); }
.nav-item.active .nav-icon { filter: none; }
.ai-nav-highlight .nav-text { background: linear-gradient(90deg, var(--violet), #8a6cf8); -webkit-background-clip: text; background-clip: text; color: transparent; font-weight: 700; }
.sidebar-footer { display: grid; gap: 8px; }
.profile-card { display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); cursor: pointer; transition: border-color .15s ease; }
.profile-card:hover { border-color: var(--line-strong); }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--violet-deep); background: var(--violet-tint); font-weight: 800; font-size: 0.8125rem; }
.profile-name { color: var(--ink); font-size: 0.8125rem; font-weight: 700; }
.profile-action { color: var(--faint); font-size: 0.6875rem; }
.admin-trigger { min-height: 34px; border: 1px dashed var(--line-strong); border-radius: 10px; color: var(--muted); background: transparent; font-size: 0.75rem; }
.sidebar-overlay { display: none; }

/* 페이지 헤더 */
.page-header { margin-bottom: 18px; }
.page-eyebrow { display: inline-block; margin-bottom: 8px; color: var(--violet); font-size: 0.6875rem; font-weight: 800; letter-spacing: .14em; }
.page-header-row { display: flex; align-items: center; gap: 14px; }
.page-header h2 { margin: 0; color: var(--ink); font-size: clamp(24px, 2.2vw, 32px); font-weight: 800; letter-spacing: -0.045em; line-height: 1.12; }
.exam-progress-badge { padding: 5px 12px; border-radius: 999px; color: var(--violet-deep); background: var(--violet-tint); font-size: 0.7812rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.page-header p { margin: 10px 0 0; color: var(--muted); font-size: 0.875rem; line-height: 1.55; }

/* 9세트 통과 트래커 */
.exam-tracker-card { margin-bottom: 16px; padding: 18px 22px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card); box-shadow: var(--shadow-card); }
.exam-tracker-head { margin-bottom: 14px; }
.exam-tracker-title { color: var(--ink); font-size: 0.875rem; font-weight: 800; }
.exam-set-tracker { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.exam-set-dots { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.exam-set-dot { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; font-size: 0.875rem; font-weight: 800; font-variant-numeric: tabular-nums; transition: transform .12s ease; }
.exam-set-dot.passed { color: #fff; background: var(--violet); }
.exam-set-dot.current { color: var(--violet-deep); background: var(--violet-tint); border: 2px solid var(--violet); }
.exam-set-dot.locked { color: var(--faint); background: var(--wash); border: 1px solid var(--line); }
.exam-set-count { flex: none; color: var(--muted); font-size: 0.8125rem; font-weight: 600; white-space: nowrap; }
.exam-set-count b { color: var(--ink); font-size: 1.0625rem; font-weight: 700; }

/* 셋업 바 */
.exam-setup-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding: 16px 22px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card); box-shadow: var(--shadow-card); flex-wrap: wrap; }
.exam-set-select { display: flex; align-items: center; gap: 12px; }
.exam-set-select label { color: var(--muted); font-size: 0.8125rem; font-weight: 700; }
#set-selector { height: 42px; min-width: 220px; padding: 0 38px 0 14px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); color: var(--ink); background: var(--card); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23767b92' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; font-size: 0.875rem; font-weight: 600; cursor: pointer; appearance: none; }
#set-selector:focus { border-color: var(--violet); outline: 0; box-shadow: 0 0 0 3px rgba(91,61,240,.1); }
#set-selector:disabled { color: var(--faint); background-color: var(--wash); }
.exam-setup-actions { display: flex; gap: 10px; }
.btn-primary, .btn-secondary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 20px; border-radius: var(--r-ctl); font-size: 0.8438rem; font-weight: 700; transition: border-color .14s ease, background-color .14s ease, color .14s ease; }
.btn-primary { border: 1px solid transparent; color: #fff; background: var(--violet); }
.btn-primary:hover { background: var(--violet-deep); }
.btn-secondary { border: 1px solid var(--line-strong); color: var(--text); background: var(--card); }
.btn-secondary:hover { border-color: var(--violet); color: var(--violet); background: var(--violet-wash); }
.btn-ico { display: inline-flex; font-size: 1rem; }

/* 시험 무대 */
.exam-stage { margin-bottom: 20px; padding: 22px; border: 1px solid #d8cffb; border-radius: var(--r-card); background: var(--card); box-shadow: 0 12px 32px rgba(91,61,240,.08); }
.exam-line-progress { display: none; align-items: center; gap: 14px; margin-bottom: 18px; }
body.exam-active .exam-line-progress { display: flex; }
.exam-line-track { flex: 1; height: 8px; border-radius: 999px; background: var(--violet-tint); overflow: hidden; }
.exam-line-bar { width: 0%; height: 100%; border-radius: 999px; background: var(--violet); transition: width .3s ease; }
.exam-line-label { flex: none; color: var(--muted); font-size: 0.7812rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.exam-block { margin-bottom: 18px; }
.exam-block-label { display: inline-flex; align-items: center; gap: 6px; margin-bottom: 10px; padding: 4px 12px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.exam-block-label b { font-weight: 800; }
.exam-block-label.purple { color: var(--violet-deep); background: var(--violet-tint); }
.exam-block-label.amber { color: var(--muted); background: var(--wash); border: 1px solid var(--line); }
#text-display { display: flex; align-items: center; justify-content: center; min-height: 150px; padding: 28px; border: 1px solid var(--line); border-radius: 14px; background: var(--violet-wash); color: var(--ink); font-size: clamp(1.4rem, 2.4vw, 2rem); font-weight: 700; line-height: 1.6; text-align: center; letter-spacing: -0.02em; }
#typing-input { width: 100%; padding: 18px 20px; border: 2px solid var(--line-strong); border-radius: var(--r-ctl); background: var(--card); color: var(--ink); font-size: 1.15rem; font-weight: 500; outline: none; transition: border-color .2s ease, box-shadow .2s ease; }
#typing-input:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(91,61,240,.12); }
#typing-input:disabled { color: var(--faint); background: var(--wash); }

/* 실시간 통계 */
.exam-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.exam-stat { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--wash); }
.exam-stat-ico { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 11px; font-size: 1.25rem; color: var(--violet); background: var(--violet-tint); }
.exam-stat-copy { display: grid; gap: 2px; min-width: 0; }
.exam-stat-label { color: var(--muted); font-size: 0.75rem; font-weight: 600; }
.exam-stat-value { color: var(--ink); font-size: 0.8125rem; font-weight: 600; }
.exam-stat-value b { font-size: 1.375rem; font-weight: 600; }

/* 응시 기록 */
.exam-history { display: none; margin-bottom: 10px; padding: 22px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card); box-shadow: var(--shadow-card); }
.exam-history-title { margin: 0 0 16px; color: var(--ink); font-size: 0.9375rem; font-weight: 800; }
.exam-table-wrap { overflow-x: auto; }
#result-table { width: 100%; border-collapse: collapse; font-size: 0.8125rem; }
#result-table th { padding: 11px 14px; border-bottom: 2px solid var(--line); color: var(--muted); font-size: 0.75rem; font-weight: 700; text-align: left; white-space: nowrap; }
#result-table td { padding: 12px 14px; border-bottom: 1px solid var(--line); color: var(--text); font-variant-numeric: tabular-nums; }
#result-table tbody tr:hover { background: var(--wash); }

/* 약어 퀴즈 오버레이 */
#quiz-overlay { display: none; position: fixed; inset: 0; z-index: 1000; align-items: center; justify-content: center; padding: 24px; background: rgba(18,19,36,.5); backdrop-filter: blur(3px); }
#quiz-card-box { width: min(560px, 100%); padding: 30px; border-radius: var(--r-card); background: var(--card); box-shadow: var(--shadow-pop); text-align: center; }
#quiz-card-box h3 { color: var(--violet-deep) !important; }
#quiz-sentence { min-height: 60px; margin: 0 0 18px; padding: 18px; border-radius: var(--r-ctl); background: var(--violet-wash); color: var(--ink); font-size: 1.3rem; font-weight: 700; line-height: 1.5; }
#quiz-input { width: 100%; padding: 16px; border: 2px solid var(--violet) !important; border-radius: var(--r-ctl); text-align: center; font-size: 1.2rem; font-weight: 600; outline: none; }
#quiz-input:focus { box-shadow: 0 0 0 4px rgba(91,61,240,.12); }
#quiz-feedback { margin-top: 16px; }
.status-msg { font-size: 1rem; font-weight: 800; margin-bottom: 8px; }
.diff-text { font-size: 1.1rem; }
.correct-info { color: var(--muted); font-size: 0.95rem; }

/* exam-active: 연습 중엔 트래커·셋업을 슬림하게, 무대에 집중 */
body.exam-active .exam-tracker-card { padding: 12px 22px; }
body.exam-active .exam-tracker-head { display: none; }
body.exam-active .exam-setup-bar { padding: 12px 22px; opacity: .8; }
body.exam-active .page-header p { display: none; }

/* 반응형 */
@media (max-width: 1100px) {
  .exam-stats { grid-template-columns: repeat(2, 1fr); }
  .exam-setup-bar { flex-direction: column; align-items: stretch; }
  .exam-setup-actions { justify-content: flex-end; }
}
@media (max-width: 980px) {
  .main-content { width: 100%; padding: 76px clamp(14px, 3vw, 24px) 32px; }
  .sidebar { position: fixed; inset: 0 auto 0 0; z-index: 50; transform: translateX(-102%); transition: transform .22s ease; box-shadow: var(--shadow-pop); }
  .sidebar.active { transform: translateX(0); }
  .sidebar-close-btn { display: grid; place-items: center; width: 32px; height: 32px; font-size: 1.25rem; color: var(--muted); }
  .sidebar-overlay { position: fixed; z-index: 40; inset: 0; display: block; visibility: hidden; background: rgba(18, 19, 36, .35); opacity: 0; transition: opacity .2s ease, visibility .2s ease; }
  .sidebar-overlay.active { visibility: visible; opacity: 1; }
  .mobile-menu-btn { position: fixed; z-index: 35; top: 14px; left: 14px; display: grid; place-items: center; width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 12px; color: var(--violet); background: var(--card); box-shadow: var(--shadow-card); font-size: 1.1875rem; }
}
@media (max-width: 640px) {
  .exam-set-tracker { flex-direction: column; align-items: flex-start; gap: 12px; }
  .exam-set-dot { width: 32px; height: 32px; font-size: 0.75rem; }
  .exam-stats { grid-template-columns: 1fr 1fr; }
  .exam-setup-actions { flex-direction: column; }
  .btn-primary, .btn-secondary { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }
