/* ============================================================
   Thermodynamics course — shared design system
   Modern technical / engineering aesthetic
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=IBM+Plex+Sans:ital,wght@0,400;0,500;0,600;0,700;1,400&family=IBM+Plex+Mono:wght@400;500;600&family=Noto+Sans+TC:wght@400;500;600;700&family=Noto+Serif+TC:wght@500;600&display=swap');

:root {
  /* ink + neutrals */
  --ink: #16181d;
  --ink-soft: #3a404c;
  --muted: #727a8a;
  --faint: #aeb4bf;
  --line: #e3e6ec;
  --line-soft: #eef0f4;
  --bg: #f5f6f9;
  --panel: #ffffff;

  /* brand */
  --brand: #5a3ec8;
  --brand-d: #46309f;
  --brand-soft: #efeafb;
  --brand-line: #ddd2f6;

  /* data accents */
  --hot: #e0663a;       /* vapor / heat */
  --hot-soft: #fbe9e1;
  --cool: #2f74d8;      /* cooling */
  --cool-soft: #e4eefb;
  --ok: #1f8a5b;
  --ok-soft: #e3f3eb;

  /* type */
  --display: 'Space Grotesk', sans-serif;
  --sans: 'IBM Plex Sans', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
  --tc: 'Noto Sans TC', sans-serif;
  --tc-serif: 'Noto Serif TC', serif;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(20,24,32,.04), 0 8px 28px -16px rgba(20,24,32,.18);
  --shadow-lg: 0 2px 6px rgba(20,24,32,.05), 0 24px 60px -28px rgba(20,24,32,.30);
  --maxw: 1180px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background-color: var(--bg);
  /* engineering graph-paper motif */
  background-image:
    linear-gradient(to right, rgba(90,62,200,.035) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(90,62,200,.035) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.6;
}

h1, h2, h3, h4 { font-family: var(--display); font-weight: 600; line-height: 1.15; letter-spacing: -0.01em; color: var(--ink); margin: 0; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-d); }

.mono { font-family: var(--mono); }

/* label / eyebrow */
.eyebrow {
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--brand);
}
.eyebrow.muted { color: var(--muted); }

/* ---------- layout helpers ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 32px; }
.stack > * + * { margin-top: 1rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,.82);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar .inner { display: flex; align-items: center; gap: 18px; height: 60px; max-width: var(--maxw); margin: 0 auto; padding: 0 32px; }
.brandmark { display: flex; align-items: center; gap: 11px; font-family: var(--display); font-weight: 600; font-size: 15.5px; letter-spacing: -.01em; color: var(--ink); }
.brandmark .glyph {
  width: 28px; height: 28px; border-radius: 7px;
  background: var(--brand); color: #fff;
  display: grid; place-items: center; font-family: var(--mono); font-weight: 600; font-size: 14px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.topbar .spacer { flex: 1; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  font-size: 13.5px; color: var(--ink-soft); padding: 7px 12px; border-radius: 8px; font-weight: 500;
}
.topbar nav a:hover { background: var(--line-soft); color: var(--ink); }
.topbar nav a.active { color: var(--brand); background: var(--brand-soft); }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--sans); font-weight: 500; font-size: 14px;
  padding: 10px 16px; border-radius: 10px; border: 1px solid transparent; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); color:#fff; }
.btn-ghost { background: var(--panel); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--brand-line); background: var(--brand-soft); }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- chips / pills ---------- */
.pill { display: inline-flex; align-items:center; gap:6px; font-family: var(--mono); font-size: 11px; letter-spacing: .04em; text-transform: uppercase; font-weight: 500; padding: 4px 9px; border-radius: 999px; }
.pill-live { background: var(--ok-soft); color: var(--ok); }
.pill-soon { background: var(--line-soft); color: var(--muted); }
.pill-brand { background: var(--brand-soft); color: var(--brand); }
.pill .dot { width:6px; height:6px; border-radius:50%; background: currentColor; }

/* ---------- KaTeX sizing ---------- */
.katex { font-size: 1.04em; }
.katex-display { margin: .9em 0; overflow-x: auto; overflow-y: hidden; padding: 2px 0; }

/* ============================================================
   Interactive "lab" widgets (shared across chapters)
   ============================================================ */
.lab { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin: 26px 0; }
.lab-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; background: linear-gradient(180deg, #fcfbff, #fff); }
.lab-head .lab-title { font-family: var(--display); font-weight: 600; font-size: 16px; }
.lab-head .lab-sub { color: var(--muted); font-size: 13px; }
.lab-head .spacer { flex: 1; }

.lab-grid { display: grid; grid-template-columns: 1.35fr 1fr; }
@media (max-width: 860px) { .lab-grid { grid-template-columns: 1fr; } }
.lab-chart { padding: 14px 14px 8px; border-right: 1px solid var(--line); min-width: 0; }
@media (max-width: 860px) { .lab-chart { border-right: none; border-bottom: 1px solid var(--line); } }
.lab-panel { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }

/* segmented control */
.seg { display: inline-flex; background: var(--line-soft); border-radius: 10px; padding: 3px; gap: 3px; flex-wrap: wrap; }
.seg button { font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: var(--ink-soft); background: transparent; border: none; padding: 7px 12px; border-radius: 8px; cursor: pointer; transition: background .14s, color .14s, box-shadow .14s; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: #fff; color: var(--brand-d); box-shadow: var(--shadow); }

/* sliders */
.control { display: flex; flex-direction: column; gap: 7px; }
.control .lbl { display: flex; justify-content: space-between; align-items: baseline; }
.control .lbl span { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.control .lbl b { font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--brand-d); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 999px; background: var(--line); outline: none; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--brand); cursor: pointer; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(20,24,32,.25); }
input[type=range]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--brand); cursor: pointer; border: 3px solid #fff; box-shadow: 0 1px 4px rgba(20,24,32,.25); }
input[type=range].hot::-webkit-slider-thumb { background: var(--hot); }
input[type=range].hot::-moz-range-thumb { background: var(--hot); }

/* readout grid */
.readout { display: grid; grid-template-columns: 1fr 1fr; gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.readout .ro { background: var(--panel); padding: 10px 12px; }
.readout .ro .k { font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); display:flex; align-items:center; gap:5px; }
.readout .ro .k .sw { width: 8px; height: 8px; border-radius: 2px; }
.readout .ro .v { font-family: var(--display); font-weight: 600; font-size: 19px; margin-top: 3px; letter-spacing: -.01em; }
.readout .ro .v small { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 3px; letter-spacing: 0; }
.readout .ro.accent .v { color: var(--hot); }
.readout .ro.brand .v { color: var(--brand-d); }

/* result strip */
.results { display: grid; gap: 10px; }

/* site footer (chapter pages) */
footer.site { border-top: 1px solid var(--line); padding: 28px 0 60px; color: var(--muted); font-size: 13px; margin-top: 20px; }
footer.site .wrap { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
footer.site .credit { flex-basis: 100%; order: -1; color: var(--ink-soft); font-size: 13.5px; padding-bottom: 14px; margin-bottom: 4px; border-bottom: 1px solid var(--line-soft); line-height: 1.5; }
footer.site .credit b { color: var(--ink); font-weight: 600; }

/* in-the-wild phenomenon blocks */
.phenomenon { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 22px 0; align-items: start; }
@media (max-width: 720px) { .phenomenon { grid-template-columns: 1fr; } }
.phen-img image-slot { display: block; width: 100%; height: 220px; }
.phen-img { min-width: 0; }
.phen-body { min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.phen-hook { font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.note.think { border-color: #d4c4f0; background: #f6f2fc; }
.note.think .note-h { color: #6a3ec2; }
.note.think ul { margin: 0; padding-left: 18px; }
.note.think li { font-size: 13.5px; color: var(--ink-soft); margin: 5px 0; line-height: 1.5; }
.note.think strong { color: var(--ink); }
.think-answers { display: none; margin-top: 10px; padding-top: 10px; border-top: 1px solid #d4c4f0; }
.think-answers.open { display: block; }
.think-answers ol { margin: 0; padding-left: 18px; }
.think-answers li { font-size: 13px; color: var(--ink-soft); margin: 6px 0; line-height: 1.55; }
.think-answers strong { color: var(--ink); }
.think-toggle { margin-top: 10px; font-family: var(--sans); font-size: 12.5px; font-weight: 500; color: #6a3ec2; background: #ede6fb; border: none; padding: 6px 13px; border-radius: 8px; cursor: pointer; }
.think-toggle:hover { background: #ddd0f8; }

/* real-world application link cards */
.appcard { display: flex; gap: 14px; align-items: flex-start; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin: 14px 0; background: linear-gradient(180deg, #fbfcff, #fff); text-decoration: none; color: inherit; transition: border-color .15s, box-shadow .15s, transform .15s; }
.appcard:hover { border-color: var(--brand-line); box-shadow: var(--shadow); transform: translateY(-1px); }
.appcard .ac-ico { flex: none; width: 42px; height: 42px; border-radius: 10px; background: var(--brand-soft); color: var(--brand-d); display: grid; place-items: center; }
.appcard .ac-ico svg { width: 20px; height: 20px; display: block; }
.appcard.hot .ac-ico { background: var(--hot-soft); color: var(--hot); }
.appcard.cool .ac-ico { background: var(--cool-soft); color: var(--cool); }
.appcard .ac-body { min-width: 0; }
.appcard .ac-kind { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); font-weight: 600; }
.appcard.hot .ac-kind { color: var(--hot); }
.appcard.cool .ac-kind { color: var(--cool); }
.appcard .ac-title { font-family: var(--display); font-weight: 600; font-size: 15px; margin: 2px 0 3px; color: var(--ink); }
.appcard .ac-desc { font-size: 13px; color: var(--muted); line-height: 1.45; }
.appcard .ac-host { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-top: 5px; }
.appcard-label { font-family: var(--mono); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 22px 0 2px; display: flex; align-items: center; gap: 8px; }
.appcard-label::before { content: ''; width: 14px; height: 1px; background: var(--faint); }

.result-row { display: flex; justify-content: space-between; align-items: baseline; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fcfcfe; }
.result-row .rl { font-size: 13px; color: var(--ink-soft); }
.result-row .rv { font-family: var(--mono); font-weight: 600; font-size: 15px; color: var(--ink); }
.result-row.major { background: var(--brand-soft); border-color: var(--brand-line); }
.result-row.major .rv { color: var(--brand-d); font-size: 17px; }

.hint { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 7px; }
.hint .kbd { font-family: var(--mono); font-size: 11px; background: var(--line-soft); border: 1px solid var(--line); border-radius: 5px; padding: 1px 6px; }

/* verdict badge (second law) */
.verdict { border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; border: 1px solid var(--line); }
.verdict .vlabel { font-family: var(--display); font-weight: 600; font-size: 16px; }
.verdict .vsub { font-family: var(--mono); font-size: 11.5px; color: var(--muted); }
.verdict.ok { background: var(--ok-soft); border-color: #b9e0cb; } .verdict.ok .vlabel { color: var(--ok); }
.verdict.warn { background: #fdf8ee; border-color: #e6d9c4; } .verdict.warn .vlabel { color: #9a7b2e; }
.verdict.no { background: var(--hot-soft); border-color: #f0c4b2; } .verdict.no .vlabel { color: var(--hot); }

/* ============================================================
   Chapter reading layout
   ============================================================ */
.chapter-shell { display: grid; grid-template-columns: 244px minmax(0,1fr); gap: 48px; max-width: 1240px; margin: 0 auto; padding: 0 32px; align-items: start; }
@media (max-width: 1000px) { .chapter-shell { grid-template-columns: 1fr; gap: 0; } .chapter-toc { display: none; } }

.chapter-toc { position: sticky; top: 76px; padding: 28px 0; max-height: calc(100vh - 90px); overflow-y: auto; }
.chapter-toc .toc-label { font-family: var(--mono); font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-bottom: 12px; }
.chapter-toc a { display: block; font-size: 13.5px; color: var(--ink-soft); padding: 5px 12px; border-left: 2px solid var(--line); line-height: 1.35; transition: color .14s, border-color .14s; }
.chapter-toc a:hover { color: var(--ink); border-color: var(--brand-line); }
.chapter-toc a.active { color: var(--brand-d); border-color: var(--brand); font-weight: 600; }
.chapter-toc a.sub { padding-left: 22px; font-size: 12.5px; color: var(--muted); }

.prose { padding: 36px 0 90px; max-width: 760px; min-width: 0; }
.prose section { scroll-margin-top: 76px; padding: 22px 0; }
.prose h2 { font-size: 28px; margin: 8px 0 4px; }
.prose h3 { font-size: 19px; margin: 26px 0 6px; }
.prose h2 + .sec-kicker { margin-top: 2px; }
.sec-kicker { font-family: var(--mono); font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--brand); margin-bottom: 6px; }
.prose p { color: var(--ink-soft); margin: 12px 0; }
.prose ul { color: var(--ink-soft); padding-left: 20px; }
.prose ul li { margin: 6px 0; }
.prose strong { color: var(--ink); font-weight: 600; }

/* equation callout */
.eqn { background: #fbfbfe; border: 1px solid var(--line); border-left: 3px solid var(--brand); border-radius: 0 10px 10px 0; padding: 6px 18px; margin: 18px 0; display: flex; align-items: center; gap: 16px; }
.eqn .eqn-body { flex: 1; min-width: 0; overflow-x: auto; }
.eqn .eqn-tag { font-family: var(--mono); font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* schematic figure (e.g. cooling tower) */
.tower-fig { margin: 22px 0; padding: 18px 18px 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.tower-fig svg { display: block; width: 100%; max-width: 560px; height: auto; margin: 0 auto; }
.tower-fig .twr-badge text { font-family: var(--mono); font-weight: 600; font-size: 15px; fill: #fff; text-anchor: middle; dominant-baseline: central; }
.tower-fig .twr-sym { font-family: var(--mono); font-size: 12.5px; fill: var(--ink-soft); }
.tower-fig .twr-sym-r { text-anchor: end; }
.tower-fig .tower-legend { display: flex; flex-wrap: wrap; gap: 8px 18px; justify-content: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.tower-fig .tower-legend > span { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-soft); }
.tower-fig .tower-legend > span b { width: 19px; height: 19px; border-radius: 50%; background: var(--brand); color: #fff; font-family: var(--mono); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.tower-fig figcaption { margin-top: 12px; font-size: 13px; line-height: 1.6; color: var(--muted); text-align: center; }

/* component / block-diagram schematic (e.g. reheat cycle) */
.cyc-fig { margin: 22px 0; padding: 18px 18px 14px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.cyc-fig svg { display: block; width: 100%; max-width: 700px; height: auto; margin: 0 auto; }
.cyc-fig .cyc-cl { font-family: var(--display); font-weight: 600; font-size: 12.5px; fill: var(--ink); text-anchor: middle; }
.cyc-fig .cyc-sub { font-family: var(--mono); font-size: 10.5px; fill: var(--muted); text-anchor: middle; }
.cyc-fig .cyc-badge text { font-family: var(--mono); font-weight: 600; font-size: 12px; fill: #fff; text-anchor: middle; dominant-baseline: central; }
.cyc-fig .cyc-badge.ghost circle { fill: #fff; stroke: var(--brand); stroke-width: 1.5; stroke-dasharray: 3 2; }
.cyc-fig .cyc-badge.ghost text { fill: var(--brand); }
.cyc-fig figcaption { margin-top: 12px; font-size: 13px; line-height: 1.6; color: var(--muted); text-align: center; }
.cite { display: block; margin-top: 5px; font-family: var(--mono); font-size: 11px; letter-spacing: .02em; color: var(--faint); }
.cite a { color: var(--brand); text-decoration: none; border-bottom: 1px solid var(--brand-line); }
.cite a:hover { border-bottom-color: var(--brand); }

/* state-definition table */
.states-tbl { width: 100%; border-collapse: collapse; margin: 16px 0 4px; font-size: 13.5px; }
.states-tbl th { text-align: left; font-family: var(--mono); font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.states-tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); color: var(--ink-soft); vertical-align: top; line-height: 1.45; }
.states-tbl td:first-child { white-space: nowrap; }
.states-tbl tr.ghost-row td { background: #fcfbff; color: var(--muted); }
.st-badge { display: inline-flex; align-items: center; justify-content: center; width: 23px; height: 23px; border-radius: 50%; background: var(--brand); color: #fff; font-family: var(--mono); font-size: 12px; font-weight: 600; }
.st-badge.ghost { background: #fff; color: var(--brand); border: 1.5px dashed var(--brand); }

/* annotated efficiency terms */
.eta-annot { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 16px 0; }
@media (max-width: 640px) { .eta-annot { grid-template-columns: 1fr; } }
.eta-col { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff; }
.eta-h { font-family: var(--mono); font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; font-weight: 600; padding: 9px 14px; color: #fff; }
.eta-h.work { background: var(--brand); }
.eta-h.heat { background: var(--hot); }
.eta-term2 { padding: 9px 14px; border-top: 1px solid var(--line-soft); }
.eta-term2 .sym { font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--ink); }
.eta-term2 .desc { font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; line-height: 1.45; }

/* real-data comparison table (e.g. Taipower fleet efficiency) */
.eff-tbl { width: 100%; border-collapse: collapse; margin: 12px 0 10px; font-size: 13.5px; }
.eff-tbl th { text-align: right; font-family: var(--mono); font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.eff-tbl th:first-child { text-align: left; }
.eff-tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); color: var(--ink-soft); text-align: right; font-variant-numeric: tabular-nums; }
.eff-tbl td:first-child { text-align: left; color: var(--ink); }
.eff-tbl tr.hi td { background: var(--brand-soft); color: var(--brand-d); font-weight: 600; }
.eff-tbl tr.hi td:first-child { color: var(--brand-d); }
.eff-tbl tr.sub td { color: var(--muted); font-style: italic; border-top: 1px solid var(--line); }

/* definition / note callouts */
.note { border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; margin: 18px 0; background: var(--panel); }
.note.def { border-color: var(--brand-line); background: var(--brand-soft); }
.note.tip { border-color: #e6d9c4; background: #fdf8ee; }
.note .note-h { font-family: var(--mono); font-size: 11px; letter-spacing: .1em; text-transform: uppercase; font-weight: 600; margin-bottom: 6px; }
.note.def .note-h { color: var(--brand-d); }
.note.tip .note-h { color: #9a7b2e; }
.note p { margin: 4px 0; }

/* worked example */
.example { border: 1px solid var(--line); border-radius: 12px; margin: 22px 0; overflow: hidden; }
.example > summary { cursor: pointer; list-style: none; padding: 14px 18px; display: flex; align-items: center; gap: 12px; font-weight: 600; font-family: var(--display); background: #faf9fd; }
.example > summary::-webkit-details-marker { display: none; }
.example > summary .ex-tag { font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: #fff; background: var(--ink); padding: 3px 8px; border-radius: 6px; }
.example > summary .chev { margin-left: auto; transition: transform .2s; color: var(--muted); }
.example[open] > summary .chev { transform: rotate(90deg); }
.example .ex-body { padding: 6px 20px 18px; border-top: 1px solid var(--line); }
.example .ex-body p { color: var(--ink-soft); }
.ex-step { padding-left: 16px; border-left: 2px solid var(--line-soft); margin: 14px 0; }

/* data table */
table.dt { border-collapse: collapse; width: 100%; font-size: 13.5px; margin: 16px 0; }
table.dt th, table.dt td { border: 1px solid var(--line); padding: 8px 12px; text-align: right; }
table.dt th { background: var(--line-soft); font-family: var(--mono); font-weight: 500; font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; color: var(--ink-soft); }
table.dt td:first-child, table.dt th:first-child { text-align: left; }
table.dt tr.total td { font-weight: 600; background: #fbfbfe; }

/* chapter hero */
.chapter-hero { border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fff, transparent); }
.chapter-hero .wrap { padding: 40px 32px 30px; max-width: 1240px; }
.chapter-hero .crumb { font-family: var(--mono); font-size: 12px; color: var(--muted); margin-bottom: 14px; }
.chapter-hero .crumb a { color: var(--muted); }
.chapter-hero .crumb a:hover { color: var(--brand); }
.chapter-hero h1 { font-size: clamp(30px, 4.5vw, 46px); letter-spacing: -.02em; max-width: 20ch; }
.chapter-hero .ch-lede { font-size: 17px; color: var(--ink-soft); max-width: 64ch; margin-top: 14px; }
.chapter-hero .ch-tags { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }

/* quiz */
.quiz { margin: 26px 0; }
.quiz-head { margin-bottom: 16px; }
.quiz-head h3 { margin: 10px 0 4px; font-size: 22px; }
.quiz-sub { color: var(--muted); font-size: 14px; margin: 0; }
.quiz-q { border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin: 12px 0; background: var(--panel); }
.quiz-q-head { display: flex; gap: 12px; margin-bottom: 14px; }
.quiz-num { font-size: 12px; color: var(--brand); font-weight: 600; padding-top: 2px; }
.quiz-q-text { font-weight: 500; color: var(--ink); }
.quiz-choices { display: grid; gap: 8px; }
.quiz-choice { display: flex; align-items: center; gap: 11px; text-align: left; padding: 11px 13px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); cursor: pointer; font-family: var(--sans); font-size: 14px; color: var(--ink-soft); transition: border-color .14s, background .14s; }
.quiz-choice:hover:not(.locked) { border-color: var(--brand-line); background: var(--brand-soft); }
.quiz-key { font-family: var(--mono); font-size: 12px; font-weight: 600; width: 22px; height: 22px; border-radius: 6px; background: var(--line-soft); color: var(--muted); display: grid; place-items: center; flex-shrink: 0; }
.quiz-label { flex: 1; }
.quiz-mark { width: 18px; text-align: center; font-weight: 700; }
.quiz-choice.locked { cursor: default; }
.quiz-choice.correct { border-color: var(--ok); background: var(--ok-soft); color: var(--ink); }
.quiz-choice.correct .quiz-key { background: var(--ok); color: #fff; }
.quiz-choice.correct .quiz-mark::after { content: '✓'; color: var(--ok); }
.quiz-choice.wrong { border-color: var(--hot); background: var(--hot-soft); }
.quiz-choice.wrong .quiz-key { background: var(--hot); color: #fff; }
.quiz-choice.wrong .quiz-mark::after { content: '✕'; color: var(--hot); }
.quiz-explain { margin-top: 12px; padding: 12px 14px; border-radius: 9px; font-size: 13.5px; color: var(--ink-soft); line-height: 1.55; }
.quiz-explain.ok { background: var(--ok-soft); }
.quiz-explain.no { background: var(--hot-soft); }
.quiz-foot { margin-top: 6px; }
.quiz-score { font-size: 12.5px; color: var(--muted); }

/* selection */
::selection { background: var(--brand-soft); }

/* scrollbar (subtle) */
* { scrollbar-width: thin; scrollbar-color: var(--faint) transparent; }

/* in-class poll */
.poll { border:1px solid var(--brand-line); background:linear-gradient(180deg,#faf8ff,#fff); border-radius:12px; padding:16px 18px; margin:22px 0; }
.poll-head { display:flex; align-items:center; gap:8px; font-family:var(--mono); font-size:11px; letter-spacing:.07em; text-transform:uppercase; color:var(--brand-d); font-weight:600; margin-bottom:10px; }
.poll-dot { width:7px; height:7px; border-radius:50%; background:var(--brand); flex:none; }
.poll-q { font-weight:600; color:var(--ink); margin-bottom:12px; line-height:1.5; }
.poll .quiz-choices { display:grid; gap:8px; }

/* problem sets */
.pset { display:flex; flex-direction:column; gap:14px; margin:18px 0; }
.problem { border:1px solid var(--line); border-radius:12px; padding:16px 18px; background:var(--panel); }
.prob-head { display:flex; gap:12px; }
.prob-num { flex:none; width:30px; height:30px; border-radius:8px; background:var(--brand-soft); color:var(--brand-d); display:grid; place-items:center; font-size:12px; font-weight:600; }
.prob-q { font-weight:500; color:var(--ink); }
.prob-gf { font-size:13.5px; color:var(--ink-soft); margin:10px 0 0 42px; display:flex; flex-direction:column; gap:3px; }
.gf-k { font-family:var(--mono); font-size:10.5px; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); margin-right:6px; }
.prob-try { margin:12px 0; padding:9px 12px; border-radius:8px; background:var(--bg); color:var(--muted); font-size:13px; }
.prob-steps { display:flex; flex-direction:column; gap:10px; }
.prob-step, .prob-answer { display:flex; gap:10px; padding:11px 13px; border-radius:9px; border:1px solid var(--line-soft); background:#fcfcfe; font-size:14px; color:var(--ink-soft); }
.prob-answer { background:var(--brand-soft); border-color:var(--brand-line); color:var(--ink); }
.step-n { flex:none; font-size:10.5px; letter-spacing:.04em; text-transform:uppercase; color:var(--brand); padding-top:2px; }
.prob-answer .step-n { color:var(--brand-d); }
.prob-btn { margin-top:12px; font-family:var(--sans); font-weight:500; font-size:13.5px; color:#fff; background:var(--brand); border:none; padding:9px 16px; border-radius:9px; cursor:pointer; }
.prob-btn:hover { background:var(--brand-d); }

/* ============================================================
   Bilingual language toggle (EN default, 繁中 on toggle)
   ============================================================ */
html[data-lang-mode="en"] [data-lang="zh"] { display:none !important; }
html[data-lang-mode="zh"] [data-lang="en"] { display:none !important; }
html:not([data-lang-mode]) [data-lang="zh"] { display:none !important; }

[data-lang="zh"] { font-family:var(--tc); }
h1 [data-lang="zh"], h2 [data-lang="zh"], h3 [data-lang="zh"],
.chapter-hero h1 [data-lang="zh"], .sec-kicker [data-lang="zh"] { font-family:var(--tc-serif); font-weight:600; }
p [data-lang="zh"], li [data-lang="zh"] { line-height:1.75; }

.lang-toggle { display:inline-flex; margin-left:16px; border:1px solid var(--line); border-radius:7px; overflow:hidden; flex:none; }
.lang-toggle button { font-family:var(--mono); font-size:12px; font-weight:500; padding:5px 11px; background:transparent; border:none; color:var(--muted); cursor:pointer; transition:background .15s,color .15s; }
.lang-toggle button + button { border-left:1px solid var(--line); }
.lang-toggle button.on { background:var(--ink); color:#fff; }
.lang-toggle button:not(.on):hover { background:var(--line-soft); color:var(--ink); }

/* think-answers toggle: CSS-driven Show/Hide labels (robust to language switch) */
.think-toggle .lbl-hide { display:none; }
.think-toggle.open .lbl-show { display:none; }
.think-toggle.open .lbl-hide { display:inline; }
