/* BowTie Academy - main stylesheet
   Colour tokens carry bowtie semantics (hazard, top event, cause, outcome, control, defeating factor)
   so diagrams, UI accents, and activities all speak the same visual language. */

:root {
  --bg: #060b17;
  --bg-2: #0a1222;
  --surface: #0f1a2f;
  --surface-2: #15233e;
  --surface-3: #1c2d4d;
  --line: rgba(148, 170, 205, 0.14);
  --line-2: rgba(148, 170, 205, 0.26);
  --text: #e8eef8;
  --text-2: #b6c3d8;
  --muted: #8193b0;
  --accent: #2dd4bf;
  --accent-2: #38bdf8;
  --accent-ink: #042f2e;
  --good: #22c55e;
  --bad: #f43f5e;
  --warn: #f59e0b;

  --hazard: #facc15;
  --top: #f97316;
  --cause: #3b82f6;
  --outcome: #ef4444;
  --control: #e2e8f0;
  --df: #a855f7;
  --dfc: #c4b5fd;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
  --glow: 0 0 0 1px rgba(45, 212, 191, 0.25), 0 10px 40px rgba(45, 212, 191, 0.12);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  --maxw: 1180px;
  --logo-filter: grayscale(1) invert(1);
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f4f7fb;
  --bg-2: #eaf0f8;
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --surface-3: #e5ecf6;
  --line: rgba(15, 30, 60, 0.1);
  --line-2: rgba(15, 30, 60, 0.2);
  --text: #0d1a2e;
  --text-2: #33425c;
  --muted: #5d6c86;
  --accent: #0d9488;
  --accent-2: #0284c7;
  --accent-ink: #ffffff;
  --shadow: 0 10px 30px rgba(15, 30, 60, 0.1);
  --glow: 0 0 0 1px rgba(13, 148, 136, 0.25), 0 10px 30px rgba(13, 148, 136, 0.12);
  --logo-filter: grayscale(1);
  color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
  --bg: #f4f7fb;
  --bg-2: #eaf0f8;
  --surface: #ffffff;
  --surface-2: #f1f5fb;
  --surface-3: #e5ecf6;
  --line: rgba(15, 30, 60, 0.1);
  --line-2: rgba(15, 30, 60, 0.2);
  --text: #0d1a2e;
  --text-2: #33425c;
  --muted: #5d6c86;
  --accent: #0d9488;
  --accent-2: #0284c7;
  --accent-ink: #ffffff;
  --shadow: 0 10px 30px rgba(15, 30, 60, 0.1);
  --glow: 0 0 0 1px rgba(13, 148, 136, 0.25), 0 10px 30px rgba(13, 148, 136, 0.12);
  --logo-filter: grayscale(1);
  color-scheme: light;
}
}


* { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 85% -10%, rgba(56, 189, 248, 0.09), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(45, 212, 191, 0.07), transparent 60%);
  background-attachment: fixed;
  overflow-x: hidden;
}
img, svg { max-width: 100%; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.01em; }
h1 { font-size: clamp(2.2rem, 5vw, 3.8rem); font-weight: 800; letter-spacing: -0.03em; }
h2 { font-size: clamp(1.6rem, 3.2vw, 2.4rem); font-weight: 750; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; font-weight: 700; }
p { margin: 0 0 1em; }
small, .small { font-size: 0.88rem; }
.muted { color: var(--muted); }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 50;
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--line);
}
.site-header .wrap { display: flex; align-items: center; gap: 18px; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 800; letter-spacing: -0.01em; font-size: 1.08rem; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand svg { width: 34px; height: 34px; flex: none; }
.brand span b { color: var(--accent); font-weight: 800; }
.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a { color: var(--text-2); padding: 8px 12px; border-radius: 999px; font-size: 0.95rem; font-weight: 600; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); text-decoration: none; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface); color: var(--text); display: inline-grid; place-items: center; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn svg { width: 18px; height: 18px; }
.menu-btn { display: none; }
@media (max-width: 820px) {
  .menu-btn { display: inline-grid; margin-left: auto; }
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch;
    background: var(--bg-2); border-bottom: 1px solid var(--line); padding: 10px 16px 16px; }
  .nav.open { display: flex; }
  .nav a { border-radius: 10px; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 12px 20px; border-radius: 999px; border: 1px solid var(--line-2);
  background: var(--surface-2); color: var(--text); font: inherit; font-weight: 700; font-size: 0.98rem;
  cursor: pointer; transition: transform .15s ease, background .15s ease, box-shadow .2s ease; text-decoration: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); background: var(--surface-3); }
.btn:active { transform: translateY(0); }
.btn svg { width: 18px; height: 18px; }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #03121a; border-color: transparent; box-shadow: var(--glow); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 8px 14px; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; transform: none; }

/* ---------- Generic cards and sections ---------- */
section { padding: 84px 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.78rem; font-weight: 800; color: var(--accent); margin-bottom: 12px; display: inline-flex; gap: 8px; align-items: center; }
.lead { font-size: 1.18rem; color: var(--text-2); max-width: 760px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 20px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 960px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .g2, .g3, .g4 { grid-template-columns: minmax(0, 1fr); } section { padding: 60px 0; } }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--surface-2); border: 1px solid var(--line); color: var(--text-2); }
.chip-dot { width: 10px; height: 10px; border-radius: 3px; display: inline-block; flex: none; }

/* ---------- Hero ---------- */
.hero { padding: 64px 0 40px; position: relative; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: 1.02fr 1.18fr; gap: 36px; align-items: center; }
@media (max-width: 960px) { .hero-grid { grid-template-columns: 1fr; } }
.hero h1 .grad { background: linear-gradient(100deg, var(--hazard), var(--top) 40%, var(--outcome) 70%, var(--cause)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero .cta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.hero-visual { position: relative; border-radius: 22px; background: radial-gradient(120% 120% at 50% 0%, #13213d 0%, #070d1a 70%); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; aspect-ratio: 16 / 10; }
.hero-visual svg { width: 100%; height: 100%; display: block; }
.hero-byline { display: inline-flex; align-items: center; gap: 12px; margin-top: 22px; color: var(--text-2); font-size: 0.95rem; line-height: 1.4; }
.hero-byline:hover { text-decoration: none; color: var(--text); }
.hero-byline img { width: 42px; height: 42px; flex: none; border-radius: 50%; border: 2px solid var(--line-2); object-fit: cover; }
.hero-byline b { color: var(--accent); }
.hero-stats { display: flex; flex-wrap: wrap; gap: 22px; margin-top: 30px; color: var(--muted); font-size: 0.92rem; }
.hero-stats b { color: var(--text); font-size: 1.4rem; display: block; line-height: 1.1; }

/* ---------- Anatomy explorer ---------- */
.anatomy { display: grid; grid-template-columns: 1.85fr 1fr; gap: 24px; align-items: stretch; }
@media (max-width: 960px) { .anatomy { grid-template-columns: 1fr; } }
.anatomy-stage { border-radius: var(--radius); background: radial-gradient(120% 120% at 50% 0%, #13213d 0%, #070d1a 70%); border: 1px solid var(--line); overflow: hidden; }
.anatomy-stage svg { display: block; width: 100%; height: auto; }
.anatomy-stage [data-part] { cursor: pointer; }
.anatomy-info { display: flex; flex-direction: column; gap: 14px; }
.anatomy-info .card { flex: 1; }
.part-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.part-tab { border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.part-tab[aria-selected="true"] { color: var(--text); background: var(--surface-3); border-color: var(--accent); }

/* ---------- Steps timeline ---------- */
.steps8 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; counter-reset: s; }
@media (max-width: 960px) { .steps8 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .steps8 { grid-template-columns: 1fr; } }
.step8 { position: relative; padding: 20px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.step8::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--c, var(--accent)); }
.step8 .n { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); font-weight: 700; }
.step8 h4 { margin: 4px 0 6px; font-size: 1.05rem; }
.step8 p { color: var(--text-2); font-size: 0.92rem; margin: 0; }
.phase-label { display: flex; align-items: center; gap: 12px; margin: 28px 0 12px; font-weight: 800; color: var(--text-2); font-size: 0.9rem; text-transform: uppercase; letter-spacing: 0.1em; }
.phase-label::after { content: ""; height: 1px; background: var(--line-2); flex: 1; }

/* ---------- Module cards ---------- */
.modules { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 960px) { .modules { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .modules { grid-template-columns: 1fr; } }
.module-card { display: flex; flex-direction: column; gap: 10px; padding: 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--text); position: relative; overflow: hidden; transition: transform .2s ease, border-color .2s ease, box-shadow .2s ease; }
.module-card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: var(--shadow); text-decoration: none; }
.module-card .top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.module-card .num { font-family: var(--mono); font-weight: 800; font-size: 0.82rem; color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); padding: 4px 9px; border-radius: 8px; }
.module-card h3 { margin: 4px 0 0; font-size: 1.12rem; }
.module-card p { color: var(--text-2); font-size: 0.93rem; margin: 0; flex: 1; }
.module-card .meta { display: flex; gap: 12px; color: var(--muted); font-size: 0.82rem; align-items: center; }
.module-card .bar { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.module-card .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); }
.module-card.done .status { color: var(--good); }
.status { font-size: 0.8rem; font-weight: 800; color: var(--muted); display: inline-flex; gap: 6px; align-items: center; }
.status svg { width: 16px; height: 16px; }
.module-card::after { content: ""; position: absolute; right: -40px; top: -40px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(closest-side, color-mix(in srgb, var(--c, var(--accent)) 22%, transparent), transparent); pointer-events: none; }

/* ---------- Author ---------- */
.author { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 32px; align-items: start; padding: 28px; }
.author-photo { margin: 0; }
.author-photo img { display: block; width: 100%; height: auto; border-radius: 14px; border: 1px solid var(--line); }
.author h2 { margin-bottom: 4px; }
.author-role { color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.author-creds { list-style: none; padding: 0; margin: 0 0 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.author-train { margin-top: 6px; padding: 18px 20px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--line); }
.author-train h3 { margin-bottom: 6px; }
.author-train p { margin-bottom: 0; }
.author-train .cta { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
@media (max-width: 760px) { .author { grid-template-columns: minmax(0, 1fr); gap: 20px; padding: 22px; } .author-photo { max-width: 180px; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); padding: 40px 0 56px; color: var(--muted); font-size: 0.9rem; margin-top: 40px; }
.site-footer .wrap { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 30px; }
@media (max-width: 760px) { .site-footer .wrap { grid-template-columns: 1fr; } }
.footer-pmrc { display: inline-block; margin-top: 16px; line-height: 0; }
.footer-pmrc img { display: block; height: 34px; width: auto; filter: var(--logo-filter); opacity: 0.55; transition: opacity .2s; }
.footer-pmrc:hover img, .footer-pmrc:focus-visible img { opacity: 0.85; }
.site-footer h4 { color: var(--text); font-size: 0.95rem; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }

/* ---------- Lesson page ---------- */
.lesson-head { padding: 22px 0 14px; }
.lesson-head .lead { font-size: 1.04rem; max-width: 900px; margin-bottom: 0; }
.crumbs { font-size: 0.88rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.lesson-head h1 { font-size: clamp(1.7rem, 3.6vw, 2.5rem); margin-bottom: 6px; }
.lesson-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
.side-panel { display: grid; gap: 16px; grid-template-columns: 1.4fr 1fr; margin-top: 18px; }
@media (max-width: 860px) { .side-panel { grid-template-columns: minmax(0, 1fr); } }
.outline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 560px) { .outline { grid-template-columns: minmax(0, 1fr); } }
.outline { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px 10px; counter-reset: o; }
.outline li button { width: 100%; text-align: left; background: none; border: 0; color: var(--text-2); font: inherit; font-size: 0.88rem; padding: 7px 10px; border-radius: 8px; cursor: pointer; display: flex; gap: 10px; align-items: baseline; }
.outline li button:hover { background: var(--surface-2); color: var(--text); }
.outline li button .i { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); min-width: 20px; }
.outline li.current button { background: var(--surface-3); color: var(--text); font-weight: 700; }
.outline li.seen button .i { color: var(--accent); }

/* Player */
.player:focus { outline: none; }
.player { border-radius: 20px; overflow: hidden; background: #050a15; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; }
.player:fullscreen { border-radius: 0; display: flex; flex-direction: column; justify-content: center; background: #050a15; }
.player:fullscreen .stage-wrap { max-height: calc(100vh - 140px); aspect-ratio: auto; flex: 1; }
.stage-wrap { position: relative; aspect-ratio: 16 / 9; background: radial-gradient(130% 120% at 50% 0%, #12203b 0%, #060b17 72%); }
.stage-wrap svg.stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.start-overlay { position: absolute; inset: 0; display: grid; place-items: center; background: radial-gradient(closest-side, rgba(6, 11, 23, 0.25), rgba(6, 11, 23, 0.82)); z-index: 3; border: 0; width: 100%; cursor: pointer; color: #fff; font: inherit; }
.start-overlay .big-play { width: 92px; height: 92px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--accent-2)); box-shadow: 0 0 0 10px rgba(45, 212, 191, 0.15), 0 0 60px rgba(45, 212, 191, 0.4); margin: 0 auto 14px; transition: transform .2s; }
.start-overlay:hover .big-play { transform: scale(1.06); }
.start-overlay .big-play svg { width: 40px; height: 40px; color: #03121a; margin-left: 5px; }
.start-overlay .label { font-weight: 800; font-size: 1.1rem; text-shadow: 0 2px 12px rgba(0,0,0,.6); }
.start-overlay .sub { color: #b6c3d8; font-size: 0.9rem; }
.caption { position: absolute; left: 50%; bottom: 3.5%; transform: translateX(-50%); width: min(92%, 1100px); text-align: center; z-index: 2; pointer-events: none; }
.caption span { display: inline; background: rgba(3, 8, 18, 0.82); color: #f1f5fb; padding: 0.25em 0.6em; border-radius: 8px; font-size: clamp(13px, 1.75cqw, 21px); line-height: 1.75; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.player { container-type: inline-size; }
.caption-bar { display: none; }
@container (max-width: 699px) {
  .caption { display: none; }
  .caption-bar { display: block; padding: 10px 14px; background: #08101f; color: #f1f5fb; font-size: 0.92rem; line-height: 1.5; min-height: 3.4em; text-align: center; border-top: 1px solid rgba(148, 170, 205, 0.12); }
  .caption-bar.off { display: none; }
  .caption-bar .w { opacity: 0.55; transition: opacity .15s; }
  .caption-bar .w.on { opacity: 1; }
}
.caption.off { display: none; }
.caption .w { opacity: 0.55; transition: opacity .15s; }
.caption .w.on { opacity: 1; }
.controls { display: flex; align-items: center; gap: 8px; padding: 10px 12px; background: #0a1222; border-top: 1px solid rgba(148, 170, 205, 0.12); color: #e8eef8; flex-wrap: wrap; }
.controls .icon-btn { background: #111c33; border-color: rgba(148, 170, 205, 0.2); color: #e8eef8; }
.controls .icon-btn:hover { background: #1c2d4d; }
.controls .icon-btn[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.controls .play-btn { width: 46px; height: 46px; background: linear-gradient(135deg, #2dd4bf, #38bdf8); color: #03121a; border: 0; }
.controls .play-btn:hover { filter: brightness(1.08); background: linear-gradient(135deg, #2dd4bf, #38bdf8); }
.controls .spacer { flex: 1; }
.controls .stepinfo { font-family: var(--mono); font-size: 0.82rem; color: #8193b0; min-width: 64px; text-align: center; }
.controls select { background: #111c33; color: #e8eef8; border: 1px solid rgba(148, 170, 205, 0.2); border-radius: 999px; padding: 7px 10px; font: inherit; font-size: 0.85rem; cursor: pointer; }
.progress-track { display: flex; gap: 3px; padding: 0 12px 10px; background: #0a1222; }
.progress-track button { flex: 1; height: 6px; border: 0; padding: 0; border-radius: 3px; background: #1c2d4d; cursor: pointer; position: relative; overflow: hidden; }
.progress-track button i { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #2dd4bf, #38bdf8); }
.progress-track button.done i { width: 100%; }
.progress-track button:hover { background: #2a3d63; }
@media (max-width: 560px) { .controls .hide-sm { display: none; } }
.transcript { margin-top: 14px; display: none; }
.transcript.open { display: block; }
.transcript ol { margin: 0; padding-left: 1.4em; display: grid; gap: 10px; color: var(--text-2); }
.transcript li.current { color: var(--text); }

/* Lesson sections after the player */
.lesson-section { margin-top: 40px; }
.lesson-section > h2 { font-size: 1.6rem; display: flex; gap: 12px; align-items: center; }
.lesson-section > h2 .badge { font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; padding: 5px 10px; border-radius: 999px; background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }
.keypoints { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 700px) { .keypoints { grid-template-columns: 1fr; } }
.keypoint { display: flex; gap: 12px; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.keypoint svg { width: 22px; height: 22px; color: var(--accent); flex: none; margin-top: 2px; }
.keypoint p { margin: 0; color: var(--text-2); font-size: 0.96rem; }
.lesson-nav { display: flex; justify-content: space-between; gap: 14px; margin: 48px 0 10px; flex-wrap: wrap; }
.refs { font-size: 0.86rem; color: var(--muted); }
.refs li { margin-bottom: 6px; }

/* ---------- Activities ---------- */
.activity { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 22px; box-shadow: var(--shadow); }
.activity-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 14px; }
.activity-head .ico { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 15%, transparent); color: var(--accent); flex: none; }
.activity-head .ico svg { width: 22px; height: 22px; }
.activity-head h3 { margin: 0 0 4px; }
.activity-head p { margin: 0; color: var(--text-2); font-size: 0.95rem; }
.activity .actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.feedback { margin-top: 14px; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface-2); font-size: 0.95rem; display: none; }
.feedback.show { display: block; animation: rise .3s ease; }
.feedback.good { border-color: color-mix(in srgb, var(--good) 50%, transparent); background: color-mix(in srgb, var(--good) 10%, var(--surface)); }
.feedback.bad { border-color: color-mix(in srgb, var(--bad) 50%, transparent); background: color-mix(in srgb, var(--bad) 9%, var(--surface)); }
.feedback.part { border-color: color-mix(in srgb, var(--warn) 50%, transparent); background: color-mix(in srgb, var(--warn) 9%, var(--surface)); }
.feedback b.t { display: block; margin-bottom: 4px; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* MCQ */
.q { margin-bottom: 18px; }
.q .stem { font-weight: 700; margin-bottom: 10px; }
.opts { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); padding: 12px 14px; border-radius: 12px; font: inherit; font-size: 0.97rem; cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover { border-color: var(--accent-2); }
.opt .k { width: 26px; height: 26px; flex: none; border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-size: 0.8rem; background: var(--surface-3); color: var(--text-2); font-family: var(--mono); }
.opt[aria-pressed="true"] { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 12%, var(--surface-2)); }
.opt.correct { border-color: var(--good); background: color-mix(in srgb, var(--good) 13%, var(--surface-2)); }
.opt.correct .k { background: var(--good); color: #04120a; }
.opt.wrong { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface-2)); }
.opt.wrong .k { background: var(--bad); color: #fff; }
.opt[disabled] { cursor: default; }
.opt .why { display: block; font-size: 0.88rem; color: var(--text-2); margin-top: 6px; }

/* Sort / drag and drop */
.pool, .bucket-items { display: flex; flex-wrap: wrap; gap: 8px; min-height: 48px; }
.pool { padding: 14px; border-radius: 14px; border: 1px dashed var(--line-2); background: var(--bg-2); margin-bottom: 14px; }
.buckets { display: grid; gap: 12px; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
@media (max-width: 760px) { .buckets { grid-template-columns: 1fr; } }
.bucket { border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 12px; min-height: 120px; transition: border-color .15s, background .15s; }
.bucket h4 { margin: 0 0 4px; font-size: 0.95rem; display: flex; align-items: center; gap: 8px; }
.bucket .hint { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
.bucket.over, .bucket.target { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 9%, var(--surface-2)); }
.bucket.selectable { cursor: pointer; }
.card-item { user-select: none; -webkit-user-select: none; touch-action: none; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); padding: 8px 12px; border-radius: 10px; font: inherit; font-size: 0.9rem; font-weight: 600; cursor: grab; box-shadow: 0 2px 6px rgba(0,0,0,0.15); text-align: left; max-width: 100%; }
.card-item:active { cursor: grabbing; }
.card-item.dragging { opacity: 0.4; }
.card-item.picked { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-item.correct { border-color: var(--good); box-shadow: inset 4px 0 0 var(--good); }
.card-item.wrong { border-color: var(--bad); box-shadow: inset 4px 0 0 var(--bad); }
.drag-ghost { position: fixed; pointer-events: none; z-index: 1000; opacity: 0.92; transform: rotate(-2deg); box-shadow: 0 12px 30px rgba(0,0,0,.4); }
.item-notes { margin-top: 12px; display: grid; gap: 8px; }
.item-note { font-size: 0.9rem; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border-left: 4px solid var(--line-2); }
.item-note.good { border-left-color: var(--good); }
.item-note.bad { border-left-color: var(--bad); }

/* Hazard builder */
.builder-slots { display: grid; gap: 14px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 860px) { .builder-slots { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .builder-slots { grid-template-columns: 1fr; } }
.slot { border-radius: 14px; border: 1px solid var(--line-2); background: var(--surface-2); padding: 12px; }
.slot .slot-n { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); font-weight: 800; }
.slot h4 { margin: 2px 0 8px; font-size: 1rem; text-transform: capitalize; }
.slot .choice { display: block; width: 100%; text-align: left; margin-bottom: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text-2); border-radius: 9px; padding: 8px 10px; font: inherit; font-size: 0.86rem; cursor: pointer; }
.slot .choice[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.statement { margin-top: 16px; padding: 16px 18px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line-2); font-size: 1.05rem; min-height: 60px; }
.statement .seg { padding: 2px 4px; border-radius: 5px; }
.statement .seg.s1 { background: rgba(250, 204, 21, 0.16); }
.statement .seg.s2 { background: rgba(56, 189, 248, 0.16); }
.statement .seg.s3 { background: rgba(45, 212, 191, 0.16); }
.statement .seg.s4 { background: rgba(168, 85, 247, 0.18); }

/* Spot the error */
.spot-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 18px; }
@media (max-width: 900px) { .spot-grid { grid-template-columns: 1fr; } }
.spot-stage { border-radius: 14px; overflow: hidden; background: radial-gradient(130% 120% at 50% 0%, #12203b 0%, #060b17 72%); border: 1px solid var(--line); }
.spot-stage svg { display: block; width: 100%; height: auto; }
.spot-stage [data-k] { cursor: pointer; }
.spot-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.spot-list { display: grid; gap: 8px; }
.spot-find { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); font-size: 0.92rem; }
.spot-find.found { border-color: var(--good); }
.spot-find .lbl { font-weight: 800; }

/* Effectiveness matrix */
.matrix-wrap { display: grid; grid-template-columns: auto 1fr; gap: 22px; align-items: start; }
@media (max-width: 860px) { .matrix-wrap { grid-template-columns: 1fr; } }
.matrix { display: grid; grid-template-columns: 74px repeat(4, 64px); grid-template-rows: repeat(4, 56px) 46px; gap: 4px; font-size: 0.78rem; }
@media (max-width: 420px) { .matrix { grid-template-columns: 54px repeat(4, 1fr); } }
.matrix .cell { border-radius: 8px; display: grid; place-items: center; font-weight: 800; font-family: var(--mono); font-size: 0.95rem; color: #111; transition: transform .15s, box-shadow .15s; }
.matrix .cell.on { transform: scale(1.08); box-shadow: 0 0 0 3px #fff, 0 0 20px rgba(255,255,255,.4); z-index: 1; }
.matrix .ax { display: grid; place-items: center; text-align: center; color: var(--text-2); font-weight: 700; line-height: 1.15; }
.r-vp { background: #ef4444; color: #fff !important; } .r-p { background: #f59e0b; } .r-g { background: #facc15; } .r-vg { background: #84cc16; }
.scale-q { margin-bottom: 14px; }
.scale-q label { font-weight: 700; display: block; margin-bottom: 6px; font-size: 0.95rem; }
.seg-ctl { display: flex; gap: 4px; flex-wrap: wrap; }
.seg-ctl button { flex: 1; min-width: 74px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); padding: 7px 8px; border-radius: 9px; font: inherit; font-size: 0.84rem; font-weight: 700; cursor: pointer; }
.seg-ctl button[aria-pressed="true"] { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.result-badge { display: inline-flex; padding: 6px 12px; border-radius: 999px; font-weight: 800; }

/* Model builder (drag cards onto a bowtie) */
.mb { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; }
@media (max-width: 960px) { .mb { grid-template-columns: 1fr; } }
.mb .pool { flex-direction: column; flex-wrap: nowrap; align-items: stretch; max-height: 640px; overflow: auto; margin: 0; }
@media (max-width: 960px) { .mb .pool { flex-direction: row; flex-wrap: wrap; max-height: none; } }
.mb-board { display: grid; grid-template-columns: 1fr 1fr 0.9fr 1fr 1fr; grid-template-rows: auto auto; gap: 10px; align-items: stretch; }
@media (max-width: 760px) { .mb-board { grid-template-columns: 1fr; } }
.mb-board .bucket { min-height: 170px; }
.mb-board .z-hazard { grid-column: 3; grid-row: 1; border-color: var(--hazard); }
.mb-board .z-top { grid-column: 3; grid-row: 2; border-color: var(--top); }
.mb-board .z-causes { grid-column: 1; grid-row: 1 / span 2; border-color: var(--cause); }
.mb-board .z-pc { grid-column: 2; grid-row: 1 / span 2; }
.mb-board .z-oc { grid-column: 4; grid-row: 1 / span 2; }
.mb-board .z-outcomes { grid-column: 5; grid-row: 1 / span 2; border-color: var(--outcome); }
.mb-board .z-reject { grid-column: 1 / -1; grid-row: 3; min-height: 80px; }
.mb-board.mb-noctl { grid-template-columns: 1fr 0.9fr 1fr; }
.mb-noctl .z-causes { grid-column: 1; } .mb-noctl .z-hazard, .mb-noctl .z-top { grid-column: 2; } .mb-noctl .z-outcomes { grid-column: 3; }
.mb-board.mb-ctlonly { grid-template-columns: 1fr 1fr; }
.mb-ctlonly .z-pc { grid-column: 1; grid-row: 1; } .mb-ctlonly .z-oc { grid-column: 2; grid-row: 1; } .mb-ctlonly .z-reject { grid-row: 2; }
@media (max-width: 760px) { .mb-board .bucket { grid-column: auto !important; grid-row: auto !important; } }
@media (max-width: 760px) { .mb-board.mb-noctl, .mb-board.mb-ctlonly { grid-template-columns: minmax(0, 1fr); } }
.mb { grid-template-columns: 280px minmax(0, 1fr); }
@media (max-width: 960px) { .mb { grid-template-columns: minmax(0, 1fr); } }

/* Quiz / assessment */
.score-ring { width: 160px; height: 160px; }
.assess-q { padding: 22px; }
.progress-line { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; margin: 10px 0 20px; }
.progress-line i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); width: 0; transition: width .3s; }
/* Certificate.  Styled as white paper in both themes, so the screen preview is what prints.
   Its colour tokens are fixed here rather than taken from the theme. */
.certificate {
  --text: #0d1a2e; --text-2: #33425c; --muted: #5d6c86; --cert-accent: #0d9488; --line: rgba(15, 30, 60, 0.14);
  background: #fff; color: var(--text); border-radius: 8px; padding: 12px; box-shadow: var(--shadow);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.cert-frame { position: relative; display: flex; flex-direction: column; border: 2px solid var(--cert-accent); border-radius: 4px; padding: 40px 48px 28px; text-align: center; }
.cert-frame::before { content: ""; position: absolute; inset: 5px; border: 1px solid rgba(13, 148, 136, 0.35); border-radius: 2px; pointer-events: none; }
.cert-brand { display: inline-flex; align-items: center; justify-content: center; gap: 10px; font-weight: 800; font-size: 1.2rem; letter-spacing: -0.01em; }
.cert-brand svg { width: 46px; height: 46px; flex: none; }
.cert-brand b { color: var(--cert-accent); font-weight: 800; }
.cert-kicker { margin-top: 26px; text-transform: uppercase; letter-spacing: 0.24em; font-size: 0.82rem; font-weight: 800; color: var(--cert-accent); }
.cert-lead { margin: 22px 0 6px; color: var(--muted); }
.cert-name { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 5vw, 2.9rem); font-weight: 700; letter-spacing: 0; color: var(--text); overflow-wrap: anywhere; }
.cert-rule { width: min(380px, 70%); height: 1px; margin: 16px auto 18px; background: rgba(15, 30, 60, 0.28); }
.cert-body { max-width: 600px; margin: 0 auto; color: var(--text-2); line-height: 1.65; text-wrap: balance; }
.cert-body b { color: var(--text); }
.cert-foot { display: flex; justify-content: space-between; gap: 24px; margin-top: 36px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 0.82rem; color: var(--muted); text-align: left; }
.cert-foot b { display: block; margin-top: 2px; font-size: 0.95rem; color: var(--text); }
.cert-foot > :last-child { text-align: right; }
@media (max-width: 560px) {
  .cert-frame { padding: 30px 18px 22px; }
  .cert-foot { flex-direction: column; gap: 12px; text-align: center; }
  .cert-foot > :last-child { text-align: center; }
}
@page certificate { size: A4 landscape; margin: 12mm; }
@media print {
  .site-header, .site-footer, .no-print { display: none !important; }
  html, body { background: #fff; }
  #main { max-width: none !important; padding: 0 !important; margin: 0 !important; }
  /* One landscape A4 page: 210 mm less 24 mm of margins, with a little slack against a spill-over page. */
  .certificate { page: certificate; display: flex; height: 184mm; margin: 0 !important; padding: 0; border-radius: 0; box-shadow: none; break-inside: avoid; }
  .cert-frame { flex: 1; justify-content: space-between; padding: 16mm 22mm 10mm; border-width: 1.6mm; }
  .cert-frame::before { inset: 2mm; }
  .cert-brand { font-size: 17pt; }
  .cert-brand svg { width: 15mm; height: 15mm; }
  .cert-kicker { margin-top: 9mm; font-size: 11pt; }
  .cert-lead { margin-top: 8mm; font-size: 12pt; }
  .cert-name { font-size: 38pt; }
  .cert-body { max-width: 190mm; font-size: 13pt; }
  .cert-foot { margin-top: 0; font-size: 9.5pt; }
  .cert-foot b { font-size: 11.5pt; }
}

/* Glossary */
.gloss-search { width: 100%; padding: 14px 18px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); color: var(--text); font: inherit; font-size: 1rem; margin-bottom: 20px; }
.gloss { display: grid; gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 760px) { .gloss { grid-template-columns: 1fr; } }
.gloss .term { padding: 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--c, var(--accent)); }
.gloss .term h3 { margin: 0 0 6px; font-size: 1.08rem; }
.gloss .term p { margin: 0 0 6px; color: var(--text-2); font-size: 0.95rem; }
.gloss .term .syn { font-size: 0.84rem; color: var(--muted); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: var(--surface-3); color: var(--text); border: 1px solid var(--line-2); padding: 12px 18px; border-radius: 12px; box-shadow: var(--shadow); opacity: 0; transition: all .3s; z-index: 200; font-weight: 700; font-size: 0.92rem; pointer-events: none; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Stage SVG element styles (used by lessons, hero, and diagrams) */
.stg text { font-family: var(--font); }
.stg .t-title { font-weight: 800; fill: #f1f5fb; letter-spacing: -0.5px; }
.stg .t-sub { fill: #93a7c6; font-weight: 500; }
.stg .t-body { fill: #d5dfee; font-weight: 500; }
.stg .t-dark { fill: #0b1527; font-weight: 700; }
.stg .t-light { fill: #f5f8fd; font-weight: 700; }
.stg .t-accent { fill: #2dd4bf; font-weight: 800; }
.stg .t-mono { font-family: var(--mono); }
.stg .ln { stroke: #7f93b4; stroke-width: 3; fill: none; stroke-linecap: round; }
.stg .ln-soft { stroke: rgba(148,170,205,.35); stroke-width: 2; fill: none; }
.stg .ln-dash { stroke-dasharray: 8 8; }

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