/* ── Custom Properties ──────────────────────────────────────────────────── */
:root {
  --accent:      #333;
  --accent-text: #fff;
  --gold:        #F9A825;
  --silver:      #9E9E9E;
  --bronze:      #8D6E63;
  --correct:     #4caf50;
  --wrong:       #ef5350;
  --bg:          #0f0f1a;
  --card-bg:     #1e1e2e;
  --text:        #e8e8f0;
  --text-muted:  #8888aa;
  --border:      #2a2a3e;
  --surface:     #252538;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ── Site Header (Index) ────────────────────────────────────────────────── */
.site-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 1.75rem 2rem 1.25rem;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  min-height: 80px;
}

.site-header-left {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: auto;
}

.site-header h1 {
  margin: 0 0 0.2rem;
  font-size: 2.25rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -0.02em;
}

.site-header .site-subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.site-header-right {
  text-align: right;
  flex-shrink: 0;
}

.overall-progress-label {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.overall-progress-count {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.overall-progress-bar {
  width: 180px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 0.4rem;
}
.overall-progress-fill {
  height: 100%;
  background: #4caf50;
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* ── XP Strip ────────────────────────────────────────────────────────────── */
.xp-strip {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 0.5rem 2rem;
  display: flex;
  justify-content: center;
}

/* ── XP Bar ─────────────────────────────────────────────────────────────── */
.xp-bar-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 700px;
  width: 100%;
  padding: 0.15rem 0;
}

.xp-level-badge {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 8px;
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
  font-weight: 700;
  white-space: nowrap;
  min-width: 60px;
  text-align: center;
}

.xp-bar-track {
  flex: 1;
  height: 12px;
  background: var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
  transition: width 0.4s ease;
}

.xp-bar-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.xp-bar-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.xp-streak {
  font-size: 0.8rem;
  font-weight: 700;
  color: #ff9800;
  white-space: nowrap;
}

/* ── Subject Grid (Index) ───────────────────────────────────────────────── */
.subject-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

/* ── Priority Section ───────────────────────────────────────────────────── */
.priority-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 0;
}

.priority-heading {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
  border-left: 3px solid var(--text-muted);
  padding-left: 0.6rem;
  margin: 0 0 1rem;
}

.priority-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* ── Subject Card ───────────────────────────────────────────────────────── */
.subject-card {
  background: var(--card-bg);
  border-radius: 10px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  border-top: 4px solid var(--accent);
  padding: 1.25rem 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
.subject-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
  text-decoration: none;
  color: inherit;
}

.card-emoji {
  font-size: 2.2rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.subject-card .subject-name {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}

.subject-card .card-meta {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0;
}

.card-score {
  font-size: 1rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0.25rem 0 0;
}

.card-status-badge {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 0.4rem;
}

.card-weak-badge {
  display: inline-block;
  background: rgba(239,83,80,0.12);
  border: 1px solid rgba(239,83,80,0.35);
  color: #ef5350;
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-top: 0.35rem;
  margin-left: 0.35rem;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s;
}
.card-weak-badge:hover { background: rgba(239,83,80,0.22); text-decoration: none; }

.exam-countdown {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
  font-weight: 600;
}

.card-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.card-actions-secondary {
  display: flex;
  gap: 0.5rem;
}

.card-actions-secondary .btn-primary {
  flex: 1;
  text-align: center;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-block;
  text-decoration: none;
  font-size: 0.95rem;
  transition: opacity 0.15s, transform 0.1s;
  font-family: inherit;
}

.btn-primary:hover {
  opacity: 0.88;
  text-decoration: none;
  color: var(--accent-text);
}

.btn-primary:active {
  transform: scale(0.97);
}

.btn-secondary {
  border: 2px solid var(--accent);
  color: var(--accent);
  background: transparent;
  border-radius: 8px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
  text-decoration: none;
  font-size: 0.95rem;
  transition: background 0.15s;
  font-family: inherit;
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.06);
  text-decoration: none;
}

.btn-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Achievements Section (Index) ───────────────────────────────────────── */
.achievements-section {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 1.5rem;
}

.achievements-section h2 {
  font-size: 1.3rem;
  margin-bottom: 1rem;
}

.achievements-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 1rem;
}

.badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem 0.5rem;
  border-radius: 12px;
  text-align: center;
}

.badge.locked {
  background: var(--surface);
  color: var(--text-muted);
}

.badge.unlocked {
  background: #1b3a1f;
  color: var(--text);
}

.badge-icon {
  font-size: 2rem;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.badge.locked .badge-icon {
  filter: grayscale(1) opacity(0.4);
}

.badge-name {
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ── Ultimate Card ──────────────────────────────────────────────────────── */
.ultimate-card {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 1.5rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.ultimate-card-text {
  color: #fff;
}

.ultimate-card-text h2 {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
  color: #FFD700;
}

.ultimate-card-text p {
  margin: 0;
  color: #aaaacc;
  font-size: 0.9rem;
}

/* ── Site Footer ────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 2rem;
}

/* ── Master Test Bar ────────────────────────────────────────────────────── */
.master-test-bar {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.master-test-bar p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ── Topic Grid / Cards ─────────────────────────────────────────────────── */
.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
  padding: 1.5rem;
  max-width: 1100px;
  margin: 0 auto;
}

.topic-card {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.4);
  border-left: 5px solid var(--accent);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.topic-card .topic-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text);
}

.hs-badge {
  display: inline-block;
  background: var(--surface);
  border-radius: 12px;
  font-size: 0.8rem;
  padding: 2px 10px;
  color: var(--text-muted);
}

/* ── Quiz Page — General ────────────────────────────────────────────────── */
.quiz-page {
  min-height: 100vh;
}

#screen-loading {
  text-align: center;
  padding: 3rem;
  font-size: 1.2rem;
}

/* ── Start Screen ───────────────────────────────────────────────────────── */
#screen-start {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
  min-height: 100vh;
}

.start-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  padding: 2rem;
  max-width: 540px;
  width: 100%;
  text-align: center;
}

.start-title {
  font-size: 1.5rem;
  font-weight: 900;
  margin: 0 0 1rem;
  color: var(--text);
}

.start-msg {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 0.75rem;
}

.start-count {
  font-size: 1rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.start-best {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin: 0 0 1.25rem;
}

.start-first {
  font-style: italic;
}

.start-btn {
  font-size: 1.1rem;
  padding: 0.8rem 2rem;
  margin-bottom: 1rem;
}

.back-link {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: inline-block;
  margin-top: 0.75rem;
}

.coming-soon-note {
  background: #2e2000;
  border: 1px solid #5a4000;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  color: #ccaa55;
  margin: 0.75rem 0 1rem;
}

/* ── Quiz Screen ────────────────────────────────────────────────────────── */
#screen-quiz {
  max-width: 600px;
  margin: 0 auto;
  padding: 1rem;
}

/* Progress bar */
.quiz-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 0.75rem;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Meta row */
.quiz-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.q-counter {
  font-weight: 600;
}

.running-score {
  color: var(--correct);
  font-weight: 600;
}

/* Streak */
.streak-display {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

/* Topic tag */
.topic-tag {
  display: block;
  text-align: center;
  background: var(--surface);
  border-radius: 12px;
  font-size: 0.8rem;
  padding: 2px 10px;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

/* Question */
.question-diagram {
  margin: 0.75rem 0 0.25rem;
  border-radius: 8px;
  overflow: hidden;
  background: #12122a;
}
.question-diagram svg {
  max-width: 100%;
  display: block;
  height: auto;
}

.question-text {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 1.25rem 0 1rem;
  line-height: 1.4;
  text-align: center;
}

/* Options */
.options-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.option-btn {
  width: 100%;
  min-height: 52px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.75rem 1rem;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  font-family: inherit;
  color: var(--text);
}

.option-btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.option-btn:disabled {
  cursor: default;
  opacity: 0.7;
}

.option-btn.correct {
  background: #1b3a1f;
  border-color: var(--correct);
  color: var(--correct);
  font-weight: 600;
  opacity: 1;
  animation: correctPulse 0.3s ease;
}

.option-btn.wrong {
  background: #3a1a1a;
  border-color: var(--wrong);
  color: var(--wrong);
  opacity: 1;
  animation: wrongShake 0.3s ease;
}

/* Feedback */
.feedback-area {
  margin-top: 1.5rem;
  padding: 1rem;
  background: var(--surface);
  border-radius: 8px;
}

.feedback-message {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.feedback-correct {
  color: var(--correct);
}

.feedback-wrong {
  color: var(--wrong);
}

.explanation-text {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Streak milestone flash */
.streak-milestone {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-text);
  padding: 1rem 2rem;
  border-radius: 12px;
  font-size: 1.3rem;
  font-weight: 800;
  z-index: 100;
  animation: fadeInOut 1.5s forwards;
  pointer-events: none;
  white-space: nowrap;
}

/* Next button */
.next-btn {
  margin-top: 1rem;
}

/* ── End Screen ─────────────────────────────────────────────────────────── */
#screen-end {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem;
}

.end-score {
  font-size: 3rem;
  font-weight: 900;
  text-align: center;
  color: var(--accent);
  margin-bottom: 0.25rem;
}

.end-pct {
  font-size: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.medal-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  font-size: 2.5rem;
  margin: 1rem auto;
}

.medal-badge.gold   { background: var(--gold); }
.medal-badge.silver { background: var(--silver); }
.medal-badge.bronze { background: var(--bronze); }

.end-message {
  font-size: 1.2rem;
  font-weight: 700;
  text-align: center;
  margin: 1rem 0;
}

.pb-banner {
  background: #2e2000;
  border: 2px solid var(--gold);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-weight: 700;
  text-align: center;
  margin: 0.75rem 0;
  animation: bounceIn 0.4s ease;
}

.xp-earned {
  text-align: center;
  color: var(--accent);
  font-weight: 600;
  font-size: 1rem;
  margin: 0.5rem 0;
}

.levelup-banner {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0.75rem 0;
  animation: levelUpFlash 0.5s ease;
}

.achievements-unlocked {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 0.75rem 0;
}

.new-ach-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: #1b3a1f;
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  min-width: 80px;
}

.ach-icon {
  font-size: 1.75rem;
}

.ach-name {
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}

.streak-info {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 0.5rem 0 1rem;
}

.topic-perf-feedback {
  background: var(--surface);
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
  margin: 0.5rem 0;
}

/* Wrong review */
.wrong-review {
  margin: 1rem 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.wrong-review summary {
  cursor: pointer;
  padding: 0.75rem 1rem;
  font-weight: 600;
  background: var(--surface);
  user-select: none;
}

.wrong-review summary:hover {
  background: var(--border);
}

.wrong-item {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
}

.wrong-q {
  font-weight: 600;
  margin-bottom: 0.25rem;
  font-size: 0.95rem;
}

.wrong-yours, .wrong-correct {
  font-size: 0.9rem;
  margin-bottom: 0.1rem;
}

.wrong-answer {
  color: var(--wrong);
  font-weight: 600;
}

.correct-answer {
  color: var(--correct);
  font-weight: 600;
}

/* Topic breakdown */
.topic-breakdown {
  margin: 1rem 0;
}

.topic-breakdown h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.topic-breakdown table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.topic-breakdown th,
.topic-breakdown td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.topic-breakdown th {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

/* End actions */
.end-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

/* ── Animations ─────────────────────────────────────────────────────────── */
@keyframes fadeInOut {
  0%   { opacity: 0; transform: translateX(-50%) scale(0.8); }
  20%  { opacity: 1; transform: translateX(-50%) scale(1); }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes bounceIn {
  0%   { transform: scale(0.8); opacity: 0; }
  60%  { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes levelUpFlash {
  0%   { transform: scale(0.9); opacity: 0; }
  50%  { transform: scale(1.02); }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes correctPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@keyframes wrongShake {
  0%,  100% { transform: translateX(0); }
  25%        { transform: translateX(-6px); }
  75%        { transform: translateX(6px); }
}

/* ── Subject Page Header ──────────────────────────────────────────────────── */
.subject-header {
  background: linear-gradient(135deg, #0d0d1f 0%, #1a1a35 60%, #1e2040 100%);
  padding: 1.5rem 2rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.subject-header .back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  font-size: 0.82rem;
  text-decoration: none;
  margin-bottom: 0.75rem;
  transition: background 0.15s;
}
.subject-header .back-btn:hover {
  background: rgba(255,255,255,0.12);
  text-decoration: none;
  color: var(--text);
}

.subject-title {
  margin: 0 0 0.2rem;
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: -0.01em;
}

.subject-subtitle {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* ── How to revise box ────────────────────────────────────────────────────── */
.howto-box {
  max-width: 900px;
  margin: 1.25rem auto 0;
  padding: 0 1.5rem;
}

.howto-box-inner {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.howto-box-inner strong { color: var(--text); }
.howto-box-inner .hl   { color: #5b8ef0; font-weight: 600; }

/* ── Subject progress bar ─────────────────────────────────────────────────── */
.subject-progress-wrap {
  max-width: 900px;
  margin: 1rem auto 0;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.subject-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.subject-progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.progress-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 110px;
  text-align: right;
}

/* ── Topic Navigation Pills ───────────────────────────────────────────────── */
.topic-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 900px;
  margin: 1rem auto 0;
  padding: 0 1.5rem;
}

.topic-pill {
  display: inline-block;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 0.3rem 0.9rem;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.02em;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  white-space: nowrap;
}
.topic-pill:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(255,255,255,0.04);
  text-decoration: none;
}

/* ── Topic Sections ───────────────────────────────────────────────────────── */
.topic-section {
  max-width: 900px;
  margin: 2rem auto 0;
  padding: 0 1.5rem;
}

.topic-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--accent);
  margin-bottom: 0.75rem;
}

.topic-num-badge {
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 5px;
  padding: 3px 8px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.topic-title {
  flex: 1;
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.04em;
}

.topic-header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}

.topic-counter {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.btn-small-quiz {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 5px;
  padding: 0.2rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-small-quiz:hover {
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
}

/* ── Criteria List ────────────────────────────────────────────────────────── */
.criteria-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 2rem;
}

/* ── Criterion Card ───────────────────────────────────────────────────────── */
.criterion {
  background: var(--card-bg);
  border-radius: 8px;
  border: 1px solid var(--border);
  overflow: hidden;
  transition: border-color 0.15s;
}
.criterion:hover      { border-color: rgba(255,255,255,0.12); }
.criterion.is-done    { border-color: rgba(76,175,80,0.4); }

/* Clickable header */
.cr-header {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  cursor: pointer;
  user-select: none;
}
.cr-header:hover { background: rgba(255,255,255,0.03); }

.cr-badge {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: 5px;
  padding: 2px 7px;
  letter-spacing: 0.03em;
  font-family: 'Courier New', Courier, monospace;
}
.criterion.is-done .cr-badge { background: #4caf50; }

.cr-text {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  min-width: 0;
}
.criterion.is-done .cr-text { color: var(--text-muted); text-decoration: line-through; }

.cr-arrow {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 0.7rem;
  opacity: 0.6;
}

/* Expandable body */
.cr-body {
  border-top: 1px solid var(--border);
  padding: 0.85rem;
}

.cr-prompt {
  font-style: italic;
  color: #7090d0;
  font-size: 0.875rem;
  margin: 0 0 0.85rem;
  padding: 0.5rem 0.75rem;
  border-left: 3px solid #3d5afe;
  background: rgba(61,90,254,0.07);
  border-radius: 0 4px 4px 0;
  line-height: 1.5;
}

/* ── Show / Hide answer button ────────────────────────────────────────────── */
.show-answer-btn {
  display: block;
  width: 100%;
  padding: 0.65rem 1rem;
  background: #3d5afe;
  border: 2px solid transparent;
  color: #ffffff;
  border-radius: 7px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, color 0.15s;
  margin-bottom: 0.85rem;
}
.show-answer-btn:hover {
  background: #536dfe;
}
.show-answer-btn.open {
  background: transparent;
  border-color: #3d5afe;
  color: #7090d0;
  box-shadow: 0 0 0 3px rgba(61,90,254,0.2);
}
.show-answer-btn.open:hover {
  background: rgba(61,90,254,0.08);
}

/* ── Answer content ───────────────────────────────────────────────────────── */
.cr-answer {
  background: #16162a;
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.85rem;
  margin-bottom: 0.85rem;
  font-size: 0.875rem;
  line-height: 1.55;
}

/* ── Criterion footer ─────────────────────────────────────────────────────── */
.cr-footer {
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.mark-done-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 0.3rem 0.9rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.mark-done-btn:hover {
  border-color: #4caf50;
  color: #4caf50;
}
.mark-done-btn.done {
  border-color: #4caf50;
  color: #4caf50;
  background: rgba(76,175,80,0.1);
}

.bitesize-link {
  display: inline-block;
  margin-top: 0.6rem;
  padding: 0.25rem 0.8rem;
  border: 1px solid rgba(255,100,0,0.35);
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #ff7043;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.bitesize-link:hover {
  background: rgba(255,112,67,0.12);
  border-color: #ff7043;
  color: #ff8a65;
}

/* ── CRS content blocks ───────────────────────────────────────────────────── */
.cr-answer p   { margin: 0.3rem 0; }
.cr-answer ul  { margin: 0.3rem 0; padding-left: 1.4rem; }
.cr-answer li  { margin-bottom: 0.2rem; }
.cr-answer ol  { margin: 0.3rem 0; padding-left: 1.4rem; }
.cr-answer strong { color: var(--text); }

/* ── Index page CRS progress on subject cards ─────────────────────────────── */
.card-crs-progress {
  margin-top: 0.25rem;
}
.card-crs-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 3px;
}
.card-crs-bar-fill {
  height: 100%;
  background: #4caf50;
  border-radius: 2px;
}

.crs-content p { margin: 0.3rem 0; }
.crs-content ul { margin: 0.3rem 0; padding-left: 1.4rem; }
.crs-content li { margin-bottom: 0.15rem; }
.crs-content ol { margin: 0.3rem 0; padding-left: 1.4rem; }
.crs-content strong { color: var(--text); }

.crs-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.6rem 0;
  font-size: 0.83rem;
}
.crs-table th {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.5rem;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
.crs-table td {
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.memory-hook {
  background: rgba(249,168,37,0.08);
  border-left: 3px solid #F9A825;
  padding: 0.45rem 0.7rem;
  margin: 0.6rem 0;
  font-size: 0.85rem;
  border-radius: 0 5px 5px 0;
}

.crs-img {
  display: block;
  width: 100%;
  max-width: 540px;
  margin: 0 auto 0.75rem;
  border-radius: 8px;
}

.key-words {
  background: rgba(255,255,255,0.04);
  border-left: 3px solid var(--accent);
  padding: 0.4rem 0.7rem;
  margin: 0.4rem 0;
  font-size: 0.82rem;
  border-radius: 0 5px 5px 0;
  color: var(--text-muted);
}

.exam-mistake {
  background: rgba(239,83,80,0.08);
  border-left: 3px solid #ef5350;
  padding: 0.45rem 0.7rem;
  margin: 0.4rem 0;
  font-size: 0.85rem;
  border-radius: 0 5px 5px 0;
}

.worked-example {
  background: var(--surface);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin: 0.6rem 0;
  font-size: 0.85rem;
}
.worked-example ol { margin: 0.3rem 0; }

/* ── Index page CRS progress on subject cards ─────────────────────────────── */
.card-crs-progress {
  margin-top: 0.25rem;
}
.card-crs-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 3px;
}
.card-crs-bar-fill {
  height: 100%;
  background: #4caf50;
  border-radius: 2px;
}

/* ── Criterion Type Labels ───────────────────────────────────────────────── */
.cr-type-label {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  border-radius: 4px;
  padding: 2px 8px;
  margin-bottom: 0.6rem;
}
.cr-type-practical   { background: rgba(255,152,0,0.18); color: #ff9800; border: 1px solid rgba(255,152,0,0.3); }
.cr-type-source      { background: rgba(156,39,176,0.15); color: #ce93d8; border: 1px solid rgba(156,39,176,0.3); }
.cr-type-chronology  { background: rgba(33,150,243,0.15); color: #64b5f6; border: 1px solid rgba(33,150,243,0.3); }
.cr-type-os-map      { background: rgba(76,175,80,0.15);  color: #81c784; border: 1px solid rgba(76,175,80,0.3); }

/* Source exercise scaffold */
.cr-source-block {
  background: rgba(255,255,255,0.04);
  border-left: 3px solid #9c27b0;
  border-radius: 0 6px 6px 0;
  padding: 0.65rem 0.85rem;
  margin: 0.6rem 0;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-muted);
}
.cr-scaffold {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.7rem 0.85rem;
  margin: 0.6rem 0;
  font-size: 0.88rem;
}
.cr-scaffold ul { margin: 0.3rem 0; padding-left: 1.4rem; }
.cr-scaffold li { margin-bottom: 0.2rem; }
.cr-scaffold-note {
  font-style: italic;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

/* ── Topic Performance Badge ─────────────────────────────────────────────── */
.topic-perf-badge {
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 20px;
  padding: 2px 10px;
  white-space: nowrap;
  flex-shrink: 0;
}
.topic-perf-badge.perf-green { background: rgba(76,175,80,0.15);  color: #4caf50; }
.topic-perf-badge.perf-amber { background: rgba(255,193,7,0.15);  color: #ffc107; }
.topic-perf-badge.perf-red   { background: rgba(239,83,80,0.15);  color: #ef5350; }

/* ── Confidence Dot (criterion header) ──────────────────────────────────── */
.cr-conf-dot {
  flex-shrink: 0;
  font-size: 0.7rem;
  line-height: 1;
  min-width: 1em;
}

/* ── Confidence-coloured criterion borders ───────────────────────────────── */
.criterion.cr-conf-red   { border-color: rgba(239,83,80,0.45); }
.criterion.cr-conf-amber { border-color: rgba(255,193,7,0.35); }
.criterion.cr-conf-green { border-color: rgba(76,175,80,0.4);  }

/* ── Confidence Buttons ─────────────────────────────────────────────────── */
.cr-confidence-btns {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.6rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
}

.cr-conf-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.cr-conf-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 0.25rem 0.75rem;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
  white-space: nowrap;
}
.cr-conf-red-btn:hover,   .cr-conf-red-btn.active   { border-color: #ef5350; color: #ef5350; background: rgba(239,83,80,0.12); }
.cr-conf-amber-btn:hover, .cr-conf-amber-btn.active  { border-color: #ffc107; color: #ffc107; background: rgba(255,193,7,0.12); }
.cr-conf-green-btn:hover, .cr-conf-green-btn.active  { border-color: #4caf50; color: #4caf50; background: rgba(76,175,80,0.12); }

/* ── Filter Strip ───────────────────────────────────────────────────────── */
.crs-filter-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 1rem auto 0;
  padding: 0.5rem 1.5rem;
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.filter-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-muted);
  border-radius: 20px;
  padding: 0.3rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--accent); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }

/* ── Topic Selector Screen (quiz.js) ───────────────────────────────────── */
#screen-topic-select {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem 1rem;
  min-height: 100vh;
}

.topic-sel-card {
  background: var(--card-bg);
  border-radius: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  padding: 2rem;
  max-width: 540px;
  width: 100%;
}

.topic-sel-title {
  font-size: 1.8rem;
  font-weight: 900;
  margin: 0.25rem 0 0.2rem;
  letter-spacing: -0.01em;
}

.topic-sel-subtitle {
  color: var(--text-muted);
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
}

.topic-sel-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.topic-sel-btn {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
}
.topic-sel-btn:hover {
  border-color: var(--topic-accent, var(--accent));
  background: rgba(255,255,255,0.04);
}

.topic-sel-name { flex: 1; }

.topic-sel-score {
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.topic-sel-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.topic-sel-soon  { color: var(--text-muted); opacity: 0.6; }

.topic-sel-thin {
  font-size: 0.7rem;
  color: #ccaa33;
  background: rgba(249,168,37,0.1);
  border-radius: 8px;
  padding: 1px 6px;
}

.topic-sel-modes {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.topic-mode-btn  { flex: 1; text-align: center; min-width: 120px; }
.weak-areas-btn:disabled { opacity: 0.38; cursor: not-allowed; }

/* ── Thin topic note (start screen) ─────────────────────────────────────── */
.thin-topic-note {
  background: #1e1a00;
  border: 1px solid #5a4a00;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  font-size: 0.88rem;
  color: #ccaa33;
  margin: 0.75rem 0 1rem;
}

/* ── Level-Up Overlay ───────────────────────────────────────────────────── */
#levelup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  align-items: center;
  justify-content: center;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.35s ease;
}
#levelup-overlay.levelup-visible { opacity: 1; }
#levelup-overlay.levelup-hiding  { opacity: 0; }

.levelup-box {
  background: var(--card-bg);
  border: 2px solid var(--accent);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  animation: levelUpEntrance 0.45s ease;
}

.levelup-stars {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  animation: starBounce 0.55s ease 0.1s both;
}

#levelup-overlay .levelup-banner {
  font-size: 2rem;
  font-weight: 900;
  background: none;
  color: var(--text);
  border-radius: 0;
  padding: 0;
  margin-bottom: 0.5rem;
  letter-spacing: 0.05em;
  animation: none;
}

.levelup-level {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.levelup-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text);
  margin-bottom: 1.5rem;
}

.levelup-dismiss {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 10px;
  padding: 0.75rem 2rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.15s, transform 0.1s;
}
.levelup-dismiss:hover  { opacity: 0.88; }
.levelup-dismiss:active { transform: scale(0.97); }

@keyframes levelUpEntrance {
  0%   { transform: scale(0.75) translateY(30px); opacity: 0; }
  70%  { transform: scale(1.03) translateY(-4px); }
  100% { transform: scale(1)    translateY(0);    opacity: 1; }
}

@keyframes starBounce {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.2) rotate(5deg); }
  100% { transform: scale(1)   rotate(0);    opacity: 1; }
}

/* ── Achievement Toast ──────────────────────────────────────────────────── */
.achievement-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  background: #1b3a1f;
  border: 1px solid #4caf50;
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.88rem;
  color: var(--text);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  z-index: 900;
  max-width: 360px;
  transform: translateY(110%);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
}
.achievement-toast.show { transform: translateY(0); opacity: 1; }
.ach-toast-icon { font-size: 1.6rem; flex-shrink: 0; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .priority-grid {
    grid-template-columns: 1fr;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 1.25rem 1rem;
  }

  .site-header-left {
    position: static;
    transform: none;
    text-align: left;
  }

  .site-header h1 {
    font-size: 1.6rem;
  }

  .site-header-right {
    text-align: left;
  }

  .overall-progress-bar {
    width: 100%;
  }

  .subject-header {
    padding: 1rem 1rem 0.75rem;
  }

  .subject-title {
    font-size: 1.4rem;
  }

  .howto-box,
  .subject-progress-wrap,
  .topic-nav,
  .topic-section {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .master-test-bar {
    padding: 0.75rem 1rem;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .end-score {
    font-size: 2.2rem;
  }

  .end-pct {
    font-size: 1.2rem;
  }

  .ultimate-card {
    margin: 0 1rem 1rem;
  }

  #screen-start {
    padding: 1rem;
  }

  .start-card {
    padding: 1.25rem;
  }

  .end-actions {
    flex-direction: column;
  }

  .end-actions .btn-primary,
  .end-actions .btn-secondary {
    width: 100%;
    text-align: center;
  }

  .achievements-grid {
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  }

  #screen-topic-select {
    padding: 1rem 0.5rem;
  }

  .topic-sel-card {
    padding: 1.25rem;
  }

  .topic-sel-modes {
    flex-direction: column;
  }

  .crs-filter-strip {
    padding: 0.5rem 1rem;
  }

  .cr-confidence-btns {
    gap: 0.4rem;
  }

  .cr-conf-btn {
    padding: 0.22rem 0.6rem;
    font-size: 0.75rem;
  }

  .achievement-toast {
    bottom: 0.75rem;
    right: 0.75rem;
    left: 0.75rem;
    max-width: none;
  }

  .levelup-box {
    padding: 2rem 1.25rem;
  }
}

/* ── Example answers & Your turn ── */
.cr-example-answer,
.cr-your-turn {
  margin-top: 1.1rem;
  border-radius: 8px;
  padding: 0.75rem 1rem;
}

.cr-example-answer {
  background: rgba(99,102,241,0.07);
  border-left: 3px solid #6366f1;
}

.cr-your-turn {
  background: rgba(16,185,129,0.07);
  border-left: 3px solid #10b981;
}

.cr-example-label,
.cr-your-turn-label {
  margin-bottom: 0.35rem;
}

.cr-example-label strong { color: #a5b4fc; }
.cr-your-turn-label strong { color: #6ee7b7; }

.cr-example-answer p,
.cr-your-turn p {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  line-height: 1.55;
}

/* ── Tonight banner ────────────────────────────────────────────────────── */
.tonight-banner {
  background: linear-gradient(135deg, #0d1a2e 0%, #12122a 100%);
  border-bottom: 2px solid #2a3a5a;
  padding: 0.65rem 1.5rem;
}
.tonight-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.tonight-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #f9d030;
  white-space: nowrap;
}
.tonight-sessions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  flex: 1;
}
.tonight-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.7rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: opacity 0.15s;
}
.tonight-pill:hover { opacity: 0.82; }
.tonight-time {
  font-size: 0.68rem;
  opacity: 0.75;
  font-weight: 400;
}
.tonight-timetable-link {
  color: #5b8ef0;
  font-size: 0.8rem;
  text-decoration: none;
  white-space: nowrap;
  margin-left: auto;
}
.tonight-timetable-link:hover { text-decoration: underline; }

/* ── Timetable page ────────────────────────────────────────────────────── */
.timetable-tabs {
  display: flex;
  gap: 0.5rem;
  max-width: 1100px;
  margin: 1rem auto;
  padding: 0 1.5rem;
  flex-wrap: wrap;
}
.timetable-tab {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  background: #12122a;
  border: 1px solid #2a3a5a;
  color: #aaa;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.15s;
}
.timetable-tab.active {
  background: #1e2e50;
  color: #e0e0e0;
  border-color: #5b8ef0;
}
.timetable-tab:hover {
  background: #1e2e50;
  color: #e0e0e0;
  border-color: #5b8ef0;
}
.timetable-tab.current-week {
  border-color: #f9d030;
  color: #f9d030;
}
.timetable-tab.current-week.active {
  background: #1e2a10;
  border-color: #f9d030;
  color: #f9d030;
}
.timetable-grid-wrap {
  max-width: 1100px;
  margin: 0 auto 2rem;
  padding: 0 1.5rem;
  overflow-x: auto;
}
.timetable-grid {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}
.timetable-grid th {
  background: #12122a;
  padding: 0.5rem 0.4rem;
  font-size: 0.8rem;
  color: #aaa;
  text-align: center;
  border: 1px solid #1e2e3a;
  white-space: nowrap;
}
.timetable-grid th.today-col {
  background: #1a2a40;
  color: #f9d030;
  border-color: #f9d030;
}
.timetable-grid td {
  padding: 0.35rem 0.4rem;
  text-align: center;
  border: 1px solid #1e2e3a;
  background: #0d0d1a;
  vertical-align: middle;
}
.timetable-grid td.today-col {
  background: #0d1820;
  border-left-color: #f9d030;
  border-right-color: #f9d030;
}
.timetable-grid .time-cell {
  color: #555;
  font-size: 0.72rem;
  white-space: nowrap;
  background: #0a0a18;
  min-width: 56px;
  text-align: right;
  padding-right: 0.6rem;
}
.timetable-pill {
  display: inline-block;
  padding: 0.22rem 0.5rem;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: none;
  transition: opacity 0.15s;
}
.timetable-pill:hover { opacity: 0.8; }
.timetable-pill.tier-3 { opacity: 0.72; }
.timetable-pill.tutor-pill {
  background: #ffd700 !important;
  color: #1a1a2e !important;
}
.timetable-empty {
  color: #252535;
  font-size: 0.7rem;
}
.timetable-legend {
  max-width: 1100px;
  margin: 0 auto 1rem;
  padding: 0 1.5rem;
  display: flex;
  gap: 1.25rem;
  flex-wrap: wrap;
}
.timetable-legend-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: #777;
}
.timetable-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

/* ── Review banner (due for review) ─────────────────────────────────────── */
.review-banner {
  background: linear-gradient(135deg, #1a1400 0%, #1a1500 100%);
  border-bottom: 2px solid rgba(255,193,7,0.3);
  padding: 0.65rem 1.5rem;
}
.review-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.review-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #ffc107;
  white-space: nowrap;
  padding-top: 0.25rem;
}
.review-items { display: flex; gap: 0.4rem; flex-wrap: wrap; flex: 1; }
.review-group { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.review-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.65rem;
  border-radius: 20px;
  background: rgba(255,193,7,0.1);
  border: 1px solid rgba(255,193,7,0.25);
  color: var(--text);
  font-size: 0.77rem;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s;
}
.review-pill:hover { background: rgba(255,193,7,0.2); text-decoration: none; }
.review-more {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
}
.review-count {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  padding-top: 0.25rem;
}

/* ── Flashcard page ──────────────────────────────────────────────────────── */
.flashcard-page {
  max-width: 600px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 70vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.flashcard-progress {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  align-self: flex-end;
}
.flashcard-wrap {
  width: 100%;
  perspective: 1000px;
  cursor: pointer;
  margin-bottom: 1.5rem;
}
.flashcard-inner {
  position: relative;
  width: 100%;
  min-height: 220px;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}
.flashcard-wrap.flipped .flashcard-inner {
  transform: rotateY(180deg);
}
.flashcard-front,
.flashcard-back {
  position: absolute;
  width: 100%;
  min-height: 220px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
  text-align: center;
}
.flashcard-front {
  background: var(--card-bg);
  border: 2px solid var(--border);
}
.flashcard-back {
  background: var(--surface);
  border: 2px solid var(--accent);
  transform: rotateY(180deg);
}
.flashcard-front-text {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text);
}
.flashcard-hint {
  margin-top: 1rem;
  font-size: 0.77rem;
  color: var(--text-muted);
}
.flashcard-back-content {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
}
.flashcard-conf-btns {
  display: flex;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}
.flashcard-conf-btn {
  flex: 1;
  padding: 0.65rem;
  border: none;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.15s;
  font-family: inherit;
}
.flashcard-conf-btn:hover { opacity: 0.82; }
.flashcard-btn-red   { background: rgba(239,83,80,0.15); color: #ef5350; border: 1px solid rgba(239,83,80,0.4); }
.flashcard-btn-amber { background: rgba(255,193,7,0.15); color: #ffc107; border: 1px solid rgba(255,193,7,0.4); }
.flashcard-btn-green { background: rgba(76,175,80,0.15); color: #4caf50; border: 1px solid rgba(76,175,80,0.4); }
.flashcard-complete {
  text-align: center;
  padding: 3rem 1rem;
}
.flashcard-complete h2 { font-size: 1.8rem; margin: 0 0 0.75rem; }
.flashcard-complete p  { color: var(--text-muted); }

/* ── Session guide ───────────────────────────────────────────────────────── */
.session-guide {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin: 1rem auto;
  width: calc(100% - 3rem);
  max-width: 900px;
}
.session-guide h3 {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--accent);
}
.session-suggestion {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.88rem;
  margin-bottom: 0.4rem;
  color: var(--text);
}
.session-suggestion a { color: var(--accent); font-weight: 600; }
.session-guide-dismiss {
  margin-top: 0.75rem;
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  padding: 0.3rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s;
}
.session-guide-dismiss:hover { border-color: var(--accent); color: var(--text); }
