/* ============ The Classroom: theme ============ */
:root {
  --wall: #f2f5f3;
  --wall-2: #e4ebe7;
  --wood: #2a4436;
  --wood-dark: #1b2e24;
  --wood-light: #3e6050;
  --board: #2a4d3c;
  --frame: #c98a2b;        /* amber board frame */
  --frame-light: #f0c46a;
  --frame-dark: #8a5a17;
  --board-2: #26402f;
  --chalk: #f4f1e8;
  --chalk-dim: rgba(244, 241, 232, 0.72);
  --chalk-yellow: #f3e38a;
  --chalk-pink: #f5a8b8;
  --chalk-blue: #a9d4f5;
  --chalk-green: #b6e3a8;
  --paper: #fdfdfc;
  --paper-line: #c9dcef;
  --margin: #e8a0a0;
  --ink: #1f2a44;
  --ink-soft: #4a5571;
  --sticky: #fff0a0;
  --sticky-pink: #ffd3dc;
  --sticky-blue: #cfe7ff;
  --good: #2f7d4a;
  --bad: #b23a3a;
  --warn: #a8650f;
  --radius: 10px;
  --shadow: 0 2px 0 rgba(0,0,0,.08), 0 10px 24px rgba(20,35,45,.14);
  --font-math: 'Cambria Math', 'STIX Two Math', 'Latin Modern Math', 'Times New Roman', Georgia, serif;
  --font-body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-chalk: 'Patrick Hand', 'Caveat', 'Comic Sans MS', cursive;
  --font-script: 'Caveat', 'Patrick Hand', cursive;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  font: 16px/1.6 var(--font-body);
  background-color: var(--wall);
  background-image:
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.45), transparent 40%),
    repeating-linear-gradient(90deg, rgba(0,0,0,.018) 0 2px, transparent 2px 70px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: min(1180px, 100% - 32px); margin: 0 auto; padding: 22px 0 60px; outline: none; }
a { color: inherit; }
code { font-family: var(--font-mono); font-size: .88em; background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 4px; }
mark { background: var(--chalk-yellow); padding: 0 3px; border-radius: 3px; }
.small { font-size: .88rem; }
.muted { color: var(--ink-soft); }
.loading { font-family: var(--font-chalk); font-size: 1.6rem; text-align: center; padding: 80px 0; color: var(--ink-soft); }

/* ---------- header: the wooden shelf ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  padding: 10px max(16px, calc((100% - 1180px) / 2));
  background: linear-gradient(180deg, var(--wood-light), var(--wood) 60%, var(--wood-dark));
  border-bottom: 4px solid var(--wood-dark);
  box-shadow: 0 4px 12px rgba(20,35,45,.25);
  color: #f1f5f7;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.brand-bell { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 50%; background: rgba(255,255,255,.14); }
.brand-name { display: block; font-family: var(--font-script); font-weight: 700; font-size: 1.75rem; line-height: 1; }
.brand-tag { display: block; font-size: .78rem; opacity: .85; letter-spacing: .03em; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-weight: 700; font-size: .95rem; }
.crumbs a { text-decoration: none; opacity: .85; }
.crumbs a:hover { opacity: 1; text-decoration: underline; }
.crumbs .sep { opacity: .55; }

.site-footer { text-align: center; padding: 18px; font-size: .85rem; color: var(--ink-soft); display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.linkish { background: none; border: 0; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  font: 700 .95rem var(--font-body); color: var(--ink); text-decoration: none;
  background: var(--paper); border: 2px solid var(--ink); border-radius: 999px;
  padding: 7px 16px; cursor: pointer; box-shadow: 0 3px 0 var(--ink);
  transition: transform .08s, box-shadow .08s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 0 var(--ink); }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.btn-chalk { background: var(--board); color: var(--chalk); border-color: var(--board-2); box-shadow: 0 3px 0 #13241a; }
.btn-chalk:hover { box-shadow: 0 4px 0 #13241a; }
.btn-again { background: var(--sticky-pink); }
.small-btn { padding: 3px 12px; font-size: .8rem; margin-left: auto; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; align-items: center; }
.btn-row.center { justify-content: center; }

/* ---------- chalkboards ---------- */
.board {
  position: relative;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,255,255,.07), transparent 55%),
    radial-gradient(ellipse at 80% 90%, rgba(255,255,255,.04), transparent 50%),
    var(--board);
  color: var(--chalk);
  border: 12px solid var(--frame);
  border-image: linear-gradient(135deg, var(--frame-light), var(--frame) 45%, var(--frame-dark)) 1;
  box-shadow: inset 0 0 40px rgba(0,0,0,.35), var(--shadow);
}
.board-inner { padding: 26px 32px 24px; }
.board a { color: var(--chalk-yellow); }
.board code { background: rgba(255,255,255,.1); color: var(--chalk-yellow); }
.board strong { color: var(--chalk-yellow); font-weight: 700; }
.board mark { background: rgba(243,227,138,.25); color: var(--chalk); }
/* paper panels and buttons sitting on a board keep ink colours */
.board .paper, .board .btn:not(.btn-chalk) { color: var(--ink); }
.board .paper code { background: rgba(0,0,0,.06); color: var(--ink); }
.board .paper strong { color: var(--ink); }
.board .paper .lab-msg.good { color: var(--good); }
.board .paper .lab-msg.bad { color: var(--bad); }
.board .paper .lab-msg.warn { color: var(--warn); }
.board .btn-chalk { color: var(--chalk); }
.chalk-title { font-family: var(--font-chalk); font-weight: 400; font-size: clamp(1.7rem, 3.4vw, 2.5rem); line-height: 1.15; margin: 0 0 6px; letter-spacing: .01em; text-shadow: 0 0 1px rgba(255,255,255,.4); }
.chalk-sub { font-size: 1.08rem; color: var(--chalk-dim); margin: 0 0 14px; }
.chalk-h { font-family: var(--font-chalk); font-weight: 400; font-size: 1.4rem; color: var(--chalk-yellow); margin: 18px 0 4px; }
.chalk-list { padding-left: 1.3em; margin: 8px 0 12px; }
.chalk-list li { margin: 5px 0; }
.chalk-list li::marker { color: var(--chalk-yellow); }
.chalk-line { margin: 10px 0 0; }
.formula {
  font-family: var(--font-math); font-size: 1.2rem; color: var(--chalk-yellow);
  background: rgba(0,0,0,.18); border: 1px dashed rgba(243,227,138,.45); border-radius: 8px;
  padding: 12px 16px; margin: 12px 0; overflow-x: auto; white-space: pre-wrap;
}
.formula-cap { font-family: var(--font-body); font-size: .85rem; color: var(--chalk-dim); margin-top: 6px; }
.paper .formula, .notebook .formula, .lab-card .formula { color: var(--ink); background: #f1f5f6; border-color: #b6c4ca; }
.table-wrap { overflow-x: auto; }
.chalk-table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: .95rem; }
.chalk-table th, .chalk-table td { border-bottom: 1px solid rgba(244,241,232,.25); padding: 7px 10px; text-align: left; vertical-align: top; }
.chalk-table th { font-family: var(--font-chalk); font-weight: 400; font-size: 1.1rem; color: var(--chalk-yellow); border-bottom: 2px solid rgba(244,241,232,.5); }
.chalk-table tr.sum td { border-top: 2px solid rgba(244,241,232,.5); color: var(--chalk-yellow); }
.board-count { position: absolute; top: 10px; right: 16px; font-family: var(--font-chalk); color: var(--chalk-dim); }
.board-ledge {
  display: flex; justify-content: space-between; gap: 10px; padding: 12px 18px;
  background: linear-gradient(180deg, var(--wood-light), var(--wood)); border-top: 3px solid var(--wood-dark);
}
.board-title { font-family: var(--font-chalk); font-size: 1.15rem; color: var(--chalk-yellow); padding: 10px 14px 0; }
.board-note { font-size: .85rem; color: var(--chalk-dim); margin: 0 14px 10px; }
.board.mini { border-width: 8px; }
.board.mini canvas { display: block; width: 100%; padding: 4px 6px 8px; }

/* sticky notes & traps */
.sticky {
  position: relative; background: var(--sticky); color: var(--ink);
  padding: 14px 16px 12px; margin: 16px 6px; border-radius: 2px;
  transform: rotate(-.8deg); box-shadow: 0 8px 14px rgba(0,0,0,.25);
  font-size: .97rem;
}
.sticky::before { content: ''; position: absolute; top: -9px; left: 50%; width: 70px; height: 18px; transform: translateX(-50%) rotate(2deg); background: rgba(255,255,255,.55); border: 1px solid rgba(0,0,0,.06); }
.sticky.pink { background: var(--sticky-pink); transform: rotate(.7deg); }
.sticky.blue { background: var(--sticky-blue); transform: rotate(-.4deg); }
.sticky.red { background: #ff9d9d; border: 2px solid #c0222d; transform: rotate(-.3deg); }
.sticky.red .sticky-label { color: #8a1119; font-weight: 700; }
.sticky ul { margin: 4px 0 0; padding-left: 1.2em; }
.sticky strong { color: var(--ink); }
.sticky code { background: rgba(0,0,0,.08); color: var(--ink); }
.sticky-label { font-family: var(--font-script); font-weight: 700; font-size: 1.35rem; line-height: 1; margin-bottom: 4px; }
.trap { border: 2px dashed var(--chalk-pink); border-radius: 10px; padding: 10px 14px; margin: 14px 0; background: rgba(245,168,184,.08); }
.trap-label { font-family: var(--font-chalk); color: var(--chalk-pink); font-size: 1.2rem; }
.trap strong { color: var(--chalk-pink); }

/* ---------- page titles ---------- */
.room-title { font-family: var(--font-script); font-size: clamp(2rem, 4.5vw, 2.9rem); line-height: 1.05; margin: 0; }
.room-sub { margin: 4px 0 0; color: var(--ink-soft); font-weight: 600; }
.eyebrow { margin: 0; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; color: var(--wood); }
.cork-title { font-family: var(--font-script); font-size: 2rem; margin: 0 0 16px; color: var(--wood-dark); background: var(--paper); display: inline-block; padding: 0 16px; transform: rotate(-1deg); box-shadow: 0 3px 6px rgba(0,0,0,.2); }
.stars { color: #e1a924; font-size: 1.15rem; letter-spacing: 2px; text-shadow: 0 1px 0 rgba(0,0,0,.2); }
.stars .off { color: rgba(0,0,0,.18); text-shadow: none; }

/* ---------- chapter: head + desk tabs ---------- */
.lesson-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 14px; }
.report-card { background: var(--paper); border: 2px solid var(--ink); border-radius: 8px; padding: 8px 14px; display: flex; align-items: center; gap: 10px; box-shadow: 0 3px 0 var(--ink); }
.rc-label { font-family: var(--font-script); font-weight: 700; font-size: 1.25rem; }
.rc-pct { font-weight: 800; }
.desk-tabs { display: flex; flex-wrap: wrap; gap: 6px; border-bottom: 4px solid var(--wood); padding-left: 6px; margin-bottom: 22px; }
.desk-tab {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none; font-weight: 800; font-size: .95rem;
  padding: 9px 16px 7px; background: var(--wall-2); border: 2px solid var(--wood); border-bottom: 0;
  border-radius: 10px 10px 0 0; color: var(--wood-dark); position: relative; top: 4px;
}
.desk-tab .ti { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.08); font-size: .85rem; }
.desk-tab:hover { background: var(--paper); }
.desk-tab.on { background: var(--paper); color: var(--ink); border-color: var(--wood-dark); border-bottom: 4px solid var(--paper); }
.tab-intro { color: var(--ink-soft); margin: 0 0 16px; max-width: 760px; }

/* lesson layout */
.lesson-layout { display: grid; grid-template-columns: 250px 1fr; gap: 22px; align-items: start; }
.clipboard { position: sticky; top: 90px; background: var(--wood-light); padding: 26px 10px 12px; border-radius: 10px; box-shadow: var(--shadow); }
.clipboard .clip { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); width: 80px; height: 26px; border-radius: 6px; background: linear-gradient(180deg, #d9d9d9, #8f8f8f); border: 2px solid #666; }
.clipboard summary { list-style: none; cursor: pointer; }
.clipboard summary::-webkit-details-marker { display: none; }
.clipboard h3 { margin: 0; padding: 12px 14px 4px; background: var(--paper); font-family: var(--font-script); font-size: 1.5rem; }
.clipboard ol { margin: 0; padding: 4px 10px 14px 34px; background: var(--paper); font-size: .92rem; counter-reset: none; }
.clipboard li { padding: 4px 0; border-bottom: 1px solid var(--paper-line); }
.clipboard li a { text-decoration: none; }
.clipboard li.on a { font-weight: 800; color: var(--board); }
.clipboard li.done::marker { content: '✓  '; color: var(--good); font-weight: 800; }
.big-board .board-inner { min-height: 420px; }
.board-content p { margin: 10px 0; }
.board-content > .widget-slot { margin: 18px 0; color: var(--ink); }

/* ---------- worked problems: notebooks ---------- */
.notebooks { display: grid; gap: 26px; }
.notebook {
  position: relative; padding: 18px 22px 18px 64px; border-radius: 4px; box-shadow: var(--shadow);
  background: var(--paper) repeating-linear-gradient(180deg, transparent 0 27px, var(--paper-line) 27px 28px);
  background-position: 0 6px;
}
.notebook::before { content: ''; position: absolute; top: 0; bottom: 0; left: 46px; border-left: 2px solid var(--margin); }
.notebook::after { content: ''; position: absolute; top: 18px; bottom: 18px; left: 14px; width: 14px; background: radial-gradient(circle, var(--wall) 5px, transparent 6px) 0 0 / 14px 46px repeat-y; }
.notebook header { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.nb-num { font-family: var(--font-script); font-weight: 700; font-size: 1.4rem; color: var(--margin); }
.tag { font-size: .75rem; font-weight: 800; background: var(--sticky-blue); padding: 1px 8px; border-radius: 999px; }
.tick { font-weight: 800; color: var(--good); margin-left: auto; }
.notebook h3 { font-family: var(--font-chalk); font-weight: 400; font-size: 1.55rem; margin: 2px 0 6px; line-height: 1.2; }
.nb-problem p { margin: 6px 0; }
.nb-steps { list-style: none; padding: 0; margin: 10px 0 0; }
.nb-step[hidden], .nb-answer[hidden], .feedback[hidden], .grade[hidden] { display: none !important; }
.nb-step { display: grid; grid-template-columns: 150px 1fr; gap: 12px; padding: 8px 0; border-top: 1px dashed #cfd8dd; }
.step-label { font-family: var(--font-script); font-weight: 700; font-size: 1.25rem; color: #2d5fb8; line-height: 1.2; }
.nb-answer { margin-top: 12px; padding: 10px 14px; background: #e8f4e2; border: 2px solid var(--good); border-radius: 8px; }
/* solution flowchart: one box per step label, arrows between, boxes fill in as steps are revealed */
.nb-flow { margin: 12px 0 4px; padding: 10px 12px 12px; background: #f0f4f6; border: 1.5px dashed #b6c4ca; border-radius: 8px; }
.flow-title { display: block; font-family: var(--font-script); font-weight: 700; font-size: 1.15rem; color: var(--ink-soft); margin-bottom: 6px; }
.nb-flow ol { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; row-gap: 10px; }
.nb-flow li { display: flex; align-items: center; min-width: 0; }
.nb-flow li + li::before { content: '→'; color: var(--ink-soft); font-weight: 800; padding: 0 6px; }
.fl-box {
  font: inherit; font-size: .85rem; font-weight: 700; line-height: 1.25; text-align: left;
  display: inline-flex; align-items: center; gap: 6px; max-width: 15rem; padding: 6px 10px;
  color: var(--ink-soft); background: var(--paper); border: 2px dashed #a7b6be; border-radius: 8px; cursor: pointer;
}
.fl-box:hover, .fl-box:focus-visible { border-color: #2d5fb8; color: var(--ink); outline: none; }
.fl-n { flex: none; display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; background: #dae2e7; font-size: .75rem; }
.fl-box.next { border-style: solid; border-color: #2d5fb8; color: var(--ink); box-shadow: 0 0 0 3px rgba(45, 95, 184, .15); }
.fl-box.done { border-style: solid; border-color: var(--good); background: #e8f4e2; color: var(--ink); }
.fl-box.done .fl-n { background: var(--good); color: #fff; }
.fl-end { cursor: default; border-radius: 999px; }
.fl-end.done { background: var(--good); color: #fff; }
@media (max-width: 600px) {
  .nb-flow { padding: 8px; }
  .nb-flow ol { row-gap: 8px; }
  .nb-flow li + li::before { padding: 0 4px; }
  .fl-box { font-size: .8rem; padding: 5px 8px; max-width: 11rem; }
}
@media print { .nb-flow { display: none; } }
.chalk-in { animation: chalkin .5s ease-out; }
@keyframes chalkin { from { opacity: 0; transform: translateY(-4px); filter: blur(2px); } to { opacity: 1; transform: none; filter: none; } }

/* ---------- labs ---------- */
.labs { display: grid; gap: 34px; }
.lab-card { background: rgba(255,255,255,.35); border: 2px dashed var(--wood-light); border-radius: 14px; padding: 18px 20px 22px; }
.lab-title { font-family: var(--font-script); font-size: 2rem; margin: 0 0 4px; }
.lab { display: grid; gap: 16px; }
.lab-controls { padding: 16px 18px; }
.paper { background: var(--paper); border-radius: 8px; box-shadow: var(--shadow); color: var(--ink); }
.field { display: flex; flex-direction: column; gap: 4px; font-weight: 700; font-size: .9rem; margin-bottom: 10px; flex: 1; min-width: 180px; }
.field input, .field textarea, .field select { font: 1rem var(--font-mono); padding: 8px 10px; border: 2px solid #b6c4ca; border-radius: 6px; background: #ffffff; color: var(--ink); }
.field input[type="checkbox"] { width: auto; padding: 0; margin-right: 6px; accent-color: var(--board); }
.field input[type="range"] { padding: 0; accent-color: var(--board); }
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid var(--chalk-blue); border-color: var(--ink); }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.lab-msg { font-weight: 700; margin: 8px 0 0; min-height: 1.2em; }
.lab-msg.good { color: var(--good); }
.lab-msg.bad { color: var(--bad); }
.lab-msg.warn { color: var(--warn); }
.board .lab-msg.good { color: var(--chalk-green); }
.board .lab-msg.bad { color: var(--chalk-pink); }
.lab-boards { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.trace-board .trace, .board > .trace { padding: 6px 16px 16px; }
.trace-row { display: flex; flex-wrap: wrap; gap: 18px 22px; align-items: flex-start; }
.trace-item .lbl { font-family: var(--font-chalk); color: var(--chalk-yellow); font-size: 1.05rem; margin-bottom: 4px; }
.mat { display: inline-block; position: relative; padding: 2px 8px; border-left: 2px solid var(--chalk); border-right: 2px solid var(--chalk); border-radius: 6px; }
.mat table { border-collapse: collapse; }
.mat td { font-family: var(--font-mono); font-size: .9rem; padding: 1px 7px; text-align: right; }
.history { padding: 10px 16px; }
.history summary { cursor: pointer; font-weight: 800; }
.ruled { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: .88rem; margin-top: 8px; }
.ruled th, .ruled td { border-bottom: 1px solid var(--paper-line); padding: 4px 8px; text-align: right; }
.ruled th { font-family: var(--font-body); }
.readout p { margin: 6px 0; }
.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 14px 0 4px; }
.metric { border: 1px dashed rgba(244,241,232,.4); border-radius: 8px; padding: 8px 12px; display: flex; flex-direction: column; }
.metric span { font-family: var(--font-chalk); color: var(--chalk-yellow); font-size: 1.1rem; }
.metric b { font-family: var(--font-mono); font-size: 1.4rem; }
.metric small { color: var(--chalk-dim); }
.widget-missing { padding: 14px; background: var(--sticky-pink); border-radius: 8px; color: var(--ink); }

/* ---------- flashcards ---------- */
.cards-wrap { max-width: 640px; margin: 0 auto; }
.cards-top { display: flex; justify-content: space-between; font-weight: 800; color: var(--ink-soft); margin-bottom: 10px; }
.flashcard { display: block; width: 100%; height: 320px; perspective: 1200px; background: none; border: 0; padding: 0; cursor: pointer; font: inherit; color: inherit; position: relative; }
.flashcard .face {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 10px;
  padding: 34px 30px; backface-visibility: hidden; border-radius: 6px; box-shadow: 0 10px 22px rgba(0,0,0,.25);
  background: var(--paper) repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px); background-position: 0 56px;
  border-top: 4px solid var(--margin); transition: transform .5s;
}
.flashcard .back { transform: rotateY(180deg); background-color: #f6f9fb; }
.flashcard.flipped .front { transform: rotateY(-180deg); }
.flashcard.flipped .back { transform: rotateY(0); }
.fc-tag { position: absolute; top: 12px; left: 16px; font-weight: 800; font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--margin); }
.fc-q { font-family: var(--font-chalk); font-size: 1.65rem; line-height: 1.3; }
.fc-a { font-size: 1.08rem; line-height: 1.55; }
.fc-hint { position: absolute; bottom: 12px; font-size: .8rem; color: var(--ink-soft); }
.done-card { cursor: default; }

/* ---------- quiz: exam paper ---------- */
.exam-paper {
  max-width: 860px; margin: 0 auto; padding: 26px 34px 30px 70px; position: relative; box-shadow: var(--shadow);
  background: var(--paper) repeating-linear-gradient(180deg, transparent 0 29px, var(--paper-line) 29px 30px); background-position: 0 14px;
}
.exam-paper::before { content: ''; position: absolute; top: 0; bottom: 0; left: 52px; border-left: 2px solid var(--margin); }
.exam-head { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px; font-family: var(--font-chalk); font-size: 1.25rem; border-bottom: 2px solid var(--ink); padding-bottom: 6px; margin-bottom: 12px; }
.exam-q { border: 0; margin: 0 0 18px; padding: 8px 0; position: relative; min-width: 0; }
.exam-q legend { font-weight: 700; padding: 0; margin-bottom: 6px; float: left; width: 100%; }
.exam-q legend + * { clear: both; }
.qn { position: absolute; left: -50px; top: 4px; font-family: var(--font-script); font-weight: 700; font-size: 1.35rem; line-height: 1.2; color: #2d5fb8; white-space: nowrap; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 5px 10px; border-radius: 6px; cursor: pointer; }
.opt:hover { background: rgba(169,212,245,.3); }
.opt input { margin-top: 5px; accent-color: var(--board); }
.opt.right { background: #e3f3dc; outline: 2px solid var(--good); }
.opt.wrong { background: #f8e0e0; outline: 2px solid var(--bad); text-decoration: line-through; }
.num-ans input { font: 1rem var(--font-mono); padding: 6px 10px; width: 160px; border: 2px solid #b6c4ca; border-radius: 6px; margin-left: 6px; }
.feedback { margin-top: 8px; padding: 8px 12px; border-radius: 6px; font-size: .95rem; }
.is-right .feedback { background: #e8f4e2; border-left: 4px solid var(--good); }
.is-wrong .feedback { background: #fbeaea; border-left: 4px solid var(--bad); }
.is-right .qn::after { content: '✓'; display: block; color: var(--good); }
.is-wrong .qn::after { content: '✗'; display: block; color: var(--bad); }
.grade { text-align: center; margin-top: 20px; }
.grade-circle { display: inline-grid; place-items: center; width: 110px; height: 110px; border-radius: 50%; border: 4px solid var(--bad); color: var(--bad); font-family: var(--font-script); font-size: 2.6rem; font-weight: 700; transform: rotate(-10deg); }

/* ---------- cheat sheet ---------- */
.cheat-sheet { max-width: 900px; margin: 0 auto; background: var(--paper); box-shadow: var(--shadow); padding: 18px 24px 24px; border-top: 6px solid var(--board); }
.cs-head { display: flex; align-items: center; gap: 10px; font-family: var(--font-chalk); font-size: 1.4rem; margin-bottom: 10px; }
.cs-table { width: 100%; border-collapse: collapse; }
.cs-table th { text-align: left; vertical-align: top; width: 30%; padding: 10px 12px 10px 0; font-weight: 800; border-bottom: 1px solid var(--paper-line); }
.cs-table td { padding: 10px 0; border-bottom: 1px solid var(--paper-line); }
.cs-f { font-family: var(--font-math); font-size: 1.12rem; }
.cs-note { font-size: .85rem; color: var(--ink-soft); margin-top: 3px; }

/* ---------- responsive & print ---------- */
@media (max-width: 860px) {
  .lesson-layout { grid-template-columns: 1fr; }
  .clipboard { position: static; }
  .clipboard h3::after { content: ' ▾'; font-size: 1rem; }
  .clipboard:not([open]) h3 { border-radius: 0 0 4px 4px; }
  .board-inner { padding: 22px 18px; }
  .nb-step { grid-template-columns: 1fr; gap: 2px; }
  .notebook { padding-left: 54px; }
  .exam-paper { padding: 20px 16px 24px 56px; }
  .exam-paper::before { left: 40px; }
  .qn { left: -40px; font-size: 1.1rem; }
}
@media (max-width: 520px) {
  .site-header { gap: 8px; }
  .brand-tag { display: none; }
  .board { border-width: 8px; }
  .flashcard { height: 360px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
@media print {
  .site-header, .site-footer, .desk-tabs, .lesson-head, .btn, .crumbs { display: none !important; }
  body { background: #fff; }
  .cheat-sheet { box-shadow: none; }
}
.clipboard h3 small { font-family: var(--font-body); font-size: .75rem; font-weight: 600; }

/* quiz set picker */
.quiz-sets { flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.quiz-sets .small-btn { margin-left: 0; }

/* tree diagram block */
.tree-wrap { margin: 12px 0; overflow-x: auto; }
.tree, .tree ul { list-style: none; margin: 0; padding-left: 0; }
.tree ul { margin-left: 14px; padding-left: 14px; border-left: 2px solid rgba(244,241,232,.35); }
.tree li { position: relative; margin: 6px 0; }
.tree ul > li::before { content: ''; position: absolute; left: -14px; top: 15px; width: 12px; border-top: 2px solid rgba(244,241,232,.35); }
.tn-box { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 4px 10px; border: 1.5px solid rgba(244,241,232,.5); border-radius: 8px; max-width: 100%; }
.tn-label { font-weight: 600; }
.tn-count { font-family: var(--font-chalk); color: var(--chalk-yellow); font-size: 1.05rem; }
.tn-note { font-size: .85rem; opacity: .8; flex-basis: 100%; }
.tn.root > .tn-box { border-color: var(--chalk-yellow); }
.tn.group > .tn-box { border-style: dashed; }
.tn.leaf > .tn-box { border-color: rgba(244,241,232,.3); }

.tab-subhead { font-family: var(--font-chalk); font-size: 1.5rem; margin: 26px 0 8px; }

/* ---------- mobile friendly ---------- */
/* Grid/flex children may shrink below their content width, so nothing pushes the page sideways. */
.lesson-layout > *, .lab > *, .lab-boards > *, .lab-card, .course-grid > *, .chapter-grid > * { min-width: 0; }
.lab-boards { grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.metric-grid { grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr)); }
.field { min-width: min(180px, 100%); }
canvas, img, svg, video { max-width: 100%; }
.clipboard li, .chalk-title, .lab-title { overflow-wrap: anywhere; }

@media (max-width: 600px) {
  main { width: calc(100% - 20px); padding: 14px 0 40px; }

  /* compact header: brand + one scrollable line of breadcrumbs */
  .site-header { gap: 4px 10px; padding: 8px 12px; }
  .brand-bell { width: 34px; height: 34px; }
  .brand-bell svg { width: 24px; height: 24px; }
  .brand-name { font-size: 1.4rem; }
  .crumbs { width: 100%; flex-wrap: nowrap; overflow-x: auto; white-space: nowrap; font-size: .85rem; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .crumbs::-webkit-scrollbar { display: none; }

  /* chapter tabs: a 3 x 2 grid of buttons instead of wrapping folder tabs */
  .desk-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 0; border-bottom: 0; margin-bottom: 16px; }
  .desk-tab { justify-content: center; text-align: center; top: 0; border: 2px solid var(--wood); border-radius: 8px; padding: 9px 4px; font-size: .8rem; line-height: 1.15; min-height: 44px; }
  .desk-tab .ti { display: none; }
  .desk-tab.on { border: 2px solid var(--ink); box-shadow: 0 3px 0 var(--ink); }

  .lesson-head { gap: 10px; }
  .report-card { width: 100%; justify-content: space-between; }

  /* tighter boards, notebooks and papers */
  .board-inner { padding: 18px 14px; }
  .board { border-width: 7px; }
  .lab-card { padding: 14px 12px 16px; }
  .lab-title { font-size: 1.6rem; }
  .lab-controls { padding: 12px; }
  .notebook { padding: 14px 12px 14px 40px; }
  .exam-paper { padding: 16px 12px 20px 44px; }
  .exam-paper::before { left: 32px; }
  .qn { left: -36px; font-size: 1rem; }
  .num-ans input { width: 100%; margin: 6px 0 0; }

  /* tables the widgets draw without a scroll wrapper: let them scroll sideways */
  .lab-card table, .board-inner table, .notebook table, .exam-paper table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .chalk-table th, .chalk-table td { padding: 6px 8px; }

  /* cheat sheet rows stack: label above formula */
  .cs-table th, .cs-table td { display: block; width: auto; padding: 6px 0; }
  .cs-table th { border-bottom: 0; padding-top: 12px; }

  .cheat-sheet { padding: 14px 14px 18px; }
  .cs-head { display: block; font-size: 1.2rem; line-height: 1.3; }
  .cs-head b { white-space: nowrap; }
  .cs-head .btn { display: flex; margin-top: 8px; }
  .btn-row .btn { flex: 1 1 auto; justify-content: center; }
  .flashcard { height: 380px; }
}

/* iPhone (Safari iOS) horizontal-scroll guards */
html, body { overflow-x: clip; }
main, .site-header, .site-footer { max-width: 100vw; overflow-x: clip; }
.flashcard { overflow: clip; }              /* 3-D flip can project past the edge mid-turn */
input, select, textarea { font-size: max(16px, 1em); }  /* stop iOS zooming in on focus */
/* tablets: widget tables (softmax / MLP calculators) scroll inside their card instead of widening the page */
@media (max-width: 900px) {
  .lab-card table, .board-inner table, .notebook table, .exam-paper table { display: block; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
/* worked-problem notebooks: let them shrink to the column; long formulas wrap or scroll inside */
.notebooks > *, .family-worked > * { min-width: 0; }
.notebook { overflow-wrap: anywhere; }
.notebook .formula { max-width: 100%; overflow-x: auto; }
@media (max-width: 600px) {
  .notebook::before { left: 32px; }   /* keep the red margin line left of the text */
  .notebook::after { left: 9px; }
}
/* tree map at the top of Worked problems and each test-type tab (collapsible) */
.tree-map { margin-bottom: 22px; }
.tree-map > summary { cursor: pointer; list-style: none; padding: 16px 22px 0; }
.tree-map > summary::-webkit-details-marker { display: none; }
.tree-map > summary::after { content: ' ▾'; font-size: .8em; opacity: .7; }
.tree-map:not([open]) > summary { padding-bottom: 16px; }
.tree-map:not([open]) > summary::after { content: ' ▸'; }
.tree-map > .board-inner { padding-top: 6px; }
@media (max-width: 600px) { .tree-map > summary { padding: 14px 14px 0; } }
.family-links { flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.family-links .btn { text-decoration: none; }

/* readable maths: stacked fractions, roots, sub/superscripts (see mathMarkup in js/core/util.js) */
.fr { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; margin: 0 .3em; line-height: 1.3; }
.fr > .fn { border-bottom: 1.6px solid currentColor; padding: 0 .4em .12em; white-space: nowrap; }
.fr > .fd { padding: .12em .4em 0; white-space: nowrap; }
.rad { display: inline-flex; align-items: stretch; vertical-align: middle; margin: 0 .15em; }
.rsym { font-size: 1.3em; line-height: 1; margin-right: 1px; }
.rbody { border-top: 1.6px solid currentColor; padding: .1em .3em 0 .2em; margin-top: .22em; white-space: nowrap; }
sub, sup { font-size: .72em; line-height: 0; }
sup { white-space: nowrap; }

/* calculation tables inside step text */
.md-table-wrap { overflow-x: auto; margin: 8px 0; }
.md-table { border-collapse: collapse; font-size: .92rem; min-width: 60%; }
.md-table th, .md-table td { border: 1px solid rgba(128,128,128,.4); padding: 4px 9px; text-align: right; white-space: nowrap; }
.md-table th { background: rgba(128,128,128,.14); font-weight: 600; }
.md-table th:first-child, .md-table td:first-child { text-align: left; }
.md-table th { text-align: center; }
.md-table tr.total { font-weight: 700; background: rgba(128,128,128,.10); }
.md-list { margin: 4px 0; padding-left: 1.4em; }
.md-list li { margin: 2px 0; }

/* course page: exam weightage tables */
.weightage { background: #ffffff; border: 1px solid #d3dde2; border-radius: 12px; padding: 16px 18px; margin: 18px 0; box-shadow: 0 2px 0 rgba(0,0,0,.05); }
.wt-title { font-family: var(--font-chalk, inherit); margin: 0 0 6px; font-size: 1.35rem; }
.weightage > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; list-style: none; }
.weightage > summary::-webkit-details-marker { display: none; }
.weightage > summary .wt-title { margin: 0; }
.weightage[open] > summary { margin-bottom: 6px; }
.wt-toggle { flex: none; }
.wt-toggle::before { content: '▴ Minimise'; }
.weightage:not([open]) .wt-toggle::before { content: '▾ Show'; }
.weightage:not([open]) { padding-top: 10px; padding-bottom: 10px; }
.wt-sub { margin: 16px 0 6px; font-size: 1.05rem; }
.wt-intro, .wt-note { font-size: .92rem; opacity: .85; margin: 4px 0 8px; }
.wt-table th, .wt-table td { font-size: .88rem; }
.wt-table td.wt-left, .wt-table th:first-child { text-align: left; }
.wt-table tbody tr:last-child { font-weight: inherit; background: none; }
.wt-table tbody tr.wt-total { font-weight: 700; }
.wt-table th.wt-left { text-align: left; }
.wt-table th, .wt-table td { padding: 4px 8px; }

/* ---------- left navigation bar ---------- */
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nav-toggle {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; margin-right: -10px;
  font-size: 1.3rem; color: inherit; background: rgba(255,255,255,.12); border: 1.5px solid rgba(255,255,255,.3);
  border-radius: 8px; cursor: pointer;
}
.nav-toggle:hover, .nav-toggle[aria-expanded="true"] { background: rgba(255,255,255,.24); }
.side-nav {
  --nav-w: 264px;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 15; width: var(--nav-w);
  padding: 86px 10px 24px; overflow-y: auto; overscroll-behavior: contain;
  background: #f6f8f9; border-right: 1px solid #d3dde2; box-shadow: 2px 0 10px rgba(20,35,45,.06);
  font-size: .88rem; line-height: 1.3;
  transform: translateX(-100%); visibility: hidden; transition: transform .2s ease, visibility .2s;
}
body.nav-open .side-nav, body.nav-drawer .side-nav { transform: none; visibility: visible; }
body.nav-open main, body.nav-open .site-footer {
  width: min(1180px, 100% - 264px - 40px);
  margin-left: calc(264px + max(20px, (100% - 264px - 1180px) / 2));
}
body.nav-drawer .side-nav { z-index: 40; padding-top: 16px; box-shadow: 4px 0 24px rgba(20,35,45,.3); }
.nav-scrim { position: fixed; inset: 0; z-index: 35; background: rgba(20,35,45,.4); }
.nav-scrim[hidden] { display: none; }
.side-nav a { text-decoration: none; color: var(--ink); }
.sn-home { display: block; font-weight: 800; padding: 6px 10px; border-radius: 6px; margin-bottom: 6px; }
.sn-sem { font-size: .72rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); padding: 10px 10px 4px; }
.sn-course > summary { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px; cursor: pointer; font-weight: 800; list-style: none; }
.sn-course > summary::-webkit-details-marker { display: none; }
.sn-dot { flex: none; width: 10px; height: 10px; border-radius: 3px; background: var(--door); }
.sn-course ol { list-style: none; margin: 2px 0 8px; padding: 0 0 0 12px; border-left: 2px solid #dbe3e8; margin-left: 12px; }
.sn-course li a, .sn-soon { display: flex; gap: 8px; padding: 5px 8px; border-radius: 6px; }
.sn-num { flex: none; min-width: 1.4em; color: var(--ink-soft); font-weight: 700; }
.sn-soon { color: #8a9aa6; cursor: default; }
.side-nav a:hover { background: #e6ecef; }
.side-nav a.on { background: var(--board); color: var(--chalk); }
.side-nav a.on .sn-num { color: var(--chalk-yellow); }

/* ---------- floating "on this page" button ---------- */
.page-nav { position: fixed; right: 20px; bottom: 20px; z-index: 30; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.page-nav[hidden], .page-nav-menu[hidden] { display: none; }
.page-nav-fab {
  width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  font-size: 1.5rem; color: var(--chalk); background: var(--board); border: 3px solid var(--wood-dark);
  box-shadow: 0 4px 14px rgba(20,35,45,.35);
}
.page-nav-fab:hover, .page-nav-fab[aria-expanded="true"] { background: var(--board-2); transform: translateY(-1px); }
.page-nav-menu {
  width: min(340px, calc(100vw - 40px)); max-height: min(60vh, 520px); overflow-y: auto; overscroll-behavior: contain;
  background: #fff; border: 1px solid #d3dde2; border-radius: 12px; padding: 8px; box-shadow: 0 10px 30px rgba(20,35,45,.25);
}
.pn-head { font-family: var(--font-script); font-weight: 700; font-size: 1.25rem; padding: 2px 8px 6px; color: var(--ink-soft); }
.page-nav-menu button {
  display: block; width: 100%; text-align: left; font: 600 .88rem/1.3 var(--font-body); color: var(--ink);
  background: none; border: 0; border-radius: 6px; padding: 7px 10px; cursor: pointer;
}
.page-nav-menu button:hover, .page-nav-menu button:focus-visible { background: #e6ecef; outline: none; }
.page-nav-menu .pn-item.sub { padding-left: 24px; font-weight: 400; }
.page-nav-menu .pn-item.on { background: var(--board); color: var(--chalk); }
.page-nav-menu [data-go="top"], .page-nav-menu [data-go="bottom"] { color: var(--ink-soft); }
main :is(.room-title, .wt-title, .cork-title, .chalk-title, .chalk-h, .tab-subhead, .notebook, .exam-head) { scroll-margin-top: 96px; }
@media (max-width: 600px) {
  .page-nav { right: 14px; bottom: 14px; }
  .page-nav-fab { width: 50px; height: 50px; }
  .nav-toggle { width: 36px; height: 36px; margin-right: 0; }
}
@media print { .side-nav, .nav-toggle, .page-nav, .nav-scrim { display: none !important; } body.nav-open main { margin: 0 auto; width: auto; } }

/* ================= portal layer: dashboard, course banner, cards, pill tabs ================= */
body { background-image: none; }
.site-header { background: linear-gradient(90deg, #1b2e24, #26432f); border-bottom: 0; box-shadow: 0 2px 12px rgba(15,30,22,.28); }
.side-nav { background: #fff; border-right-color: #dde5e1; }
.side-nav a:hover { background: #eef3f0; }
.muted { color: var(--ink-soft); }
.eyebrow.light { color: rgba(255,255,255,.78); }
.room-title { font-family: var(--font-body); font-weight: 800; font-size: clamp(1.7rem, 3.6vw, 2.4rem); letter-spacing: -.01em; line-height: 1.15; }

/* progress ring: --p is 0..100 */
.ring {
  --p: 0; --size: 84px; --ring: var(--chalk-yellow); --track: rgba(255,255,255,.16); --ring-bg: #1f3a2c;
  flex: none; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--track) 0);
}
.ring > span { width: calc(100% - 14px); height: calc(100% - 14px); border-radius: 50%; display: grid; place-items: center; background: var(--ring-bg); font-weight: 800; font-size: calc(var(--size) / 4.6); }

/* dashboard */
.dash-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 24px; margin-bottom: 18px;
  padding: 30px 36px; border-radius: 18px; color: var(--chalk);
  background: radial-gradient(ellipse at 15% 0%, rgba(255,255,255,.10), transparent 55%), linear-gradient(135deg, #2d4a3a, #20392c 60%, #172c21);
  box-shadow: 0 10px 30px rgba(15,30,22,.25);
}
.dash-hero h1 { font-family: var(--font-chalk); font-weight: 400; font-size: clamp(2rem, 4.5vw, 3rem); margin: 4px 0 8px; line-height: 1.1; }
.dash-hero p { margin: 0; color: var(--chalk-dim); max-width: 660px; }
.dash-hero-side { display: grid; justify-items: center; gap: 6px; }
.dash-hero-cap { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--chalk-dim); }
.continue-card {
  --door: #2d4a3a; display: flex; align-items: center; gap: 16px; margin-bottom: 18px; padding: 14px 18px;
  background: #fff; border: 1px solid #dde5e1; border-left: 6px solid var(--door); border-radius: 14px;
  text-decoration: none; box-shadow: 0 4px 14px rgba(15,30,22,.06); transition: transform .12s, box-shadow .12s;
}
.continue-card:hover { transform: translateY(-2px); box-shadow: 0 8px 22px rgba(15,30,22,.12); }
.cc-icon { flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: var(--door); font-size: 1rem; }
.cc-text { display: flex; flex-direction: column; min-width: 0; }
.cc-label { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.cc-title { font-weight: 800; font-size: 1.08rem; }
.cc-sub { font-size: .86rem; color: var(--ink-soft); }
.cc-go { margin-left: auto; flex: none; font-weight: 800; color: var(--door); }
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 8px; }
.stat-tile {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; align-items: center;
  padding: 14px 16px; background: #fff; border: 1px solid #dde5e1; border-radius: 14px; box-shadow: 0 2px 8px rgba(15,30,22,.04);
}
.st-icon { grid-row: span 2; width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: #e6f0ea; color: var(--board); font-size: 1.15rem; font-weight: 800; }
.st-num { font-size: 1.5rem; font-weight: 800; line-height: 1.1; }
.st-label { font-size: .8rem; color: var(--ink-soft); font-weight: 700; }
.dash-section { margin: 28px 0; }
.section-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-head h2, .cork-title {
  font-family: var(--font-body); font-weight: 800; font-size: 1.3rem; margin: 0; color: var(--ink);
  background: none; padding: 0; transform: none; box-shadow: none; display: inline;
}
.section-intro { margin: -4px 0 14px; color: var(--ink-soft); font-size: .93rem; max-width: 820px; }
.bar { display: block; height: 8px; border-radius: 999px; background: #e3e9e6; overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: inherit; background: var(--door, var(--good)); }

/* course cards */
.course-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(270px, 100%), 1fr)); gap: 18px; }
.course-card {
  display: flex; flex-direction: column; background: #fff; border-radius: 16px; overflow: hidden; text-decoration: none;
  border: 1px solid #dde5e1; box-shadow: 0 4px 14px rgba(15,30,22,.07); transition: transform .12s, box-shadow .12s;
}
.course-card:hover { transform: translateY(-3px); box-shadow: 0 12px 28px rgba(15,30,22,.14); }
.course-card:focus-visible, .chapter-card:focus-visible, .continue-card:focus-visible { outline: 3px solid var(--door); outline-offset: 3px; }
.cc-band { display: flex; justify-content: space-between; align-items: flex-start; height: 84px; padding: 14px 16px; color: #fff;
  background: radial-gradient(circle at 90% 10%, rgba(255,255,255,.22), transparent 45%), linear-gradient(135deg, var(--door), color-mix(in srgb, var(--door) 62%, black)); }
.cc-code, .cc-room { font-size: .75rem; font-weight: 800; letter-spacing: .04em; padding: 2px 10px; border-radius: 999px; background: rgba(255,255,255,.2); }
.cc-room { background: rgba(0,0,0,.18); }
.cc-body { display: flex; flex-direction: column; gap: 8px; padding: 16px 18px 18px; flex: 1; }
.cc-name { font-weight: 800; font-size: 1.15rem; line-height: 1.25; }
.cc-teacher { font-size: .86rem; color: var(--ink-soft); margin-top: -4px; }
.cc-meta { display: flex; justify-content: space-between; font-size: .84rem; font-weight: 700; color: var(--ink-soft); margin-top: auto; }
.cc-open { font-weight: 800; color: var(--door); font-size: .92rem; }

/* course page */
.course-banner {
  --door: #2d4a3a; display: flex; justify-content: space-between; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 28px 32px; border-radius: 18px; color: #fff; margin: 4px 0 18px;
  background: radial-gradient(circle at 92% 0%, rgba(255,255,255,.2), transparent 45%), linear-gradient(135deg, var(--door), color-mix(in srgb, var(--door) 58%, black));
  box-shadow: 0 10px 28px rgba(15,30,22,.2);
}
.course-banner .room-title { color: #fff; margin: 4px 0 2px; }
.cb-teacher { margin: 0; opacity: .88; font-weight: 600; }
.cb-stats { display: flex; align-items: center; gap: 16px; }
.cb-stats .ring { --ring: #fff; --track: rgba(255,255,255,.22); --ring-bg: color-mix(in srgb, var(--door) 60%, black); }
.cb-nums { display: flex; flex-direction: column; gap: 2px; font-size: .9rem; opacity: .95; }
.info-card { background: #fff; border: 1px solid #dde5e1; border-radius: 14px; padding: 14px 20px; margin: 0 0 16px; box-shadow: 0 2px 8px rgba(15,30,22,.04); }
.info-card p { margin: 0; }
.weightage { border-color: #dde5e1; border-radius: 14px; box-shadow: 0 2px 8px rgba(15,30,22,.04); }
.wt-title { font-family: var(--font-body); font-weight: 800; font-size: 1.1rem; }
.wt-title::before { content: '📊 '; }

/* chapter cards */
.chapter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 16px; }
.chapter-card {
  --door: #8a9aa6; display: flex; flex-direction: column; gap: 6px; padding: 16px 16px 14px; text-decoration: none;
  background: #fff; border: 1px solid #dde5e1; border-top: 4px solid var(--door); border-radius: 14px;
  box-shadow: 0 2px 8px rgba(15,30,22,.05); transition: transform .12s, box-shadow .12s;
}
a.chapter-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(15,30,22,.12); }
.chapter-card.soon { background: #f7f9f8; border-top-color: #c9d3ce; box-shadow: none; }
.chapter-card.soon .ch-title, .chapter-card.soon .ch-blurb { opacity: .6; }
.ch-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.ch-num { min-width: 34px; height: 34px; padding: 0 6px; border-radius: 10px; display: grid; place-items: center; font-weight: 800;
  color: var(--door); background: color-mix(in srgb, var(--door) 14%, white); }
.ch-label { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.ch-title { font-weight: 800; font-size: 1.04rem; line-height: 1.3; }
.ch-blurb { font-size: .87rem; color: var(--ink-soft); line-height: 1.45; }
.ch-foot { display: flex; align-items: center; gap: 10px; margin-top: auto; padding-top: 8px; }
.ch-foot .bar { flex: 1; }
.ch-foot .stars { font-size: .95rem; }
.chip { font-size: .72rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: #eef2f0; color: var(--ink-soft); white-space: nowrap; }
.chip-done { background: #e3f3dc; color: var(--good); }
.chip-going { background: #fff3cc; color: #8a6100; }
.chip-soon { background: #eceff1; color: #6b7b85; }

/* chapter page: header, progress ring, pill tabs */
.lesson-head { align-items: center; }
.eyebrow-course { text-decoration: none; color: var(--door); background: color-mix(in srgb, var(--door) 12%, white); padding: 2px 9px; border-radius: 999px; }
.eyebrow-course:hover { background: color-mix(in srgb, var(--door) 22%, white); }
.report-card { background: #fff; border: 1px solid #dde5e1; border-radius: 14px; padding: 8px 16px 8px 8px; gap: 12px; box-shadow: 0 4px 14px rgba(15,30,22,.07); }
.report-card .ring { --size: 52px; --ring: var(--good); --track: #e3e9e6; --ring-bg: #fff; color: var(--ink); }
.rc-text { display: flex; flex-direction: column; line-height: 1.2; }
.rc-label { font-family: var(--font-body); font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.desk-tabs { gap: 4px; padding: 6px; margin-bottom: 20px; background: #fff; border: 1px solid #dde5e1; border-radius: 14px; box-shadow: 0 2px 8px rgba(15,30,22,.05); }
.desk-tab { top: 0; border: 0; border-radius: 10px; background: transparent; color: var(--ink-soft); padding: 8px 14px; }
.desk-tab:hover { background: #eef3f0; color: var(--ink); }
.desk-tab.on { background: var(--board); color: var(--chalk); border: 0; }
.desk-tab.on .ti { background: rgba(255,255,255,.18); }

@media (max-width: 700px) {
  .dash-hero, .course-banner { flex-direction: column; align-items: flex-start; padding: 22px 20px; }
  .dash-hero-side { grid-auto-flow: column; align-items: center; gap: 12px; }
  .continue-card { flex-wrap: wrap; }
  .cc-go { margin-left: 60px; }
  .stat-tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-tile { padding: 12px; }
}
@media (max-width: 600px) {
  .desk-tabs { display: grid; padding: 6px; gap: 4px; }
  .desk-tab, .desk-tab.on { border: 0; box-shadow: none; }
  .desk-tab:not(.on) { background: #f2f5f3; }
}

/* header: brand on the left edge, not centred */
@media (min-width: 601px) { .site-header { padding: 10px 24px; } }

/* footer credits */
.site-footer { flex-direction: column; align-items: center; gap: 10px; padding: 26px 18px 22px; border-top: 1px solid #dde5e1; background: #fff; margin-top: 10px; }
.credits { display: grid; gap: 8px; justify-items: center; text-align: center; }
.credit-line { font-size: .95rem; color: var(--ink); }
.credit-line a { font-weight: 800; color: var(--board); text-decoration: none; }
.heart { color: #d9435f; }
.credit-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 10px; }
.credit-links a { font-size: .84rem; font-weight: 700; color: var(--board); text-decoration: none; padding: 3px 12px; border-radius: 999px; background: #eef3f0; border: 1px solid #dde5e1; }
.credit-links a:hover { background: #e2ece6; }
.footer-meta { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; font-size: .82rem; color: var(--ink-soft); }

/* end-sem weightage on chapter cards */
.ch-weight {
  --w: #6b7b85; --w-bg: #f1f4f3; --w-line: #dde5e1;
  display: flex; flex-direction: column; gap: 6px; margin: 2px 0 6px; padding: 10px 12px;
  border-radius: 12px; background: var(--w-bg); border: 1.5px solid var(--w-line); color: var(--ink);
}
.cw-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cw-tag { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--w); }
.cw-rank { font-size: .7rem; font-weight: 800; color: #fff; background: var(--w); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.cw-main { display: flex; align-items: center; gap: 12px; }
.cw-big { font-size: 1.9rem; font-weight: 800; line-height: 1; color: var(--w); white-space: nowrap; }
.cw-big small { font-size: .9rem; font-weight: 700; opacity: .75; }
.cw-info { display: flex; flex-direction: column; font-size: .8rem; line-height: 1.3; color: var(--ink-soft); }
.cw-info b { color: var(--ink); font-size: .86rem; }
.cw-meter { display: block; height: 6px; border-radius: 999px; background: rgba(0,0,0,.07); overflow: hidden; }
.cw-meter span { display: block; height: 100%; border-radius: inherit; background: var(--w); }
.cw-qp { font-size: .76rem; font-weight: 700; color: var(--ink-soft); }
.chapter-card.soon .ch-weight { opacity: 1; }
.eyebrow-weight { --w: #6b7b85; --w-bg: #eef2f0; --w-line: #dde5e1; margin-left: 6px; padding: 2px 9px; border-radius: 999px; letter-spacing: .03em; color: var(--w); background: var(--w-bg); border: 1px solid var(--w-line); }
/* weightage levels (shared by the card block and the chapter-header chip) */
.lvl-high { --w: #b4540a; --w-bg: #fff3df; --w-line: #f2c27a; }
.lvl-mid { --w: #2d5fb8; --w-bg: #eaf2ff; --w-line: #b9d1f5; }
.lvl-low { --w: #3f7a5a; --w-bg: #eef6f1; --w-line: #cfe3d7; }
.lvl-none { --w: #7a8790; --w-bg: #f3f5f6; --w-line: #dfe4e7; }
.lvl-qp { --w: #6a4fb0; --w-bg: #f3efff; --w-line: #d8cdf5; }

/* sidebar course rows: the whole row toggles; big caret target */
.sn-course > summary { min-height: 44px; padding: 6px 4px 6px 8px; user-select: none; }
.sn-course > summary:hover { background: #eef3f0; }
.sn-course > summary:focus-visible { outline: 2px solid var(--board); outline-offset: 1px; }
.sn-name { flex: 1; min-width: 0; }
.sn-name.here { color: var(--board); }
.sn-caret { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; color: var(--ink-soft); font-size: .95rem; transition: transform .15s, background .15s; }
.sn-course > summary:hover .sn-caret { background: #e0e9e4; color: var(--ink); }
.sn-course:not([open]) .sn-caret { transform: rotate(-90deg); }
.sn-overview .sn-num { color: var(--board); }

/* current-semester badge with a blinking green light */
.live-badge {
  display: inline-flex; align-items: center; gap: 6px; vertical-align: middle;
  font: 800 .72rem/1 var(--font-body); letter-spacing: .06em; text-transform: uppercase;
  color: #1f7a3d; background: #e3f6e8; border: 1px solid #b6e2c2; padding: 4px 10px 4px 8px; border-radius: 999px;
}
.sn-sem .live-badge { margin-left: 8px; padding: 2px 8px 2px 6px; font-size: .62rem; }
.live-dot { position: relative; width: 9px; height: 9px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 6px #22c55e; animation: live-blink 1.4s ease-in-out infinite; }
.live-dot::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid #22c55e; animation: live-ping 1.4s ease-out infinite; }
@keyframes live-blink { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes live-ping { 0% { transform: scale(.6); opacity: .8; } 100% { transform: scale(1.8); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .live-dot, .live-dot::after { animation: none !important; } }

/* a worked problem opened from a link (…/worked/5) */
.notebook.nb-target { outline: 3px solid #e0a100; outline-offset: 4px; scroll-margin-top: 90px; }

/* breadcrumbs sit inside the page, above the content (not in the header) */
.page-crumbs { width: min(1180px, 100% - 32px); margin: 18px auto -10px; color: var(--ink-soft); font-size: .92rem; }
.page-crumbs:empty { display: none; }
.page-crumbs a { color: var(--ink); }
.page-crumbs [aria-current] { color: var(--ink); }
body.nav-open .page-crumbs { width: min(1180px, 100% - 264px - 40px); margin-left: calc(264px + max(20px, (100% - 264px - 1180px) / 2)); }
@media (max-width: 600px) { .page-crumbs { width: calc(100% - 20px); margin: 12px auto -6px; } }

/* the course's target score: the first thing under the banner */
.target-card { display: flex; gap: 22px; align-items: center; margin: 0 0 16px; padding: 18px 22px; border-radius: 14px;
  background: linear-gradient(135deg, #fff7e0, #ffe9b8); border: 2px solid #e0a100; box-shadow: 0 4px 14px rgba(224,161,0,.18); }
.tg-score { display: flex; flex-direction: column; align-items: center; padding-right: 22px; border-right: 2px dashed rgba(160,110,0,.35); flex: none; }
.tg-label { font-weight: 800; font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: #8a5a00; }
.tg-num { font-weight: 800; font-size: 3.4rem; line-height: 1; color: #6b4300; }
.tg-num small { font-size: 1.4rem; opacity: .75; }
.tg-text { margin: 0 0 6px; }
.tg-points { margin: 0; padding: 0; list-style: none; display: flex; flex-wrap: wrap; gap: 6px; }
.tg-points li { background: rgba(255,255,255,.75); border: 1px solid rgba(160,110,0,.3); border-radius: 999px; padding: 3px 12px; font-size: .88rem; }
@media (max-width: 600px) {
  .target-card { flex-direction: column; align-items: stretch; gap: 12px; padding: 14px 16px; }
  .tg-score { flex-direction: row; justify-content: space-between; align-items: baseline; padding: 0 0 10px; border-right: 0; border-bottom: 2px dashed rgba(160,110,0,.35); }
  .tg-num { font-size: 2.6rem; }
}

/* the exam line inside the course banner */
.cb-exam { margin: 10px 0 0; display: inline-block; padding: 6px 12px; border-radius: 10px; background: rgba(255,255,255,.16); font-size: .95rem; }
.cb-exam strong { color: #ffe9a8; }

/* ================= Horizon theme (after horizon-ui-chakra): light grey-blue page, white rounded cards,
   navy text, brand purple-blue. Lessons sit on white cards; the dark board is kept for questions only. ================= */
:root {
  --brand: #4318FF; --brand-2: #7551FF; --brand-light: #868CFF; --brand-50: #E9E3FF;
  --navy: #2B3674; --navy-dark: #1B254B; --gray-500: #A3AED0; --gray-600: #707EAE; --gray-100: #F4F7FE; --line: #E0E5F2;
  --wall: #F4F7FE; --wall-2: #E9EDF7; --paper: #ffffff; --paper-line: #E9EDF7;
  --ink: #2B3674; --ink-soft: #707EAE;
  --board: #4318FF; --board-2: #3311DB;
  --wood: #4318FF; --wood-dark: #1B254B; --wood-light: #7551FF;
  --good: #01A66F; --bad: #E31A1A; --warn: #C27803;
  --card-shadow: 14px 17px 40px 4px rgba(112, 144, 176, .08);
  --shadow: var(--card-shadow);
  --radius: 20px;
  --font-body: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-chalk: 'DM Sans', system-ui, sans-serif;
  --font-script: 'DM Sans', system-ui, sans-serif;
}
body { background: var(--gray-100); color: var(--ink); letter-spacing: -.01em; }
mark { background: #FFF2C7; color: var(--navy); }

/* header: white glass bar */
.site-header { background: rgba(255,255,255,.82); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); color: var(--navy);
  border-bottom: 1px solid var(--line); box-shadow: 0 4px 20px rgba(112,144,176,.10); }
.brand-bell { background: linear-gradient(135deg, var(--brand-light), var(--brand)); }
.brand-name { font-weight: 800; font-size: 1.35rem; letter-spacing: -.02em; color: var(--navy); }
.brand-tag { color: var(--gray-600); opacity: 1; }
.nav-toggle { color: var(--navy); background: var(--gray-100); border: 1px solid var(--line); border-radius: 12px; }
.nav-toggle:hover, .nav-toggle[aria-expanded="true"] { background: var(--brand-50); color: var(--brand); }

/* buttons */
.btn { border: 1px solid var(--line); border-radius: 14px; box-shadow: none; font-weight: 700; color: var(--navy); background: #fff; padding: 8px 18px; }
.btn:hover { box-shadow: 0 6px 16px rgba(112,144,176,.18); }
.btn:active { box-shadow: none; }
.btn-chalk, .board .btn-chalk { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-chalk:hover { background: var(--board-2); box-shadow: 0 8px 20px rgba(67,24,255,.25); }
.btn-again { background: #FFE8EC; }

/* lesson boards are now plain white cards (explanations) */
.board, .board.big-board, .tree-map {
  background: #fff; color: var(--ink); border: 0; border-image: none; border-radius: var(--radius);
  box-shadow: var(--card-shadow); overflow: hidden;
}
.board a { color: var(--brand); }
.board code { background: var(--gray-100); color: var(--navy); }
.board strong { color: var(--navy-dark); }
.board mark { background: #FFF2C7; color: var(--navy); }
.chalk-title { font-weight: 800; font-size: clamp(1.4rem, 2.6vw, 1.9rem); letter-spacing: -.02em; text-shadow: none; color: var(--navy); }
.chalk-sub { color: var(--gray-600); }
.chalk-h { font-weight: 700; font-size: 1.15rem; color: var(--brand); margin-top: 20px; }
.chalk-list li::marker { color: var(--brand); }
.formula { color: var(--navy-dark); background: var(--gray-100); border: 0; border-left: 4px solid var(--brand); border-radius: 12px; }
.formula-cap { color: var(--gray-600); }
.chalk-table th, .chalk-table td { border-bottom: 1px solid var(--line); }
.chalk-table th { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); border-bottom: 1px solid var(--line); }
.chalk-table tr.sum td { border-top: 2px solid var(--line); color: var(--navy-dark); font-weight: 700; }
.board-count { color: var(--gray-500); font-weight: 700; font-size: .85rem; top: 16px; right: 22px; }
.board-ledge { background: var(--gray-100); border-top: 1px solid var(--line); }
.board-title { color: var(--navy); }
.board-note, .metric small { color: var(--gray-600); }
.board .lab-msg.good { color: var(--good); }
.board .lab-msg.bad { color: var(--bad); }
.metric { border: 1px solid var(--line); border-radius: 14px; }
.metric span, .trace-item .lbl, .tn-count { color: var(--brand); }
.mat { border-color: var(--navy); }
.tree ul { border-left-color: var(--line); }
.tree ul > li::before { border-top-color: var(--line); }
.tn-box { border-color: #C9D2EA; }
.tn.root > .tn-box { border-color: var(--brand); }
.trap { border: 0; border-left: 4px solid var(--bad); background: #FFF1F1; border-radius: 12px; }
.trap-label, .trap strong { color: #B01515; font-weight: 700; font-size: 1rem; }

/* notes: flat tinted callouts instead of sticky notes */
.sticky, .sticky.pink, .sticky.blue, .sticky.red { transform: none; border-radius: 14px; box-shadow: none; margin: 16px 0; border-left: 4px solid #F5B400; background: #FFF8E1; }
.sticky::before { display: none; }
.sticky.pink { background: #FFEEF3; border-left-color: #E3478B; }
.sticky.blue { background: #EEF2FF; border-left-color: var(--brand); }
.sticky.red { background: #FFECEC; border: 0; border-left: 4px solid var(--bad); }
.sticky-label { font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--navy); }

/* lesson side list */
.clipboard { background: #fff; padding: 10px; border-radius: var(--radius); box-shadow: var(--card-shadow); top: 84px; }
.clipboard .clip { display: none; }
.clipboard h3 { font-weight: 800; font-size: 1.05rem; background: none; color: var(--navy); }
.clipboard ol { background: none; }
.clipboard li { border-bottom-color: var(--line); }
.clipboard li.on a { color: var(--brand); }

/* worked problems: white cards; the problem statement is the one "board" (dark navy) */
.notebook { background: #fff; border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--card-shadow); }
.notebook::before, .notebook::after { display: none; }
.nb-num { font-weight: 800; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }
.tag { background: var(--brand-50); color: var(--brand); }
.notebook h3 { font-weight: 800; font-size: 1.25rem; color: var(--navy); }
.nb-problem {
  margin: 10px 0 4px; padding: 16px 20px; border-radius: 16px; color: #F4F7FE;
  background: radial-gradient(circle at 95% 0%, rgba(134,140,255,.28), transparent 50%), linear-gradient(135deg, #1B254B, #111C44);
}
.nb-problem strong { color: #fff; }
.nb-problem a { color: #B9BDFF; }
.nb-problem code { background: rgba(255,255,255,.12); color: #fff; }
.nb-problem mark { background: rgba(255,214,102,.3); color: #fff; }
.nb-problem .formula { background: rgba(255,255,255,.08); color: #fff; border-left-color: var(--brand-light); }
.nb-problem .md-table th, .nb-problem .md-table td, .nb-problem .chalk-table th, .nb-problem .chalk-table td { border-color: rgba(255,255,255,.22); color: #F4F7FE; }
.nb-problem .md-table th { background: rgba(255,255,255,.1); }
.nb-problem .sticky { color: var(--ink); }
.nb-problem .sticky strong, .nb-problem .sticky mark, .nb-problem .sticky code { color: var(--ink); }
.nb-problem .sticky a { color: var(--brand); }
.nb-step { border-top: 1px solid var(--line); }
.step-label { font-weight: 700; font-size: .95rem; color: var(--brand); }
.nb-answer { background: #E6FAF5; border: 0; border-left: 4px solid var(--good); border-radius: 12px; }
.nb-flow { background: var(--gray-100); border: 0; border-radius: 14px; }
.flow-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--gray-600); }
.fl-box { border: 1px solid #C9D2EA; border-radius: 10px; }
.fl-box.next { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(67,24,255,.12); }
.fl-box:hover, .fl-box:focus-visible { border-color: var(--brand); }
.fl-box.done { border-color: var(--good); background: #E6FAF5; }
.notebook.nb-target { outline-color: var(--brand); }

/* labs, flashcards, quiz, cheat sheet */
.lab-card { background: #fff; border: 0; border-radius: var(--radius); box-shadow: var(--card-shadow); }
.lab-title { font-weight: 800; font-size: 1.35rem; color: var(--navy); }
.paper { border-radius: 16px; box-shadow: none; border: 1px solid var(--line); }
.field input, .field textarea, .field select, .num-ans input { border: 1px solid var(--line); border-radius: 12px; }
.field input:focus, .field textarea:focus, .field select:focus { outline: 3px solid rgba(67,24,255,.18); border-color: var(--brand); }
.flashcard .face { background: #fff; border-top: 0; border-radius: var(--radius); box-shadow: var(--card-shadow); }
.flashcard .back { background: #F7F5FF; }
.fc-tag { color: var(--brand); }
.fc-q { font-weight: 700; font-size: 1.4rem; color: var(--navy); }
.exam-paper { background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); }
.exam-paper::before { border-left-color: var(--line); }
.exam-head { font-weight: 700; font-size: 1.05rem; border-bottom: 1px solid var(--line); }
.qn { font-weight: 800; font-size: 1rem; color: var(--brand); }
.grade-circle { font-size: 2rem; }
.cheat-sheet { border-radius: var(--radius); box-shadow: var(--card-shadow); border-top: 0; }
.cs-head { font-weight: 800; font-size: 1.15rem; }
.cs-table th, .cs-table td { border-bottom-color: var(--line); }

/* portal: hero, banners, cards, tabs, nav */
.dash-hero, .course-banner { border-radius: var(--radius); box-shadow: 0 18px 40px rgba(67,24,255,.18); }
.dash-hero { background: radial-gradient(circle at 90% 0%, rgba(255,255,255,.22), transparent 45%), linear-gradient(135deg, #868CFF, #4318FF); color: #fff; }
.dash-hero h1 { font-weight: 800; letter-spacing: -.02em; }
.dash-hero p, .dash-hero-cap { color: rgba(255,255,255,.85); }
.ring { --ring: #fff; --ring-bg: #3a1ad6; }
.course-card, .chapter-card, .stat-tile, .info-card, .weightage, .continue-card, .report-card, .desk-tabs { border-color: transparent; border-radius: var(--radius); box-shadow: var(--card-shadow); }
.chapter-card { border-top: 4px solid var(--door); }
.st-icon { background: var(--gray-100); color: var(--brand); border-radius: 50%; }
.desk-tab:hover { background: var(--gray-100); }
.desk-tab.on { background: var(--brand); color: #fff; box-shadow: 0 6px 16px rgba(67,24,255,.25); }
.desk-tab:not(.on) { background: transparent; }
.chip { background: var(--gray-100); }
.bar { background: #E9EDF7; }
.side-nav { background: #fff; border-right: 0; box-shadow: 14px 0 40px rgba(112,144,176,.10); }
.side-nav a:hover, .sn-course > summary:hover { background: var(--gray-100); }
.side-nav a.on, .page-nav-menu .pn-item.on { background: var(--brand); color: #fff; }
.side-nav a.on .sn-num { color: #fff; }
.sn-name.here, .sn-overview .sn-num, .credit-line a, .credit-links a { color: var(--brand); }
.credit-links a { background: var(--gray-100); border-color: var(--line); }
.page-nav-fab { background: linear-gradient(135deg, #868CFF, #4318FF); border: 0; color: #fff; box-shadow: 0 10px 24px rgba(67,24,255,.35); }
.page-nav-menu { border: 0; border-radius: 16px; }
.pn-head { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.site-footer { background: #fff; border-top: 1px solid var(--line); }
.eyebrow { color: var(--gray-600); }
.page-crumbs a { color: var(--brand); text-decoration: none; }
@media (max-width: 600px) {
  .desk-tab, .desk-tab.on { border: 0; }
  .desk-tab:not(.on) { background: var(--gray-100); }
  .notebook { padding: 16px 14px; }
  .nb-problem { padding: 14px; }
}
@media print { .nb-problem { background: #fff; color: #000; border: 1px solid #999; } }

/* per-part check inside a lesson part: flashcards + pop quiz for that part only */
.part-check { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--line); }
.pc-h { font-weight: 800; font-size: 1.1rem; color: var(--navy); margin: 14px 0 10px; }
.pc-h small { font-weight: 600; font-size: .8rem; color: var(--gray-600); margin-left: 6px; }
.pc-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr)); gap: 12px; }
.mc { display: flex; flex-direction: column; gap: 4px; }
.mc-face { display: flex; flex-direction: column; gap: 6px; text-align: left; font: inherit; color: var(--ink); cursor: pointer;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; min-height: 96px; box-shadow: 0 4px 12px rgba(112,144,176,.10); }
.mc-face:hover { border-color: var(--brand-light); }
.mc-tag { font-size: .7rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }
.mc-front { font-weight: 700; color: var(--navy); }
.mc-back { display: none; padding-top: 8px; border-top: 1px dashed var(--line); font-size: .93rem; }
.mc.flipped .mc-face { background: #F7F5FF; border-color: var(--brand-light); }
.mc.flipped .mc-back { display: block; }
.mc-know { align-self: flex-end; font-size: .8rem; color: var(--gray-600); }
.pc-quiz { display: grid; gap: 14px; }
.pq { border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; background: #fff; }
.pq-q { padding: 12px 16px; border-radius: 12px; color: #F4F7FE; background: linear-gradient(135deg, #1B254B, #111C44); margin-bottom: 8px; }
.pq-q strong { color: #fff; }
.pq-n { font-weight: 800; color: #B9BDFF; margin-right: 4px; }
.pq .btn-row { margin-top: 8px; }
.pq .small-btn { margin-left: 0; }
.pq.is-right .feedback { background: #E6FAF5; border-left: 4px solid var(--good); }
.pq.is-wrong .feedback { background: #FFF1F1; border-left: 4px solid var(--bad); }
.pc-more { margin: 14px 0 0; }
.pc-more a { color: var(--brand); }

/* solution-path "Answer" box once done: solid green so the white text shows */
.fl-box.fl-end.done { background: var(--good); border-color: var(--good); color: #fff; }

/* phones: wide lesson tables become one card per row (label on the left, value on the right) */
@media (max-width: 600px) {
  .board-inner table.chalk-table.stack-sm { display: block; overflow: visible; }
  .chalk-table.stack-sm thead { display: none; }
  .chalk-table.stack-sm tbody { display: grid; gap: 10px; }
  .chalk-table.stack-sm tr { display: block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
  .chalk-table.stack-sm td { display: block; padding: 6px 0; border-bottom: 1px dashed var(--line); }
  .chalk-table.stack-sm td:last-child { border-bottom: 0; }
  .chalk-table.stack-sm td::before { content: attr(data-label); font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); display: block; margin-bottom: 1px; }
  .chalk-table.stack-sm td:first-child { font-weight: 700; color: var(--navy); }
  .chalk-table.stack-sm td[data-label=""]::before { display: none; }
  .chalk-table.stack-sm td:empty { display: none; }
}

/* mid-sem syllabus chip on chapter cards and chapter pages (catalog chapter.phase) */
.ch-label-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.ch-phase { display: inline-block; font-size: .68rem; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; white-space: nowrap; vertical-align: middle; }
.ph-pre { background: #e6effd; color: #2d5bd1; border: 1px solid #c9dafb; }
.ph-post { background: #f3e8fd; color: #7a35c0; border: 1px solid #e2cdf8; }
.ph-mixed { background: #fff3cc; color: #8a6100; border: 1px solid #f2dc8f; }

/* prerequisite badges (catalog chapter.needs) on chapter cards and chapter pages */
.ch-needs { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-top: 8px; }
.needs-label { font-size: .66rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-right: 2px; }
.need-chip { font-size: .7rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: #f4f6f5; color: #3d4b45; border: 1px dashed #b9c6c0; white-space: nowrap; text-decoration: none; }
a.need-chip:hover { background: #e9efec; border-style: solid; }
.lesson-head .ch-needs { margin-top: 10px; }



/* ⓘ buttons with click-to-open tooltips (chapter.readme) */
.info-wrap { position: relative; display: inline-block; vertical-align: middle; }
.info-i { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid #8a6100; background: #fff8dc; color: #8a6100; font: italic 700 12px/1 Georgia, serif; cursor: pointer; padding: 0; display: inline-flex; align-items: center; justify-content: center; margin-left: 4px; }
.info-i:hover, .info-i[aria-expanded="true"] { background: #8a6100; color: #fff; }
.info-pop { position: absolute; z-index: 40; top: calc(100% + 6px); left: -8px; width: min(620px, 86vw); max-height: 60vh; overflow: auto; background: #fffbea; border: 1px solid #e8cf7a; border-radius: 12px; box-shadow: 0 10px 28px rgba(0,0,0,.18); padding: 12px 14px; font-size: .84rem; font-weight: 400; font-style: normal; text-transform: none; letter-spacing: normal; color: #3f3820; text-align: left; white-space: normal; line-height: 1.45; }
.info-pop .ip-sum { margin: 0 0 8px; }
.info-pop h4 { margin: 10px 0 6px; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; color: #8a6100; }
.info-pop .md-table { font-size: .8rem; }
.info-pop .md-table th, .info-pop .md-table td { text-align: left; }
@media (max-width: 760px) { .info-pop { position: fixed; left: 4vw; right: 4vw; top: 18vh; width: auto; } }
.room-sub .info-pop { left: auto; right: -8px; }

/* "Where marks are lost" steps in red (solution steps and the solution-path box) */
.nb-step.marks-lost { background: #fdecec; border-left: 4px solid #c0222d; border-radius: 8px; }
.nb-step.marks-lost .step-label, .nb-step.marks-lost > div { color: #a3141d; }
.nb-step.marks-lost .step-label { font-weight: 800; }
.fl-box.marks-lost { border-color: #c0222d; color: #a3141d; background: #fdecec; }

/* Method tabs inside one worked problem (e.g. Method 1 / Method 2) */
.nb-mtabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 4px; }
.nb-mtab { font: inherit; font-size: .9em; padding: 5px 12px; border-radius: 999px; border: 1px solid currentColor; background: transparent; color: inherit; opacity: .65; cursor: pointer; }
.nb-mtab.on { opacity: 1; font-weight: 600; background: rgba(0,0,0,.06); }
.nb-mintro { margin: 6px 0 8px; font-size: .95em; }

/* time budget beside a worked problem */
.tag.tag-time { background: #fff4d6; color: #7a5400; border-color: #e8c56a; font-weight: 600; }

/* Revisit flag (red) and the Pending list at the top of a tab */
.notebook.nb-revisit { outline: 2px solid #c0222d; outline-offset: 2px; }
.tag.tag-revisit { background: #c0222d; color: #fff; border-color: #c0222d; }
.revisit-note { color: #a3141d; background: #fdecec; border-left: 4px solid #c0222d; padding: 6px 10px; border-radius: 6px; margin: 6px 0 10px; }
.pending-box { background: #fdecec; border: 1.5px solid #c0222d; border-radius: 12px; padding: 12px 16px; margin: 0 0 18px; color: #a3141d; }
.pending-box h3 { margin: 0 0 6px; color: #c0222d; font-size: 1rem; letter-spacing: .02em; text-transform: uppercase; }
.pending-box ul { margin: 0; padding-left: 18px; }
.pending-box li { margin: 4px 0; }
.pending-box a { color: #a3141d; font-weight: 700; }
.pending-why { display: block; font-size: .9em; color: #7d1a1f; }
.desk-tab.tab-pending { color: #c0222d; border-color: #c0222d; background: #fdecec; font-weight: 800; }
.desk-tab.tab-pending.on { background: #c0222d; color: #fff; }
.eyebrow-weight.per-paper { background: #eef6ff; color: #1d4f91; }
.ch-weight .cw-avg { display: block; font-weight: 700; color: #1d4f91; }

/* aligned equations (type "eqs") */
.eqs { background: var(--gray-100, #f3f4f6); border-left: 4px solid var(--brand, #4f46e5); border-radius: 12px; padding: 14px 18px; margin: 12px 0; overflow-x: auto; }
.eq-group + .eq-group { margin-top: 14px; padding-top: 12px; border-top: 1px dashed #cfd5dd; }
.eq-label { font-weight: 800; color: var(--navy-dark, #1e1b4b); margin-bottom: 6px; }
.eq-ref { font-weight: 500; font-size: .85em; color: var(--gray-600, #555); }
.eq-grid { display: grid; grid-template-columns: max-content max-content 1fr; column-gap: 10px; row-gap: 8px; align-items: center; font-family: var(--font-math); font-size: 1.15rem; color: var(--navy-dark, #1e1b4b); }
.eq-l { text-align: right; white-space: nowrap; }
.eq-o { text-align: center; color: var(--brand, #4f46e5); font-weight: 700; }
.eq-r { white-space: nowrap; }
.eq-note { font-size: .85rem; color: var(--gray-600, #555); margin-top: 6px; }
.eq-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 3px; font-size: .92em; }
.eq-frac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 4px 1px; }
.eq-frac > span:last-child { padding: 1px 4px 0; }
.eqs sub { font-size: .7em; }
.eq-sqrt { display: inline-flex; align-items: flex-start; white-space: nowrap; }
.eq-rad-sign { font-family: var(--font-body); font-size: 1.05em; line-height: 1; padding-top: 1px; }
.eq-rad { border-top: 1.5px solid currentColor; padding: 1px 2px 0 1px; line-height: 1.15; }
/* auto-aligned formula boxes and cheat-sheet lines */
.fx-grid { font-family: inherit; font-size: inherit; color: inherit; row-gap: 6px; white-space: normal; }
.fx-grid .eq-o { color: inherit; opacity: .8; }
.fx-grid .eq-r { white-space: normal; }
.eq-all { grid-column: 1 / -1; }
.cs-f .fx-grid { row-gap: 4px; }
/* the math font's √ sits too low next to the bar: use the body font for the sign */
.formula .rsym, .cs-f .rsym, .eqs .rsym { font-family: var(--font-body); font-size: 1.15em; line-height: 1.05; }
.formula .rad, .cs-f .rad, .eqs .rad { align-items: flex-end; }
.formula .rsym, .cs-f .rsym, .eqs .rsym { font-size: 1.2em; line-height: 1.1; transform: translateY(.04em); }
/* one shared grid for all groups: every ←, =, ≤, ≥, ⇒ sits in the same column */
.eq-all-grid > .eq-label, .eq-all-grid > .eq-note, .eq-all-grid > .eq-sep { grid-column: 1 / -1; }
.eq-all-grid > .eq-label { margin: 2px 0 0; }
.eq-all-grid > .eq-note { margin: 0 0 2px; }
.eq-all-grid > .eq-sep { border-top: 1px dashed #cfd5dd; margin: 6px 0; }
.eqs .eq-grid { column-gap: 12px; }
.eq-all-grid > .eq-label, .eq-all-grid > .eq-note { font-family: var(--font-body); }
.eq-all-grid > .eq-label { font-size: 1rem; }
.eq-all-grid > .eq-note { font-size: .85rem; }

/* Must do / If time */
.tag.tag-must { background: #2F9E44; color: #fff; border-color: #2F9E44; font-weight: 700; }
.tag.tag-optional { background: #eef0f6; color: #5a6380; border-color: #cfd4e3; }
.prio-bar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: .2rem 0 1rem; font-size: .92rem; }
.prio-bar .prio-btns { margin-left: auto; display: flex; gap: .4rem; }
.notebooks.must-only .notebook.nb-optional { display: none; }
.prio-bar .prio-def { flex-basis: 100%; margin: .3rem 0 0; font-size: .86rem; color: #5a6380; line-height: 1.45; }
/* Topic groups on the course page: one header per topic, lecture cards stay one per lecture */
.topic-head { margin: 1.6rem 0 .7rem; padding: .7rem 1rem; border-left: 4px solid var(--door, #4318FF); background: rgba(67, 24, 255, .05); border-radius: 0 10px 10px 0; }
.topic-head:first-of-type { margin-top: .4rem; }
.topic-head h3 { margin: 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; font-size: 1.15rem; }
.topic-head .th-lec { font-size: .85rem; font-weight: 600; color: #5a6380; }
.topic-head .th-weight { margin: .25rem 0 0; font-size: .92rem; }
.topic-head .th-note { margin: .2rem 0 0; font-size: .85rem; color: #5a6380; }
.ch-topic { display: inline-block; margin: .15rem 0 .1rem; font-size: .75rem; font-weight: 600; color: #4318FF; background: rgba(67, 24, 255, .08); border-radius: 999px; padding: .1rem .55rem; }
/* Side-nav topic headers (lectures grouped as on the course page) */
.sn-course li.sn-topic { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; margin: 10px 0 2px; padding: 2px 8px; border-top: 1px solid #e3e9ee; padding-top: 8px; }
.sn-topic-name { font-size: .72rem; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); }
.sn-topic-meta { flex: none; font-size: .7rem; font-weight: 700; color: #4318FF; }
/* Pre-mid / post-mid badges and filter */
.tag.tag-phase.ph-pre { background: #e7f0ff; color: #1d4ed8; border-color: #b9cdf7; font-weight: 600; }
.tag.tag-phase.ph-post { background: #f3ecff; color: #6b21a8; border-color: #d8c3f3; font-weight: 600; }
.tag.tag-phase.ph-mixed { background: linear-gradient(90deg, #e7f0ff 50%, #f3ecff 50%); color: #3b2a8a; border-color: #c9c6f3; font-weight: 600; }
.phase-bar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; margin: -.3rem 0 1rem; font-size: .92rem; }
.phase-bar .pb-label { font-weight: 700; color: #5a6380; }
.phase-bar .pb-note { flex-basis: 100%; font-size: .82rem; color: #5a6380; }
.notebook[hidden] { display: none !important; }

/* matrices: [[a, b], [c, d]] in content text (see mathMarkup in core/util.js) */
.mx { display: inline-flex; align-items: stretch; vertical-align: middle; margin: 3px 2px; }
.mx-b { width: .32em; border: 1.5px solid currentColor; }
.mx-l { border-right: none; }
.mx-r { border-left: none; }
.mx-grid { display: inline-grid; column-gap: .9em; row-gap: .1em; padding: .12em .3em; text-align: center; line-height: 1.3; white-space: nowrap; }

/* working tables inside solution steps read left to right */
.nb-step .md-table td, .nb-step .md-table th { text-align: left; }
