/* ===================================
   EnglishUp — Main Stylesheet
   Mobile-first, vibrant, modern
   =================================== */

:root {
  --primary: #4F6EF7;
  --primary-dark: #3451d4;
  --primary-light: #EEF1FE;
  --accent: #D97741;
  --accent-light: #FEF0E6;
  --success: #22C55E;
  --success-light: #DCFCE7;
  --warning: #F59E0B;
  --warning-light: #FEF3C7;
  --danger: #EF4444;
  --danger-light: #FEE2E2;
  --purple: #8B5CF6;
  --purple-light: #EDE9FE;
  --teal: #14B8A6;
  --teal-light: #CCFBF1;

  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --surface-2: #F5F2EC;
  --border: #E6E1D8;
  --text: #1C1917;
  --text-muted: #78716C;
  --text-light: #A8A29E;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --shadow: 0 2px 16px rgba(70, 50, 20, 0.07);
  --shadow-md: 0 8px 32px rgba(70, 50, 20, 0.10);
  --shadow-lg: 0 16px 48px rgba(70, 50, 20, 0.14);

  --font: 'Sora', sans-serif;
  --font-body: 'DM Sans', sans-serif;

  --nav-height: 64px;
  --bottom-nav-height: 72px;
}

/* ---- DARK MODE ---- */
[data-theme="dark"] {
  --bg: #111110;
  --surface: #1C1B19;
  --surface-2: #242320;
  --border: #2E2C28;
  --text: #F2EFE8;
  --text-muted: #A09890;
  --text-light: #6B6560;

  --primary-light: #1A2240;
  --accent-light: #2D1A0A;
  --success-light: #0D2E1A;
  --warning-light: #2D200A;
  --danger-light: #2D0E0E;
  --purple-light: #1E1535;
  --teal-light: #0A2420;

  --shadow: 0 2px 16px rgba(0,0,0,0.35);
  --shadow-md: 0 8px 32px rgba(0,0,0,0.45);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.55);
}

[data-theme="dark"] .hero {
  background: linear-gradient(160deg, #1A1815 0%, #201E1A 100%);
}
[data-theme="dark"] .hero::before {
  background:
    radial-gradient(ellipse at 20% 60%, rgba(217,119,65,0.13) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 40%, rgba(79,110,247,0.11) 0%, transparent 55%);
}
[data-theme="dark"] .hero-cta {
  background: var(--primary);
  color: #fff;
}
[data-theme="dark"] .hero-cta-secondary {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.2);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---- TYPOGRAPHY ---- */
h1, h2, h3, h4, h5, h6 { font-family: var(--font); font-weight: 700; line-height: 1.2; }
p { line-height: 1.7; }
a { text-decoration: none; color: inherit; }

/* ---- TOP NAV ---- */
.topnav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
}
.topnav-inner {
  max-width: 1200px; margin: 0 auto;
  height: 100%; display: flex; align-items: center;
  padding: 0 1rem; gap: 1.5rem;
}
.brand {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--font); font-weight: 800; font-size: 1.2rem;
  color: var(--primary);
}
.brand-icon { font-size: 1.4rem; }

.nav-links { display: flex; gap: 0.25rem; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.875rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500; color: var(--text-muted);
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  background: var(--primary-light); color: var(--primary);
}
.nav-link.active { font-weight: 600; }

/* Meet Learners nav button */
.nav-meet {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.4rem 0.9rem; border-radius: 100px;
  font-size: 0.9rem; font-weight: 600;
  background: var(--accent); color: #fff;
  transition: all 0.2s; white-space: nowrap;
}
.nav-meet:hover, .nav-meet.active { background: var(--accent-dark, #c0622d); color: #fff; }

/* Practice dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-trigger {
  background: none; border: none; cursor: pointer; font-family: var(--font-body);
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.5rem 0.875rem; border-radius: var(--radius-sm);
  font-size: 0.9rem; font-weight: 500; color: var(--text-muted);
  transition: all 0.2s;
}
.nav-dropdown-trigger:hover,
.nav-dropdown-trigger.active { background: var(--primary-light); color: var(--primary); }
.nav-dropdown-trigger.active { font-weight: 600; }
.nav-dropdown-trigger .chevron { font-size: 0.6rem; transition: transform 0.2s; }
.nav-dropdown:hover .nav-dropdown-trigger .chevron { transform: rotate(180deg); }
.nav-dropdown-menu {
  position: absolute; top: calc(100% + 6px); left: 50%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  padding: 0.4rem; min-width: 168px; z-index: 200;
  opacity: 0; visibility: hidden;
  transform: translateX(-50%) translateY(-6px);
  transition: opacity 0.18s ease, transform 0.18s ease, visibility 0s 0.18s;
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1; visibility: visible;
  transform: translateX(-50%) translateY(0);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.nav-dropdown-item {
  display: flex; align-items: center; gap: 0.65rem;
  padding: 0.6rem 0.875rem; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500; color: var(--text);
  transition: all 0.15s;
}
.nav-dropdown-item:hover { background: var(--surface-2); color: var(--primary); }

.nav-actions { display: flex; align-items: center; gap: 0.5rem; margin-left: auto; }
.xp-badge {
  display: flex; align-items: center; gap: 0.3rem;
  background: var(--warning-light); color: var(--warning);
  padding: 0.3rem 0.75rem; border-radius: 100px;
  font-size: 0.85rem; font-weight: 700; font-family: var(--font);
}
.avatar-btn {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--primary-light); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; transition: all 0.2s; border: none; cursor: pointer;
}
.avatar-btn:hover { background: var(--primary); color: #fff; }

.avatar-dropdown { position: relative; align-items: center; }
.avatar-menu {
  display: none; position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-md);
  min-width: 170px; z-index: 200; overflow: hidden;
}
.avatar-menu.open { display: block; }
.avatar-menu-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .65rem 1rem; font-size: .875rem; color: var(--text);
  transition: background .15s; line-height: 1.4;
  box-sizing: border-box; width: 100%;
  background: none; border: none; cursor: pointer;
  font-family: var(--font); text-align: left; margin: 0;
}
.avatar-menu-item:hover { background: var(--bg); }
.avatar-menu-item.danger { color: var(--danger); }
.avatar-menu-item.danger:hover { background: #fff5f5; }
.avatar-menu-divider { height: 1px; background: var(--border); margin: .25rem 0; }

.btn-ghost {
  padding: 0.4rem 1rem; border-radius: var(--radius-sm);
  font-weight: 600; font-size: 0.9rem; color: var(--text-muted);
  transition: all 0.2s; border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }

.btn-primary {
  padding: 0.4rem 1.1rem; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff;
  font-weight: 600; font-size: 0.9rem; font-family: var(--font);
  transition: all 0.2s; border: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 0.4rem;
}
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: var(--shadow-md); color: #fff; }

.btn-accent {
  background: var(--accent); color: #fff;
  padding: 0.6rem 1.4rem; border-radius: var(--radius-sm);
  font-weight: 600; font-family: var(--font); display: inline-flex;
  align-items: center; gap: 0.4rem; transition: all 0.2s; border: none; cursor: pointer;
}
.btn-accent:hover { background: #e85520; transform: translateY(-1px); color: #fff; }

.btn-success {
  background: var(--success); color: #fff;
  padding: 0.6rem 1.4rem; border-radius: var(--radius-sm);
  font-weight: 600; font-family: var(--font); display: inline-flex;
  align-items: center; gap: 0.4rem; transition: all 0.2s; border: none; cursor: pointer;
}
.btn-success:hover { background: #16a34a; transform: translateY(-1px); color: #fff; }

.btn-outline {
  padding: 0.5rem 1.2rem; border-radius: var(--radius-sm);
  border: 2px solid var(--primary); color: var(--primary);
  font-weight: 600; font-size: 0.9rem; transition: all 0.2s;
  display: inline-flex; align-items: center; gap: 0.4rem; background: transparent;
  cursor: pointer;
}
.btn-outline:hover { background: var(--primary); color: #fff; }

/* ---- THEME TOGGLE ---- */
.theme-toggle {
  background: none; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); width: 38px; height: 38px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: var(--text-muted); cursor: pointer;
  transition: all 0.2s;
}
.theme-toggle:hover { border-color: var(--primary); color: var(--primary); }

/* ---- HAMBURGER ---- */
.hamburger {
  display: none; background: none; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); width: 38px; height: 38px;
  align-items: center; justify-content: center;
  font-size: 1.2rem; color: var(--text); cursor: pointer;
}

/* ---- MOBILE MENU ---- */
.mobile-menu {
  display: none; position: fixed; top: var(--nav-height); left: 0; right: 0; bottom: 0;
  background: rgba(26,29,46,0.7); z-index: 99; backdrop-filter: blur(4px);
}
.mobile-menu.open { display: block; }
.mobile-menu-inner {
  background: var(--surface); padding: 1rem;
  display: flex; flex-direction: column; gap: 0.25rem;
  box-shadow: var(--shadow-lg);
}
.mobile-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1rem; border-radius: var(--radius-sm);
  font-weight: 500; color: var(--text); font-size: 1rem; transition: all 0.15s;
}
.mobile-link:hover { background: var(--primary-light); color: var(--primary); }
.mobile-link.danger { color: var(--danger); }
.mobile-link.accent { color: var(--primary); font-weight: 700; }

/* ---- MAIN CONTENT ---- */
.main-content {
  min-height: calc(100vh - var(--nav-height));
  padding-bottom: 5rem;
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 1rem; }
.container-sm { max-width: 760px; margin: 0 auto; padding: 0 1rem; }
.section { padding: 2.5rem 0; }

/* ---- BOTTOM NAV ---- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--surface); border-top: 1px solid var(--border);
  display: flex; height: var(--bottom-nav-height);
  box-shadow: 0 -4px 20px rgba(0,0,0,0.06);
}
.bn-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 0.2rem; font-size: 0.7rem; font-weight: 600;
  color: var(--text-light); transition: all 0.2s; padding: 0.5rem 0;
}
.bn-item i { font-size: 1.3rem; }
.bn-item.active { color: var(--primary); }
.bn-item:hover { color: var(--primary); }

/* ---- VISIBILITY HELPERS ---- */
.desktop-only { display: flex !important; }
.mobile-only { display: none !important; }

/* ---- MESSAGES / TOASTS ---- */
.messages-container {
  position: fixed; top: calc(var(--nav-height) + 0.75rem);
  right: 1rem; z-index: 200; display: flex; flex-direction: column; gap: 0.5rem;
  max-width: 360px;
}
.toast-msg {
  display: flex; align-items: center; justify-content: space-between; gap: 0.75rem;
  padding: 0.85rem 1rem; border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-md);
  border-left: 4px solid var(--primary); font-size: 0.9rem;
  animation: slideIn 0.3s ease;
}
.toast-msg.success { border-color: var(--success); }
.toast-msg.error { border-color: var(--danger); }
.toast-msg button { background: none; border: none; cursor: pointer; color: var(--text-muted); }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- CARDS ---- */
.card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: all 0.25s; box-shadow: var(--shadow);
}
.card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.card-body { padding: 1.25rem; }
.card-footer { padding: 0.875rem 1.25rem; border-top: 1px solid var(--border); background: var(--bg); }

/* ---- LESSON CARD ---- */
.lesson-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); overflow: hidden;
  transition: all 0.25s; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.lesson-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--accent); }
.lesson-card-header {
  padding: 1.25rem; display: flex; gap: 1rem; align-items: flex-start;
}
.lesson-emoji {
  font-size: 2.2rem; width: 56px; height: 56px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.lesson-card-title { font-size: 1rem; font-weight: 700; margin-bottom: 0.25rem; }
.lesson-card-desc { font-size: 0.85rem; color: var(--text-muted); line-height: 1.5; }
.lesson-card-footer {
  padding: 0.875rem 1.25rem; border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; background: var(--bg);
}

/* ---- BADGES ---- */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.65rem; border-radius: 100px;
  font-size: 0.75rem; font-weight: 700; font-family: var(--font);
  text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--success-light); color: #16a34a; }
.badge-warning { background: var(--warning-light); color: #d97706; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-teal { background: var(--teal-light); color: var(--teal); }
.badge-accent { background: var(--accent-light); color: var(--accent); }

/* ---- LEVEL BADGES ---- */
.level-beginner { background: var(--success-light); color: #16a34a; }
.level-elementary { background: var(--teal-light); color: var(--teal); }
.level-intermediate { background: var(--primary-light); color: var(--primary); }
.level-upper_intermediate { background: var(--purple-light); color: var(--purple); }
.level-advanced { background: var(--danger-light); color: var(--danger); }

/* ---- CATEGORY BADGES ---- */
.cat-vocabulary { background: #DCFCE7; color: #16a34a; }
.cat-grammar { background: #DBEAFE; color: #2563EB; }
.cat-reading { background: #FEF3C7; color: #D97706; }
.cat-listening { background: var(--purple-light); color: var(--purple); }
.cat-speaking { background: var(--danger-light); color: var(--danger); }
.cat-writing { background: var(--teal-light); color: var(--teal); }

/* ---- PROGRESS BAR ---- */
.progress-wrap { background: var(--border); border-radius: 100px; overflow: hidden; }
.progress-fill {
  height: 100%; border-radius: 100px;
  background: linear-gradient(90deg, var(--primary), #7B8FF8);
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-fill.accent { background: linear-gradient(90deg, var(--accent), #FF9A70); }
.progress-fill.success { background: linear-gradient(90deg, var(--success), #4ADE80); }

/* ---- STAT CARDS ---- */
.stat-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.stat-value { font-size: 1.6rem; font-weight: 800; font-family: var(--font); line-height: 1; }
.stat-label { font-size: 0.82rem; color: var(--text-muted); margin-top: 0.15rem; }

/* ---- QUIZ STYLES ---- */
.quiz-question {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 1.5rem; margin-bottom: 1.25rem;
}
.question-num {
  font-size: 0.8rem; font-weight: 700; color: var(--primary);
  text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 0.5rem;
}
.question-text { font-size: 1.05rem; font-weight: 600; margin-bottom: 1rem; }
.answer-options { display: flex; flex-direction: column; gap: 0.5rem; }
.answer-label {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); cursor: pointer;
  transition: all 0.2s; font-size: 0.95rem;
}
.answer-label:hover { border-color: var(--primary); background: var(--primary-light); }
.answer-label input[type="radio"] { display: none; }
.answer-label.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }
.answer-label.correct { border-color: var(--success); background: var(--success-light); color: #16a34a; }
.answer-label.incorrect { border-color: var(--danger); background: var(--danger-light); color: var(--danger); }
.answer-dot {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--border); display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; font-size: 0.75rem; transition: all 0.2s;
}

/* ---- VOCAB CARD ---- */
.vocab-card {
  background: var(--surface); border-radius: var(--radius);
  border: 1px solid var(--border); padding: 1.25rem;
  transition: all 0.2s;
}
.vocab-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.vocab-word { font-size: 1.3rem; font-weight: 800; font-family: var(--font); color: var(--primary); }
.vocab-pron { font-size: 0.85rem; color: var(--text-muted); font-style: italic; margin-top: 0.15rem; }
.vocab-def { font-size: 0.9rem; margin-top: 0.6rem; line-height: 1.6; }
.vocab-example {
  font-size: 0.85rem; color: var(--text-muted); margin-top: 0.5rem;
  border-left: 3px solid var(--primary-light); padding-left: 0.75rem;
  font-style: italic;
}

/* ---- HERO ---- */
.hero {
  background: linear-gradient(160deg, #FDF9F5 0%, #EDE5D8 100%);
  padding: 5rem 1rem 4.5rem; text-align: center; color: var(--text); position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 20% 60%, rgba(217,119,65,0.09) 0%, transparent 55%),
    radial-gradient(ellipse at 80% 40%, rgba(79,110,247,0.07) 0%, transparent 55%);
}
.hero-content { position: relative; max-width: 700px; margin: 0 auto; }
.hero h1 { font-size: clamp(2.25rem, 7vw, 4rem); font-weight: 800; margin-bottom: 1rem; line-height: 1.1; color: var(--text); }
.hero p { font-size: 1.15rem; color: var(--text-muted); margin-bottom: 2.25rem; }
.hero-actions { display: flex; gap: 0.75rem; justify-content: center; flex-wrap: wrap; }
.hero-cta {
  background: var(--text); color: #fff;
  padding: 0.9rem 2.1rem; border-radius: var(--radius-sm);
  font-weight: 700; font-family: var(--font); font-size: 1rem;
  transition: all 0.2s; display: inline-flex; align-items: center; gap: 0.5rem;
}
.hero-cta:hover { background: var(--primary); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(79,110,247,0.28); color: #fff; }
.hero-cta-secondary {
  border: 2px solid var(--border); color: var(--text);
  padding: 0.9rem 2.1rem; border-radius: var(--radius-sm);
  font-weight: 600; font-family: var(--font); font-size: 1rem;
  transition: all 0.2s; background: rgba(255,255,255,0.6);
}
.hero-cta-secondary:hover { background: #fff; border-color: var(--text-light); color: var(--text); }

/* ---- FILTERS ---- */
.filter-bar {
  display: flex; gap: 0.75rem; flex-wrap: wrap;
  padding: 1rem; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 1.5rem;
}
.filter-select, .filter-search {
  flex: 1; min-width: 140px;
  padding: 0.6rem 0.875rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-family: var(--font-body); font-size: 0.9rem; color: var(--text);
  transition: border-color 0.2s; outline: none;
}
.filter-select:focus, .filter-search:focus { border-color: var(--primary); }
.filter-btn {
  padding: 0.6rem 1.2rem; border-radius: var(--radius-sm);
  background: var(--primary); color: #fff; border: none;
  font-weight: 600; cursor: pointer; font-family: var(--font); transition: all 0.2s;
}
.filter-btn:hover { background: var(--primary-dark); }

/* ---- GRIDS ---- */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1.25rem; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem; }

/* ---- LEADERBOARD ---- */
.leaderboard-item {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface);
  margin-bottom: 0.5rem; transition: all 0.2s;
}
.leaderboard-item:hover { border-color: var(--primary); }
.lb-rank {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-family: var(--font); font-size: 0.95rem;
  flex-shrink: 0;
}
.lb-rank.gold { background: #FEF3C7; color: #D97706; }
.lb-rank.silver { background: #F1F5F9; color: #64748B; }
.lb-rank.bronze { background: #FEF0E7; color: #C2410C; }
.lb-rank.other { background: var(--bg); color: var(--text-muted); }
.lb-name { font-weight: 600; font-size: 0.95rem; }
.lb-xp { margin-left: auto; font-weight: 800; color: var(--warning); font-family: var(--font); }

/* ---- RESULTS ---- */
.result-correct { border-left: 4px solid var(--success); background: var(--success-light); }
.result-incorrect { border-left: 4px solid var(--danger); background: var(--danger-light); }
.result-score-circle {
  width: 120px; height: 120px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font); margin: 0 auto 1.5rem;
}
.score-percent { font-size: 2.5rem; font-weight: 800; line-height: 1; }
.score-label { font-size: 0.8rem; font-weight: 600; opacity: 0.8; }

/* ---- FORM STYLES ---- */
.auth-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 2rem; border: 1px solid var(--border); box-shadow: var(--shadow-md);
  max-width: 440px; margin: 2rem auto;
}
.auth-title { font-size: 1.8rem; text-align: center; margin-bottom: 0.4rem; }
.auth-sub { color: var(--text-muted); text-align: center; margin-bottom: 1.75rem; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-weight: 600; font-size: 0.875rem; margin-bottom: 0.4rem; }
.form-control {
  width: 100%; padding: 0.7rem 1rem; border-radius: var(--radius-sm);
  border: 1.5px solid var(--border); background: var(--bg);
  font-family: var(--font-body); font-size: 0.95rem; color: var(--text);
  outline: none; transition: border-color 0.2s;
}
.form-control:focus { border-color: var(--primary); background: #fff; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.3rem; }
.form-error { font-size: 0.82rem; color: var(--danger); margin-top: 0.3rem; }

/* ---- EMPTY STATE ---- */
.empty-state {
  text-align: center; padding: 4rem 2rem; color: var(--text-muted);
}
.empty-state-icon { font-size: 3.5rem; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.2rem; font-weight: 700; color: var(--text); margin-bottom: 0.5rem; }

/* ---- PAGE HEADER ---- */
.page-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border); margin-bottom: 2rem;
}
.page-header h1 { font-size: clamp(1.75rem, 4vw, 2.4rem); font-weight: 800; }
.page-header p { color: var(--text-muted); margin-top: 0.5rem; font-size: 1.05rem; }

/* ---- DIVIDER ---- */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

/* ---- FOOTER ---- */
.site-footer {
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 1.25rem; text-align: center; font-size: 0.85rem; color: var(--text-muted);
}
.footer-inner { display: flex; gap: 1rem; justify-content: center; align-items: center; flex-wrap: wrap; }
.brand-name-sm { font-family: var(--font); font-weight: 700; color: var(--primary); }

/* ---- LESSON CONTENT ---- */
.lesson-content { line-height: 1.85; font-size: 1.02rem; }
.lesson-content h2 {
  font-family: var(--font); font-size: 1.25rem; font-weight: 700;
  margin: 2rem 0 .6rem; color: var(--text);
  padding-bottom: .35rem; border-bottom: 2px solid var(--border);
}
.lesson-content h3 {
  font-family: var(--font); font-size: 1.05rem; font-weight: 600;
  margin: 1.5rem 0 .4rem; color: var(--primary);
}
.lesson-content h4 { font-family: var(--font); font-size: .95rem; font-weight: 600; margin: 1rem 0 .3rem; }
.lesson-content p { margin-bottom: 1rem; }
.lesson-content ul, .lesson-content ol { padding-left: 1.5rem; margin-bottom: 1rem; }
.lesson-content li { margin-bottom: .45rem; }
.lesson-content strong { color: var(--primary); font-weight: 600; }
.lesson-content em { color: var(--accent); font-style: italic; }
.lesson-content code {
  background: var(--primary-light); color: var(--primary);
  padding: .15rem .4rem; border-radius: 4px; font-size: .88em; font-family: monospace;
}
.lesson-content pre {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 1rem; margin-bottom: 1rem;
  overflow-x: auto;
}
.lesson-content pre code { background: none; color: var(--text); padding: 0; }
.lesson-content blockquote {
  border-left: 4px solid var(--primary); margin: 1rem 0;
  padding: .6rem 1rem; background: var(--primary-light);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-muted); font-style: italic;
}
.lesson-content table {
  width: 100%; border-collapse: collapse; margin-bottom: 1.25rem;
  font-size: .93rem; border-radius: var(--radius-sm); overflow: hidden;
}
.lesson-content th {
  background: var(--primary); color: #fff; font-weight: 600;
  padding: .6rem .9rem; text-align: left;
}
.lesson-content td { padding: .55rem .9rem; border-bottom: 1px solid var(--border); }
.lesson-content tr:nth-child(even) td { background: var(--surface-2); }
.lesson-content hr { border: none; border-top: 2px solid var(--border); margin: 1.75rem 0; }

/* ---- STREAKS ---- */
.streak-flame { font-size: 1.5rem; vertical-align: middle; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }
  .hamburger { display: flex; }
  .main-content { padding-bottom: calc(var(--bottom-nav-height) + 1rem); }
  .hero { padding: 3rem 1rem; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .auth-card { margin: 1rem; }
  .filter-bar { flex-direction: column; }
  .filter-select, .filter-search { min-width: unset; }
  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.3rem; }
  .page-header { padding: 1.25rem 0 1rem; }
  .section { padding: 1.5rem 0; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(3, 1fr); }
}

/* ---- ANIMATIONS ---- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fadeInUp 0.4s ease forwards; }
.animate-delay-1 { animation-delay: 0.1s; opacity: 0; }
.animate-delay-2 { animation-delay: 0.2s; opacity: 0; }
.animate-delay-3 { animation-delay: 0.3s; opacity: 0; }

/* ---- UTILS ---- */
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.fw-800 { font-weight: 800; font-family: var(--font); }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.flex-wrap { flex-wrap: wrap; }
.justify-between { justify-content: space-between; }
.w-100 { width: 100%; }

/* ===================================
   SPEECH / LISTENING / SPEAKING UI
   =================================== */

/* Speak button on vocab cards */
.speak-btn {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--teal-light); color: var(--teal);
  border: none; border-radius: 100px; cursor: pointer;
  font-size: .78rem; font-weight: 700; padding: .28rem .75rem;
  transition: background .15s, transform .1s;
  font-family: var(--font-body);
}
.speak-btn:hover  { background: var(--teal); color: #fff; }
.speak-btn:active { transform: scale(.94); }
.speak-btn.playing { background: var(--teal); color: #fff; animation: pulse-teal 1s infinite; }

@keyframes pulse-teal {
  0%, 100% { box-shadow: 0 0 0 0 rgba(20, 184, 166, .4); }
  50%       { box-shadow: 0 0 0 6px rgba(20, 184, 166, 0); }
}

/* Listen-to-lesson bar */
.listen-bar {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  background: var(--teal-light); border-radius: var(--radius-sm);
  padding: .75rem 1rem; margin-bottom: 1rem;
}
.listen-bar-label { font-size: .85rem; color: var(--teal); font-weight: 600; flex: 1; }
.listen-bar .speak-btn { font-size: .82rem; padding: .4rem 1rem; }

/* Record button */
.record-btn {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--danger-light); color: var(--danger);
  border: 2px solid var(--danger); border-radius: 100px;
  cursor: pointer; font-size: .875rem; font-weight: 700;
  padding: .55rem 1.25rem; transition: all .15s;
  font-family: var(--font-body);
}
.record-btn:hover     { background: var(--danger); color: #fff; }
.record-btn.recording { background: var(--danger); color: #fff; animation: pulse-red 1s infinite; }
.record-btn:disabled  { opacity: .45; cursor: not-allowed; }

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .4); }
  50%       { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* Speaking practice card */
.speaking-card {
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 2rem;
  text-align: center; margin-bottom: 1.5rem;
}
.speaking-sentence {
  font-size: 1.3rem; font-family: var(--font); font-weight: 600;
  line-height: 1.5; color: var(--text); margin: 1.25rem 0;
  min-height: 4rem;
}
.speaking-meta {
  font-size: .82rem; color: var(--text-muted); margin-bottom: .5rem;
}
.speaking-actions {
  display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap;
  margin-top: 1.25rem;
}

/* Score ring */
.score-ring-wrap {
  display: flex; flex-direction: column; align-items: center;
  margin: 1.25rem 0;
}
.score-ring {
  width: 110px; height: 110px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; font-family: var(--font);
  border: 6px solid var(--border); position: relative;
  transition: border-color .4s;
}
.score-ring.great  { border-color: var(--success); background: var(--success-light); }
.score-ring.good   { border-color: var(--warning); background: var(--warning-light); }
.score-ring.low    { border-color: var(--danger);  background: var(--danger-light);  }
.score-num  { font-size: 1.8rem; font-weight: 800; line-height: 1; }
.score-unit { font-size: .75rem; color: var(--text-muted); }

/* Word-by-word result */
.word-result {
  display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center;
  margin: .75rem 0; font-family: var(--font); font-size: .95rem;
}
.word-hit  { color: var(--success); font-weight: 700; }
.word-miss { color: var(--danger);  font-weight: 700; text-decoration: line-through; }

/* Transcript box */
.transcript-box {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .75rem 1rem;
  font-size: .875rem; color: var(--text-muted); margin-top: .75rem;
  min-height: 2.5rem; text-align: left;
}

/* Quiz listen button */
.quiz-listen-btn {
  display: inline-flex; align-items: center; gap: .3rem;
  background: none; border: 1px solid var(--teal);
  color: var(--teal); border-radius: 100px; cursor: pointer;
  font-size: .75rem; font-weight: 600; padding: .2rem .65rem;
  transition: all .15s; font-family: var(--font-body);
}
.quiz-listen-btn:hover { background: var(--teal); color: #fff; }

/* Not-supported banner */
.speech-unsupported {
  background: var(--warning-light); border: 1px solid var(--warning);
  border-radius: var(--radius-sm); padding: .75rem 1rem;
  font-size: .875rem; color: #92400e; margin-bottom: 1rem;
}

/* Voice switcher chips */
.voice-chip {
  background: none; border: 1px solid var(--border);
  border-radius: 100px; padding: .25rem .75rem;
  font-size: .78rem; font-weight: 600; cursor: pointer;
  color: var(--text-muted); font-family: var(--font-body);
  transition: all .15s;
}
.voice-chip:hover { border-color: var(--teal); color: var(--teal); }
.voice-chip.active { background: var(--teal); border-color: var(--teal); color: #fff; }

/* -- Chat -------------------------------------------------------- */
.chat-lobby-grid { display:grid; grid-template-columns:1fr 260px; gap:1.25rem; align-items:start; }
@media(max-width:700px){ .chat-lobby-grid { grid-template-columns:1fr; } }

.room-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:.6rem .75rem; border-radius:var(--radius-sm); text-decoration:none;
  color:var(--text); transition:background .15s; gap:.5rem;
  border-bottom:1px solid var(--border);
}
.room-row:last-child { border-bottom:none; }
.room-row:hover { background:var(--surface); color:var(--primary); }

.online-dot {
  display:inline-block; width:8px; height:8px;
  background:#22c55e; border-radius:50%; flex-shrink:0;
}

.online-user-row {
  display:flex; align-items:center; justify-content:space-between;
  padding:.4rem .3rem; border-bottom:1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); text-decoration: none;
  transition: background .15s;
}
.online-user-row:hover { background: var(--bg); }
.online-user-row:last-child { border-bottom:none; }

.dm-btn {
  background:none; border:1px solid var(--teal); color:var(--teal);
  border-radius:100px; padding:.2rem .55rem; cursor:pointer;
  font-size:.75rem; text-decoration:none; transition:all .15s;
}
.dm-btn:hover { background:var(--teal); color:#fff; }

.form-input {
  width:100%; border:1px solid var(--border); border-radius:var(--radius-sm);
  padding:.5rem .75rem; font-size:.875rem; font-family:var(--font-body);
  background:var(--surface); color:var(--text); box-sizing:border-box;
}
.form-input:focus { outline:none; border-color:var(--primary); }

/* ── Streak banner ───────────────────────────────────────── */
.streak-banner {
  background: linear-gradient(135deg, #fff7ed, #fff);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  display: flex; align-items: center;
  justify-content: space-between; flex-wrap: wrap; gap: 1rem;
}
.streak-flame {
  font-size: 2.2rem;
  display: inline-block;
  animation: flame 1.6s ease-in-out infinite alternate;
}
@keyframes flame {
  from { transform: scale(1) rotate(-4deg); }
  to   { transform: scale(1.18) rotate(4deg); }
}
.freeze-buy-btn {
  background: none; border: 1.5px solid #60a5fa; color: #2563eb;
  border-radius: 100px; padding: .3rem .9rem;
  font-size: .8rem; font-weight: 700; cursor: pointer;
  font-family: var(--font-body); transition: all .15s;
  white-space: nowrap;
}
.freeze-buy-btn:hover { background: #eff6ff; }

/* ── Dictation ───────────────────────────────────────────── */
.dictation-textarea {
  width: 100%; border: 2px solid var(--border); border-radius: var(--radius-sm);
  padding: .75rem 1rem; font-size: 1rem; font-family: var(--font-body);
  background: var(--surface); color: var(--text); resize: vertical;
  transition: border-color .2s; box-sizing: border-box;
}
.dictation-textarea:focus { outline: none; border-color: var(--primary); }
.dictation-textarea:disabled { background: var(--surface-2); color: var(--text-muted); }

/* ── AI Conversation bubbles ─────────────────────────────── */
.chat-bubble {
  max-width: 82%; padding: .75rem 1rem; border-radius: 1.1rem;
  font-size: .925rem; line-height: 1.65; word-wrap: break-word;
}
.chat-bubble p { margin: 0 0 .4rem; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble.user {
  align-self: flex-end; margin-left: auto;
  background: var(--primary); color: #fff;
  border-bottom-right-radius: .3rem;
}
.chat-bubble.ai {
  align-self: flex-start;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: .3rem;
}

/* ── Lesson: reading progress bar ───────────────────────────── */
.lesson-progress-bar {
  position: fixed; top: var(--nav-height); left: 0;
  height: 3px; width: 0; z-index: 99; pointer-events: none;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.12s ease;
}

/* ── Lesson: paragraph highlight (follow-along) ─────────────── */
.lesson-sentence { border-radius: 4px; transition: background 0.35s, box-shadow 0.35s; }
.lesson-sentence.reading {
  background: rgba(245, 158, 11, 0.13);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.18);
}

/* ── Lesson: vocab tooltip in text ──────────────────────────── */
.vocab-hl { border-bottom: 2px dotted var(--primary); cursor: help; position: relative; display: inline; }
.vocab-hl .vtip {
  display: none; position: absolute; bottom: calc(100% + 8px);
  left: 50%; transform: translateX(-50%);
  background: #1C1917; color: #fff;
  padding: .55rem .875rem; border-radius: 8px;
  font-size: .78rem; font-style: normal;
  min-width: 200px; max-width: 280px; z-index: 500;
  pointer-events: none; line-height: 1.65;
  text-align: left; white-space: normal;
  box-shadow: 0 4px 20px rgba(0,0,0,0.22);
}
.vocab-hl .vtip::after {
  content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 6px solid transparent;
  border-top-color: #1C1917;
}
.vocab-hl:hover .vtip { display: block; }

/* ── Lesson: vocabulary flashcards ──────────────────────────── */
@keyframes fcReveal {
  from { opacity: 0; transform: translateY(-5px); }
  to   { opacity: 1; transform: translateY(0); }
}
.flashcard-wrap {
  border-radius: var(--radius); cursor: pointer;
  border: 1.5px solid var(--border); background: var(--surface);
  overflow: hidden; transition: border-color .2s, box-shadow .2s;
}
.flashcard-wrap:hover { border-color: var(--primary); box-shadow: var(--shadow); }
.fc-front {
  padding: 1.25rem; display: flex; flex-direction: column;
  justify-content: space-between; min-height: 140px;
}
.fc-back {
  padding: 1.25rem; border-top: 1.5px solid var(--primary);
  background: var(--primary-light); display: none;
  animation: fcReveal .22s ease;
}
.flashcard-wrap.flipped .fc-front { display: none; }
.flashcard-wrap.flipped .fc-back  { display: block; }
.fc-hint { font-size: .72rem; color: var(--text-light); text-align: right; }

/* ── Lesson: fill in the blank ───────────────────────────────── */
.fitb-item {
  background: var(--surface-2); border-radius: var(--radius-sm);
  padding: .875rem 1rem; margin-bottom: .625rem;
  border: 1px solid var(--border);
}
.fitb-sentence { font-size: 1rem; line-height: 2.4; }
.fitb-input {
  border: none; border-bottom: 2.5px solid var(--primary);
  background: rgba(79,110,247,.09); color: var(--primary);
  font-size: .95rem; font-family: var(--font); font-weight: 600;
  padding: .1rem .4rem; min-width: 80px; max-width: 200px;
  outline: none; border-radius: 4px 4px 0 0;
  text-align: center; vertical-align: middle; transition: all .2s;
}
.fitb-input.correct { border-bottom-color: var(--success); background: var(--success-light); color: #15803d; }
.fitb-input.wrong   { border-bottom-color: var(--danger);  background: var(--danger-light);  color: var(--danger); }
