/* 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: 950px;
  --container-pad: 24px;
}

/* ============================================================
   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;
  scrollbar-gutter: stable;
  -webkit-font-smoothing: antialiased;
}

/* 모달(팝업)이 열려있는 동안 배경 스크롤 차단 — 모달 내부는 각자 overflow-y:auto로 스크롤 */
body.scroll-locked {
  overflow: hidden;
  position: fixed;
  left: 0;
  right: 0;
  width: 100%;
}

/* 앰비언트 배경 (기존 유지) */
.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;
  justify-content: space-between;
  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;
}

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

/* 볼륨 컨트롤 */
.volume-control {
  position: relative;
  display: flex;
  align-items: center;
}

.volume-btn {
  background: none;
  border: none;
  padding: 6px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--secondary);
  transition: background 0.15s;
}

.volume-btn:hover {
  background: var(--surface);
}

.volume-btn .material-symbols-rounded {
  font-size: 22px;
}

/* 아이콘 래퍼: 두 아이콘이 겹쳐 위치 */
.vol-icon-wrap {
  position: relative;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vol-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.22s ease, transform 0.22s ease;
}

/* 기본: 소리 아이콘 보임, 음소거 아이콘 숨김 */
.vol-icon--hidden {
  opacity: 0;
  transform: scale(0.7);
  pointer-events: none;
}

/* 음소거 상태: 아이콘 교체 */
.volume-btn.is-muted #vol-icon-on {
  opacity: 0;
  transform: scale(0.7);
}
.volume-btn.is-muted #vol-icon-off {
  opacity: 1;
  transform: scale(1);
}

.volume-popup {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px 16px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.13);
  z-index: 300;
  min-width: 180px;
}

.volume-popup.hidden {
  display: none;
}

.volume-slider-wrap {
  position: relative;
  padding-top: 30px;
}

.volume-thumb-label {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  background: var(--primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 7px;
  border-radius: 5px;
  pointer-events: none;
  white-space: nowrap;
}

.volume-thumb-label::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 4px solid transparent;
  border-top-color: var(--primary);
}

.modern-slider {
  -webkit-appearance: none;
  width: 140px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  transition: var(--transition-fast);
  display: block;
}

.volume-range {
  width: 140px;
}

.modern-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--primary);
  cursor: pointer;
  transition: transform 0.1s;
}

.modern-slider::-webkit-slider-thumb:hover {
}

/* 뒤로가기 버튼 */
.back-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--border-light);
  color: var(--text-main);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.back-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.back-btn .material-symbols-rounded {
  font-size: 20px;
}


/* ============================================================
   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);
}

/* ============================================================
   푸터
   ============================================================ */
.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 40px 0;
}

.footer-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--container-pad);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.footer-brand {
  width: fit-content;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  text-decoration: none;
}
.footer-brand:hover {
  opacity: 0.75;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.footer-links a {
  color: inherit;
  text-decoration: none;
}
.footer-links a:hover {
  color: var(--primary);
}

.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);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.3);
}

.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: 홈 대시보드 화면
   ============================================================ */

.sync-info {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.sync-info strong {
  color: var(--primary);
}

/* 통계 카드 그리드 — 차트(좌측 확장) + 누적 오답 + 최근 시험 점수 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 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-chart::before {
  background: var(--primary);
}

.stat-card.stat-avg::before {
  background: var(--warning);
}

.stat-card.stat-score::before {
  background: var(--success);
}

.stat-card:hover {
  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-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-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;
}

/* 단어 수 카드 + 평균 정답 카드 공통 레이아웃 */
.stat-card.stat-chart,
.stat-card.stat-avg {
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  gap: 12px;
  padding: 20px 24px;
}

.stat-card.stat-chart .chart-header,
.stat-card.stat-avg .chart-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
  flex-shrink: 0;
}

.stat-card.stat-chart .chart-header .material-symbols-rounded {
  font-size: 20px;
  color: var(--primary);
}

.stat-card.stat-avg .chart-header .material-symbols-rounded {
  font-size: 20px;
  color: var(--warning);
}

.stat-card.stat-chart .chart-body {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  max-height: 130px;
  padding-right: 4px;
}

/* 평균 정답 게이지 */
.avg-score-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.avg-fraction {
  display: flex;
  align-items: center;
}

.avg-num {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1;
}

.avg-bar-track {
  width: 100%;
  height: 5px;
  background: var(--border-light);
  border-radius: 4px;
  overflow: hidden;
}

.avg-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 시험 설정 패널 */
.quiz-setup-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.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);
  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;
}

.btn-hero-secondary {
  background: #374151;
  color: #ffffff;
  border: none;
  box-shadow: 0 6px 16px rgba(55, 65, 81, 0.25);
}

.btn-hero-secondary:hover {
  background: #1f2937;
}

/* 단어 수 분포 (stat-chart 내부) */
.category-count-inline {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.category-pct {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: auto;
}

.category-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.category-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.category-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
}

.category-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

.category-bar {
  height: 5px;
  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: 12px;
  padding: 20px 0;
}



/* ============================================================
   페이지 헤더 (기록 화면 공용)
   ============================================================ */
.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);
}

.tab-count {
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 700;
  margin-left: 4px;
}

/* 업로드 카드 (홈 통합) */
.upload-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.upload-card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.upload-card-title-left {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-card-title-left .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);
}

.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-limit-info {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
  opacity: 0.75;
}

.upload-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 0;
}

.upload-actions>button {
  flex: 1;
}

.status-container {
  text-align: center;
  min-height: 0;
  margin-top: 8px;
}

.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);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.status-message {
  font-size: 13px;
  font-weight: 600;
}

/* AI 처리 진행 박스 */
.ai-progress-box {
  margin-top: 12px;
  background: var(--surface-container, #f5f5f5);
  border: 1px solid var(--outline-variant, #e0e0e0);
  border-radius: 12px;
  padding: 14px 16px 12px;
  text-align: left;
}

.ai-progress-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.ai-progress-header {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-progress-pct {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary, #6750a4);
  white-space: nowrap;
}

.ai-progress-bottom-row {
  display: flex;
  justify-content: flex-end;
  margin-top: 5px;
}

.ai-progress-time {
  font-size: 11px;
  color: var(--on-surface-variant, #49454f);
}

.ai-progress-icon {
  font-size: 18px;
  color: var(--primary, #6750a4);
  animation: pulse-icon 1.4s ease-in-out infinite;
}

@keyframes pulse-icon {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

#ai-progress-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface, #1c1b1f);
}

.ai-progress-bar-wrap {
  background: var(--outline-variant, #e0e0e0);
  border-radius: 99px;
  height: 6px;
  overflow: hidden;
}

.ai-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--primary, #6750a4);
  border-radius: 99px;
  transition: width 0.8s ease;
}

/* 저장된 단어 섹션 */
.terms-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-sm);
}

.terms-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.terms-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.terms-section-title .material-symbols-rounded {
  font-size: 20px;
  color: var(--primary);
}

.terms-section-actions {
  display: flex;
  gap: 8px;
}

.btn-tonal-sm {
  background: var(--primary-light);
  color: var(--primary);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 13px;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition-fast);
}

.btn-tonal-sm:hover:not(:disabled) {
  background: #e0e7ff;
}

.btn-tonal-sm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-tonal-sm .material-symbols-rounded {
  font-size: 16px;
}

.btn-tonal-sm.btn-tonal-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.btn-tonal-sm-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.btn-tonal-sm-danger:hover:not(:disabled) {
  background: #fecaca;
}

/* 전체 삭제 확인 팝업 */
.confirm-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 10px;
}

.confirm-warn {
  display: block;
  font-size: 12.5px;
  color: var(--danger);
  font-weight: 600;
  margin-top: 6px;
}

/* 단어 목록 */
.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: 24px;
}

.terms-flat-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* 컬럼 헤더 */
.term-row-header {
  display: grid;
  grid-template-columns: 70px 1.8fr 1fr 1fr 108px;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: #fafbfc;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.term-row {
  display: grid;
  grid-template-columns: 70px 1.8fr 1fr 1fr 108px;
  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-row.editing {
  background: var(--primary-light);
}

.term-row.dirty {
  background: #fffbeb;
}

.term-row.dirty:hover {
  background: #fef3c7;
}

.term-col-abbr {
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  background: var(--primary-light);
  padding: 4px 10px;
  border-radius: 6px;
  text-align: center;
  display: inline-block;
  width: fit-content;
  min-width: 40px;
  max-width: 100%;
}

.term-col-abbr.empty {
  background: transparent;
  color: var(--text-light);
  font-weight: 600;
}

.term-col-term {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-main);
  word-break: break-word;
}

.term-col-meaning {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  word-break: keep-all;
}

.term-col-pron {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  word-break: keep-all;
  overflow-wrap: break-word;
}

.term-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
}

.term-tts-btn,
.term-edit-btn,
.term-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 50%;
  transition: var(--transition-fast);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.term-tts-btn:hover,
.term-edit-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.term-delete-btn:hover {
  background: #fde8e8;
  color: #e53e3e;
}

.term-tts-btn .material-symbols-rounded,
.term-edit-btn .material-symbols-rounded,
.term-delete-btn .material-symbols-rounded {
  font-size: 18px;
}

/* 삭제 확인 모달 */
.delete-confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fadeIn .15s ease;
}

.delete-confirm-modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 28px 24px;
  width: 320px;
  max-width: 90vw;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
}

.delete-confirm-icon {
  margin-bottom: 12px;
}

.delete-confirm-icon .material-symbols-rounded {
  font-size: 40px;
  color: #e53e3e;
}

.delete-confirm-msg {
  font-size: 15px;
  color: var(--text-main);
  line-height: 1.6;
  margin-bottom: 24px;
}

.delete-confirm-btns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.delete-btn-cancel {
  flex: 1;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
}

.delete-btn-cancel:hover {
  background: var(--border-light);
}

.delete-btn-ok {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: #e53e3e;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-fast);
}

.delete-btn-ok:hover {
  background: #c53030;
}

/* 인라인 편집 input */
.term-row.editing .term-edit-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text-main);
  transition: var(--transition-fast);
}

.term-row.editing .term-edit-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.term-edit-actions {
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  gap: 4px;
}

.term-confirm-btn,
.term-cancel-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.term-confirm-btn {
  background: var(--success-bg);
  color: var(--success-text);
}

.term-confirm-btn:hover {
  background: var(--success);
  color: white;
}

.term-confirm-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.term-cancel-btn {
  background: var(--border-light);
  color: var(--text-muted);
}

.term-cancel-btn:hover {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.term-confirm-btn .material-symbols-rounded,
.term-cancel-btn .material-symbols-rounded {
  font-size: 16px;
}

/* 편집 모드 발음 read-only 표시 */
.term-pron-readonly {
  display: flex;
  align-items: center;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  padding: 0 4px;
}

.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,
.btn-hint-extra {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-hint .material-symbols-rounded,
.btn-hint-extra .material-symbols-rounded {
  font-size: 18px;
}

.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);
}

.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);
}

.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;
}

.quiz-hint-icon {
  font-size: 18px;
  vertical-align: middle;
  margin-right: 4px;
}

/* 객관식 버튼 */
.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);
}

.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;
  display: flex;
  align-items: center;
  gap: 6px;
}

.feedback-title-icon {
  font-size: 24px;
}

.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;
  cursor: pointer;
  transition: var(--transition-fast);
  padding: 4px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.tts-btn .material-symbols-rounded {
  font-size: 22px;
}

.tts-btn:hover {
  color: var(--primary);
  background: var(--primary-light);
}


/* ============================================================
   P6: 결과 화면
   ============================================================ */
#result-screen {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px var(--container-pad);
  padding-bottom: calc(32px + 10vh);
}

.result-wrapper {
  width: 100%;
  max-width: 560px;
}

.result-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  padding: 48px 40px 36px;
}

.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;
}

.result-time-chip {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--primary-light);
  border-radius: 999px;
  padding: 8px 22px 8px 8px;
}

.result-time-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.result-time-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.3;
}

.result-time-label {
  font-size: 11.5px;
  color: var(--primary);
  font-weight: 700;
}

.result-time-value {
  font-size: 17px;
  color: var(--text-main);
  font-weight: 800;
  font-family: monospace;
  letter-spacing: 0.02em;
}

.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);
  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);
  min-width: 0;
}

.btn-retry {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  height: 36px;
  flex-shrink: 0;
  background: var(--primary-light);
  color: var(--primary);
  border: 1px solid rgba(79, 70, 229, 0.25);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-retry:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-retry .material-symbols-rounded {
  font-size: 17px;
}

.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;
}


/* ============================================================
   토스트 알림 (하단 중앙, 아래→위 슬라이드)
   ============================================================ */
.toast-container {
  position: fixed;
  left: 50%;
  bottom: 36px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
  z-index: 3000;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
  max-width: 92vw;
  padding: 14px 22px;
  background: rgba(15, 23, 42, 0.95);
  color: #ffffff;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.1px;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28), 0 2px 6px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  white-space: pre-line;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast.hide {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.25s ease, transform 0.3s ease;
}

.toast .toast-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 18px;
  flex-shrink: 0;
}

.toast.success .toast-icon {
  color: #34d399;
}

.toast.error .toast-icon {
  color: #fca5a5;
}

.toast.info .toast-icon {
  color: #93c5fd;
}

.toast .toast-msg {
  line-height: 1.4;
}

@media (max-width: 768px) {
  .toast-container {
    bottom: 24px;
  }

  .toast {
    min-width: 0;
    padding: 12px 18px;
    font-size: 13.5px;
  }
}


/* ============================================================
   헤더 인증 UI (로그인 버튼 / 사용자 메뉴)
   ============================================================ */
.btn-plan-purchase {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  height: 38px;
  border: none;
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.btn-plan-purchase:hover {
  background: #4338ca;
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,0.3);
}

.btn-plan-purchase .material-symbols-rounded {
  font-size: 17px;
}

.btn-auth-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-auth-trigger:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-auth-trigger .material-symbols-rounded {
  font-size: 18px;
}

.user-menu {
  position: relative;
}

.user-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  height: 38px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-weight: 600;
  font-size: 13.5px;
  border-radius: 999px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.user-menu-btn:hover {
  border-color: var(--primary);
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}

.user-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-menu-chev {
  font-size: 18px;
  color: var(--text-muted);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  min-width: 260px;
  max-width: min(400px, calc(100vw - 24px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 950;
  overflow: hidden;
}

.user-dropdown-info {
  padding: 18px 16px;
  border-bottom: 1px solid var(--border-light);
  background: var(--background);
  display: grid;
  grid-template-columns: max-content minmax(0, max-content);
  column-gap: 10px;
  row-gap: 8px;
  align-items: center;
  font-size: 13px;
}

.udi-row {
  display: contents;
}

.udi-label {
  color: var(--text-muted);
  font-weight: 600;
  white-space: nowrap;
}

.udi-value {
  color: var(--text-main);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-dropdown-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  color: var(--text-main);
  transition: background var(--transition-fast);
}

.user-dropdown-item:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.user-dropdown-item.user-dropdown-logout:hover {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.user-dropdown-item .material-symbols-rounded {
  font-size: 18px;
}

/* ============================================================
   계정 설정 모달 항목
   ============================================================ */
.account-settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.account-settings-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  color: var(--text-main);
  transition: background var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast);
}

.account-settings-item:hover {
  background: var(--primary-light);
  border-color: var(--primary);
}

.account-settings-item:active {
  transform: scale(0.99);
}

.account-settings-item > .material-symbols-rounded {
  font-size: 24px;
  color: var(--primary);
  flex-shrink: 0;
}

.account-settings-item-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.account-settings-item-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.account-settings-item-desc {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.4;
}

.account-settings-item-chev {
  font-size: 20px !important;
  color: var(--text-muted);
  flex-shrink: 0;
}

.account-settings-item-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

.account-settings-item-danger > .material-symbols-rounded:first-child {
  color: var(--danger);
}

.account-settings-item-danger:hover .account-settings-item-title {
  color: var(--danger-text);
}


/* ============================================================
   인증 모달 (로그인 / 회원가입 / 아이디 찾기 / 비밀번호 찾기)
   ============================================================ */
.modal-surface.auth-surface {
  max-width: 440px;
}

.modal-surface.auth-surface-wide {
  max-width: 480px;
}

.modal-body.auth-body {
  padding: 24px;
}

.auth-field {
  margin-bottom: 16px;
}

.auth-field:last-child {
  margin-bottom: 4px;
}

.auth-label {
  display: block;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}

.auth-label-sub {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 4px;
}

.auth-input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--surface);
  transition: all var(--transition-fast);
  outline: none;
}

.auth-input::placeholder {
  color: var(--text-light);
}

.auth-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.auth-input:disabled {
  background: var(--background);
  color: var(--text-muted);
  cursor: not-allowed;
}

.auth-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.auth-row .auth-input {
  flex: 1;
}

.auth-side-btn {
  padding: 0 14px;
  height: 44px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.auth-side-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.auth-side-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.auth-options {
  display: flex;
  align-items: center;
  gap: 20px;
  margin: 6px 0 12px;
  flex-wrap: wrap;
}

.auth-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}

.auth-check input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
  margin: 0;
}

.auth-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.auth-link-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 2px;
  transition: color var(--transition-fast);
}

.auth-link-btn:hover {
  color: var(--primary);
  text-decoration: underline;
}

.auth-link-sep {
  color: var(--border);
  font-size: 12px;
}

/* 로그인 액션 영역: 좌측(아이디 저장·로그인 유지·찾기·회원가입) ↔ 우측(로그인 버튼) */
.login-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 12px;
}

.login-actions-left {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.login-actions-left .auth-options {
  margin: 0;
}

.login-actions-left .auth-links {
  margin-top: 0;
}

.login-submit-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  height: 48px;
  padding: 0 30px;
  font-size: 15px;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

.login-submit-btn .material-symbols-rounded {
  font-size: 18px;
}

.auth-feedback {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  padding-left: 2px;
}

.auth-feedback.ok {
  color: var(--success-text);
}

.auth-feedback.err {
  color: var(--danger);
}

.auth-feedback.muted {
  color: var(--text-muted);
}

.auth-error {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--danger-bg);
  color: var(--danger-text);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}

.auth-result {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--success-bg);
  color: var(--success-text);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1.5;
}

.auth-result .result-username {
  display: inline-block;
  font-family: "Pretendard", monospace;
  font-weight: 800;
  background: var(--surface);
  padding: 4px 10px;
  border-radius: 6px;
  margin: 0 4px;
  letter-spacing: 0.5px;
}

.auth-info-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 16px;
}

.auth-info-banner .material-symbols-rounded {
  font-size: 20px;
}

.modal-footer.auth-footer {
  padding: 16px 24px;
  gap: 10px;
  background: var(--surface);
  border-top: 1px solid var(--border-light);
}

.modal-footer.auth-footer .btn-tonal,
.modal-footer.auth-footer .btn-primary {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 44px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 700;
  border-radius: var(--radius-sm);
}

.modal-footer.auth-footer .material-symbols-rounded {
  font-size: 18px;
}

/* 소셜 로그인 섹션 */
.social-login-section {
  padding: 0 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.social-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-sub);
  font-size: 12px;
}

.social-divider::before,
.social-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.social-login-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-social {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition-fast);
  font-family: inherit;
}

.btn-google {
  background: #fff;
  color: #3c4043;
  border: 1.5px solid #dadce0;
}

.btn-google:hover {
  background: #f8faff;
  border-color: #c0c4cc;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.1);
}


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

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card.stat-chart {
    grid-column: 1 / -1;
    min-height: 0;
  }

  .stat-card.stat-chart .chart-body {
    max-height: 100px;
  }

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

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

  .history-detail-body {
    max-height: none;
  }

  .term-row,
  .term-row-header {
    grid-template-columns: 80px 1.2fr 1fr 0.8fr 80px;
  }
}

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

  .header-brand h1 {
    font-size: 15px;
  }

  .volume-range {
    width: 120px;
  }

  /* 헤더 인증 UI - 모바일 */
  .btn-plan-purchase {
    padding: 6px 10px;
    height: 34px;
    font-size: 12.5px;
  }

  .btn-plan-purchase span:last-of-type { display: none; }

  .btn-auth-trigger {
    padding: 6px 10px;
    height: 34px;
    font-size: 12.5px;
  }

  .btn-auth-trigger span:not(.material-symbols-rounded) {
    display: none;
  }

  .user-menu-btn {
    padding: 3px 10px 3px 3px;
    height: 34px;
  }

  .user-avatar {
    width: 26px;
    height: 26px;
    font-size: 12px;
  }

  .user-name {
    max-width: 80px;
    font-size: 12.5px;
  }

  .user-dropdown {
    right: -8px;
    min-width: 240px;
  }

  /* 인증 모달 - 모바일 */
  .modal-body.auth-body {
    padding: 18px;
  }

  .auth-options {
    gap: 14px;
  }

  .login-actions {
    gap: 12px;
  }

  .login-submit-btn {
    height: 46px;
    padding: 0 22px;
  }

  .auth-side-btn {
    padding: 0 10px;
    font-size: 12.5px;
  }

  .modal-footer.auth-footer {
    padding: 14px 18px;
  }

  .social-login-section {
    padding: 0 18px 16px;
  }

  /* 대시보드 */
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
    gap: 12px;
    min-height: 0;
  }

  .stat-card.stat-chart {
    grid-column: 1 / -1;
    padding: 16px 20px;
  }

  .stat-value {
    font-size: 22px;
  }

  .quiz-setup-panel {
    padding: 20px;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  /* 퀴즈 */
  .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;
  }

  #result-screen {
    padding: 24px 16px;
    align-items: flex-start;
    padding-top: 40px;
  }

  .result-container {
    padding: 36px 24px 28px;
  }

  /* 단어 목록 - 모바일: 약어/단어/뜻만 표시, 발음 숨김 */
  .term-row,
  .term-row-header {
    grid-template-columns: 70px 1fr 1fr 70px;
  }

  .term-col-pron {
    display: none;
  }

  .term-row-header .col-pron {
    display: none;
  }
}

/* ============================================================
   반응형 — 소형 모바일 (≤ 480px)
   ============================================================ */
@media (max-width: 480px) {
  /* 좁은 화면: 로그인 액션을 세로로 쌓고 버튼은 전체 너비 */
  .login-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .login-submit-btn {
    width: 100%;
    padding: 0 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .stat-card {
    padding: 16px 12px;
  }

  .quiz-status-bar {
    padding: 10px 14px;
  }

  .timer {
    font-size: 18px;
  }

  .result-time-chip {
    padding: 6px 18px 6px 6px;
  }

  .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;
  }

  .term-row,
  .term-row-header {
    grid-template-columns: 60px 1fr 1fr 60px;
    padding-left: 14px;
    padding-right: 14px;
    gap: 8px;
  }

  .term-col-abbr {
    font-size: 11px;
    padding: 3px 6px;
    min-width: 30px;
  }
}

/* ============================================================
   커스텀 알림 시스템
   ============================================================ */

/* ── 토스트 (하단 중앙 슬라이드업) ── */
#toast-container {
  position: fixed;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  gap: 10px;
  z-index: 9900;
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px;
  border-radius: var(--radius-md);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  pointer-events: auto;
  min-width: 220px;
  max-width: 420px;
  white-space: pre-line;
  opacity: 0;
  transform: translateY(16px);
  animation: toastIn 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.toast.toast-out {
  animation: toastOut 0.28s ease forwards !important;
}

.toast-success {
  background: #065f46;
}

.toast-error {
  background: #991b1b;
}

.toast-warning {
  background: #78350f;
}

.toast-info {
  background: #1e3a5f;
}

.toast .material-symbols-rounded {
  font-size: 20px;
  flex-shrink: 0;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }

  to {
    opacity: 0;
    transform: translateY(-8px);
  }
}

/* ── 성공 팝업 (정중앙 대형) ── */
.success-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: spOverlayIn 0.3s ease forwards;
}

.success-popup-overlay.sp-closing {
  animation: spOverlayOut 0.35s ease forwards;
}

.success-popup-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 52px 44px 40px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  max-width: 380px;
  width: 90%;
  animation: spCardIn 0.45s cubic-bezier(0.34, 1.36, 0.64, 1) 0.05s both;
}

.success-popup-svg {
  width: 76px;
  height: 76px;
  margin: 0 auto 24px;
  display: block;
}

.sp-circle {
  fill: none;
  stroke: var(--success);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-dasharray: 188;
  stroke-dashoffset: 188;
  animation: spDrawCircle 0.55s ease 0.25s forwards;
}

.sp-check {
  fill: none;
  stroke: var(--success);
  stroke-width: 3.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 44;
  stroke-dashoffset: 44;
  animation: spDrawCheck 0.38s cubic-bezier(0.22, 1, 0.36, 1) 0.72s forwards;
}

.success-popup-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin: 0 0 8px;
}

.success-popup-msg {
  font-size: 14px;
  color: var(--text-muted);
  margin: 0 0 28px;
  line-height: 1.6;
}

.success-popup-progress {
  height: 3px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.success-popup-progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transform-origin: left;
  animation: spBarShrink 2.2s linear 0.9s forwards;
}

@keyframes spOverlayIn {
  from {
    opacity: 0
  }

  to {
    opacity: 1
  }
}

@keyframes spOverlayOut {
  from {
    opacity: 1
  }

  to {
    opacity: 0
  }
}

@keyframes spCardIn {
  from {
    opacity: 0;
    transform: scale(0.82) translateY(24px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes spCardOut {
  from {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  to {
    opacity: 0;
    transform: scale(0.94) translateY(6px);
  }
}

@keyframes spDrawCircle {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes spDrawCheck {
  to {
    stroke-dashoffset: 0;
  }
}

@keyframes spBarShrink {
  from {
    transform: scaleX(1);
  }

  to {
    transform: scaleX(0);
  }
}

/* ── 확인 다이얼로그 ── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: spOverlayIn 0.2s ease forwards;
}

.confirm-overlay.closing {
  animation: spOverlayOut 0.2s ease forwards;
  pointer-events: none;
}

.confirm-overlay.closing .confirm-card {
  animation: spCardOut 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.delete-confirm-overlay.closing {
  animation: spOverlayOut 0.2s ease forwards;
  pointer-events: none;
}

.delete-confirm-overlay.closing .delete-confirm-modal {
  animation: spCardOut 0.2s cubic-bezier(0.4, 0, 1, 1) forwards;
}

.confirm-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 36px 32px 28px;
  text-align: center;
  box-shadow: var(--shadow-xl);
  max-width: 340px;
  width: 90%;
  animation: spCardIn 0.3s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}

.confirm-card .material-symbols-rounded {
  font-size: 40px;
  color: var(--warning);
  margin-bottom: 12px;
}

.confirm-msg {
  font-size: 15px;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.6;
  margin: 0 0 24px;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-actions > button {
  flex: 1 1 0;
  min-width: 0;
  padding: 11px 0;
  font-size: 14px;
}

.btn-danger-filled {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-danger-filled:hover {
  background: #dc2626;
}

/* ============================================================
   슬롯 탭 (로그인 시 업로드 카드 상단 표시)
   ============================================================ */
.slot-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 16px;
  padding: 6px;
  background: var(--border-light);
  border-radius: var(--radius-md);
}

.slot-tab {
  flex: 1 1 0; /* 3개 균등 배분 */
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 6px;
  border: none;
  border-radius: calc(var(--radius-md) - 2px);
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition-fast);
  font-family: inherit;
  white-space: nowrap;
}

.slot-tab:hover:not(.active):not(.locked) {
  background: var(--surface);
  color: var(--text-main);
}

.slot-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

/* 잠금 슬롯 (클릭 시 유료 플랜 안내) */
.slot-tab.locked {
  opacity: 0.5;
  cursor: pointer;
}

.slot-tab.locked:hover {
  opacity: 0.75;
  background: var(--surface);
}

.slot-lock-icon {
  font-size: 13px;
  flex-shrink: 0;
}

.slot-tab-label {
  font-size: 12px;
}

.slot-count {
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  padding: 1px 6px;
  font-size: 10px;
  font-weight: 700;
  min-width: 18px;
  text-align: center;
}

.slot-tab.active .slot-count {
  background: var(--primary);
  color: #fff;
}

/* ============================================================
   수동 작성 / AI 검토 공용 편집 모달
   ============================================================ */
.modal-surface-large {
  width: min(952px, 96vw);
  max-width: min(952px, 96vw);
  /* 고정 높이: 행 추가해도 팝업 크기 변하지 않음 */
  height: min(88vh, 720px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.manual-edit-body {
  flex: 1;
  min-height: 0;          /* flex overflow 정상 작동을 위해 필수 */
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 28px 10px;  /* modal-body 패딩 완전 재정의 */
}

.manual-edit-guide {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--border-light);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 7px 12px;
  margin: 0;
  line-height: 1.5;
  flex-shrink: 0;
}

/* 헤더 행: 발음 컬럼 제거 — 약어(160px, EN placeholder "Abbreviation (optional)" 전체 노출 기준) / 영어(2.2fr) / 뜻(1.8fr) / 삭제(44px) */
.manual-edit-header-row {
  display: grid;
  grid-template-columns: 160px 2.2fr 1.8fr 44px;
  gap: 6px;
  padding: 6px 8px;
  background: var(--border-light);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

/* 스크롤 영역: flex:1로 남은 공간 전부 차지, 내용이 넘칠 때만 스크롤 */
.manual-edit-rows {
  flex: 1;
  min-height: 0;          /* 필수: flex 자식이 overflow 처리하도록 */
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-right: 4px;
}

/* 개별 입력 행: 헤더와 동일한 그리드 */
.manual-edit-row {
  display: grid;
  grid-template-columns: 160px 2.2fr 1.8fr 44px;
  gap: 6px;
  align-items: center;
  padding: 4px 2px;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  flex-shrink: 0;  /* 행이 압축되지 않도록 */
}

.manual-edit-row:hover {
  background: var(--border-light);
}

/* 입력 필드 */
.mer-input {
  width: 100%;
  padding: 7px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-main);
  background: var(--surface);
  transition: border-color var(--transition-fast);
  outline: none;
}

.mer-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}

/* ── 자가검토: 확인이 필요한 행 표시 (메타인지 경고) ───────────────── */
.manual-edit-row.needs-review {
  background: rgba(245, 158, 11, 0.045);
}
.manual-edit-row.needs-review .mer-input[data-field="meaning"],
.manual-edit-row.needs-review .mer-cell-meaning .mer-input {
  border-color: rgba(245, 158, 11, 0.55);
}
.mer-cell {
  position: relative;
  display: flex;
  align-items: center;
}
.mer-warn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--warning);
  font-size: 18px;
  cursor: help;
  pointer-events: auto;
  line-height: 1;
}
.mer-warn .material-symbols-rounded { font-size: 18px; }
.mer-warn:focus-visible {
  outline: 2px solid var(--warning);
  outline-offset: 2px;
  border-radius: 4px;
}

/* 경고 아이콘 호버/포커스 안내 툴팁 (fixed: 모달 스크롤 영역에서도 잘리지 않음) */
.mer-warn-tip {
  position: fixed;
  z-index: 4000;
  max-width: 260px;
  padding: 9px 12px;
  background: #1f2937;
  color: #fff;
  font-size: 12px;
  line-height: 1.55;
  border-radius: 9px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.22);
  white-space: pre-line;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.13s ease, transform 0.13s ease;
}
.mer-warn-tip.show {
  opacity: 1;
  transform: translateY(0);
}

/* 발음 표시 칸 */
.mer-pron-cell {
  display: flex;
  align-items: center;
  gap: 4px;
}

.mer-pron-display {
  font-size: 12px;
  color: var(--text-muted);
  background: var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  min-height: 32px;
  width: 100%;
  display: flex;
  align-items: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mer-pron-display.loading {
  color: var(--secondary);
  font-style: italic;
}

/* 삭제 버튼 */
.mer-delete-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
  flex-shrink: 0;
}

.mer-delete-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.mer-delete-btn .material-symbols-rounded {
  font-size: 18px;
}

/* 행 추가 버튼 */
.manual-add-row-btn {
  align-self: flex-start;
  margin-top: 2px;
}

/* 모달 푸터 */
.manual-edit-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.manual-edit-count-info {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.manual-edit-footer-actions {
  display: flex;
  gap: 10px;
}

/* 모바일 대응 */
@media (max-width: 600px) {
  .manual-edit-header-row,
  .manual-edit-row {
    grid-template-columns: 70px 1.8fr 1.5fr 40px;
  }
  .modal-surface-large {
    width: 100vw;
    height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    margin-top: auto;
  }
}

/* manual-edit-modal의 modal-body 패딩 재정의 (modal-body 기본 패딩 무시) */
#manual-edit-modal .modal-body {
  padding: 0;
  overflow: hidden;
}


/* ==================================================================
   ★ RESPONSIVE OVERHAUL — 모바일 / 태블릿 완성
   ================================================================== */

/* ── 바텀 시트 슬라이드업 애니메이션 ── */
@keyframes slideUpSheet {
  from { transform: translateY(48px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── dvh 지원: 모바일 주소창·키보드 등장 시 레이아웃 안정화 ── */
@supports (height: 100dvh) {
  .site-main     { min-height: calc(100dvh - var(--header-height)); }
  #result-screen { min-height: calc(100dvh - var(--header-height)); }
  .modal-surface { max-height: 90dvh; }
  .modal-surface.modal-surface-large { max-height: 92dvh; height: 92dvh; }
}

/* ================================================================
   터치 디바이스 공통 최적화  (hover 없는 기기)
   ================================================================ */
@media (hover: none) and (pointer: coarse) {
  /* hover 효과 제거 — 고스트 하이라이트 방지 */
  .stat-card:hover          { box-shadow: var(--shadow-sm); }
  .history-record-btn:hover { box-shadow: none; }
  .term-tts-btn:hover,
  .term-edit-btn:hover,
  .term-delete-btn:hover    { background: none; color: var(--text-muted); }
  .dropzone:hover           { border-color: var(--border); background: var(--surface); }
  .dropzone:hover .drop-icon { color: var(--secondary); }
  .btn-primary:hover        { background: var(--primary); box-shadow: 0 4px 12px rgba(79,70,229,.2); }
  .btn-tonal:hover          { background: var(--primary-light); }
  .btn-tonal-sm:hover:not(:disabled) { background: var(--primary-light); }

  /* active 터치 피드백 */
  .btn-hero:active,
  .btn-hero-danger:active,
  .btn-hero-secondary:active,
  .btn-primary:active,
  .btn-tonal:active         { transform: scale(0.97); transition: transform 0.08s; }
  .mc-btn:active:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary);
    transform: scale(0.98);
  }
  .history-record-btn:active { background: var(--primary-light); }
  .btn-tonal-sm:active:not(:disabled) { transform: scale(0.97); }

  /* WCAG 2.5.8 — 최소 터치 타겟 44×44 */
  .term-tts-btn,
  .term-edit-btn,
  .term-delete-btn  { min-width: 40px; min-height: 40px; }
  .back-btn         { width: 42px; height: 42px; }
  .btn-tonal-sm     { min-height: 40px; }
  .volume-btn       { min-width: 40px; min-height: 40px; }
  .icon-btn-small   { width: 36px; height: 36px; }

  /* 슬롯 탭 터치 타겟 */
  .slot-tab         { min-height: 40px; }

  /* 체크박스 확대 */
  .auth-check input[type="checkbox"] { width: 18px; height: 18px; }
}

/* ================================================================
   태블릿 전용  (769px – 1100px)
   ================================================================ */
@media (min-width: 769px) and (max-width: 1100px) {
  :root {
    --container-pad: 20px;
    --container-max: 880px;
  }

  /* 통계 그리드: 2열 */
  .stats-grid           { grid-template-columns: 1fr 1fr; }
  .stat-card.stat-chart { grid-column: 1 / -1; }
  .stat-card.stat-chart .chart-body { max-height: 100px; }

  /* 오답 기록: 좌측 패널 축소 */
  .history-layout    { grid-template-columns: 300px 1fr; }
  .history-list-panel { max-height: calc(100vh - 200px); }

  /* 단어 목록 */
  .term-row,
  .term-row-header   { grid-template-columns: 75px 1.5fr 1fr 0.9fr 100px; }

  /* 모달: 중앙 유지, 너비만 넓게 */
  .modal-surface     { max-width: 600px; }
  .modal-surface.auth-surface-wide { max-width: 660px; }
}

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

  /* iOS 모멘텀 스크롤 */
  body { -webkit-overflow-scrolling: touch; }

  /* 하단 안전 영역 여백 (홈 인디케이터) */
  .site-main {
    padding-top: 24px;
    padding-bottom: max(40px, env(safe-area-inset-bottom));
  }

  /* ── 헤더 ─────────────────────────────────────────── */
  .site-header-inner   { padding: 0 14px; gap: 8px; }
  .header-brand h1     { font-size: 14.5px; }
  .header-brand .brand-icon { font-size: 22px; }
  .header-actions      { gap: 6px; }

  /* 로그인 버튼: 텍스트 숨기고 아이콘만 */
  .btn-auth-trigger    { padding: 6px 10px; height: 36px; font-size: 13px; }
  .btn-auth-trigger span:last-of-type { display: none; }

  /* 유저 메뉴 */
  .user-menu-btn       { padding: 3px 8px 3px 3px; height: 36px; }
  .user-avatar         { width: 28px; height: 28px; font-size: 13px; }
  .user-name           { max-width: 70px; font-size: 12.5px; }
  .user-dropdown       { right: 0; min-width: 220px; max-width: min(280px, 92vw); }

  /* ── 통계 카드 ───────────────────────────────────── */
  .stats-grid           { grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
  .stat-card            { padding: 16px; gap: 12px; }
  .stat-card.stat-chart { grid-column: 1 / -1; padding: 16px 20px; }
  .stat-card.stat-chart .chart-body { max-height: 90px; }
  .stat-value           { font-size: 22px; }

  /* ── 업로드 카드 ─────────────────────────────────── */
  .upload-card { padding: 18px 20px; border-radius: var(--radius-lg); }
  .dropzone    { padding: 26px 16px; border-radius: var(--radius-md); }
  .drop-icon   { font-size: 36px; margin-bottom: 8px; }
  .drop-title  { font-size: 14px; }
  .upload-actions       { gap: 8px; }
  .upload-actions > button { font-size: 13.5px; padding: 10px 12px; }

  /* 슬롯 탭: 가로 스크롤 */
  #slot-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }
  #slot-tabs::-webkit-scrollbar { display: none; }

  /* ── 시험 설정 ───────────────────────────────────── */
  .quiz-setup-panel  { padding: 18px 20px; border-radius: var(--radius-lg); }
  .settings-grid     { grid-template-columns: 1fr; gap: 12px; margin-bottom: 18px; }
  .btn-hero,
  .btn-hero-danger,
  .btn-hero-secondary { padding: 15px 18px; font-size: 15px; border-radius: var(--radius-md); }

  /* ── 저장된 단어 ─────────────────────────────────── */
  .terms-section      { padding: 18px 20px; border-radius: var(--radius-lg); }
  .terms-search-bar   { gap: 8px; flex-wrap: wrap; }
  .search-input-wrap  { max-width: 100%; flex: 1 1 100%; }
  .term-row,
  .term-row-header    { grid-template-columns: 65px 1.5fr 1fr 72px; gap: 8px; padding: 12px 14px; }
  .term-col-pron,
  .term-row-header .col-pron { display: none; }
  .term-col-term      { font-size: 14px; }
  .term-col-meaning   { font-size: 13px; }
  .term-tts-btn,
  .term-edit-btn,
  .term-delete-btn    { padding: 7px; min-width: 36px; min-height: 36px; }

  /* ── 퀴즈 화면 ───────────────────────────────────── */
  .quiz-wrapper        { gap: 16px; }
  .quiz-status-bar     { padding: 12px 18px; }
  .timer               { font-size: 20px; }
  .question-container  { padding: 32px 20px; min-height: 160px; border-radius: var(--radius-lg); }
  .question-title      { font-size: 22px; }
  #answer-input        { font-size: 20px; padding: 16px; }
  .btn-large           { padding: 15px 24px; font-size: 15px; min-height: 52px; }
  .mc-btn              { padding: 15px 16px; font-size: 14px; min-height: 52px; }
  .feedback-card       { padding: 18px 20px; border-radius: var(--radius-lg); }

  /* ── 결과 화면 ───────────────────────────────────── */
  #result-screen       { min-height: auto; padding: 32px 16px; align-items: flex-start; }
  .result-wrapper      { width: 100%; }
  .result-container    { padding: 32px 20px 24px; border-radius: var(--radius-lg); }
  .score-circle        { width: 150px; height: 150px; }
  .score-circle::before { width: 115px; height: 115px; }
  .score-text          { font-size: 30px; }
  .result-msg          { font-size: 20px; margin-bottom: 16px; }
  .result-stats        { flex-wrap: wrap; justify-content: center; gap: 10px; margin-bottom: 24px; }
  .result-actions      { max-width: 100%; }

  /* ── 오답 기록 ───────────────────────────────────── */
  .page-header         { margin-bottom: 16px; }
  .page-header h2      { font-size: 19px; }
  .history-layout      { grid-template-columns: 1fr; gap: 16px; }
  .history-list-panel  { max-height: 260px; }
  .history-detail-body { max-height: none; }

  /* 오답 기록 → 리스트 클릭 시 상세 패널이 바로 보이도록 앵커 스크롤 힌트 */
  .history-detail-panel {
    scroll-margin-top: calc(var(--header-height) + 12px);
  }

  /* ── 누적 오답 ───────────────────────────────────── */
  .accumulated-wrapper { max-width: 100%; }
  .bottom-actions      { flex-direction: column; gap: 10px; }
  .bottom-actions > button { width: 100%; justify-content: center; }

  /* ── 모달 → 바텀 시트 변환 ──────────────────────── */
  .modal-overlay        { align-items: flex-end; }
  .modal-surface {
    width: 100%;
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    animation: slideUpSheet 0.32s cubic-bezier(0.32, 0.72, 0, 1) both;
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  /* 드래그 핸들 표시 */
  .modal-header {
    padding: 20px 20px 16px;
    position: relative;
  }
  .modal-header::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
  }

  /* 이미지 뷰어는 중앙 유지 */
  #image-viewer-modal   { align-items: center; }
  #image-viewer-modal .viewer-surface {
    border-radius: var(--radius-lg);
    width: 95vw;
    max-height: 90vh;
  }

  .modal-surface.auth-surface      { max-height: 94vh; }
  .modal-surface.auth-surface-wide { max-height: 96vh; }
  .modal-surface.modal-surface-large {
    height: 92vh;
    max-height: 92vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }

  .modal-body          { -webkit-overflow-scrolling: touch; }
  .modal-body.auth-body { padding: 16px 18px; }
  .modal-footer        { padding-bottom: max(16px, env(safe-area-inset-bottom)); }
  .modal-footer.auth-footer {
    padding: 12px 18px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .social-login-section {
    padding: 0 18px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .auth-side-btn { padding: 0 10px; font-size: 12.5px; white-space: nowrap; flex-shrink: 0; }

  /* ── 토스트 ──────────────────────────────────────── */
  #toast-container {
    bottom: max(24px, env(safe-area-inset-bottom));
    width: 92%;
    left: 4%;
    transform: none;
  }
  .toast { min-width: 0; width: 100%; padding: 12px 16px; font-size: 13.5px; }
}

/* ================================================================
   소형 모바일  (≤ 480px)
   ================================================================ */
@media (max-width: 480px) {
  :root { --container-pad: 14px; }

  /* 헤더: 타이틀 숨기고 아이콘만 */
  .header-brand h1   { display: none; }
  .site-header-inner { padding: 0 14px; }

  /* 통계: 1열 세로 스택 */
  .stats-grid { grid-template-columns: 1fr; gap: 10px; }

  /* 업로드 카드 */
  .dropzone  { padding: 22px 12px; }
  .drop-desc { display: none; }
  .upload-actions > button { font-size: 13px; padding: 9px 10px; }

  /* 시험 설정 */
  .quiz-setup-panel { padding: 16px; }
  .btn-hero,
  .btn-hero-danger,
  .btn-hero-secondary { padding: 14px; font-size: 14.5px; }

  /* 저장된 단어 */
  .terms-section { padding: 16px 14px; }
  .terms-section-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .terms-section-actions { width: 100%; justify-content: flex-end; }
  .term-row,
  .term-row-header {
    grid-template-columns: 55px 1fr 1fr 64px;
    padding: 10px 12px;
    gap: 6px;
  }
  .term-col-abbr    { font-size: 11.5px; padding: 3px 5px; min-width: 32px; }
  .term-col-term    { font-size: 13px; }
  .term-col-meaning { font-size: 12.5px; }
  .term-tts-btn .material-symbols-rounded,
  .term-edit-btn .material-symbols-rounded,
  .term-delete-btn .material-symbols-rounded { font-size: 17px; }

  /* 퀴즈 */
  .quiz-status-bar { padding: 10px 14px; border-radius: var(--radius-md); }
  .timer           { font-size: 18px; }
  .question-container { padding: 26px 16px; min-height: 140px; }
  .question-title  { font-size: 20px; }
  #answer-input    { font-size: 18px; padding: 14px; }
  .mc-btn          { padding: 14px; font-size: 13.5px; min-height: 50px; }

  /* 결과 */
  .result-container  { padding: 28px 16px 20px; }
  .score-circle      { width: 130px; height: 130px; }
  .score-circle::before { width: 98px; height: 98px; }
  .score-text        { font-size: 26px; }
  .result-msg        { font-size: 18px; }
  .result-time-chip  { padding: 6px 16px 6px 6px; }

  /* 오답 기록 */
  .history-list-panel { max-height: 220px; }

  /* 수동 편집 모달 */
  .manual-edit-header-row,
  .manual-edit-row { grid-template-columns: 62px 1.6fr 1.4fr 38px; gap: 4px; }
}

/* ================================================================
   극소형 모바일  (≤ 360px)
   ================================================================ */
@media (max-width: 360px) {
  :root { --container-pad: 12px; --header-height: 52px; }

  .header-brand .brand-icon { font-size: 20px; }

  .term-row,
  .term-row-header { grid-template-columns: 48px 1fr 1fr 56px; padding: 9px 10px; gap: 4px; }

  .question-title { font-size: 18px; }
  #answer-input   { font-size: 16px; padding: 12px; }

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

  .quiz-setup-panel   { padding: 14px; }
  .upload-card        { padding: 14px; }
  .terms-section      { padding: 14px 12px; }
}

/* ============================================================
   언어 전환 버튼 (드롭다운)
   ============================================================ */
.lang-dropdown-wrap {
  position: relative;
  flex-shrink: 0;
}

.btn-lang-toggle {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 6px;
  height: auto;
  border: none;
  background: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  border-radius: 6px;
  letter-spacing: 0.4px;
  cursor: pointer;
  transition: color var(--transition-fast);
  text-transform: uppercase;
}

.btn-lang-toggle:hover {
  color: var(--primary);
}

.lang-globe-icon {
  font-size: 14px;
}

.lang-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  overflow: hidden;
  z-index: 9999;
}

.lang-dropdown.open {
  display: block;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition-fast);
}

.lang-option:hover {
  background: var(--primary-light);
  color: var(--primary);
}

.lang-opt-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  border: 2px solid var(--border);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.lang-opt-dot.active {
  background: var(--primary);
  border-color: var(--primary);
}
