/* ============================================================
   Tux: Lingo Atlas — Celestial Atlas Editorial UI
   Aesthetic: antique atlas / star chart meets modern app
   ============================================================ */

:root {
  --font-serif: "Cormorant Garamond", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --serif: var(--font-serif);
  --sans: var(--font-sans);
  --mono: var(--font-mono);

  --gold-1: #f7e089;
  --gold-2: #c68a0c;
  --gold-3: #7c5303;
  --gold-grad: linear-gradient(135deg, #d49a18 0%, #c48b0e 50%, #af7805 100%);
  --gold-grad-soft: linear-gradient(135deg, rgba(212, 154, 24, 0.14) 0%, rgba(196, 139, 14, 0.14) 100%);
  --gold-glow: rgba(196, 139, 14, 0.28);
  --gold-btn-text: #0e1530;

  --skill-listening: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  --skill-speaking: linear-gradient(135deg, #9333ea 0%, #ec4899 100%);
  --skill-exam: linear-gradient(135deg, #059669 0%, #10b981 100%);
  --skill-vocab: linear-gradient(135deg, #ea580c 0%, #f59e0b 100%);
  --skill-arcade: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --skill-media: linear-gradient(135deg, #0284c7 0%, #0ea5e9 100%);

  --fire-flame: #ff5722;
  --fire-flame-glow: rgba(255, 87, 34, 0.35);
  --xp-cyan: #00d2ff;
  --gem-ruby: #f43f5e;

  --srs-tier-1: #f97316;
  --srs-tier-1-soft: rgba(249, 115, 22, 0.15);
  --srs-tier-1-text: #9a3412;
  --srs-tier-2: #f59e0b;
  --srs-tier-2-soft: rgba(245, 158, 11, 0.15);
  --srs-tier-2-text: #92400e;
  --srs-tier-3: #eab308;
  --srs-tier-3-soft: rgba(234, 179, 8, 0.15);
  --srs-tier-3-text: #854d0e;
  --srs-tier-4: #84cc16;
  --srs-tier-4-soft: rgba(132, 204, 22, 0.15);
  --srs-tier-4-text: #365314;
  --srs-tier-5: #10b981;
  --srs-tier-5-soft: rgba(16, 185, 129, 0.15);
  --srs-tier-5-text: #065f46;

  --success: #15803d;
  --success-soft: rgba(21, 128, 61, 0.12);
  --warning: #d97706;
  --warning-soft: rgba(217, 119, 6, 0.12);
  --error: #e05252;
  --error-soft: rgba(224, 82, 82, 0.12);
  --info: #0284c7;
  --info-soft: rgba(2, 132, 199, 0.12);
  --coral: var(--error);
  --coral-soft: var(--error-soft);
  --green: var(--success);
  --green-soft: var(--success-soft);

  --space-0-5: 4px;
  --space-1: 8px;
  --space-2: 16px;
  --space-3: 24px;
  --space-4: 32px;
  --space-5: 40px;
  --space-6: 48px;
  --space-8: 64px;

  --radius-xs: 4px;
  --radius-sm: 12px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --radius-pill: 9999px;
  --r-sm: var(--radius-sm);
  --r-md: var(--radius-md);
  --r-lg: var(--radius-lg);
  --r-xl: var(--radius-lg);
  --r-pill: var(--radius-pill);

  --font-h1: clamp(28px, 4vw + 12px, 56px);
  --font-h2: clamp(20px, 2.2vw + 10px, 34px);
  --font-h3: clamp(16px, 1.4vw + 10px, 24px);
  --font-sub: clamp(15px, 0.8vw + 12px, 18px);
  --font-body: clamp(14px, 0.5vw + 12px, 16px);
  --font-label: clamp(11px, 0.3vw + 10px, 13px);

  --shadow-sm: 0 1px 2px rgba(14, 21, 48, 0.04), 0 2px 6px rgba(14, 21, 48, 0.04);
  --shadow-md: 0 4px 12px rgba(14, 21, 48, 0.06), 0 12px 24px -4px rgba(14, 21, 48, 0.08);
  --shadow-lg: 0 8px 24px rgba(14, 21, 48, 0.08), 0 24px 48px -8px rgba(14, 21, 48, 0.12);
  --shadow-gold: 0 4px 14px rgba(196, 139, 14, 0.18), 0 10px 32px rgba(180, 130, 20, 0.22);
  --shadow-deep: 0 12px 36px rgba(14, 21, 48, 0.08), 0 32px 64px -12px rgba(14, 21, 48, 0.14);

  --gold-text: #8c5b05;

  --bg: #f8f6f0;
  --bg-soft: #f0ebe0;
  --bg-elev: #e8e1d0;
  --surface: #ffffff;
  --surface-hover: #f3eedf;
  --border: rgba(180, 130, 20, 0.25);
  --border-strong: rgba(180, 130, 20, 0.55);
  --text: #0e1530;
  --text-soft: #2a3460;
  --text-dim: #5c678a;
}

[data-theme="dark"] {
  --bg: #0a0e27;
  --bg-soft: #111739;
  --bg-elev: #1a2350;
  --surface: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 255, 255, 0.1);
  --border: rgba(232, 185, 53, 0.22);
  --border-strong: rgba(232, 185, 53, 0.5);
  --text: #eef1ff;
  --text-soft: #b8c0e6;
  --text-dim: #8892bf;

  --gold-1: #f7e089;
  --gold-2: #e8b935;
  --gold-3: #b8860b;
  --gold-grad: linear-gradient(135deg, #d4a520 0%, #caa01e 50%, #b8860b 100%);
  --gold-grad-soft: linear-gradient(135deg, rgba(212, 165, 32, 0.18) 0%, rgba(202, 160, 30, 0.18) 100%);
  --gold-glow: rgba(232, 185, 53, 0.35);
  --gold-btn-text: #0a0e27;

  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.15);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, 0.15);
  --error: #ff6b6b;
  --error-soft: rgba(255, 107, 107, 0.15);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.15);
  --coral: var(--error);
  --coral-soft: var(--error-soft);
  --green: var(--success);
  --green-soft: var(--success-soft);

  --srs-tier-1-text: var(--srs-tier-1);
  --srs-tier-2-text: var(--srs-tier-2);
  --srs-tier-3-text: var(--srs-tier-3);
  --srs-tier-4-text: var(--srs-tier-4);
  --srs-tier-5-text: var(--srs-tier-5);

  --gold-text: #f7e089;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.35), 0 12px 32px -4px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.45), 0 24px 60px -8px rgba(0, 0, 0, 0.6);
  --shadow-gold: 0 4px 16px rgba(232, 185, 53, 0.18), 0 12px 40px rgba(232, 185, 53, 0.28);
  --shadow-deep: 0 16px 40px rgba(0, 0, 0, 0.5), 0 36px 80px -10px rgba(0, 0, 0, 0.65);
}

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

html { scroll-behavior: smooth; }

html, body {
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  transition: background 0.4s ease, color 0.4s ease;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: url("img/atlas_bg_dark.png");
  background-size: cover;
  background-position: center;
  opacity: 0.18;
  z-index: -2;
  pointer-events: none;
}

[data-theme="light"] body::before {
  opacity: 0.04;
  filter: contrast(0.8) brightness(1.1);
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 56px 56px;
  opacity: 0.4;
  z-index: -1;
  pointer-events: none;
  mask-image: radial-gradient(circle at center, black 30%, transparent 75%);
}

a { color: inherit; text-decoration: none; }

h1, .h1 {
  font-family: var(--serif);
  font-size: var(--font-h1);
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.025em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

h2, .h2 {
  font-family: var(--serif);
  font-size: var(--font-h2);
  font-weight: 600;
  line-height: 1.22;
  letter-spacing: -0.02em;
  text-wrap: balance;
  overflow-wrap: break-word;
}

h3, .h3 {
  font-family: var(--sans);
  font-size: var(--font-h3);
  font-weight: 700;
  line-height: 1.3;
  text-wrap: balance;
  overflow-wrap: break-word;
}

p, .body-text {
  font-size: var(--font-body);
  line-height: 1.6;
}

.sub-label, .small-label {
  font-size: var(--font-label);
  line-height: 1.4;
}

/* ============ TOP NAV ============ */
.topnav {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px);
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  border-bottom: 1px solid var(--border);
}

.topnav-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 100%;
  box-sizing: border-box;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 22px;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.brand-logo {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: transparent;
  display: grid;
  place-items: center;
  overflow: visible;
  flex-shrink: 0;
  border: none;
  box-shadow: none;
}

.brand-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.15));
  transition: transform 0.2s ease;
}

.brand-logo:hover img {
  transform: scale(1.08);
}

/* Sửa lỗi text trên nền gradient vàng bị chìm 1 bên */
.brand-name,
.hero h1 em,
.hero-stat .num,
.flashcard-word,
.vocab-popup h4 {
  background: var(--gold-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  display: inline-block;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}

[data-theme="light"] .brand-name,
[data-theme="light"] .hero h1 em,
[data-theme="light"] .hero-stat .num,
[data-theme="light"] .flashcard-word,
[data-theme="light"] .vocab-popup h4 {
  /* Ở light theme, dùng màu vàng hổ phách đậm đồng đều, không dùng gradient sáng chói dễ chìm */
  background: none;
  -webkit-background-clip: unset;
  background-clip: unset;
  color: #926405;
  filter: none;
  font-weight: 700;
}

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: transparent;
  display: grid;
  place-items: center;
  overflow: visible;
  flex-shrink: 0;
  border: none;
  box-shadow: none;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}

.nav-links a {
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-soft);
  transition: all 0.25s ease;
  white-space: nowrap;
}

.nav-links a:hover { color: var(--text); background: var(--surface-hover); }

.nav-links a.active {
  color: var(--gold-btn-text);
  background: var(--gold-grad);
  box-shadow: var(--shadow-gold);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-launcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  height: 40px;
  border-radius: var(--r-pill);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--gold-2);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  white-space: nowrap;
}

.nav-launcher-btn:hover {
  background: var(--gold-grad-soft);
  border-color: var(--gold-2);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(232, 185, 53, 0.18);
}

.nav-launcher-btn:active {
  transform: scale(0.96);
}

.nav-launcher-btn .launcher-icon {
  font-size: 15px;
  line-height: 1;
}

.nav-launcher-btn .launcher-text {
  font-size: 12px;
  letter-spacing: 0.02em;
}

.theme-toggle {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--gold-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 18px;
  transition: all 0.25s ease;
}

/* Nút Hamburger menu */
.hamburger-btn {
  display: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  place-items: center;
  transition: all 0.2s ease;
}

.hamburger-btn:hover {
  background: var(--surface-hover);
  border-color: var(--gold-2);
}

/* Sidebar Drawer Mobile */
.mobile-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  z-index: 998;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.mobile-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  background: var(--bg);
  z-index: 999;
  display: flex;
  flex-direction: column;
  transform: translateY(-100%);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease;
  box-shadow: none;
}

.mobile-sidebar.open {
  transform: translateY(0);
  opacity: 1;
}

.mobile-sidebar-head {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.sidebar-app-count-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  background: var(--gold-grad-soft);
  border: 1px solid var(--gold-2);
  color: var(--gold-2);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mobile-sidebar-close {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 20px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.mobile-sidebar-close:active {
  background: var(--surface-hover);
  transform: scale(0.94);
}

/* App Launcher Grid View */
.mobile-sidebar-dashboard {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 1024px) {
  .mobile-sidebar-dashboard {
    max-width: 960px;
    margin: 0 auto;
    width: 100%;
  }
}

.sidebar-store-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-section-title {
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-2);
  padding: 0 4px;
}

/* Launcher Grid: 3 cột trên mobile chuẩn, 4 cột trên tablet */
.sidebar-app-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

@media (min-width: 480px) {
  .sidebar-app-list {
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
  }
}

.sidebar-app-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  text-align: center;
  padding: 16px 8px 12px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
  overflow: hidden;
  min-height: 120px;
}

.sidebar-app-card:hover, .sidebar-app-card:active {
  border-color: var(--gold-2);
  transform: translateY(-3px) scale(0.98);
  background: var(--surface-hover);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.sidebar-app-card.active {
  background: var(--gold-grad-soft);
  border-color: var(--gold-2);
  box-shadow: 0 4px 16px rgba(232, 185, 53, 0.25);
}

.sidebar-app-icon {
  width: 58px;
  height: 58px;
  background: transparent;
  border: none;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  margin-bottom: 8px;
  box-shadow: none;
  transition: transform 0.2s ease;
}

.sidebar-app-card:active .sidebar-app-icon {
  transform: scale(0.95);
}

.sidebar-app-icon .sprite-icon {
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -85px;
  margin-top: -120px;
  transform: scale(0.24);
  transform-origin: center center;
}

.sidebar-app-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.sidebar-app-info h5 {
  font-size: 12.5px;
  font-weight: 700;
  margin: 0 0 2px;
  color: var(--text);
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-app-info span {
  display: none; /* Ẩn subtitle dài trong chế độ icon grid launcher */
}

.sidebar-app-badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--gold-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.sidebar-app-card.active .sidebar-app-badge {
  background: var(--gold-grad);
  color: var(--gold-btn-text);
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(232, 185, 53, 0.35);
}

/* Fallback legacy link */
.mobile-sidebar-links {
  display: none;
}

.mobile-sidebar-footer {
  margin-top: auto;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
}

.streak-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-weight: 700;
  font-size: 14px;
}

.container {
  max-width: 1320px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-3) calc(var(--space-8) + 32px);
}

/* ============ HERO ============ */
.hero {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 40px;
  align-items: center;
  padding: 40px 0 20px;
  position: relative;
}

.hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  background: var(--coral-soft);
  color: var(--coral);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--coral) 30%, transparent);
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(32px, 4.5vw + 14px, 64px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.025em;
  margin-bottom: var(--space-3);
  text-wrap: balance;
}

.hero h1 em {
  font-style: italic;
}

.hero-lead {
  font-size: var(--font-sub);
  color: var(--text-soft);
  max-width: 540px;
  line-height: 1.65;
  margin-bottom: var(--space-4);
}

.hero-cta {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-weight: 700;
  font-size: 15px;
  border: none;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: var(--gold-grad);
  color: var(--gold-btn-text);
  box-shadow: var(--shadow-gold);
}

.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 48px rgba(232, 185, 53, 0.35); }

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-ghost:hover { background: var(--surface-hover); transform: translateY(-2px); }

.btn-soft {
  background: var(--gold-grad-soft);
  color: var(--gold-text, var(--gold-2));
  border: 1px solid var(--border);
}

.btn-soft:hover { background: var(--surface-hover); color: var(--gold-2); }

.hero-stats {
  display: flex;
  gap: 32px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.hero-stat .num {
  font-family: var(--serif);
  font-size: 38px;
  font-weight: 600;
  line-height: 1;
}

.hero-stat .label {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
  letter-spacing: 0.02em;
}

.hero-visual {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: clamp(260px, 34vw, 440px);
  overflow: visible;
  max-width: 100%;
}

.hero-mascot {
  position: relative;
  z-index: 2;
  width: clamp(200px, 25vw, 320px);
  max-width: 100%;
  aspect-ratio: 2/3;
  height: auto;
  display: block;
  margin: 0 auto;
  filter: drop-shadow(0 20px 40px rgba(180, 130, 20, 0.25));
  animation: float 5s ease-in-out infinite;
  min-height: unset;
}

.hero-globe {
  position: absolute;
  width: 90%;
  max-width: 440px;
  opacity: 0.22;
  animation: spin 70s linear infinite;
  pointer-events: none;
}

[data-theme="dark"] .hero-globe {
  opacity: 0.35;
}

@keyframes spin { to { transform: rotate(360deg); } }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}

.hero-compass {
  position: absolute;
  width: 90px;
  z-index: 3;
  animation: float 4s ease-in-out infinite;
}

.hero-compass.c1 { top: 8%; right: 4%; transform: rotate(-15deg); }
.hero-compass.c2 { bottom: 12%; left: 0; width: 70px; transform: rotate(20deg); animation-delay: 1s; }

/* ============ AI DAILY CARD ============ */
.ai-daily {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--gold-grad-soft);
  border: 1px solid var(--border-strong);
  margin: var(--space-4) 0 var(--space-6);
  position: relative;
  overflow: hidden;
}

.ai-daily-header {
  display: contents;
}

.ai-daily::after {
  content: "";
  position: absolute;
  top: -50%;
  right: -10%;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(232, 185, 53, 0.25), transparent 70%);
  pointer-events: none;
}

.ai-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: transparent;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: none;
  border: none;
}

.ai-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.15));
}

.ai-daily-text .tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin-bottom: 6px;
}

.ai-daily-text .msg {
  font-size: 16px;
  color: var(--text);
  line-height: 1.5;
}

.ai-daily-text .msg strong { color: var(--gold-2); }

/* ============ SECTION HEAD ============ */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--space-6) 0 var(--space-3);
}

.section-head h2 {
  font-family: var(--serif);
  font-size: var(--font-h2);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.section-head h2::after {
  content: "";
  display: block;
  width: 60px;
  height: 3px;
  background: var(--gold-grad);
  border-radius: var(--radius-xs);
  margin-top: var(--space-1);
}

.section-head .see-all {
  font-size: 14px;
  color: var(--gold-2);
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
}

/* ============ FEATURE GRID (editorial, asymmetric) ============ */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: 1fr;
  gap: 24px;
}

@media (min-width: 1024px) {
  .feature-card.wide {
    grid-column: span 2;
  }
  .feature-card.feature-card-full,
  .feature-grid > .feature-card:last-child {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 20px;
  }
}

.feature-card {
  position: relative;
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.3s ease;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
}

.feature-card.wide { grid-column: span 2; }
.feature-card.tall { grid-row: span 2; }

.feature-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-2);
  box-shadow: var(--shadow-md);
}

.feature-card .feature-img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  margin-bottom: 14px;
  display: block;
  transition: transform 0.3s ease;
}

.sprite-icon-box {
  width: 140px;
  height: 140px;
  margin: 0 auto var(--space-2);
  overflow: hidden;
  position: relative;
  border-radius: var(--radius-lg);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mascot-tux-sprite {
  width: 85px;
  height: 120px;
  background-repeat: no-repeat;
  background-size: 680px 120px;
  animation: play-tux-sprite 1.2s steps(8) infinite;
  display: inline-block;
  flex-shrink: 0;
}

.mascot-tux-stage {
  width: 170px;
  height: 240px;
  background-repeat: no-repeat;
  background-size: 1360px 240px;
  animation: play-tux-stage 1.2s steps(8) infinite;
  display: inline-block;
  flex-shrink: 0;
}

.mascot-tux-large {
  width: 255px;
  height: 360px;
  background-repeat: no-repeat;
  background-size: 2040px 360px;
  animation: play-tux-large 1.2s steps(8) infinite;
  display: inline-block;
  flex-shrink: 0;
}

.sprite-icon {
  width: 170px;
  height: 240px;
  background-repeat: no-repeat;
  background-size: 1360px 240px;
  transform: scale(0.55);
  transform-origin: center center;
  transition: transform 0.25s ease;
  animation: play-tux-stage 1.2s steps(8) infinite;
}

@keyframes play-tux-sprite {
  from { background-position: 0 0; }
  to { background-position: -680px 0; }
}

@keyframes play-tux-stage {
  from { background-position: 0 0; }
  to { background-position: -1360px 0; }
}

@keyframes play-tux-large {
  from { background-position: 0 0; }
  to { background-position: -2040px 0; }
}

.sprite-exam,
.sprite-study,
.feat-study,
.feat-exam {
  background-image: url("img/mascot-sprite/tux_gold_01_study.png");
}

.sprite-dictation,
.feat-dictation {
  background-image: url("img/mascot-sprite/tux_gold_02_dictation.png");
}

.sprite-speaking,
.feat-speaking {
  background-image: url("img/mascot-sprite/tux_gold_03_speaking.png");
}

.sprite-vocab,
.feat-vocab {
  background-image: url("img/mascot-sprite/tux_gold_04_vocabulary.png");
}

.sprite-shadowing,
.feat-shadowing {
  background-image: url("img/mascot-sprite/tux_gold_05_shadowing.png");
}

.sprite-arcade,
.sprite-gaming,
.feat-gaming,
.feat-arcade {
  background-image: url("img/mascot-sprite/tux_gold_06_gaming.png");
}

.sprite-studio,
.sprite-teacher,
.feat-teacher,
.feat-studio {
  background-image: url("img/mascot-sprite/tux_gold_07_teacher.png");
}

.sprite-roadmap,
.feat-roadmap {
  background-image: url("img/mascot-sprite/tux_gold_08_roadmap.png");
}

.feature-card:hover .sprite-icon {
  transform: scale(0.6);
}

.feature-card.tall .feature-img { height: 180px; }

.feature-card h3 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 6px;
}

.feature-card p {
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.55;
}

.feature-card .ai-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  align-self: flex-start;
  margin-top: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--coral-soft);
  color: var(--coral);
  font-size: 11px;
  font-weight: 700;
}



/* ============ EXAM GRID ============ */
.exam-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
}

.exam-card {
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all 0.25s ease;
  cursor: pointer;
}

.exam-card:hover {
  border-color: var(--gold-2);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.exam-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--gold-grad-soft);
  color: var(--gold-2);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: var(--space-2);
  border: 1px solid var(--border);
}

.exam-card h3 {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  margin-bottom: 8px;
}

.exam-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 18px;
}

/* ============ EXAM PLAYER ============ */
.exam-player {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 28px;
  max-width: 100%;
}

.question-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  max-width: 100%;
  box-sizing: border-box;
}

.part-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--coral-soft);
  color: var(--coral);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 18px;
}

.question-image {
  width: 100%;
  max-height: 340px;
  object-fit: cover;
  border-radius: 16px;
  margin-bottom: 22px;
  background: var(--bg-elev);
}

.question-text {
  font-size: 17px;
  line-height: 1.6;
  margin-bottom: 18px;
}

.audio-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  background: var(--bg-elev);
  border-radius: 14px;
  margin-bottom: 22px;
  border: 1px solid var(--border);
}

.audio-play {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gold-grad);
  border: none;
  color: var(--gold-btn-text);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: transform 0.15s;
}

.audio-play:hover { transform: scale(1.08); }

.audio-wave {
  flex: 1;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 240px;
}

.audio-wave span {
  flex: 0 0 4px;
  width: 4px;
  max-width: 6px;
  min-height: 6px;
  background: var(--gold-grad);
  border-radius: 3px;
  animation: wave 1.2s ease-in-out infinite;
  opacity: 0.4;
}

.audio-wave.playing span { opacity: 1; }

.audio-wave span:nth-child(odd) { animation-delay: 0.3s; }
.audio-wave span:nth-child(3n) { animation-delay: 0.6s; }

@keyframes wave {
  0%, 100% { height: 20%; }
  50% { height: 100%; }
}

.choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: var(--space-2) var(--space-3);
  background: var(--bg-elev);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.choice:hover { border-color: var(--gold-2); }

.choice.selected {
  border-color: var(--gold-2);
  background: var(--gold-grad-soft);
}

.choice.correct { border-color: var(--green); background: var(--green-soft); }

.choice.wrong { border-color: var(--coral); background: var(--coral-soft); }

.choice-letter {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 14px;
  flex-shrink: 0;
}

.choice-text { flex: 1; font-size: 15px; line-height: 1.5; }

.choice-vi {
  display: block;
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

.vocab-link {
  color: var(--gold-text, var(--gold-2));
  border-bottom: 1px dashed var(--gold-text, var(--gold-2));
  cursor: pointer;
  font-weight: 600;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.vocab-link:hover { color: var(--gold-1); border-bottom-color: var(--gold-1); }

.falling-word {
  color: var(--gold-text, var(--gold-2));
}

/* ============ AI EXPLAIN PANEL ============ */
.ai-explain {
  margin-top: 22px;
  padding: 18px 22px;
  border-radius: 16px;
  background: var(--gold-grad-soft);
  border: 1px solid var(--border);
  display: none;
}

.ai-explain.show { display: block; animation: fadeUp 0.3s ease; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-explain-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.ai-explain-head .tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-2);
}

.ai-explain-body {
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text-soft);
}

.ai-explain-body strong { color: var(--text); }

/* ============ PROGRESS SIDEBAR & STUDY4 EXAM PALETTE ============ */
.progress-sidebar,
.exam-palette {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 24px;
  height: fit-content;
  position: sticky;
  top: 90px;
  box-shadow: var(--shadow-sm);
}

.timer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--gold-2);
  margin-bottom: var(--space-3);
  padding: var(--space-2);
  background: var(--bg-elev);
  border-radius: var(--radius-md);
  font-family: var(--mono);
}

.progress-head-row,
.exam-palette-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.toggle-grid-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  min-height: 28px;
  font-size: 11px;
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.toggle-grid-btn:hover {
  border-color: var(--gold-2);
  color: var(--text);
}

.question-grid,
.palette-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  max-height: calc(100vh - 340px);
  overflow-y: auto;
  padding-right: 4px;
  margin-bottom: var(--space-2);
}

.question-grid button,
.palette-item {
  aspect-ratio: 1;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-dim);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.question-grid button:hover,
.palette-item:hover {
  border-color: var(--gold-2);
  color: var(--text);
}

.question-grid button.answered,
.palette-item.answered {
  background: var(--gold-grad);
  color: var(--gold-btn-text);
  border-color: transparent;
  box-shadow: 0 2px 6px var(--gold-glow);
}

.question-grid button.flagged,
.palette-item.flagged {
  border-color: var(--warning);
  color: #92400e;
  background: var(--warning-soft);
  position: relative;
}

[data-theme="dark"] .question-grid button.flagged,
[data-theme="dark"] .palette-item.flagged {
  color: var(--warning);
}

.question-grid button.flagged::after,
.palette-item.flagged::after {
  content: "⚑";
  position: absolute;
  top: 2px;
  right: 3px;
  font-size: 8px;
}

.question-grid button.current,
.question-grid button.active,
.palette-item.current,
.palette-item.active {
  outline: 2px solid var(--coral);
  outline-offset: 1px;
}

.question-grid button.unanswered,
.palette-item.unanswered {
  background: var(--bg-elev);
  color: var(--text-dim);
  border-color: var(--border);
}

.nav-buttons {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}

.nav-buttons .btn { flex: 1; justify-content: center; }

/* ============ DICTATION ============ */
.dictation-player {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  margin-bottom: 22px;
}

.dictation-sentence {
  font-family: var(--serif);
  font-size: 28px;
  line-height: 1.6;
  margin-bottom: 24px;
  min-height: 80px;
}

.dictation-blank {
  display: inline-block;
  min-width: 100px;
  border-bottom: 2px solid var(--gold-2);
  margin: 0 4px;
  padding: 0 6px;
  color: var(--gold-2);
  font-weight: 700;
}

.dictation-input {
  width: 100%;
  padding: 18px 20px;
  background: var(--bg-elev);
  border: 2px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 17px;
  font-family: var(--sans);
  outline: none;
  transition: border-color 0.2s;
}

.dictation-input:focus { border-color: var(--gold-2); }

.dictation-controls {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}

/* ============ AI SPEAKING PAGE ============ */
/* ============ MINIMAL AI LIVE SPEAKING (ChatGPT Voice / Gemini Live Style) ============ */
.voice-stage-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 140px);
  position: relative;
  padding: 20px 16px 40px;
  overflow: hidden;
}

.voice-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 680px;
  margin-bottom: 24px;
}

.voice-scenario-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s ease;
}

.voice-scenario-badge:hover {
  border-color: var(--gold-2);
  background: var(--surface-hover);
}

.voice-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.voice-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 600;
  color: var(--text-soft);
  cursor: pointer;
  transition: all 0.2s ease;
}

.voice-action-btn:hover {
  border-color: var(--gold-2);
  color: var(--text);
}

.voice-avatar-stage {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 240px;
  height: 240px;
  margin: 10px 0 30px;
}

.voice-pulse-ring {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  border: 2px solid rgba(232, 185, 53, 0.25);
  animation: voiceGlow 2.4s ease-out infinite;
  pointer-events: none;
}

.voice-pulse-ring:nth-child(2) {
  inset: -45px;
  border-color: rgba(232, 185, 53, 0.12);
  animation-delay: 0.8s;
}

@keyframes voiceGlow {
  0% { transform: scale(0.92); opacity: 0.8; }
  50% { transform: scale(1.05); opacity: 0.3; }
  100% { transform: scale(0.92); opacity: 0.8; }
}

.voice-avatar-disc {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 185, 53, 0.18) 0%, rgba(13, 21, 38, 0.6) 75%);
  border: 2px solid rgba(232, 185, 53, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 40px rgba(232, 185, 53, 0.2);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.voice-stage-container.ai-speaking .voice-avatar-disc {
  border-color: var(--gold-2);
  box-shadow: 0 0 45px rgba(232, 185, 53, 0.5);
}

.voice-stage-container.user-listening .voice-avatar-disc {
  border-color: var(--coral);
  box-shadow: 0 0 45px rgba(255, 107, 107, 0.4);
}

/* Mascot Sprite Lipsync Animation (tux_ai_speaking_assistant.png) */
.voice-mascot-sprite {
  width: 340px;
  height: 480px;
  background-image: url("img/tux_ai_speaking_assistant.png");
  background-repeat: no-repeat;
  background-size: 2720px 480px;
  background-position: 0 0;
  transform: scale(0.32);
  transform-origin: center center;
  flex-shrink: 0;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

.voice-stage-container.ai-speaking .voice-mascot-sprite {
  animation: tuxLipsyncRun 1.1s steps(8) infinite;
}

@keyframes tuxLipsyncRun {
  from { background-position: 0 0; }
  to { background-position: -2720px 0; }
}

/* Subtitle live captions */
.voice-subtitle-box {
  width: 100%;
  max-width: 640px;
  text-align: center;
  margin-bottom: 30px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.voice-speaker-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-2);
  margin-bottom: 6px;
}

.voice-subtitle-text {
  font-family: var(--serif);
  font-size: 24px;
  line-height: 1.45;
  color: var(--text);
  transition: opacity 0.2s ease;
}

.voice-subtitle-feedback {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-dim);
  font-family: var(--sans);
}

.voice-subtitle-feedback .good { color: var(--green); font-weight: 600; }
.voice-subtitle-feedback .bad { color: var(--coral); font-weight: 600; }

/* Control dock bar */
.voice-dock {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 12px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  backdrop-filter: blur(12px);
}

.voice-mic-main {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--gold-grad);
  color: var(--gold-btn-text);
  border: none;
  font-size: 26px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 6px 20px rgba(232, 185, 53, 0.35);
}

.voice-mic-main:hover {
  transform: scale(1.08);
}

.voice-mic-main.recording {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 0 25px rgba(255, 107, 107, 0.6);
  animation: pulseMic 1.2s infinite;
}

@keyframes pulseMic {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.voice-dock-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all 0.2s ease;
}

.voice-dock-btn:hover {
  border-color: var(--gold-2);
  transform: scale(1.06);
}

/* Chat logs drawer modal */
.chat-logs-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  justify-content: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.chat-logs-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.chat-logs-drawer {
  width: 100%;
  max-width: 460px;
  height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: -10px 0 40px rgba(0, 0, 0, 0.3);
}

.chat-logs-modal.open .chat-logs-drawer {
  transform: translateX(0);
}

.chat-logs-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
}

.chat-logs-head h3 {
  font-size: 17px;
  font-weight: 700;
  margin: 0;
}

.chat-logs-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.chat-logs-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Scenario selector modal */
.scenario-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.scenario-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.scenario-box {
  width: 100%;
  max-width: 520px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.4);
}

.scenario-grid-list {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 16px;
}

@media (max-width: 480px) {
  .scenario-grid-list {
    grid-template-columns: 1fr;
  }
}

.speaking-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 28px;
}

.speaking-main {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
}

.chat-messages {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
  overflow-y: auto;
  max-height: 420px;
  padding-right: 8px;
}

.chat-msg {
  display: flex;
  gap: 12px;
  max-width: 85%;
}

.chat-msg.ai { align-self: flex-start; }

.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }

.chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  font-size: 20px;
}

.chat-msg.ai .chat-avatar {
  background: transparent;
  border: none;
  overflow: visible;
  padding: 0;
}

.chat-msg.ai .chat-avatar img {
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.15));
}
.chat-msg.user .chat-avatar { background: var(--coral-soft); border: 1px solid var(--coral); }

.chat-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.55;
}

.chat-msg.ai .chat-bubble {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
}

.chat-msg.user .chat-bubble {
  background: var(--gold-grad);
  color: var(--gold-btn-text);
  border-top-right-radius: 4px;
  font-weight: 600;
}

.chat-bubble .feedback {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-dim);
}

.chat-bubble .feedback .good { color: var(--green); }
.chat-bubble .feedback .bad { color: var(--coral); }

.speaking-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.record-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: var(--coral);
  color: white;
  font-size: 24px;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  transition: all 0.2s;
  box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.5);
}

.record-btn.recording {
  animation: pulse 1.5s infinite;
  background: #c92a2a;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0.6); }
  70% { box-shadow: 0 0 0 20px rgba(255, 107, 107, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 107, 0); }
}

.speaking-input {
  flex: 1;
  padding: 16px 20px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 14px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--sans);
  outline: none;
  min-width: 0;
}

@media (max-width: 768px) {
  .speaking-main {
    padding: 20px 16px;
    border-radius: 20px;
  }
  .chat-msg {
    max-width: 92%;
  }
  .speaking-controls {
    flex-wrap: wrap;
    gap: 10px;
  }
  .record-btn {
    width: 52px;
    height: 52px;
    font-size: 22px;
  }
  .speaking-input {
    width: calc(100% - 62px);
    padding: 12px 14px;
    font-size: 14px;
  }
  #sendBtn {
    width: 100%;
    justify-content: center;
    padding: 12px;
  }
}

.speaking-input:focus { border-color: var(--gold-2); }

.speaking-scenes {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  height: fit-content;
  position: sticky;
  top: 90px;
}

.scene-card {
  padding: 16px;
  border-radius: 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  margin-bottom: 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.scene-card:hover { border-color: var(--gold-2); }

.scene-card.active {
  border-color: var(--gold-2);
  background: var(--gold-grad-soft);
}

.scene-card h4 {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 4px;
}

.scene-card p { font-size: 12px; color: var(--text-dim); }

/* ============ VOCAB FLASHCARD ============ */
.flashcard-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.flashcard,
.flashcard-flip-container {
  width: 100%;
  max-width: 560px;
  aspect-ratio: 3/2;
  perspective: 1400px;
  cursor: pointer;
  user-select: none;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner,
.flashcard-flip-container.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

.flashcard-face,
.flashcard-front,
.flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  border: 2px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.flashcard:hover .flashcard-face,
.flashcard:hover .flashcard-front,
.flashcard-flip-container:hover .flashcard-front {
  border-color: var(--gold-2);
  box-shadow: var(--shadow-gold);
}

.flashcard-front::before {
  content: "";
  position: absolute;
  inset: 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  pointer-events: none;
}

.flashcard-back {
  transform: rotateY(180deg);
  background: var(--gold-grad-soft);
}

.flashcard-word {
  font-family: var(--serif);
  font-size: 52px;
  font-weight: 600;
  margin-bottom: 12px;
}

.flashcard-ipa {
  font-size: 18px;
  color: var(--text-dim);
  margin-bottom: 16px;
  font-style: italic;
}

.flashcard-meaning {
  font-family: var(--serif);
  font-size: 30px;
  font-weight: 600;
  margin-bottom: 10px;
}

.flashcard-pos {
  color: var(--coral);
  font-style: italic;
  font-size: 14px;
  margin-bottom: 14px;
}

.flashcard-example {
  font-size: 15px;
  color: var(--text-soft);
  font-style: italic;
  max-width: 400px;
}

.flashcard-actions {
  display: flex;
  gap: var(--space-2);
}

/* ============ VOCAB LIST ============ */
.vocab-table {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  overflow: hidden;
}

.vocab-row {
  display: grid;
  grid-template-columns: 1fr 1fr 100px 100px 120px 40px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  transition: background 0.2s;
}

.vocab-row:last-child { border-bottom: none; }

.vocab-row:hover { background: var(--surface-hover); }

.vocab-row .word {
  font-weight: 700;
  color: var(--gold-2);
  font-size: 16px;
}

.vocab-row .meaning { color: var(--text-soft); font-size: 14px; }

@media (min-width: 1024px) {
  .vocab-dual-layout {
    display: grid;
    grid-template-columns: 460px minmax(0, 1fr);
    gap: var(--space-4);
    align-items: start;
  }
  .vocab-pane-left {
    position: sticky;
    top: 88px;
    max-height: calc(100vh - 104px);
    overflow-y: auto;
    padding-right: 8px;
  }
  .vocab-controls-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
  }
}
@media (max-width: 1023px) {
  .vocab-dual-layout {
    display: flex;
    flex-direction: column;
    gap: 24px;
  }
}

.virtual-keyboard {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 16px;
  user-select: none;
}
.vk-row {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 6px;
}
.vk-row:last-child {
  margin-bottom: 0;
}
.vk-key {
  min-width: 32px;
  height: 44px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, transform 0.1s ease;
}
.vk-key:hover, .vk-key:active {
  background: var(--surface-hover);
  border-color: var(--gold-2);
}
.vk-key-space {
  flex: 1;
  max-width: 240px;
}
.vk-key-shift, .vk-key-bksp {
  padding: 0 12px;
  font-size: 13px;
}

/* ============ STUDIO ============ */
.studio-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 24px;
}

.studio-sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 18px;
  height: fit-content;
}

.side-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-soft);
}

.side-item:hover { background: var(--surface-hover); color: var(--text); }

.side-item.active {
  background: var(--gold-grad-soft);
  color: var(--gold-2);
  border: 1px solid var(--border);
}

.studio-room {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 32px;
}

.room-code {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px;
  background: var(--bg-elev);
  border: 1px dashed var(--gold-2);
  border-radius: 12px;
  font-family: "JetBrains Mono", monospace;
  font-size: 20px;
  font-weight: 800;
  color: var(--gold-2);
  letter-spacing: 4px;
}

.students-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  margin: 22px 0;
}

.student-avatar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 10px;
  background: var(--bg-elev);
  border-radius: 16px;
  position: relative;
  border: 1px solid var(--border);
}

.student-avatar .avatar-img {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: var(--gold-grad);
  display: grid;
  place-items: center;
  font-size: 22px;
}

.student-avatar .name { font-size: 12px; font-weight: 600; }

.student-avatar .score {
  position: absolute;
  top: 6px;
  right: 6px;
  background: var(--coral);
  color: white;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
}

.team-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  margin-top: 22px;
}

.team-card {
  padding: 26px;
  border-radius: 20px;
  border: 2px solid;
  text-align: center;
}

.team-card.red {
  border-color: var(--coral);
  background: var(--coral-soft);
}

.team-card.blue {
  border-color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
}

.team-score {
  font-family: var(--serif);
  font-size: 72px;
  font-weight: 600;
  margin: 12px 0;
  color: var(--text);
}

.buzzer-btn {
  width: 100%;
  padding: 30px;
  border-radius: 20px;
  border: none;
  color: white;
  font-size: 28px;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: 2px;
  transition: transform 0.1s;
  font-family: var(--sans);
}

.buzzer-btn:active { transform: scale(0.96); }

.buzzer-btn.red { background: linear-gradient(135deg, #ff6b6b, #c92a2a); }
.buzzer-btn.blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }

/* ============ FLOATING AI ASSISTANT ============ */
.ai-fab {
  position: fixed;
  bottom: 28px;
  right: 24px;
  width: 54px;
  height: 54px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-deep);
  cursor: pointer;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease, bottom 0.2s ease;
  backdrop-filter: blur(12px);
}

.ai-fab-elevated,
body.has-bottom-bar .ai-fab,
.leaderboard-page ~ .ai-fab,
[data-page="leaderboard"] .ai-fab {
  bottom: 96px;
}

body[data-page="speaking"] .ai-fab,
.speaking-page ~ .ai-fab,
.voice-stage-container ~ .ai-fab {
  display: none !important;
}

.ai-fab img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 24px rgba(0, 0, 0, 0.25)) drop-shadow(0 4px 10px rgba(180, 130, 20, 0.3));
  transition: transform 0.2s;
}

.ai-fab:hover {
  transform: scale(1.15) translateY(-4px);
}

.ai-fab:hover img {
  filter: drop-shadow(0 16px 32px rgba(0, 0, 0, 0.3)) drop-shadow(0 6px 16px rgba(180, 130, 20, 0.5));
}

.ai-panel {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 360px;
  max-height: 520px;
  background: var(--bg-soft);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-deep);
  z-index: 998;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.ai-panel.show { display: flex; animation: slideUp 0.3s ease; }

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.ai-panel-head {
  padding: 18px;
  background: var(--gold-grad-soft);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.ai-panel-head h4 {
  font-family: var(--serif);
  font-size: 19px;
  font-weight: 600;
}

.ai-panel-head .sub { font-size: 12px; color: var(--text-dim); }

.ai-panel-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ai-suggest {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.2s;
  line-height: 1.45;
}

.ai-suggest:hover {
  border-color: var(--gold-2);
  background: var(--surface-hover);
}

.ai-suggest .s-icon { margin-right: 8px; }

/* ============ VOCAB POPUP ============ */
.vocab-popup {
  position: fixed;
  background: var(--bg-soft);
  border: 1px solid var(--gold-2);
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow-deep), var(--shadow-gold);
  z-index: 1000;
  min-width: 280px;
  max-width: 340px;
  display: none;
}

.vocab-popup.show { display: block; animation: fadeUp 0.2s ease; }

.vocab-popup h4 {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 600;
}

.vocab-popup .pos {
  font-size: 13px;
  color: var(--coral);
  font-style: italic;
  margin: 4px 0 8px;
}

.vocab-popup .def {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1.5;
}

.vocab-popup .saved {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

/* ============ AI OVERLAY ============ */
.ai-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 997;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.ai-overlay.show,
.ai-overlay.open {
  display: block;
  opacity: 1;
}

/* ============ TOAST NOTIFICATIONS ============ */
.tux-toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
  max-width: 380px;
  width: calc(100vw - 32px);
}

.tux-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: 14px;
  font-weight: 500;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

.tux-toast.show {
  transform: translateX(0);
  opacity: 1;
}

.tux-toast-icon {
  font-size: 18px;
  flex-shrink: 0;
}

.tux-toast-message {
  flex: 1;
  line-height: 1.4;
}

.tux-toast-success {
  border-left: 4px solid var(--success);
}
.tux-toast-success .tux-toast-icon {
  color: var(--success);
}

.tux-toast-error {
  border-left: 4px solid var(--error);
}
.tux-toast-error .tux-toast-icon {
  color: var(--error);
}

.tux-toast-warning {
  border-left: 4px solid var(--warning);
}
.tux-toast-warning .tux-toast-icon {
  color: var(--warning);
}

.tux-toast-info {
  border-left: 4px solid var(--info);
}
.tux-toast-info .tux-toast-icon {
  color: var(--info);
}

/* ============ 5-TIER MEMORY SRS (MOCHIMOCHI EBBINGHAUS) ============ */
.srs-pill,
.srs-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.srs-tier-1 {
  background: var(--srs-tier-1-soft);
  color: var(--srs-tier-1-text, #9a3412);
  border: 1px solid color-mix(in srgb, var(--srs-tier-1) 35%, transparent);
}

.srs-tier-2 {
  background: var(--srs-tier-2-soft);
  color: var(--srs-tier-2-text, #92400e);
  border: 1px solid color-mix(in srgb, var(--srs-tier-2) 35%, transparent);
}

.srs-tier-3 {
  background: var(--srs-tier-3-soft);
  color: var(--srs-tier-3-text, #854d0e);
  border: 1px solid color-mix(in srgb, var(--srs-tier-3) 35%, transparent);
}

.srs-tier-4 {
  background: var(--srs-tier-4-soft);
  color: var(--srs-tier-4-text, #365314);
  border: 1px solid color-mix(in srgb, var(--srs-tier-4) 35%, transparent);
}

.srs-tier-5 {
  background: var(--srs-tier-5-soft);
  color: var(--srs-tier-5-text, #065f46);
  border: 1px solid color-mix(in srgb, var(--srs-tier-5) 35%, transparent);
}

[data-theme="dark"] .srs-tier-1 { color: var(--srs-tier-1); }
[data-theme="dark"] .srs-tier-2 { color: var(--srs-tier-2); }
[data-theme="dark"] .srs-tier-3 { color: var(--srs-tier-3); }
[data-theme="dark"] .srs-tier-4 { color: var(--srs-tier-4); }
[data-theme="dark"] .srs-tier-5 { color: var(--srs-tier-5); }

/* ============ 3D BUTTON EFFECT ============ */
.btn-3d {
  position: relative;
  border-bottom: 4px solid var(--gold-3);
  transition: transform 0.1s ease, border-bottom-width 0.1s ease, box-shadow 0.1s ease;
}
.btn-3d:active {
  transform: translateY(2px);
  border-bottom-width: 2px;
}

/* ============ MOBILE BOTTOM DOCK (DESKTOP DEFAULT: HIDDEN) ============ */
.mobile-bottom-dock,
.mobile-dock {
  display: none;
}

.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  min-height: 48px;
  padding: 4px 8px;
  border-radius: var(--r-md);
  color: var(--text-dim);
  text-decoration: none;
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), color 0.2s ease, background 0.2s ease;
}

.dock-item:active {
  transform: scale(0.90);
}

.dock-item:hover,
.dock-item.active {
  color: var(--gold-3);
}

[data-theme="dark"] .dock-item:hover,
[data-theme="dark"] .dock-item.active {
  color: var(--gold-2);
}

.dock-item.active::after {
  content: "";
  position: absolute;
  bottom: 2px;
  width: 16px;
  height: 3px;
  border-radius: var(--r-pill);
  background: var(--gold-grad);
  box-shadow: 0 0 8px var(--gold-glow);
}

.dock-icon {
  font-size: 20px;
  line-height: 1.2;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dock-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 2px;
}

.dock-badge {
  position: absolute;
  top: 2px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: var(--r-pill);
  background: var(--coral);
  color: #ffffff;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============ FOOTER ============ */
.footer {
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px 28px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

/* ============ RESPONSIVE (Editorial & Fluid Precision) ============ */
@media (min-width: 1280px) {
  .container,
  .arena-container,
  .classroom-page {
    max-width: 1320px !important;
    margin-left: auto !important;
    margin-right: auto !important;
    padding-left: 28px !important;
    padding-right: 28px !important;
    box-sizing: border-box !important;
  }
  .feature-grid {
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 22px !important;
  }
  .feature-card.wide {
    grid-column: span 2 !important;
  }
  .feature-grid > .feature-card:last-child {
    grid-column: span 3 !important;
  }
  .studio-layout {
    grid-template-columns: 320px minmax(0, 1fr) !important;
    gap: 32px !important;
    align-items: start !important;
  }
  .studio-sidebar {
    padding: 24px !important;
  }
  .side-item {
    padding: 14px 18px !important;
    font-size: 15px !important;
  }
  .students-grid {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 16px !important;
  }
  .team-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 28px !important;
  }
}

@media (min-width: 1440px) {
  .container,
  .arena-container,
  .classroom-page {
    max-width: 1360px !important;
  }
  .feature-grid { gap: 24px !important; }
}

@media (max-width: 1180px) {
  .nav-links {
    display: none !important;
  }
  .nav-launcher-btn {
    display: none !important;
  }
  .hamburger-btn {
    display: grid !important;
  }
  .feature-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
  .feature-card.wide { grid-column: span 2; }
  .speaking-layout {
    grid-template-columns: 1fr 320px;
    gap: 20px;
  }
}

@media (max-width: 1024px) {
  .container { padding: 24px 20px 80px; }
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    gap: 32px;
  }
  .hero-eyebrow { margin-left: auto; margin-right: auto; }
  .hero-lead { margin-left: auto; margin-right: auto; }
  .hero-cta { justify-content: center; }
  .hero-stats { justify-content: center; }
  .hero-visual { min-height: 360px; }

  .feature-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
  }
  .feature-card.wide { grid-column: span 2; }
  .feature-card.tall { grid-row: span 1; }

  .speaking-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }
  .speaking-scenes { position: static; }
  .studio-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .studio-sidebar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
  }
  .sidebar-category {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  .exam-player {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 280px !important;
    gap: 18px !important;
    align-items: start !important;
  }
  .progress-sidebar {
    position: sticky !important;
    top: 84px !important;
    max-height: calc(100vh - 180px) !important;
    overflow-y: auto !important;
    padding: 18px 14px !important;
    border-radius: 20px !important;
    margin-top: 0 !important;
  }
  .question-grid {
    grid-template-columns: repeat(6, 1fr) !important;
    max-height: calc(100vh - 340px) !important;
    overflow-y: auto !important;
    gap: 6px !important;
  }
  .question-grid button,
  .palette-item,
  .q-cell {
    min-width: 28px !important;
    min-height: 28px !important;
  }
  .shadowing-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr) !important;
    gap: 20px !important;
    align-items: start !important;
  }
  .ipa-card {
    position: sticky !important;
    top: 84px !important;
    max-height: calc(100vh - 120px) !important;
    overflow-y: auto !important;
  }
  .q-cell {
    width: 32px !important;
    height: 32px !important;
    font-size: 12px !important;
  }
  .question-panel {
    padding: 24px 20px !important;
  }
  .students-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }
}

@media (min-width: 768px) and (max-width: 859px) {
  .exam-player {
    grid-template-columns: minmax(0, 1fr) 260px !important;
    gap: 14px !important;
  }
  .progress-sidebar {
    padding: 16px 12px !important;
  }
  .question-grid {
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 6px !important;
  }
  .question-grid button,
  .palette-item,
  .q-cell {
    min-width: 26px !important;
    min-height: 26px !important;
    font-size: 11px !important;
  }
}

@media (max-width: 767px) {
  body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 16px));
  }

  .mobile-bottom-dock,
  .mobile-dock {
    display: grid !important;
    grid-template-columns: repeat(5, 1fr) !important;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 950;
    min-height: 56px;
    padding: var(--space-1) var(--space-0-5) calc(var(--space-1) + env(safe-area-inset-bottom, 16px)) !important;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border);
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  }

  .container {
    padding: var(--space-2) var(--space-2) calc(88px + env(safe-area-inset-bottom, 16px));
    max-width: 100%;
    overflow-x: hidden;
  }

  .studio-sidebar {
    display: flex;
    overflow-x: auto;
    gap: 12px;
    padding: 12px 14px !important;
    scrollbar-width: none;
  }
  .studio-sidebar::-webkit-scrollbar { display: none; }
  .sidebar-category {
    display: flex;
    flex-direction: row;
    gap: 8px;
    flex-shrink: 0;
  }
  .sidebar-category > div:first-child { display: none; }
  .side-item {
    white-space: nowrap;
    min-height: 40px;
  }
  .students-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  .question-panel {
    padding: 18px 16px;
    border-radius: 20px;
    max-width: 100%;
  }

  .audio-bar {
    padding: 12px 14px;
    gap: 12px;
    flex-wrap: wrap;
  }

  .audio-wave {
    min-width: 120px;
  }

  .choices {
    gap: 10px;
  }

  .choice {
    padding: 14px;
    border-radius: 14px;
  }

  .choice-letter {
    width: 32px;
    height: 32px;
    font-size: 13px;
  }

  /* Navigation mobile với Launcher Button */
  .topnav-inner {
    padding: 10px 16px;
    flex-wrap: nowrap;
    gap: 10px;
  }
  .brand {
    font-size: 18px;
    gap: 8px;
  }
  .brand-logo {
    width: 32px;
    height: 32px;
  }
  .nav-right {
    gap: 8px;
    flex-shrink: 0;
  }
  .streak-pill {
    padding: 6px 10px;
    font-size: 12px;
    gap: 5px;
  }
  .theme-toggle {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    font-size: 16px;
    border-radius: 10px;
  }

  /* Ẩn thanh nav-links ngang trên mobile, thay bằng nút hamburger */
  .nav-links {
    display: none !important;
  }
  .hamburger-btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    border-radius: 10px;
    font-size: 18px;
  }

  /* Hero section mobile */
  .hero {
    grid-template-columns: 1fr;
    text-align: center;
    padding: 16px 0 10px;
    gap: 20px;
  }
  .hero h1 {
    font-size: 42px;
    letter-spacing: -0.02em;
  }
  .hero-lead {
    font-size: 15.5px;
    margin: 0 auto 24px;
    line-height: 1.6;
  }
  .hero-cta {
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 24px;
  }
  .hero-cta .btn {
    padding: 12px 20px;
    font-size: 14px;
  }
  .hero-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    padding-top: 18px;
  }
  .hero-stat .num { font-size: 32px; }
  .hero-visual { min-height: 260px; }
  .hero-mascot {
    width: 220px;
    min-height: 190px;
    margin: 0 auto;
  }
  .hero-globe { max-width: 320px; }

  /* Feature Grid trên mobile: 1 cột hoặc 2 cột linh hoạt */
  .feature-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .feature-card.wide { grid-column: span 1; }
  .feature-card {
    padding: 20px;
    border-radius: 20px;
  }

  /* Section Head */
  .section-head {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    margin: 28px 0 16px;
    gap: 8px;
  }
  .section-head h2 {
    font-size: 21px;
    margin: 0;
    line-height: 1.25;
  }
  .section-head h2::after {
    margin-top: 4px;
    width: 36px;
    height: 2px;
  }
  .section-head .see-all {
    font-size: 13.5px;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: center;
    min-height: 28px;
    padding: 4px 10px;
    display: inline-flex;
    align-items: center;
  }

  /* AI Daily Card */
  .ai-daily {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 14px;
    padding: 18px;
    margin: 20px 0 28px;
    border-radius: 18px;
  }
  .ai-daily-header {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
  }
  .ai-daily .ai-avatar {
    width: 46px;
    height: 46px;
  }
  .ai-daily-text .tag {
    font-size: 10.5px;
    margin-bottom: 3px;
  }
  .ai-daily-text .msg {
    font-size: 14.5px;
    line-height: 1.5;
  }
  .ai-daily .btn {
    width: 100%;
    justify-content: center;
    padding: 12px 16px;
    font-size: 14px;
  }

  /* Exam & Dictation player */
  @media (max-width: 767px) {
    .exam-player {
      grid-template-columns: minmax(0, 1fr);
      max-width: 100%;
      overflow: hidden;
    }
  }
  .exam-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .nav-buttons {
    flex-wrap: wrap;
    gap: 8px;
  }
  .nav-buttons .btn {
    flex: 1 1 calc(50% - 6px);
    padding: 12px 14px;
    font-size: 13.5px;
    white-space: normal;
    text-align: center;
  }
  .nav-buttons .btn:last-child {
    flex-basis: 100%;
  }

  /* Progress Sidebar Mobile UX */
  @media (max-width: 767px) {
    .progress-sidebar {
      padding: 18px 18px calc(280px + env(safe-area-inset-bottom, 24px));
      border-radius: 20px;
      margin-top: 20px;
    }
  }
  .progress-head-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
  }
  .toggle-grid-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 12px;
    min-height: 28px;
    font-size: 12px;
    color: var(--text-dim);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .progress-sidebar .timer {
    font-size: 24px;
    padding: 12px;
    margin-bottom: 16px;
  }
  .question-grid {
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
  }
  .question-grid.collapsed {
    display: none !important;
  }
  .question-grid button {
    font-size: 11px;
    border-radius: 6px;
    max-height: 38px;
    max-width: 38px;
    margin: 0 auto;
    width: 100%;
  }

  .dictation-input { font-size: 16px; min-height: 120px; }
  .dictation-controls { flex-wrap: wrap; }

  /* Flashcard & Vocab */
  .flashcard-wrap { max-width: 100%; min-height: 340px; }
  .flashcard-word { font-size: 38px; }
  .flashcard-actions { flex-wrap: wrap; gap: 8px; }
  .flashcard-actions .btn { flex: 1 1 calc(50% - 8px); }

  /* Vocab Table Mobile: Chuyển dạng card view */
  .vocab-table > .vocab-row:first-child {
    display: none;
  }
  .vocab-row {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-bottom: 10px;
  }
  .vocab-row > div:nth-child(3),
  .vocab-row > div:nth-child(4),
  .vocab-row > div:nth-child(5) {
    display: inline-flex;
  }

  /* Team buzzers (Studio) */
  .team-grid { grid-template-columns: 1fr; }

  /* Floating AI Assistant Panel */
  .ai-fab {
    bottom: calc(76px + env(safe-area-inset-bottom, 16px));
    right: 16px;
    width: 52px;
    height: 52px;
  }
  .ai-panel {
    width: calc(100% - 32px);
    right: 16px;
    left: 16px;
    bottom: calc(136px + env(safe-area-inset-bottom, 16px));
    max-height: 65vh;
  }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 34px; }
  .hero-cta .btn { width: 100%; justify-content: center; }
  .sidebar-app-list {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  .sidebar-app-card {
    padding: 12px 6px 10px;
    min-height: 118px;
  }
  .sidebar-app-icon {
    width: 52px;
    height: 52px;
  }
  .sidebar-app-info h5 {
    font-size: 11.5px;
  }
}
