:root {
  --maths: #2563eb;
  --english: #16a34a;
  --vr: #9333ea;
  --nvr: #ea580c;
  --spatial: #0891b2;
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --border: #e2e5ec;
  --good: #16a34a;
  --ok: #d97706;
  --weak: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; }

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

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.5rem;
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
}

.site-header h1 {
  margin: 0;
  font-size: 1.4rem;
}

.tagline {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  opacity: 0.9;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

nav button, nav a.nav-link {
  background: rgba(255, 255, 255, 0.15);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.4);
  padding: 0.5rem 0.9rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  text-decoration: none;
  display: inline-block;
}

nav button:hover, nav a.nav-link:hover { background: rgba(255, 255, 255, 0.28); }
nav button.active, nav a.nav-link.active { background: white; color: #1e3a8a; font-weight: 600; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.view[hidden] { display: none; }

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.intro-card h2 { margin-top: 0; }
.resume-card { border-color: var(--maths); border-left-width: 4px; }
.resume-card h3 { margin-top: 0; }
.resume-card p { margin: 0.25rem 0; }

.subject-list {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
}
.subject-list li {
  padding: 0.5rem 0;
  border-bottom: 1px dashed var(--border);
}
.subject-list li:last-child { border-bottom: none; }

.pill {
  display: inline-block;
  background: var(--maths);
  color: white;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  margin-right: 0.5rem;
}
.pill.light {
  background: #eef1f8;
  color: var(--text);
}
.pill.subject-maths { background: var(--maths); }
.pill.subject-english { background: var(--english); }
.pill.subject-vr { background: var(--vr); }
.pill.subject-nvr { background: var(--nvr); }
.pill.subject-spatial { background: var(--spatial); }

.home-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin: 1rem 0;
}

button.primary, button.secondary, button.danger {
  font-size: 0.95rem;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  cursor: pointer;
  border: 1px solid transparent;
}
button.primary { background: var(--maths); color: white; }
button.primary:hover { background: #1d4ed8; }
button.primary:disabled { background: #9db6ee; cursor: not-allowed; }

button.secondary { background: white; color: var(--text); border-color: var(--border); }
button.secondary:hover { background: #f0f2f7; }

button.danger { background: #fff1f1; color: var(--weak); border-color: #f8caca; }
button.danger:hover { background: #ffe1e1; }

.link-button {
  background: none;
  border: none;
  color: var(--maths);
  text-decoration: underline;
  cursor: pointer;
  font: inherit;
  padding: 0;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* Setup form */
.setup-form { max-width: 480px; }
.setup-form label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin: 0.9rem 0 0.3rem;
}
.setup-form select {
  width: 100%;
  padding: 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}
.setup-form button.primary { margin-top: 1.25rem; width: 100%; }

/* Quiz view */
.quiz-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  /* Keeps the progress count and mock-test timer in view while a student
     scrolls through a long passage or figure. */
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 0.5rem 0;
}

.quiz-progress { font-weight: 600; color: var(--muted); font-size: 0.9rem; }

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem;
  font-weight: 700;
  background: #eef1f8;
  padding: 0.25rem 0.75rem;
  border-radius: 6px;
}
.timer.urgent { background: #fde8e8; color: var(--weak); }

.passage-box {
  background: #fbfbfd;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}
.passage-box h3 { margin-top: 0; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }

.question-text {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0;
}

.options-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 1rem;
}

.spatial-figure {
  margin-top: 0.75rem;
  display: flex;
  justify-content: center;
}
.spatial-figure svg { max-width: 100%; height: auto; }

.options-list.options-grid {
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
}
.option-btn.option-figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.6rem;
}
.option-btn.option-figure svg { max-width: 100%; height: auto; }
.option-btn.option-figure .option-label {
  font-size: 0.8rem;
  color: var(--muted);
}

.option-btn {
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  font-size: 0.98rem;
  color: var(--text);
  min-height: 44px;
}
.option-btn:hover:not(:disabled) { border-color: var(--maths); background: #f5f8ff; }
.option-btn.selected { border-color: var(--maths); background: #eaf0ff; }
.option-btn.correct { border-color: var(--good); background: #eafaf0; font-weight: 600; }
.option-btn.incorrect { border-color: var(--weak); background: #fdecec; }
.option-btn:disabled { cursor: default; opacity: 1; color: var(--text); }

.feedback {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.92rem;
}
.correct-feedback { background: #eafaf0; color: #15803d; }
.incorrect-feedback { background: #fdecec; color: #b91c1c; }

.quiz-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
}

.score-line { font-size: 1.4rem; font-weight: 700; margin: 0.25rem 0; }

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.data-table th, .data-table td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.data-table th { color: var(--muted); font-weight: 600; font-size: 0.82rem; text-transform: uppercase; }
.data-table td.good { color: var(--good); font-weight: 700; }
.data-table td.ok { color: var(--ok); font-weight: 700; }
.data-table td.weak { color: var(--weak); font-weight: 700; }

/* Review list */
.review-list { display: grid; gap: 0.9rem; }
.review-item {
  border-left: 4px solid var(--border);
  padding: 0.5rem 0.9rem;
  background: #fbfbfd;
  border-radius: 0 8px 8px 0;
}
.review-item.good { border-left-color: var(--good); }
.review-item.weak { border-left-color: var(--weak); }
.review-item.skipped { border-left-color: var(--muted); }
.review-q { font-weight: 600; margin: 0 0 0.3rem; }
.review-item p { margin: 0.25rem 0; font-size: 0.92rem; }

/* Learn view */
.topic-list {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.9rem;
}
.topic-link {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  text-align: left;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  cursor: pointer;
  width: 100%;
}
.topic-link:hover { border-color: var(--maths); background: #f5f8ff; }
.topic-link-title { font-weight: 700; font-size: 0.98rem; }
.topic-link-summary { font-size: 0.85rem; color: var(--muted); }
.topic-link-detailed { gap: 0.4rem; }
.topic-link-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.15rem;
}

.difficulty-stars { font-size: 0.85rem; letter-spacing: 1px; color: #d8dce6; }
.difficulty-stars .star-filled { color: #f5a623; }

.relevance-badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}
.relevance-badge.relevance-high { background: #e3f7e8; color: #1c7c3c; }
.relevance-badge.relevance-medium { background: #fdf0da; color: #b06a00; }
.relevance-badge.relevance-low { background: #edeff3; color: #6b7280; }
.lesson-only-badge {
  display: inline-block;
  padding: 0.1rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid #d8dce6;
  color: #6b7280;
}

.topic-link-title-row { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.visited-badge { font-size: 0.72rem; font-weight: 600; color: var(--good); }

.relevance-filter-label { font-size: 0.85rem; color: var(--muted); margin-bottom: 0.5rem; }
.relevance-filter-row { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.relevance-filter-btn {
  padding: 0.3rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: white;
  font-size: 0.85rem;
  cursor: pointer;
}
.relevance-filter-btn:hover { border-color: var(--maths); }
.relevance-filter-btn.active { background: var(--maths); border-color: var(--maths); color: white; }

.tip-box {
  background: #fff9ec;
  border: 1px solid #f5d99b;
  border-left: 4px solid var(--ok);
}
.tip-box h3 { color: #92650a; }

.mistake-box {
  background: #fdf1f1;
  border: 1px solid #f5bcbc;
  border-left: 4px solid var(--weak);
}
.mistake-box h3 { color: #9c2b2b; }

.back-link {
  display: inline-block;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.key-points {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}
.key-points li { margin-bottom: 0.5rem; font-size: 0.95rem; }

.example-box {
  background: #fbfbfd;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.example-box:last-child { margin-bottom: 0; }
.example-box p { margin: 0.35rem 0; }

.learn-section { margin-bottom: 1.1rem; }
.learn-section:last-child { margin-bottom: 0; }
.learn-section h4 { margin: 0 0 0.3rem; font-size: 0.98rem; color: var(--text); }
.learn-section p { margin: 0; font-size: 0.95rem; }

.key-points.mistakes li::marker { color: var(--weak); }

/* Subject accuracy bars (progress.html) */
.subject-bar-row { margin-bottom: 1.1rem; }
.subject-bar-row:last-child { margin-bottom: 0; }
.subject-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.subject-bar-track {
  background: #eef1f8;
  border-radius: 999px;
  height: 10px;
  overflow: hidden;
}
.subject-bar-fill { height: 100%; border-radius: 999px; }
.subject-bar-fill.subject-maths { background: var(--maths); }
.subject-bar-fill.subject-english { background: var(--english); }
.subject-bar-fill.subject-vr { background: var(--vr); }
.subject-bar-fill.subject-nvr { background: var(--nvr); }
.subject-bar-fill.subject-spatial { background: var(--spatial); }

.week-compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.week-compare .stat-label { margin-top: 0.3rem; }

/* Dashboard stats */
.stat-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 1rem;
  margin-top: 1rem;
}
.stat { text-align: center; padding: 0.75rem; background: #fbfbfd; border-radius: 8px; border: 1px solid var(--border); }
.stat-value { font-size: 1.6rem; font-weight: 800; }
.stat-value.good { color: var(--good); }
.stat-value.ok { color: var(--ok); }
.stat-value.weak { color: var(--weak); }
.stat-label { font-size: 0.78rem; color: var(--muted); margin-top: 0.15rem; }

.site-footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
}

@media (max-width: 600px) {
  .site-header { flex-direction: column; align-items: flex-start; gap: 0.6rem; padding: 0.75rem 1rem; }
  .site-header h1 { font-size: 1.2rem; }
  nav { gap: 0.4rem; }
  nav button, nav a.nav-link { padding: 0.4rem 0.75rem; font-size: 0.85rem; }
  .account-controls { flex-wrap: wrap; width: 100%; gap: 0.5rem; }
  /* The avatar already identifies the student; the greeting has no room here. */
  .account-controls .user-email { display: none; }
  .account-controls .secondary.small { white-space: nowrap; }
  .quiz-actions { flex-direction: column-reverse; }
  .quiz-actions button { width: 100%; }
  .relevance-filter-btn { min-height: 36px; }
}

/* ===== Auth guard (app.html) ===== */
html.auth-pending body { display: none; }

.brand-link { text-decoration: none; color: inherit; }

.account-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.avatar-badge {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  display: inline-block;
}
.avatar-badge.large { width: 84px; height: 84px; }
.avatar-fill {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.avatar-initials {
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.85rem;
}
.avatar-badge.large .avatar-initials { font-size: 1.8rem; }

.avatar-upload-row {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: 1rem;
}
.avatar-upload-btn {
  display: inline-block;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.65rem 1.2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
}
.avatar-upload-btn:hover { background: #f0f2f7; }
.user-email {
  font-size: 0.82rem;
  opacity: 0.9;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
button.secondary.small, a.secondary.small {
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  text-decoration: none;
}
a.secondary.small {
  background: white;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: inline-block;
}
a.secondary.small:hover { background: #f0f2f7; }

.back-to-app {
  color: white;
  text-decoration: none;
  font-size: 0.9rem;
  opacity: 0.9;
}
.back-to-app:hover { opacity: 1; text-decoration: underline; }

.program-banner {
  max-width: 900px;
  margin: 0 auto 1rem;
  padding: 0.75rem 1rem;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 8px;
  font-size: 0.9rem;
}

/* ===== Landing page (index.html) ===== */
.landing-body { background: var(--card-bg); }

.wrap {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.landing-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}
.landing-nav a {
  color: white;
  text-decoration: none;
  font-size: 0.92rem;
  opacity: 0.9;
}
.landing-nav a:hover { opacity: 1; text-decoration: underline; }
.landing-nav a.secondary-link {
  opacity: 1;
  border: 1px solid rgba(255, 255, 255, 0.5);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
}
.landing-nav a.primary-link {
  opacity: 1;
  background: white;
  color: #1e3a8a;
  font-weight: 600;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
}

main.landing-main { max-width: none; padding: 0; margin: 0; }

.hero {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  padding: 4rem 0 5rem;
  text-align: center;
}
.hero h2 {
  font-size: 2.2rem;
  margin: 0 0 1rem;
  line-height: 1.25;
}
.hero-sub {
  font-size: 1.1rem;
  opacity: 0.95;
  max-width: 640px;
  margin: 0 auto 2rem;
}
.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}
.hero-actions a.primary {
  background: white;
  color: #1e3a8a;
}
.hero-actions a.secondary {
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

a.primary, a.secondary {
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.98rem;
}
a.primary { background: var(--maths); color: white; }
a.primary:hover { background: #1d4ed8; }
a.secondary { background: white; color: var(--text); border: 1px solid var(--border); }
a.secondary:hover { background: #f0f2f7; }

.section { padding: 4rem 0; }
.section.alt { background: #fbfbfd; }
.section-title {
  font-size: 1.6rem;
  text-align: center;
  margin: 0 0 0.5rem;
}
.section-sub {
  text-align: center;
  color: var(--muted);
  margin: 0 0 2.5rem;
}

.programme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}
.programme-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
}
.programme-card.available { border-color: var(--maths); border-width: 2px; }
.programme-card h4 { font-size: 1.15rem; margin: 0.75rem 0 0.5rem; }
.programme-card p { color: var(--muted); font-size: 0.92rem; margin: 0 0 1.25rem; }
.programme-card.coming-soon { opacity: 0.75; }
.programme-badge {
  display: inline-block;
  background: #eef1f8;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
}
.programme-badge.available-badge { background: #eafaf0; color: var(--good); }

.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.5rem;
}
.feature-card { text-align: center; padding: 1rem; }
.feature-icon { font-size: 2rem; display: block; margin-bottom: 0.5rem; }
.feature-card h4 { margin: 0 0 0.5rem; font-size: 1.05rem; }
.feature-card p { color: var(--muted); font-size: 0.9rem; margin: 0; }

.cta-band {
  background: linear-gradient(135deg, #1e3a8a, #2563eb);
  color: white;
  padding: 3.5rem 0;
  text-align: center;
}
.cta-band h3 { margin: 0 0 0.5rem; font-size: 1.6rem; }
.cta-band p { margin: 0 0 1.5rem; opacity: 0.95; }
.cta-band a.primary { background: white; color: #1e3a8a; }

.site-footer a { color: var(--muted); }

/* ===== Auth page (auth.html) ===== */
.auth-main {
  max-width: 440px;
  margin: 3rem auto;
  padding: 0 1rem;
}
.auth-card { padding: 2rem; }

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1;
  background: none;
  border: none;
  padding: 0.75rem;
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tab.active { color: var(--maths); border-bottom-color: var(--maths); }

.styled-form label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  margin: 0.9rem 0 0.3rem;
}
.styled-form input, .styled-form select {
  width: 100%;
  padding: 0.6rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.95rem;
}
.styled-form input:disabled {
  background: #f4f6fb;
  color: var(--muted);
}
.styled-form button.primary {
  margin-top: 1.5rem;
  width: 100%;
  border: none;
  cursor: pointer;
}

.notice {
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  font-size: 0.88rem;
  background: #eafaf0;
  color: #15803d;
  margin: 0 0 1rem;
}
.notice.error { background: #fdecec; color: #b91c1c; }

.switch-mode {
  text-align: center;
  font-size: 0.88rem;
  color: var(--muted);
  margin: 1.5rem 0 0;
}
.switch-mode a { color: var(--maths); font-weight: 600; text-decoration: none; margin-left: 0.3rem; }
.switch-mode a:hover { text-decoration: underline; }

.forgot-password-row {
  text-align: right;
  margin: 0.5rem 0 0;
}
.forgot-password-row a {
  color: var(--maths);
  font-size: 0.85rem;
  text-decoration: none;
}
.forgot-password-row a:hover { text-decoration: underline; }

.board-confirmation {
  background: #eef1f8;
  color: var(--text);
  font-size: 0.88rem;
  padding: 0.6rem 0.9rem;
  border-radius: 8px;
  margin: 0 0 1rem;
}
.board-confirmation a {
  color: var(--maths);
  font-weight: 600;
  text-decoration: none;
}
.board-confirmation a:hover { text-decoration: underline; }

@media (max-width: 700px) {
  .landing-nav { gap: 0.75rem; }
  .landing-nav a { font-size: 0.85rem; }
  .hero h2 { font-size: 1.7rem; }
}
