/* ============================================================================
   약어 랜덤 테스트 — 중급반 리디자인과 통일된 디자인 언어 (20260704)
   구조 개편: 1단계 파일 → 2단계 방식 선택(무대 위 셋업) → 연습 무대 → 보조 액션.
   중복됐던 듣고치기 칩 제거, 큰 약어표시+입력창을 위로. JS의 id/onclick·상태 클래스
   (blind/reveal/mosaic-flash/shake/active/is-disabled/loaded/show)는 그대로 유지.
   ========================================================================== */
: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;
  --amber: #b45309;
  --red: #c2453f;
  --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);
  --text-dark: var(--ink);
  --text-grey: var(--muted);
  --danger: var(--red);
}

* { 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;
}
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; }

/* 앱 셸 */
#app-wrapper { display: flex; min-height: 100vh; width: 100vw; }
body[data-auth="approved"] { display: flex; }
.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: 22px; }
.page-eyebrow { display: inline-block; margin-bottom: 8px; color: var(--violet); font-size: 0.6875rem; font-weight: 800; letter-spacing: .14em; }
.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; }
.page-header p { margin: 8px 0 0; color: var(--muted); font-size: 0.875rem; }

/* =========================================================
   셋업 존 — 연습 전. 드릴 시작되면 슬림하게 접힌다.
   ========================================================= */
.setup-zone { display: grid; gap: 14px; margin-bottom: 20px; }

/* 파일 불러오기 패널: 파일 없을 때 이 화면의 첫 액션이므로 눈에 띄게 */
.load-panel { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border: 1px solid var(--line); border-radius: var(--r-card); background: var(--card); box-shadow: var(--shadow-card); }
.load-panel-icon { display: grid; place-items: center; width: 46px; height: 46px; flex: none; border-radius: 12px; color: var(--violet); background: var(--violet-tint); font-size: 1.375rem; }
.load-panel-copy { min-width: 0; }
.file-load-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: var(--r-ctl); color: #fff; background: var(--violet); font-size: 0.875rem; font-weight: 700; transition: background-color .14s ease; }
.file-load-btn:hover { background: var(--violet-deep); }
.file-load-btn.loaded, .personal-load-chip.loaded { color: var(--green); background: #e6f5ef; border-color: transparent; }
.load-panel-note { margin: 8px 0 0; color: var(--faint); font-size: 0.75rem; line-height: 1.5; }

/* 방식 선택: 큰 선택 카드 두 장 */
.mode-pick-group { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mode-pick { display: flex; align-items: center; gap: 14px; padding: 18px 20px; border: 1px solid var(--line-strong); border-radius: var(--r-card); background: var(--card); text-align: left; transition: border-color .14s ease, background-color .14s ease, box-shadow .14s ease, transform .1s ease; }
.mode-pick:hover:not(:disabled):not(.is-disabled) { border-color: var(--violet); box-shadow: 0 10px 26px rgba(91,61,240,.1); transform: translateY(-1px); }
.mode-pick.active { border-color: transparent; background: var(--violet); box-shadow: 0 12px 30px rgba(91,61,240,.22); }
.mode-pick-ico { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: 12px; color: var(--violet); background: var(--violet-tint); font-size: 1.375rem; }
.mode-pick.active .mode-pick-ico { color: #fff; background: rgba(255,255,255,.18); }
.mode-pick-text { display: grid; gap: 2px; min-width: 0; }
.mode-pick-text b { color: var(--ink); font-size: 1rem; font-weight: 800; }
.mode-pick-text em { color: var(--muted); font-size: 0.75rem; font-style: normal; }
.mode-pick.active .mode-pick-text b, .mode-pick.active .mode-pick-text em { color: #fff; }
.mode-pick.active .mode-pick-text em { opacity: .85; }
.mode-pick:disabled, .mode-pick.is-disabled { cursor: not-allowed; opacity: .55; border-style: dashed; }
.mode-pick:disabled .mode-pick-ico, .mode-pick.is-disabled .mode-pick-ico { color: var(--faint); background: var(--wash); }

/* 오답 복습 스트립 */
.review-strip { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border: 1px dashed var(--line-strong); border-radius: var(--r-card); background: var(--wash); }
.review-strip-label { display: inline-flex; align-items: center; gap: 8px; flex: none; color: var(--muted); font-size: 0.8125rem; font-weight: 700; }
.review-ico { display: inline-flex; font-size: 1rem; color: var(--amber); }
.wrong-review-actions { display: flex; gap: 10px; flex-wrap: wrap; flex: 1; }
.wrong-review-actions:empty::after { content: '연습을 마치면 틀린 약어만 모아 복습할 수 있습니다.'; color: var(--faint); font-size: 0.75rem; }
.mode-chip { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: var(--r-ctl); color: var(--text); background: var(--card); font-size: 0.8125rem; font-weight: 700; transition: border-color .14s ease, color .14s ease; }
.mode-chip:hover:not(.is-disabled) { border-color: var(--violet); color: var(--violet); }
.mode-chip.active { border-color: transparent; color: #fff; background: var(--violet); }
.mode-chip.is-disabled, .mode-chip:disabled { color: var(--faint); background: var(--wash); border-color: var(--line); cursor: not-allowed; opacity: .7; }

.btn-ico { display: inline-flex; font-size: 1rem; }
.mode-status { margin: 0; padding: 11px 14px; border-radius: var(--r-ctl); background: var(--wash); border: 1px solid var(--line); color: var(--muted); font-size: 0.7812rem; line-height: 1.5; }
.dict-voice-guide { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: var(--r-ctl); background: var(--violet-wash); border: 1px solid #e6e1fb; }
.dict-voice-guide strong { color: var(--violet-deep); font-size: 0.8125rem; font-weight: 700; }
.dict-voice-guide span { color: var(--muted); font-size: 0.75rem; }

/* =========================================================
   드릴 존 — 연습 중. 기본은 숨김, drill-active일 때만 표시.
   ========================================================= */
.drill-zone { display: none; 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,.1); }
body.drill-active .drill-zone { display: block; }

/* 드릴 진행 헤더 */
.drill-head { display: flex; align-items: center; gap: 18px; margin-bottom: 18px; }
.drill-progress { flex: 1; min-width: 0; }
.drill-progress-track { height: 8px; border-radius: 999px; background: var(--violet-tint); overflow: hidden; }
.drill-progress-bar { width: 0%; height: 100%; border-radius: 999px; background: var(--violet); transition: width .3s ease; }
.drill-progress-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; color: var(--muted); font-size: 0.7812rem; }
.drill-progress-meta b { color: var(--ink); font-weight: 700; }
.drill-time { display: inline-flex; align-items: center; gap: 6px; }
.status-ico { display: inline-flex; font-size: 0.9375rem; color: var(--violet); }
.drill-controls { display: flex; align-items: center; gap: 10px; flex: none; }
.combo-badge { padding: 6px 14px; border-radius: 999px; color: var(--amber); background: #fdf3e7; font-size: 0.8125rem; font-weight: 700; opacity: 0; transform: scale(.9); transition: opacity .2s ease, transform .2s ease; }
.combo-badge.show { opacity: 1; transform: scale(1); }
.tts-toggle-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 38px; padding: 0 16px; border: 1px solid #c9befb; border-radius: var(--r-ctl); color: var(--violet-deep); background: var(--card); font-size: 0.8125rem; font-weight: 700; transition: border-color .14s ease, background-color .14s ease, color .14s ease; }
.tts-toggle-btn:hover { background: var(--violet-wash); }
.tts-toggle-btn.active { border-color: transparent; color: #fff; background: var(--violet); }

.audio-settings { display: none; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-ctl); background: var(--wash); }
.audio-group { display: flex; flex-direction: column; gap: 6px; }
.audio-group label { color: var(--muted); font-size: 0.75rem; font-weight: 700; }
.audio-group input { width: 100%; accent-color: var(--violet); cursor: pointer; }

.abbr-wrapper { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-bottom: 20px; }
.abbr-display { width: 100%; min-height: 210px; display: flex; justify-content: center; align-items: center; text-align: center; padding: 24px; border: 1px solid var(--line); border-radius: 14px; background: var(--violet-wash); color: var(--ink); font-size: clamp(3.2rem, 6vw, 5rem); font-weight: 800; letter-spacing: -0.04em; transition: filter .3s ease, opacity .3s ease; }
.abbr-display.blind { filter: blur(20px); opacity: .4; }
.abbr-display.reveal { filter: blur(0); opacity: 1; }
.abbr-display.mosaic-flash { filter: blur(9px) contrast(1.15); opacity: .78; color: var(--violet-deep); text-shadow: 0 0 13px rgba(91,61,240,.5); }
.abbr-display.mosaic-correct-preview { filter: blur(2.2px) contrast(1.08); opacity: 1; color: var(--violet-deep); text-shadow: 0 0 4px rgba(91,61,240,.28); transition: none !important; }
.answer-hint { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; max-width: min(100%, 520px); margin: 0 auto; padding: 7px 14px; border-radius: 999px; color: var(--red); background: #fdeceb; font-size: .9rem; font-weight: 700; text-align: center; line-height: 1.35; }
.answer-hint:empty { display: none; }
.replay-btn { display: inline-flex; align-items: center; gap: 6px; width: fit-content; max-width: 100%; margin: 0 auto; padding: 7px 14px; border: 1px solid var(--line-strong); border-radius: 999px; color: var(--muted); background: var(--card); font-size: .82rem; font-weight: 600; transition: border-color .14s ease, color .14s ease; }
.replay-btn:hover { border-color: var(--violet); color: var(--violet); }
#userInput { width: 100%; padding: 20px; border: 2px solid var(--line-strong); border-radius: var(--r-ctl); text-align: center; font-size: 1.7rem; font-weight: 600; background: var(--card); color: var(--ink); outline: none; transition: border-color .2s ease, box-shadow .2s ease; }
#userInput:focus { border-color: var(--violet); box-shadow: 0 0 0 4px rgba(91,61,240,.12); }
#userInput.shake { animation: shake .4s both; border-color: var(--red) !important; }
@keyframes shake { 10%,90% { transform: translate3d(-1px,0,0); } 20%,80% { transform: translate3d(2px,0,0); } 30%,50%,70% { transform: translate3d(-4px,0,0); } 40%,60% { transform: translate3d(4px,0,0); } }

/* 드릴 중에는 셋업을 슬림 바로 접어 무대에 집중 */
body.drill-active .load-panel { padding: 10px 16px; }
body.drill-active .load-panel-icon { width: 34px; height: 34px; font-size: 1.0625rem; }
body.drill-active .load-panel-note { display: none; }
body.drill-active .file-load-btn { min-height: 36px; font-size: 0.8125rem; }
body.drill-active .mode-pick-group { grid-template-columns: 1fr 1fr; }
body.drill-active .mode-pick { padding: 10px 14px; }
body.drill-active .mode-pick-ico { width: 32px; height: 32px; font-size: 1rem; }
body.drill-active .mode-pick-text em { display: none; }
body.drill-active .review-strip { padding: 10px 16px; }
body.drill-active .mode-status { display: none; }

/* 보조 액션 */
.btn-column { display: flex; flex-direction: column; gap: 12px; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn-secondary, .btn-ghost { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; 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-secondary { border: 1px solid var(--line-strong); background: var(--card); color: var(--text); }
.btn-secondary:hover { border-color: var(--violet); color: var(--violet); background: var(--violet-wash); }
.btn-ghost { border: 1px dashed var(--line-strong); background: transparent; color: var(--muted); }
.btn-ghost:hover { border-color: var(--faint); color: var(--text); }
#fileInput { display: none; }
.helper-text { display: none; }

/* 반응형 */
@media (max-width: 1100px) {
  .drill-head { flex-wrap: wrap; }
  .drill-controls { width: 100%; justify-content: space-between; }
}
@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) {
  .mode-pick-group { grid-template-columns: 1fr; }
  .load-panel { flex-direction: column; align-items: flex-start; }
  .review-strip { flex-direction: column; align-items: flex-start; }
  .btn-row { grid-template-columns: 1fr; }
  .abbr-display { font-size: 2.8rem; min-height: 160px; }
  #userInput { font-size: 1.4rem; }
  body.drill-active .mode-pick-group { grid-template-columns: 1fr 1fr; }
  body.drill-active .mode-pick-text b { font-size: 0.8125rem; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition: none !important; animation: none !important; } }


/* 샘플 파일 다운로드 링크 */
.sample-links { margin:8px 0 0; font-size:12.5px; color:#8b93ab; display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.sample-links a { color:#5b3df0; font-weight:700; text-decoration:none; }
.sample-links a:hover { text-decoration:underline; }
