/* ============================================================
   FOREX MASTERY ACADEMY — Design System & Styles
   Pure CSS, no frameworks. Light + Dark themes via [data-theme].
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --bg: #f3f5fb;
  --surface: #ffffff;
  --surface-2: #eaeef7;
  --surface-3: #dfe5f2;
  --text: #0f172a;
  --muted: #5b6478;
  --border: #dde3f0;
  --primary: #4f6df5;
  --primary-soft: rgba(79, 109, 245, 0.12);
  --accent: #7c5cfc;
  --green: #10b981;
  --green-soft: rgba(16, 185, 129, 0.12);
  --red: #ef4444;
  --red-soft: rgba(239, 68, 68, 0.10);
  --gold: #f59e0b;
  --gold-soft: rgba(245, 158, 11, 0.13);
  --purple-soft: rgba(124, 92, 252, 0.12);
  --viz-orange: #dd5f1e; /* CVD-safe partner to --primary (blue) for 2-series indicator charts */
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 16px 48px rgba(15, 23, 42, 0.14);
  --radius: 14px;
  --radius-sm: 10px;
  --topbar-h: 62px;
  --sidebar-w: 292px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

html[data-theme="dark"] {
  --bg: #0a0f1f;
  --surface: #121936;
  --surface-2: #1a2244;
  --surface-3: #232d55;
  --text: #e9edfa;
  --muted: #97a3c4;
  --border: #26305a;
  --primary: #6d86ff;
  --primary-soft: rgba(109, 134, 255, 0.16);
  --green-soft: rgba(16, 185, 129, 0.16);
  --red-soft: rgba(239, 68, 68, 0.15);
  --gold-soft: rgba(245, 158, 11, 0.16);
  --purple-soft: rgba(124, 92, 252, 0.18);
  --viz-orange: #f0904f;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 15.5px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
p { margin: .6em 0; }
img, svg { max-width: 100%; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
::selection { background: var(--primary); color: #fff; }

/* ---------- App layout ---------- */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas: "topbar topbar" "sidebar main";
  height: 100vh;
}

/* ---------- Topbar ---------- */
#topbar {
  grid-area: topbar;
  min-width: 0; /* the search input's intrinsic width must not expand the grid column */
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 60;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; color: var(--text) !important; text-decoration: none !important; white-space: nowrap; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 10px;
  display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff; flex: none;
}
.brand-accent { color: var(--primary); margin-left: 5px; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; font-size: 16px;
  transition: background .15s;
  flex: none;
}
.icon-btn:hover { background: var(--surface-2); }
.top-search {
  flex: 1; min-width: 0; max-width: 460px; margin-left: auto;
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 12px; color: var(--muted);
}
.top-search input {
  flex: 1; border: 0; background: transparent; outline: none;
  padding: 9px 0; color: var(--text); min-width: 0;
}
.top-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.top-search + .top-actions { margin-left: 0; }
#progressRing { display: flex; align-items: center; gap: 8px; font-size: 12.5px; font-weight: 700; color: var(--muted); }

/* ---------- Sidebar ---------- */
#sidebar {
  grid-area: sidebar;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 16px 12px 40px;
  scrollbar-width: thin;
}
.nav-section { margin-bottom: 10px; }
.nav-label {
  font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: 12px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 10px; margin: 2px 0;
  color: var(--text); text-decoration: none !important;
  font-size: 14px; font-weight: 500;
  border: 1px solid transparent;
  transition: background .12s;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--primary-soft); border-color: var(--primary); color: var(--primary); font-weight: 700; }
.nav-item .nav-icon { width: 22px; text-align: center; flex: none; font-size: 15px; }
.nav-item .nav-title { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-item .nav-meta { font-size: 11px; color: var(--muted); flex: none; font-weight: 700; }
.nav-item.done .nav-meta { color: var(--green); }
.nav-item.soon { opacity: .55; }
.badge {
  display: inline-block; font-size: 10.5px; font-weight: 800; letter-spacing: .04em;
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted);
}
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.gold { background: var(--gold-soft); color: var(--gold); }
.badge.red { background: var(--red-soft); color: var(--red); }

/* ---------- Main view ---------- */
#view {
  grid-area: main;
  min-width: 0; /* prevent grid blowout: wide lesson content must scroll inside, not widen the column */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px clamp(18px, 4vw, 48px) 80px;
  scroll-behavior: smooth;
}
.view-inner { max-width: 900px; margin: 0 auto; animation: fadeUp .3s ease both; }
.view-inner.wide { max-width: 1100px; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Cards, buttons ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  margin: 18px 0;
}
.card h3 { display: flex; align-items: center; gap: 10px; font-size: 17px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: 11px; font-weight: 700; font-size: 14.5px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  transition: transform .12s, box-shadow .12s, background .12s;
  text-decoration: none !important;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: 0; color: #fff;
}
.btn.green { background: var(--green); border: 0; color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 7px 14px; font-size: 13px; border-radius: 9px; }

/* ---------- Progress bars ---------- */
.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .4s ease;
}
.progress.green > span { background: var(--green); }

/* ---------- Home / hero ---------- */
.hero {
  border-radius: 20px;
  padding: clamp(30px, 6vw, 60px);
  background:
    radial-gradient(1000px 400px at 85% -10%, var(--purple-soft), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, var(--primary-soft), transparent 55%),
    var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.hero h1 { font-size: clamp(28px, 4.6vw, 44px); font-weight: 900; letter-spacing: -0.02em; }
.hero h1 .grad {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p.lead { font-size: clamp(15px, 2vw, 18px); color: var(--muted); max-width: 640px; margin: 12px auto 26px; }
.hero-cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.stat-chips { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 30px; }
.stat-chip {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px; font-size: 13px; font-weight: 700; color: var(--muted);
}
.stat-chip b { color: var(--text); }

.feature-grid, .module-grid { display: grid; gap: 16px; margin: 20px 0; }
.feature-grid { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.module-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.feature {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.feature .f-icon { font-size: 26px; margin-bottom: 8px; }
.feature h4 { margin: 0 0 4px; font-size: 15px; }
.feature p { margin: 0; font-size: 13.5px; color: var(--muted); }

.module-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px;
  color: var(--text) !important; text-decoration: none !important;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.module-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.module-card .mc-top { display: flex; align-items: center; gap: 10px; }
.module-card .mc-icon {
  width: 40px; height: 40px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: var(--primary-soft);
}
.module-card h4 { margin: 0; font-size: 14.5px; }
.module-card .mc-num { font-size: 11px; font-weight: 800; color: var(--muted); letter-spacing: .08em; }
.module-card p { margin: 0; font-size: 13px; color: var(--muted); flex: 1; }
.module-card .mc-foot { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--muted); font-weight: 700; }
.module-card .progress { flex: 1; }

/* ---------- Dashboard ---------- */
.dash-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; }
.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; margin: 18px 0; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-card .sc-val { font-size: 26px; font-weight: 900; }
.stat-card .sc-label { font-size: 12.5px; color: var(--muted); font-weight: 700; }
.continue-card {
  display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
  background: linear-gradient(120deg, var(--primary-soft), var(--purple-soft)), var(--surface);
  border: 1px solid var(--primary); border-radius: var(--radius); padding: 20px 24px;
}
.continue-card .cc-body { flex: 1; min-width: 220px; }
.continue-card h3 { margin: 0 0 2px; }
.continue-card p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ---------- Module overview ---------- */
.lesson-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 18px; margin: 8px 0;
  color: var(--text) !important; text-decoration: none !important;
  transition: border-color .12s, transform .12s;
}
.lesson-row:hover { border-color: var(--primary); transform: translateX(3px); }
.lesson-row .lr-check {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: transparent; font-weight: 900;
}
.lesson-row.done .lr-check { background: var(--green); border-color: var(--green); color: #fff; }
.lesson-row .lr-body { flex: 1; min-width: 0; }
.lesson-row .lr-title { font-weight: 700; font-size: 14.5px; }
.lesson-row .lr-meta { font-size: 12px; color: var(--muted); }
.lesson-row.exam { border-style: dashed; }

/* ---------- Lesson page ---------- */
.crumbs { font-size: 12.5px; color: var(--muted); font-weight: 700; margin-bottom: 6px; }
.crumbs a { color: var(--muted); }
.lesson-head { display: flex; align-items: flex-start; gap: 14px; }
.lesson-head h1 { font-size: clamp(24px, 3.6vw, 34px); font-weight: 900; letter-spacing: -0.02em; flex: 1; }
.lesson-meta { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 20px; }
.bookmark-btn { font-size: 20px; background: none; border: none; color: var(--muted); padding: 6px; }
.bookmark-btn.on { color: var(--gold); }

.lesson-content h2 { font-size: 21px; margin-top: 34px; padding-top: 10px; }
.lesson-content h3 { font-size: 17px; margin-top: 26px; }
.lesson-content ul, .lesson-content ol { padding-left: 24px; }
.lesson-content li { margin: 5px 0; }
.lesson-content code {
  font-family: var(--mono); font-size: .88em; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px;
}
.lesson-content table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 14px; }
.lesson-content th, .lesson-content td { border: 1px solid var(--border); padding: 9px 12px; text-align: left; }
.lesson-content th { background: var(--surface-2); font-size: 12.5px; text-transform: uppercase; letter-spacing: .05em; }
.lesson-content tr:nth-child(even) td { background: var(--surface-2); }

/* Callouts */
.callout {
  display: flex; gap: 14px; align-items: flex-start;
  border: 1px solid var(--border); border-left-width: 4px;
  border-radius: 12px; padding: 15px 18px; margin: 18px 0;
  background: var(--surface);
}
.callout .co-icon { font-size: 22px; flex: none; margin-top: 2px; }
.callout .co-body { flex: 1; min-width: 0; }
.callout .co-body > strong { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .09em; margin-bottom: 3px; }
.callout .co-body p { margin: 4px 0; font-size: 14.5px; }
.callout.definition { border-left-color: var(--accent); background: var(--purple-soft); }
.callout.definition strong { color: var(--accent); }
.callout.analogy { border-left-color: var(--primary); background: var(--primary-soft); }
.callout.analogy strong { color: var(--primary); }
.callout.example { border-left-color: var(--green); background: var(--green-soft); }
.callout.example strong { color: var(--green); }
.callout.warning { border-left-color: var(--red); background: var(--red-soft); }
.callout.warning strong { color: var(--red); }
.callout.tip { border-left-color: var(--gold); background: var(--gold-soft); }
.callout.tip strong { color: var(--gold); }

/* Objectives / summary / mistakes / protips blocks */
.block { border-radius: var(--radius); border: 1px solid var(--border); padding: 20px 24px; margin: 20px 0; background: var(--surface); box-shadow: var(--shadow); }
.block > h3 { display: flex; align-items: center; gap: 10px; font-size: 16px; margin-bottom: 12px; }
.block ul { margin: 0; padding-left: 22px; }
.block li { margin: 6px 0; font-size: 14.5px; }
.block.objectives { border-top: 3px solid var(--primary); }
.block.mistakes { border-top: 3px solid var(--red); }
.block.protips { border-top: 3px solid var(--gold); }
.block.summary { border-top: 3px solid var(--green); }

/* Diagrams */
.diagram {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px; margin: 20px 0; overflow-x: auto;
}
.diagram .d-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: 14px; text-align: center; }
.diagram .d-caption { font-size: 12.5px; color: var(--muted); text-align: center; margin-top: 12px; }

/* CSS bar chart */
.barchart { display: grid; gap: 10px; }
.barchart .bar-row { display: grid; grid-template-columns: 170px 1fr 70px; gap: 10px; align-items: center; font-size: 13px; }
.barchart .bar-label { font-weight: 700; text-align: right; }
.barchart .bar-track { background: var(--surface-3); border-radius: 999px; height: 22px; overflow: hidden; }
.barchart .bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--accent)); min-width: 8px; }
.barchart .bar-fill.green { background: var(--green); }
.barchart .bar-fill.gold { background: var(--gold); }
.barchart .bar-val { font-weight: 800; font-family: var(--mono); font-size: 12.5px; }

/* CSS timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 26px; position: relative; }
.timeline::before { content: ""; position: absolute; left: 8px; top: 6px; bottom: 6px; width: 3px; border-radius: 3px; background: linear-gradient(var(--primary), var(--accent)); }
.timeline li { position: relative; padding: 4px 0 18px; }
.timeline li::before {
  content: ""; position: absolute; left: -25px; top: 9px; width: 13px; height: 13px;
  border-radius: 50%; background: var(--surface); border: 3px solid var(--primary);
}
.timeline .tl-year { font-weight: 900; color: var(--primary); font-family: var(--mono); font-size: 14px; }
.timeline .tl-title { font-weight: 800; }
.timeline p { margin: 2px 0 0; font-size: 14px; color: var(--muted); }

/* Flow diagram (boxes + arrows) */
.flow { display: flex; align-items: stretch; gap: 6px; flex-wrap: wrap; justify-content: center; }
.flow .fbox {
  background: var(--surface); border: 2px solid var(--primary); border-radius: 12px;
  padding: 12px 16px; text-align: center; min-width: 150px; flex: 1; max-width: 220px;
}
.flow .fbox .fb-icon { font-size: 24px; }
.flow .fbox .fb-title { font-weight: 800; font-size: 13.5px; }
.flow .fbox .fb-sub { font-size: 12px; color: var(--muted); }
.flow .farrow { display: flex; flex-direction: column; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); font-size: 12px; padding: 0 4px; }
.flow .farrow .fa-sym { font-size: 20px; color: var(--primary); line-height: 1; }

/* Pyramid */
.pyramid { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pyramid .pyr-level {
  border-radius: 10px; padding: 10px 16px; text-align: center; color: #fff;
  font-weight: 800; font-size: 13px; line-height: 1.4;
}
.pyramid .pyr-level small { display: block; font-weight: 600; font-size: 11.5px; opacity: .9; }
.pyramid .p1 { width: min(40%, 240px); background: linear-gradient(135deg, #f59e0b, #ef4444); }
.pyramid .p2 { width: min(60%, 360px); background: linear-gradient(135deg, #7c5cfc, #4f6df5); }
.pyramid .p3 { width: min(80%, 480px); background: linear-gradient(135deg, #4f6df5, #10b981); }
.pyramid .p4 { width: min(100%, 600px); background: linear-gradient(135deg, #10b981, #0ea5e9); }

/* Comparison / up-down cards */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 18px 0; }
.duo .duo-card { border-radius: 12px; padding: 16px 18px; border: 1px solid var(--border); }
.duo .duo-card h4 { margin: 0 0 6px; display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.duo .duo-card p, .duo .duo-card li { font-size: 13.5px; margin: 4px 0; }
.duo .up { background: var(--green-soft); border-color: var(--green); }
.duo .up h4 { color: var(--green); }
.duo .down { background: var(--red-soft); border-color: var(--red); }
.duo .down h4 { color: var(--red); }
@media (max-width: 640px) { .duo { grid-template-columns: 1fr; } }

/* ---------- Interactive widgets ---------- */
.widget {
  border: 2px solid var(--primary); border-radius: var(--radius);
  padding: 22px 24px; margin: 22px 0;
  background: linear-gradient(160deg, var(--primary-soft), transparent 55%), var(--surface);
  box-shadow: var(--shadow);
}
.widget .w-title { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 16px; margin-bottom: 4px; }
.widget .w-sub { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.widget .w-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin: 10px 0; }
.widget label { font-size: 12.5px; font-weight: 800; color: var(--muted); display: block; margin-bottom: 4px; }
.widget input[type="number"], .widget input[type="text"], .widget select {
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px;
  padding: 9px 12px; outline: none; min-width: 120px;
}
.widget input:focus, .widget select:focus { border-color: var(--primary); }
.widget input[type="range"] { width: 100%; accent-color: var(--primary); }
.w-readout {
  font-family: var(--mono); font-weight: 800; font-size: 15px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 9px; padding: 9px 14px;
}
.w-readout.big { font-size: 22px; }
.w-pos { color: var(--green); }
.w-neg { color: var(--red); }
.w-msg { font-size: 13.5px; margin-top: 10px; font-weight: 600; }

/* ---------- Exercises ---------- */
.exercise { border: 1px dashed var(--border); border-radius: 12px; padding: 16px 18px; margin: 12px 0; background: var(--surface); }
.exercise .ex-num { font-size: 11px; font-weight: 900; letter-spacing: .08em; color: var(--primary); text-transform: uppercase; }
.exercise .ex-task { font-size: 14.5px; margin: 4px 0 10px; }
.exercise details summary { cursor: pointer; font-weight: 800; font-size: 13px; color: var(--primary); user-select: none; }
.exercise details .ex-solution {
  margin-top: 10px; padding: 12px 16px; border-radius: 10px;
  background: var(--green-soft); border: 1px solid var(--green); font-size: 14px;
}

/* ---------- Quiz ---------- */
.quiz-wrap { margin: 10px 0; }
.quiz-q { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; margin: 12px 0; }
.quiz-question { font-weight: 700; font-size: 15px; margin-bottom: 12px; }
.quiz-question .qnum {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
  border-radius: 8px; font-size: 12px; font-weight: 900; padding: 2px 8px; margin-right: 8px;
}
.quiz-opt {
  display: block; width: 100%; text-align: left;
  background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 10px 14px; margin: 7px 0; font-size: 14px; color: var(--text);
  transition: border-color .12s, background .12s;
}
.quiz-opt:hover { border-color: var(--primary); }
.quiz-opt.selected { border-color: var(--primary); background: var(--primary-soft); font-weight: 700; }
.quiz-opt.correct { border-color: var(--green); background: var(--green-soft); font-weight: 700; }
.quiz-opt.wrong { border-color: var(--red); background: var(--red-soft); }
.quiz-opt:disabled { cursor: default; opacity: 1; }
.quiz-explain {
  margin-top: 10px; padding: 12px 14px; border-radius: 10px; font-size: 13.5px;
  background: var(--surface-2); border-left: 3px solid var(--primary);
}
.quiz-explain.hidden { display: none; }
.quiz-footer { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-top: 16px; }
.quiz-result { font-weight: 900; font-size: 16px; padding: 10px 18px; border-radius: 11px; }
.quiz-result.pass { background: var(--green-soft); color: var(--green); }
.quiz-result.fail { background: var(--red-soft); color: var(--red); }
.quiz-result.hidden { display: none; }

/* ---------- Notes ---------- */
.notes-box textarea {
  width: 100%; min-height: 110px; resize: vertical;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 14px; outline: none; font-size: 14px; line-height: 1.6;
}
.notes-box textarea:focus { border-color: var(--primary); }
.notes-saved { font-size: 12px; color: var(--green); font-weight: 700; min-height: 16px; }

/* ---------- Lesson footer nav ---------- */
.lesson-nav { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 34px; flex-wrap: wrap; }
.lesson-nav .btn { flex: 0 1 auto; }

/* ---------- Glossary ---------- */
.gloss-item { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; margin: 8px 0; }
.gloss-item .g-term { font-weight: 900; }
.gloss-item .g-def { font-size: 14px; color: var(--muted); margin-top: 2px; }
.gloss-letter { font-size: 14px; font-weight: 900; color: var(--primary); margin: 22px 0 4px; letter-spacing: .1em; }

/* ---------- Tools grid ---------- */
.tool-card { position: relative; }
.tool-card.locked { opacity: .6; }
.tool-card .mc-icon { background: var(--gold-soft); }

/* ---------- Search results ---------- */
.search-hit { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 18px; margin: 10px 0; color: var(--text) !important; text-decoration: none !important; }
.search-hit:hover { border-color: var(--primary); }
.search-hit .sh-title { font-weight: 800; }
.search-hit .sh-snippet { font-size: 13px; color: var(--muted); margin-top: 3px; }
.search-hit mark { background: var(--gold-soft); color: var(--gold); border-radius: 3px; padding: 0 2px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); padding: 11px 22px; border-radius: 12px;
  font-weight: 700; font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .25s, transform .25s; z-index: 200; box-shadow: var(--shadow-lg);
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Risk disclaimer ---------- */
.disclaimer {
  margin-top: 40px; padding: 16px 20px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-size: 12px; color: var(--muted); line-height: 1.6;
}

/* ---------- Empty state ---------- */
.empty {
  text-align: center; padding: 60px 20px; color: var(--muted);
}
.empty .e-icon { font-size: 44px; margin-bottom: 10px; }

/* ---------- Responsive ---------- */
#overlay { display: none; }
@media (max-width: 960px) {
  #app { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
  #sidebar {
    position: fixed; top: var(--topbar-h); left: 0; bottom: 0; width: min(84vw, 320px);
    transform: translateX(-105%); transition: transform .25s ease; z-index: 80;
    box-shadow: var(--shadow-lg);
  }
  body.nav-open #sidebar { transform: translateX(0); }
  #overlay {
    display: block; position: fixed; inset: var(--topbar-h) 0 0 0;
    background: rgba(5, 8, 20, 0.5); opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 70;
  }
  body.nav-open #overlay { opacity: 1; pointer-events: auto; }
  .top-search { max-width: none; }
  #progressRing .pr-label { display: none; }
  .brand-text { display: none; }
}
@media (min-width: 961px) { #menuBtn { display: none; } }
