/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0; padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

:root {
  --navy:          #152238;
  --navy-light:    #1A2B40;
  --card:          #1E3350;
  --card2:         #263D5E;
  --card3:         #2E476E;
  --blue:          #3B82F6;
  --blue-dim:      rgba(59,130,246,0.15);
  --yellow:        #F59E0B;
  --yellow-light:  #FCD34D;
  --yellow-dim:    rgba(245,158,11,0.12);
  --yellow-glow:   rgba(245,158,11,0.25);
  --success:       #10B981;
  --success-dim:   rgba(16,185,129,0.12);
  --danger:        #FF0000;
  --danger-dim:    rgba(255,0,0,0.12);
  --warn:          #F59E0B;
  --text:          #E8EDF5;
  --text2:         #94A3B8;
  --text3:         #5A7089;
  --border:        rgba(255,255,255,0.07);
  --border2:       rgba(255,255,255,0.04);
  --radius:        16px;
  --radius-sm:     10px;
  --radius-lg:     22px;
  --shadow:        0 4px 20px rgba(0,0,0,0.4);
  --shadow-sm:     0 2px 8px rgba(0,0,0,0.3);
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Segoe UI', sans-serif;
  background: var(--navy);
  color: var(--text);
}

/* ── App Shell ────────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding-bottom: 8px;
}
.content::-webkit-scrollbar { display: none; }

.app.test-mode .tab-bar { display: none; }
.app.test-mode .content { padding-bottom: 0; }

/* ── Page Animation ───────────────────────────────────────────────────────── */
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.content > * { animation: pageIn 0.2s ease-out both; }

/* ── Tab Bar ──────────────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  background: rgba(21,34,56,0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 4px 6px;
  background: none;
  border: none;
  color: var(--text3);
  font-size: 10px;
  cursor: pointer;
  transition: color 0.2s;
  font-family: inherit;
  position: relative;
}
.tab svg { width: 22px; height: 22px; transition: transform 0.2s; }
.tab.active { color: var(--yellow); }
.tab.active svg { transform: scale(1.1); }
.tab.active::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%);
  width: 28px; height: 2px;
  background: var(--yellow);
  border-radius: 0 0 3px 3px;
}

/* ── Nav Headers ──────────────────────────────────────────────────────────── */
.nav-header {
  position: sticky;
  top: 0;
  background: rgba(21,34,56,0.95);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  padding: 16px 20px 14px;
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.nav-header h1 { font-size: 28px; font-weight: 700; letter-spacing: -0.5px; }
.nav-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.back-header {
  padding: 44px 20px 12px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.back-btn {
  background: none; border: none;
  color: var(--yellow);
  font-size: 17px; cursor: pointer;
  display: flex; align-items: center; gap: 2px;
  padding: 0; font-family: inherit; font-weight: 400;
}
.back-btn svg { width: 20px; height: 20px; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 22px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.15s;
  font-family: inherit;
  text-decoration: none;
}
.btn:active { opacity: 0.82; transform: scale(0.97); }
.btn-block { width: 100%; display: flex; }

.btn-yellow {
  background: var(--yellow);
  color: #0F1D30;
  box-shadow: 0 4px 16px var(--yellow-glow);
}
.btn-blue {
  background: var(--blue);
  color: white;
  box-shadow: 0 4px 16px rgba(59,130,246,0.3);
}
.btn-ghost {
  background: var(--card);
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-danger {
  background: var(--danger);
  color: white;
}
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--radius-sm); }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border2);
}
.card-mx { margin: 0 16px 12px; }
.card-yellow-border { border-left: 3px solid var(--yellow); }

/* ── Hero / Banner ────────────────────────────────────────────────────────── */
.home-hero {
  background: linear-gradient(145deg, #0f1d30 0%, #152c48 45%, #1a3a6b 100%);
  margin: 16px;
  border-radius: var(--radius-lg);
  padding: 28px 22px;
  border: 1px solid rgba(59,130,246,0.2);
  box-shadow: 0 8px 40px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.03) inset;
  position: relative;
  overflow: hidden;
}
.home-hero::before {
  content: '';
  position: absolute;
  right: -30px; top: -30px;
  width: 160px; height: 160px;
  background: radial-gradient(circle, rgba(59,130,246,0.12) 0%, transparent 70%);
  pointer-events: none;
}
.home-hero::after {
  content: '🌍';
  position: absolute;
  right: 16px; top: 14px;
  font-size: 56px;
  opacity: 0.14;
  pointer-events: none;
}
.home-hero h2 { font-size: 12px; font-weight: 700; color: var(--yellow); letter-spacing: 1.5px; text-transform: uppercase; margin-bottom: 6px; }
.home-hero h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; margin-bottom: 4px; }
.home-hero p { font-size: 14px; color: var(--text2); margin-bottom: 18px; }

/* ── Stat Chips ───────────────────────────────────────────────────────────── */
.stat-row {
  display: flex;
  gap: 10px;
  padding: 0 16px;
  margin-bottom: 16px;
}
.stat-chip {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
  border: 1px solid var(--border2);
}
.stat-chip .val {
  font-size: 26px;
  font-weight: 800;
  color: var(--yellow);
  letter-spacing: -0.5px;
  line-height: 1;
}
.stat-chip .lbl {
  font-size: 11px;
  color: var(--text3);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Section Label ────────────────────────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 16px 20px 8px;
}

/* ── List Section ─────────────────────────────────────────────────────────── */
.list-section {
  background: var(--card);
  border-radius: var(--radius);
  margin: 0 16px 16px;
  overflow: hidden;
  border: 1px solid var(--border2);
}
.list-item {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  gap: 12px;
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--card2); }
.list-icon {
  width: 40px; height: 40px;
  border-radius: 11px;
  background: var(--yellow-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}
.list-icon.blue { background: var(--blue-dim); }
.list-text { flex: 1; min-width: 0; }
.list-text h3 { font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-text p { font-size: 12px; color: var(--text3); margin-top: 2px; }
.chevron { color: var(--text3); font-size: 20px; }

/* ── Study Set Cards ──────────────────────────────────────────────────────── */
.set-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 16px;
}
.set-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: transform 0.15s, background 0.15s;
  border: 1px solid var(--border2);
  position: relative;
  overflow: hidden;
}
.set-card:active { transform: scale(0.97); background: var(--card2); }
.set-card-icon { font-size: 28px; margin-bottom: 10px; }
.set-card-name { font-size: 14px; font-weight: 700; margin-bottom: 4px; line-height: 1.3; }
.set-card-meta { font-size: 11px; color: var(--text3); }
.set-card-badge {
  position: absolute;
  top: 10px; right: 10px;
  background: var(--yellow);
  color: #0F1D30;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 20px;
}
.set-card-new {
  border: 2px dashed rgba(255,255,255,0.12);
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 110px;
}
.set-card-new .plus { font-size: 28px; color: var(--text3); margin-bottom: 6px; }
.set-card-new span { font-size: 13px; color: var(--text3); font-weight: 500; }

/* ── Mode Cards ───────────────────────────────────────────────────────────── */
.mode-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px 16px;
}
.mode-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  border: 2px solid var(--border2);
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  display: flex;
  gap: 14px;
  align-items: flex-start;
}
.mode-card:active { transform: scale(0.98); }
.mode-card.selected { border-color: var(--yellow); background: var(--yellow-dim); box-shadow: 0 0 0 4px var(--yellow-glow); }
.mode-icon { font-size: 28px; flex-shrink: 0; margin-top: 2px; }
.mode-info h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.mode-info p { font-size: 13px; color: var(--text2); line-height: 1.5; }
.mode-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-top: 6px;
}
.mode-badge-green  { background: var(--success-dim); color: var(--success); }
.mode-badge-yellow { background: var(--yellow-dim);  color: var(--yellow);  }
.mode-badge-blue   { background: var(--blue-dim);    color: var(--blue);    }
.mode-badge-purple { background: rgba(139,92,246,0.15); color: #a78bfa;     }

.mode-card.premium-mode {
  border-color: rgba(139,92,246,0.4);
  background: linear-gradient(135deg, var(--card) 0%, rgba(139,92,246,0.06) 100%);
}
.mode-card.premium-mode.selected {
  border-color: #a78bfa;
  background: rgba(139,92,246,0.12);
  box-shadow: 0 0 0 4px rgba(139,92,246,0.15);
}
.mode-card.premium-mode .mode-icon::after {
  content: '✦';
  font-size: 10px;
  color: #a78bfa;
  position: absolute;
  top: -4px; right: -4px;
}

/* ── Upload Zone ──────────────────────────────────────────────────────────── */
.upload-zone {
  margin: 0 16px 12px;
  border: 2px dashed rgba(245,158,11,0.3);
  border-radius: var(--radius-lg);
  padding: 36px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  background: rgba(245,158,11,0.03);
}
.upload-zone:hover { border-color: var(--yellow); background: var(--yellow-dim); }
.upload-zone.drag-over { border-color: var(--yellow); background: var(--yellow-dim); }
.upload-icon { font-size: 44px; margin-bottom: 10px; }
.upload-zone h3 { font-size: 17px; font-weight: 700; margin-bottom: 6px; }
.upload-zone p { font-size: 13px; color: var(--text3); }
.upload-zone input { display: none; }

.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 16px 8px;
  border: 1px solid var(--border2);
}
.file-chip-icon { font-size: 22px; flex-shrink: 0; }
.file-chip-name { flex: 1; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-remove {
  background: none; border: none;
  color: var(--text3); font-size: 20px;
  cursor: pointer; padding: 0 2px;
  line-height: 1;
}
.file-chip-status { font-size: 11px; color: var(--success); font-weight: 600; }
.file-chip-processing { font-size: 11px; color: var(--yellow); font-weight: 600; }

/* ── Processing Overlay ───────────────────────────────────────────────────── */
.processing-overlay {
  position: fixed; inset: 0;
  background: rgba(21,34,56,0.9);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100;
  gap: 16px;
}
.spinner {
  width: 48px; height: 48px;
  border: 4px solid rgba(245,158,11,0.2);
  border-top-color: var(--yellow);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-overlay p { font-size: 16px; color: var(--text2); font-weight: 500; }

/* ── Test Taking ──────────────────────────────────────────────────────────── */
.test-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top,16px) 0 0;
}

.test-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px 10px;
  flex-shrink: 0;
}
.test-progress-wrap { flex: 1; margin: 0 14px; }
.test-progress-track {
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 4px;
  overflow: hidden;
}
.test-progress-fill {
  height: 100%;
  background: var(--yellow);
  border-radius: 4px;
  transition: width 0.35s ease;
}
.test-q-counter { font-size: 13px; color: var(--text3); font-weight: 600; text-align: right; white-space: nowrap; }

.test-timer {
  font-size: 15px;
  font-weight: 700;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
  min-width: 42px;
}
.test-timer.warn { color: var(--yellow); }
.test-timer.danger { color: var(--danger); animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:0.5} }

.test-question-card {
  margin: 12px 16px;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  border: 1px solid var(--border2);
  flex-shrink: 0;
}
.test-qtype-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 3px 10px;
  border-radius: 20px;
  background: var(--yellow-dim);
  color: var(--yellow);
  margin-bottom: 14px;
}
.test-qtype-badge.blue     { background: var(--blue-dim); color: var(--blue); }
.test-qtype-badge.web      { background: var(--success-dim); color: var(--success); }
.test-qtype-badge.math     { background: rgba(139,92,246,0.15); color: #a78bfa; }
.test-qtype-badge.academic { background: rgba(124,58,237,0.15); color: #7C3AED; }

/* ── Math Display ─────────────────────────────────────────────────────────── */
.katex { font-size: 1.1em; }
.katex-display { margin: 8px 0; overflow-x: auto; }
.math-block {
  background: var(--card2);
  border-left: 3px solid #a78bfa;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 10px 14px;
  margin: 8px 0;
  font-family: 'Courier New', monospace;
  font-size: 15px;
  color: var(--text);
  overflow-x: auto;
}
.test-question-text {
  font-size: 18px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: -0.2px;
}

.test-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 16px 16px;
  flex: 1;
}

.option-btn {
  width: 100%;
  padding: 16px 18px;
  background: var(--card);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
  line-height: 1.4;
}
.option-btn:active { background: var(--card2); }
.option-btn { display: flex; align-items: center; gap: 12px; }
.option-btn.selected { border-color: var(--yellow); background: var(--yellow-dim); color: var(--yellow-light); }
.option-btn.correct { border-color: var(--success); background: var(--success-dim); color: var(--success); }
.option-btn.wrong { border-color: var(--danger); background: var(--danger-dim); color: var(--danger); }
.option-btn.reveal-correct { border-color: var(--success); background: var(--success-dim); color: var(--success); }
.option-btn:disabled { cursor: default; }

.option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
  transition: background 0.15s;
}
.option-btn.selected .option-letter  { background: rgba(245,158,11,0.3); }
.option-btn.correct .option-letter   { background: rgba(16,185,129,0.3); }
.option-btn.wrong .option-letter     { background: rgba(255,0,0,0.3); }
.option-btn.reveal-correct .option-letter { background: rgba(16,185,129,0.3); }
.option-text { flex: 1; line-height: 1.4; }

.tf-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 16px 16px;
}

.fill-blank-input {
  width: 100%;
  background: var(--card2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 17px;
  font-weight: 500;
  padding: 16px 18px;
  font-family: inherit;
  outline: none;
  margin: 0 16px 12px;
  width: calc(100% - 32px);
}
.fill-blank-input:focus { border-color: var(--yellow); }
.fill-blank-input.math-input { font-family: 'Courier New', monospace; font-size: 18px; letter-spacing: 0.5px; }
.fill-blank-input.math-input:focus { border-color: #a78bfa; }

.test-feedback-bar {
  margin: 0 16px 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
.test-feedback-bar.correct { background: var(--success-dim); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }
.test-feedback-bar.wrong { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(255,0,0,0.2); }

.test-next-btn {
  margin: auto 16px 24px;
  flex-shrink: 0;
}

/* ── Results ──────────────────────────────────────────────────────────────── */
.score-ring-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 20px 20px;
}
.score-ring { position: relative; width: 140px; height: 140px; }
.score-ring svg { width: 140px; height: 140px; }
.score-ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.score-pct { font-size: 36px; font-weight: 800; line-height: 1; }
.score-sub { font-size: 12px; color: var(--text3); margin-top: 2px; }

.result-breakdown {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 0 16px 16px;
}
.breakdown-chip {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px 8px;
  text-align: center;
  border: 1px solid var(--border2);
}
.breakdown-chip .bval { font-size: 22px; font-weight: 800; }
.breakdown-chip .blbl { font-size: 10px; color: var(--text3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.4px; }
.bval-green { color: var(--success); }
.bval-red { color: var(--danger); }
.bval-yellow { color: var(--yellow); }

.weak-highlight { background: rgba(255,0,0,0.18); border-radius: 3px; padding: 1px 3px; color: #FF6B6B; }

/* ── Flashcards ───────────────────────────────────────────────────────────── */
.flashcard-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top,16px) 16px 0;
}
.fc-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0 10px;
}
.fc-counter { font-size: 13px; color: var(--text3); font-weight: 600; }
.fc-progress-track {
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 20px;
}
.fc-progress-fill {
  height: 100%;
  background: var(--yellow);
  border-radius: 3px;
  transition: width 0.35s ease;
}

.flashcard-container {
  perspective: 1200px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.flashcard {
  width: 100%;
  max-width: 380px;
  height: 280px;
  position: relative;
  cursor: pointer;
  user-select: none;
}
.flashcard-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}
.flashcard.flipped .flashcard-inner { transform: rotateY(180deg); }
.flashcard-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px 24px;
  text-align: center;
}
.flashcard-front {
  background: var(--card);
  border: 2px solid var(--border);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.flashcard-back {
  background: linear-gradient(135deg, #162440, #1a3060);
  border: 2px solid rgba(59,130,246,0.3);
  box-shadow: 0 8px 32px rgba(59,130,246,0.15);
  transform: rotateY(180deg);
}
.fc-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; opacity: 0.5; }
.fc-front-text { font-size: 18px; font-weight: 700; line-height: 1.45; color: var(--text); }
.fc-back-text { font-size: 15px; line-height: 1.6; color: var(--text2); }
.fc-tap-hint { font-size: 12px; color: var(--text3); margin-top: 16px; }

.fc-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0 24px;
  width: 100%;
  max-width: 380px;
}
.fc-btn {
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.15s;
  display: flex; align-items: center; justify-content: center; gap: 6px;
}
.fc-btn:active { opacity: 0.8; transform: scale(0.97); }
.fc-btn-again { background: var(--danger-dim); color: var(--danger); border: 1px solid rgba(255,0,0,0.2); }
.fc-btn-got-it { background: var(--success-dim); color: var(--success); border: 1px solid rgba(16,185,129,0.2); }

/* ── Progress Charts ──────────────────────────────────────────────────────── */
.progress-bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.progress-bar-label { font-size: 13px; color: var(--text2); width: 110px; flex-shrink: 0; }
.progress-bar-track {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: var(--yellow);
  border-radius: 8px;
  transition: width 0.6s ease;
}
.progress-bar-val { font-size: 13px; font-weight: 700; color: var(--text); width: 36px; text-align: right; flex-shrink: 0; }

.activity-grid {
  display: flex;
  gap: 4px;
  padding: 0 16px;
  margin-bottom: 16px;
  align-items: flex-end;
}
.activity-bar {
  flex: 1;
  min-height: 4px;
  background: var(--yellow-dim);
  border-radius: 3px 3px 0 0;
  transition: height 0.4s ease;
  position: relative;
}
.activity-bar.active { background: var(--yellow); }
.activity-day { text-align: center; font-size: 10px; color: var(--text3); margin-top: 4px; }

/* ── Input / Form ─────────────────────────────────────────────────────────── */
.input-field {
  width: 100%;
  background: var(--card2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 16px;
  padding: 14px 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.input-field:focus { border-color: var(--yellow); }
.input-field::placeholder { color: var(--text3); }
.input-wrap { padding: 0 16px 12px; }
.input-label { font-size: 13px; color: var(--text3); font-weight: 600; margin-bottom: 6px; padding: 0 16px; }

/* ── Slider ───────────────────────────────────────────────────────────────── */
.qty-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px 16px;
}
.qty-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--card2);
  border-radius: 4px;
  outline: none;
}
.qty-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--yellow);
  cursor: pointer;
  box-shadow: 0 2px 8px var(--yellow-glow);
}
.qty-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--yellow);
  width: 36px;
  text-align: center;
}

/* ── Tag Chips ────────────────────────────────────────────────────────────── */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px 14px; }
.tag-chip {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.tag-yellow { background: var(--yellow-dim); color: var(--yellow); }
.tag-blue { background: var(--blue-dim); color: var(--blue); }
.tag-green { background: var(--success-dim); color: var(--success); }

/* ── Notification Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 100px; left: 50%; transform: translateX(-50%);
  background: var(--card);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 30px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  z-index: 999;
  white-space: nowrap;
  border: 1px solid var(--border);
  animation: toastIn 0.25s ease-out;
}
@keyframes toastIn { from { opacity:0; transform: translateX(-50%) translateY(10px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }

/* ── Empty State ──────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 32px;
  text-align: center;
}
.empty-icon { font-size: 52px; margin-bottom: 14px; opacity: 0.5; }
.empty-state h3 { font-size: 18px; font-weight: 700; margin-bottom: 8px; }
.empty-state p { font-size: 14px; color: var(--text3); line-height: 1.6; max-width: 260px; margin-bottom: 20px; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex; align-items: flex-end;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--card);
  width: 100%;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 24px 20px;
  border-top: 1px solid var(--border);
  animation: slideUp 0.25s ease-out;
}
@keyframes slideUp { from { transform: translateY(30px); opacity:0; } to { transform: translateY(0); opacity:1; } }
.modal h2 { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.modal p { font-size: 14px; color: var(--text3); margin-bottom: 20px; line-height: 1.6; }
.modal-btns { display: flex; flex-direction: column; gap: 10px; }

/* ── Pomodoro ─────────────────────────────────────────────────────────────── */
.pomo-card { text-align: center; padding: 20px 16px; }
.pomo-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); margin-bottom: 8px; }
.pomo-time { font-size: 48px; font-weight: 800; letter-spacing: -2px; color: var(--text); font-variant-numeric: tabular-nums; margin-bottom: 14px; }
.pomo-controls { display: flex; gap: 10px; justify-content: center; }

/* ── Study Guide ──────────────────────────────────────────────────────────── */
.guide-card { padding: 12px 0; border-bottom: 1px solid var(--border); }
.guide-card:last-child { border-bottom: none; padding-bottom: 0; }
.guide-term { font-size: 15px; font-weight: 700; color: var(--yellow); margin-bottom: 4px; }
.guide-def  { font-size: 13px; color: var(--text2); line-height: 1.6; }

/* ── Color Dots ───────────────────────────────────────────────────────────── */
.color-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: border-color 0.15s, transform 0.15s;
}
.color-dot.selected { border-color: white; transform: scale(1.15); }

/* ── Due Badge ────────────────────────────────────────────────────────────── */
.due-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  background: var(--yellow-dim); color: var(--yellow);
  padding: 2px 7px; border-radius: 20px;
  margin-left: 6px; vertical-align: middle;
}

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-yellow { color: var(--yellow); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text3); }
.fw-800 { font-weight: 800; }
.fs-12 { font-size: 12px; }
.mt-8 { margin-top: 8px; }
.divider { height: 1px; background: var(--border); margin: 0 16px 16px; }

/* ── XP / Level Bar ───────────────────────────────────────────────────────── */
.xp-bar-wrap { padding: 0 16px 14px; }
.level-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--yellow);
  color: #0F1D30;
  font-size: 12px;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}
.xp-bar-track {
  height: 8px;
  background: rgba(255,255,255,0.07);
  border-radius: 8px;
  overflow: hidden;
  margin-top: 8px;
}
.xp-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--yellow), #fbbf24);
  border-radius: 8px;
  transition: width 0.6s ease;
}

/* ── Combo Overlay ────────────────────────────────────────────────────────── */
.combo-overlay {
  position: fixed;
  top: 28%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--yellow);
  color: #0F1D30;
  padding: 12px 28px;
  border-radius: 30px;
  font-size: 20px;
  font-weight: 800;
  z-index: 500;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 8px 32px var(--yellow-glow);
  animation: comboIn 0.3s cubic-bezier(0.34,1.56,0.64,1), comboOut 0.3s ease-in 1.1s forwards;
}
@keyframes comboIn {
  from { opacity: 0; transform: translateX(-50%) scale(0.6); }
  to   { opacity: 1; transform: translateX(-50%) scale(1); }
}
@keyframes comboOut {
  to { opacity: 0; transform: translateX(-50%) translateY(-16px); }
}

/* ── Achievement Toast ────────────────────────────────────────────────────── */
.achievement-toast {
  position: fixed;
  top: max(env(safe-area-inset-top, 16px), 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  border: 1px solid var(--yellow);
  padding: 12px 18px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 999;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 20px var(--yellow-glow);
  white-space: nowrap;
  animation: toastIn 0.3s ease-out;
}

/* ── Level Up Overlay ─────────────────────────────────────────────────────── */
.level-up-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.level-up-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  text-align: center;
  border: 2px solid var(--yellow);
  box-shadow: 0 0 60px var(--yellow-glow);
  max-width: 320px;
  width: 90%;
}
.level-up-card .lv-icon { font-size: 64px; display: block; margin-bottom: 8px; }
.level-up-card h2 { font-size: 28px; font-weight: 800; color: var(--yellow); margin-bottom: 4px; }
.level-up-card .lv-num { font-size: 72px; font-weight: 800; line-height: 1; margin: 8px 0; color: var(--text); }
.level-up-card p { color: var(--text2); margin-bottom: 24px; font-size: 15px; }

/* ── Achievements ─────────────────────────────────────────────────────────── */
.achievement-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 14px;
}
.achievement-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
}
.achievement-chip.unlocked {
  background: var(--yellow-dim);
  border-color: rgba(245,158,11,0.3);
  color: var(--yellow);
}
.achievement-chip.locked { color: var(--text3); opacity: 0.5; }

/* ── Highlights Page ──────────────────────────────────────────────────────── */
.highlight-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.highlight-item:last-child { border-bottom: none; }
.highlight-topic {
  font-size: 11px;
  font-weight: 700;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.highlight-text {
  font-size: 14px;
  color: var(--text2);
  line-height: 1.65;
  border-left: 3px solid var(--danger);
  padding-left: 10px;
  margin-bottom: 8px;
}
.highlight-q {
  font-size: 12px;
  color: var(--text3);
  font-style: italic;
  padding-left: 13px;
}

/* ── Pet / Buddy Page ─────────────────────────────────────────────────────── */
.animal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 0 16px 16px;
}
.animal-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 14px;
  cursor: pointer;
  border: 2px solid var(--border2);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
  text-align: center;
}
.animal-card:active { transform: scale(0.96); }
.animal-card.selected { border-color: var(--yellow); background: var(--yellow-dim); }
.animal-emoji { font-size: 40px; display: block; margin-bottom: 8px; }
.animal-name { font-size: 15px; font-weight: 800; margin-bottom: 3px; }
.animal-tag { font-size: 11px; color: var(--text3); font-weight: 600; }

.pet-display {
  margin: 16px;
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 28px 20px 22px;
  text-align: center;
  border: 1px solid var(--border2);
  position: relative;
  overflow: hidden;
}
.pet-display::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(245,158,11,0.08) 0%, transparent 70%);
  pointer-events: none;
}
.pet-big-emoji {
  font-size: 80px;
  display: block;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 4px 16px rgba(0,0,0,0.4));
  animation: petBob 3s ease-in-out infinite;
}
@keyframes petBob {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.pet-mood-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}
.pet-speech {
  font-size: 14px;
  color: var(--text2);
  font-style: italic;
  margin-top: 8px;
  min-height: 20px;
}

.meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.meter-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text3);
  width: 76px;
  flex-shrink: 0;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.meter-track {
  flex: 1;
  height: 10px;
  background: rgba(255,255,255,0.07);
  border-radius: 10px;
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: 10px;
  transition: width 0.6s ease;
}
.meter-fill.hunger  { background: linear-gradient(90deg, #F59E0B, #fbbf24); }
.meter-fill.happy   { background: linear-gradient(90deg, #3B82F6, #60a5fa); }
.meter-fill.health  { background: linear-gradient(90deg, #10B981, #34d399); }
.meter-val {
  font-size: 12px;
  font-weight: 700;
  color: var(--text2);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

.pet-style-card {
  margin: 0 16px 12px;
  background: var(--card2);
  border-radius: var(--radius);
  padding: 14px 16px;
  border: 1px solid var(--border2);
}
.pet-style-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}
.pet-style-desc { font-size: 13px; color: var(--text2); line-height: 1.6; }

.pet-speech-bubble {
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 13px;
  font-style: italic;
  color: var(--text2);
  margin: 0 16px 12px;
  position: relative;
}
.pet-speech-bubble::before {
  content: '';
  position: absolute;
  top: -8px; left: 24px;
  border: 8px solid transparent;
  border-bottom-color: var(--border);
  border-top: none;
  width: 0; height: 0;
}

/* ── AI Style / Difficulty chips ──────────────────────────────────────────── */
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border-radius: 20px;
  border: 2px solid var(--border);
  background: var(--card);
  color: var(--text2);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  font-family: inherit;
}
.ai-chip:active { transform: scale(0.95); }
.ai-chip.selected {
  border-color: #a78bfa;
  background: rgba(139,92,246,0.15);
  color: #c4b5fd;
}

/* ── AI Explanation box (shown after answers) ─────────────────────────────── */
.ai-explanation {
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(139,92,246,0.1);
  border-left: 3px solid #a78bfa;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.55;
  color: #c4b5fd;
  text-align: left;
}

/* ── Card hover depth ─────────────────────────────────────────────────────── */
.card { transition: box-shadow 0.2s; }
.list-item { transition: background 0.15s, transform 0.1s; }
.list-item:active { transform: scale(0.99); }

/* ── Auth overlay ─────────────────────────────────────────────────────────── */
.auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: #0e1927;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
  -webkit-overflow-scrolling: touch;
}

.auth-input {
  width: 100%;
  background: #152238;
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  padding: 14px 16px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.auth-input:focus  { border-color: #F59E0B; }
.auth-input::placeholder { color: #5A7089; }
