/* ============================================================
   NISM XVI · Commodity Derivatives — Study & Practice
   ============================================================ */

:root {
  --gold: #e0a82e;
  --gold-soft: rgba(224, 168, 46, 0.14);
  --bg: #080e19;
  --bg-2: #0c1424;
  --panel: #111c30;
  --panel-2: #16233a;
  --line: #22314c;
  --text: #e9eefb;
  --muted: #93a4c2;
  --muted-2: #6f819e;
  --green: #2ec98b;
  --green-soft: rgba(46, 201, 139, 0.13);
  --red: #f0555b;
  --red-soft: rgba(240, 85, 91, 0.13);
  --blue: #6ea8fe;
  --blue-soft: rgba(110, 168, 254, 0.13);
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
  --sans: "Segoe UI", Inter, "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --max: 1180px;
}

[data-theme="light"] {
  --bg: #f3f6fb;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f7f9fd;
  --line: #dbe3ef;
  --text: #101a2d;
  --muted: #55647e;
  --muted-2: #7a889f;
  --gold: #a9760a;
  --gold-soft: rgba(169, 118, 10, 0.11);
  --green: #0f8a5f;
  --green-soft: rgba(15, 138, 95, 0.1);
  --red: #c4343a;
  --red-soft: rgba(196, 52, 58, 0.09);
  --blue: #235fbe;
  --blue-soft: rgba(35, 95, 190, 0.09);
  --shadow: 0 12px 30px rgba(16, 26, 45, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15.5px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 420px at 12% -8%, rgba(224, 168, 46, 0.10), transparent 60%),
    radial-gradient(800px 400px at 92% 4%, rgba(110, 168, 254, 0.09), transparent 62%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; }

h1, h2, h3, h4 { line-height: 1.25; margin: 0; letter-spacing: -0.01em; }

::selection { background: var(--gold); color: #10131a; }

/* ---------- Shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  backdrop-filter: blur(14px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 12px 22px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.brand:hover { text-decoration: none; }

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--gold), #b6760c);
  color: #151002;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 20px;
  box-shadow: 0 6px 16px rgba(224, 168, 46, 0.28);
}

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text b { font-size: 14.5px; letter-spacing: 0.01em; }
.brand-text span { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; }

.nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav a {
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.nav a.active { color: var(--gold); background: var(--gold-soft); }

.icon-btn {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  font-size: 15px;
}
.icon-btn:hover { color: var(--text); border-color: var(--muted-2); }

main {
  position: relative;
  z-index: 1;
  max-width: var(--max);
  margin: 0 auto;
  padding: 30px 22px 90px;
}

/* ---------- Typography helpers ---------- */

.eyebrow {
  font-size: 11.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.muted { color: var(--muted); }
.small { font-size: 13px; }
.tiny { font-size: 12px; }
.center { text-align: center; }
.mono { font-family: "Cascadia Code", Consolas, "Courier New", monospace; }

/* ---------- Hero ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 32px;
  align-items: center;
  padding: 34px 0 12px;
}

.hero h1 {
  font-family: var(--serif);
  font-size: clamp(30px, 4.4vw, 48px);
  font-weight: 600;
  margin: 12px 0 14px;
  letter-spacing: -0.02em;
}
.hero h1 em { font-style: normal; color: var(--gold); }

.hero p.lead {
  color: var(--muted);
  font-size: 16px;
  max-width: 58ch;
  margin: 0 0 24px;
}

.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 11px 18px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn-primary { background: linear-gradient(145deg, var(--gold), #c08a16); color: #171102; box-shadow: 0 8px 22px rgba(224, 168, 46, 0.22); }
.btn-ghost { background: var(--panel); border-color: var(--line); color: var(--text); }
.btn-ghost:hover { border-color: var(--muted-2); }
.btn-green { background: var(--green); color: #04140d; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- Stat strip ---------- */

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 26px;
}
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
}
.stat b { display: block; font-size: 22px; font-family: var(--serif); letter-spacing: -0.01em; }
.stat span { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.07em; }

/* ---------- Exam card ---------- */

.exam-card {
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}
.exam-card h3 { font-family: var(--serif); font-size: 20px; margin-bottom: 4px; }
.exam-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 18px; }

.exam-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.exam-cell {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 10px 12px;
}
.exam-cell b { display: block; font-size: 17px; }
.exam-cell span { font-size: 11px; color: var(--muted); letter-spacing: 0.05em; text-transform: uppercase; }

/* ---------- Section headers ---------- */

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 46px 0 18px;
  flex-wrap: wrap;
}
.section-head h2 { font-family: var(--serif); font-size: 26px; font-weight: 600; }
.section-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }

/* ---------- Chapter cards ---------- */

.chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 16px;
}

.chapter-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  color: var(--text);
  text-decoration: none;
  overflow: hidden;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.chapter-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--gold), transparent);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.chapter-card:hover {
  transform: translateY(-2px);
  border-color: var(--muted-2);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.chapter-card:hover::after { opacity: 1; }

.ch-top { display: flex; align-items: center; gap: 10px; }
.ch-num {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: var(--gold);
  font-weight: 800;
  font-size: 14px;
  border: 1px solid color-mix(in srgb, var(--gold) 28%, transparent);
}
.ch-weight {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 2px 9px;
  white-space: nowrap;
}
.chapter-card h3 { font-size: 16.5px; font-weight: 650; letter-spacing: -0.01em; }
.ch-meta { display: flex; gap: 14px; color: var(--muted); font-size: 12.5px; }
.ch-meta b { color: var(--text); font-weight: 650; }

.mini-progress {
  height: 5px;
  background: var(--panel-2);
  border-radius: 20px;
  overflow: hidden;
  margin-top: 4px;
}
.mini-progress > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #f0c454);
  border-radius: 20px;
  transition: width 0.35s ease;
}

/* ---------- Chapter page ---------- */

.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 16px; }
.crumb a { color: var(--muted); }
.crumb a:hover { color: var(--gold); }
.crumb span { margin: 0 8px; opacity: 0.5; }

.ch-hero {
  display: flex;
  gap: 22px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.ch-hero h1 { font-family: var(--serif); font-size: clamp(26px, 3.4vw, 38px); font-weight: 600; }
.ch-hero .meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 10px; color: var(--muted); font-size: 13px; }
.ch-hero .meta b { color: var(--text); }

.progress-ring {
  --p: 0;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--gold) calc(var(--p) * 1%), var(--panel-2) 0);
  position: relative;
  flex-shrink: 0;
}
.progress-ring::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 50%;
  background: var(--bg);
}
.progress-ring b { position: relative; font-size: 19px; font-family: var(--serif); }
.progress-ring small { position: relative; display: block; font-size: 9.5px; color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase; text-align: center; }

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin: 26px 0 24px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 650;
  padding: 11px 16px;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ---------- Notes ---------- */

.notes-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }

.rev-summary {
  background: linear-gradient(150deg, var(--gold-soft), transparent 70%), var(--panel);
  border: 1px solid color-mix(in srgb, var(--gold) 32%, var(--line));
  border-radius: var(--radius);
  padding: 22px 24px;
}
.rev-summary h3 { font-family: var(--serif); font-size: 19px; margin-bottom: 8px; color: var(--gold); }
.rev-summary p { margin: 0; color: var(--text); }

.rev-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

.rev-box {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.rev-box h4 {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.rev-box h4 i { color: var(--gold); font-style: normal; }
.rev-box ul { margin: 0; padding-left: 18px; }
.rev-box li { margin-bottom: 9px; font-size: 13.7px; color: var(--text); }
.rev-box li::marker { color: var(--gold); }
.rev-box.numbers li::marker { color: var(--blue); }
.rev-box.traps { border-color: color-mix(in srgb, var(--red) 34%, var(--line)); }
.rev-box.traps li::marker { color: var(--red); }

.acc {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.acc + .acc { margin-top: 10px; }
.acc summary {
  list-style: none;
  cursor: pointer;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-weight: 650;
  font-size: 14.5px;
}
.acc summary::-webkit-details-marker { display: none; }
.acc summary:hover { background: var(--panel-2); }
.acc .sid {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--gold);
  background: var(--gold-soft);
  border-radius: 6px;
  padding: 2px 7px;
  flex-shrink: 0;
}
.acc .chev { margin-left: auto; color: var(--muted); transition: transform 0.18s ease; font-size: 12px; }
.acc[open] .chev { transform: rotate(90deg); }
.acc-body { padding: 4px 20px 22px; border-top: 1px solid var(--line); }

.notes-list { margin: 14px 0 0; padding-left: 20px; }
.notes-list li { margin-bottom: 10px; font-size: 14.2px; }
.notes-list li::marker { color: var(--gold); }

.term-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; margin-top: 16px; }
.term {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-left: 2px solid var(--blue);
  border-radius: 8px;
  padding: 10px 12px;
}
.term b { display: block; font-size: 13px; margin-bottom: 2px; }
.term span { font-size: 12.7px; color: var(--muted); }

.formula {
  background: var(--bg-2);
  border: 1px dashed color-mix(in srgb, var(--gold) 45%, var(--line));
  border-radius: 8px;
  padding: 10px 13px;
  font-family: var(--mono);
  font-size: 12.8px;
  color: var(--gold);
  margin-top: 10px;
  overflow-x: auto;
}

/* ---------- Practice / lists ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
}
.panel h3 { font-family: var(--serif); font-size: 19px; margin-bottom: 6px; }
.panel .sub { color: var(--muted); font-size: 13px; margin: 0 0 18px; }

.row-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--line);
}
.row-item:last-child { border-bottom: none; }
.row-item .name { font-size: 14px; font-weight: 600; }
.row-item .sub2 { font-size: 12.3px; color: var(--muted); }
.row-item .right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.pill {
  font-size: 11.5px;
  font-weight: 700;
  border-radius: 20px;
  padding: 3px 10px;
  white-space: nowrap;
}
.pill.gold { color: var(--gold); background: var(--gold-soft); }
.pill.green { color: var(--green); background: var(--green-soft); }
.pill.red { color: var(--red); background: var(--red-soft); }
.pill.blue { color: var(--blue); background: var(--blue-soft); }
.pill.muted { color: var(--muted); background: var(--panel-2); }

.split-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.split-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ---------- Quiz ---------- */

.quiz-top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.quiz-top h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; }
.quiz-top .spacer { flex: 1; }

.qbar {
  height: 6px;
  background: var(--panel-2);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 22px;
}
.qbar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--gold), #f4cc63); transition: width 0.25s ease; }

.qcard {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  box-shadow: var(--shadow);
}

.qmeta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.qtext { font-size: 17.5px; line-height: 1.55; font-weight: 550; margin-bottom: 20px; }

.opts { display: grid; gap: 9px; }

.opt {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  width: 100%;
  text-align: left;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 15px;
  color: var(--text);
  font-size: 14.5px;
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.opt:hover:not(.disabled) { border-color: var(--muted-2); background: var(--panel-2); }
.opt .letter {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 6px;
  display: grid;
  place-items: center;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  margin-top: 1px;
}
.opt.selected { border-color: var(--gold); background: var(--gold-soft); }
.opt.selected .letter { background: var(--gold); color: #171102; border-color: var(--gold); }
.opt.correct { border-color: var(--green); background: var(--green-soft); }
.opt.correct .letter { background: var(--green); color: #04140d; border-color: var(--green); }
.opt.wrong { border-color: var(--red); background: var(--red-soft); }
.opt.wrong .letter { background: var(--red); color: #fff; border-color: var(--red); }
.opt.disabled { cursor: default; }

.explain {
  margin-top: 16px;
  border-left: 3px solid var(--gold);
  background: var(--gold-soft);
  border-radius: 0 10px 10px 0;
  padding: 13px 16px;
  font-size: 14px;
}
.explain b { display: block; font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gold); margin-bottom: 4px; }
.explain p { margin: 0; }

.quiz-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.quiz-actions .spacer { flex: 1; }

.timer {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  padding: 5px 11px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}
.timer.warn { color: var(--red); border-color: var(--red); }

.qnav {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 6px;
  margin-top: 18px;
}
.qnav button {
  aspect-ratio: 1;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.qnav button:hover { border-color: var(--muted-2); color: var(--text); }
.qnav button.answered { background: var(--blue-soft); border-color: var(--blue); color: var(--blue); }
.qnav button.current { outline: 2px solid var(--gold); color: var(--gold); }
.qnav button.correct { background: var(--green-soft); border-color: var(--green); color: var(--green); }
.qnav button.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); }

/* ---------- Result ---------- */

.result-hero {
  text-align: center;
  padding: 34px 20px 26px;
  background: linear-gradient(160deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.score-big {
  font-family: var(--serif);
  font-size: 58px;
  line-height: 1;
  letter-spacing: -0.03em;
}
.score-big small { font-size: 20px; color: var(--muted); }
.result-hero .verdict { margin-top: 12px; font-size: 15px; font-weight: 700; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 22px auto 0;
  max-width: 620px;
}
.result-grid .cell { background: var(--bg-2); border: 1px solid var(--line); border-radius: 9px; padding: 9px; }
.result-grid b { display: block; font-size: 18px; }
.result-grid span { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }

.review-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 15px 18px;
  margin-top: 10px;
  background: var(--panel);
}
.review-item .rq { font-weight: 600; margin-bottom: 8px; font-size: 14.5px; }
.review-item .ra { font-size: 13px; margin: 2px 0; }
.review-item .ra b { font-weight: 700; }

/* ---------- Tables ---------- */

table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th, table.tbl td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
table.tbl th { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl td.num, table.tbl th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- Empty state ---------- */

.empty {
  text-align: center;
  padding: 48px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
}
.empty b { display: block; color: var(--text); font-size: 16px; margin-bottom: 4px; }

/* ---------- Footer ---------- */

footer {
  border-top: 1px solid var(--line);
  margin-top: 30px;
  padding: 28px 22px 50px;
  text-align: center;
  color: var(--muted-2);
  font-size: 12.5px;
}
footer p { margin: 4px 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%) translateY(20px);
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Plain English Concept Guide ---------- */

.plain-guide {
  background: var(--panel);
  border: 1px solid color-mix(in srgb, var(--gold) 45%, var(--line));
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  position: relative;
  overflow: hidden;
}
.plain-guide::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--blue));
}
.plain-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}
.plain-header .tag {
  background: var(--gold-soft);
  color: var(--gold);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid color-mix(in srgb, var(--gold) 35%, transparent);
}
.plain-analogy {
  background: var(--bg-2);
  border-left: 4px solid var(--gold);
  border-radius: 10px;
  padding: 14px 18px;
  margin-bottom: 18px;
  font-size: 14.5px;
  line-height: 1.65;
  color: var(--text);
}
.plain-analogy b {
  color: var(--gold);
  display: block;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 14px;
  margin-top: 14px;
}
.concept-card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.concept-card:hover {
  border-color: var(--muted-2);
  transform: translateY(-2px);
}
.concept-card h5 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--gold);
  display: flex;
  align-items: center;
  gap: 6px;
}
.concept-card p {
  margin: 0 0 10px;
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  flex-grow: 1;
}
.concept-card .ex {
  font-size: 12.3px;
  color: var(--muted);
  background: color-mix(in srgb, var(--panel) 70%, transparent);
  border-radius: 6px;
  padding: 7px 10px;
  border-left: 2px solid var(--blue);
  line-height: 1.45;
}
.golden-rules {
  margin-top: 18px;
  background: var(--bg-2);
  border: 1px solid color-mix(in srgb, var(--green) 35%, var(--line));
  border-radius: 10px;
  padding: 16px 18px;
}
.golden-rules h4 {
  font-size: 14px;
  color: var(--green);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.golden-rules ul {
  margin: 0;
  padding-left: 20px;
}
.golden-rules li {
  font-size: 13.5px;
  margin-bottom: 8px;
  line-height: 1.5;
}
.golden-rules li:last-child {
  margin-bottom: 0;
}

/* ---------- Mobile Bottom Navigation Bar ---------- */

.mobile-nav {
  display: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; gap: 22px; padding-top: 18px; }
  .rev-cols { grid-template-columns: 1fr; }
  .split-2, .split-3 { grid-template-columns: 1fr; }
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  main {
    padding: 16px 14px calc(75px + env(safe-area-inset-bottom));
  }
  .topbar-inner {
    padding: 10px 14px;
    gap: 10px;
    justify-content: space-between;
  }
  .topbar .nav a {
    display: none;
  }
  .brand-text span {
    display: none;
  }

  /* Mobile bottom bar active */
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: color-mix(in srgb, var(--bg) 94%, transparent);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 50;
    justify-content: space-around;
    align-items: center;
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.25);
  }
  .mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 12px;
    border-radius: 10px;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s ease, background 0.15s ease;
    -webkit-tap-highlight-color: transparent;
  }
  .mobile-nav a .nav-icon {
    font-size: 19px;
    line-height: 1;
  }
  .mobile-nav a.active {
    color: var(--gold);
    background: var(--gold-soft);
  }

  /* Touch-friendly Quiz Option Buttons */
  .opt {
    min-height: 52px;
    padding: 13px 14px;
    font-size: 14.8px;
    border-radius: 12px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
  .opt:active:not(.disabled) {
    transform: scale(0.99);
  }
  .opt .letter {
    width: 28px;
    height: 28px;
    font-size: 13px;
    border-radius: 8px;
  }
  .qcard {
    padding: 16px;
    border-radius: 14px;
  }
  .qtext {
    font-size: 16px;
    line-height: 1.5;
  }
  .qmeta {
    gap: 6px;
    flex-wrap: wrap;
  }
  .quiz-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 18px;
  }
  .quiz-actions button {
    width: 100%;
    min-height: 48px;
    font-size: 14.5px;
    justify-content: center;
  }
  .tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px;
  }
  .tab {
    white-space: nowrap;
    padding: 10px 14px;
    font-size: 13.5px;
  }
  .qnav {
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
  }
  .qnav button {
    height: 38px;
    font-size: 13px;
  }
  .ch-hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .progress-ring {
    align-self: center;
  }
  .concept-grid {
    grid-template-columns: 1fr;
  }
  .plain-guide {
    padding: 16px;
  }
  .result-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .row-item {
    flex-wrap: wrap;
    gap: 8px;
  }
  .row-item .right {
    width: 100%;
    margin-left: 0;
    justify-content: space-between;
  }
}

/* Extra small devices (< 400px) */
@media (max-width: 400px) {
  .qnav {
    grid-template-columns: repeat(4, 1fr);
  }
  .mobile-nav a {
    padding: 5px 8px;
    font-size: 10px;
  }
  .mobile-nav a .nav-icon {
    font-size: 17px;
  }
}

/* ---------- Print (revision notes) ---------- */

@media print {
  body { background: #fff; color: #000; }
  body::before, .topbar, .tabs, .mobile-nav, footer, .no-print { display: none !important; }
  main { max-width: none; padding: 0; }
  .acc { break-inside: avoid; border-color: #ccc; }
  .acc[open] summary { background: #eee; }
  .rev-box, .rev-summary, .panel, .qcard, .plain-guide { border-color: #ccc; box-shadow: none; background: #fff; }
  .chapter-card { break-inside: avoid; }
  a { color: #000; }
}
