/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;900&family=Noto+Sans+TC:wght@400;500;700&display=swap');

:root {
  --bg: #F2EEE3;
  --bg-2: #E8E2D0;
  --bg-3: #DCD5BC;
  --border: #C9C2AC;
  --ink: #1A1A16;
  --text-1: #1A1A16;
  --text-2: #55523F;
  --text-3: #8A8570;
  --accent: #2857A6;
  --accent-hover: #1E4380;
  --accent-light: #DCE6F4;
  --brick: #C33D2E;
  --success: #22c55e;
  --success-light: #E4F3E9;
  --success-border: #22c55e;
  --error: #C33D2E;
  --error-light: #F5E1DD;
  --error-border: #C33D2E;
  --shadow: 2px 2px 0 var(--ink);
  --shadow-md: 3px 3px 0 var(--ink);
  --shadow-lg: 4px 4px 0 var(--ink);
  --radius: 6px;
  --radius-sm: 4px;
  --radius-lg: 8px;
  --radius-full: 9999px;
  --font-display: 'Archivo Black', 'Archivo', system-ui, sans-serif;
  --font-cjk: 'Noto Sans TC', var(--font);
  --font: 'Archivo', -apple-system, BlinkMacSystemFont, 'Noto Sans TC', 'Segoe UI', system-ui, sans-serif;
  --transition: 150ms ease;
  --nav-height: 64px;
  --max-w: 640px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17160F;
    --bg-2: #1E1C13;
    --bg-3: #262311;
    --border: #3A3826;
    --ink: #F2EEE3;
    --text-1: #F2EEE3;
    --text-2: #C9C2AC;
    --text-3: #8A8570;
    --accent: #5B87CC;
    --accent-hover: #7BA0DA;
    --accent-light: #23324A;
    --brick: #DB5B48;
    --error: #DB5B48;
    --error-light: #3A241F;
    --error-border: #DB5B48;
    --success-light: #16311F;
    --success-border: #22c55e;
  }
}

:root[data-theme="dark"] {
  --bg: #17160F;
  --bg-2: #1E1C13;
  --bg-3: #262311;
  --border: #3A3826;
  --ink: #F2EEE3;
  --text-1: #F2EEE3;
  --text-2: #C9C2AC;
  --text-3: #8A8570;
  --accent: #5B87CC;
  --accent-hover: #7BA0DA;
  --accent-light: #23324A;
  --brick: #DB5B48;
  --error: #DB5B48;
  --error-light: #3A241F;
  --error-border: #DB5B48;
  --success-light: #16311F;
  --success-border: #22c55e;
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body.no-nav { padding-bottom: 0; }

/* === Layout === */
.container { max-width: var(--max-w); margin: 0 auto; padding: 0 20px; }
.page { padding: 24px 0; }

/* === Typography === */
h1 { font-family: var(--font-display); font-size: 1.75rem; font-weight: 700; line-height: 1.25; }
h2 { font-size: 1.375rem; font-weight: 600; line-height: 1.3; }
h3 { font-size: 1.125rem; font-weight: 600; }
p { line-height: 1.7; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  border: 2px solid var(--ink);
  cursor: pointer;
  transition: all var(--transition);
  min-height: 48px;
  text-decoration: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn-primary { background: var(--accent); color: #fff; width: 100%; border-color: var(--ink); box-shadow: var(--shadow-lg); }
.btn-primary:hover, .btn-primary:active { background: var(--accent-hover); transform: translate(-1px,-1px); box-shadow: 5px 5px 0 var(--ink); }
.btn-primary:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ink); }

.btn-secondary {
  background: var(--bg-2);
  color: var(--text-1);
  border: 1.5px solid var(--border);
  width: 100%;
}
.btn-secondary:hover, .btn-secondary:active { background: var(--bg-3); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  padding: 8px 16px;
  min-height: 40px;
  width: auto;
}
.btn-ghost:hover { background: var(--bg-2); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* === Progress Bar (fixed top, quiz pages) === */
.progress-bar-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  background: var(--bg);
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.progress-bar-back {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  padding: 4px;
  min-width: 32px;
  -webkit-tap-highlight-color: transparent;
}

.progress-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-3);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  transition: width 0.5s cubic-bezier(.4,0,.2,1);
}

.progress-count {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  min-width: 36px;
  text-align: right;
}

.quiz-page { padding-top: 80px; }

/* === Question Card === */
.question-card { padding: 24px 0; }

.question-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  margin-bottom: 12px;
}

.question-instruction {
  font-size: 0.9375rem;
  color: var(--text-2);
  margin-bottom: 16px;
  line-height: 1.5;
}

.question-instruction strong { color: var(--text-1); }

.question-passage {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--text-1);
  margin-bottom: 16px;
  padding: 16px;
  background: var(--bg-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.phrase-passage u {
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
  font-weight: 600;
  color: var(--accent);
}

.question-text {
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--text-1);
  margin-bottom: 20px;
  line-height: 1.6;
}

/* === Options === */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 24px;
}

.option-btn {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--text-1);
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  min-height: 52px;
  width: 100%;
  line-height: 1.5;
}

.option-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--accent-light); }
.option-btn.selected { border-color: var(--accent); background: var(--accent-light); }
.option-btn.pending { border-color: var(--accent); background: var(--accent-light); transform: scale(1.01); }
.option-btn.correct { border-color: var(--success); background: var(--success-light); }
.option-btn.wrong { border-color: var(--error); background: var(--error-light); }
.option-btn:disabled { cursor: default; }
.option-btn:disabled .word-clickable { pointer-events: auto; cursor: pointer; }

/* === Confirm Bar === */
.confirm-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--accent-light);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.confirm-bar.show { display: flex; }
.confirm-hint { font-size: 0.8125rem; color: var(--text-2); }
.confirm-btn {
  padding: 6px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  white-space: nowrap;
}

.option-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  font-size: 0.75rem;
  font-weight: 700;
  background: var(--bg-3);
  color: var(--text-2);
  margin-top: 1px;
  transition: all var(--transition);
}

.option-btn.selected:not(.correct):not(.wrong) .option-label { background: var(--accent); color: #fff; }
.option-btn.pending .option-label { background: var(--accent); color: #fff; }
.option-btn.correct .option-label { background: var(--success); color: #fff; }
.option-btn.wrong .option-label { background: var(--error); color: #fff; }
.option-text { flex: 1; }

/* === Audio Button === */
.audio-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-1);
  width: 100%;
  margin-bottom: 20px;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.audio-btn:hover { border-color: var(--accent); background: var(--accent-light); }

.audio-btn.playing {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.audio-btn svg { width: 22px; height: 22px; flex-shrink: 0; }
.audio-ripple { width: 8px; height: 8px; background: var(--accent); border-radius: 50%; margin-left: auto; animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity:1; transform:scale(1); } 50% { opacity:.5; transform:scale(1.4); } }

/* === Skip Button（聽力/口說不方便作答時跳過） === */
.skip-row { text-align: right; margin: -12px 0 16px; }
.skip-btn {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 0.8125rem;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
  font-family: var(--font);
}
.skip-btn:hover { color: var(--accent); }

/* === Feedback Panel === */
.feedback-panel {
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  display: none;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

.feedback-panel.show { display: block; }
.feedback-panel.correct { background: var(--success-light); border: 1.5px solid var(--success-border); }
.feedback-panel.wrong { background: var(--error-light); border: 1.5px solid var(--error-border); }

.feedback-header { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.feedback-icon { font-size: 1.25rem; }
.feedback-result { font-size: 1rem; font-weight: 700; }
.feedback-panel.correct .feedback-result { color: var(--success); }
.feedback-panel.wrong .feedback-result { color: var(--brick); }

.feedback-body { font-size: 0.875rem; color: var(--text-1); line-height: 1.75; }
.feedback-body strong { font-weight: 600; }
.feedback-loading { color: var(--text-2); font-style: italic; }
.feedback-audio-script { background: var(--bg-3); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 10px; font-size: 0.875rem; color: var(--text-2); line-height: 1.6; }

/* === Word Tooltip === */
.word-clickable {
  cursor: pointer;
  border-bottom: 1.5px dashed var(--text-3);
  transition: border-color var(--transition);
  display: inline;
}
.word-clickable:hover { border-color: var(--accent); }
.word-clickable.in-vocab { border-bottom: 2px solid var(--accent); }

.tooltip-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15,23,42,.4);
  display: flex;
  align-items: flex-end;
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }

.tooltip-sheet {
  background: var(--bg);
  border-radius: var(--radius-lg) var(--radius-lg) var(--radius-sm) var(--radius-sm);
  padding: 24px 20px 20px;
  width: 100%;
  max-width: var(--max-w);
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
  animation: sheetUp 0.25s cubic-bezier(.4,0,.2,1);
}
@keyframes sheetUp { from { transform:translateY(20px); opacity:0; } to { transform:translateY(0); opacity:1; } }

.tooltip-drag-handle { width: 36px; height: 4px; background: var(--border); border-radius: 2px; margin: -8px auto 20px; }

.tooltip-word-row { display: flex; align-items: center; gap: 10px; margin-bottom: 2px; }
.tooltip-word { font-size: 1.5rem; font-weight: 700; color: var(--text-1); }
.tooltip-example-row { display: flex; align-items: flex-start; gap: 8px; }
.tooltip-example-row .tooltip-example { flex: 1; }

.tooltip-speak-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  background: var(--bg-3);
  border-radius: var(--radius-full);
  color: var(--accent);
  cursor: pointer;
  transition: background var(--transition);
}
.tooltip-speak-btn:hover { background: var(--accent-light); }

.tooltip-pos { font-size: 0.8125rem; color: var(--text-3); margin-top: 2px; margin-bottom: 10px; }
.tooltip-meaning { font-size: 1rem; color: var(--text-1); margin-bottom: 10px; }
.tooltip-example { font-size: 0.875rem; color: var(--text-2); font-style: italic; margin-bottom: 3px; }
.tooltip-translation { font-size: 0.8125rem; color: var(--text-3); margin-bottom: 18px; }
.tooltip-loading { font-size: 0.875rem; color: var(--text-2); padding: 12px 0 18px; display: flex; align-items: center; gap: 10px; }

.tooltip-actions { display: flex; gap: 10px; }
.tooltip-actions .btn { flex: 1; font-size: 0.875rem; padding: 10px 12px; min-height: 44px; }
.tooltip-goto-phrases { display: block; text-align: center; margin-top: 10px; font-size: 0.8125rem; color: var(--accent); text-decoration: none; }
.retry-lookup-btn { background: none; border: 1px solid var(--accent); color: var(--accent); border-radius: var(--radius-sm); padding: 2px 10px; font-size: 0.8125rem; cursor: pointer; margin-left: 6px; }

/* === Bottom Navigation === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  padding-top: 8px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  z-index: 100;
  height: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px));
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-decoration: none;
  color: var(--text-3);
  transition: color var(--transition);
  padding: 4px 8px;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active { color: var(--accent); }
.nav-item svg { width: 24px; height: 24px; }
.nav-label { font-size: 0.6875rem; font-weight: 600; }

/* === Home Page === */
.home-masthead { background: var(--ink); padding: 22px 0 18px; margin-bottom: 16px; }
.home-masthead .greeting { font-size: 0.875rem; color: var(--border); margin-bottom: 4px; }
.home-masthead .user-name { font-family: var(--font-display); font-size: 1.375rem; color: var(--bg); }
.greeting { font-size: 0.9375rem; color: var(--text-2); margin-bottom: 4px; }
.user-name { font-size: 1.625rem; font-weight: 700; }

.streak-card {
  position: relative;
  overflow: hidden;
  background: var(--accent);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  padding: 20px 24px;
  color: white;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.streak-card::after {
  content: '';
  position: absolute;
  top: -26px;
  right: -26px;
  width: 76px;
  height: 76px;
  background: var(--brick);
  transform: rotate(45deg);
}

.streak-info {}
.streak-number { font-family: var(--font-display); font-size: 2.75rem; font-weight: 800; line-height: 1; }
.streak-label { font-size: 0.875rem; opacity: 0.85; margin-top: 2px; }
.streak-icon {
  position: relative;
  z-index: 1;
  font-size: 1.75rem;
  width: 54px;
  height: 54px;
  background: var(--brick);
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-block {
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  margin-bottom: 16px;
  overflow: hidden;
  background: var(--bg-2);
}

.stat-block-head {
  font-family: var(--font-display);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #fff;
  padding: 9px 16px;
}
.stat-block-head.blue { background: var(--accent); }
.stat-block-head.brick { background: var(--brick); }
.stat-block-body { padding: 18px 16px; }

.today-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
}

.card-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-3);
  margin-bottom: 12px;
}

.today-progress-bar {
  height: 8px;
  background: var(--bg-3);
  border: 1px solid var(--ink);
  border-radius: var(--radius-full);
  overflow: hidden;
  margin-bottom: 8px;
}

.today-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.8s cubic-bezier(.4,0,.2,1);
}

.today-stats { display: flex; justify-content: space-between; font-size: 0.8125rem; color: var(--text-2); }
.today-stats strong { color: var(--text-1); }

.quick-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 18px 8px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-family: var(--font);
  font-weight: 700;
  font-size: 0.9375rem;
  color: #fff;
  text-decoration: none;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.quick-link .quick-link-icon { font-size: 1.5rem; }
.quick-link-blue { background: var(--accent); }
.quick-link-brick { background: var(--brick); }
.quick-link:hover { transform: translate(-1px,-1px); box-shadow: 5px 5px 0 var(--ink); }
.quick-link:active { transform: translate(2px,2px); box-shadow: 2px 2px 0 var(--ink); }

.weekly-row {
  display: flex;
  gap: 8px;
}

.week-day {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  font-size: 0.6875rem;
  color: var(--text-3);
}

.week-day-dot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-3);
}

.week-day-dot.done { background: var(--accent); color: #fff; }
.week-day-dot.today { background: var(--brick); color: #fff; }

.milestone-banner {
  background: var(--brick);
  border: 2px solid var(--ink);
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius);
  padding: 14px 18px;
  color: white;
  font-size: 0.9375rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* === Login Page === */
.login-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 40px 24px;
  text-align: center;
  padding-bottom: 40px !important;
}

.login-logo { font-size: 3.5rem; margin-bottom: 24px; }
.login-mark { width: 64px; height: 64px; border-radius: var(--radius-sm); margin-bottom: 20px; box-shadow: var(--shadow-md); }
.login-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; margin-bottom: 6px; letter-spacing: 0.02em; }
.title-accent-dot { display: inline-block; width: 10px; height: 10px; background: var(--brick); margin-left: 6px; vertical-align: middle; }
.login-tagline { font-size: 0.8125rem; font-weight: 600; letter-spacing: 0.08em; color: var(--accent); text-transform: uppercase; margin-bottom: 20px; }
.login-subtitle { font-size: 1rem; color: var(--text-2); margin-bottom: 48px; line-height: 1.65; max-width: 280px; }

.google-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 14px 28px;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius-full);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-1);
  cursor: pointer;
  width: 100%;
  max-width: 320px;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
  box-shadow: var(--shadow);
}

.google-btn:hover { border-color: var(--accent); background: var(--accent-light); box-shadow: var(--shadow-md); }

.google-icon { width: 22px; height: 22px; flex-shrink: 0; }

.guest-btn {
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--text-3);
  font-family: var(--font);
  font-size: 0.9375rem;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.guest-btn:hover { color: var(--text-1); }
.guest-note { margin-top: 8px; font-size: 0.75rem; color: var(--text-3); max-width: 280px; }

.guest-banner {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text-2);
  font-size: 0.8125rem;
  line-height: 1.5;
  margin-bottom: 16px;
}
.guest-banner a { color: var(--accent); font-weight: 600; text-decoration: underline; }

/* === Loading === */
.loading-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
  text-align: center;
  padding: 24px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-3);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-text { font-size: 0.9375rem; color: var(--text-2); }
.loading-sub { font-size: 0.8125rem; color: var(--text-3); }

/* === Placement Test === */
.placement-intro {
  padding: 40px 0 32px;
  text-align: center;
}

.placement-icon { font-size: 3rem; margin-bottom: 16px; }
.placement-title { font-family: var(--font-display); font-size: 1.625rem; font-weight: 800; margin-bottom: 8px; }
.placement-desc { font-size: 0.9375rem; color: var(--text-2); margin-bottom: 32px; line-height: 1.7; }

.info-list { list-style: none; text-align: left; margin-bottom: 32px; display: flex; flex-direction: column; gap: 10px; }
.info-list li { display: flex; align-items: flex-start; gap: 10px; font-size: 0.9375rem; color: var(--text-2); }
.info-dot { width: 6px; height: 6px; background: var(--accent); border-radius: 50%; margin-top: 8px; flex-shrink: 0; }

.result-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 64px 0;
}

.result-level-display {
  font-family: var(--font-display);
  font-size: 5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
  margin-bottom: 8px;
}

.result-label { font-size: 1.125rem; font-weight: 600; margin-bottom: 6px; }
.result-desc { font-size: 0.9375rem; color: var(--text-2); margin-bottom: 32px; }
.result-countdown { font-size: 0.875rem; color: var(--text-3); }

/* === Session Completion === */
.completion-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 56px 24px;
}

.completion-icon { font-size: 4rem; margin-bottom: 16px; }
.completion-title { font-family: var(--font-display); font-size: 1.75rem; font-weight: 800; margin-bottom: 8px; }
.completion-sub { font-size: 1rem; color: var(--text-2); margin-bottom: 36px; line-height: 1.6; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  margin-bottom: 36px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 8px;
  text-align: center;
}

.stat-value { font-family: var(--font-display); font-size: 1.875rem; font-weight: 800; color: var(--accent); line-height: 1; }
.stat-label { font-size: 0.6875rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 6px; }

/* === Vocabulary Page === */
.vocab-header { padding: 24px 0 16px; }
.vocab-count { font-size: 0.875rem; color: var(--text-2); margin-top: 4px; }

.vocab-empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-2);
}

.vocab-empty-icon { font-size: 3rem; margin-bottom: 12px; }
.vocab-empty-text { font-size: 0.9375rem; line-height: 1.6; }

.vocab-list { list-style: none; }

.vocab-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.vocab-item:last-child { border-bottom: none; }
.vocab-word-group { flex: 1; min-width: 0; }
.vocab-word { font-size: 1rem; font-weight: 600; }
.vocab-pos { font-size: 0.75rem; color: var(--text-3); }
.vocab-meaning { font-size: 0.875rem; color: var(--text-2); margin-top: 2px; }

.vocab-badge {
  font-size: 0.6875rem;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-weight: 600;
  flex-shrink: 0;
}

.vocab-badge.active { background: var(--accent-light); color: var(--accent); }
.vocab-badge.known { background: var(--success-light); color: var(--success); }

/* === Progress Page === */
.progress-header { padding: 24px 0 20px; }

.level-cards { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }

.level-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.level-card-icon { font-size: 1.75rem; }
.level-card-body { flex: 1; }
.level-card-name { font-size: 0.9375rem; font-weight: 600; margin-bottom: 2px; }
.level-card-meta { font-size: 0.8125rem; color: var(--text-2); }

.level-badge {
  background: var(--accent-light);
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 800;
  padding: 6px 14px;
  border-radius: var(--radius-full);
}

.accuracy-bar-label { display: flex; justify-content: space-between; font-size: 0.8125rem; color: var(--text-2); margin-bottom: 6px; }
.accuracy-bar-track { height: 6px; background: var(--bg-3); border-radius: var(--radius-full); overflow: hidden; }
.accuracy-bar-fill { height: 100%; border-radius: var(--radius-full); background: var(--accent); transition: width 1s ease; }

/* === Toast === */
.toast {
  position: fixed;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--text-1);
  color: var(--bg);
  padding: 10px 20px;
  border-radius: var(--radius-full);
  font-size: 0.875rem;
  font-weight: 500;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 400;
  white-space: nowrap;
  pointer-events: none;
}

.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* === Start Screen === */
.start-screen { padding: 48px 0; text-align: center; }
.start-icon { font-size: 3.5rem; margin-bottom: 20px; }
.start-title { font-family: var(--font-display); font-size: 1.5rem; font-weight: 800; margin-bottom: 8px; }
.start-meta { font-size: 0.9375rem; color: var(--text-2); margin-bottom: 32px; line-height: 1.6; }

.skill-pills { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 32px; }
.skill-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: var(--radius-full);
  font-size: 0.8125rem;
  font-weight: 600;
}

/* === Utility === */
.hidden { display: none !important; }
.text-center { text-align: center; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.section-gap { margin-bottom: 28px; }

/* === Speaking Question === */
.speaking-prompt {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.speaking-zh { font-size: 1rem; color: var(--text-1); font-weight: 500; margin-bottom: 6px; }
.speaking-en { font-size: 0.875rem; color: var(--text-2); font-style: italic; }

.speaking-controls { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 20px 0; }

.speak-mic-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.speak-mic-btn:hover { background: var(--accent-hover); }
.speak-mic-btn.recording {
  background: var(--error);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.05); } }

.speak-status { font-size: 0.875rem; color: var(--text-3); text-align: center; }
.speak-transcript {
  background: var(--bg-3);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9375rem;
  color: var(--text-1);
  font-style: italic;
  margin-bottom: 8px;
}
.speak-score { font-size: 1.25rem; letter-spacing: 2px; color: #f59e0b; }
.speak-scores { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; font-size: 0.8125rem; color: var(--text-2); }
.speak-scores span { background: var(--bg-3); padding: 4px 10px; border-radius: var(--radius-full); }
.inline-speak-btn {
  background: none; border: none; cursor: pointer; color: var(--accent);
  font-size: 0.9rem; padding: 0 4px; vertical-align: middle;
}

/* === Ask Tutor === */
.ask-tutor-section {
  margin-top: 14px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.ask-tutor-toggle {
  background: none;
  border: 1.5px solid var(--accent);
  color: var(--accent);
  border-radius: var(--radius-full);
  padding: 7px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  -webkit-tap-highlight-color: transparent;
}
.ask-tutor-toggle:hover, .ask-tutor-toggle:active {
  background: var(--accent);
  color: #fff;
}

.ask-tutor-panel {
  margin-top: 10px;
}

.ask-tutor-messages {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.ask-msg {
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  line-height: 1.55;
  max-width: 90%;
}

.ask-msg-user {
  background: var(--accent);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

.ask-msg-ai {
  background: var(--bg-3);
  color: var(--text-1);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}

/* === Feedback FAB === */
.feedback-fab {
  position: fixed;
  right: 16px;
  bottom: calc(var(--nav-height) + env(safe-area-inset-bottom, 0px) + 14px);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: 1.5px solid var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 900;
  transition: transform 0.15s, box-shadow 0.15s;
}

.feedback-fab:hover { transform: scale(1.08); }
.feedback-fab:active { transform: scale(0.94); }

body.no-nav .feedback-fab { bottom: calc(env(safe-area-inset-bottom, 0px) + 20px); }

/* === Feedback Modal === */
.feedback-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.feedback-overlay.show { opacity: 1; }

.feedback-modal {
  background: var(--bg);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform 0.2s ease;
}
.feedback-overlay.show .feedback-modal { transform: translateY(0); }

.feedback-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.feedback-modal-header h3 { font-size: 1.0625rem; color: var(--text-1); margin: 0; }

.feedback-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-3);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.feedback-modal-close:hover { background: var(--bg-3); color: var(--text-1); }

.feedback-modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

.feedback-label {
  display: block;
  font-size: 0.875rem;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}

.feedback-textarea {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.9375rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  outline: none;
  resize: vertical;
  min-height: 100px;
  transition: border-color var(--transition);
}
.feedback-textarea:focus { border-color: var(--accent); }

.feedback-image-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.feedback-img-btn { padding: 8px 14px; font-size: 0.875rem; }
.feedback-img-name { font-size: 0.8125rem; color: var(--text-3); word-break: break-all; }

.feedback-img-preview {
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  background: var(--bg-2);
}
.feedback-img-preview img {
  max-width: 100%;
  max-height: 200px;
  display: block;
  border-radius: 6px;
}

.feedback-status {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}
.feedback-status.info { background: var(--accent-light); color: var(--accent); }
.feedback-status.success { background: var(--success-light); color: var(--success); }
.feedback-status.error { background: var(--error-light); color: var(--error); }

.feedback-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}
.feedback-modal-footer .btn { padding: 9px 18px; font-size: 0.9375rem; }

.ask-tutor-input-row {
  display: flex;
  gap: 8px;
}

.ask-tutor-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-full);
  padding: 9px 14px;
  font-size: 0.9rem;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  outline: none;
  transition: border-color var(--transition);
}
.ask-tutor-input:focus { border-color: var(--accent); }

.ask-tutor-send {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-full);
  padding: 9px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition);
}
.ask-tutor-send:hover { background: var(--accent-hover); }
.ask-tutor-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Version Badge (右上角版本標籤，避開底部 nav 與頁面內容) === */
.version-badge {
  position: fixed;
  top: 8px;
  right: 8px;
  font-size: 10px;
  color: var(--text-3);
  opacity: 0.55;
  pointer-events: none;
  z-index: 10000;
  font-family: var(--font);
  background: rgba(255,255,255,0.7);
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.2px;
}
