/* =====================================================================
   MT Security Service Preparation — style.css
   ---------------------------------------------------------------------
   1. Theme tokens (colours)
   2. Base / reset
   3. Layout helpers
   4. Buttons, forms, badges, alerts
   5. Header + navigation + dropdown
   6. Hero + service cards + subject cards
   7. Syllabus + notes viewer (rich text)
   8. Exam (question card, options, timer, progress, palette)
   9. Result + review
   10. Dashboard + leaderboard + tables
   11. Admin panel
   12. Modal + toast
   13. Footer
   14. Responsive rules
   ===================================================================== */

/* Kalimati — the font for Nepali (Devanagari) letters. The installed copy is used when the device
   has it; otherwise it is loaded from assets/fonts so phones show the same letters.
   unicode-range: Kalimati is used ONLY for Devanagari. English letters, digits 0–9 and signs such
   as × ÷ — “ ” … come from the next font ("Segoe UI" …), because Kalimati draws them wrongly. */
@font-face {
  font-family: "Kalimati";
  src: local("Kalimati"), url("../assets/fonts/Kalimati.ttf") format("truetype");
  font-display: swap;
  unicode-range: U+0900-097F, U+A8E0-A8FF, U+200C-200D, U+25CC;
}
/* Kalimati's digits only (it draws 0–9 the Nepali way) — used for numbers in maths:
   column sums, long division and questions of the गणित topic (class .is-math). */
@font-face {
  font-family: "KalimatiDigits";
  src: local("Kalimati"), url("../assets/fonts/Kalimati.ttf") format("truetype");
  font-display: swap;
  unicode-range: U+0030-0039;
}
.vsum-d, .vdiv-by, .vdiv-num, .is-math { font-family: "KalimatiDigits", var(--font); }

/* ---------- 1. Theme tokens ---------- */
:root {
  --green: #0f7a4a;
  --green-600: #0c6a40;
  --green-soft: #e3f4ea;
  --blue: #1d4ed8;
  --blue-600: #1a43bb;
  --blue-soft: #e5edff;
  --red: #c62828;
  --red-soft: #fdecec;
  --amber: #b45309;
  --amber-soft: #fff4e0;

  --bg: #f4f7fa;
  --surface: #ffffff;
  --surface-2: #f0f4f8;
  --border: #dde4ec;
  --text: #17212e;
  --text-muted: #5a6878;
  --heading: #0d1b2a;
  --shadow: 0 1px 2px rgba(16, 32, 56, .06), 0 4px 16px rgba(16, 32, 56, .06);
  --shadow-lg: 0 10px 40px rgba(16, 32, 56, .18);
  --header-bg: rgba(255, 255, 255, .92);
  --hero-grad: linear-gradient(135deg, #0f7a4a 0%, #11698a 50%, #1d4ed8 100%);
  --footer-bg: #0d1b2a;
  --footer-text: #c9d4e0;
  --focus: #2563eb;

  --radius: 14px;
  --radius-sm: 9px;
  --font: "Kalimati", "Segoe UI", "Nirmala UI", "Noto Sans Devanagari", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --header-h: 66px;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background-color .2s, color .2s;
}
h1, h2, h3, h4 { color: var(--heading); line-height: 1.3; margin: 0 0 .5em; }
h1 { font-size: clamp(1.6rem, 3.2vw, 2.3rem); }
h2 { font-size: clamp(1.3rem, 2.4vw, 1.7rem); }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; }
a { color: var(--blue); }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; } /* the hidden attribute always wins over display rules */
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 1000;
  background: var(--blue); color: #fff; padding: 10px 16px; border-radius: 8px;
}
.skip-link:focus { top: 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 3. Layout ---------- */
.container { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.app-main { flex: 1; outline: none; }
.section { padding: 40px 0; }
.section-sm { padding: 24px 0; }
.page-head { padding: 32px 0 8px; }
.page-head p { color: var(--text-muted); margin: 0; }
.eyebrow { display: inline-block; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--green); margin-bottom: 6px; }
.grid { display: grid; gap: 20px; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card h3 { margin-bottom: .35em; }
.muted { color: var(--text-muted); }
.small { font-size: .88rem; }
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 10px; } .mt-2 { margin-top: 20px; } .mt-3 { margin-top: 32px; }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: 20px; }
.flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.breadcrumb { font-size: .9rem; color: var(--text-muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--blue); text-decoration: underline; }

/* ---------- 4. Buttons / forms / badges / alerts ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 20px;
  border: 1.5px solid transparent; border-radius: 10px;
  font-weight: 600; font-size: .97rem; line-height: 1.2;
  text-decoration: none; cursor: pointer;
  transition: background-color .15s, border-color .15s, transform .1s, box-shadow .15s;
  background: var(--surface-2); color: var(--text);
}
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--green-600); }
.btn-secondary { background: var(--blue); color: #fff; }
.btn-secondary:hover:not(:disabled) { background: var(--blue-600); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover:not(:disabled) { border-color: var(--blue); color: var(--blue); }
.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--surface-2); }
.btn-danger { background: var(--red); color: #fff; }
.btn-light { background: #fff; color: #0d3b66; }
.btn-light:hover { background: #eef4ff; }
.btn-glass { background: rgba(255, 255, 255, .14); color: #fff; border-color: rgba(255, 255, 255, .55); }
.btn-glass:hover { background: rgba(255, 255, 255, .24); }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .88rem; border-radius: 8px; }
.btn-lg { min-height: 52px; padding: 14px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .95rem; }
.form-hint { font-size: .85rem; color: var(--text-muted); margin-top: 4px; }
.form-control {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1.5px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text);
  transition: border-color .15s, box-shadow .15s;
}
textarea.form-control { min-height: 120px; resize: vertical; line-height: 1.5; }
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 25%, transparent); outline: none; }
.form-control.invalid { border-color: var(--red); }
.form-error { color: var(--red); font-size: .88rem; margin-top: 6px; min-height: 1em; }
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: flex; align-items: center; gap: 10px; min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--green); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--text-muted); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }

.alert { padding: 14px 16px; border-radius: var(--radius-sm); border-left: 4px solid; margin-bottom: 16px; }
.alert-info { background: var(--blue-soft); border-color: var(--blue); }
.alert-success { background: var(--green-soft); border-color: var(--green); }
.alert-warning { background: var(--amber-soft); border-color: var(--amber); }
.alert-error { background: var(--red-soft); border-color: var(--red); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
.tab {
  display: inline-flex; align-items: center; gap: 6px; min-height: 42px; padding: 8px 16px;
  border: 1.5px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); font-weight: 600; text-decoration: none; cursor: pointer; font-size: .93rem;
}
.tab:hover { border-color: var(--green); }
.tab.active, .tab[aria-selected="true"] { background: var(--green); border-color: var(--green); color: #fff; }

.empty-state { text-align: center; padding: 40px 20px; color: var(--text-muted); }
.empty-state .big { font-size: 2.6rem; display: block; margin-bottom: 8px; }

/* ---------- 5. Header / navigation ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  border-bottom: 1px solid var(--border);
}
/* Blur lives on a pseudo-element: backdrop-filter on the header itself would
   trap the fixed mobile menu inside the header box. */
.site-header::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--header-bg);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
}
.nav-wrap { display: flex; align-items: center; gap: 16px; min-height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--heading); flex-shrink: 0; }
.brand-logo { width: 38px; height: 38px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-size: 1.02rem; }
.brand-text small { font-size: .74rem; color: var(--text-muted); letter-spacing: .02em; }
.main-nav { margin-left: auto; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; align-items: center; gap: 2px; }
.nav-link {
  display: flex; align-items: center; gap: 4px;
  padding: 9px 11px; border-radius: 8px; min-height: 42px;
  font-size: .93rem; font-weight: 600; color: var(--text); text-decoration: none;
  background: none; border: 0; cursor: pointer; white-space: nowrap;
}
.nav-link:hover, .dropdown:hover > .nav-link { background: var(--surface-2); color: var(--green); }
.nav-link.active { color: var(--green); background: var(--green-soft); }
.caret { font-size: .75rem; transition: transform .15s; }
.dropdown { position: relative; }
.dropdown-menu {
  list-style: none; margin: 0; padding: 6px;
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 220px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow-lg);
  opacity: 0; visibility: hidden; transform: translateY(-4px);
  transition: opacity .15s, transform .15s, visibility .15s;
}
.dropdown-menu a { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.dropdown-menu a:hover, .dropdown-menu a:focus-visible { background: var(--green-soft); color: var(--green); }
/* Desktop: open on hover / keyboard focus / click */
@media (hover: hover) and (min-width: 1101px) {
  .dropdown:hover .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
}
.dropdown:focus-within .dropdown-menu,
.dropdown.open .dropdown-menu { opacity: 1; visibility: visible; transform: none; }
.dropdown.open .caret { transform: rotate(180deg); }
.nav-divider { width: 1px; height: 26px; background: var(--border); margin: 0 6px; }
.nav-icon-link { font-size: 1.1rem; padding: 9px 9px; }
.nav-icon-label { display: none; font-size: .93rem; }

.nav-actions { display: flex; align-items: center; gap: 6px; order: 3; }
.icon-btn {
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); cursor: pointer; font-size: 1.1rem;
}
.icon-btn:hover { border-color: var(--green); }
.hamburger { display: none; flex-direction: column; gap: 4px; }
.hamburger span { display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; transition: transform .2s, opacity .2s; }
.hamburger[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.hamburger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Logged-in name in the header — click opens the profile popup */
.user-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 170px; min-height: 40px;
  padding: 6px 12px; border-radius: 999px; background: var(--green-soft); color: var(--green);
  font-weight: 700; font-size: .88rem; text-decoration: none; border: 1.5px solid transparent; cursor: pointer;
}
.user-chip:hover { border-color: var(--green); }
.user-chip[hidden] { display: none; }
.user-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Profile popup */
.profile-info { display: grid; grid-template-columns: auto 1fr; gap: 10px 18px; margin: 4px 0 14px; padding: 14px 16px; background: var(--surface-2); border-radius: 12px; }
.profile-info dt { color: var(--text-muted); font-weight: 600; }
.profile-info dt::after { content: ":"; }
.profile-info dd { margin: 0; font-weight: 700; color: var(--heading); overflow-wrap: anywhere; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Syllabus popup */
.picker-list { display: grid; gap: 10px; }
.picker-item {
  display: flex; align-items: center; gap: 14px; padding: 12px 14px; min-height: 56px;
  border: 1.5px solid var(--border); border-radius: 12px; color: var(--text); text-decoration: none;
}
.picker-item:hover, .picker-item:focus-visible { border-color: var(--green); background: var(--green-soft); }
.picker-item small { display: block; color: var(--text-muted); }
.picker-icon { font-size: 1.5rem; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 10px; background: var(--surface-2); flex-shrink: 0; }

/* Before login: only the brand is shown in the header */
body.logged-out .main-nav,
body.logged-out .hamburger { display: none !important; }
body.logged-out .nav-actions { margin-left: auto; }

/* ---------- Login page ---------- */
.login-page {
  background: url("../assets/images/hero-pattern.svg"), var(--hero-grad);
  color: #fff; padding: 56px 0 64px; min-height: calc(100vh - var(--header-h));
  display: flex; align-items: center;
}
.login-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 48px; align-items: center; }
.login-intro .hero-services { margin-bottom: 20px; }
.login-features { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; opacity: .95; font-weight: 500; }
.login-card { color: var(--text); padding: 32px; max-width: 440px; width: 100%; justify-self: end; box-shadow: var(--shadow-lg); }
.login-card h2 { margin-bottom: 4px; }
.auth-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; margin-bottom: 18px; }
.auth-tab { display: flex; align-items: center; justify-content: center; min-height: 42px; border-radius: 9px; font-weight: 700; color: var(--text-muted); text-decoration: none; }
.auth-tab:hover { color: var(--green); }
.auth-tab[aria-selected="true"] { background: var(--surface); color: var(--green); box-shadow: var(--shadow); }
.login-card .check { margin-bottom: 6px; }
.login-badge {
  width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center;
  font-size: 1.8rem; background: var(--blue-soft); margin-bottom: 14px;
}

/* ---------- 6. Login hero text / service cards / subject cards ---------- */
.h2-size { font-size: clamp(1.3rem, 2.4vw, 1.7rem); }
.hero-title { color: #fff; font-size: clamp(1.9rem, 4.6vw, 3.1rem); font-weight: 800; letter-spacing: -.01em; margin-bottom: 14px; }
.hero-title span { color: #b9f5d0; }
.hero-sub { font-size: 1.15rem; opacity: .95; margin-bottom: 10px; font-weight: 600; }
.hero-services { list-style: none; padding: 0; margin: 0 0 28px; display: flex; flex-wrap: wrap; gap: 10px; }
.hero-services li { background: rgba(255, 255, 255, .13); border: 1px solid rgba(255, 255, 255, .28); padding: 8px 16px; border-radius: 999px; font-weight: 600; }

.service-card { display: flex; flex-direction: column; gap: 6px; border-top: 4px solid var(--green); transition: transform .15s, box-shadow .15s; }
.service-card:nth-child(2) { border-top-color: var(--blue); }
.service-card:nth-child(3) { border-top-color: #0e7490; }
.service-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.service-icon { font-size: 2.3rem; width: 64px; height: 64px; display: grid; place-items: center; border-radius: 16px; background: var(--surface-2); margin-bottom: 6px; }
.service-name { margin: 0; }
.service-post { font-weight: 600; color: var(--green); margin: 0 0 4px; }
.service-desc { color: var(--text-muted); font-size: .95rem; flex: 1; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.feature-icon { font-size: 1.6rem; width: 48px; height: 48px; display: grid; place-items: center; border-radius: 12px; background: var(--blue-soft); margin-bottom: 10px; }

.subject-card {
  display: flex; align-items: center; gap: 14px; text-align: left; width: 100%;
  background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 18px; cursor: pointer; text-decoration: none; color: var(--text); box-shadow: var(--shadow);
  transition: border-color .15s, transform .15s;
}
.subject-card:hover { border-color: var(--green); transform: translateY(-2px); }
.subject-icon { font-size: 1.7rem; width: 52px; height: 52px; flex-shrink: 0; display: grid; place-items: center; border-radius: 12px; background: var(--green-soft); }
.subject-name { display: block; font-weight: 700; font-size: 1.05rem; color: var(--heading); }
.subject-meta { display: block; font-size: .86rem; color: var(--text-muted); }

/* ---------- 7. Syllabus + rich text (notes) ---------- */
.syllabus-head { display: flex; gap: 16px; align-items: center; }
.syllabus-head .service-icon { margin: 0; }
.syllabus-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; box-shadow: var(--shadow); overflow: hidden; }
.syllabus-section summary {
  cursor: pointer; list-style: none; padding: 16px 20px; font-weight: 700; font-size: 1.05rem; color: var(--heading);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.syllabus-section summary::-webkit-details-marker { display: none; }
.syllabus-section summary::after { content: "+"; font-size: 1.4rem; color: var(--green); line-height: 1; }
.syllabus-section[open] summary::after { content: "−"; }
.syllabus-section[open] summary { border-bottom: 1px solid var(--border); }
.syllabus-body { padding: 16px 20px 8px; }

.notes-layout { display: grid; grid-template-columns: 280px 1fr; gap: 24px; align-items: start; }
.notes-toc { position: sticky; top: calc(var(--header-h) + 16px); padding: 12px; }
.notes-toc h3 { font-size: .95rem; padding: 6px 8px; margin: 0; color: var(--text-muted); }
.toc-link { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px; border: 0; background: none; cursor: pointer; color: var(--text); font-weight: 500; min-height: 42px; text-decoration: none; }
.toc-link:hover { background: var(--surface-2); }
.toc-link.active { background: var(--green-soft); color: var(--green); font-weight: 700; }
.note-article { padding: 28px; }
.note-article > h2 { border-bottom: 2px solid var(--green-soft); padding-bottom: 10px; }
.note-nav { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; flex-wrap: wrap; }

.rich { font-size: 1.02rem; }
.rich h3 { font-size: 1.25rem; margin-top: 1.2em; color: var(--green); }
.rich h4 { font-size: 1.05rem; margin-top: 1em; color: var(--blue); }
.rich ul, .rich ol { padding-left: 1.4em; margin: 0 0 1em; }
.rich li { margin-bottom: .35em; }
.rich strong { color: var(--heading); }
.rich .tip, .rich .important { padding: 12px 14px 12px 44px; border-radius: 10px; margin: 0 0 1em; position: relative; }
.rich .tip { background: var(--blue-soft); }
.rich .important { background: var(--amber-soft); }
.rich .tip::before, .rich .important::before { position: absolute; left: 14px; top: 11px; }
.rich .tip::before { content: "💡"; }
.rich .important::before { content: "⚠️"; }
.rich .table-wrap { margin-bottom: 1em; }

/* Home page service boxes (packages) */
.plan-grid { max-width: 1040px; margin-left: auto; margin-right: auto; }
.plan-card { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; border-top: 4px solid var(--green); padding: 26px 22px; }
.plan-card:nth-child(2) { border-top-color: var(--blue); }
.plan-card:nth-child(3) { border-top-color: #0e7490; }
.plan-logo { width: 104px; height: 104px; border-radius: 50%; background: #fff; border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; box-shadow: var(--shadow); }
.plan-logo img { width: 88%; height: 88%; object-fit: contain; }
.plan-logo-fallback { display: none; font-size: 2.6rem; }
.plan-logo.no-img img { display: none; }
/* Wide images (banners) fill the top of the box instead of a circle */
.plan-logo.wide { width: 100%; height: auto; min-height: 0; border-radius: 10px; padding: 0; }
.plan-logo.wide img { width: 100%; height: auto; }
.plan-logo.no-img .plan-logo-fallback { display: block; }
.plan-name { font-size: 1.25rem; margin: 4px 0 0; }
.plan-price { font-size: 1.9rem; font-weight: 800; color: var(--green); line-height: 1.1; }
.plan-card .btn-block { max-width: 260px; }
.plan-features { width: 100%; margin-top: 8px; padding-top: 14px; border-top: 1px dashed var(--border); text-align: left; }
.plan-features h3 { font-size: 1rem; text-align: center; margin-bottom: 8px; }
.plan-features ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.plan-features li { position: relative; padding-left: 26px; }
.plan-features li::before { content: "✓"; position: absolute; left: 4px; color: var(--green); font-weight: 800; }
.plan-features a { color: var(--text); text-decoration: none; }
.plan-features a:hover { color: var(--green); text-decoration: underline; }

/* Purchased service card: 4 section tiles */
.plan-grid-single { max-width: 460px; }
.my-service .section-tiles { width: 100%; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 6px; }
.section-tile {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  min-height: 92px; padding: 12px 8px; border-radius: 12px; border: 1.5px solid var(--border);
  background: var(--surface-2); color: var(--heading); font-weight: 700; text-decoration: none;
  transition: border-color .15s, background-color .15s, transform .1s;
}
.section-tile:hover, .section-tile:focus-visible { border-color: var(--green); background: var(--green-soft); }
.section-tile:active { transform: translateY(1px); }
.section-tile-icon { font-size: 1.7rem; line-height: 1; }
/* 5th tile (Class Room) spans the full width */
.my-service .section-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }
.section-tile.is-live { border-color: var(--red); background: #fff1f1; }
.tile-live { font-size: .72rem; animation: live-pulse 1.4s ease-in-out infinite; }

/* Class Room */
.h3-size { font-size: 1.2rem; }
.class-form { margin-bottom: 16px; }
.class-list { display: grid; gap: 16px; }
.class-card.is-live { border: 2px solid var(--red); box-shadow: 0 0 0 4px rgba(220, 38, 38, .08); }
.class-comments { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 10px; }
.comment-list { display: grid; gap: 8px; margin: 8px 0; max-height: 360px; overflow-y: auto; }
.comment { background: var(--surface-2); border-radius: 10px; padding: 8px 12px; }
.comment.is-admin { background: var(--blue-soft); }
.comment-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .92rem; }
.comment-head .btn { margin-left: auto; min-height: 28px; padding: 2px 8px; }
.comment p { white-space: pre-wrap; word-break: break-word; }
.comment.is-reply { margin-left: 22px; border-left: 3px solid var(--blue); }
.class-comments .comment-list .comment { scroll-margin-top: 80px; }
.reply-quote { margin: 0 0 10px; padding: 8px 12px; border-left: 3px solid var(--border); background: var(--surface-2); border-radius: 6px; white-space: pre-wrap; }
.comment-form { display: flex; gap: 8px; }
.comment-form .form-control { flex: 1; min-width: 0; }
.live-banner { background: var(--red); color: #fff; }
.live-banner-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 8px; padding-bottom: 8px; flex-wrap: wrap; }
.live-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: live-pulse 1.2s ease-in-out infinite; }
@keyframes live-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live-dot, .tile-live { animation: none; } }
/* One-click choice chips (e.g. existing sub-topic names) */
.pick-chips { display: flex; flex-wrap: wrap; gap: 6px; max-height: 160px; overflow-y: auto; }
.chip-btn { border: 1.5px solid var(--border); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 6px 12px; min-height: 36px; cursor: pointer; font: inherit; font-size: .9rem; }
.chip-btn:hover, .chip-btn:focus-visible { border-color: var(--green); background: var(--green-soft); color: var(--green); }

/* Admin edit mode on content pages */
.price-edit { background: none; border: 1.5px dashed transparent; border-radius: 10px; padding: 2px 10px; cursor: pointer; font-family: inherit; }
.price-edit:hover, .price-edit:focus-visible { border-color: var(--green); }
.edit-banner { margin-top: 8px; }
.topic-wrap { position: relative; }
.topic-wrap .subject-card { padding-right: 84px; height: 100%; }
.topic-wrap .inline-tools { position: absolute; top: 8px; right: 8px; }
.inline-tools { display: inline-flex; gap: 2px; }
.inline-tools .btn-sm { min-height: 32px; padding: 4px 8px; }
.toc-tools { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 8px 10px; }
.toc-group { margin-bottom: 6px; }
.toc-group-title { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 8px 8px 4px; font-weight: 700; font-size: .9rem; color: var(--blue); border-top: 1px dashed var(--border); }
.toc-empty { padding: 0 12px; }
.q-group { margin-top: 16px; }
.q-group-title { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); margin-bottom: 8px; }

/* Video page */
.video-list { display: grid; gap: 18px; max-width: 860px; }
.video-frame { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #000; }
.video-frame iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* Buy Now popup */
.pay-box { text-align: center; background: var(--surface-2); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.pay-amount { font-size: 1.6rem; font-weight: 800; color: var(--green); margin-bottom: 6px; }
.pay-row { display: flex; justify-content: center; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.pay-qr { width: 200px; max-width: 100%; margin: 10px auto 0; border-radius: 10px; background: #fff; padding: 6px; border: 1px solid var(--border); }
.pay-steps { padding-left: 1.2em; margin: 0 0 12px; }
.pay-preview { max-height: 180px; margin-top: 8px; border-radius: 8px; border: 1px solid var(--border); }

.grade-card { margin: 0; }
.grade-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 0; border-top: 1px dashed var(--border); }
.grade-q { flex: 1; min-width: 220px; font-weight: 600; }
.grade-actions { display: flex; align-items: center; gap: 8px; }
.grade-input { width: 90px; min-height: 38px; }
.pay-thumb { width: 64px; height: 64px; flex-shrink: 0; padding: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; cursor: zoom-in; }
.pay-thumb img { width: 100%; height: 100%; object-fit: cover; }

/* Protected notes (no select / drag / save; watermark; hidden when window not active) */
.protected-note { position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; overflow: hidden; }
.protected-note canvas, .protected-note img { -webkit-user-drag: none; user-drag: none; }
.note-page { display: block; width: 100%; height: auto; margin: 0 0 14px; border: 1px solid var(--border); border-radius: 6px; background: #fff; }
.note-watermark {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  display: flex; flex-wrap: wrap; align-content: space-around; justify-content: space-around; gap: 60px 40px;
  transform: rotate(-24deg) scale(1.4); opacity: .1; font-weight: 800; font-size: 1rem; color: #0d1b2a;
}
.note-watermark span { white-space: nowrap; }
.docx-note img { max-width: 100%; height: auto; }
.docx-note table { border-collapse: collapse; width: 100%; margin-bottom: 1em; }
.docx-note td, .docx-note th { border: 1px solid var(--border); padding: 6px 8px; }
body.note-hidden .protected-note > :not(.note-watermark) { filter: blur(18px); }
body.note-hidden .protected-note::after {
  content: "🔒 Note hidden — click here to continue reading"; position: absolute; inset: 0; z-index: 3;
  display: grid; place-items: center; text-align: center; font-weight: 700; color: var(--heading); padding: 20px;
}
@media print { .protected-note, .note-article { display: none !important; } }

/* Exam paper (all questions on one scrolling page) */
.paper-head { text-align: center; margin: 6px 0 18px; }
.paper-date { font-weight: 700; color: var(--text-muted); margin-bottom: 4px; }
.paper-title { font-size: clamp(1.35rem, 3vw, 1.9rem); margin-bottom: 4px; }
.paper-section { margin-bottom: 18px; }
.paper-section-title { font-size: 1.15rem; padding: 10px 14px; border-radius: 10px; background: var(--blue-soft); color: var(--blue); margin: 18px 0 12px; }
/* Model set paper — printed exam sheet inside a page boundary */
.exam-sheet { background: #fff; border: 2px solid var(--heading); outline: 1px solid var(--heading); outline-offset: -7px; border-radius: 4px; padding: 26px 28px; margin: 6px 0 18px; }
.sheet-head { text-align: center; border-bottom: 2px solid var(--heading); padding-bottom: 12px; margin-bottom: 14px; }
.sheet-title { font-size: clamp(1.1rem, 2.6vw, 1.45rem); line-height: 1.5; margin: 0 0 4px; }
.sheet-sub { font-size: 1.1rem; font-weight: 700; margin: 0; text-decoration: underline; text-underline-offset: 4px; }
.sheet-meta { border-bottom: 1px solid var(--heading); padding-bottom: 10px; margin-bottom: 6px; }
.sheet-meta p { margin: 0 0 6px; }
.sheet-date { text-align: center; }
.sheet-subjects { text-align: center; font-size: 1.05rem; color: var(--heading); }
.q-main { display: block; }
.q-subs { display: block; margin-top: 4px; }
.q-sub { display: grid; grid-template-columns: 2.4em 1fr; align-items: baseline; margin-top: 3px; font-weight: 500; }
.q-sub-key { font-weight: 700; }
.aq .q-subs { margin-left: 4px; }
.sheet-row { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sheet-key { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 8px; }
.key-given { font-weight: 800; font-size: 1.15rem; color: var(--danger, #c0262d); min-width: 1.2em; }
.key-box { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--heading); background: #fff; font-weight: 800; font-size: 1rem; cursor: pointer; color: var(--heading); }
.key-box:hover { background: var(--blue-soft); }
.key-box.chosen { background: var(--heading); color: #fff; }
.key-box:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.key-note { color: var(--danger, #c0262d); font-weight: 600; font-size: .9rem; }
.sheet-section { margin-top: 16px; }
.sheet-section-title { font-size: 1.15rem; margin: 0 0 4px; text-decoration: underline; text-underline-offset: 4px; }
.sheet-sub-title { font-weight: 700; margin: 0 0 10px; }
.sheet-subject { margin-top: 12px; }
.sheet-subject .sheet-sub-title { border-bottom: 1px dashed var(--border); padding-bottom: 4px; margin-bottom: 4px; }
@media (max-width: 600px) {
  .exam-sheet { padding: 18px 14px; outline-offset: -5px; }
  .key-box { width: 34px; height: 34px; }
}
/* Questions laid out like a printed question paper */
.q-item { margin: 0; padding: 12px 0 14px; border: 0; border-bottom: 1px dotted #c3ccd6; min-width: 0; background: none; box-shadow: none; }
.q-item:last-child { border-bottom: 0; }
.q-item legend.q-text, .q-item .q-text {
  font-size: 1.04rem; font-weight: 600; color: var(--heading); line-height: 1.6;
  margin-bottom: 8px; padding: 0; float: left; width: 100%;
  display: grid; grid-template-columns: 2.2em 1fr; align-items: baseline;
}
.q-item .options { clear: both; margin-left: 2.2em; }
.q-no { color: var(--heading); font-weight: 800; text-align: right; padding-right: .45em; }
.q-item .options { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 18px; }
.q-item .options.options-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.q-item .option-btn { min-height: 38px; padding: 5px 10px; gap: 8px; border: 1px solid transparent; border-radius: 8px; background: none; font-size: .98rem; }
.q-item .option-btn:hover { border-color: var(--border); background: var(--surface-2); }
.q-item .option-btn.selected { border-color: var(--green); background: var(--green-soft); }
.q-item .option-key { width: 26px; height: 26px; font-size: .8rem; border: 1.5px solid var(--heading); background: #fff; color: var(--heading); }
.q-item .option-btn.selected .option-key { background: var(--green); border-color: var(--green); color: #fff; }
.option-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.q-subjective { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 0 10px; align-items: baseline; font-size: 1.04rem; font-weight: 600; color: var(--heading); line-height: 1.6; }
.q-subjective .q-no { padding-right: 0; }
.q-marks { font-weight: 700; white-space: nowrap; }
.answer-upload { border: 2px dashed var(--blue); border-radius: 12px; background: var(--blue-soft); padding: 18px 20px; margin: 4px 0 14px; }
.answer-upload-title { font-size: 1.1rem; margin: 0 0 4px; color: var(--blue); }
.upload-list { list-style: none; margin: 10px 0 0; padding: 0; }
.upload-list .upload-row { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; margin-top: 8px; }
.upload-q { font-weight: 700; min-width: 8.5em; }
@media (max-width: 640px) {
  .q-item .options, .q-item .options.options-4 { grid-template-columns: 1fr; margin-left: 0; }
  .q-item legend.q-text, .q-item .q-text, .q-subjective { grid-template-columns: 1.9em 1fr; }
  .q-subjective .q-marks { grid-column: 2; }
}
.upload-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.upload-status { font-size: .9rem; color: var(--amber); font-weight: 600; }
.upload-status.done { color: var(--green); }
.paper-actions { justify-content: center; flex-wrap: wrap; }
.paper-actions .btn { flex: 1; max-width: 220px; }
.paper-actions .btn:disabled { opacity: .5; }

/* Result paper */
.result-paper { padding-top: 20px; }
.answer-table td { vertical-align: top; }
.answer-table td:first-child { width: 56px; font-weight: 700; }
.answer-table td:nth-child(2) { width: 34%; }
.answer-table .aq { font-weight: 600; color: var(--heading); margin-bottom: 4px; }
.ans { font-weight: 600; }
.ans-ok { color: var(--green); }
.ans-bad { color: var(--red); }
.ans-skip { color: var(--amber); }
.ans-file { color: var(--blue); }
.ans-correct { color: var(--green); }
.row-wrong { background: color-mix(in srgb, var(--red-soft) 50%, transparent); }
.result-lines { max-width: 620px; margin: 20px auto 0; }
.result-lines p { margin: 0 0 8px; font-size: 1.02rem; }
.result-total { font-size: 1.15rem !important; padding-top: 8px; border-top: 1px dashed var(--border); }
.all-results { max-width: 720px; margin: 0 auto; }
.all-results tr.is-me { background: var(--green-soft); }

/* Notice page */
.notice-list { display: grid; gap: 16px; max-width: 860px; }
.notice-card { border-left: 5px solid var(--blue); }
.notice-card.is-important { border-left-color: var(--red); }
.notice-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.notice-title { font-size: 1.15rem; margin: 0; }
.notice-date { margin: 4px 0 10px; }

/* ---------- 8. Exam ---------- */
.setup-card { max-width: 720px; margin: 0 auto; }
.model-start { display: flex; flex-direction: column; align-items: center; gap: 22px; padding: 28px 0 40px; }
.model-start-item { text-align: center; }
.topic-setup { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); padding: 14px 16px; margin: 10px 0 16px; }
.setup-table { width: 100%; border-collapse: collapse; background: var(--surface); }
.setup-table th, .setup-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.setup-table th { font-size: .85rem; }
.setup-table tfoot th { font-size: .95rem; background: var(--surface-2); }
.setup-table td:nth-child(2), .setup-table td:nth-child(3) { width: 130px; white-space: nowrap; }
.setup-table .form-control { width: 70px; display: inline-block; min-height: 36px; padding: 4px 8px; }
.doc-frame { width: 100%; height: 80vh; min-height: 420px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
.doc-image { max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 10px; }
.doc-word { display: flex; align-items: center; gap: 14px; padding: 16px; border: 1px dashed var(--border); border-radius: 10px; background: var(--surface-2); }
.doc-word .big { font-size: 2.4rem; }
/* Column (vertical) sum inside a question: [[2367 + 2568]] */
.vsum { display: grid; width: max-content; grid-template-columns: auto auto; column-gap: 6px; margin: 6px 0 6px 8px; font-weight: 700; font-size: 1.08em; line-height: 1.5; }
.vsum-op { text-align: right; }
.vsum-num { display: flex; justify-content: flex-end; }
.vsum-d { display: inline-block; width: 1.3em; text-align: center; }
.vsum-line { grid-column: 1 / -1; border-top: 2px solid currentColor; height: 1.4em; }
/* Long division: [[355 ÷ 7]] →  7 ) 355  with the bar over the dividend */
.vdiv { display: flex; width: max-content; align-items: stretch; margin: 10px 0 10px 8px; font-weight: 700; font-size: 1.08em; letter-spacing: .25em; line-height: 1.5; }
.vdiv-by { padding: 4px 6px 0 0; }
.vdiv-num { border-top: 2px solid currentColor; border-left: 2px solid currentColor; border-bottom-left-radius: 14px 30px; padding: 4px 10px 22px 12px; }
.q-item legend .q-body { display: block; }
/* Feedback Class — live MCQ poll */
.fb-live { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 18px 22px; padding: 20px; }
.fb-main { min-width: 0; }
.fb-count { display: flex; align-items: center; gap: 8px; font-size: .85rem; color: var(--text-muted); font-weight: 700; margin: 0 0 8px; }
.fb-count-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--blue); }
.fb-q { font-size: clamp(1.2rem, 2.6vw, 1.6rem); line-height: 1.5; margin: 0 0 18px; }
.fb-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.fb-opt { position: relative; display: flex; align-items: center; gap: 14px; min-height: 70px; padding: 12px 16px; border: 2px solid #c9d2dc; border-radius: 12px; background: #fff; font-size: 1.12rem; font-weight: 700; color: var(--heading); box-shadow: 0 2px 0 #c9d2dc; }
.fb-opt-key { flex-shrink: 0; font-weight: 800; color: var(--heading); }
.fb-opt.is-mine { border-color: var(--blue); }
.fb-opt.is-correct { border-color: var(--green); background: var(--green-soft); }
.fb-opt.is-wrong { border-color: var(--red); background: #fff1f1; }
.fb-tick { margin-left: auto; color: var(--green); font-size: 1.3rem; }
.fb-hint { margin: 16px 0 0; font-weight: 700; color: var(--heading); }
.fb-explain { margin: 10px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--blue-soft); }
.fb-poll { border-left: 1px solid var(--border); padding-left: 18px; min-width: 0; }
.fb-poll h3 { font-size: .8rem; letter-spacing: .08em; color: var(--text-muted); margin: 0 0 10px; }
.fb-bars { display: grid; gap: 8px; margin-bottom: 14px; }
.fb-bar-row { display: grid; grid-template-columns: 22px 1fr 30px; align-items: center; gap: 8px; }
.fb-bar-key { font-weight: 800; font-size: .85rem; text-align: center; border-radius: 6px; background: var(--surface-2); }
.fb-bar { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.fb-bar span { display: block; height: 100%; border-radius: 6px; background: #8b5cf6; transition: width .3s; }
.fb-bar-row:nth-child(1) .fb-bar span { background: #3b82f6; }
.fb-bar-row:nth-child(2) .fb-bar span { background: #22c55e; }
.fb-bar-row:nth-child(3) .fb-bar span { background: #eab308; }
.fb-bar-row:nth-child(4) .fb-bar span { background: #a855f7; }
.fb-bar-row.is-correct .fb-bar-key { background: var(--green); color: #fff; }
.fb-bar-n { font-weight: 700; font-size: .9rem; text-align: right; }
.fb-people { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 320px; overflow-y: auto; }
.fb-people li { display: flex; align-items: center; gap: 10px; font-size: .92rem; }
.fb-avatar { flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800; color: #fff; background: #e11d48; }
.fb-people li:nth-child(3n+2) .fb-avatar { background: #7c3aed; }
.fb-people li:nth-child(3n+3) .fb-avatar { background: #0891b2; }
.fb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.fb-letter { font-weight: 800; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); }
.fb-letter.ok { background: var(--green-soft); color: var(--green); }
.fb-letter.bad { background: #fff1f1; color: var(--red); }
.fb-footer { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 12px; }
.fb-chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); font-size: .88rem; }
.fb-spacer { flex: 1; }
.fb-chat-list { max-height: 300px; }
/* Full screen: only the question and options, large, for showing on a projector / live stream */
.fb-full { position: fixed; inset: 0; z-index: 2000; display: flex; padding: 4vh 5vw; overflow: auto; background: #fff; color: var(--heading); }
.fb-full[hidden] { display: none !important; }
body.fb-full-open { overflow: hidden; }
.fb-full-close { position: absolute; top: 14px; right: 18px; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--border); background: #fff; font-size: 1.3rem; cursor: pointer; }
/* auto margins centre it, and never cut the top off when it is taller than the screen */
.fb-full-inner { width: 100%; max-width: 1400px; margin: auto; }
.fb-full .fb-count { font-size: 1.3rem; }
.fb-full .fb-q { font-size: clamp(1.8rem, 3.6vw, 3.2rem); margin-bottom: 4vh; }
.fb-full .fb-opts { gap: 2.5vh 2vw; }
.fb-full .fb-opt { min-height: 13vh; font-size: clamp(1.4rem, 2.6vw, 2.4rem); padding: 2vh 2vw; border-width: 3px; }
.fb-full .fb-hint { font-size: clamp(1.1rem, 1.8vw, 1.6rem); margin-top: 4vh; }
.fb-full .fb-explain { font-size: clamp(1rem, 1.6vw, 1.4rem); }
.fb-full-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; margin-top: 4vh; }
.fb-full-controls .btn { min-width: 200px; font-size: clamp(1rem, 1.6vw, 1.3rem); }
.fb-full-keys { margin-top: 3vh; font-size: .9rem; color: var(--text-muted); text-align: center; }
.fb-user .fb-opt { min-height: 54px; font-size: 1rem; }
@media (max-width: 760px) {
  .fb-live { grid-template-columns: 1fr; padding: 14px; }
  .fb-poll { border-left: 0; border-top: 1px solid var(--border); padding: 12px 0 0; }
  .fb-opts { grid-template-columns: 1fr; }
  .fb-spacer { display: none; }
}
.vs-preview { min-height: 70px; border: 1px dashed var(--border); border-radius: 8px; padding: 6px 10px; margin-bottom: 8px; }
.math-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 6px; }
.math-key { min-width: 34px; height: 32px; padding: 0 6px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); color: var(--heading); font-size: 1rem; font-weight: 600; cursor: pointer; }
.math-key:hover { background: var(--blue-soft); border-color: var(--blue); }
.math-key:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.math-tools .btn { margin-left: 4px; }
.count-box { margin: 0; padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); font-weight: 700; color: var(--heading); }
.page-sub-center { display: block; text-align: center; color: var(--heading); }
.model-start .btn-lg { min-width: 260px; font-size: 1.15rem; padding: 16px 28px; }
.model-start .alert { margin-top: 10px; }
.model-card .dist { list-style: none; padding: 0; margin: 10px 0; }
.model-card .dist li { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .95rem; }
.model-meta { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }

.exam-shell { max-width: 900px; margin: 0 auto; padding: 16px 0 40px; }
.exam-bar {
  position: sticky; top: var(--header-h); z-index: 50;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 16px; margin-bottom: 16px;
}
.exam-bar-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.exam-title { font-weight: 700; color: var(--heading); font-size: 1rem; margin: 0; }
.exam-sub { font-size: .85rem; color: var(--text-muted); }
.timer {
  display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums;
  font-weight: 800; font-size: 1.15rem; padding: 6px 14px; border-radius: 10px;
  background: var(--green-soft); color: var(--green); white-space: nowrap;
}
.timer.warning { background: var(--amber-soft); color: var(--amber); }
.timer.danger { background: var(--red-soft); color: var(--red); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.progress { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin-top: 10px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--green), var(--blue)); border-radius: 999px; transition: width .25s; }
.progress-label { display: flex; justify-content: space-between; font-size: .84rem; color: var(--text-muted); margin-top: 6px; }

.question-card { padding: 24px; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.q-number { font-weight: 700; color: var(--blue); }
.q-text { font-size: 1.18rem; font-weight: 600; color: var(--heading); margin-bottom: 18px; line-height: 1.55; }
.options { display: grid; gap: 10px; }
.option-btn {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  min-height: 56px; padding: 12px 16px;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface);
  color: var(--text); cursor: pointer; font-size: 1.02rem;
  transition: border-color .12s, background-color .12s;
}
.option-btn:hover { border-color: var(--blue); background: var(--blue-soft); }
.option-btn.selected { border-color: var(--green); background: var(--green-soft); font-weight: 600; }
.option-key {
  flex-shrink: 0; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-weight: 700; background: var(--surface-2); color: var(--text-muted); font-size: .92rem;
}
.option-btn.selected .option-key { background: var(--green); color: #fff; }
.exam-nav { display: flex; gap: 10px; justify-content: space-between; margin-top: 20px; }
.exam-nav .btn { flex: 1; max-width: 200px; }
.exam-nav .btn-submit { max-width: 220px; }
.palette-card { margin-top: 16px; padding: 16px; }
.palette-title { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; font-size: .9rem; flex-wrap: wrap; gap: 8px; }
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(42px, 1fr)); gap: 6px; }
.palette-btn {
  height: 42px; border-radius: 8px; border: 1.5px solid var(--border); background: var(--surface);
  cursor: pointer; font-weight: 600; font-size: .9rem; color: var(--text);
}
.palette-btn.answered { background: var(--green); border-color: var(--green); color: #fff; }
.palette-btn.current { outline: 3px solid var(--blue); outline-offset: 1px; }
.legend { display: flex; gap: 12px; color: var(--text-muted); font-size: .82rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; border: 1.5px solid var(--border); }
.legend .l-answered { background: var(--green); border-color: var(--green); }
.kbd-hint { font-size: .82rem; color: var(--text-muted); margin-top: 12px; text-align: center; }

/* ---------- 9. Result ---------- */
.result-card { padding: 28px; }
.result-top { display: grid; grid-template-columns: 180px 1fr; gap: 28px; align-items: center; }
.score-ring {
  --p: 0;
  width: 170px; height: 170px; border-radius: 50%;
  background: conic-gradient(var(--ring-color, var(--green)) calc(var(--p) * 1%), var(--surface-2) 0);
  display: grid; place-items: center;
}
.score-ring-inner { width: 134px; height: 134px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.score-ring-inner strong { font-size: 2rem; color: var(--heading); display: block; line-height: 1; }
.score-ring-inner span { font-size: .85rem; color: var(--text-muted); }
.result-info dl { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.result-info dt { color: var(--text-muted); }
.result-info dd { margin: 0; font-weight: 600; }
.result-summary { margin-top: 16px; padding: 14px 16px; border-radius: 10px; font-weight: 600; }
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-top: 24px; }
.stat { background: var(--surface-2); border-radius: 12px; padding: 14px; text-align: center; }
.stat-value { display: block; font-size: 1.45rem; font-weight: 800; color: var(--heading); font-variant-numeric: tabular-nums; }
.stat-label { font-size: .84rem; color: var(--text-muted); }
.stat.good .stat-value { color: var(--green); }
.stat.bad .stat-value { color: var(--red); }
.stat.info .stat-value { color: var(--blue); }

.review-list { display: grid; gap: 14px; }
.review-item { border-left: 5px solid var(--border); padding: 18px 20px; }
.review-item.correct { border-left-color: var(--green); }
.review-item.wrong { border-left-color: var(--red); }
.review-item.skipped { border-left-color: var(--amber); }
.review-q { font-weight: 600; color: var(--heading); margin-bottom: 10px; }
.answer-line { padding: 8px 12px; border-radius: 8px; margin-bottom: 6px; font-size: .96rem; }
.answer-line.is-correct { background: var(--green-soft); }
.answer-line.is-wrong { background: var(--red-soft); }
.answer-line.is-skipped { background: var(--amber-soft); }
.explanation { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--blue-soft); font-size: .95rem; }

/* ---------- 10. Dashboard / leaderboard / tables ---------- */
.profile-card { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; font-size: 1.6rem; font-weight: 800; color: #fff; background: var(--hero-grad); flex-shrink: 0; }
.progress-row { margin-bottom: 14px; }
.progress-row .flex-between { font-size: .92rem; }
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: .95rem; background: var(--surface); }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.table th { background: var(--surface-2); font-weight: 700; color: var(--heading); white-space: nowrap; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.rank-badge { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; font-weight: 800; background: var(--surface-2); }
.rank-1 { background: #f5c542; color: #3d2c00; }
.rank-2 { background: #c9d1da; color: #222; }
.rank-3 { background: #d99a5b; color: #2b1600; }
.filter-bar { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; margin-bottom: 16px; }
.filter-bar .form-group { margin: 0; min-width: 200px; flex: 1; }

/* ---------- 11. Admin panel ---------- */
.admin-layout { display: grid; grid-template-columns: 230px 1fr; gap: 20px; align-items: start; }
.admin-tabs { display: flex; flex-direction: column; gap: 4px; padding: 10px; position: sticky; top: calc(var(--header-h) + 16px); }
.admin-tab { text-align: left; padding: 11px 14px; border-radius: 9px; border: 0; background: none; cursor: pointer; font-weight: 600; min-height: 44px; color: var(--text); }
.admin-tab:hover { background: var(--surface-2); }
.admin-tab[aria-selected="true"] { background: var(--blue-soft); color: var(--blue); }
.admin-panel h2 { margin-bottom: 4px; }
.admin-toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; margin: 16px 0; }
.admin-toolbar .form-group { margin: 0; min-width: 180px; flex: 1; }
.admin-list { display: grid; gap: 10px; }
.admin-item { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.admin-item-main { min-width: 0; flex: 1; }
.admin-item-title { font-weight: 600; color: var(--heading); word-break: break-word; }
.admin-item-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.admin-form { border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 18px; margin: 16px 0; background: var(--surface-2); }
.admin-form h3 { margin-top: 0; }
.option-input-row { display: grid; grid-template-columns: auto 1fr; gap: 10px; align-items: center; margin-bottom: 8px; }
.option-input-row input[type="radio"] { width: 22px; height: 22px; accent-color: var(--green); }
.dist-row { display: grid; grid-template-columns: 1fr 90px 90px 40px; gap: 8px; align-items: center; margin-bottom: 8px; }
.dist-head { margin-bottom: 4px; font-weight: 600; }
/* Model set rows: खण्ड · Topic · Sub-topic · MCQ · Subjective · Marks per Question */
.dist-table { min-width: 760px; }
.dist-table th { font-size: .85rem; }
.dist-table td { padding: 6px; vertical-align: middle; }
.dist-table td:nth-child(1) { width: 110px; }
.dist-table td:nth-child(4), .dist-table td:nth-child(5) { width: 100px; white-space: nowrap; }
.dist-table td:nth-child(6) { width: 110px; }
.dist-table td:last-child { width: 44px; }
.dist-table .form-control { min-height: 38px; padding: 6px 8px; }
.dist-table td:nth-child(4) .form-control, .dist-table td:nth-child(5) .form-control { width: 60px; display: inline-block; }
.avail { font-size: .8rem; color: var(--text-muted); margin-left: 2px; }
.avail.short { color: var(--red); font-weight: 700; }
@media (max-width: 760px) {
  .dist-table { min-width: 0; }
  .dist-table thead { display: none; }
  .dist-table, .dist-table tbody, .dist-table tr, .dist-table td { display: block; width: 100% !important; }
  .dist-table tr { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; padding: 6px; background: var(--surface); }
  .dist-table td { border: 0; padding: 4px 6px; }
  .dist-table td[data-label]::before { content: attr(data-label); display: block; font-size: .8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 2px; }
  .dist-table td:last-child { text-align: right; }
}
.qpick-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 10px; padding: 6px 10px; background: var(--surface); }
.qpick-list .check { align-items: flex-start; font-size: .92rem; min-height: 34px; padding: 4px 0; }
.qpick-list .check input { margin-top: 3px; flex-shrink: 0; }
.admin-note { font-size: .88rem; }

/* ---------- 12. Modal + toast ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 500; background: rgba(8, 14, 22, .6);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface); color: var(--text); border-radius: 16px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px; max-height: 90vh; overflow-y: auto;
  border: 1px solid var(--border); animation: popIn .18s ease;
}
.modal.modal-wide { max-width: 900px; }
.paper-preview { width: 100%; height: 62vh; min-height: 360px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.modal-header { padding: 20px 22px 0; }
.modal-header h2 { font-size: 1.25rem; margin: 0; }
.modal-icon { font-size: 2rem; margin-bottom: 6px; }
.modal-body { padding: 12px 22px 4px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 22px 20px; flex-wrap: wrap; }
.modal-actions .btn { min-width: 110px; }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: scale(.96); } }

.toast-root { position: fixed; bottom: 18px; right: 18px; z-index: 600; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 5px solid var(--blue); border-radius: 10px; padding: 12px 16px; box-shadow: var(--shadow-lg); font-size: .94rem; animation: popIn .18s ease; }
.toast.success { border-left-color: var(--green); }
.toast.error { border-left-color: var(--red); }
.toast.warning { border-left-color: var(--amber); }

/* ---------- 13. Footer ---------- */
.site-footer {
  position: relative; margin-top: 56px; color: var(--footer-text);
  background:
    radial-gradient(900px 260px at 50% 0, rgba(16, 185, 129, .16), transparent 70%),
    linear-gradient(180deg, #0f2236 0%, var(--footer-bg) 60%, #08121d 100%);
}
/* Coloured strip on top (green → teal → blue, like the login hero) */
.site-footer::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--hero-grad); }

/* Logo, name and tagline in the centre; the cards and © line below are aligned to the left */
.footer-brand { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding-top: 44px; padding-bottom: 10px; max-width: 980px; }
.footer-logo { width: 52px; height: 52px; filter: drop-shadow(0 4px 14px rgba(16, 185, 129, .35)); }
.footer-name { margin: 6px 0 0; color: #fff; font-size: 1.25rem; font-weight: 800; letter-spacing: .01em; }
.footer-tagline { margin: 0; max-width: 560px; color: #9fb3c8; font-size: .95rem; }

.footer-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; padding-top: 26px; padding-bottom: 36px;
  max-width: 980px; text-align: left;
}
.footer-card {
  padding: 22px 18px; border-radius: 16px;
  background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08);
  transition: border-color .2s, background-color .2s, transform .2s;
}
.footer-card:hover { border-color: rgba(126, 226, 168, .35); background: rgba(255, 255, 255, .06); transform: translateY(-2px); }
.footer-title { position: relative; color: #fff; font-size: 1.05rem; margin: 0 0 18px; padding-bottom: 10px; }
.footer-title::after { content: ""; position: absolute; left: 0; bottom: 0; width: 36px; height: 3px; border-radius: 3px; background: var(--hero-grad); }
.footer-links, .footer-contact { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; justify-items: start; }
.footer-links a, .footer-contact a, .footer-admin { color: var(--footer-text); text-decoration: none; transition: color .15s; }
.footer-links a:hover, .footer-contact a:hover, .footer-admin:hover { color: #7ee2a8; }
.footer-links a::before { content: "›"; margin-right: 6px; color: #34d399; font-weight: 800; }
.footer-contact li { display: inline-flex; align-items: center; gap: 8px; }
.contact-icon { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: rgba(255, 255, 255, .08); font-size: .95rem; }
.contact-icon.contact-fb { background: #1877f2; color: #fff; }
.footer-bottom .container { max-width: 980px; }
.footer-bottom { border-top: 1px solid rgba(255, 255, 255, .08); padding: 16px 0; font-size: .88rem; text-align: left; color: #8ea3b8; background: rgba(0, 0, 0, .18); }
@media (prefers-reduced-motion: reduce) { .footer-card { transition: none; } .footer-card:hover { transform: none; } }

/* ---------- 14. Responsive ---------- */
@media (max-width: 1100px) {
  .hamburger { display: inline-flex; }
  .nav-actions { margin-left: auto; }
  .main-nav {
    position: fixed; top: var(--header-h); left: 0; right: 0; bottom: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    overflow-y: auto; padding: 12px 16px 32px;
    display: none; margin: 0;
  }
  .main-nav.open { display: block; animation: fadeIn .15s ease; }
  .nav-list { flex-direction: column; align-items: stretch; gap: 2px; }
  .nav-link { width: 100%; justify-content: space-between; padding: 12px 14px; font-size: 1rem; min-height: 48px; }
  .dropdown-menu {
    position: static; box-shadow: none; border: 0; background: var(--surface-2);
    display: none; opacity: 1; visibility: visible; transform: none; margin: 2px 0 6px; min-width: 0;
  }
  .dropdown.open .dropdown-menu { display: block; }
  .dropdown:focus-within:not(.open) .dropdown-menu { display: none; }
  .dropdown-menu a { padding: 12px 14px; }
  .nav-divider { width: 100%; height: 1px; margin: 8px 0; }
  .nav-icon-link { justify-content: flex-start; gap: 10px; }
  .nav-icon-label { display: inline; }
  body.menu-open { overflow: hidden; }
}

@media (max-width: 900px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .notes-layout, .admin-layout { grid-template-columns: 1fr; }
  .notes-toc, .admin-tabs { position: static; }
  .admin-tabs { flex-direction: row; overflow-x: auto; }
  .admin-tab { white-space: nowrap; }
  .login-grid { grid-template-columns: 1fr; gap: 28px; }
  .login-card { justify-self: stretch; max-width: none; }
}

@media (max-width: 640px) {
  :root { --header-h: 60px; }
  body { font-size: 15.5px; }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .section { padding: 28px 0; }
  .brand-text small { display: none; }
  .user-chip { max-width: 110px; padding: 6px 10px; }
  .login-page { padding: 32px 0 40px; align-items: flex-start; }
  .login-features { display: none; }
  .login-card { padding: 22px 18px; }
  .card { padding: 18px; }
  .note-article { padding: 20px 16px; }
  .question-card { padding: 18px 16px; }
  .q-text { font-size: 1.07rem; }
  .exam-shell { padding-bottom: 110px; }
  .exam-bar { border-radius: 0 0 12px 12px; margin-left: -16px; margin-right: -16px; border-left: 0; border-right: 0; padding: 8px 14px; }
  .exam-title { font-size: .92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .exam-sub { display: none; }
  .timer { font-size: 1.02rem; padding: 5px 10px; }
  /* Mobile: Previous / Next / Submit stay reachable at the bottom of the screen */
  .exam-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60; margin: 0;
    background: var(--surface); border-top: 1px solid var(--border);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
  }
  .exam-nav .btn { max-width: none; padding: 10px 8px; }
  .result-top { grid-template-columns: 1fr; justify-items: center; text-align: left; }
  .result-card { padding: 20px 16px; }
  .footer-grid { grid-template-columns: 1fr; }
  .dist-row { grid-template-columns: 1fr 64px 64px 36px; gap: 6px; }
  .admin-item { flex-direction: column; }
  .modal-actions .btn { flex: 1; }
  .table th, .table td { padding: 9px 10px; }
}

/* Phones: the answers table becomes one small card per question */
@media (max-width: 640px) {
  .answer-table thead { display: none; }
  .answer-table, .answer-table tbody, .answer-table tr, .answer-table td { display: block; width: 100% !important; }
  .answer-table tr { border-bottom: 1px solid var(--border); padding: 8px 0; }
  .answer-table td { border: 0; padding: 4px 12px; }
  .answer-table td:first-child::before { content: "प्रश्न "; }
  .answer-table td:nth-child(2)::before { content: "तपाईको उत्तर: "; color: var(--text-muted); font-weight: 600; }
  .answer-table td:nth-child(3) { padding-top: 6px; }
  .all-results .table { font-size: .88rem; }
  .all-results .table th, .all-results .table td { padding: 8px 6px; white-space: normal; }
}

/* Very small phones: show only the 👤 icon so the header still fits */
@media (max-width: 400px) {
  .user-chip { padding: 6px 10px; }
  .user-chip-name { display: none; }
  .profile-info { grid-template-columns: 1fr; gap: 2px; }
  .profile-info dt { font-size: .82rem; margin-top: 6px; }
  .profile-info dt:first-child { margin-top: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

@media print {
  .site-header, .site-footer, .exam-nav, .no-print { display: none !important; }
}
