/* ============================================================================
   StudyHub — Design System
   savemyexams-inspired: clean white, blue accent, calm grays, topic hierarchy.
   Palette + fonts locked in PROJECT-STATUS.md.
   ============================================================================ */

@import url("../fonts/fonts.css");

:root {
  color-scheme: light; /* native form controls & scrollbars follow the theme */

  /* Brand palette (locked) */
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #DBEAFE;
  --primary-tint: #EFF5FF;
  --correct: #059669;
  --correct-light: #D1FAE5;
  --wrong: #DC2626;
  --wrong-light: #FEE2E2;
  --warn: #D97706;

  /* Neutrals */
  --bg: #F8FAFC;
  --surface: #FFFFFF;
  --text: #0F172A;
  --text-soft: #475569;
  --text-mute: #64748B; /* AA contrast on white/near-white for small meta text */
  --border: #E2E8F0;
  --border-soft: #EEF2F6;

  /* Subject accent (overridden per subject via --subj) */
  --subj: var(--primary);

  /* Base colour that subject tints mix toward (white in light, dark in dark) */
  --mix: #ffffff;

  /* Type */
  --font-head: "Outfit", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --font-body: "Instrument Sans", "Segoe UI", system-ui, -apple-system, sans-serif;

  /* Shape & depth */
  --radius: 14px;
  --radius-sm: 10px;
  --radius-lg: 22px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.04);
  --shadow: 0 4px 14px rgba(15,23,42,.06), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg: 0 18px 40px rgba(15,23,42,.10), 0 4px 12px rgba(15,23,42,.06);
  --ring: 0 0 0 3px rgba(37,99,235,.18);

  --maxw: 1140px;
  --header-h: 66px;
}

/* Outfit / Instrument Sans have no Vietnamese glyphs, so accented characters
   would fall back to Segoe UI mid-word. In Vietnamese the whole UI switches
   to Be Vietnam Pro (self-hosted in fonts/) for consistent letterforms.
   core.js sets <html lang> from the saved language on every page. */
html[lang="vi"] {
  --font-head: "Be Vietnam Pro", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --font-body: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-h) + 12px); }
body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, h5 { font-family: var(--font-head); font-weight: 700; line-height: 1.15; letter-spacing: -0.02em; margin: 0 0 .5em; color: var(--text); text-wrap: balance; }
h1 { font-size: clamp(2rem, 4.5vw, 3.2rem); font-weight: 800; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 1em; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }
img { max-width: 100%; }
.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.muted { color: var(--text-soft); }
.center { text-align: center; }
::selection { background: var(--primary-light); }

/* ---- Keyboard focus ----------------------------------------------------
   Visible ring for keyboard users only (:focus-visible), never on mouse
   clicks. :where() keeps specificity at zero so component styles still win. */
:where(a, button, select, textarea, input, [tabindex]):focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
#app:focus { outline: none; } /* skip-link target, not an interactive control */

/* Skip link — hidden above the viewport until it receives keyboard focus */
.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: 100;
  background: var(--primary); color: #fff;
  font-family: var(--font-head); font-weight: 600; font-size: .9rem;
  padding: .6em 1.1em; border-radius: 999px; box-shadow: var(--shadow-lg);
  transform: translateY(calc(-100% - 24px));
}
.skip-link:focus-visible { transform: none; color: #fff; }

/* ---- Buttons ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: .5em;
  font-family: var(--font-head); font-weight: 600; font-size: .98rem;
  padding: .72em 1.3em; border-radius: 999px; border: 1.5px solid transparent;
  cursor: pointer; transition: transform .08s ease, box-shadow .15s ease, background .15s ease;
  background: var(--surface); color: var(--text); line-height: 1;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 6px 16px rgba(37,99,235,.28); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text); }
.btn-ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn-subtle { background: var(--primary-tint); color: var(--primary-dark); }
.btn-subtle:hover { background: var(--primary-light); }
.btn-lg { padding: .9em 1.7em; font-size: 1.05rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---- Header ----------------------------------------------------------- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.86); backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 24px; height: var(--header-h); }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--text); font-family: var(--font-head); }
.brand-mark { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #4F86FF); color: #fff; box-shadow: 0 4px 10px rgba(37,99,235,.35); }
.brand-name { font-weight: 800; font-size: 1.32rem; letter-spacing: -.03em; }
.brand-accent { color: var(--primary); }
.site-nav { display: flex; gap: 4px; margin-left: 8px; }
.nav-link { padding: .5em .85em; border-radius: 9px; color: var(--text-soft); font-weight: 500; font-size: .96rem; }
.nav-link:hover { background: var(--primary-tint); color: var(--primary-dark); }
.nav-link.is-active { color: var(--primary-dark); background: var(--primary-tint); font-weight: 600; }
.header-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.lang-toggle {
  display: inline-flex; align-items: center; gap: 5px; font-family: var(--font-head); font-weight: 600;
  font-size: .82rem; padding: .42em .7em; border-radius: 999px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text-mute); cursor: pointer;
}
.lang-toggle .is-on { color: var(--primary); }
.lang-sep { color: var(--border); }
.menu-toggle { display: none; background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text); }

/* ---- Footer ----------------------------------------------------------- */
.site-footer { margin-top: 72px; background: #0B1220; color: #CBD5E1; }
.footer-inner { display: grid; grid-template-columns: 1.6fr 1fr; gap: 40px; padding: 54px 22px 36px; }
.site-footer .brand-name { color: #fff; }
.footer-tagline { font-family: var(--font-head); font-weight: 600; color: #fff; margin: 14px 0 8px; font-size: 1.05rem; }
.footer-about { color: #94A3B8; max-width: 46ch; font-size: .94rem; }
.footer-links { display: flex; flex-direction: column; gap: 9px; }
.footer-links h4 { color: #fff; margin-bottom: 6px; }
.footer-links a { color: #CBD5E1; font-size: .94rem; }
.footer-links a:hover { color: #fff; }
.footer-bar { border-top: 1px solid rgba(255,255,255,.08); }
.footer-bar .container { display: flex; justify-content: space-between; align-items: center; padding-top: 16px; padding-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.badge-free { font-size: .85rem; color: #6EE7B7; font-weight: 600; }
.footer-credit { font-size: .85rem; color: #64748B; }

/* ---- Hero ------------------------------------------------------------- */
.hero { position: relative; overflow: hidden; padding: 76px 0 60px;
  background:
    radial-gradient(900px 400px at 85% -10%, var(--primary-light), transparent 60%),
    radial-gradient(700px 380px at 10% 0%, #E0F2FE, transparent 55%); }
.hero-inner { max-width: 760px; }
.eyebrow { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-head); font-weight: 600;
  font-size: .85rem; color: var(--primary-dark); background: var(--surface); border: 1px solid var(--primary-light);
  padding: .45em .9em; border-radius: 999px; box-shadow: var(--shadow-sm); margin-bottom: 20px; }
.eyebrow::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--correct); }
.hero h1 { margin-bottom: .15em; }
.hero h1 .accent { color: var(--primary); }
.hero-sub { font-size: 1.2rem; color: var(--text-soft); max-width: 58ch; margin: 18px 0 30px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }

/* ---- Sections --------------------------------------------------------- */
.section { padding: 56px 0; }
.section-head { max-width: 640px; margin-bottom: 30px; }
.section-head.center { margin-left: auto; margin-right: auto; }
.section-head p { color: var(--text-soft); font-size: 1.08rem; margin: 0; }

/* ---- Subject grid / cards --------------------------------------------- */
.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.subject-card {
  position: relative; display: block; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .18s ease, border-color .18s ease; overflow: hidden;
}
.subject-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 5px; background: var(--subj); }
.subject-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: transparent; }
.subject-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font-size: 1.7rem;
  background: color-mix(in srgb, var(--subj) 12%, var(--mix)); color: var(--subj); margin-bottom: 16px; }
.subject-card h3 { color: var(--text); margin-bottom: 4px; }
.subject-code { font-family: var(--font-head); font-size: .8rem; font-weight: 600; color: var(--subj);
  background: color-mix(in srgb, var(--subj) 10%, var(--mix)); padding: .2em .6em; border-radius: 6px; }
.subject-board { font-size: .82rem; color: var(--text-mute); display: block; margin: 8px 0 10px; }
.subject-blurb { color: var(--text-soft); font-size: .94rem; margin: 0 0 16px; }
.subject-meta { display: flex; gap: 16px; font-size: .85rem; color: var(--text-mute); border-top: 1px solid var(--border-soft); padding-top: 14px; }
.subject-meta b { color: var(--text); font-family: var(--font-head); }
.subject-progress { height: 6px; background: var(--border-soft); border-radius: 99px; margin-top: 12px; overflow: hidden; }
.subject-progress > span { display: block; height: 100%; background: var(--subj); border-radius: 99px; transition: width .4s ease; }

/* ---- Feature cards ---------------------------------------------------- */
.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 18px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow-sm); }
.feature .ico { width: 44px; height: 44px; border-radius: 12px; background: var(--primary-tint); color: var(--primary);
  display: grid; place-items: center; font-size: 1.4rem; margin-bottom: 14px; }
.feature h3 { font-size: 1.08rem; }
.feature p { color: var(--text-soft); font-size: .94rem; margin: 0; }

/* ---- Breadcrumb ------------------------------------------------------- */
.crumbs { display: flex; align-items: center; gap: 8px; font-size: .9rem; color: var(--text-mute); margin: 22px 0 6px; flex-wrap: wrap; }
.crumbs a { color: var(--text-soft); }
.crumbs a:hover { color: var(--primary); }
.crumbs .sep { color: var(--border); }

/* ---- Subject header (subject page) ------------------------------------ */
.subject-hero { padding: 30px 0 8px; }
.subject-hero .badges { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.pill { font-family: var(--font-head); font-weight: 600; font-size: .8rem; padding: .3em .75em; border-radius: 999px;
  background: color-mix(in srgb, var(--subj) 12%, var(--mix)); color: var(--subj); }
.pill-free { background: var(--correct-light); color: var(--correct); }
.subject-hero h1 { font-size: clamp(1.9rem, 4vw, 2.7rem); }
.subject-stats { display: flex; gap: 26px; margin-top: 14px; flex-wrap: wrap; }
.stat b { font-family: var(--font-head); font-size: 1.5rem; display: block; color: var(--text); }
.stat span { font-size: .85rem; color: var(--text-mute); }

/* ---- Topic list ------------------------------------------------------- */
.topic-list { display: grid; gap: 12px; margin-top: 8px; }
.topic-row {
  display: flex; align-items: center; gap: 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow-sm);
  transition: transform .1s ease, box-shadow .16s ease, border-color .16s; color: var(--text);
}
.topic-row:hover { transform: translateX(3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--subj) 40%, var(--border)); }
.topic-num { flex: none; width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; background: color-mix(in srgb, var(--subj) 12%, var(--mix)); color: var(--subj); }
.topic-row.done .topic-num { background: var(--correct-light); color: var(--correct); }
.topic-info { flex: 1; min-width: 0; }
.topic-info h3 { margin: 0 0 2px; font-size: 1.06rem; }
.topic-info p { margin: 0; font-size: .9rem; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topic-tags { display: flex; gap: 8px; flex: none; font-size: .8rem; color: var(--text-mute); align-items: center; }
.topic-tags .chip { background: var(--bg); border: 1px solid var(--border); border-radius: 7px; padding: .2em .55em; }
.topic-row .chev { color: var(--text-mute); flex: none; }
.done-tick { color: var(--correct); font-weight: 700; }

/* ---- Topic page (notes + questions) ----------------------------------- */
.layout-topic { display: grid; grid-template-columns: 1fr; gap: 30px; }
.notes { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 30px 34px; box-shadow: var(--shadow-sm); }
.notes h2 { display: flex; align-items: center; gap: 10px; }
.note-block { margin-bottom: 26px; }
.note-block h3 { color: var(--primary-dark); border-left: 3px solid var(--subj); padding-left: 12px; margin-bottom: 10px; }
.note-block .body { color: var(--text); }
.note-block .body p { margin: 0 0 .8em; }
.note-block .body ul, .note-block .body ol { margin: 0 0 1em; padding-left: 1.3em; }
.note-block .body li { margin-bottom: .4em; }
.note-block .body code, code.inline { background: #F1F5F9; border: 1px solid var(--border); border-radius: 6px; padding: .1em .4em; font-size: .9em; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; color: #0F766E; }
.note-block .body pre { background: #0B1220; color: #E2E8F0; padding: 16px 18px; border-radius: var(--radius-sm); overflow-x: auto; font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .88rem; line-height: 1.55; }
.note-block .body pre code { background: none; border: none; color: inherit; padding: 0; }
.keyterm { background: var(--primary-tint); border: 1px solid var(--primary-light); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0 0 14px; }
.keyterm b { color: var(--primary-dark); font-family: var(--font-head); }
.note-block table.def { width: 100%; border-collapse: collapse; margin: 0 0 1em; }
.note-block table.def td, .note-block table.def th { border: 1px solid var(--border); padding: 8px 12px; text-align: left; font-size: .92rem; }
.note-block table.def th { background: var(--bg); font-family: var(--font-head); }

/* Questions */
.q-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 16px; flex-wrap: wrap; }
.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow-sm); margin-bottom: 16px; }
.q-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.q-num { font-family: var(--font-head); font-weight: 700; color: var(--subj); }
.q-marks { margin-left: auto; font-family: var(--font-head); font-weight: 600; font-size: .85rem; color: var(--text-soft); background: var(--bg); border: 1px solid var(--border); padding: .25em .7em; border-radius: 999px; }
.diff { font-size: .76rem; font-weight: 600; font-family: var(--font-head); padding: .2em .6em; border-radius: 6px; }
.diff.easy { background: var(--correct-light); color: var(--correct); }
.diff.medium { background: #FEF3C7; color: var(--warn); }
.diff.hard { background: var(--wrong-light); color: var(--wrong); }
.q-prompt { margin-bottom: 10px; }
.q-prompt p { margin: 0 0 .5em; }
.q-part { margin: 8px 0 8px; }
.q-part .lbl { font-weight: 700; font-family: var(--font-head); margin-right: 6px; }
.q-part .pmarks { color: var(--text-mute); font-size: .85rem; margin-left: 6px; }
.q-answer-input { width: 100%; min-height: 70px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; font-family: var(--font-body); font-size: .95rem; resize: vertical; margin: 6px 0 12px; background: var(--bg); }
.q-answer-input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); background: #fff; }
.ms { border-top: 1px dashed var(--border); margin-top: 12px; padding-top: 14px; display: none; }
.ms.is-open { display: block; }
.ms-head { font-family: var(--font-head); font-weight: 700; color: var(--correct); display: flex; align-items: center; gap: 7px; margin-bottom: 8px; }
.ms ul { margin: 0; padding-left: 1.2em; }
.ms li { margin-bottom: .35em; color: var(--text); }
.ms .model { background: var(--correct-light); border-radius: var(--radius-sm); padding: 10px 14px; margin-top: 8px; color: #064E3B; }

/* ---- Past papers ------------------------------------------------------ */
.paper-card { border-left: 4px solid var(--subj); }
.paper-ref { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }
.paper-code { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-weight: 700; font-size: .82rem;
  color: var(--subj); background: color-mix(in srgb, var(--subj) 12%, var(--mix)); padding: .25em .6em; border-radius: 7px; letter-spacing: .02em; }
.paper-sess { font-family: var(--font-head); font-weight: 600; font-size: .82rem; color: var(--text-soft); }
.paper-qno { font-family: var(--font-head); font-weight: 600; font-size: .82rem; color: var(--text-mute); }
.paper-ref .q-marks { margin-left: auto; }
.topic-chip { display: inline-block; margin-top: 8px; font-size: .8rem; font-weight: 600; font-family: var(--font-head);
  color: var(--subj); background: color-mix(in srgb, var(--subj) 9%, var(--mix)); border: 1px solid color-mix(in srgb, var(--subj) 22%, transparent);
  padding: .22em .7em; border-radius: 999px; }
.topic-chip:hover { background: color-mix(in srgb, var(--subj) 18%, var(--mix)); color: var(--subj); }
.paper-actions { display: flex; gap: 16px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border-soft); }
.mini-link { font-size: .85rem; font-weight: 600; color: var(--text-soft); }
.mini-link:hover { color: var(--primary); }

/* ---- MCQ practice ----------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 26px 28px; box-shadow: var(--shadow); }
.field { margin-bottom: 18px; }
.field > label { display: block; font-family: var(--font-head); font-weight: 600; margin-bottom: 8px; font-size: .95rem; }
.select, .input { width: 100%; padding: .7em .9em; border: 1.5px solid var(--border); border-radius: var(--radius-sm); font-family: var(--font-body); font-size: 1rem; background: var(--surface); color: var(--text); }
.select:focus, .input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-toggle { font-size: .88rem; padding: .45em .85em; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text-soft); cursor: pointer; font-family: var(--font-body); transition: all .12s; }
.chip-toggle:hover { border-color: var(--primary); color: var(--primary); }
.chip-toggle.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.seg { display: inline-flex; border: 1.5px solid var(--border); border-radius: 999px; overflow: hidden; }
.seg button { border: none; background: var(--surface); padding: .5em 1em; cursor: pointer; font-family: var(--font-body); color: var(--text-soft); }
.seg button.is-on { background: var(--primary); color: #fff; }

/* Per-question countdown (timed practice). The bar is driven by JS ticks, so
   it still works when prefers-reduced-motion disables the width transition;
   the number means it never relies on colour alone. */
.q-timer { display: flex; align-items: center; gap: 12px; margin: 0 0 16px; }
.q-timer-num { font-family: var(--font-head); font-weight: 700; font-variant-numeric: tabular-nums;
  min-width: 2.2ch; text-align: right; color: var(--text-soft); }
.q-timer-bar { flex: 1; height: 8px; background: var(--border-soft); border-radius: 99px; overflow: hidden; }
.q-timer-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width 1s linear; }
.q-timer.is-low .q-timer-num { color: var(--wrong); }
.q-timer.is-low .q-timer-bar > span { background: var(--wrong); }

.mcq-stage { max-width: 720px; margin: 0 auto; }
.mcq-progress { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.mcq-bar { flex: 1; height: 8px; background: var(--border-soft); border-radius: 99px; overflow: hidden; }
.mcq-bar > span { display: block; height: 100%; background: var(--primary); border-radius: 99px; transition: width .3s; }
.mcq-count { font-family: var(--font-head); font-weight: 600; font-size: .9rem; color: var(--text-soft); }
.mcq-q { font-size: 1.22rem; font-family: var(--font-head); font-weight: 600; margin: 6px 0 20px; }
.mcq-q .src { display: block; font-size: .8rem; color: var(--text-mute); font-weight: 500; margin-top: 6px; }
.options { display: grid; gap: 10px; }
.option { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1.5px solid var(--border); border-radius: var(--radius); cursor: pointer; transition: all .12s; background: var(--surface); user-select: none; }
.option:hover { border-color: var(--primary); background: var(--primary-tint); }
.option .key { flex: none; width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; font-family: var(--font-head); font-weight: 700; background: var(--bg); border: 1px solid var(--border); font-size: .9rem; }
.option.is-selected { border-color: var(--primary); background: var(--primary-tint); }
.option.correct { border-color: var(--correct); background: var(--correct-light); }
.option.correct .key { background: var(--correct); color: #fff; border-color: var(--correct); }
.option.wrong { border-color: var(--wrong); background: var(--wrong-light); }
.option.wrong .key { background: var(--wrong); color: #fff; border-color: var(--wrong); }
.option.disabled { pointer-events: none; }
.verdict { margin-top: 18px; padding: 14px 16px; border-radius: var(--radius); display: none; }
.verdict.is-open { display: block; }
.verdict.good { background: var(--correct-light); color: #064E3B; }
.verdict.bad { background: var(--wrong-light); color: #7F1D1D; }
.verdict b { font-family: var(--font-head); }
.verdict .exp { margin-top: 6px; font-size: .94rem; }
.mcq-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

.result-card { text-align: center; max-width: 520px; margin: 0 auto; }
.result-score { font-family: var(--font-head); font-weight: 800; font-size: 3.4rem; color: var(--primary); line-height: 1; }
.result-ring { width: 150px; height: 150px; margin: 10px auto 18px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--primary) var(--p,0%), var(--border-soft) 0); }
.result-ring .inner { width: 120px; height: 120px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; }

/* ---- Worksheet -------------------------------------------------------- */
.worksheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px 40px; box-shadow: var(--shadow); }
.ws-head { display: flex; justify-content: space-between; align-items: flex-end; border-bottom: 2px solid var(--text); padding-bottom: 14px; margin-bottom: 22px; }
.ws-head h2 { margin: 0; }
.ws-head .meta { text-align: right; font-size: .85rem; color: var(--text-soft); }
.ws-q { margin-bottom: 22px; page-break-inside: avoid; }
.ws-q .top { display: flex; gap: 10px; align-items: baseline; }
.ws-q .n { font-family: var(--font-head); font-weight: 700; }
.ws-q .m { margin-left: auto; color: var(--text-soft); font-size: .85rem; white-space: nowrap; }
.ws-lines { border-bottom: 1px solid var(--border); height: 26px; }
.ws-ms { margin-top: 8px; padding: 10px 14px; background: var(--correct-light); border-radius: var(--radius-sm); font-size: .9rem; color: #064E3B; }
.ws-ms ul { margin: 4px 0 0; padding-left: 1.2em; }

/* ---- Assistant -------------------------------------------------------- */
.assistant-wrap { max-width: 820px; margin: 0 auto; }
.chat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; height: min(68vh, 620px); }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.chat-avatar { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), #4F86FF); color: #fff; display: grid; place-items: center; font-size: 1.3rem; }
.chat-head .who { font-family: var(--font-head); font-weight: 700; }
.chat-mode { margin-left: auto; font-size: .78rem; font-weight: 600; padding: .3em .7em; border-radius: 999px; }
.chat-mode.scripted { background: #FEF3C7; color: var(--warn); }
.chat-mode.live { background: var(--correct-light); color: var(--correct); }
.chat-body { flex: 1; overflow-y: auto; padding: 22px 20px; display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: 80%; padding: 12px 16px; border-radius: 16px; line-height: 1.55; font-size: .96rem; }
.msg.bot { background: var(--bg); border: 1px solid var(--border); border-bottom-left-radius: 5px; align-self: flex-start; }
.msg.user { background: var(--primary); color: #fff; border-bottom-right-radius: 5px; align-self: flex-end; }
.msg.bot code { background: #F1F5F9; padding: .1em .35em; border-radius: 5px; font-family: ui-monospace, Consolas, monospace; font-size: .9em; }
.msg.bot pre { background: #0B1220; color: #E2E8F0; padding: 12px; border-radius: 10px; overflow-x: auto; font-size: .85rem; }
.msg.typing { color: var(--text-mute); font-style: italic; }
.suggests { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.suggest { font-size: .85rem; padding: .4em .8em; border-radius: 999px; border: 1px solid var(--primary-light); background: var(--primary-tint); color: var(--primary-dark); cursor: pointer; }
.suggest:hover { background: var(--primary-light); }
.chat-input { display: flex; gap: 10px; padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-input input { flex: 1; border: 1.5px solid var(--border); border-radius: 999px; padding: .7em 1.1em; font-family: var(--font-body); font-size: 1rem; }
.chat-input input:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }

/* ---- Study path (plan page) ------------------------------------------- */
.check-toolbar { display: flex; align-items: center; gap: 8px; margin: 2px 0 10px; flex-wrap: wrap; }
.check-count { margin-left: auto; font-family: var(--font-head); font-weight: 600; font-size: .82rem;
  color: var(--subj); background: color-mix(in srgb, var(--subj) 12%, var(--mix)); padding: .25em .75em; border-radius: 999px; }
.btn-mini { font-size: .8rem; padding: .38em .85em; }
.check-list { display: grid; gap: 8px; max-height: 340px; overflow-y: auto; padding: 2px; }
.check-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font-size: .92rem;
  transition: border-color .12s ease, background .12s ease; }
.check-row:hover { border-color: var(--primary); }
.check-row input { width: 18px; height: 18px; accent-color: var(--subj, var(--primary)); flex: none; cursor: pointer; margin: 0; }
.check-row .num { font-family: var(--font-head); font-weight: 700; font-size: .78rem; color: var(--subj);
  background: color-mix(in srgb, var(--subj) 12%, var(--mix)); border-radius: 7px; padding: .18em .55em; flex: none; }
.check-row.is-known { background: var(--correct-light); border-color: color-mix(in srgb, var(--correct) 45%, var(--border)); }
.plan-status { font-size: .85rem; margin: 8px 0 0; }
.plan-status.ok { color: var(--correct); }
.plan-status.warn { color: var(--warn); }
.path-summary { border-left: 4px solid var(--subj); }
.path-summary .subject-progress { margin-top: 14px; }
.path-steps { display: grid; gap: 12px; margin-top: 16px; }
.path-step { display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); }
.path-step .idx { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: .95rem; background: var(--subj); color: #fff; }
.path-step .body { flex: 1; min-width: 0; }
.path-step h3 { font-size: 1.05rem; margin-bottom: 2px; }
.path-step .why { color: var(--text-soft); font-size: .9rem; margin: 0 0 12px; }
.path-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }

/* ---- Misc ------------------------------------------------------------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--text-mute); }
.empty-state .ico { font-size: 2.6rem; margin-bottom: 10px; }
.grid-2 { display: grid; grid-template-columns: 360px 1fr; gap: 30px; align-items: start; }
.sticky { position: sticky; top: calc(var(--header-h) + 18px); }
.tabbar { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tabbar button { border: none; background: none; padding: .8em 1.1em; font-family: var(--font-head); font-weight: 600; color: var(--text-mute); cursor: pointer; border-bottom: 2.5px solid transparent; margin-bottom: -1px; }
.tabbar button.is-on { color: var(--primary-dark); border-bottom-color: var(--primary); }
.fade-in { animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Responsive ------------------------------------------------------- */
@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .sticky { position: static; }
  .footer-inner { grid-template-columns: 1fr; gap: 26px; }
}
/* Six nav links need ~1000px before they fit next to the brand + actions,
   so the hamburger kicks in well above phone width. */
@media (max-width: 1000px) {
  .site-nav { position: absolute; top: var(--header-h); left: 0; right: 0; background: var(--surface); flex-direction: column;
    padding: 10px 16px; border-bottom: 1px solid var(--border); box-shadow: var(--shadow); display: none; }
  .site-nav.is-open { display: flex; }
  .menu-toggle { display: block; min-width: 44px; min-height: 40px; }
  .theme-toggle, .lang-toggle { min-height: 40px; }
  .nav-link { padding: .7em .6em; }
}
@media (max-width: 720px) {
  .topic-tags { display: none; }
  .notes { padding: 22px 20px; }
  .worksheet { padding: 22px 18px; }
  .msg { max-width: 90%; }
}

/* ============================================================================
   DARK MODE  (savemyexams-style)  — toggled via html[data-theme="dark"]
   Most of the work is done by overriding the CSS variables; a few components
   need a touch more.
   ============================================================================ */
html[data-theme="dark"] {
  color-scheme: dark;

  --primary: #3B82F6;
  --primary-dark: #60A5FA;
  --primary-light: rgba(59,130,246,.30);
  --primary-tint: rgba(59,130,246,.14);
  --correct: #34D399;
  --correct-light: rgba(16,185,129,.18);
  --wrong: #F87171;
  --wrong-light: rgba(220,38,38,.20);
  --warn: #FBBF24;

  --bg: #0B1220;
  --surface: #151E30;
  --text: #E6EDF6;
  --text-soft: #A7B4C7;
  --text-mute: #8494AB; /* lighter than before — readable small text on dark */
  --border: #25324A;
  --border-soft: #1B2536;

  --mix: #0B1220;

  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow: 0 6px 18px rgba(0,0,0,.45);
  --shadow-lg: 0 22px 48px rgba(0,0,0,.55);
  --ring: 0 0 0 3px rgba(59,130,246,.35);
}
html[data-theme="dark"] body { background: var(--bg); }
html[data-theme="dark"] .site-header {
  background: rgba(11,18,32,.82); border-bottom-color: var(--border);
}
html[data-theme="dark"] .hero {
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(59,130,246,.22), transparent 60%),
    radial-gradient(700px 380px at 10% 0%, rgba(13,148,136,.16), transparent 55%);
}
html[data-theme="dark"] .eyebrow { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .lang-toggle,
html[data-theme="dark"] .theme-toggle { background: var(--surface); border-color: var(--border); }
html[data-theme="dark"] .select,
html[data-theme="dark"] .input,
html[data-theme="dark"] .q-answer-input,
html[data-theme="dark"] .chat-input input { background: #0E1626; color: var(--text); }
html[data-theme="dark"] .chip-toggle,
html[data-theme="dark"] .btn-ghost,
html[data-theme="dark"] .seg button { background: var(--surface); }
html[data-theme="dark"] .note-block .body code,
html[data-theme="dark"] .msg.bot code,
html[data-theme="dark"] code.inline { background: #0E1626; border-color: var(--border); color: #5EEAD4; }
html[data-theme="dark"] .note-block table.def th { background: #0E1626; }
html[data-theme="dark"] .ms .model,
html[data-theme="dark"] .ws-ms { color: #D1FAE5; }
html[data-theme="dark"] .verdict.good { color: #D1FAE5; }
html[data-theme="dark"] .verdict.bad { color: #FECACA; }
html[data-theme="dark"] .option .key { background: #0E1626; }
/* Amber chips hardcode a light-yellow tint; swap it for a dark one so the
   amber text keeps its contrast in dark mode. */
html[data-theme="dark"] .diff.medium,
html[data-theme="dark"] .chat-mode.scripted { background: rgba(251,191,36,.15); }
/* footer is already dark — keep it consistent */
html[data-theme="dark"] .site-footer { background: #070C16; border-top: 1px solid var(--border); }

/* Smooth theme transition on the big surfaces */
body, .site-header, .panel, .q-card, .topic-row, .subject-card, .notes, .chat, .feature,
.select, .input, .worksheet, .chip-toggle, .option, .btn-ghost {
  transition: background-color .22s ease, border-color .22s ease, color .22s ease;
}

.theme-toggle {
  display: inline-grid; place-items: center; width: 38px; height: 34px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer; font-size: 1rem; line-height: 1;
}
.theme-toggle:hover { border-color: var(--primary); }

/* ---- Reduced motion ----------------------------------------------------
   Users who ask the OS for less motion get instant state changes instead of
   animations, transitions and smooth scrolling. */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---- Print (worksheet) ------------------------------------------------ */
@media print {
  .site-header, .site-footer, .ws-controls, .no-print { display: none !important; }
  body { background: #fff; }
  .worksheet { box-shadow: none; border: none; padding: 0; }
  .ws-q { page-break-inside: avoid; }
}
