/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  scroll-behavior: smooth;
}
body {
  min-height: 100dvh;
  font-family: 'General Sans', 'Inter', sans-serif;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  transition: background 0.3s ease, color 0.3s ease;
}

/* ===== DESIGN TOKENS ===== */
:root, [data-theme="dark"] {
  --bg: #0f1117;
  --surface: #181a22;
  --surface-2: #1e2130;
  --surface-3: #262a3a;
  --border: #2e3348;
  --border-active: #4a5070;
  --text: #e4e5ea;
  --text-muted: #8b8fa3;
  --text-faint: #5c6078;
  --accent-bio: #34d399;
  --accent-bio-bg: rgba(52,211,153,0.12);
  --accent-chem: #60a5fa;
  --accent-chem-bg: rgba(96,165,250,0.12);
  --accent-phys: #f97316;
  --accent-phys-bg: rgba(249,115,22,0.12);
  --accent-cs: #c084fc;
  --accent-cs-bg: rgba(192,132,252,0.12);
  --accent-maths: #f472b6;
  --accent-maths-bg: rgba(244,114,182,0.12);
  --accent-enlang: #fbbf24;
  --accent-enlang-bg: rgba(251,191,36,0.12);
  --accent-enlit: #a78bfa;
  --accent-enlit-bg: rgba(167,139,250,0.12);
  --accent-btec: #fb923c;
  --accent-btec-bg: rgba(251,146,60,0.12);
  --accent-food: #4ade80;
  --accent-food-bg: rgba(74,222,128,0.12);
  --accent-geo: #38bdf8;
  --accent-geo-bg: rgba(56,189,248,0.12);
  --accent-art: #f43f5e;
  --accent-art-bg: rgba(244,63,94,0.12);
  --accent-combined: #a3e635;
  --accent-combined-bg: rgba(163,230,53,0.12);
  --correct: #34d399;
  --correct-bg: rgba(52,211,153,0.15);
  --wrong: #f87171;
  --wrong-bg: rgba(248,113,113,0.15);
  --warning: #fbbf24;
  --warning-bg: rgba(251,191,36,0.12);
  --radius: 0.75rem;
  --radius-lg: 1rem;
  --radius-xl: 1.25rem;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f0f1f4;
  --surface-3: #e6e8ed;
  --border: #d4d7e0;
  --border-active: #a0a5b8;
  --text: #1a1d2a;
  --text-muted: #6b7085;
  --text-faint: #9da2b5;
  --correct-bg: rgba(52,211,153,0.18);
  --wrong-bg: rgba(248,113,113,0.18);
  --warning-bg: rgba(251,191,36,0.15);
  --shadow: 0 4px 24px rgba(0,0,0,0.08);
}

/* ===== TYPOGRAPHY ===== */
.font-display { font-family: 'Chillax', 'General Sans', sans-serif; }

/* ===== LAYOUT ===== */
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  min-height: 100dvh;
}

/* ===== HEADER ===== */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.header h1 {
  font-family: 'Chillax', sans-serif;
  font-weight: 600;
  font-size: clamp(1.1rem, 1rem + 0.5vw, 1.35rem);
  letter-spacing: -0.02em;
}
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.btn-icon {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}
.btn-icon:hover { background: var(--surface-3); color: var(--text); }
.btn-icon .badge-dot {
  position: absolute;
  top: 4px; right: 4px;
  width: 7px; height: 7px;
  background: var(--wrong);
  border-radius: 50%;
  border: 1.5px solid var(--bg);
}

/* ===== HOME ===== */
.home-title {
  font-family: 'Chillax', sans-serif;
  font-weight: 700;
  font-size: clamp(1.75rem, 1.2rem + 2vw, 2.5rem);
  line-height: 1.15;
  margin-bottom: 0.5rem;
}
.home-sub {
  color: var(--text-muted);
  margin-bottom: 1.75rem;
  font-size: clamp(0.95rem, 0.9rem + 0.3vw, 1.1rem);
}

/* ===== WEAK SPOTS BANNER ===== */
.weak-spots-banner {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--wrong);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  cursor: pointer;
  transition: all 0.18s ease;
}
.weak-spots-banner:hover { border-color: var(--border-active); border-left-color: var(--wrong); }
.weak-spots-banner-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.4rem;
}
.weak-spots-banner-title {
  font-weight: 600;
  font-size: 0.95rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.weak-spots-count {
  font-size: 0.75rem;
  background: var(--wrong-bg);
  color: var(--wrong);
  padding: 0.15rem 0.5rem;
  border-radius: var(--radius);
  font-weight: 600;
}
.weak-spots-preview {
  display: flex; flex-wrap: wrap; gap: 0.4rem;
  margin-top: 0.5rem;
}
.weak-tag {
  font-size: 0.75rem;
  background: var(--surface-2);
  color: var(--text-muted);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* ===== SUBJECT GRID ===== */
.section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.5rem;
}
.subject-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.4rem;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}
.subject-card:hover { border-color: var(--border-active); transform: translateY(-2px); box-shadow: var(--shadow); }
.subject-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
}
.subject-card[data-subject="Biology"]::before { background: var(--accent-bio); }
.subject-card[data-subject="Chemistry"]::before { background: var(--accent-chem); }
.subject-card[data-subject="Physics"]::before { background: var(--accent-phys); }
.subject-card[data-subject="Computer Science"]::before { background: var(--accent-cs); }
.subject-card[data-subject="Maths"]::before { background: var(--accent-maths); }
.subject-card[data-subject="English Language"]::before { background: var(--accent-enlang); }
.subject-card[data-subject="English Literature"]::before { background: var(--accent-enlit); }
.subject-card[data-subject="BTec Sport"]::before { background: var(--accent-btec); }
.subject-card[data-subject="Food Technology"]::before { background: var(--accent-food); }
.subject-card[data-subject="Geography"]::before { background: var(--accent-geo); }
.subject-card[data-subject="Art & Design"]::before { background: var(--accent-art); }
.subject-card[data-subject="Combined Science"]::before { background: var(--accent-combined); }

.subject-icon {
  width: 40px; height: 40px; border-radius: 0.625rem;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem; margin-bottom: 0.875rem;
}
.subject-card[data-subject="Biology"] .subject-icon { background: var(--accent-bio-bg); }
.subject-card[data-subject="Chemistry"] .subject-icon { background: var(--accent-chem-bg); }
.subject-card[data-subject="Physics"] .subject-icon { background: var(--accent-phys-bg); }
.subject-card[data-subject="Computer Science"] .subject-icon { background: var(--accent-cs-bg); }
.subject-card[data-subject="Maths"] .subject-icon { background: var(--accent-maths-bg); }
.subject-card[data-subject="English Language"] .subject-icon { background: var(--accent-enlang-bg); }
.subject-card[data-subject="English Literature"] .subject-icon { background: var(--accent-enlit-bg); }
.subject-card[data-subject="BTec Sport"] .subject-icon { background: var(--accent-btec-bg); }
.subject-card[data-subject="Food Technology"] .subject-icon { background: var(--accent-food-bg); }
.subject-card[data-subject="Geography"] .subject-icon { background: var(--accent-geo-bg); }
.subject-card[data-subject="Art & Design"] .subject-icon { background: var(--accent-art-bg); }
.subject-card[data-subject="Combined Science"] .subject-icon { background: var(--accent-combined-bg); }

.subject-card h3 {
  font-family: 'Chillax', sans-serif; font-weight: 600; font-size: 1.05rem; margin-bottom: 0.2rem;
}
.subject-card .topic-count { color: var(--text-muted); font-size: 0.85rem; }
.subject-card .q-count { color: var(--text-faint); font-size: 0.78rem; margin-top: 0.15rem; }
.subject-card .weak-indicator {
  position: absolute; top: 1rem; right: 1rem;
  font-size: 0.7rem; font-weight: 600;
  background: var(--wrong-bg); color: var(--wrong);
  padding: 0.15rem 0.45rem; border-radius: 0.375rem;
}

/* ===== BACK BUTTON ===== */
.back-btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  color: var(--text-muted); font-size: 0.9rem; cursor: pointer;
  background: none; border: none; font-family: inherit;
  margin-bottom: 1.25rem; transition: color 0.15s;
}
.back-btn:hover { color: var(--text); }

/* ===== TOPIC LIST ===== */
.topic-header { margin-bottom: 1.5rem; }
.topic-header h2 {
  font-family: 'Chillax', sans-serif; font-weight: 700;
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); margin-bottom: 0.25rem;
}
.topic-header .paper-info { color: var(--text-muted); font-size: 0.9rem; }

.topic-list { display: flex; flex-direction: column; gap: 0.5rem; }
.topic-item {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.875rem 1.125rem;
  cursor: pointer; transition: all 0.18s ease;
}
.topic-item:hover { border-color: var(--border-active); background: var(--surface-2); }
.topic-item .topic-name { font-weight: 500; font-size: 0.9rem; }
.topic-item .topic-meta { display: flex; align-items: center; gap: 0.625rem; flex-shrink: 0; }
.topic-item .topic-q-count { color: var(--text-muted); font-size: 0.78rem; white-space: nowrap; }
.topic-item .topic-weak { font-size: 0.7rem; font-weight: 600; background: var(--wrong-bg); color: var(--wrong); padding: 0.15rem 0.4rem; border-radius: 0.375rem; }
.topic-item .arrow { color: var(--text-faint); font-size: 1.1rem; }

.start-all-btn {
  display: block; width: 100%; margin-top: 1rem; padding: 0.875rem;
  font-family: 'General Sans', sans-serif; font-weight: 600; font-size: 0.95rem;
  border: none; border-radius: var(--radius); cursor: pointer;
  transition: all 0.18s ease; color: #fff;
}
.start-all-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.start-all-btn[data-subject="Biology"] { background: #059669; }
.start-all-btn[data-subject="Chemistry"] { background: #2563eb; }
.start-all-btn[data-subject="Physics"] { background: #ea580c; }
.start-all-btn[data-subject="Computer Science"] { background: #9333ea; }
.start-all-btn[data-subject="Maths"] { background: #db2777; }
.start-all-btn[data-subject="English Language"] { background: #d97706; }
.start-all-btn[data-subject="English Literature"] { background: #7c3aed; }
.start-all-btn[data-subject="BTec Sport"] { background: #ea580c; }
.start-all-btn[data-subject="Food Technology"] { background: #16a34a; }
.start-all-btn[data-subject="Geography"] { background: #0284c7; }
.start-all-btn[data-subject="Art & Design"] { background: #be123c; }
.start-all-btn[data-subject="Combined Science"] { background: #65a30d; }

/* ===== QUIZ SETUP ===== */
.mode-selector { display: flex; flex-direction: column; gap: 0.625rem; margin-top: 1rem; }
.mode-btn {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%; padding: 1rem 1.25rem;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; font-family: inherit;
  font-size: 0.95rem; color: var(--text); text-align: left; transition: all 0.18s ease;
}
.mode-btn:hover { border-color: var(--border-active); background: var(--surface-2); }
.mode-btn.mode-weak { border-color: rgba(248,113,113,0.35); }
.mode-btn.mode-weak:hover { border-color: var(--wrong); }
.mode-label { font-weight: 600; }
.mode-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
.mode-count { color: var(--text-faint); font-size: 0.8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mode-count.mode-count-warn { color: var(--wrong); }

/* ===== QUIZ VIEW ===== */
.quiz-top-bar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem;
}
.subject-badge {
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.3rem 0.65rem; border-radius: var(--radius);
}
.badge-Biology { background: var(--accent-bio-bg); color: var(--accent-bio); }
.badge-Chemistry { background: var(--accent-chem-bg); color: var(--accent-chem); }
.badge-Physics { background: var(--accent-phys-bg); color: var(--accent-phys); }
.badge-Computer-Science { background: var(--accent-cs-bg); color: var(--accent-cs); }
.badge-Maths { background: var(--accent-maths-bg); color: var(--accent-maths); }
.badge-English-Language { background: var(--accent-enlang-bg); color: var(--accent-enlang); }
.badge-English-Literature { background: var(--accent-enlit-bg); color: var(--accent-enlit); }
.badge-BTec-Sport { background: var(--accent-btec-bg); color: var(--accent-btec); }
.badge-Food-Technology { background: var(--accent-food-bg); color: var(--accent-food); }
.badge-Geography { background: var(--accent-geo-bg); color: var(--accent-geo); }
.badge-Art-\&-Design { background: var(--accent-art-bg); color: var(--accent-art); }
.badge-Combined-Science { background: var(--accent-combined-bg); color: var(--accent-combined); }

.progress-bar { height: 5px; background: var(--surface-3); border-radius: 3px; margin-bottom: 1.25rem; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.4s cubic-bezier(0.16,1,0.3,1); }
.progress-fill[data-subject="Biology"] { background: var(--accent-bio); }
.progress-fill[data-subject="Chemistry"] { background: var(--accent-chem); }
.progress-fill[data-subject="Physics"] { background: var(--accent-phys); }
.progress-fill[data-subject="Computer Science"] { background: var(--accent-cs); }
.progress-fill[data-subject="Maths"] { background: var(--accent-maths); }
.progress-fill[data-subject="English Language"] { background: var(--accent-enlang); }
.progress-fill[data-subject="English Literature"] { background: var(--accent-enlit); }
.progress-fill[data-subject="BTec Sport"] { background: var(--accent-btec); }
.progress-fill[data-subject="Food Technology"] { background: var(--accent-food); }
.progress-fill[data-subject="Geography"] { background: var(--accent-geo); }
.progress-fill[data-subject="Art & Design"] { background: var(--accent-art); }
.progress-fill[data-subject="Combined Science"] { background: var(--accent-combined); }

.score-display { font-size: 0.82rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.question-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: 1.6rem 1.4rem; margin-bottom: 0.875rem;
}
.question-topic { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.625rem; font-weight: 500; }
.question-text { font-size: clamp(1rem, 0.95rem + 0.3vw, 1.15rem); font-weight: 500; line-height: 1.55; margin-bottom: 1.375rem; }
.difficulty-badge {
  display: inline-block; font-size: 0.68rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  padding: 0.2rem 0.45rem; border-radius: 0.375rem; margin-left: 0.4rem; vertical-align: middle;
}
.difficulty-Foundation { background: rgba(96,165,250,0.15); color: #60a5fa; }
.difficulty-Higher { background: rgba(249,115,22,0.15); color: #f97316; }

/* ===== OPTIONS ===== */
.options { display: flex; flex-direction: column; gap: 0.5rem; }
.option-btn {
  display: flex; align-items: flex-start; gap: 0.75rem;
  width: 100%; padding: 0.875rem 1rem;
  background: var(--surface-2); border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer;
  font-family: inherit; font-size: 0.92rem; line-height: 1.5; color: var(--text); text-align: left;
  transition: all 0.18s ease;
}
.option-btn:hover:not(.answered) { border-color: var(--border-active); background: var(--surface-3); }
.option-letter {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; min-width: 28px; border-radius: 0.4375rem;
  background: var(--surface-3); font-weight: 700; font-size: 0.8rem; color: var(--text-muted);
  transition: all 0.18s ease;
}
.option-text { padding-top: 0.15rem; }
.option-btn.correct { border-color: var(--correct); background: var(--correct-bg); }
.option-btn.correct .option-letter { background: var(--correct); color: #fff; }
.option-btn.wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.option-btn.wrong .option-letter { background: var(--wrong); color: #fff; }
.option-btn.answered { cursor: default; opacity: 0.65; }
.option-btn.correct.answered, .option-btn.wrong.answered { opacity: 1; }

/* ===== EXPLANATION ===== */
.explanation {
  margin-top: 0.875rem; padding: 0.875rem 1.125rem;
  background: var(--surface-2); border-radius: var(--radius);
  border-left: 3px solid var(--correct);
  font-size: 0.88rem; line-height: 1.6; color: var(--text-muted);
  animation: fadeIn 0.3s ease;
}
.explanation.wrong-exp { border-left-color: var(--wrong); }
.explanation strong { color: var(--text); }
.explanation .concept-tag {
  display: inline-block; margin-top: 0.5rem;
  font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--surface-3); color: var(--text-muted);
  padding: 0.2rem 0.5rem; border-radius: 0.375rem;
}

.next-btn {
  display: block; width: 100%; margin-top: 1rem; padding: 0.85rem;
  font-family: 'General Sans', sans-serif; font-weight: 600; font-size: 0.95rem;
  border: none; border-radius: var(--radius); cursor: pointer;
  background: var(--surface-3); color: var(--text); transition: all 0.18s ease;
}
.next-btn:hover { background: var(--border); }

/* ===== STREAK ===== */
.streak { display: flex; align-items: center; gap: 0.35rem; font-size: 0.82rem; font-weight: 600; color: var(--accent-bio); font-variant-numeric: tabular-nums; }
.streak.hot { color: #f97316; animation: pulse 0.5s ease; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.18); } }

/* ===== RESULTS ===== */
.results-card {
  text-align: center; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 2.25rem 1.5rem;
}
.results-emoji { font-size: 3rem; margin-bottom: 0.875rem; }
.results-title {
  font-family: 'Chillax', sans-serif; font-weight: 700;
  font-size: clamp(1.4rem, 1.1rem + 1vw, 1.875rem); margin-bottom: 0.4rem;
}
.results-score {
  font-size: clamp(2.25rem, 1.8rem + 1.8vw, 3.5rem); font-weight: 700;
  font-variant-numeric: tabular-nums; margin: 0.875rem 0;
  font-family: 'Chillax', sans-serif;
}
.results-detail { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.75rem; }
.results-actions { display: flex; gap: 0.625rem; justify-content: center; flex-wrap: wrap; }
.results-btn {
  padding: 0.7rem 1.375rem; font-family: 'General Sans', sans-serif; font-weight: 600;
  font-size: 0.875rem; border: none; border-radius: var(--radius); cursor: pointer; transition: all 0.18s ease;
}
.results-btn.primary { background: var(--text); color: var(--bg); }
.results-btn.primary:hover { opacity: 0.85; }
.results-btn.secondary { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); }
.results-btn.secondary:hover { background: var(--surface-3); }
.results-btn.danger { background: var(--wrong-bg); color: var(--wrong); border: 1px solid rgba(248,113,113,0.3); }
.results-btn.danger:hover { background: rgba(248,113,113,0.2); }

/* ===== REVIEW SECTION ===== */
.review-section { margin-top: 1.75rem; }
.review-section-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.875rem;
}
.review-section h3 { font-family: 'Chillax', sans-serif; font-weight: 600; font-size: 1.1rem; }
.review-item {
  background: var(--surface-2); border-radius: var(--radius); padding: 0.875rem 1.125rem;
  margin-bottom: 0.5rem; border-left: 3px solid var(--wrong);
}
.review-item.was-correct { border-left-color: var(--correct); }
.review-q { font-weight: 500; font-size: 0.875rem; margin-bottom: 0.35rem; }
.review-answer { font-size: 0.78rem; color: var(--text-muted); }
.review-answer span.right { color: var(--correct); font-weight: 600; }
.review-answer span.picked-wrong { color: var(--wrong); font-weight: 600; }
.review-item .review-exp { margin-top: 0.4rem; font-size: 0.78rem; color: var(--text-muted); line-height: 1.5; }

/* ===== WEAK SPOTS VIEW ===== */
.weak-spots-view-header { margin-bottom: 1.5rem; }
.weak-spots-view-header h2 {
  font-family: 'Chillax', sans-serif; font-weight: 700;
  font-size: clamp(1.4rem, 1.1rem + 1.2vw, 1.9rem); margin-bottom: 0.25rem;
}
.weak-spots-view-header p { color: var(--text-muted); font-size: 0.9rem; }

.weak-subject-group { margin-bottom: 1.75rem; }
.weak-subject-label {
  display: flex; align-items: center; gap: 0.625rem;
  font-family: 'Chillax', sans-serif; font-weight: 600; font-size: 1rem;
  margin-bottom: 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border);
}
.weak-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 0.625rem; overflow: hidden;
}
.weak-card-header {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem;
  padding: 1rem 1.125rem; cursor: pointer;
}
.weak-card-header:hover { background: var(--surface-2); }
.weak-card-q { font-weight: 500; font-size: 0.875rem; line-height: 1.45; flex: 1; }
.weak-card-chevron { color: var(--text-faint); font-size: 0.85rem; flex-shrink: 0; margin-top: 0.15rem; transition: transform 0.2s ease; }
.weak-card.open .weak-card-chevron { transform: rotate(180deg); }
.weak-card-body {
  display: none; padding: 0 1.125rem 1rem; border-top: 1px solid var(--border);
}
.weak-card.open .weak-card-body { display: block; }
.weak-card-concept {
  margin-top: 0.75rem; padding: 0.75rem 1rem;
  background: var(--surface-2); border-radius: 0.5rem;
  font-size: 0.85rem; line-height: 1.6; color: var(--text-muted);
  border-left: 3px solid var(--wrong);
}
.weak-card-concept strong { color: var(--text); }
.weak-card-answers { margin-top: 0.75rem; font-size: 0.82rem; }
.weak-card-answers .wa-row { margin-bottom: 0.2rem; color: var(--text-muted); }
.weak-card-answers .wa-correct { color: var(--correct); font-weight: 600; }
.weak-card-answers .wa-wrong { color: var(--wrong); }
.weak-card-actions { display: flex; gap: 0.5rem; margin-top: 0.875rem; }
.weak-card-retest {
  padding: 0.45rem 0.875rem; font-family: 'General Sans', sans-serif; font-weight: 600; font-size: 0.8rem;
  border: none; border-radius: 0.5rem; cursor: pointer; transition: all 0.18s ease;
  background: var(--surface-3); color: var(--text);
}
.weak-card-retest:hover { background: var(--border); }
.weak-card-dismiss {
  padding: 0.45rem 0.875rem; font-family: 'General Sans', sans-serif; font-weight: 600; font-size: 0.8rem;
  border: 1px solid var(--border); border-radius: 0.5rem; cursor: pointer; transition: all 0.18s ease;
  background: none; color: var(--text-muted);
}
.weak-card-dismiss:hover { color: var(--text); background: var(--surface-2); }

.weak-retest-mini {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 0.5rem;
  padding: 0.5rem 0.75rem; margin-top: 0.75rem;
}
.weak-retest-mini-q { font-size: 0.82rem; font-weight: 500; flex: 1; }
.retest-opts { display: flex; flex-direction: column; gap: 0.35rem; margin-top: 0.5rem; }
.retest-opt {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; font-family: inherit; font-size: 0.82rem;
  background: var(--surface-3); border: 1.5px solid var(--border); border-radius: 0.5rem;
  cursor: pointer; text-align: left; color: var(--text); transition: all 0.15s ease;
}
.retest-opt:hover:not(.answered) { border-color: var(--border-active); }
.retest-opt.correct { border-color: var(--correct); background: var(--correct-bg); }
.retest-opt.wrong { border-color: var(--wrong); background: var(--wrong-bg); }
.retest-opt.answered { cursor: default; opacity: 0.7; }
.retest-opt.correct.answered, .retest-opt.wrong.answered { opacity: 1; }
.retest-letter { width: 22px; height: 22px; min-width: 22px; display: flex; align-items: center; justify-content: center; background: var(--surface); border-radius: 0.35rem; font-weight: 700; font-size: 0.75rem; color: var(--text-muted); }
.retest-opt.correct .retest-letter { background: var(--correct); color: #fff; }
.retest-opt.wrong .retest-letter { background: var(--wrong); color: #fff; }
.retest-result { margin-top: 0.5rem; padding: 0.5rem 0.75rem; background: var(--surface-2); border-radius: 0.4rem; font-size: 0.8rem; color: var(--text-muted); }
.retest-result.pass { color: var(--correct); }
.retest-result.fail { color: var(--wrong); }

.empty-weak {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted); font-size: 0.95rem;
}
.empty-weak .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }

/* ===== MINI RETEST IN WEAK CARD ===== */
.retest-section { margin-top: 0.75rem; }

/* ===== ANIMATIONS ===== */
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.fade-in { animation: fadeIn 0.35s ease; }
.slide-up { animation: slideUp 0.35s cubic-bezier(0.16,1,0.3,1); }

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
  #app { padding: 1rem 0.75rem 2.5rem; }
  .question-card { padding: 1.125rem 0.875rem; }
  .option-btn { padding: 0.75rem 0.875rem; }
  .results-card { padding: 1.75rem 0.875rem; }
  .subject-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ===== XP SYSTEM ===== */
.xp-chip {
  font-size: 0.72rem; font-weight: 700;
  padding: 0.3rem 0.65rem; border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(251,191,36,0.18), rgba(249,115,22,0.18));
  color: #fbbf24; border: 1px solid rgba(251,191,36,0.3);
  cursor: default; white-space: nowrap;
}
.xp-bar-wrap {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.75rem 1rem;
  margin-bottom: 1.5rem;
}
.xp-level-info {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.5rem;
}
.xp-level-badge {
  font-weight: 700; font-size: 0.88rem; color: #fbbf24;
}
.xp-total {
  font-size: 0.75rem; color: var(--text-muted);
}
.xp-track {
  height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden;
}
.xp-fill {
  height: 100%;
  background: linear-gradient(90deg, #fbbf24, #f97316);
  border-radius: 3px;
  transition: width 0.6s cubic-bezier(0.16,1,0.3,1);
}

/* XP gained indicator in quiz */
.explanation-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.4rem;
}
.xp-gained {
  font-size: 0.78rem; font-weight: 700; color: #fbbf24;
  background: rgba(251,191,36,0.15); border: 1px solid rgba(251,191,36,0.3);
  padding: 0.2rem 0.5rem; border-radius: 0.375rem;
  animation: xpPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes xpPop {
  0% { transform: scale(0.6) translateY(6px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

/* ===== CONFETTI ===== */
@keyframes confettiBurst {
  0% { transform: translate(0,0) rotate(0deg) scale(1); opacity: 1; }
  100% { transform: translate(var(--tx),var(--ty)) rotate(var(--rot)) scale(0.3); opacity: 0; }
}
.confetti-piece { pointer-events: none; }

/* ===== MASCOT REACTIONS ===== */
.mascot-reaction {
  display: flex; align-items: center; gap: 0.875rem;
  padding: 0.875rem 1rem; border-radius: var(--radius);
  margin-top: 0.875rem; margin-bottom: -0.25rem;
  animation: mascotPop 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
.mascot-correct {
  background: rgba(52,211,153,0.1); border: 1px solid rgba(52,211,153,0.3);
}
.mascot-wrong {
  background: rgba(248,113,113,0.08); border: 1px solid rgba(248,113,113,0.25);
}
.mascot-face {
  font-size: 2.2rem; line-height: 1; flex-shrink: 0;
  animation: faceBounce 0.5s cubic-bezier(0.34,1.56,0.64,1);
}
.mascot-bubble { flex: 1; }
.mascot-say {
  font-weight: 700; font-size: 0.92rem; line-height: 1.3;
  color: var(--text); margin-bottom: 0.2rem;
}
.mascot-sub {
  font-size: 0.78rem; color: var(--text-muted); line-height: 1.4;
}
@keyframes mascotPop {
  0% { transform: scale(0.8) translateY(10px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes faceBounce {
  0% { transform: scale(0.5) rotate(-15deg); }
  60% { transform: scale(1.2) rotate(8deg); }
  100% { transform: scale(1) rotate(0deg); }
}

/* ===== FUN FACT CARD ===== */
.fun-fact-card {
  background: linear-gradient(135deg, var(--surface), var(--surface-2));
  border: 2px solid var(--border-active); border-radius: var(--radius-xl);
  padding: 1.75rem 1.5rem; text-align: center;
  margin-top: 1.5rem;
}
.fun-fact-emoji { font-size: 3rem; margin-bottom: 1rem; animation: spin180 0.6s ease; }
@keyframes spin180 {
  0% { transform: rotate(-20deg) scale(0.5); }
  100% { transform: rotate(0deg) scale(1); }
}
.fun-fact-label {
  font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--text-faint); margin-bottom: 0.75rem;
}
.fun-fact-text {
  font-size: clamp(1rem, 0.9rem + 0.3vw, 1.15rem);
  font-weight: 500; line-height: 1.6; color: var(--text); margin-bottom: 1.5rem;
}
.fun-fact-next {
  display: inline-block; padding: 0.75rem 1.5rem;
  background: var(--text); color: var(--bg);
  border: none; border-radius: var(--radius); font-family: inherit;
  font-weight: 600; font-size: 0.92rem; cursor: pointer;
  transition: opacity 0.18s ease;
}
.fun-fact-next:hover { opacity: 0.85; }

/* ===== OPTION ANIMATIONS ===== */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}
@keyframes bounce {
  0%,100% { transform: scale(1); }
  30% { transform: scale(1.04); }
  60% { transform: scale(0.98); }
  80% { transform: scale(1.02); }
}
.option-btn.shake { animation: shake 0.5s ease; }
.option-btn.bounce { animation: bounce 0.5s ease; }

/* ===== MILESTONE TOAST ===== */
.milestone-toast {
  position: fixed; bottom: 2rem; left: 50%; transform: translateX(-50%) translateY(100px);
  background: var(--surface); border: 1px solid var(--border);
  border-left: 4px solid var(--correct); border-radius: var(--radius);
  padding: 0.75rem 1.25rem; font-weight: 600; font-size: 0.92rem; color: var(--text);
  box-shadow: var(--shadow); z-index: 9998; white-space: nowrap;
  transition: transform 0.35s cubic-bezier(0.34,1.56,0.64,1), opacity 0.35s ease;
  opacity: 0;
}
.milestone-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ===== LEVEL UP TOAST ===== */
.level-up-toast {
  position: fixed; top: 1.5rem; left: 50%; transform: translateX(-50%) translateY(-120px);
  z-index: 9999; transition: transform 0.4s cubic-bezier(0.34,1.56,0.64,1), opacity 0.4s ease;
  opacity: 0;
}
.level-up-toast.show { transform: translateX(-50%) translateY(0); opacity: 1; }
.level-up-inner {
  display: flex; align-items: center; gap: 1rem;
  background: linear-gradient(135deg, #1a1500, #2a2000);
  border: 2px solid #fbbf24; border-radius: var(--radius-xl);
  padding: 1rem 1.5rem; box-shadow: 0 0 40px rgba(251,191,36,0.3);
}
.level-up-emoji { font-size: 2.25rem; animation: faceBounce 0.5s ease; }
.level-up-title { font-weight: 800; font-size: 1rem; color: #fbbf24; letter-spacing: 0.04em; }
.level-up-sub { font-size: 0.82rem; color: rgba(251,191,36,0.75); margin-top: 0.15rem; }

/* ===== SCIENCE NOTE ON HOME ===== */
.science-note {
  background: var(--surface); border: 1px solid var(--border);
  border-left: 3px solid #60a5fa;
  border-radius: var(--radius); padding: 1rem 1.25rem;
  margin-top: 0.5rem; margin-bottom: 1.5rem;
}
.science-note-title {
  font-weight: 600; font-size: 0.88rem; color: var(--text); margin-bottom: 0.75rem;
}
.science-note-facts {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.science-note-facts span {
  font-size: 0.75rem; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border);
  padding: 0.3rem 0.7rem; border-radius: var(--radius);
}

/* ===== RESULTS EXTRAS ===== */
.results-message {
  font-size: 0.92rem; color: var(--text-muted); line-height: 1.6;
  max-width: 480px; margin: 0 auto 0.875rem; padding: 0 0.5rem;
}
.results-level-note {
  font-size: 0.82rem; color: var(--text-muted); margin: 0.5rem 0 1.25rem;
}

/* ===== REPORT ACTIONS (results screen) ===== */
.report-actions {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-top: 3px solid var(--accent-enlang);
}
.report-label {
  font-weight: 600; font-size: 0.88rem; color: var(--text);
  margin-bottom: 0.75rem;
}
.report-btn-row {
  display: flex; gap: 0.625rem; flex-wrap: wrap;
}
.report-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.65rem 1.1rem;
  font-family: 'General Sans', sans-serif; font-weight: 600; font-size: 0.875rem;
  border-radius: var(--radius); cursor: pointer; border: none;
  transition: all 0.18s ease; flex: 1; min-width: 140px; justify-content: center;
}
.report-btn.download {
  background: var(--text); color: var(--bg);
}
.report-btn.download:hover { opacity: 0.85; transform: translateY(-1px); }
.report-btn.share {
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border);
}
.report-btn.share:hover { background: var(--border); }
.report-hint {
  margin-top: 0.625rem; font-size: 0.75rem; color: var(--text-muted);
  line-height: 1.5;
}

/* ===== PRINT HOME BUTTON ===== */
.print-home-btn {
  display: flex; align-items: center; gap: 0.625rem;
  width: 100%; padding: 0.875rem 1.25rem;
  background: var(--surface-2);
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  font-family: 'General Sans', sans-serif; font-weight: 600; font-size: 0.925rem;
  color: var(--text); cursor: pointer;
  transition: all 0.18s ease;
  margin: 0.75rem 0;
}
.print-home-btn:hover {
  border-color: var(--accent);
  background: var(--surface-3);
  color: var(--accent);
}
.print-home-btn svg { flex-shrink: 0; opacity: 0.75; }
.print-home-badge {
  margin-left: auto; font-size: 0.72rem; font-weight: 600;
  background: var(--surface-3); color: var(--text-muted);
  padding: 0.2rem 0.55rem; border-radius: 20px; border: 1px solid var(--border);
}

/* ===== PRINT TOPIC WORKSHEET BUTTON (in topics view) ===== */
.print-topic-worksheet-btn {
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  width: 100%; margin-top: 0.625rem; padding: 0.75rem 1rem;
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  font-family: 'General Sans', sans-serif; font-weight: 600; font-size: 0.875rem;
  color: var(--text-muted); cursor: pointer;
  transition: all 0.18s ease;
}
.print-topic-worksheet-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--surface-2);
}
.print-topic-worksheet-btn svg { flex-shrink: 0; }

/* ===== PRINT SETUP CARD ===== */
.print-setup-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 2rem;
}
.print-section-label {
  font-size: 0.78rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--accent);
  margin-bottom: 0.625rem;
}
.print-subject-grid {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.print-subj-btn {
  padding: 0.45rem 0.875rem;
  font-family: 'General Sans', sans-serif; font-size: 0.82rem; font-weight: 600;
  background: var(--surface-3); color: var(--text-muted);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s ease;
}
.print-subj-btn:hover {
  border-color: var(--accent); color: var(--text);
}
.print-subj-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.print-topic-list {
  display: flex; flex-wrap: wrap; gap: 0.45rem;
}
.print-topic-btn {
  padding: 0.35rem 0.75rem;
  font-family: 'General Sans', sans-serif; font-size: 0.78rem; font-weight: 500;
  background: var(--surface-3); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s ease;
}
.print-topic-btn:hover { border-color: var(--accent); color: var(--text); }
.print-topic-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.print-mode-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.print-mode-btn {
  padding: 0.4rem 0.9rem;
  font-family: 'General Sans', sans-serif; font-size: 0.82rem; font-weight: 600;
  background: var(--surface-3); color: var(--text-muted);
  border: 1.5px solid var(--border); border-radius: var(--radius);
  cursor: pointer; transition: all 0.15s ease;
}
.print-mode-btn:hover { border-color: var(--accent); color: var(--text); }
.print-mode-btn.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
}
.print-count-row {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
}
.print-preview-row {
  margin-top: 1rem;
  padding: 0.75rem 0.875rem;
  background: var(--surface-3); border-radius: var(--radius);
  border: 1px solid var(--border);
}
.print-preview-info {
  display: flex; align-items: center; gap: 0.625rem; flex-wrap: wrap;
}
.print-preview-badge {
  background: var(--accent); color: #fff;
  font-size: 0.78rem; font-weight: 700;
  padding: 0.2rem 0.6rem; border-radius: 20px;
  white-space: nowrap;
}
.print-actions {
  margin-top: 1.25rem;
}
.print-go-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.875rem 1.5rem;
  background: var(--accent); color: #fff;
  font-family: 'General Sans', sans-serif; font-weight: 700; font-size: 0.95rem;
  border: none; border-radius: var(--radius); cursor: pointer;
  transition: all 0.18s ease; width: 100%; justify-content: center;
}
.print-go-btn:hover:not(:disabled) {
  opacity: 0.88; transform: translateY(-1px);
}
.print-go-btn:disabled {
  opacity: 0.4; cursor: not-allowed;
}
.print-go-hint {
  margin-top: 0.625rem; font-size: 0.75rem; color: var(--text-muted); line-height: 1.55;
}
.print-pick-prompt {
  text-align: center; padding: 2rem 1rem;
  font-size: 0.95rem; color: var(--text-muted);
}
