/* ===========================================================
   MATH 4223 — Chapter 2: Regular Surfaces
   Interactive lecture notes — shared stylesheet
   =========================================================== */
:root{
  --hkust:#003366;
  --hkust-2:#0a4f8f;
  --accent:#0a6ebd;
  --ink:#1a1f2b;
  --muted:#5b6472;
  --paper:#ffffff;
  --bg:#eef2f7;
  --line:#d8e0ea;
  --ok:#1b7d3f;
  --ok-bg:#e9f7ee;
  --bad:#b00020;
  --bad-bg:#fdecee;
  --warn:#cc5500;
  --def:#0a6ebd;
  --def-bg:#eef5fc;
  --thm:#9a6b00;
  --thm-bg:#fbf4e0;
  --prop:#5b3da8;
  --prop-bg:#f1ecfb;
  --ex:#0f7a6c;
  --ex-bg:#e8f6f3;
  --exer-bg:#fdf3e7;
  --exer:#b5651d;
  --radius:14px;
  --shadow:0 1px 3px rgba(16,32,64,.08),0 6px 24px rgba(16,32,64,.06);
  --maxw:880px;
}
*{box-sizing:border-box}
html{scroll-behavior:smooth}
body{
  margin:0;
  font-family:"Charter","Georgia","Times New Roman",serif;
  color:var(--ink);
  background:var(--bg);
  line-height:1.65;
  font-size:18px;
  -webkit-font-smoothing:antialiased;
}
.wrap{max-width:var(--maxw);margin:0 auto;padding:0 22px 80px}

/* ---------- top bar / progress ---------- */
.topbar{
  position:sticky;top:0;z-index:50;
  background:rgba(255,255,255,.92);backdrop-filter:saturate(1.4) blur(8px);
  border-bottom:1px solid var(--line);
}
.topbar-inner{max-width:var(--maxw);margin:0 auto;padding:10px 22px;display:flex;align-items:center;gap:14px}
.crumb{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:13.5px;color:var(--muted);font-weight:600;letter-spacing:.02em}
.crumb a{color:var(--accent);text-decoration:none}
.crumb a:hover{text-decoration:underline}
.prog-wrap{margin-left:auto;display:flex;align-items:center;gap:10px;font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:12.5px;color:var(--muted);font-weight:600}
.prog-track{width:150px;height:8px;border-radius:99px;background:#dde5ef;overflow:hidden}
.prog-fill{height:100%;width:0;border-radius:99px;background:linear-gradient(90deg,var(--accent),#28c08a);transition:width .45s cubic-bezier(.2,.7,.2,1)}

/* ---------- hero ---------- */
.hero{
  background:linear-gradient(135deg,var(--hkust),var(--hkust-2) 60%,#10639f);
  color:#fff;border-radius:0 0 var(--radius) var(--radius);
  padding:42px 22px 36px;margin-bottom:30px;box-shadow:var(--shadow);
}
.hero-inner{max-width:var(--maxw);margin:0 auto}
.hero .kicker{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:13px;letter-spacing:.18em;text-transform:uppercase;color:#bfe0ff;font-weight:700;margin:0 0 8px}
.hero h1{font-size:34px;line-height:1.15;margin:0 0 14px;font-weight:800;letter-spacing:-.01em}
.hero .sub{font-size:17px;color:#dcebff;max-width:680px;margin:0}
.hero .quote{margin-top:18px;padding-left:16px;border-left:3px solid #9cc7ff;color:#e7f1ff;font-style:italic;font-size:15.5px}
.hero .quote span{display:block;font-style:normal;font-size:13px;color:#bfe0ff;margin-top:4px;font-family:-apple-system,Segoe UI,Roboto,sans-serif}

/* ---------- section header on each page ---------- */
.page-head{margin:6px 0 26px}
.page-head .sec-no{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:800;font-size:14px;letter-spacing:.12em;color:var(--accent);text-transform:uppercase}
.page-head h1{font-size:30px;line-height:1.15;margin:6px 0 0;color:var(--hkust);font-weight:800;letter-spacing:-.01em}

h2.sub-h{font-size:22px;color:var(--hkust);margin:38px 0 10px;font-weight:700;border-bottom:2px solid var(--line);padding-bottom:6px}
h3.subsub{font-size:18.5px;color:var(--hkust-2);margin:26px 0 8px;font-weight:700;font-family:-apple-system,Segoe UI,Roboto,sans-serif}

p{margin:0 0 14px}
.note-p{color:var(--ink)}

/* ---------- callout blocks ---------- */
.block{
  border-radius:var(--radius);padding:16px 18px 14px;margin:20px 0;
  box-shadow:var(--shadow);background:var(--paper);border:1px solid var(--line);
  position:relative;
}
.block .label{
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:800;font-size:13.5px;
  letter-spacing:.03em;display:inline-block;margin-bottom:6px;
}
.block.def{border-left:6px solid var(--def);background:var(--def-bg)}
.block.def .label{color:var(--def)}
.block.thm{border-left:6px solid var(--thm);background:var(--thm-bg)}
.block.thm .label{color:var(--thm)}
.block.prop{border-left:6px solid var(--prop);background:var(--prop-bg)}
.block.prop .label{color:var(--prop)}
.block.example{border-left:6px solid var(--ex);background:var(--ex-bg)}
.block.example .label{color:var(--ex)}
.block.exercise{border-left:6px solid var(--exer);background:var(--exer-bg)}
.block.exercise .label{color:var(--exer)}
.block.remark{border-left:6px solid #8a93a3;background:#f4f6f9}
.block.remark .label{color:#5b6472}

/* proof */
.proof{margin:14px 0 18px;padding:2px 0 2px 16px;border-left:3px dashed #c3ccd9;color:#2c3340}
.proof .pf-label{font-style:italic;font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:600;color:var(--muted);font-size:14px;margin-right:4px}
.qed{float:right;font-weight:700;color:var(--muted)}

/* collapsible proof */
details.proofbox{margin:12px 0 18px;border:1px solid var(--line);border-radius:10px;background:#fafbfd;overflow:hidden}
details.proofbox>summary{cursor:pointer;list-style:none;padding:10px 14px;font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:600;font-size:14px;color:var(--accent);user-select:none}
details.proofbox>summary::-webkit-details-marker{display:none}
details.proofbox>summary::before{content:"▸ ";color:var(--accent)}
details.proofbox[open]>summary::before{content:"▾ "}
details.proofbox .pf-body{padding:2px 16px 12px}

/* ---------- math overflow handling ---------- */
/* Wide display equations scroll horizontally instead of overflowing the page. */
mjx-container[display="true"]{
  overflow-x:auto;
  overflow-y:hidden;
  max-width:100%;
  padding:4px 2px 6px;
  /* gentle fade hint that content scrolls */
  scrollbar-width:thin;
}
mjx-container[display="true"]::-webkit-scrollbar{height:7px}
mjx-container[display="true"]::-webkit-scrollbar-thumb{background:#c4cfdd;border-radius:99px}
mjx-container[display="true"] > svg{max-width:none}
/* Inline math should never force the line wider than its container. */
mjx-container:not([display="true"]){max-width:100%}
/* Keep equations inside coloured blocks within the block padding. */
.block mjx-container[display="true"]{margin-left:0;margin-right:0}

/* figures */
figure.fig{margin:24px auto;text-align:center;max-width:100%}
figure.fig img{max-width:100%;height:auto;border-radius:10px;background:#fff;border:1px solid var(--line);box-shadow:var(--shadow)}
figure.fig figcaption{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:13.5px;color:var(--muted);margin-top:8px;font-style:italic}
figure.fig figcaption b{font-style:normal;color:var(--ink)}

/* ---------- checkpoint ---------- */
.checkpoint{
  border:1.5px solid #bcd6ef;border-radius:var(--radius);background:linear-gradient(180deg,#f6fbff,#eef6ff);
  padding:18px 18px 14px;margin:26px 0;box-shadow:var(--shadow);
}
.cp-badge{
  display:inline-flex;align-items:center;gap:7px;font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-weight:800;font-size:12.5px;letter-spacing:.06em;text-transform:uppercase;color:#fff;
  background:linear-gradient(90deg,var(--accent),#1390c9);padding:4px 11px;border-radius:99px;margin-bottom:10px;
}
.cp-badge svg{width:14px;height:14px}
.cp-q{font-weight:600;margin:2px 0 12px}
.mc-options{display:flex;flex-direction:column;gap:9px}
.mc-label{
  display:flex;gap:11px;align-items:flex-start;padding:11px 13px;border:1.5px solid var(--line);border-radius:10px;
  background:#fff;cursor:pointer;transition:.15s;font-size:16.5px;
}
.mc-label:hover{border-color:var(--accent);background:#f5faff}
.mc-label input{margin-top:4px;accent-color:var(--accent);width:16px;height:16px;flex:none}
.mc-letter{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:700;color:var(--accent);flex:none}
.mc-label.correct{border-color:var(--ok);background:var(--ok-bg)}
.mc-label.correct .mc-letter{color:var(--ok)}
.mc-label.wrong{border-color:var(--bad);background:var(--bad-bg)}
.mc-label.wrong .mc-letter{color:var(--bad)}
.mc-label.dim{opacity:.5}
.mc-label.locked{cursor:default}
.verdict{margin-top:12px;font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:700;font-size:14.5px;display:none}
.verdict.show{display:block}
.verdict.ok{color:var(--ok)}
.verdict.no{color:var(--bad)}
.explain{
  margin-top:10px;padding:12px 14px;border-radius:10px;background:#fff;border:1px dashed #b9c6d6;
  font-size:15.5px;color:#333;display:none;
}
.explain.show{display:block}
.explain .ex-tag{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:700;color:var(--accent);font-size:13px;display:block;margin-bottom:4px}

/* ---------- post-proof checkpoints ---------- */
.proof-cp-group{
  margin:18px 0 26px;padding:16px 18px 6px;border:1.5px dashed var(--thm);
  border-radius:var(--radius);background:linear-gradient(180deg,#fdf9ef,#fbf4e0);
}
.proof-cp-head{
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:800;font-size:13px;
  letter-spacing:.06em;text-transform:uppercase;color:var(--thm);margin-bottom:4px;
  display:flex;align-items:center;gap:8px;
}
.proof-cp-head::before{content:"";width:18px;height:18px;flex:none;border-radius:50%;
  background:radial-gradient(circle at 50% 45%,#fff 0 3px,transparent 4px),var(--thm);
}
.checkpoint.proof-cp{
  border:1.5px solid #e3cf94;background:linear-gradient(180deg,#fffdf8,#fdf6e6);margin:14px 0;
}
.checkpoint.proof-cp .cp-badge{background:linear-gradient(90deg,var(--thm),#c08a16)}
.cp-kind{
  display:inline-block;margin:0 0 10px 8px;font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-weight:700;font-size:11.5px;letter-spacing:.05em;text-transform:uppercase;color:var(--thm);
  background:#fbf0d2;border:1px solid #e3cf94;padding:3px 9px;border-radius:99px;vertical-align:middle;
}
.checkpoint.proof-cp .explain .ex-tag{color:var(--thm)}

/* ---------- item page subtitle ---------- */
.item-subttl{font-size:18px;color:var(--muted);margin-top:6px;font-style:italic}
.lead-in{margin:0 0 8px;color:var(--ink)}
.lead-in p:first-child{margin-top:0}

/* ---------- proof step-through ---------- */
.proof-stepper{
  margin:22px 0 26px;border:1px solid #d9e2ee;border-radius:var(--radius);
  background:#fafbfd;box-shadow:var(--shadow);overflow:hidden;
}
.proof-stepper-head{
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:800;font-size:13px;
  letter-spacing:.06em;text-transform:uppercase;color:var(--muted);
  background:#eef2f8;border-bottom:1px solid #e0e7f0;padding:11px 18px;
  display:flex;align-items:center;gap:9px;
}
.ps-ico{width:16px;height:16px;flex:none;border-radius:4px;
  background:linear-gradient(135deg,var(--accent),#28c08a)}
.ps-track{padding:8px 18px 4px}
.ps-step{
  position:relative;margin:0;padding:2px 0 2px 18px;border-left:3px dashed #c9d4e2;
  color:#2c3340;
  display:none;animation:psFade .45s ease both;
}
.ps-step.shown{display:block}
.ps-step > p{margin:10px 0}
.ps-step .qed{float:right;font-weight:700;color:var(--muted)}
@keyframes psFade{from{opacity:0;transform:translateY(6px)}to{opacity:1;transform:none}}
.ps-step::before{
  content:"";position:absolute;left:-7px;top:14px;width:11px;height:11px;border-radius:50%;
  background:var(--accent);box-shadow:0 0 0 3px #fff,0 0 0 4px #d9e2ee;
}
/* gate wrapper holds an in-proof checkpoint */
.ps-gatewrap{display:none;margin:6px 0 6px 18px}
.ps-gatewrap[data-locked="1"],
.ps-gatewrap[data-locked="0"]{display:block}
/* a gate is only visible once its preceding step is shown */
.ps-step:not(.shown) + .ps-gatewrap{display:none}
.checkpoint.proof-cp.ps-gate{border-color:#b9c6d6;background:linear-gradient(180deg,#f7faff,#eef5ff)}
.checkpoint.proof-cp.ps-gate .cp-badge{background:linear-gradient(90deg,var(--accent),#1390c9)}
.checkpoint.proof-cp.ps-gate .cp-kind{color:var(--accent);background:#e9f2fc;border-color:#b9d4ef}
.checkpoint.proof-cp.ps-gate .explain .ex-tag{color:var(--accent)}
.ps-gatewrap.unlocked .checkpoint{border-color:var(--ok);box-shadow:0 0 0 1px var(--ok-bg)}
.ps-controls{
  display:flex;align-items:center;gap:14px;padding:12px 18px 16px;
  border-top:1px solid #eaeff6;margin-top:6px;background:#f4f7fb;
}
.ps-next{
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:700;font-size:15px;
  color:#fff;background:linear-gradient(90deg,var(--accent),#1390c9);border:none;
  border-radius:99px;padding:10px 20px;cursor:pointer;transition:.16s;box-shadow:var(--shadow);
}
.ps-next:hover:not(:disabled){transform:translateY(-1px);filter:brightness(1.05)}
.ps-next:disabled{cursor:default;opacity:.55}
.ps-next.awaiting{background:#b9c6d6;opacity:1}
.ps-next.complete{background:var(--ok);opacity:1}
.ps-status{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:13px;color:var(--muted);font-weight:600}

/* ---------- section hub: item list ---------- */
.hub-blurb{color:var(--muted);font-size:16px;margin:0 0 18px}
.hub-intro{margin:0 0 22px}
.item-list{display:grid;grid-template-columns:1fr;gap:12px;margin:8px 0 26px}
.il-card{
  display:block;text-decoration:none;color:var(--ink);background:#fff;border:1px solid var(--line);
  border-left:6px solid var(--line);border-radius:12px;padding:14px 18px;box-shadow:var(--shadow);
  transition:.16s;
}
.il-card:hover{transform:translateY(-1px);box-shadow:0 8px 26px rgba(16,32,64,.1);border-left-color:var(--accent)}
.il-kind{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:800;font-size:11.5px;
  letter-spacing:.08em;text-transform:uppercase;display:block;margin-bottom:3px}
.il-ttl{font-size:18px;font-weight:700;color:var(--hkust)}
.il-paren{font-weight:500;color:var(--muted);font-size:16px}
.il-tags{display:block;margin-top:8px}
.il-tag{display:inline-block;font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:11.5px;
  font-weight:700;border-radius:99px;padding:3px 10px;margin:3px 6px 0 0}
.tag-cp{background:#e9f2fc;color:var(--accent)}
.tag-proof{background:#e8f6f3;color:var(--ex)}
.tag-gate{background:#fbf0d2;color:var(--thm)}
.il-card.sub-def{border-left-color:var(--def)} .il-card.sub-def .il-kind{color:var(--def)}
.il-card.sub-thm{border-left-color:var(--thm)} .il-card.sub-thm .il-kind{color:var(--thm)}
.il-card.sub-prop{border-left-color:var(--prop)} .il-card.sub-prop .il-kind{color:var(--prop)}
.il-card.sub-example{border-left-color:var(--ex)} .il-card.sub-example .il-kind{color:var(--ex)}
.il-card.sub-exercise{border-left-color:var(--exer)} .il-card.sub-exercise .il-kind{color:var(--exer)}
.il-card.sub-remark{border-left-color:#8a93a3} .il-card.sub-remark .il-kind{color:#5b6472}

/* ---------- page nav (prev/next) ---------- */
.pagenav{display:flex;gap:12px;margin:46px 0 10px;flex-wrap:wrap}
.pagenav a{
  flex:1 1 200px;text-decoration:none;border:1px solid var(--line);border-radius:12px;background:#fff;
  padding:14px 16px;box-shadow:var(--shadow);transition:.15s;color:var(--ink);
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;
}
.pagenav a:hover{border-color:var(--accent);transform:translateY(-1px)}
.pagenav .dir{font-size:12px;color:var(--muted);font-weight:700;letter-spacing:.08em;text-transform:uppercase}
.pagenav .ttl{font-size:16px;font-weight:700;color:var(--hkust);margin-top:3px}
.pagenav a.next{text-align:right}
.pagenav a.disabled{opacity:.35;pointer-events:none}

/* ---------- index page cards ---------- */
.toc-grid{display:grid;grid-template-columns:1fr;gap:16px;margin:10px 0 30px}
.toc-card{
  display:block;text-decoration:none;color:var(--ink);background:#fff;border:1px solid var(--line);
  border-radius:var(--radius);padding:20px 22px;box-shadow:var(--shadow);transition:.18s;position:relative;overflow:hidden;
}
.toc-card:hover{border-color:var(--accent);transform:translateY(-2px);box-shadow:0 8px 30px rgba(16,32,64,.12)}
.toc-card::before{content:"";position:absolute;left:0;top:0;bottom:0;width:6px;background:linear-gradient(180deg,var(--accent),#28c08a)}
.toc-card .num{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-weight:800;font-size:13px;letter-spacing:.1em;color:var(--accent);text-transform:uppercase}
.toc-card h3{margin:6px 0 6px;font-size:21px;color:var(--hkust);font-weight:800}
.toc-card p{margin:0;color:var(--muted);font-size:15px}
.toc-card .meta{margin-top:10px;font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:12.5px;color:var(--accent);font-weight:700}

.howto{background:#fff;border:1px solid var(--line);border-radius:var(--radius);padding:18px 20px;box-shadow:var(--shadow);margin:6px 0 26px}
.howto h3{margin:0 0 8px;font-size:16px;color:var(--hkust);font-family:-apple-system,Segoe UI,Roboto,sans-serif}
.howto ul{margin:0;padding-left:20px;color:var(--muted);font-size:15px}
.howto li{margin:4px 0}

/* misc */
.eq-note{color:var(--muted);font-size:15px}
hr.soft{border:none;border-top:1px solid var(--line);margin:30px 0}
.footer{margin-top:50px;padding-top:18px;border-top:1px solid var(--line);color:var(--muted);font-size:13px;font-family:-apple-system,Segoe UI,Roboto,sans-serif;text-align:center}

/* reset button */
.cp-reset{
  margin-top:18px;font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:13px;font-weight:600;
  background:#fff;border:1px solid var(--line);color:var(--muted);border-radius:99px;padding:7px 16px;cursor:pointer;transition:.15s;
}
.cp-reset:hover{border-color:var(--bad);color:var(--bad)}

@media (max-width:600px){
  body{font-size:17px}
  .hero h1{font-size:27px}
  .page-head h1{font-size:24px}
  .prog-track{width:90px}
}

/* print */
@media print{
  body{background:#fff;font-size:12pt}
  .topbar,.pagenav,.cp-reset,.prog-wrap{display:none!important}
  .hero{background:var(--hkust)!important;-webkit-print-color-adjust:exact;print-color-adjust:exact}
  .block,.checkpoint,figure.fig img{box-shadow:none}
  details.proofbox{border:1px solid #ccc}
  details.proofbox[open] .pf-body{display:block}
  .ps-step{display:block!important}
  .ps-gatewrap{display:block!important}
  .ps-controls{display:none!important}
  .explain,.verdict{display:block!important}
  a{color:inherit;text-decoration:none}
}

/* ============================================================
   EMBEDDED (inside the two-frame shell) — hide page chrome
   ============================================================ */
body.embed .topbar,
body.embed .pagenav,
body.embed .footer,
body.embed .cp-reset{ display:none !important; }
body.embed .wrap{ padding-top:26px; }
body.embed{ background:#fff; }

/* ============================================================
   TWO-FRAME SHELL (reader.html)
   ============================================================ */
html.shell, body.shell{ height:100%; margin:0; overflow:hidden; }
.shell-root{
  display:flex; height:100vh; width:100%;
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;
}
/* ----- left navigation frame (~10%) ----- */
.nav-frame{
  flex:0 0 10%; min-width:188px; max-width:300px;
  background:#0d1b2e; color:#dfe9f5;
  display:flex; flex-direction:column;
  border-right:1px solid #0a1525;
}
.nav-head{
  padding:18px 16px 14px; border-bottom:1px solid rgba(255,255,255,.10);
}
.nav-head .kick{ font-size:11px; letter-spacing:.16em; text-transform:uppercase; color:#7fb2e8; font-weight:700; margin:0 0 4px; }
.nav-head h1{ font-size:16px; line-height:1.25; margin:0; font-weight:800; color:#fff; }
.nav-head h1 a{ color:#fff; text-decoration:none; }
.nav-head .instructor{ font-size:12px; color:#cfe0f3; margin:7px 0 0; font-weight:600; }
.nav-head .sub{ font-size:12px; color:#9bb4d0; margin:5px 0 0; }
.nav-scroll{ flex:1 1 auto; overflow-y:auto; padding:8px 0 30px; }
.nav-scroll::-webkit-scrollbar{ width:9px; }
.nav-scroll::-webkit-scrollbar-thumb{ background:#2b466b; border-radius:6px; }
.nav-sec{ margin:2px 0; }
.nav-sec-h{
  display:block; padding:11px 16px 6px; font-size:11px; font-weight:800;
  letter-spacing:.10em; text-transform:uppercase; color:#6f97c4;
}
.nav-sec-h b{ color:#bcd4f0; font-weight:800; }
.nav-item{
  display:flex; align-items:baseline; gap:7px; cursor:pointer;
  padding:6px 16px 6px 18px; font-size:13px; line-height:1.3;
  color:#cdddf0; border-left:3px solid transparent; text-decoration:none;
}
.nav-item:hover{ background:rgba(255,255,255,.06); color:#fff; }
.nav-item.active{ background:rgba(20,120,210,.26); border-left-color:#3a9be8; color:#fff; font-weight:600; }
.nav-item .ni-kind{
  flex:0 0 auto; font-size:9.5px; font-weight:800; letter-spacing:.04em;
  text-transform:uppercase; padding:2px 5px; border-radius:4px; line-height:1;
  align-self:center; color:#fff;
}
.ni-kind.k-def{ background:#0a6ebd; }
.ni-kind.k-thm{ background:#9a6b00; }
.ni-kind.k-prop{ background:#5b3da8; }
.ni-kind.k-example{ background:#0f7a6c; }
.ni-kind.k-exercise{ background:#b5651d; }
.ni-kind.k-remark{ background:#516074; }
.nav-item .ni-ttl{ flex:1 1 auto; }
.nav-item .ni-sub{ display:block; font-size:11px; color:#90aacb; font-weight:400; margin-top:1px; }
.nav-item.active .ni-sub{ color:#bcd6f2; }

/* ----- right content frame (~90%): split into top (main) + bottom (reference) ----- */
.content-frame{
  flex:1 1 auto; position:relative; background:#eef2f7;
  display:flex; flex-direction:column; min-width:0; min-height:0;
}
/* TOP: the main reading pane */
.main-pane{
  position:relative; flex:1 1 auto; min-height:0;
  display:flex; flex-direction:column; background:#fff;
}
.main-pane iframe{ width:100%; height:100%; border:0; display:block; background:#fff; flex:1 1 auto; }
.cf-loading{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  font-size:14px; color:#5b7390; background:#eef2f7; z-index:2;
  transition:opacity .25s; font-family:-apple-system,Segoe UI,Roboto,sans-serif;
}
.cf-loading.hide{ opacity:0; pointer-events:none; }

/* divider between the two panes (visible only when the ref pane is open) */
.pane-divider{ flex:0 0 0; height:0; background:transparent; }
.ref-pane[data-open="1"] ~ .pane-divider,
.content-frame:has(.ref-pane[data-open="1"]) .pane-divider{
  height:3px; background:linear-gradient(90deg,var(--accent),#28c08a);
}

/* BOTTOM: the cross-reference pane (collapsed until a reference is clicked) */
.ref-pane{
  flex:0 0 auto; display:flex; flex-direction:column; min-height:0;
  background:#f6f9fd; border-top:1px solid var(--line);
  height:0; overflow:hidden;
  transition:height .28s cubic-bezier(.2,.7,.2,1), border-color .2s;
}
.ref-pane[data-open="1"]{ height:40%; min-height:170px; border-top-color:#bcd2ec; }
.ref-head{
  flex:0 0 auto; display:flex; align-items:center; justify-content:space-between;
  padding:7px 14px; background:#eaf2fb; border-bottom:1px solid #d2e2f4;
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;
}
.ref-head-label{
  display:inline-flex; align-items:center; gap:7px;
  font-size:12px; font-weight:800; letter-spacing:.08em; text-transform:uppercase;
  color:var(--hkust-2);
}
.ref-head-label svg{ width:15px; height:15px; opacity:.85; }
.ref-head-target{
  text-transform:none; letter-spacing:0; font-weight:600; font-size:12.5px;
  color:var(--ink); padding-left:8px; margin-left:2px; border-left:1px solid #c2d6ee;
}
.ref-close{
  border:1px solid #c2d6ee; background:#fff; color:#5b7390; cursor:pointer;
  width:24px; height:24px; border-radius:6px; font-size:17px; line-height:1;
  display:flex; align-items:center; justify-content:center; padding:0;
}
.ref-close:hover{ background:#fdecee; color:var(--bad); border-color:#f3c2c9; }
.ref-body{ position:relative; flex:1 1 auto; min-height:0; background:#fff; }
.ref-body iframe{ width:100%; height:100%; border:0; display:block; background:#fff; }
.ref-placeholder{
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  text-align:center; padding:0 28px; font-size:13.5px; color:#7088a4; z-index:2;
  font-family:-apple-system,Segoe UI,Roboto,sans-serif; background:#fff;
}
.ref-placeholder.hide{ display:none; }
.ref-placeholder em{ color:var(--accent); font-style:normal; font-weight:600; }

/* mobile: stack the frames */
@media(max-width:760px){
  .shell-root{ flex-direction:column; height:auto; }
  html.shell, body.shell{ overflow:auto; height:auto; }
  .nav-frame{ flex:none; max-width:none; width:100%; max-height:42vh; }
  .content-frame{ height:auto; }
  .main-pane iframe{ height:80vh; }
  .ref-pane[data-open="1"]{ height:auto; }
  .ref-body iframe{ height:60vh; }
}

/* ======================================================================
   v3 additions: cover page, page-head kind tags, breadcrumb, in-frame nav
   ====================================================================== */

/* ---------- breadcrumb segments ---------- */
.crumb .crumb-sec{color:var(--accent);text-decoration:none;font-weight:700}
.crumb .crumb-sec:hover{text-decoration:underline}
.crumb .crumb-secn{color:var(--muted)}
.crumb .crumb-sep{color:#b9c4d4;margin:0 2px}
.crumb .crumb-strong{color:var(--hkust);font-weight:700}

/* ---------- page-head kind tag (block pages) ---------- */
.page-head .ph-kind{
  display:inline-block;font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-size:11.5px;font-weight:800;letter-spacing:.1em;text-transform:uppercase;
  padding:3px 9px;border-radius:99px;margin-bottom:8px;
  background:#eef2f7;color:var(--muted);
}
.page-head h2{font-size:27px;line-height:1.18;margin:2px 0 0;color:var(--hkust);font-weight:800;letter-spacing:-.01em}
.page-head h2 .ph-sub{display:block;font-size:16px;font-weight:600;color:var(--muted);margin-top:4px;letter-spacing:0}
.ph-kind.k-def{background:var(--def-bg);color:var(--def)}
.ph-kind.k-thm{background:var(--thm-bg);color:var(--thm)}
.ph-kind.k-prop{background:var(--prop-bg);color:var(--prop)}
.ph-kind.k-example{background:var(--ex-bg);color:var(--ex)}
.ph-kind.k-exercise{background:var(--exer-bg);color:var(--exer)}
.ph-kind.k-remark{background:#eef2f7;color:#475569}
.ph-kind.k-prose{background:#e9eef9;color:var(--accent)}

/* ---------- cover page ---------- */
.cover{max-width:720px;margin:8px auto 0;padding:18px 4px 0}
.cover-kick{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:13px;letter-spacing:.18em;text-transform:uppercase;color:var(--accent);font-weight:800;margin:0 0 18px}
.cover-ch{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:15px;letter-spacing:.22em;text-transform:uppercase;color:var(--muted);font-weight:700;margin:0 0 2px}
.cover-title{font-size:46px;line-height:1.08;margin:0 0 22px;color:var(--hkust);font-weight:800;letter-spacing:-.02em}
.cover-quote{
  margin:0 0 26px;padding:14px 20px;border-left:4px solid var(--accent);
  background:linear-gradient(135deg,#f3f8fd,#eef5fc);border-radius:0 10px 10px 0;
  font-style:italic;font-size:19px;color:var(--hkust);
}
.cover-quote cite{display:block;font-style:normal;font-size:14px;color:var(--muted);margin-top:8px;font-weight:600;font-family:-apple-system,Segoe UI,Roboto,sans-serif}
.cover-intro{font-size:18.5px;line-height:1.7;color:var(--ink);margin:0 0 30px}
.cover-secs{border-top:1px solid var(--line);padding-top:18px}
.cover-secs-h{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:12.5px;letter-spacing:.12em;text-transform:uppercase;color:var(--muted);font-weight:800;margin:0 0 10px}
.cover-secs ol{margin:0;padding-left:0;list-style:none;counter-reset:cs}
.cover-secs li{padding:7px 0;border-bottom:1px solid #eef2f7;font-size:16px;color:var(--ink)}
.cover-secs li b{color:var(--accent);font-family:-apple-system,Segoe UI,Roboto,sans-serif;margin-right:6px}

/* ---------- in-frame Previous / Next ---------- */
.framenav{
  display:flex;gap:14px;margin:40px 0 8px;padding-top:22px;
  border-top:1px solid var(--line);
}
.framenav a,.framenav span{
  flex:1 1 0;display:flex;flex-direction:column;gap:3px;
  padding:12px 16px;border:1px solid var(--line);border-radius:12px;
  text-decoration:none;background:#fff;transition:border-color .15s,box-shadow .15s,background .15s;
}
.framenav a:hover{border-color:var(--accent);box-shadow:0 3px 12px rgba(10,110,189,.12);background:#fafcff}
.framenav .fn-next{text-align:right}
.framenav .fn-dir{font-family:-apple-system,Segoe UI,Roboto,sans-serif;font-size:12px;font-weight:800;letter-spacing:.06em;text-transform:uppercase;color:var(--accent)}
.framenav .fn-ttl{font-size:14.5px;color:var(--hkust);font-weight:600;line-height:1.3}
.framenav .fn-disabled{opacity:.45;cursor:default;background:#f6f8fb}
.framenav .fn-disabled .fn-dir{color:var(--muted)}
.framenav .fn-disabled .fn-ttl{color:var(--muted)}

/* keep the in-frame nav VISIBLE in embed mode (unlike .topbar/.footer) */
body.embed .framenav{display:flex}

/* nav rail: cover entry + prose kind tag */
.nav-item .ni-kind.k-cover{background:var(--hkust);color:#fff}
.nav-item .ni-kind.k-prose{background:#e9eef9;color:var(--accent)}
.nav-item.nav-cover .ni-ttl{font-weight:700;color:var(--hkust)}

/* ======================================================================
   v4 additions: cross-reference inline links + exercise hint cards
   ====================================================================== */

/* ---------- inline cross-reference links (open in the bottom pane) ---------- */
a.xref{
  color:var(--accent); text-decoration:none; font-weight:600; cursor:pointer;
  border-bottom:1px dotted var(--accent);
  border-radius:2px; padding:0 .5px;
  transition:background .12s,color .12s,border-color .12s;
}
a.xref:hover{ background:#eaf4fd; color:var(--hkust-2); border-bottom-style:solid; }
a.xref:focus-visible{ outline:2px solid var(--accent); outline-offset:1px; }
/* keep cross-references visible inside the shell (do NOT hide in embed mode) */
body.embed a.xref{ display:inline; }

/* ---------- exercise hints (replace checkpoints on exercise pages) ---------- */
.hints{
  margin:24px 0 6px; padding:14px 16px 6px;
  border:1px solid #d9e6d3; border-left:5px solid #5a9b54;
  border-radius:12px; background:linear-gradient(180deg,#f6fbf4,#f1f8ee);
}
.hints-head{ display:flex; align-items:center; flex-wrap:wrap; gap:10px; margin-bottom:6px; }
.hints-badge{
  display:inline-flex; align-items:center; gap:7px;
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-size:12px; font-weight:800; letter-spacing:.06em; text-transform:uppercase;
  color:#fff; background:linear-gradient(90deg,#5a9b54,#3f8f6b);
  padding:4px 11px; border-radius:99px;
}
.hints-badge svg{ width:14px; height:14px; }
.hints-note{ font-family:-apple-system,Segoe UI,Roboto,sans-serif; font-size:12.5px; color:#5f7a55; font-style:italic; }
.hint{
  margin:8px 0; border:1px solid #d9e6d3; border-radius:10px;
  background:#fff; overflow:hidden;
}
.hint>summary{
  cursor:pointer; list-style:none; user-select:none;
  display:flex; align-items:center; gap:10px; padding:11px 14px;
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;
}
.hint>summary::-webkit-details-marker{ display:none; }
.hint-k{
  flex:0 0 auto; font-size:11px; font-weight:800; letter-spacing:.05em; text-transform:uppercase;
  color:#fff; background:#5a9b54; padding:3px 9px; border-radius:6px;
}
.hint-2 .hint-k{ background:#3f8f6b; }
.hint-t{ flex:1 1 auto; font-size:14px; font-weight:600; color:var(--ink); }
.hint-chev{ flex:0 0 auto; font-size:18px; color:#5a9b54; transition:transform .2s; line-height:1; }
.hint[open] .hint-chev{ transform:rotate(90deg); }
.hint[open]>summary{ border-bottom:1px solid #e6efe1; background:#f8fcf6; }
.hint-body{ padding:12px 16px 14px; font-size:15.5px; line-height:1.65; color:var(--ink); }
.hint-body p{ margin:0 0 8px; }
.hint-body p:last-child{ margin-bottom:0; }
.hint-body a.xref{ font-weight:600; }
/* keep hints visible inside the shell */
body.embed .hints{ display:block; }

/* ======================================================================
   PART 1 additions: simplified Chapter->Section nav, smaller arrow
   prev/next, section hero pages, readiness-quiz pages
   ====================================================================== */

/* ---------- simplified nav rail: Chapter -> Section only ---------- */
.nav-ch{ margin:4px 0 8px; }
.nav-item.nav-chh{
  display:flex; flex-direction:column; gap:2px; align-items:flex-start;
  padding:12px 16px 10px; border-left:3px solid transparent;
  border-top:1px solid rgba(255,255,255,.06);
}
.nav-item.nav-chh .ni-ch{
  font-size:10.5px; font-weight:800; letter-spacing:.14em; text-transform:uppercase;
  color:#7fb2e8;
}
.nav-item.nav-chh .ni-ch-ttl{ font-size:14.5px; font-weight:800; color:#fff; line-height:1.2; }
.nav-item.nav-chh:hover{ background:rgba(255,255,255,.06); }
.nav-item.nav-chh.active{ background:rgba(20,120,210,.30); border-left-color:#3a9be8; }

.nav-item.nav-secitem{
  display:flex; align-items:baseline; gap:9px;
  padding:7px 16px 7px 22px; font-size:13px; line-height:1.3; color:#cdddf0;
  border-left:3px solid transparent; text-decoration:none;
}
.nav-item.nav-secitem .ni-secno{
  flex:0 0 auto; font-size:11px; font-weight:800; color:#8fb6e4; min-width:26px;
}
.nav-item.nav-secitem .ni-ttl{ flex:1 1 auto; }
.nav-item.nav-secitem:hover{ background:rgba(255,255,255,.06); color:#fff; }
.nav-item.nav-secitem.active{
  background:rgba(20,120,210,.26); border-left-color:#3a9be8; color:#fff; font-weight:600;
}
.nav-item.nav-secitem.active .ni-secno{ color:#bcd6f2; }

.nav-item.nav-preface{
  display:flex; align-items:center;
  padding:9px 16px 9px 22px; font-size:13.5px; font-weight:700; color:#cdddf0;
  border-left:3px solid transparent; text-decoration:none; letter-spacing:.01em;
}
.nav-item.nav-preface:hover{ background:rgba(255,255,255,.06); color:#fff; }
.nav-item.nav-preface.active{
  background:rgba(20,120,210,.26); border-left-color:#3a9be8; color:#fff;
}

/* ---------- preface page ---------- */
.preface-body{ max-width:760px; }
.preface-courses{ margin:10px 0 16px; padding-left:22px; }
.preface-courses li{ margin:4px 0; }
.preface-sign{ margin-top:22px; text-align:right; color:var(--muted); line-height:1.6; }
.preface-note{
  margin-top:26px; padding:14px 16px; border-radius:var(--radius);
  background:#f3f7fc; border:1px solid var(--line);
  font-size:13.5px; color:#41506a; line-height:1.6;
}

/* ---------- SMALLER arrow Previous / Next ---------- */
.framenav.framenav-sm{
  display:flex; gap:10px; margin:34px 0 6px; padding-top:18px;
  border-top:1px solid var(--line); justify-content:space-between;
}
.framenav.framenav-sm a,
.framenav.framenav-sm span{
  flex:0 0 auto; display:inline-flex; align-items:center; gap:6px;
  padding:7px 13px; border:1px solid var(--line); border-radius:9px;
  text-decoration:none; background:#fff; color:var(--hkust);
  font-size:13px; font-weight:700; line-height:1;
  transition:border-color .15s, box-shadow .15s, background .15s, color .15s;
}
.framenav.framenav-sm a:hover{
  border-color:var(--accent); color:var(--accent);
  box-shadow:0 2px 8px rgba(10,110,189,.12); background:#fafcff;
}
.framenav.framenav-sm .fn-ico{ width:16px; height:16px; flex:0 0 auto; }
.framenav.framenav-sm .fn-dir{
  font-family:-apple-system,Segoe UI,Roboto,sans-serif; font-size:13px;
  font-weight:700; letter-spacing:.01em; text-transform:none;
}
.framenav.framenav-sm .fn-disabled{ opacity:.4; cursor:default; background:#f6f8fb; color:var(--muted); }
.framenav.framenav-sm .framenav-name{
  flex:1 1 auto; justify-content:center; text-align:center;
  border:0; background:none; padding:7px 8px; box-shadow:none;
  color:var(--muted); font-size:12px; font-weight:600;
  letter-spacing:.01em; white-space:nowrap;
}
body.embed .framenav.framenav-sm{ display:flex; }

/* ---------- section hero (section-heading page) ---------- */
.sec-hero{ margin:10px 0 6px; padding:8px 0 4px; }
.sec-hero-kick{
  font-family:-apple-system,Segoe UI,Roboto,sans-serif; font-size:12.5px;
  font-weight:800; letter-spacing:.12em; text-transform:uppercase;
  color:var(--accent); margin:0 0 8px;
}
.sec-hero-title{
  font-size:34px; line-height:1.12; margin:0 0 16px; color:var(--hkust);
  font-weight:800; letter-spacing:-.015em;
}
.sec-hero-lead{ font-size:16.5px; line-height:1.7; color:var(--ink); max-width:62ch; }
.sec-hero-lead p{ margin:0 0 12px; }

/* ---------- readiness quiz page ---------- */
.ph-kind.k-quiz{ background:#fff3e0; color:#b5651d; }
.nav-item .ni-kind.k-quiz{ background:#b5651d; color:#fff; }
.quiz-body{ max-width:64ch; }
.quiz-intro{
  font-size:15.5px; line-height:1.7; color:var(--ink); background:#f3f7fc;
  border:1px solid #dce8f5; border-left:4px solid var(--accent);
  border-radius:10px; padding:14px 16px; margin:4px 0 22px;
}
.qz-q{
  border:1px solid var(--line); border-radius:12px; padding:16px 18px;
  margin:0 0 18px; background:#fff; box-shadow:0 1px 3px rgba(15,40,80,.04);
}
.qz-head{ display:flex; align-items:baseline; gap:10px; flex-wrap:wrap; margin-bottom:8px; }
.qz-num{
  font-family:-apple-system,Segoe UI,Roboto,sans-serif; font-size:12px; font-weight:800;
  letter-spacing:.06em; text-transform:uppercase; color:var(--accent);
}
.qz-topic{ font-size:12.5px; font-weight:700; color:#6b7c93; }
.qz-stem{ font-size:15.5px; line-height:1.65; color:var(--ink); margin:0 0 10px; }
.qz-controls{ margin:6px 0 0; }
.qz-controls .reveal-btn,
.reveal-btn{
  background:#eef2f6; color:var(--hkust); border:1px solid var(--line);
  border-radius:8px; padding:7px 13px; font-size:13px; font-weight:700;
  cursor:pointer; font-family:-apple-system,Segoe UI,Roboto,sans-serif;
}
.reveal-btn:hover{ background:#e2e9f0; border-color:var(--accent); color:var(--accent); }
.qz-sol{
  display:none; margin-top:12px; padding:13px 15px; border-radius:10px;
  background:#f1faf4; border:1px solid #c8e9d6; border-left:4px solid #1f9d57;
  font-size:14.5px; line-height:1.65; color:#143b27;
}
.qz-sol.show{ display:block; }
.qz-video{
  margin-top:12px; font-size:13.5px; line-height:1.6; color:#6b4a16;
  background:#fff7ec; border:1px solid #f0dcc0; border-radius:9px; padding:10px 13px;
}
.qz-video b{ color:#a85e12; }
.qz-video a{ color:#a85e12; text-decoration:none; font-weight:600; display:inline-block; margin-right:14px; }
.qz-video a:hover{ text-decoration:underline; }
.quiz-foot{
  font-size:14px; color:#516074; font-style:italic; margin:18px 0 0;
  padding-top:14px; border-top:1px dashed var(--line);
}
.ni-kind.k-fig{ background:#3a7d44; }
.ph-kind.k-fig{ background:#e7f4ea; color:#2f6b3a; }

/* ============================================================
   Part 1 revision: prerequisite topic pages (replace quizzes)
   + subsection anchor targets for cross-references
   ============================================================ */
.ph-kind.k-prereq{ background:#e7f0ff; color:#1d4ed8; }
.prereq-body{ max-width:70ch; }
.prereq-intro{
  font-size:15.5px; line-height:1.7; color:var(--ink);
  background:#f6f9ff; border:1px solid #dbe6fb; border-left:4px solid #1d4ed8;
  border-radius:10px; padding:14px 16px; margin:0 0 22px;
}
.prereq-group{
  border:1px solid var(--line,#e6e9ef); border-radius:12px;
  padding:14px 18px 8px; margin:0 0 18px; background:#fff;
}
.prereq-group-head{
  display:flex; align-items:center; gap:9px;
  font-weight:800; font-size:15px; color:var(--hkust,#0a3d62);
  letter-spacing:-.01em; margin:0 0 6px;
}
.prereq-group-head svg{ width:18px; height:18px; color:#1d4ed8; flex:none; }
.prereq-list{ margin:4px 0 8px; padding-left:22px; }
.prereq-list li{
  font-size:15px; line-height:1.62; color:var(--ink);
  margin:0 0 9px; padding-left:2px;
}
.prereq-list li b{ color:var(--hkust,#0a3d62); }
.prereq-foot{
  font-size:13.5px; color:var(--muted,#64748b); line-height:1.6;
  margin:20px 0 0; padding-top:12px; border-top:1px dashed #d7dde6;
}

/* anchor target wrappers: give a little scroll offset under sticky topbar */
.anchor-item{ scroll-margin-top:74px; }
.anchor-item.xref-flash,
.xref-flash{ animation:xrefFlash 1.6s ease-out 1; }
@keyframes xrefFlash{
  0%{ background:#fff6d8; box-shadow:0 0 0 6px #fff6d8; }
  100%{ background:transparent; box-shadow:0 0 0 0 transparent; }
}

/* ---------- Chinese poem epigraph (Chapter 4) ---------- */
.cover-quote .poem-zh{
  display:block; font-style:normal;
  font-family:"Noto Serif TC","Songti TC","Songti SC",STSong,SimSun,
    "Source Han Serif TC",serif;
  font-size:22px; line-height:1.95; letter-spacing:.06em;
  color:var(--hkust); font-weight:500;
}

/* ======================================================================
   PHASE 3 additions:
   (a) subsection tab strip at top of each page
   (b) Scope / Hint / Solution exercise buttons
   (c) exercise-helper page panels (shown in the bottom reference pane)
   ====================================================================== */

/* ---------- (a) subsection tab strip ---------- */
.subtabs{
  margin:2px 0 18px; padding:0;
  border-bottom:1px solid var(--line);
}
.subtabs-inner{
  display:flex; gap:6px; flex-wrap:wrap; align-items:stretch;
  overflow-x:auto; padding-bottom:2px;
}
.subtab{
  display:inline-flex; align-items:center; gap:8px; flex:0 0 auto;
  max-width:300px; text-decoration:none;
  padding:8px 13px 9px; border:1px solid var(--line); border-bottom:none;
  border-radius:10px 10px 0 0; background:#f4f7fb; color:var(--muted);
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-size:13px; line-height:1.2; font-weight:600;
  transition:background .14s,color .14s,border-color .14s;
}
.subtab:hover{ background:#eaf2fb; color:var(--hkust-2); border-color:#c4d4e8; }
.subtab.active{
  background:#fff; color:var(--hkust); border-color:var(--line);
  position:relative; box-shadow:0 -2px 0 var(--accent) inset;
}
.subtab .subtab-no{
  flex:0 0 auto; font-size:11.5px; font-weight:800; color:var(--accent);
  letter-spacing:.01em;
}
.subtab.active .subtab-no{ color:var(--hkust-2); }
.subtab .subtab-tt{
  flex:1 1 auto; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
}
.subtab.subtab-bg{
  gap:6px; font-weight:700; color:var(--exer);
  background:#fdf6ec; border-color:#f0dcc2;
}
.subtab.subtab-bg::before{
  content:""; width:7px; height:7px; border-radius:50%;
  background:var(--exer); flex:0 0 auto;
}
.subtab.subtab-bg:hover{ background:#fbeedc; color:#9a531a; }
.subtab.subtab-bg.active{
  background:#fff; color:var(--exer); box-shadow:0 -2px 0 var(--exer) inset;
}
body.embed .subtabs{ display:block; }

/* ---------- (b) Scope / Hint / Solution buttons ---------- */
.ex-actions{
  display:flex; align-items:center; flex-wrap:wrap; gap:9px;
  margin:18px 0 6px; padding:12px 14px;
  border:1px solid #d9e6d3; border-left:5px solid #5a9b54;
  border-radius:12px; background:linear-gradient(180deg,#f6fbf4,#f1f8ee);
}
.ex-actions-lab{
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-size:12px; font-weight:800; letter-spacing:.05em; text-transform:uppercase;
  color:#5f7a55; margin-right:2px;
}
.ex-btn{
  display:inline-flex; align-items:center; gap:7px; cursor:pointer;
  padding:7px 14px; border-radius:99px; border:1px solid transparent;
  font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-size:13px; font-weight:700; line-height:1; color:#fff;
  transition:filter .14s, box-shadow .14s, transform .04s;
}
.ex-btn svg{ width:15px; height:15px; flex:0 0 auto; }
.ex-btn:hover{ filter:brightness(1.06); box-shadow:0 2px 9px rgba(16,32,64,.16); }
.ex-btn:active{ transform:translateY(1px); }
.ex-btn:focus-visible{ outline:2px solid var(--ink); outline-offset:2px; }
.ex-btn-scope{ background:linear-gradient(90deg,#0a6ebd,#1390c9); }
.ex-btn-hint{ background:linear-gradient(90deg,#5a9b54,#3f8f6b); }
.ex-btn-sol{ background:linear-gradient(90deg,#9a6b00,#c08a16); }
body.embed .ex-actions{ display:flex; }

/* ---------- (c) exercise-helper page panels ---------- */
.exhelp-body{ max-width:64ch; }
.exhelp{
  margin:0 0 18px; border:1px solid var(--line); border-radius:12px;
  background:#fff; overflow:hidden; box-shadow:var(--shadow);
}
.exhelp-head{
  display:flex; align-items:center; gap:9px;
  padding:11px 16px; font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-size:13px; font-weight:800; letter-spacing:.02em; color:#fff;
}
.exhelp-head svg{ width:16px; height:16px; flex:0 0 auto; }
.exhelp-scope{ background:linear-gradient(90deg,#0a6ebd,#1390c9); }
.exhelp-hint{ background:linear-gradient(90deg,#5a9b54,#3f8f6b); }
.exhelp-sol{ background:linear-gradient(90deg,#9a6b00,#c08a16); }
.exhelp-text{
  padding:14px 18px 16px; font-size:15.5px; line-height:1.7; color:var(--ink);
}
.exhelp-text p{ margin:0 0 10px; }
.exhelp-text p:last-child{ margin-bottom:0; }
.exhelp-text ul,.exhelp-text ol{ margin:6px 0 10px 1.2em; }
.exhelp-text li{ margin:3px 0; }
.exhelp-text a.xref{ font-weight:600; }
/* anchor target flash also applies to whole helper sections */
.exhelp.xref-flash{ animation:xrefFlash 1.6s ease-out 1; }
body.embed .exhelp{ display:block; }

/* ---------- (b2) inline Scope / Hint panels (expand inside exercise box) ---------- */
.ex-help{ margin:18px 0 6px; }
.ex-help .ex-actions{ margin:0; }
.ex-btn[data-toggle].open{ box-shadow:0 0 0 2px rgba(255,255,255,.6) inset, 0 2px 9px rgba(16,32,64,.18); }
.ex-inline{
  margin:10px 0 0; border:1px solid var(--line); border-radius:11px;
  background:#fff; overflow:hidden; box-shadow:var(--shadow);
  animation:exInlineIn .18s ease;
}
.ex-inline[hidden]{ display:none; }
@keyframes exInlineIn{ from{opacity:0; transform:translateY(-4px);} to{opacity:1; transform:none;} }
.ex-inline-head{
  display:flex; align-items:center; gap:8px;
  padding:9px 14px; font-family:-apple-system,Segoe UI,Roboto,sans-serif;
  font-size:12.5px; font-weight:800; letter-spacing:.02em; color:#fff;
}
.ex-inline-head svg{ width:15px; height:15px; flex:0 0 auto; }
.ex-inline-scope .ex-inline-head{ background:linear-gradient(90deg,#0a6ebd,#1390c9); }
.ex-inline-hint .ex-inline-head{ background:linear-gradient(90deg,#5a9b54,#3f8f6b); }
.ex-inline-text{
  padding:12px 16px 14px; font-size:15px; line-height:1.65; color:var(--ink);
}
.ex-inline-text p{ margin:0 0 8px; }
.ex-inline-text p:last-child{ margin-bottom:0; }
.ex-inline-text ul,.ex-inline-text ol{ margin:5px 0 8px 1.2em; }
.ex-inline-text li{ margin:3px 0; }
.ex-inline-text a.xref{ font-weight:600; }
body.embed .ex-inline{ display:block; }
body.embed .ex-inline[hidden]{ display:none; }
