/* static/css/style.css */
@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.8/dist/web/static/pretendard.css");

/* ============================================================
   P1: 디자인 토큰 — 기존 색감 100% 유지
   ============================================================ */
:root {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  --secondary: #64748b;
  --background: #f8fafc;
  --surface: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.9);

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-light: #94a3b8;

  --success: #10b981;
  --success-bg: #d1fae5;
  --success-text: #065f46;

  --danger: #ef4444;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;

  --warning: #f59e0b;
  --warning-bg: #fef3c7;
  --warning-text: #92400e;

  --border: #e2e8f0;
  --border-light: #f1f5f9;

  --radius-xl: 24px;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;

  --primary-color: var(--primary);
  --secondary-color: var(--secondary);
  --success-color: var(--success);
  --danger-color: var(--danger);
  --text-color: var(--text-main);

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.05);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.05);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.05);
  --shadow-glass: 0 8px 32px 0 rgba(31, 38, 135, 0.07);

  --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* 레이아웃 토큰 */
  --header-height: 64px;
  --container-max: 1280px;
  --container-pad: 40px;
}

/* ============================================================
   P1: 글로벌 리셋 + 바디 (팝업 → 웹앱 전환)
   ============================================================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

html, body {
  width: 100%;
  min-height: 100%;
}

body {
  font-family: "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  background-color: var(--background);
  color: var(--text-main);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 앰비언트 배경 (기존 유지) */
.ambient-background {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background:
    radial-gradient(circle at 15% 50%, rgba(79, 70, 229, 0.06), transparent 40%),
    radial-gradient(circle at 85% 30%, rgba(16, 185, 129, 0.05), transparent 40%),
    radial-gradient(circle at 50% 100%, rgba(239, 68, 68, 0.04), transparent 40%);
  z-index: -1;
  pointer-events: none;
}

.hidden { display: none !important; }

.material-symbols-rounded {
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}

.custom-scrollbar::-webkit-scrollbar { width: 6px; height: 6px; }
.custom-scrollbar::-webkit-scrollbar-track { background: transparent; }
.custom-scrollbar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
.custom-scrollbar::-webkit-scrollbar-thumb:hover { background: var(--secondary); }


/* ============================================================
   P2: 헤더 + 네비게이션 시스템
   ============================================================ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 900;
  width: 100%;
  height: var(--header-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-light);
  box-shadow: 0 1px 12px rgba(15, 23, 42, 0.06);
}

.site-header-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 32px;
}

/* 브랜드 로고 영역 */
.header-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--primary);
  text-decoration: none;
  flex-shrink: 0;
  cursor: pointer;
}
.header-brand .brand-icon { font-size: 26px; }
.header-brand h1 {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

/* 시험 진행 중 배지 */
.quiz-active-badge {
  display: none;
  align-items: center;
  gap: 6px;
  background: var(--danger-bg);
  color: var(--danger);
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
  border: 1px solid #fecaca;
  flex-shrink: 0;
}
.quiz-active-badge.visible { display: flex; }
.quiz-active-badge .material-symbols-rounded { font-size: 14px; }

/* 가로 네비게이션 */
.site-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  justify-content: center;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  transition: var(--transition-fast);
  white-space: nowrap;
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  position: relative;
}
.nav-item .material-symbols-rounded { font-size: 20px; }
.nav-item:hover {
  background: var(--border-light);
  color: var(--text-main);
}
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}
.nav-item.active::after {
  content: '';
  position: absolute;
  bottom: -13px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 3px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

/* 헤더 우측 액션 */
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

/* 볼륨 컨트롤 (헤더 내 이동) */
.volume-control {
  display: flex;
  align-items: center;
  gap: 8px;
}
.volume-control .material-symbols-rounded {
  color: var(--secondary);
  font-size: 20px;
  cursor: pointer;
}
.modern-slider {
  -webkit-appearance: none;
  width: 72px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  transition: var(--transition-fast);
}
.modern-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.1s;
}
.modern-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

/* 햄버거 버튼 (모바일 전용) */
.hamburger-btn {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  transition: var(--transition-fast);
}
.hamburger-btn:hover { background: var(--border-light); }
.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text-main);
  border-radius: 2px;
  transition: var(--transition-normal);
}
.hamburger-btn.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* 모바일 드로어 */
.mobile-drawer {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 280px;
  height: calc(100vh - var(--header-height));
  background: var(--surface);
  box-shadow: var(--shadow-xl);
  z-index: 800;
  padding: 16px;
  flex-direction: column;
  gap: 4px;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow-y: auto;
}
.mobile-drawer.open { transform: translateX(0); }

.drawer-overlay {
  display: none;
  position: fixed;
  top: var(--header-height);
  left: 0;
  width: 100%;
  height: calc(100vh - var(--header-height));
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(2px);
  z-index: 799;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  background: none;
  border: none;
  font-family: inherit;
  width: 100%;
  text-align: left;
}
.drawer-nav-item .material-symbols-rounded { font-size: 22px; }
.drawer-nav-item:hover { background: var(--border-light); color: var(--text-main); }
.drawer-nav-item.active { background: var(--primary-light); color: var(--primary); }


/* ============================================================
   P1: 메인 컨테이너 + 스크린 뷰 시스템
   ============================================================ */
.site-main {
  min-height: calc(100vh - var(--header-height));
  padding: 36px 0 60px;
}

.main-container {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
}

.screen-view { width: 100%; }

/* 공용 버튼 */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-fast);
  -webkit-tap-highlight-color: transparent;
}
button:disabled { opacity: 0.6; cursor: not-allowed; }

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--secondary);
}
.icon-btn:hover { background: var(--border-light); color: var(--primary); }
.icon-btn:active { transform: scale(0.95); }

.icon-btn-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--border-light);
  color: var(--secondary);
}
.icon-btn-small:hover { background: var(--border); color: var(--text-main); }

.btn-primary {
  background: var(--primary);
  color: white;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}
.btn-primary:hover { background: var(--primary-hover); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3); }
.btn-primary:active { transform: translateY(0); }

.btn-large { padding: 16px 32px; font-size: 16px; border-radius: var(--radius-lg); width: 100%; }

.btn-tonal {
  background: var(--primary-light);
  color: var(--primary);
  padding: 12px 24px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 15px;
}
.btn-tonal:hover { background: #e0e7ff; }

.btn-danger-outline {
  background: transparent;
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
}
.btn-danger-outline:hover { background: var(--danger-bg); }

/* 글래스 카드 (기존 유지) */
.glass-card {
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}


/* ============================================================
   P3: 홈 대시보드 화면
   ============================================================ */

/* 인사 배너 */
.dashboard-greeting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 28px;
}
.greeting-text h2 {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
  margin-bottom: 4px;
}
.greeting-text p {
  font-size: 14px;
  color: var(--text-muted);
}
.sync-info {
  font-size: 13px;
  color: var(--text-muted);
  background: var(--border-light);
  padding: 6px 14px;
  border-radius: 20px;
  white-space: nowrap;
}
.sync-info strong { color: var(--primary); }

/* 통계 카드 그리드 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px;
  height: 100%;
  border-radius: 4px 0 0 4px;
}
.stat-card.stat-words::before { background: var(--primary); }
.stat-card.stat-wrong::before { background: var(--danger); }
.stat-card.stat-score::before { background: var(--success); }
.stat-card.stat-categories::before { background: var(--warning); }

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-icon-wrap {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stat-card.stat-words .stat-icon-wrap { background: var(--primary-light); color: var(--primary); }
.stat-card.stat-wrong .stat-icon-wrap { background: var(--danger-bg); color: var(--danger); }
.stat-card.stat-score .stat-icon-wrap { background: var(--success-bg); color: var(--success); }
.stat-card.stat-categories .stat-icon-wrap { background: var(--warning-bg); color: var(--warning); }
.stat-icon-wrap .material-symbols-rounded { font-size: 24px; }

.stat-info { min-width: 0; }
.stat-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.stat-value { font-size: 28px; font-weight: 900; color: var(--text-main); line-height: 1; }
.stat-unit { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-left: 2px; }

/* 대시보드 본문 2단 레이아웃 */
.dashboard-body {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 20px;
  align-items: start;
}

/* 시험 설정 패널 */
.quiz-setup-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
}
.panel-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-title .material-symbols-rounded { font-size: 20px; color: var(--primary); }

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.setting-group { display: flex; flex-direction: column; gap: 8px; }
.setting-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}
.setting-group label .material-symbols-rounded { font-size: 16px; color: var(--secondary); }
.select-wrapper { position: relative; }
.modern-select {
  width: 100%;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 11px 36px 11px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
}
.modern-select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.select-arrow {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--secondary);
  font-size: 18px;
}

/* 시작 버튼 그룹 */
.action-launch-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-hero, .btn-hero-danger, .btn-hero-secondary {
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-lg);
  font-size: 16px;
  font-weight: 700;
  display: flex;
  justify-content: center;
  gap: 10px;
}
.btn-hero {
  background: var(--primary);
  color: white;
  box-shadow: 0 8px 20px rgba(79, 70, 229, 0.3);
}
.btn-hero:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 12px 24px rgba(79, 70, 229, 0.35); }
.btn-hero-danger {
  background: var(--danger);
  color: white;
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.2);
}
.btn-hero-danger:hover { background: #dc2626; transform: translateY(-2px); }
.btn-hero-secondary {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.btn-hero-secondary:hover { background: var(--border-light); color: var(--text-main); transform: translateY(-1px); }

/* 카테고리 분포 패널 */
.category-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.category-panel .panel-title { margin-bottom: 4px; }

.category-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.category-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.category-name { font-size: 13px; font-weight: 700; color: var(--text-main); }
.category-count { font-size: 13px; font-weight: 700; color: var(--text-muted); }
.category-bar {
  height: 6px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}
.category-bar-fill {
  height: 100%;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--primary), #818cf8);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.category-empty {
  text-align: center;
  color: var(--text-light);
  font-size: 13px;
  padding: 16px 0;
}


/* ============================================================
   P4: 단어 관리 페이지
   ============================================================ */

/* 페이지 섹션 헤더 */
.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}
.page-header .material-symbols-rounded { font-size: 28px; color: var(--primary); }
.page-header h2 { font-size: 22px; font-weight: 800; color: var(--text-main); }

/* 탭 전환 */
.manage-tabs {
  display: flex;
  gap: 4px;
  background: var(--border-light);
  padding: 4px;
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  width: fit-content;
}
.tab-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: var(--transition-fast);
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.tab-btn .material-symbols-rounded { font-size: 18px; }
.tab-count {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* 업로드 탭 레이아웃 */
.upload-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.upload-card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.upload-card-title .material-symbols-rounded { font-size: 18px; color: var(--primary); }

/* 드롭존 */
.hidden-input { display: none; }
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-normal);
  text-align: center;
  margin-bottom: 16px;
}
.dropzone:hover { border-color: var(--primary); background: var(--primary-light); }
.drop-icon { font-size: 44px; color: var(--secondary); margin-bottom: 10px; transition: var(--transition-normal); }
.dropzone:hover .drop-icon { color: var(--primary); transform: translateY(-4px); }
.drop-title { font-size: 15px; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.drop-desc { font-size: 12px; color: var(--text-muted); margin-bottom: 12px; }
.file-status-badge {
  background: var(--border-light);
  color: var(--text-muted);
  padding: 4px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
}
.upload-actions { display: flex; gap: 10px; margin-bottom: 12px; }
.upload-actions > button { flex: 1; }
.status-container { text-align: center; min-height: 40px; }
.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 8px;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
.status-message { font-size: 13px; font-weight: 600; }

/* 업로드 가이드 카드 */
.upload-guide {
  background: var(--primary-light);
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}
.upload-guide-title {
  font-size: 14px;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.upload-guide ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.upload-guide li {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  color: var(--primary-hover);
  line-height: 1.5;
}
.upload-guide li::before {
  content: '✓';
  font-weight: 800;
  flex-shrink: 0;
  margin-top: 1px;
}

/* 단어 목록 탭 */
.terms-search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  max-width: 400px;
}
.search-input-wrap .material-symbols-rounded {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 18px;
}
.search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-main);
  transition: var(--transition-fast);
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}
.terms-count-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}
.terms-count-badge strong { color: var(--primary); }

.terms-list-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.category-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.category-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
}
.category-group-name {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}
.category-group-name .material-symbols-rounded { font-size: 16px; color: var(--primary); }
.category-group-cnt {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 10px;
}

.term-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: var(--transition-fast);
}
.term-row:last-child { border-bottom: none; }
.term-row:hover { background: var(--border-light); }

.term-col-term { font-size: 15px; font-weight: 800; color: var(--text-main); }
.term-col-fullword { font-size: 13px; color: var(--text-muted); font-weight: 500; }
.term-col-meaning { font-size: 14px; font-weight: 600; color: var(--primary); }
.term-tts-btn {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  transition: var(--transition-fast);
  color: var(--text-muted);
  display: flex;
  align-items: center;
}
.term-tts-btn:hover { background: var(--primary-light); color: var(--primary); transform: scale(1.1); }

.terms-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.terms-empty .material-symbols-rounded { font-size: 48px; color: var(--border); margin-bottom: 12px; }
.terms-empty p { font-size: 15px; font-weight: 600; }


/* ============================================================
   P5: 퀴즈 진행 화면
   ============================================================ */
.quiz-wrapper {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.quiz-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--surface);
  padding: 14px 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}
.progress-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  color: var(--secondary);
}
.timer {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 1px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #4f46e5, #818cf8, #a5b4fc, #6366f1, #4f46e5);
  background-size: 300% 100%;
  animation: progressGradient 2.5s ease infinite;
  border-radius: 4px;
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes progressGradient {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.question-container {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 48px 36px;
  text-align: center;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 200px;
}
.question-category {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.question-title {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.4;
  word-break: keep-all;
}

.input-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
}
.interaction-area { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.action-btn-slot { width: 100%; }

.input-wrapper { position: relative; width: 100%; }
#answer-input {
  width: 100%;
  padding: 20px;
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  color: var(--text-main);
  transition: var(--transition-normal);
  font-family: inherit;
}
#answer-input:focus { outline: none; border-color: var(--primary); }
.focus-border {
  position: absolute;
  bottom: -2px; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 3px;
  background: var(--primary);
  transition: 0.3s ease;
  border-radius: 4px;
  pointer-events: none;
}
#answer-input:focus ~ .focus-border { width: 60%; }

/* 힌트 시스템 */
.hint-system {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}
.hint-controls { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; justify-content: center; }
.btn-hint {
  background-color: #f39c12;
  color: white;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 20px;
  box-shadow: 0 4px 10px rgba(243, 156, 18, 0.3);
}
.btn-hint:hover { filter: brightness(0.95); transform: translateY(-1px); }
.btn-hint-extra {
  background-color: #27ae60;
  color: white;
  padding: 10px 24px;
  font-size: 14px;
  font-weight: bold;
  border-radius: 20px;
  box-shadow: 0 4px 10px rgba(39, 174, 96, 0.3);
}
.btn-hint-extra:hover:not(:disabled) { filter: brightness(0.95); transform: translateY(-1px); }
.btn-hint-extra:disabled {
  background-color: #ecf0f1;
  color: var(--danger);
  box-shadow: none;
  cursor: not-allowed;
  border: 1px solid #bdc3c7;
}
.hint-display-box {
  width: 100%;
  text-align: center;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--warning);
  min-height: 28px;
  opacity: 0;
  transition: opacity 0.3s;
}
.hint-display-box.visible { opacity: 1; }

/* 객관식 버튼 */
.mc-btn {
  width: 100%;
  padding: 16px 20px;
  text-align: left;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  margin-bottom: 6px;
  font-family: inherit;
}
.mc-btn:hover:not(:disabled) { border-color: var(--primary); background: var(--primary-light); transform: translateX(4px); }
.mc-btn.correct { background: var(--success); color: white; border-color: var(--success); }
.mc-btn.wrong { background: var(--danger); color: white; border-color: var(--danger); }

/* 피드백 카드 */
.feedback-card {
  padding: 24px;
  border-radius: var(--radius-lg) !important;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  overflow: hidden !important;
}
.feedback-correct { background: var(--success-bg); border: 2px solid #a7f3d0; }
.feedback-correct #feedback-title, .feedback-correct #feedback-icon { color: var(--success-text); }
.feedback-incorrect { background: var(--danger-bg); border: 2px solid #fecaca; }
.feedback-incorrect #feedback-title, .feedback-incorrect #feedback-icon { color: var(--danger-text); }
.feedback-header { display: flex; align-items: center; gap: 8px; font-size: 20px; }
.feedback-header h3 { margin: 0; font-weight: 800; }
.feedback-content { font-size: 16px; color: var(--text-main); }
.feedback-extra { background: rgba(255,255,255,0.6); padding: 12px; border-radius: var(--radius-md); font-size: 14px; }
.badge-importance {
  display: inline-block;
  background: var(--warning);
  color: white;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 6px;
}

/* TTS 버튼 */
.tts-btn {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  transition: transform 0.2s;
  padding: 4px;
  border-radius: 50%;
}
.tts-btn:hover { background: var(--primary-light); transform: scale(1.1); }


/* ============================================================
   P6: 결과 화면
   ============================================================ */
.result-wrapper {
  max-width: 680px;
  margin: 0 auto;
}
.result-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.score-display { position: relative; margin-bottom: 24px; }
.score-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: conic-gradient(var(--success) 0%, var(--border-light) 0%);
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
  position: relative;
  box-shadow: var(--shadow-md);
}
.score-circle::before {
  content: '';
  position: absolute;
  width: 140px; height: 140px;
  background-color: var(--surface);
  border-radius: 50%;
}
.score-text {
  position: relative;
  font-size: 36px;
  font-weight: 900;
  color: var(--primary);
  z-index: 1;
}
.result-msg { font-size: 24px; font-weight: 800; color: var(--primary); margin-bottom: 20px; }

.result-stats { display: flex; gap: 16px; margin-bottom: 32px; }
.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 14px 24px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.stat-box .material-symbols-rounded { color: var(--secondary); font-size: 20px; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 600; }
.stat-box strong { font-size: 18px; color: var(--text-main); font-weight: 800; font-family: monospace; }

.result-actions { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 420px; margin-bottom: 28px; }

/* 오답 목록 */
.data-list-container { display: flex; flex-direction: column; gap: 14px; width: 100%; margin-bottom: 24px; }
.wrong-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.wrong-item h4 { margin: 0 0 10px 0; color: var(--text-main); font-size: 15px; font-weight: 700; line-height: 1.4; }
.wrong-item p { margin: 4px 0; font-size: 14px; color: var(--text-muted); }
.user-ans { color: var(--danger); text-decoration: line-through; margin-right: 8px; }
.correct-ans { color: var(--success); font-weight: 700; }


/* ============================================================
   P6: 오답 기록 화면 (모달 → 풀페이지)
   ============================================================ */
.history-layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  align-items: start;
}

.history-list-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  max-height: calc(100vh - 160px);
  display: flex;
  flex-direction: column;
}
.history-list-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.history-list-header h3 { font-size: 15px; font-weight: 800; color: var(--text-main); }
.history-list-body { overflow-y: auto; flex: 1; padding: 12px; }

.history-record-btn {
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  margin-bottom: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: var(--transition-fast);
  display: flex;
  flex-direction: column;
  gap: 5px;
  cursor: pointer;
  font-family: inherit;
}
.history-record-btn:hover { border-color: var(--primary); transform: translateX(3px); box-shadow: var(--shadow-sm); }
.history-record-btn.active { border-color: var(--primary); background: var(--primary-light); }
.history-record-btn .rec-date { font-size: 13px; font-weight: 700; color: var(--text-main); }
.history-record-btn .rec-info { font-size: 12px; color: var(--text-muted); }

.history-detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.history-detail-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.history-detail-header h3 { font-size: 16px; font-weight: 800; color: var(--text-main); }
.history-detail-body { padding: 20px 24px; overflow-y: auto; max-height: calc(100vh - 220px); }

.history-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
  color: var(--text-muted);
}
.history-empty-state .material-symbols-rounded { font-size: 52px; color: var(--border); margin-bottom: 16px; }
.history-empty-state p { font-size: 15px; font-weight: 600; }
.history-empty-state small { font-size: 13px; color: var(--text-light); margin-top: 6px; display: block; }

.info-banner {
  background: var(--primary-light);
  color: var(--primary-hover);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 20px;
}

/* 누적 오답 화면 */
.accumulated-wrapper {
  max-width: 800px;
  margin: 0 auto;
}
.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  color: var(--text-main);
}
.display-icon { font-size: 28px; color: var(--primary); }
.screen-header h2 { font-size: 22px; font-weight: 800; margin: 0; }
.bottom-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  border-top: 1px solid var(--border);
  padding-top: 20px;
  margin-top: 20px;
  gap: 12px;
}


/* ============================================================
   모달 (이미지 뷰어 / 업로드 대기열)
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}
.modal-surface {
  background: var(--surface);
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}
.modal-header h3 { margin: 0; font-size: 17px; font-weight: 700; color: var(--text-main); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--background);
}

.viewer-surface {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  display: flex;
  justify-content: center;
  align-items: center;
}
#viewer-image {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}
.close-viewer-btn {
  position: absolute;
  top: -20px; right: -20px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-main);
  font-size: 24px;
  box-shadow: var(--shadow-md);
  z-index: 3001;
}
.close-viewer-btn:hover { background: var(--danger); color: white; }


/* ============================================================
   P11: 반응형 — 태블릿 (≤ 1100px)
   ============================================================ */
@media (max-width: 1100px) {
  :root {
    --container-pad: 28px;
  }

  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  .dashboard-body {
    grid-template-columns: 1fr;
  }
  .category-panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .category-panel .panel-title { grid-column: 1 / -1; margin-bottom: 0; }

  .upload-layout { grid-template-columns: 1fr; }

  .history-layout {
    grid-template-columns: 1fr;
  }
  .history-list-panel { max-height: 320px; }
  .history-detail-body { max-height: none; }
}

/* ============================================================
   P11: 반응형 — 모바일 (≤ 768px)
   ============================================================ */
@media (max-width: 768px) {
  :root {
    --container-pad: 16px;
    --header-height: 56px;
  }

  /* 헤더 모바일 */
  .site-nav { display: none; }
  .hamburger-btn { display: flex; }
  .mobile-drawer { display: flex; }

  .header-brand h1 { font-size: 15px; }
  .volume-control { display: none; } /* 드로어로 이동 */

  /* 대시보드 */
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 16px; gap: 12px; }
  .stat-value { font-size: 22px; }

  .dashboard-greeting h2 { font-size: 20px; }
  .quiz-setup-panel { padding: 20px; }
  .settings-grid { grid-template-columns: 1fr; }

  .category-panel { grid-template-columns: 1fr; }
  .category-panel .panel-title { grid-column: 1; }

  /* 퀴즈 */
  .question-container { padding: 32px 20px; }
  .question-title { font-size: 22px; }
  #answer-input { font-size: 18px; padding: 16px; }

  /* 오답 기록 */
  .history-layout { grid-template-columns: 1fr; }

  /* 결과 */
  .result-stats { flex-wrap: wrap; justify-content: center; }

  /* 단어 목록 */
  .term-row { grid-template-columns: 1fr 1fr auto; }
  .term-col-fullword { display: none; }

  /* 탭 */
  .manage-tabs { width: 100%; }
  .tab-btn { flex: 1; justify-content: center; }
}

/* ============================================================
   P11: 반응형 — 소형 모바일 (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { flex-direction: column; text-align: center; padding: 16px 12px; }
  .stat-card::before { width: 100%; height: 4px; top: 0; left: 0; border-radius: 4px 4px 0 0; }

  .quiz-status-bar { padding: 10px 14px; }
  .timer { font-size: 18px; }

  .quiz-active-badge span:not(.material-symbols-rounded) { display: none; }

  .result-stats { gap: 10px; }
  .stat-box { padding: 12px 16px; }
  .result-actions { max-width: 100%; }

  .btn-hero, .btn-hero-danger, .btn-hero-secondary { padding: 14px 16px; font-size: 15px; }

  .history-list-panel { max-height: 260px; }
}
