/* style.css — English App (overrides on top of MobileKit) */

/* ─── Light Mode Variables (default) ────────────────────────────────────── */
:root {
  --bg:           #f1f5f9;
  --bg2:          #ffffff;
  --bg3:          #e2e8f0;
  --border:       #cbd5e1;
  --text:         #0f172a;
  --text2:        #475569;
  --text3:        #94a3b8;
  --primary:      #3b82f6;
  --primary-dark: #2563eb;
  --accent:       #6366f1;
  --success:      #16a34a;
  --warning:      #d97706;
  --danger:       #dc2626;
  --purple:       #7c3aed;
  --radius:       12px;
  --radius-sm:    8px;
  --shadow:       0 4px 24px rgba(0,0,0,0.08);
  --hero-from:    #dbeafe;
  --hero-to:      #eff6ff;
  --hover-overlay: rgba(0,0,0,0.04);
}

/* ─── Dark Mode Variables ────────────────────────────────────────────────── */
body.dark-mode-active {
  --bg:           #0f172a;
  --bg2:          #1e293b;
  --bg3:          #334155;
  --border:       #475569;
  --text:         #f1f5f9;
  --text2:        #94a3b8;
  --text3:        #64748b;
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --purple:       #8b5cf6;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --hero-from:    #1e3a5f;
  --hero-to:      #1e293b;
  --hover-overlay: rgba(255,255,255,0.04);
}

/* ─── Base overrides ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg) !important;
  color: var(--text) !important;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* ─── MobileKit Integration ──────────────────────────────────────────────── */
#appCapsule {
  background: var(--bg);
  /* Override MobileKit's padding: 56px 0 — add horizontal + top breathing room */
  padding: calc(56px + 0.75rem) 1rem calc(56px + 0.75rem);
  box-sizing: border-box;
}
/* Tablet */
@media(min-width: 600px) {
  #appCapsule { padding-left: 1.5rem; padding-right: 1.5rem; }
}
/* Desktop/Web — center content with max-width */
@media(min-width: 960px) {
  #appCapsule {
    max-width: 960px;
    margin-left: auto;
    margin-right: auto;
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

/* Theme toggle button in header */
.appHeader .headerButton[id="themeToggle"] {
  background: none;
  border: none;
  padding: 0 8px;
  font-size: 1.2rem;
  color: var(--text2);
  cursor: pointer;
  display: flex;
  align-items: center;
}
.appHeader .headerButton[id="themeToggle"]:hover {
  color: var(--text);
}

/* Override MobileKit appHeader dark mode */
.appHeader {
  background: var(--bg2) !important;
  border-bottom: 1px solid var(--border) !important;
}
.appHeader .pageTitle {
  color: var(--text) !important;
}
.appHeader .headerButton {
  color: var(--text2) !important;
}
.appHeader .headerButton:hover {
  color: var(--text) !important;
}

/* Override MobileKit bottom menu */
.appBottomMenu {
  background: var(--bg2) !important;
  border-top: 1px solid var(--border) !important;
}
.appBottomMenu .item {
  color: var(--text3) !important;
}
.appBottomMenu .item.active {
  color: var(--primary) !important;
}
.appBottomMenu .item strong {
  color: inherit !important;
}

/* Override MobileKit offcanvas sidebar */
.offcanvas {
  background: var(--bg2) !important;
  border-color: var(--border) !important;
}
.offcanvas .profileBox {
  background: var(--bg3) !important;
}
.offcanvas .listview > li > a {
  color: var(--text) !important;
}
.offcanvas .listview > li > a:hover {
  background: var(--bg3) !important;
}
.offcanvas .listview-title {
  color: var(--text2) !important;
}
.offcanvas .close-sidebar-button {
  color: var(--text2) !important;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-outline, .btn-back, .btn-sm {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 0.4rem; padding: 0.6rem 1.25rem; border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 500; border: none; transition: all 0.15s;
  min-height: 44px;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--bg3); color: var(--text); }
.btn-secondary:hover { background: var(--border); }
.btn-outline { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--bg3); color: var(--text); }
.btn-back { background: transparent; color: var(--text2); padding: 0.4rem 0.75rem; font-size: 0.9rem; min-height: 44px; }
.btn-back:hover { color: var(--text); }
.btn-sm { padding: 0.5rem 0.8rem; font-size: 0.85rem; background: var(--primary); color: #fff; border-radius: 6px; min-height: 40px; }
.btn-danger { color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }

/* ─── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
}

/* ─── HOME PAGE ──────────────────────────────────────────────────────────── */
.home-page { display: flex; flex-direction: column; gap: 1.5rem; }

.home-hero {
  background: linear-gradient(135deg, var(--hero-from), var(--hero-to));
  border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2rem;
  text-align: center;
}
.hero-day { font-size: 0.9rem; color: var(--primary); font-weight: 600; margin-bottom: 0.5rem; }
.hero-title { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.4rem; }
.hero-subtitle { color: var(--text2); font-size: 1rem; }
.hero-streak { font-size: 0.9rem; color: var(--warning); font-weight: 700; margin-top: 0.5rem; }

.home-stats { display: grid; grid-template-columns: repeat(2,1fr); gap: 0.75rem; }
@media(min-width:480px) { .home-stats { grid-template-columns: repeat(4,1fr); } }
.stat-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1rem; text-align: center;
}
.stat-card .stat-num { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-card.streak-card .stat-num { color: var(--warning); }
.stat-card .stat-label { font-size: 0.75rem; color: var(--text2); margin-top: 0.25rem; }

.home-section h3 { font-size: 1rem; color: var(--text2); margin-bottom: 1rem; font-weight: 600; }

.review-alert {
  display: flex; align-items: center; gap: 1rem;
  background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--radius); padding: 1rem;
}
.alert-icon { font-size: 1.5rem; flex-shrink: 0; }
.review-alert p { font-size: 0.85rem; color: var(--text2); margin-top: 0.2rem; }

.home-actions { display: grid; grid-template-columns: repeat(2,1fr); gap: 1rem; }
@media(min-width:600px){ .home-actions { grid-template-columns: repeat(4,1fr); } }

.action-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  text-align: center; transition: all 0.15s; display: block;
}
.action-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.ac-icon { font-size: 1.8rem; margin-bottom: 0.5rem; }
.ac-label { font-weight: 600; margin-bottom: 0.25rem; }
.ac-desc { font-size: 0.8rem; color: var(--text2); }

/* Mini calendar */
.mini-calendar { display: grid; grid-template-columns: repeat(7,1fr); gap: 5px; }
.cal-day {
  aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; font-size: 0.75rem;
  background: var(--bg2); border: 1px solid var(--border);
  transition: all 0.15s; position: relative; overflow: hidden;
  min-height: 36px;
}
.cal-day:hover { border-color: var(--primary); }
.cal-day.today { border-color: var(--primary); background: rgba(59,130,246,0.15); font-weight: 700; }
.cal-day.done { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); }
.cal-day.locked { opacity: 0.4; cursor: not-allowed; }
.cal-day.review-day { background: rgba(139,92,246,0.15); border-color: rgba(139,92,246,0.3); }
.cal-num { font-weight: 600; }
.cal-score { font-size: 0.6rem; color: var(--success); }
.cal-lock { font-size: 0.6rem; }
/* Review day dot badge — top-right corner, no text */
.cal-rev-dot {
  position: absolute; top: 3px; right: 4px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--purple);
}
.cal-day.review-day .cal-num { color: var(--purple); }

/* ─── DAY PAGE ───────────────────────────────────────────────────────────── */
.day-page { display: flex; flex-direction: column; gap: 1.5rem; }
.day-header {
  display: flex; align-items: flex-start; gap: 1rem;
  padding-bottom: 1rem; border-bottom: 1px solid var(--border);
}
.day-num { font-size: 0.85rem; color: var(--primary); font-weight: 600; }
.day-header h2 { font-size: 1.3rem; margin-top: 0.2rem; }
.day-score { margin-left: auto; background: var(--success); color: #fff; padding: 0.4rem 0.8rem; border-radius: 6px; font-weight: 700; white-space: nowrap; }

.day-locked { text-align: center; padding: 3rem 1rem; }
.day-locked div { font-size: 3rem; margin-bottom: 1rem; }
.day-locked p { color: var(--text2); margin-bottom: 1.5rem; }

.day-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.day-section h3 { font-size: 1rem; margin-bottom: 1rem; color: var(--text2); }
.grammar-box {
  background: rgba(59,130,246,0.1); border-left: 3px solid var(--primary);
  padding: 0.75rem 1rem; border-radius: 0 8px 8px 0;
  font-size: 0.95rem; font-family: monospace; color: var(--text);
}

.word-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 0.75rem; }
@media(min-width:500px){ .word-grid { grid-template-columns: repeat(3,1fr); } }
@media(min-width:700px){ .word-grid { grid-template-columns: repeat(4,1fr); } }
.word-card {
  background: var(--bg3); border-radius: var(--radius-sm); padding: 0.85rem;
  cursor: pointer; transition: all 0.15s; border: 1px solid transparent;
  min-height: 80px;
}
.word-card:hover { border-color: var(--primary); background: rgba(59,130,246,0.1); }
.word-card:active { transform: scale(0.97); }
.wc-word { font-size: 1rem; font-weight: 700; margin-bottom: 0.2rem; }
.wc-phonetic { font-size: 0.75rem; color: var(--text2); font-family: monospace; }
.wc-meaning { font-size: 0.85rem; color: var(--text); margin-top: 0.2rem; }
.wc-group { font-size: 0.7rem; color: var(--text3); margin-top: 0.2rem; }

.dialogue { display: flex; flex-direction: column; gap: 0.75rem; }
.dialogue-line { display: flex; gap: 0.75rem; }
.dl-speaker {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}
.speaker-a .dl-speaker { background: var(--primary); color: #fff; }
.speaker-b .dl-speaker { background: var(--success); color: #fff; }
.dl-en { font-weight: 500; margin-bottom: 0.2rem; }
.dl-vi { font-size: 0.85rem; color: var(--text2); }

.day-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
.review-notice {
  background: rgba(139,92,246,0.1); border: 1px solid rgba(139,92,246,0.3);
  border-radius: var(--radius); padding: 1.5rem; text-align: center;
}
.review-notice h3 { margin-bottom: 0.5rem; }
.review-notice p { color: var(--text2); }

/* ─── AUDIO PLAYER ───────────────────────────────────────────────────────── */
.audio-player { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.ap-track-info { display: flex; justify-content: space-between; padding: 1rem 1rem 0.5rem; }
.ap-file-name { font-weight: 600; font-size: 1rem; }
.ap-counter { color: var(--text2); font-size: 0.9rem; }
.ap-progress-bar {
  margin: 0.5rem 1rem; height: 8px; background: var(--bg3);
  border-radius: 4px; cursor: pointer; touch-action: none;
}
.ap-progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width 0.1s; }
.ap-time { display: flex; justify-content: space-between; padding: 0 1rem; font-size: 0.8rem; color: var(--text2); }
.ap-controls {
  display: flex; align-items: center; justify-content: center;
  gap: 1rem; padding: 1rem;
}
.ap-btn {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 0.5rem 1rem; border-radius: var(--radius-sm); font-size: 1rem;
  transition: all 0.15s; min-height: 44px; min-width: 44px;
}
.ap-btn:hover { background: var(--border); }
.ap-btn-play {
  background: var(--primary); border-color: var(--primary);
  padding: 0.6rem 1.5rem; font-size: 1.2rem; min-height: 48px;
}
.ap-btn-play:hover { background: var(--primary-dark); }
.ap-volume { display: flex; align-items: center; gap: 0.5rem; }
.ap-range { width: 80px; accent-color: var(--primary); height: 20px; }
.ap-playlist {
  max-height: 320px; overflow-y: auto;
  border-top: 1px solid var(--border);
}
.ap-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem; cursor: pointer; transition: background 0.1s;
  border-bottom: 1px solid rgba(71,85,105,0.3);
  min-height: 48px;
}
.ap-item:hover { background: var(--bg3); }
.ap-item.active { background: rgba(59,130,246,0.15); color: var(--primary); }
.ap-item-num { font-size: 0.8rem; color: var(--text2); width: 24px; }
.ap-item-name { flex: 1; font-size: 0.9rem; }
.ap-item-play { color: var(--text3); font-size: 0.8rem; }

/* Rich audio player track info */
.ap-track-names { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; flex: 1; }
.ap-file-name { font-weight: 600; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-file-sub  { font-size: 0.78rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-track-info { display: flex; align-items: flex-start; justify-content: space-between; padding: 1rem 1rem 0.5rem; gap: 0.5rem; }

/* Group header in playlist */
.ap-group-header {
  padding: 0.4rem 1rem; font-size: 0.72rem; font-weight: 700;
  color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em;
  background: rgba(59,130,246,0.07); border-bottom: 1px solid rgba(59,130,246,0.15);
  position: sticky; top: 0; z-index: 1;
}

/* Playlist item with sub-label */
.ap-item-info { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.ap-item-name { font-size: 0.9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-item-sub  { font-size: 0.72rem; color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-item.active .ap-item-sub { color: var(--primary); }
.ap-item-ex-en { font-size: 0.72rem; color: var(--text); font-style: italic; white-space: normal; line-height: 1.4; }
.ap-item-ex-vi { font-size: 0.68rem; color: var(--text2); white-space: normal; line-height: 1.3; }
.ap-item.active .ap-item-ex-en { color: var(--text); }
.ap-item.active .ap-item-ex-vi { color: var(--text2); }

/* ─── FLASHCARD ──────────────────────────────────────────────────────────── */
.flashcard-page, .fc-page-header { display: flex; flex-direction: column; gap: 1rem; }
.fc-wrapper { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem; max-width: 480px; margin: 0 auto; }
.fc-header { display: flex; justify-content: space-between; width: 100%; font-size: 0.9rem; color: var(--text2); }
.fc-session-stats { display: flex; gap: 0.75rem; }
.fc-session-stats .stat { font-size: 0.85rem; }
.stat.known { color: var(--success); }
.stat.learning { color: var(--warning); }
.stat.forgot { color: var(--danger); }
.fc-progress-bar { width: 100%; height: 4px; background: var(--bg3); border-radius: 2px; }
.fc-progress-fill { height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.3s; }

.fc-card {
  width: 100%; min-height: 220px; background: var(--bg2);
  border: 2px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.2s; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem; text-align: center; user-select: none;
  -webkit-user-select: none; touch-action: pan-y;
}
.fc-card:hover { border-color: var(--primary); }
.fc-card.flipped { border-color: var(--success); background: rgba(34,197,94,0.05); }
.fc-swipe-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: 0.7rem; color: var(--text3); white-space: nowrap; pointer-events: none;
}
.fc-front, .fc-back { display: flex; flex-direction: column; align-items: center; gap: 0.75rem; width: 100%; }
.fc-word { font-size: 2.5rem; font-weight: 700; }
.fc-hint { font-size: 0.85rem; color: var(--text3); }
.fc-group { font-size: 0.75rem; background: var(--bg3); padding: 0.2rem 0.6rem; border-radius: 4px; color: var(--text2); }
.fc-meaning { font-size: 1.8rem; font-weight: 700; }
.fc-phonetic { font-size: 1rem; color: var(--text2); font-family: monospace; }
.fc-word-small { font-size: 0.9rem; color: var(--text3); }
.fc-audio-btn {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text2);
  padding: 0.5rem 0.8rem; border-radius: 6px; font-size: 0.85rem; min-height: 40px;
}
.fc-audio-btn:hover { background: var(--border); color: var(--text); }

.fc-buttons {
  display: flex; gap: 0.75rem; width: 100%;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.fc-buttons.visible { opacity: 1; pointer-events: all; }
.fc-btn {
  flex: 1; padding: 0.8rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; border: none; transition: all 0.15s;
  min-height: 48px;
}
.fc-btn.forgot { background: rgba(239,68,68,0.2); color: var(--danger); border: 1px solid var(--danger); }
.fc-btn.forgot:hover { background: var(--danger); color: #fff; }
.fc-btn.learning { background: rgba(245,158,11,0.2); color: var(--warning); border: 1px solid var(--warning); }
.fc-btn.learning:hover { background: var(--warning); color: #fff; }
.fc-btn.known { background: rgba(34,197,94,0.2); color: var(--success); border: 1px solid var(--success); }
.fc-btn.known:hover { background: var(--success); color: #fff; }
.fc-flip-btn {
  background: var(--bg3); border: 1px solid var(--border); color: var(--text);
  padding: 0.75rem 1.5rem; border-radius: var(--radius-sm); font-size: 0.9rem;
  min-height: 48px;
}
.fc-flip-btn:hover { background: var(--border); }
.fc-empty { text-align: center; padding: 3rem; color: var(--text2); }

/* FC Summary */
.fc-summary { text-align: center; padding: 2rem; max-width: 400px; margin: 0 auto; }
.fc-summary-icon { font-size: 3rem; margin-bottom: 1rem; }
.fc-summary h2 { margin-bottom: 1.5rem; }
.fc-summary-stats { display: flex; gap: 1rem; justify-content: center; margin-bottom: 1.5rem; }
.stat-box { padding: 1rem 1.5rem; border-radius: var(--radius-sm); }
.stat-box.known { background: rgba(34,197,94,0.15); }
.stat-box.learning { background: rgba(245,158,11,0.15); }
.stat-box.forgot { background: rgba(239,68,68,0.15); }
.stat-num { font-size: 2rem; font-weight: 700; }
.fc-score { font-size: 1.3rem; font-weight: 700; margin-bottom: 1.5rem; }
.fc-actions { display: flex; gap: 0.75rem; justify-content: center; }

/* ─── TEST PAGE ──────────────────────────────────────────────────────────── */
.test-page, .test-page-header { display: flex; flex-direction: column; gap: 1rem; }
.test-type-select h3 { margin-bottom: 1rem; color: var(--text2); }
.test-types { display: grid; grid-template-columns: repeat(2,1fr); gap: 0.75rem; }
@media(min-width:600px){ .test-types { grid-template-columns: repeat(3,1fr); } }
.test-type-card {
  background: var(--bg2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 1.25rem;
  cursor: pointer; transition: all 0.15s; text-align: center;
  min-height: 100px;
}
.test-type-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.test-type-card:active { transform: scale(0.97); }
.tt-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.tt-name { font-weight: 600; margin-bottom: 0.3rem; }
.tt-desc { font-size: 0.8rem; color: var(--text2); }

.test-wrapper { max-width: 560px; margin: 0 auto; padding: 1rem 0.5rem; }
.test-header { display: flex; justify-content: space-between; margin-bottom: 1rem; font-size: 0.9rem; color: var(--text2); }
.test-timer { font-size: 1.2rem; font-weight: 700; color: var(--warning); font-family: monospace; }
.test-desc { color: var(--text2); font-size: 0.9rem; margin-bottom: 1rem; }
.test-card-flip {
  background: var(--bg2); border: 2px solid var(--border);
  border-radius: var(--radius); padding: 2rem; text-align: center;
  margin-bottom: 1rem; cursor: pointer; min-height: 140px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.5rem;
}
.test-word { font-size: 2.2rem; font-weight: 700; }
.test-hint { color: var(--text3); font-size: 0.85rem; }
.test-back.hidden { display: none; }
.test-meaning { font-size: 1.5rem; font-weight: 600; }
.test-phonetic { font-family: monospace; color: var(--text2); }
.test-flip-area, .test-rate-area { margin-bottom: 1rem; }
.test-rate-area.hidden { display: none; }
.test-rate-btns { display: flex; gap: 0.75rem; margin-top: 0.75rem; }
.btn-rate {
  flex: 1; padding: 0.8rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 600; border: none; min-height: 48px;
}
.btn-rate.fail { background: rgba(239,68,68,0.2); color: var(--danger); border: 1px solid var(--danger); }
.btn-rate.fail:hover { background: var(--danger); color: #fff; }
.btn-rate.pass { background: rgba(34,197,94,0.2); color: var(--success); border: 1px solid var(--success); }
.btn-rate.pass:hover { background: var(--success); color: #fff; }

.test-textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 0.75rem;
  font-family: inherit; font-size: 16px; resize: vertical; margin-bottom: 1rem;
}
.test-textarea:focus { outline: none; border-color: var(--primary); }
.test-input {
  width: 100%; background: var(--bg3); border: 1px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 0.75rem;
  font-family: inherit; font-size: 16px; margin-bottom: 1rem;
}
.test-input:focus { outline: none; border-color: var(--primary); }
.test-audio-section { display: flex; gap: 0.75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.btn-audio {
  background: var(--primary); color: #fff; border: none;
  padding: 0.75rem 1.5rem; border-radius: var(--radius-sm); font-size: 1rem;
  min-height: 48px;
}
.btn-audio:hover { background: var(--primary-dark); }
.btn-audio-sm {
  background: var(--bg3); color: var(--text2); border: 1px solid var(--border);
  padding: 0.6rem 1rem; border-radius: var(--radius-sm); font-size: 0.85rem;
  min-height: 44px;
}
.btn-audio-sm:hover { background: var(--border); }
.test-question { text-align: center; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1rem; }
.test-meaning-big { font-size: 1.8rem; font-weight: 700; margin-bottom: 0.5rem; }
.test-phonetic-hint { font-family: monospace; color: var(--text2); }
.test-feedback {
  padding: 0.75rem 1rem; border-radius: var(--radius-sm); margin-top: 0.75rem; font-size: 0.95rem;
}
.test-feedback.correct { background: rgba(34,197,94,0.15); color: var(--success); }
.test-feedback.wrong { background: rgba(239,68,68,0.15); color: var(--danger); }
.test-word-play { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.test-word-play .test-word-big { flex: 1; margin-bottom: 0; }
.test-word-big { font-size: 2.5rem; font-weight: 700; text-align: center; padding: 1.5rem; background: var(--bg2); border: 2px solid var(--primary); border-radius: var(--radius); margin-bottom: 0.5rem; }
.test-word-info { text-align: center; color: var(--text2); font-family: monospace; margin-bottom: 1rem; }
.test-actions { display: flex; gap: 0.75rem; }
.test-note { font-size: 0.85rem; color: var(--text2); margin: 1rem 0; }
.sentence-list { display: flex; flex-direction: column; gap: 0.5rem; margin: 1rem 0; }
.sentence-item { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem; font-size: 0.9rem; }
.sentence-item.skipped { opacity: 0.5; }

/* Test Result */
.test-result { text-align: center; padding: 2rem; max-width: 400px; margin: 0 auto; }
.test-score-circle {
  width: 140px; height: 140px; border-radius: 50%;
  border: 6px solid var(--score-color, var(--primary));
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  margin: 0 auto 1.5rem; background: rgba(255,255,255,0.02);
}
.score-num { font-size: 2.5rem; font-weight: 700; }
.score-label { font-size: 0.8rem; font-weight: 600; color: var(--text2); }
.test-stats { display: flex; gap: 1rem; justify-content: center; margin-bottom: 1.5rem; font-size: 0.9rem; flex-wrap: wrap; }
.stat-correct { color: var(--success); }
.stat-wrong { color: var(--danger); }
.stat-total { color: var(--text2); }
.gateway-pass { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1.5rem; color: var(--success); font-size: 0.9rem; }
.gateway-near { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1.5rem; color: var(--warning); font-size: 0.9rem; }
.gateway-fail { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1.5rem; color: var(--danger); font-size: 0.9rem; }

/* ─── Write Memory Result ────────────────────────────────────────────────── */
.wm-result-section { margin-top: 1rem; text-align: left; }
.wm-result-title {
  font-size: 0.8rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 0.5rem;
}
.wm-result-title.wm-correct { color: var(--success); }
.wm-result-title.wm-wrong   { color: var(--danger); }
.wm-result-title.wm-missed  { color: var(--text3); }
.wm-result-words { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.wm-tag {
  font-size: 0.8rem; padding: 0.25rem 0.55rem; border-radius: 6px;
  display: inline-flex; align-items: center; gap: 0.3rem;
}
.wm-tag em { font-style: normal; opacity: 0.75; font-size: 0.75rem; }
.wm-tag.wm-correct { background: rgba(34,197,94,0.15);  color: var(--success); border: 1px solid rgba(34,197,94,0.3); }
.wm-tag.wm-wrong   { background: rgba(239,68,68,0.12);  color: var(--danger);  border: 1px solid rgba(239,68,68,0.3); }
.wm-tag.wm-missed  { background: rgba(100,116,139,0.15); color: var(--text2);  border: 1px solid rgba(100,116,139,0.3); }

/* ─── PROGRESS PAGE ──────────────────────────────────────────────────────── */
.progress-page { display: flex; flex-direction: column; gap: 1.5rem; }
.progress-page h2 { margin-bottom: 0.5rem; }
.prog-overview { display: grid; grid-template-columns: repeat(3,1fr); gap: 1rem; }
.prog-stat { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.ps-num { font-size: 2rem; font-weight: 700; color: var(--primary); }
.ps-label { font-size: 0.8rem; color: var(--text2); margin-top: 0.25rem; }
.prog-week { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.pw-header { display: flex; justify-content: space-between; margin-bottom: 0.75rem; font-size: 0.9rem; color: var(--text2); }
.prog-bar { height: 6px; background: var(--bg3); border-radius: 3px; margin-bottom: 0.75rem; }
.prog-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.5s; }
.pw-days { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pd-day {
  width: 42px; padding: 0.4rem; border-radius: var(--radius-sm); text-align: center;
  background: var(--bg3); border: 1px solid var(--border); font-size: 0.75rem;
  display: flex; flex-direction: column; align-items: center; transition: all 0.15s;
  min-height: 42px;
}
.pd-day:hover { border-color: var(--primary); }
.pd-day.done { background: rgba(34,197,94,0.15); border-color: rgba(34,197,94,0.4); }
.pd-day.locked { opacity: 0.4; cursor: not-allowed; }
.pd-day.review { background: rgba(139,92,246,0.15); border-color: rgba(139,92,246,0.3); }
.pd-day small { font-size: 0.6rem; color: var(--text2); }

.prog-section { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; }
.prog-section h3 { margin-bottom: 1rem; color: var(--text2); font-size: 1rem; }
.vocab-stats { display: flex; gap: 1rem; }
.vs-item { text-align: center; flex: 1; padding: 0.75rem; border-radius: var(--radius-sm); }
.vs-item.known { background: rgba(34,197,94,0.1); }
.vs-item.learning { background: rgba(245,158,11,0.1); }
.vs-item.forgot { background: rgba(239,68,68,0.1); }
.vs-item span { font-size: 1.5rem; font-weight: 700; display: block; }
.vs-item small { font-size: 0.8rem; color: var(--text2); }
.prog-actions { padding-top: 0.5rem; }

/* ─── LISTEN PAGE ────────────────────────────────────────────────────────── */
.listen-page { display: flex; flex-direction: column; gap: 1rem; }
.listen-page h2 { font-size: 1.4rem; }
.listen-desc { color: var(--text2); margin-bottom: 0.5rem; }

/* Tabs */
.listen-tabs { display: flex; gap: 0.5rem; }
.listen-tab {
  flex: 1; padding: 0.65rem 1rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500; border: 1px solid var(--border);
  background: var(--bg2); color: var(--text2); cursor: pointer;
  transition: all 0.15s; min-height: 44px;
}
.listen-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.listen-tab:not(.active):hover { background: var(--bg3); color: var(--text); }

/* Word List (tab 2) */
.listen-word-list { display: flex; flex-direction: column; gap: 0.5rem; }

.wl-day { background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.wl-day-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1rem; cursor: pointer; user-select: none;
  transition: background 0.15s; gap: 0.75rem;
}
.wl-day-header:hover { background: var(--bg3); }

.wl-day-title { display: flex; flex-direction: column; gap: 0.15rem; }
.wl-day-num  { font-size: 0.75rem; font-weight: 700; color: var(--primary); text-transform: uppercase; letter-spacing: 0.04em; }
.wl-day-name { font-size: 0.95rem; font-weight: 600; }

.wl-day-meta { display: flex; align-items: center; gap: 0.75rem; flex-shrink: 0; }
.wl-day-count { font-size: 0.8rem; color: var(--text3); white-space: nowrap; }
.wl-play-all {
  font-size: 0.78rem; padding: 0.35rem 0.65rem; min-height: 34px;
  background: rgba(59,130,246,0.15); color: var(--primary);
  border: 1px solid rgba(59,130,246,0.3); border-radius: 6px;
  white-space: nowrap;
}
.wl-play-all:hover { background: var(--primary); color: #fff; }

.wl-words {
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.wl-words.collapsed { display: none; }

.wl-word {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem; border-bottom: 1px solid rgba(71,85,105,0.2);
  transition: background 0.1s;
}
.wl-word:last-child { border-bottom: none; }
.wl-word:hover { background: var(--hover-overlay); }
.wl-word.playing { background: rgba(59,130,246,0.1); }

.wl-btn-play {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  background: var(--bg3); border: 1px solid var(--border);
  color: var(--text2); font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.wl-btn-play:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.wl-btn-play.playing { background: var(--primary); color: #fff; border-color: var(--primary); }
.wl-word.playing .wl-btn-play { animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(59,130,246,0.5); }
  50%       { box-shadow: 0 0 0 6px rgba(59,130,246,0); }
}

.wl-word-info { display: flex; align-items: baseline; gap: 0.5rem; flex: 1; flex-wrap: wrap; }
.wl-word-en   { font-size: 1rem; font-weight: 700; }
.wl-word-ipa  { font-size: 0.78rem; color: var(--text2); font-family: monospace; }
.wl-word-vi   { font-size: 0.85rem; color: var(--text); margin-left: auto; text-align: right; }

.wl-word-example {
  width: 100%;
  display: flex; flex-direction: column; gap: 0.15rem;
  margin-top: 0.3rem; padding: 0.35rem 0.6rem;
  border-left: 3px solid var(--accent);
  background: rgba(99,102,241,0.06);
  border-radius: 0 6px 6px 0;
}
.wl-ex-en { font-size: 0.82rem; color: var(--text); font-style: italic; }
.wl-ex-vi { font-size: 0.78rem; color: var(--text2); }

/* ─── SEARCH PAGE ────────────────────────────────────────────────────────── */
.search-page { display: flex; flex-direction: column; gap: 1rem; }
.search-page h2 { font-size: 1.4rem; }
.search-input {
  width: 100%; background: var(--bg2); border: 2px solid var(--border);
  color: var(--text); border-radius: var(--radius-sm); padding: 0.85rem 1rem;
  font-family: inherit; font-size: 16px; transition: border-color 0.15s;
}
.search-input:focus { outline: none; border-color: var(--primary); }
.search-count { font-size: 0.85rem; color: var(--text3); margin-bottom: 0.5rem; }
.search-empty { color: var(--text3); text-align: center; padding: 2rem; }
.search-grid { display: grid; grid-template-columns: repeat(2,1fr); gap: 0.75rem; }
@media(min-width:500px){ .search-grid { grid-template-columns: repeat(3,1fr); } }
@media(min-width:700px){ .search-grid { grid-template-columns: repeat(4,1fr); } }
.search-item {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0.85rem;
  cursor: pointer; transition: all 0.15s;
}
.search-item:hover { border-color: var(--primary); background: rgba(59,130,246,0.08); }
.search-item:active { transform: scale(0.97); }
.si-word { font-size: 1rem; font-weight: 700; margin-bottom: 0.2rem; }
.si-phonetic { font-size: 0.75rem; color: var(--text2); font-family: monospace; }
.si-meaning { font-size: 0.85rem; margin-top: 0.2rem; }
.si-meta { font-size: 0.7rem; color: var(--text3); margin-top: 0.3rem; }

/* ─── TOPIC GRID (Nghe theo chủ đề) ─────────────────────────────────────── */
.topic-grid-hint { color: var(--text2); font-size: 0.85rem; margin-bottom: 0.75rem; }
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(165px, 1fr));
  gap: 0.75rem;
}
.topic-card {
  background: var(--bg2); border: 1.5px solid var(--border);
  border-radius: 12px; padding: 0.85rem 0.9rem;
  cursor: pointer; transition: all 0.15s;
  display: flex; flex-direction: column; gap: 0.25rem;
}
.topic-card:hover { border-color: var(--primary); background: rgba(59,130,246,0.07); transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.topic-card:active { transform: scale(0.97); }
.tc-icon { font-size: 1.75rem; line-height: 1; margin-bottom: 0.25rem; }
.tc-name { font-weight: 700; font-size: 0.88rem; line-height: 1.3; }
.tc-desc { font-size: 0.72rem; color: var(--text2); line-height: 1.45; flex: 1; }
.tc-meta { font-size: 0.68rem; color: var(--text3); margin-top: 0.3rem; padding-top: 0.35rem; border-top: 1px solid var(--border); }
.topic-detail-header {
  display: flex; align-items: flex-start; gap: 0.75rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}
.topic-detail-info { flex: 1; min-width: 0; }
.topic-detail-title { font-size: 1.05rem; font-weight: 700; margin-bottom: 0.25rem; }
.topic-detail-meta { font-size: 0.78rem; color: var(--text2); line-height: 1.5; }
.topic-player-area { margin-bottom: 0.5rem; }
.group-player-area { margin-bottom: 1rem; position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 0.5rem 0; }

/* ─── GUIDE PAGE ─────────────────────────────────────────────────────────── */
.guide-page { max-width: 720px; margin: 0 auto; padding: 1rem; }
.guide-page h2 { margin-bottom: 1.25rem; }

.guide-tabs {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-bottom: 1.5rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0.75rem;
}
.guide-tab {
  padding: 0.45rem 0.9rem; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--bg2);
  color: var(--text2); font-size: 0.85rem; cursor: pointer;
  transition: all 0.15s;
}
.guide-tab:hover { border-color: var(--primary); color: var(--text); }
.guide-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }

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

.guide-section h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }
.guide-intro { color: var(--text2); margin-bottom: 1.25rem; line-height: 1.6; }

/* Roadmap weeks */
.guide-weeks { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin-bottom: 1rem; }
.guide-week { border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.gw-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.6rem 0.85rem; font-weight: 600; font-size: 0.9rem;
  background: var(--bg3);
}
.gw-badge {
  background: var(--primary); color: #fff;
  padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem;
}
.week2 .gw-badge { background: #8b5cf6; }
.week3 .gw-badge { background: #06b6d4; }
.week4 .gw-badge { background: #22c55e; }
.gw-body { padding: 0.75rem 0.85rem; font-size: 0.85rem; line-height: 1.6; }
.gw-words { font-weight: 600; color: var(--primary); margin-bottom: 0.4rem; font-size: 0.9rem; }
.gw-body ul { margin: 0; padding-left: 1.2rem; color: var(--text2); }
.gw-body ul li { margin-bottom: 0.2rem; }

/* Philosophy cards */
.guide-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.guide-card {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem;
}
.gc-icon { font-size: 1.6rem; margin-bottom: 0.4rem; }
.gc-title { font-weight: 700; margin-bottom: 0.4rem; font-size: 0.95rem; }
.gc-body { font-size: 0.82rem; color: var(--text2); line-height: 1.6; }
.gc-body em { color: var(--text); font-style: normal; font-weight: 600; }

/* Method steps */
.guide-steps { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 1rem; }
.guide-step {
  display: flex; gap: 1rem; align-items: flex-start;
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem;
}
.gs-num {
  width: 2rem; height: 2rem; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.gs-content { flex: 1; }
.gs-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 0.5rem; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.gs-time { font-size: 0.75rem; background: var(--bg3); color: var(--text2); padding: 0.1rem 0.5rem; border-radius: 999px; font-weight: 400; }
.gs-content p { font-size: 0.85rem; color: var(--text2); line-height: 1.6; margin: 0 0 0.5rem; }
.gs-content ul, .gs-content ol { margin: 0.25rem 0 0; padding-left: 1.2rem; font-size: 0.85rem; color: var(--text2); line-height: 1.8; }

/* Features */
.guide-features { display: flex; flex-direction: column; gap: 0.75rem; }
.guide-feature { background: var(--bg2); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.gf-header { padding: 0.65rem 1rem; font-weight: 700; font-size: 0.95rem; background: var(--bg3); border-bottom: 1px solid var(--border); }
.gf-body { padding: 0.75rem 1rem; font-size: 0.85rem; color: var(--text2); line-height: 1.7; }
.gf-body p { margin: 0 0 0.5rem; }
.gf-body ul, .gf-body ol { margin: 0.25rem 0 0; padding-left: 1.2rem; }
.gf-body li { margin-bottom: 0.3rem; }
.gf-body strong { color: var(--text); }

/* Shared tip box */
.guide-tip {
  background: rgba(59,130,246,0.08); border-left: 3px solid var(--primary);
  border-radius: 0 8px 8px 0; padding: 0.75rem 1rem;
  font-size: 0.85rem; color: var(--text2); line-height: 1.6;
  margin-top: 0.75rem;
}
.guide-tip strong { color: var(--text); }

/* ─── Responsive ─────────────────────────────────────────────────────────── */
@media(max-width:640px) {
  .hero-title { font-size: 1.3rem; }
  .home-hero { padding: 1.5rem 1rem; }
  .day-actions { flex-direction: column; }
  .day-actions .btn-primary,
  .day-actions .btn-secondary,
  .day-actions .btn-outline { width: 100%; justify-content: center; }
  .test-types { grid-template-columns: 1fr 1fr; }
  .fc-wrapper { padding: 0.5rem; }
  .test-wrapper { padding: 0.5rem; }
  .prog-overview { gap: 0.5rem; }
  .vocab-stats { gap: 0.5rem; }
  .fc-buttons { gap: 0.5rem; }
  .fc-btn { font-size: 0.8rem; }
  .guide-weeks { grid-template-columns: 1fr; }
  .guide-cards { grid-template-columns: 1fr; }
  .guide-step { gap: 0.75rem; }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .wl-word-vi { display: none; }
  .wl-day-name { font-size: 0.85rem; }
}

@media(max-width:380px) {
  .test-types { grid-template-columns: 1fr; }
  .home-stats { grid-template-columns: repeat(2,1fr); }
}

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--bg3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border); }

/* ─── Selection ──────────────────────────────────────────────────────────── */
::selection { background: rgba(59,130,246,0.3); }
