/* ============================================================
   传热学数字教材 · Design System
   Heat Transfer Digital Textbook — global stylesheet
   Grounded in Bird, Stewart & Lightfoot "Transport Phenomena" (2e, 2002)
   ============================================================ */

:root {
  /* ---- Brand & accent palette (warm "heat" theme) ---- */
  --ember-50:  #fff7ed;
  --ember-100: #ffedd5;
  --ember-200: #fed7aa;
  --ember-300: #fdba74;
  --ember-400: #fb923c;
  --ember-500: #f97316;
  --ember-600: #ea580c;
  --ember-700: #c2410c;

  --cool-400: #38bdf8;
  --cool-500: #0ea5e9;
  --cool-600: #0284c7;
  --cool-700: #0369a1;

  --violet-500: #8b5cf6;
  --green-500: #10b981;
  --rose-500:  #f43f5e;

  /* ---- Neutral scale ---- */
  --ink-900: #0f172a;
  --ink-800: #1e293b;
  --ink-700: #334155;
  --ink-600: #475569;
  --ink-500: #64748b;
  --ink-400: #94a3b8;
  --ink-300: #cbd5e1;
  --ink-200: #e2e8f0;
  --ink-100: #f1f5f9;
  --ink-50:  #f8fafc;
  --white:   #ffffff;

  /* ---- Semantic tokens (light) ---- */
  --bg:        var(--ink-50);
  --bg-soft:   var(--white);
  --bg-sunken: var(--ink-100);
  --surface:   var(--white);
  --surface-2: var(--ink-50);
  --border:    var(--ink-200);
  --border-strong: var(--ink-300);
  --text:      var(--ink-900);
  --text-soft: var(--ink-700);
  --text-mute: var(--ink-500);
  --accent:    var(--ember-600);
  --accent-soft: var(--ember-100);
  --accent-ink:  var(--ember-700);
  --link:      var(--cool-600);
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.10);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.06);
  --shadow-lg: 0 18px 40px rgba(15,23,42,.14), 0 6px 12px rgba(15,23,42,.08);
  --radius:    16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --maxw:      1180px;
  --sidebar-w: 290px;
  --font-sans: "Noto Sans SC", -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Noto Serif SC", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

[data-theme="dark"] {
  --bg:        #0b1220;
  --bg-soft:   #0f1a2e;
  --bg-sunken: #0a0f1c;
  --surface:   #111c33;
  --surface-2: #0e1830;
  --border:    #1e2c47;
  --border-strong: #2b3c5e;
  --text:      #e8eef9;
  --text-soft: #b6c4dd;
  --text-mute: #7e8cab;
  --accent:    var(--ember-400);
  --accent-soft: rgba(251,146,60,.16);
  --accent-ink:  var(--ember-300);
  --link:      var(--cool-400);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
  --shadow-md: 0 6px 18px rgba(0,0,0,.45);
  --shadow-lg: 0 22px 50px rgba(0,0,0,.55);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background .35s ease, color .35s ease;
}

h1, h2, h3, h4 { line-height: 1.25; font-weight: 800; letter-spacing: -.01em; color: var(--text); }
h1 { font-size: clamp(1.9rem, 4vw, 2.9rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); margin-top: 2.4rem; }
h3 { font-size: 1.3rem; margin-top: 1.8rem; }
h4 { font-size: 1.08rem; margin-top: 1.4rem; }
p  { margin: 1rem 0; color: var(--text-soft); }
a  { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout helpers ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.section { padding: 72px 0; }
.section-tight { padding: 44px 0; }

/* ============================================================
   TOP NAV (global)
   ============================================================ */
.topnav {
  position: sticky; top: 0; z-index: 70;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(160%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topnav__inner {
  max-width: var(--maxw); margin: 0 auto; padding: 12px 24px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-left: calc(24px + env(safe-area-inset-left, 0px));
  padding-right: calc(24px + env(safe-area-inset-right, 0px));
  display: flex; align-items: center; gap: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand__logo {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, var(--ember-500), var(--ember-700));
  display: grid; place-items: center; color: #fff; font-size: 20px;
  box-shadow: 0 6px 16px rgba(234,88,12,.35);
}
.brand__name { font-size: 1.05rem; }
.brand__name small { display:block; font-weight:500; font-size:.7rem; color: var(--text-mute); letter-spacing:.08em; }
.topnav__spacer { flex: 1; }
.topnav__links { display: flex; gap: 4px; align-items: center; }
.topnav__links a {
  padding: 8px 14px; border-radius: 9px; color: var(--text-soft); font-weight: 600; font-size: .95rem;
}
.topnav__links a:hover { background: var(--bg-sunken); text-decoration: none; color: var(--text); }
.topbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border-radius: 10px; border: 1px solid var(--border); background: var(--surface);
  color: var(--text-soft); cursor: pointer; font-size: 18px;
}
.topbtn:hover { color: var(--text); border-color: var(--border-strong); }

/* ============================================================
   HERO
   ============================================================ */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(1200px 500px at 80% -10%, rgba(249,115,22,.20), transparent 60%),
    radial-gradient(900px 500px at 0% 110%, rgba(14,165,233,.16), transparent 55%),
    linear-gradient(160deg, #0b1220 0%, #15233f 55%, #1b2c4d 100%);
  color: #f2f7ff;
}
.hero__inner { max-width: var(--maxw); margin: 0 auto; padding: 84px 24px 96px; position: relative; z-index: 2; }
.hero h1 { color: #fff; max-width: 16ch; }
.hero p.lead { color: #c8d6ee; font-size: 1.18rem; max-width: 56ch; }
.hero__eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: #ffd9b8; background: rgba(249,115,22,.16); border: 1px solid rgba(249,115,22,.4);
  padding: 7px 14px; border-radius: 999px; margin-bottom: 22px;
}
.hero__cta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 30px; }
.btn {
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 13px 22px; border-radius: 12px; font-weight: 700; font-size: .98rem;
  border: 1px solid transparent; transition: transform .15s ease, box-shadow .2s ease, background .2s;
}
.btn:hover { text-decoration: none; transform: translateY(-2px); }
.btn-primary { background: linear-gradient(135deg, var(--ember-500), var(--ember-600)); color: #fff; box-shadow: 0 10px 26px rgba(234,88,12,.4); }
.btn-ghost { background: rgba(255,255,255,.08); color: #fff; border-color: rgba(255,255,255,.22); }
.btn-ghost:hover { background: rgba(255,255,255,.16); }
.btn-outline { background: var(--surface); color: var(--text); border-color: var(--border-strong); }

.hero__stats { display: flex; gap: 34px; flex-wrap: wrap; margin-top: 46px; }
.hero__stat .n { font-size: 1.9rem; font-weight: 800; color: #fff; }
.hero__stat .l { font-size: .86rem; color: #a9bcdc; }
.hero__canvas { position: absolute; inset: 0; z-index: 1; opacity: .55; }

/* ============================================================
   CARDS / GRID
   ============================================================ */
.grid { display: grid; gap: 22px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1024px){ .grid-3,.grid-4{ grid-template-columns: repeat(2,1fr);} }
@media (max-width: 560px){ .grid-2,.grid-3,.grid-4{ grid-template-columns: 1fr;} }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow-sm); transition: transform .2s ease, box-shadow .25s ease, border-color .2s;
}
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.card h3 { margin-top: 0; }
.card .ic { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; font-size: 22px; margin-bottom: 14px; }
.ic--ember { background: var(--accent-soft); color: var(--accent-ink); }
.ic--cool  { background: color-mix(in srgb, var(--cool-500) 16%, transparent); color: var(--cool-600); }
.ic--violet{ background: color-mix(in srgb, var(--violet-500) 16%, transparent); color: var(--violet-500); }
.ic--green { background: color-mix(in srgb, var(--green-500) 16%, transparent); color: var(--green-500); }
.kicker { font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }

/* feature card link */
.feature-link { display: block; color: inherit; }
.feature-link:hover { text-decoration: none; }

/* ============================================================
   CALLOUTS
   ============================================================ */
.callout {
  border-radius: var(--radius-sm); padding: 18px 20px; margin: 22px 0;
  border: 1px solid var(--border); border-left-width: 5px; background: var(--surface);
  display: flex; gap: 14px; align-items: flex-start;
}
.callout .c-ic { font-size: 22px; line-height: 1.4; }
.callout p:last-child { margin-bottom: 0; }
.callout--tip    { border-left-color: var(--green-500);  background: color-mix(in srgb, var(--green-500) 7%, var(--surface)); }
.callout--note   { border-left-color: var(--cool-500);   background: color-mix(in srgb, var(--cool-500) 7%, var(--surface)); }
.callout--warn   { border-left-color: var(--ember-500);  background: color-mix(in srgb, var(--ember-500) 8%, var(--surface)); }
.callout--analogy{ border-left-color: var(--violet-500); background: color-mix(in srgb, var(--violet-500) 8%, var(--surface)); }
.callout__title { font-weight: 800; margin: 0 0 4px; color: var(--text); }

/* ============================================================
   FORMULA BLOCKS
   ============================================================ */
.formula {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 20px 22px; margin: 18px 0; text-align: center; overflow-x: auto;
}
.formula .eq { font-family: var(--font-mono); font-size: 1.12rem; color: var(--accent-ink); }
.formula .cap { font-size: .9rem; color: var(--text-mute); margin-top: 8px; }
.formula .eq sub, .formula .eq sup { font-size: .72em; }

code.inline { font-family: var(--font-mono); background: var(--bg-sunken); padding: 2px 7px; border-radius: 6px; font-size: .9em; color: var(--accent-ink); }

pre.code {
  background: #0d1426; color: #d7e2f4; border-radius: var(--radius-sm); padding: 18px 20px;
  overflow-x: auto; font-family: var(--font-mono); font-size: .9rem; line-height: 1.6;
}
pre.code .cm { color: #6b89b8; }

/* ============================================================
   TABLES
   ============================================================ */
.tablewrap { overflow-x: auto; margin: 22px 0; border: 1px solid var(--border); border-radius: var(--radius-sm); }
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { background: var(--surface-2); font-weight: 700; color: var(--text); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }

/* ============================================================
   READER LAYOUT (chapters): sidebar + content
   ============================================================ */
.reader { display: grid; grid-template-columns: var(--sidebar-w) 1fr; gap: 0; align-items: start; }
.sidebar {
  position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px);
  overflow-y: auto; padding: 26px 18px 60px; border-right: 1px solid var(--border);
  background: var(--bg-soft);
}
.sidebar__title { font-size: .76rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--text-mute); margin: 18px 12px 8px; }
.sidebar a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  color: var(--text-soft); font-size: .96rem; font-weight: 500;
}
.sidebar a .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-300); flex: none; }
.sidebar a:hover { background: var(--bg-sunken); text-decoration: none; color: var(--text); }
.sidebar a.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.sidebar a.active .dot { background: var(--accent); }
.sidebar a.done .dot { background: var(--green-500); }
.sidebar a .num { font-variant-numeric: tabular-nums; color: var(--text-mute); font-size: .82rem; }

.content { padding: 40px clamp(20px, 4vw, 64px) 100px; min-width: 0; max-width: 920px; }
.content > h1 { margin-top: 0; }
.chapter-meta { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0 28px; }
.tag { font-size: .76rem; font-weight: 700; padding: 5px 11px; border-radius: 999px; background: var(--bg-sunken); color: var(--text-mute); border: 1px solid var(--border); }

/* progress bar in sidebar */
.progress { margin: 6px 12px 14px; }
.progress__track { height: 8px; border-radius: 999px; background: var(--bg-sunken); overflow: hidden; }
.progress__fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--ember-500), var(--ember-600)); transition: width .4s ease; }
.progress__label { font-size: .76rem; color: var(--text-mute); margin-top: 6px; }

/* prev/next pager */
.pager { display: flex; justify-content: space-between; gap: 14px; margin-top: 56px; }
.pager a { flex: 1; padding: 16px 20px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.pager a:hover { border-color: var(--accent); text-decoration: none; }
.pager .dir { font-size: .78rem; color: var(--text-mute); }
.pager .ttl { font-weight: 700; color: var(--text); }
.pager .next { text-align: right; }

/* ============================================================
   INTERACTIVE WIDGETS
   ============================================================ */
.widget {
  background: linear-gradient(180deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; margin: 28px 0; box-shadow: var(--shadow-sm);
}
.widget__head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.widget__head .badge { font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: #fff; background: var(--ember-600); padding: 4px 10px; border-radius: 999px; }
.widget__head h4 { margin: 0; }
.widget__desc { color: var(--text-mute); font-size: .95rem; margin: 0 0 18px; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-bottom: 18px; }
.ctrl label { display: flex; justify-content: space-between; font-size: .85rem; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }
.ctrl label .val { color: var(--accent-ink); font-family: var(--font-mono); }
.ctrl input[type="range"] { width: 100%; accent-color: var(--ember-500); }
.readout { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.readout .chip { background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; }
.readout .chip .k { font-size: .82rem; color: var(--text-mute); }
.readout .chip .v { font-size: 1.15rem; font-weight: 800; color: var(--text); font-family: var(--font-mono); }
.readout .chip .v small { font-size: .7rem; font-weight: 600; color: var(--text-mute); }
canvas.sim { width: 100%; height: auto; display: block; border-radius: var(--radius-sm); background: var(--bg-sunken); border: 1px solid var(--border); }

/* ============================================================
   QUIZ
   ============================================================ */
.quiz { margin: 30px 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
.quiz__head { padding: 16px 22px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; display:flex; align-items:center; gap:10px;}
.quiz__body { padding: 22px; }
.quiz__q { font-weight: 700; margin: 0 0 16px; color: var(--text); }
.quiz__opts { display: grid; gap: 10px; }
.quiz__opt {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; border: 1.5px solid var(--border);
  border-radius: 11px; cursor: pointer; transition: border-color .15s, background .15s;
}
.quiz__opt:hover { border-color: var(--border-strong); background: var(--surface-2); }
.quiz__opt input { margin-top: 4px; accent-color: var(--ember-500); }
.quiz__opt.correct { border-color: var(--green-500); background: color-mix(in srgb, var(--green-500) 10%, var(--surface)); }
.quiz__opt.wrong { border-color: var(--rose-500); background: color-mix(in srgb, var(--rose-500) 10%, var(--surface)); }
.quiz__feedback { margin-top: 14px; font-size: .93rem; padding: 12px 16px; border-radius: 10px; display: none; }
.quiz__feedback.show { display: block; }
.quiz__feedback.ok { background: color-mix(in srgb, var(--green-500) 10%, var(--surface)); color: var(--green-500); border:1px solid color-mix(in srgb,var(--green-500) 40%, transparent);}
.quiz__feedback.no { background: color-mix(in srgb, var(--rose-500) 10%, var(--surface)); color: var(--rose-500); border:1px solid color-mix(in srgb,var(--rose-500) 40%, transparent);}
.quiz__btn { margin-top: 16px; }

/* ============================================================
   RESERVED / PLACEHOLDER ("to be filled")
   ============================================================ */
.reserved {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 40px 28px; text-align: center; background: var(--surface-2); margin: 26px 0;
}
.reserved .ph-ic { font-size: 38px; opacity: .55; }
.reserved h4 { margin: 12px 0 6px; }
.reserved p { color: var(--text-mute); margin: 0 auto; max-width: 52ch; }
.reserved .meta { font-size: .8rem; color: var(--text-mute); margin-top: 14px; font-family: var(--font-mono); }

/* timeline / learning path */
.path { position: relative; margin: 30px 0; padding-left: 8px; }
.path__item { display: flex; gap: 20px; padding: 8px 0 28px; position: relative; }
.path__item::before { content:""; position:absolute; left: 19px; top: 40px; bottom: -8px; width: 2px; background: var(--border); }
.path__item:last-child::before { display: none; }
.path__node { width: 40px; height: 40px; border-radius: 50%; flex: none; display: grid; place-items: center; font-weight: 800; color:#fff; background: var(--ember-500); z-index: 1; box-shadow: var(--shadow-sm); }
.path__body h4 { margin: 4px 0 4px; }
.path__body p { margin: 0; font-size: .94rem; }

/* utility */
.center { text-align: center; }
.muted { color: var(--text-mute); }
.small { font-size: .86rem; }
.spacer-lg { height: 40px; }
.divider { height: 1px; background: var(--border); margin: 40px 0; }

/* footer */
.footer { background: var(--bg-soft); border-top: 1px solid var(--border); padding: 44px 0; margin-top: 40px; }
.footer__inner { max-width: var(--maxw); margin: 0 auto; padding: 0 24px; display: flex; gap: 30px; flex-wrap: wrap; justify-content: space-between; }
.footer a { color: var(--text-soft); }
.footer small { color: var(--text-mute); }

/* ---------- Animation embed card ---------- */
.anim-embed { margin: 1.8rem 0; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: #0b1020; box-shadow: var(--shadow); }
.anim-embed__bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: .7rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border); }
.anim-embed__title { font-weight: 700; font-size: .95rem; color: var(--text); }
.anim-embed__title .ic { margin-right: 6px; }
.anim-embed__bar a { font-size: .85rem; color: var(--ember-600); text-decoration: none; white-space: nowrap; font-weight: 600; }
.anim-embed__bar a:hover { text-decoration: underline; }
.anim-embed iframe { display: block; width: 100%; border: 0; background: #0b1020; }
.anim-embed__note { padding: .6rem 1rem .9rem; font-size: .9rem; color: var(--text-mute); background: var(--surface); border-top: 1px solid var(--border); }

/* ---------- Mobile navigation primitives (hidden on desktop) ---------- */
#navToggle { display: none; }
.mobile-menu { display: none; }
.nav-overlay {
  position: fixed; inset: 0; z-index: 55;
  background: color-mix(in srgb, var(--ink-900) 45%, transparent);
  opacity: 0; visibility: hidden; transition: opacity .3s ease, visibility .3s ease;
}
body.nav-open .nav-overlay { opacity: 1; visibility: visible; }

/* ============================================================
   TABLET & BELOW (<=1024px)
   Collapse the sidebar into an off-canvas drawer and show the
   hamburger, so tablets get a clean full-width reading layout
   instead of a cramped desktop sidebar.
   ============================================================ */
@media (max-width: 1024px) {
  .topnav__links { display: none; }
  #navToggle { display: inline-grid; }
  .topnav__inner {
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    padding-right: calc(16px + env(safe-area-inset-right, 0px));
    gap: 10px;
  }
  .brand__name small { display: none; }
  .brand__name { font-size: .98rem; }

  .reader { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100%;
    width: min(80vw, 320px); z-index: 60;
    padding: calc(72px + env(safe-area-inset-top, 0px)) 16px 40px;
    padding-left: calc(16px + env(safe-area-inset-left, 0px));
    border-right: 1px solid var(--border); box-shadow: var(--shadow-lg);
    background: var(--bg-soft);
    transform: translateX(-100%); transition: transform .3s ease;
  }
  body.nav-open .sidebar { transform: translateX(0); }

  .mobile-menu {
    display: none; position: absolute; top: 100%; left: 0; right: 0; z-index: 70;
    flex-direction: column; gap: 2px; padding: 8px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-md);
  }
  body.nav-open .mobile-menu { display: flex; }
  .mobile-menu a { padding: 14px 16px; border-radius: 10px; color: var(--text-soft); font-weight: 600; font-size: 1rem; }
  .mobile-menu a:hover { background: var(--bg-sunken); text-decoration: none; color: var(--text); }

  .wrap { padding: 0 20px; }
  .section { padding: 56px 0; }
  .section-tight { padding: 34px 0; }
  .content { padding: 34px 22px 90px; }
  .hero__inner { padding: 64px 22px 72px; }
  .hero__stat .n { font-size: 1.7rem; }
  .card { padding: 22px; }
  .widget { padding: 20px; }
  .formula .eq { font-size: 1.08rem; }
}

/* ============================================================
   PHONE (<=600px)
   Single-column cards, bigger tap targets, larger reading font.
   ============================================================ */
@media (max-width: 600px) {
  body { font-size: 17.5px; line-height: 1.8; }
  h1 { font-size: clamp(1.8rem, 7vw, 2.4rem); }
  p { margin: 1.1rem 0; }

  .wrap { padding: 0 16px; }
  .section { padding: 44px 0; }
  .section-tight { padding: 28px 0; }
  .content { padding: 26px 16px 80px; }
  .hero__inner { padding: 52px 16px 58px; }
  .hero p.lead { font-size: 1.08rem; }
  .hero__stats { gap: 16px; margin-top: 28px; }
  .hero__stat .n { font-size: 1.55rem; }
  .hero__stat .l { font-size: .82rem; }

  .card { padding: 20px; }
  .widget { padding: 18px; }
  .widget__desc { font-size: .92rem; }
  .controls { grid-template-columns: 1fr; gap: 14px; }
  .ctrl label { font-size: .92rem; }
  .readout { gap: 10px; }
  .readout .chip { flex: 1 1 calc(50% - 10px); padding: 12px 14px; }
  .readout .chip .k { font-size: .8rem; }
  .readout .chip .v { font-size: 1.1rem; }

  .pager { flex-direction: column; gap: 12px; }
  .pager .next { text-align: left; }
  .pager a { padding: 14px 18px; }

  .formula { padding: 16px 12px; }
  .formula .eq { font-size: 1.02rem; }
  .formula .cap { font-size: .86rem; }

  .callout { flex-direction: column; gap: 8px; padding: 16px 18px; }

  .tablewrap { margin: 18px -16px; border-radius: 0; border-left: none; border-right: none; }
  .footer__inner { gap: 20px; }
  .quiz__opt { padding: 14px 16px; font-size: 1.02rem; }
  .quiz__q { font-size: 1.05rem; }
}

/* ============================================================
   SMALL PHONE (<=400px)
   ============================================================ */
@media (max-width: 400px) {
  body { font-size: 17px; }
  .hero h1 { font-size: clamp(1.6rem, 9vw, 2.1rem); }
  .btn { padding: 12px 18px; font-size: .95rem; }
  .hero__cta { width: 100%; }
  .hero__cta .btn { width: 100%; justify-content: center; }
  h2 { margin-top: 1.6rem; font-size: 1.45rem; }
  .readout .chip { flex: 1 1 100%; }
}

/* ============================================================
   ENHANCEMENTS — polish, typography & motion
   ============================================================ */

/* selection + accessible focus ring */
::selection { background: color-mix(in srgb, var(--ember-500) 26%, transparent); color: var(--text); }
:focus-visible { outline: 2px solid var(--ember-500); outline-offset: 2px; border-radius: 6px; }

/* keep anchored headings clear of the sticky top nav */
.content h2, .content h3, .section h2 { scroll-margin-top: 84px; }

/* calmer, balanced hero text */
.hero__inner h1 { text-wrap: balance; }
.hero p.lead { text-wrap: pretty; }

/* a touch more breathing room for the content column on very wide screens */
@media (min-width: 1400px){ .content { max-width: 1000px; } }

/* refine interactive controls for touch */
.btn, .topbtn, .quiz__opt, .anim-embed__sound { -webkit-tap-highlight-color: transparent; }

/* ---- Scroll reveal (progressive enhancement; safe without JS) ---- */
.reveal-ready .reveal {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity .6s cubic-bezier(.16,1,.3,1), transform .6s cubic-bezier(.16,1,.3,1);
}
.reveal-ready .reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal-ready .reveal { opacity: 1 !important; transform: none !important; transition: none; }
  html { scroll-behavior: auto; }
}
