@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@400;600;700;800;900&display=swap');

/* ================================================================
   THEME VARIABLES — Dark (default) + Light
   ================================================================ */
:root {
  --red: #DD0000;
  --gold: #FFCE00;
  --gold-dark: #e8b800;
  --green: #2ec4b6;
  --blue: #4361ee;
  --purple: #7b2d8b;
  --orange: #ff6b35;

  --sidebar-w: 240px;
  --topbar-h: 60px;
  --radius: 16px;
  --radius-lg: 24px;
  --transition: 0.25s ease;

  /* Font */
  --font-body: 'Nunito', sans-serif;
  --font-display: 'Fredoka One', cursive;
}

/* ===== DARK MODE (default) ===== */
[data-theme="dark"], :root {
  --bg: #0d0d1a;
  --bg2: #13131f;
  --bg3: #1a1a2e;
  --card: rgba(255,255,255,0.05);
  --card-border: rgba(255,255,255,0.10);
  --card-hover: rgba(255,255,255,0.09);
  --sidebar-bg: #0f0f1c;
  --topbar-bg: rgba(13,13,26,0.92);
  --text: #f0f0f8;
  --text2: #b0b0cc;
  --text3: #7070a0;
  --input-bg: rgba(255,255,255,0.06);
  --input-border: rgba(255,255,255,0.12);
  --input-focus: rgba(255,206,0,0.3);
  --divider: rgba(255,255,255,0.08);
  --overlay: rgba(0,0,0,0.6);
  --progress-bg: rgba(255,255,255,0.08);
  --scrollbar: rgba(255,255,255,0.15);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-gold: 0 8px 32px rgba(255,206,0,0.2);
  --shadow-red: 0 8px 32px rgba(221,0,0,0.3);
  --active-link: rgba(221,0,0,0.15);
  --active-link-text: #DD0000;
}

/* ===== LIGHT MODE ===== */
[data-theme="light"] {
  --bg: #f4f4fb;
  --bg2: #eceef8;
  --bg3: #e4e6f2;
  --card: rgba(255,255,255,0.9);
  --card-border: rgba(0,0,0,0.08);
  --card-hover: rgba(255,255,255,1);
  --sidebar-bg: #ffffff;
  --topbar-bg: rgba(255,255,255,0.95);
  --text: #1a1a2e;
  --text2: #4a4a6a;
  --text3: #8080a0;
  --input-bg: rgba(0,0,0,0.04);
  --input-border: rgba(0,0,0,0.12);
  --input-focus: rgba(221,0,0,0.2);
  --divider: rgba(0,0,0,0.07);
  --overlay: rgba(0,0,0,0.5);
  --progress-bg: rgba(0,0,0,0.08);
  --scrollbar: rgba(0,0,0,0.2);
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
  --shadow-gold: 0 6px 24px rgba(255,206,0,0.25);
  --shadow-red: 0 6px 24px rgba(221,0,0,0.2);
  --active-link: rgba(221,0,0,0.08);
  --active-link-text: #BB0000;
}

/* ================================================================
   RESETS & BASE
   ================================================================ */
*, *::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;
  overflow-x: hidden;
  transition: background var(--transition), color var(--transition);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; border: none; outline: none; }
input, textarea, select { font-family: var(--font-body); outline: none; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 10px; }

/* ================================================================
   LAYOUT — Sidebar + Main
   ================================================================ */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--divider);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  padding: 20px 12px;
  scrollbar-width: thin;
}

.sidebar-logo {
  font-family: var(--font-display);
  font-size: 22px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  display: block;
  margin-bottom: 20px;
  padding: 0 8px;
  white-space: nowrap;
}

.sidebar-user {
  background: linear-gradient(135deg, rgba(221,0,0,0.12), rgba(255,206,0,0.06));
  border: 1px solid rgba(255,206,0,0.2);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.sidebar-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar-avatar { font-size: 28px; line-height: 1; }

.sidebar-name {
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-level {
  font-size: 11px;
  color: var(--text2);
}

.sidebar-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 16px;
}

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

.sidebar-stat-icon { font-size: 14px; }
.sidebar-stat-label { font-size: 10px; color: var(--text2); display: block; }
.sidebar-stat-val { font-weight: 900; font-size: 14px; }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--text2);
  font-weight: 700;
  font-size: 13.5px;
  transition: all var(--transition);
  white-space: nowrap;
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--card);
}

.sidebar-link.active {
  color: var(--active-link-text);
  background: var(--active-link);
  font-weight: 800;
}

.sidebar-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  max-width: calc(100vw - var(--sidebar-w));
  transition: margin-left var(--transition);
}

/* ===== TOP BAR (mobile) ===== */
.topbar {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topbar-h);
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--divider);
  z-index: 300;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
}

.topbar-logo {
  font-family: var(--font-display);
  font-size: 20px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.menu-btn {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--text);
  font-size: 18px;
  line-height: 1;
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 199;
  backdrop-filter: blur(2px);
}

/* ================================================================
   CARDS & GLASS
   ================================================================ */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
}

.card-hover:hover {
  background: var(--card-hover);
  border-color: rgba(255,206,0,0.25);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}

/* ================================================================
   TYPOGRAPHY
   ================================================================ */
.text-gradient {
  background: linear-gradient(135deg, var(--red), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

h1 { font-family: var(--font-display); font-size: clamp(24px, 4vw, 36px); color: var(--text); }
h2 { font-family: var(--font-display); font-size: clamp(20px, 3vw, 28px); color: var(--text); }
h3 { font-family: var(--font-display); font-size: clamp(16px, 2.5vw, 22px); color: var(--text); }
p { color: var(--text2); line-height: 1.6; }

.page-title { font-family: var(--font-display); font-size: clamp(22px, 3.5vw, 32px); }
.section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text3);
  font-weight: 800;
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 50px;
  font-weight: 800;
  font-size: 15px;
  padding: 12px 28px;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--red), #aa0000);
  color: white;
  box-shadow: var(--shadow-red);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(221,0,0,0.45); }

.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: #1a1500;
  box-shadow: var(--shadow-gold);
}
.btn-gold:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(255,206,0,0.5); }

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 2px solid var(--card-border);
}
.btn-outline:hover { border-color: var(--gold); color: var(--gold); transform: translateY(-2px); }

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

.btn-sm { padding: 8px 18px; font-size: 13px; }
.btn-lg { padding: 16px 40px; font-size: 17px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ================================================================
   FORMS
   ================================================================ */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 12px;
  padding: 13px 16px;
  color: var(--text);
  font-size: 15px;
  font-family: var(--font-body);
  transition: all var(--transition);
}

.form-input:focus {
  border-color: var(--gold);
  background: var(--input-bg);
  box-shadow: 0 0 0 3px var(--input-focus);
}

.form-input::placeholder { color: var(--text3); }

select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

/* ================================================================
   PROGRESS BARS
   ================================================================ */
.progress-bar {
  background: var(--progress-bg);
  border-radius: 100px;
  height: 8px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 100px;
  background: linear-gradient(90deg, var(--red), var(--gold));
  transition: width 0.6s ease;
}

.progress-fill-green { background: linear-gradient(90deg, #2ec4b6, #1a9a8a); }
.progress-fill-blue  { background: linear-gradient(90deg, var(--blue), #2a41be); }

/* ================================================================
   BADGES & TAGS
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
}

.badge-a1 { background: rgba(46,196,182,0.15); color: #2ec4b6; border: 1px solid rgba(46,196,182,0.3); }
.badge-a2 { background: rgba(67,97,238,0.15); color: #4361ee; border: 1px solid rgba(67,97,238,0.3); }
.badge-b1 { background: rgba(123,45,139,0.15); color: #a040c0; border: 1px solid rgba(123,45,139,0.3); }
.badge-b2 { background: rgba(221,0,0,0.15); color: var(--red); border: 1px solid rgba(221,0,0,0.3); }
.badge-c1 { background: rgba(255,206,0,0.15); color: var(--gold-dark); border: 1px solid rgba(255,206,0,0.3); }
.badge-c2 { background: rgba(255,107,53,0.15); color: var(--orange); border: 1px solid rgba(255,107,53,0.3); }

/* ================================================================
   QUIZ OPTIONS
   ================================================================ */
.quiz-option {
  background: var(--card);
  border: 2px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
}

.quiz-option:hover:not(:disabled) {
  border-color: var(--gold);
  background: var(--card-hover);
  transform: translateY(-2px);
}

.quiz-option.correct {
  background: rgba(46,196,182,0.15) !important;
  border-color: #2ec4b6 !important;
  color: #2ec4b6 !important;
}

.quiz-option.incorrect {
  background: rgba(221,0,0,0.15) !important;
  border-color: var(--red) !important;
  color: #ff6b6b !important;
}

/* ================================================================
   ACHIEVEMENT TOAST
   ================================================================ */
.achievement-toast {
  position: fixed;
  top: 80px;
  right: -380px;
  width: 340px;
  background: var(--card);
  border: 1px solid rgba(255,206,0,0.3);
  border-radius: 20px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 9000;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  transition: right 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.achievement-toast.show { right: 20px; }

.toast-icon-wrap {
  width: 50px;
  height: 50px;
  background: linear-gradient(135deg, rgba(255,206,0,0.3), rgba(255,206,0,0.1));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
}

.toast-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--gold);
  font-weight: 800;
}

.toast-title { font-weight: 800; font-size: 15px; color: var(--text); }
.toast-desc { font-size: 12px; color: var(--text2); }

/* ================================================================
   THEME TOGGLE
   ================================================================ */
.theme-toggle {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 50px;
  padding: 6px;
  display: flex;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.theme-btn {
  border: none;
  background: transparent;
  border-radius: 50px;
  padding: 6px 10px;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
  color: var(--text2);
}

.theme-btn.active {
  background: var(--card-hover);
  color: var(--text);
}

/* ================================================================
   STATS GRID
   ================================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
}

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

.stat-icon { font-size: 24px; margin-bottom: 6px; }
.stat-value { font-weight: 900; font-size: 24px; color: var(--text); }
.stat-label { font-size: 12px; color: var(--text2); font-weight: 600; }

/* ================================================================
   LEVEL BADGE
   ================================================================ */
.level-badge {
  background: linear-gradient(135deg, var(--red), #aa0000);
  color: white;
  font-weight: 900;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 100px;
  display: inline-block;
}

/* ================================================================
   NOTIFICATION DOT
   ================================================================ */
.notif-dot {
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  position: absolute;
  top: 0; right: 0;
}

/* ================================================================
   STREAK & COIN DISPLAY
   ================================================================ */
.streak-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,107,53,0.12);
  border: 1px solid rgba(255,107,53,0.25);
  border-radius: 50px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 13px;
  color: var(--orange);
}

.coin-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,206,0,0.12);
  border: 1px solid rgba(255,206,0,0.25);
  border-radius: 50px;
  padding: 6px 14px;
  font-weight: 800;
  font-size: 13px;
  color: var(--gold);
  text-decoration: none;
}

/* ================================================================
   PAGE HEADER
   ================================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

/* ================================================================
   LEADERBOARD
   ================================================================ */
.lb-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  padding: 24px 0 8px;
}

.lb-podium-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.lb-avatar { font-size: 36px; }
.lb-name { font-weight: 800; font-size: 12px; color: var(--text); text-align: center; }
.lb-xp { font-size: 11px; color: var(--text2); }

.lb-plinth {
  border-radius: 12px 12px 0 0;
  width: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 900;
  color: white;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-radius: 14px;
  transition: all var(--transition);
  cursor: default;
}

.lb-row:hover { background: var(--card); }
.lb-row.current-user { background: rgba(255,206,0,0.08); border: 1px solid rgba(255,206,0,0.2); }

.lb-rank { font-weight: 900; font-size: 15px; color: var(--text2); width: 28px; text-align: right; }
.lb-user-info { flex: 1; }
.lb-user-name { font-weight: 800; font-size: 14px; color: var(--text); }
.lb-user-sub { font-size: 12px; color: var(--text2); }
.lb-score { font-weight: 900; font-size: 15px; color: var(--gold); }

/* ================================================================
   STORY CARDS
   ================================================================ */
.story-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.story-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: rgba(255,206,0,0.2);
}

.story-emoji { font-size: 40px; }
.story-title { font-weight: 900; font-size: 18px; color: var(--text); }
.story-preview { font-size: 13px; color: var(--text2); line-height: 1.5; }
.story-meta { display: flex; gap: 12px; font-size: 12px; color: var(--text3); font-weight: 600; }

/* ================================================================
   VOCAB CARD
   ================================================================ */
.vocab-card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all var(--transition);
}

.vocab-german { font-weight: 900; font-size: 18px; color: var(--text); }
.vocab-gender { color: var(--gold); font-size: 13px; font-weight: 700; }
.vocab-english { font-size: 14px; color: var(--text2); margin-top: 4px; }
.vocab-example { font-size: 12px; color: var(--text3); font-style: italic; margin-top: 6px; }

/* ================================================================
   AI TUTOR WIDGET
   ================================================================ */
.ai-tutor {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 500;
}

.ai-tutor-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--red), var(--gold));
  border: none;
  cursor: pointer;
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(221,0,0,0.4);
  transition: all var(--transition);
}

.ai-tutor-btn:hover { transform: scale(1.1); }

.ai-tutor-panel {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 320px;
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

.ai-tutor-panel.open { display: flex; }

.ai-tutor-header {
  background: linear-gradient(135deg, var(--red), #aa0000);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: white;
  font-weight: 800;
}

.ai-tutor-body {
  flex: 1;
  padding: 16px;
  height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ai-message {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--card);
  border-radius: 10px;
}

.ai-tutor-input-row {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--divider);
}

.ai-tutor-input {
  flex: 1;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-body);
}

.ai-tutor-send {
  background: var(--red);
  color: white;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 16px;
}

/* ================================================================
   LOADING SPINNER
   ================================================================ */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--divider);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 20px auto;
}

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

/* ================================================================
   HERO (Landing page)
   ================================================================ */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 100px 40px 60px;
  position: relative;
  overflow: hidden;
  background: var(--bg);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(221,0,0,0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255,206,0,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 60% 80%, rgba(67,97,238,0.08) 0%, transparent 50%);
  pointer-events: none;
}

[data-theme="light"] .hero-bg {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(221,0,0,0.07) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(255,206,0,0.05) 0%, transparent 50%);
}

/* ================================================================
   NAVBAR (Landing page)
   ================================================================ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 1000;
  background: var(--topbar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--divider);
  padding: 0 40px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-family: var(--font-display);
  font-size: 26px;
  background: linear-gradient(135deg, var(--red), var(--gold));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  gap: 4px;
  list-style: none;
}

.nav-links a {
  color: var(--text2);
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 10px;
  transition: all var(--transition);
  font-size: 14px;
}

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

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

/* ================================================================
   MODAL
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg2);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 32px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  animation: slideUp 0.3s ease;
}

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

/* ================================================================
   SETTINGS
   ================================================================ */
.settings-section {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 20px;
}

.settings-section h3 {
  font-size: 16px;
  margin-bottom: 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--divider);
  color: var(--text);
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--divider);
}

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

.settings-label { font-weight: 700; font-size: 14px; color: var(--text); }
.settings-desc { font-size: 12px; color: var(--text2); margin-top: 2px; }

/* Toggle switch */
.toggle {
  width: 44px;
  height: 24px;
  background: var(--input-border);
  border-radius: 100px;
  position: relative;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle.on { background: var(--green); }

.toggle::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  background: white;
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: left var(--transition);
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.toggle.on::after { left: 23px; }

/* ================================================================
   EMPTY STATE
   ================================================================ */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}

.empty-state-icon { font-size: 60px; margin-bottom: 16px; }
.empty-state-title { font-family: var(--font-display); font-size: 22px; color: var(--text); margin-bottom: 8px; }

/* ================================================================
   TABS
   ================================================================ */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 50px;
  padding: 4px;
}

.tab {
  padding: 8px 18px;
  border-radius: 50px;
  font-weight: 700;
  font-size: 13px;
  color: var(--text2);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}

.tab.active {
  background: linear-gradient(135deg, var(--red), #aa0000);
  color: white;
}

/* ================================================================
   FLASHCARD
   ================================================================ */
.flashcard {
  perspective: 1000px;
  height: 200px;
  cursor: pointer;
}

.flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.5s ease;
}

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

.flashcard-front, .flashcard-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  text-align: center;
}

.flashcard-back { transform: rotateY(180deg); }

/* ================================================================
   ANIMATIONS
   ================================================================ */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,206,0,0.4); }
  50% { box-shadow: 0 0 0 10px rgba(255,206,0,0); }
}

.pulse-glow { animation: pulse-glow 2s ease infinite; }

/* ================================================================
   UTILITIES
   ================================================================ */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-col { display: flex; flex-direction: column; }
.gap-4 { gap: 4px; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.gap-20 { gap: 20px; }
.gap-24 { gap: 24px; }
.w-full { width: 100%; }
.text-center { text-align: center; }
.text-sm { font-size: 13px; }
.text-xs { font-size: 11px; }
.text-lg { font-size: 18px; }
.font-bold { font-weight: 700; }
.font-heavy { font-weight: 900; }
.text-muted { color: var(--text2); }
.text-gold { color: var(--gold); }
.text-red { color: var(--red); }
.text-green { color: var(--green); }
.text-orange { color: var(--orange); }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.p-16 { padding: 16px; }
.p-24 { padding: 24px; }
.p-32 { padding: 32px; }
.rounded { border-radius: var(--radius); }
.rounded-lg { border-radius: var(--radius-lg); }
.overflow-hidden { overflow: hidden; }
.relative { position: relative; }

/* ================================================================
   GRID LAYOUTS
   ================================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }

/* ================================================================
   RESPONSIVE — TABLET & MOBILE
   ================================================================ */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 24px; }
}

@media (max-width: 768px) {
  /* Show topbar, hide sidebar by default */
  .topbar { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    top: 0;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 40px rgba(0,0,0,0.4);
  }

  .sidebar-overlay.visible { display: block; }

  .main-content {
    margin-left: 0;
    max-width: 100%;
    padding: 80px 16px 100px;
  }

  /* Grid collapses */
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Navbar for landing */
  .navbar { padding: 0 16px; }
  .nav-links { display: none; }

  /* Hero */
  .hero { padding: 80px 16px 40px; }

  /* Page header */
  .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }

  /* Leaderboard */
  .lb-podium { gap: 8px; }
  .lb-plinth { width: 70px; }

  /* Tabs */
  .tabs { overflow-x: auto; border-radius: 12px; }
  .tabs::-webkit-scrollbar { height: 0; }

  /* Buttons */
  .btn { font-size: 14px; padding: 11px 22px; }

  /* AI Tutor */
  .ai-tutor { bottom: 16px; right: 16px; }
  .ai-tutor-panel { width: calc(100vw - 32px); right: 0; }

  /* Achievement toast */
  .achievement-toast { width: calc(100vw - 32px); }
  .achievement-toast.show { right: 16px; }

  /* Modal */
  .modal { padding: 24px 16px; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .sidebar-stats { grid-template-columns: 1fr 1fr; }
}

/* ================================================================
   SCROLLABLE HORIZONTAL (vocab categories on mobile)
   ================================================================ */
.scroll-x {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 4px;
}

.scroll-x::-webkit-scrollbar { display: none; }

/* ================================================================
   ALERT / ERROR / SUCCESS MESSAGES
   ================================================================ */
.alert {
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 16px;
}

.alert-error {
  background: rgba(221,0,0,0.1);
  border: 1px solid rgba(221,0,0,0.25);
  color: #ff6b6b;
}

.alert-success {
  background: rgba(46,196,182,0.1);
  border: 1px solid rgba(46,196,182,0.25);
  color: #2ec4b6;
}
