/* 格物之學 — 全站設計系統
   風格：墨線 × 透明水彩（2026-09-22 改版）。
   鬆散的黑色線稿、連續輪廓與速寫筆觸；透明水彩色塊自由暈染，不必填在線內；
   保留手繪感、未完成感與大量留白。輕盈、詩意、優雅。
   做法：
   · 紙：暖白底＋極淡的紙紋雜訊。
   · 線：墨色細線，邊框用「不規則圓角」營造手繪的歪斜，卡片外再疊一條錯位的淡墨線。
   · 色：藤黃、玫瑰朱、鼠尾草綠、淺青、灰紫，外加靛青當主色。水彩色塊用 SVG 濾鏡 #nx-wc（邊緣暈開、邊緣略深），疊色用 multiply（夜間用 screen）。
   所有顏色一律走變數；新增元件請勿寫死色碼。 */

/* ── 色票 ───────────────────────────────────────────── */
:root {
  color-scheme: light;

  /* 紙 */
  --bg:         #F2EDE3;
  --bg-warm:    #F6F1E7;
  --surface:    #FBF8F1;
  --surface-2:  #FFFCF6;
  --tint:       #EEF0EA;   /* 極淡的鼠尾草綠水痕，用來填圖面 */
  --dusk:       #2B3A42;   /* 圖上的「遮光／黑暗」：深靛墨，不用純黑 */
  --halo:       rgba(234, 181, 47, .16);

  /* 墨 */
  --ink:        #1F1E1C;
  --ink-soft:   #4C4841;
  --ink-faint:  #8F887C;
  --line:       #CFC6B6;
  --line-soft:  #E3DCCF;

  /* 五個水彩色（沿用舊變數名，單元檔不需改動） */
  --mint:       #7FA68E;   /* 鼠尾草綠 */
  --pink:       #E46F6B;   /* 玫瑰朱：單元文字裡的「粉紅」 */
  --lilac:      #7B6CA0;   /* 灰紫：單元文字裡的「紫色」 */
  --butter:     #EAB52F;   /* 藤黃 */
  --sky:        #7FB0C0;   /* 淺青 */

  --accent:     #2F6F82;
  --accent-2:   #E46F6B;
  --accent-ink: #2A5F70;

  --ok:         #5F9468;
  --warn:       #D98A2B;
  --bad:        #D04A32;

  /* 科別 */
  --s-phy:   #3F7F99;
  --s-chem:  #E07B2F;
  --s-bio:   #6E9C57;
  --s-earth: #A7813A;
  --s-cross: #D9573F;

  /* 尺度帶：由小到大，從靛青走到藤黃再到朱紅 */
  --sc-quantum: #45708A;
  --sc-atom:    #5F93A8;
  --sc-mol:     #6FA398;
  --sc-cell:    #7FA66A;
  --sc-body:    #B6A43F;
  --sc-eco:     #E2B53A;
  --sc-earth:   #E6903B;
  --sc-star:    #DC6446;
  --sc-cosmos:  #8E6C8F;
  --sc-river:   #5F93A8;

  /* 手繪的不規則圓角 */
  --r-sm: 14px 10px 16px 9px / 10px 15px 9px 14px;
  --r:    22px 14px 24px 12px / 14px 22px 12px 24px;
  --r-lg: 30px 18px 34px 16px / 18px 30px 16px 34px;
  --r-pill: 255px 18px 225px 18px / 18px 225px 18px 255px;

  --shadow:    none;
  --shadow-lg: 0 10px 30px rgba(60, 50, 30, .08);

  --wc-blend: multiply;
  --wash-op: .42;

  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-read: "LXGW WenKai TC", "Noto Serif TC", serif;
  --measure: 34rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;

  /* 夜：深靛的紙，淺色的墨 */
  --bg:         #1C2124;
  --bg-warm:    #22282B;
  --surface:    #242B2F;
  --surface-2:  #2A3236;
  --tint:       #243035;
  --dusk:       #0E1214;
  --halo:       rgba(242, 200, 82, .12);

  --ink:        #EEE8DC;
  --ink-soft:   #C7BFB1;
  --ink-faint:  #8E887E;
  --line:       #465055;
  --line-soft:  #333C41;

  --mint:       #9CC4AA;
  --pink:       #F08A84;
  --lilac:      #A898C8;
  --butter:     #F2C852;
  --sky:        #9CC9D6;

  --accent:     #7FB6C9;
  --accent-2:   #F08A84;
  --accent-ink: #A3D2E2;

  --ok:         #8CC196;
  --warn:       #F0AE5A;
  --bad:        #F07C62;

  --s-phy:   #7FB6C9;
  --s-chem:  #F2A262;
  --s-bio:   #9CC98A;
  --s-earth: #D4B06A;
  --s-cross: #F2866B;

  --sc-quantum: #7FA3BD;
  --sc-atom:    #8FBCCF;
  --sc-mol:     #92C4B8;
  --sc-cell:    #A2C48E;
  --sc-body:    #D2C26A;
  --sc-eco:     #F2CB62;
  --sc-earth:   #F2AB66;
  --sc-star:    #F28B6E;
  --sc-cosmos:  #B494B5;
  --sc-river:   #8FBCCF;

  --shadow-lg: 0 10px 30px rgba(0, 0, 0, .35);
  --wc-blend: screen;
  --wash-op: .30;
}

/* 上課／列印模式：拉高對比、放大字級 */
:root[data-mode="class"] {
  --line: #A99F8E;
  --ink-soft: #3A3630;
  font-size: 19px;
}

/* ── 基底 ───────────────────────────────────────────── */
* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1rem;
  font-weight: 400;
  line-height: 1.85;
  letter-spacing: .02em;
  overflow-x: hidden;
}

/* 紙紋：極淡的雜訊，鋪滿整頁 */
body::after {
  content: "";
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='240'%3E%3Cfilter id='p'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .3 0 0 0 0 .22 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='240' height='240' filter='url(%23p)'/%3E%3C/svg%3E");
  background-size: 240px 240px;
  opacity: .9;
}
:root[data-theme="dark"] body::after { opacity: .55; }

/* 整頁的水痕：角落幾團極淡的暈染 */
body::before {
  content: "";
  position: fixed; inset: -10%; pointer-events: none; z-index: 0;
  background:
    radial-gradient(30rem 22rem at 88% 6%, color-mix(in srgb, var(--butter) 10%, transparent), transparent 70%),
    radial-gradient(26rem 20rem at 4% 12%, color-mix(in srgb, var(--sky) 10%, transparent), transparent 72%),
    radial-gradient(28rem 20rem at 70% 104%, color-mix(in srgb, var(--pink) 7%, transparent), transparent 70%);
}

main, header, footer { position: relative; z-index: 1; }

h1, h2, h3 { font-family: var(--font-read); line-height: 1.35; letter-spacing: .03em; font-weight: 400; margin: 0 0 .5em; }
h1 { font-size: clamp(2.1rem, 5.4vw, 3.3rem); font-weight: 400; }
h2 { font-size: clamp(1.45rem, 3.6vw, 2rem); }
h3 { font-size: 1.12rem; font-weight: 700; }

p { margin: 0 0 1em; max-width: var(--measure); }
a { color: var(--accent-ink); text-decoration-thickness: 1px; text-underline-offset: .26em; }
a:hover { text-decoration-color: var(--accent-2); }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); font-size: .9rem; }
.lede { font-family: var(--font-read); font-size: 1.14rem; color: var(--ink-soft); }
b, strong { font-weight: 700; color: var(--ink); }

.wrap { width: min(100% - 2rem, 68rem); margin-inline: auto; }
@media (min-width: 720px) { .wrap { width: min(100% - 4rem, 68rem); } }

/* ── 手繪線的共用做法 ───────────────────────────────── */
/* 一條錯位的淡墨線，疊在卡片、舞台外面，像速寫時多描的一筆 */
.card, .stage, .opt, .caution, .readout { position: relative; }
.card::before, .stage::before {
  content: "";
  position: absolute; inset: -3px -2px -2px -4px;
  border: 1px solid var(--ink);
  border-radius: var(--r);
  opacity: .14;
  transform: rotate(-.5deg);
  pointer-events: none;
  filter: url(#nx-rough);
}
.stage::before { border-radius: var(--r-lg); transform: rotate(.35deg); opacity: .18; }

/* ── 卡片與標籤 ─────────────────────────────────────── */
.card {
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border: 1px solid color-mix(in srgb, var(--ink) 48%, transparent);
  border-radius: var(--r);
  padding: 1.15rem 1.3rem;
}

/* 標籤：墨線圈起來的字，後面一抹水彩 */
.sticker {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .12rem .75rem;
  font-size: .82rem; font-weight: 500; letter-spacing: .08em;
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: var(--r-pill);
}
.sticker::before {
  content: "";
  position: absolute; inset: 10% -12% -18% 20%;
  z-index: -1;
  background: currentColor;
  border-radius: 58% 42% 63% 37% / 45% 55% 45% 55%;
  opacity: var(--wash-op);
  mix-blend-mode: var(--wc-blend);
  filter: url(#nx-wc);
}
.sticker[style*="color"] { -webkit-text-fill-color: var(--ink); border-color: var(--ink); }
.sticker[style*="s-phy"]::before   { background: var(--s-phy); }
.sticker[style*="s-chem"]::before  { background: var(--s-chem); }
.sticker[style*="s-bio"]::before   { background: var(--s-bio); }
.sticker[style*="s-earth"]::before { background: var(--s-earth); }

/* ── 首頁舞台 ───────────────────────────────────────── */
.stage-hero {
  position: relative;
  background: transparent;
  overflow: hidden;
  isolation: isolate;
}
.stage-hero .deco { position: absolute; inset: 0; pointer-events: none; z-index: -1; }

/* ── 裝飾層 ─────────────────────────────────────────── */
.deco-host { position: relative; isolation: isolate; overflow: hidden; }
.deco {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: -1;
}
.deco-band { display: block; width: 100%; height: auto; max-height: 70px; margin: .5rem 0 1.25rem; pointer-events: none; }
.deco .wc, .deco-band .wc { mix-blend-mode: var(--wc-blend); }

/* 夜間：大片的淡水痕在深色紙上會變成髒污，壓得更淡 */
:root[data-theme="dark"] .deco path.wc[opacity^="0.1"] { opacity: .06; }

/* 裝飾一律靜止：水彩濾鏡若跟著動畫每格重算，手機會很吃力 */

/* 段落標籤前面的一小枝墨線 */
.sec-label::before,
.brand::before {
  content: "";
  display: inline-block;
  width: 1.5em; height: 1.1em;
  background: var(--ink);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 26'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.3' stroke-linecap='round'%3E%3Cpath d='M2 23c9-2 17-8 24-19'/%3E%3Cpath d='M12 18c-3-4-2-8 1-10 1 4 1 7-1 10z'/%3E%3Cpath d='M19 12c1-4 5-6 8-5-2 3-5 5-8 5z'/%3E%3Cpath d='M26 4c2-1 4 0 5 2'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 26'%3E%3Cg fill='none' stroke='%23000' stroke-width='1.3' stroke-linecap='round'%3E%3Cpath d='M2 23c9-2 17-8 24-19'/%3E%3Cpath d='M12 18c-3-4-2-8 1-10 1 4 1 7-1 10z'/%3E%3Cpath d='M19 12c1-4 5-6 8-5-2 3-5 5-8 5z'/%3E%3Cpath d='M26 4c2-1 4 0 5 2'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

/* 標題：一團水彩墊在字的後面、偏一點位置，下方一筆墨線 */
.sec h2 {
  position: relative;
  isolation: isolate;
  display: inline-block;
  justify-self: start;
  padding: 0 .2em .3rem 0;
}
.sec h2::before {
  content: "";
  position: absolute;
  left: -.5em; top: .05em; width: 3.6em; height: 1.35em;
  z-index: -1;
  background: var(--wash, var(--butter));
  border-radius: 62% 38% 55% 45% / 48% 58% 42% 52%;
  opacity: var(--wash-op);
  mix-blend-mode: var(--wc-blend);
  filter: url(#nx-wc);
}
.sec h2::after {
  content: "";
  position: absolute; left: 0; right: -.4em; bottom: -.1rem; height: 9px;
  background: var(--ink);
  opacity: .85;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 9' preserveAspectRatio='none'%3E%3Cpath d='M1 6c40-3 90-4 140-3s110 2 158-1c-50 3-108 4-158 3S40 3 1 6z' fill='%23000'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 300 9' preserveAspectRatio='none'%3E%3Cpath d='M1 6c40-3 90-4 140-3s110 2 158-1c-50 3-108 4-158 3S40 3 1 6z' fill='%23000'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
#hook   { --wash: var(--butter); }
#guess  { --wash: var(--pink); }
#lab    { --wash: var(--sky); }
#why    { --wash: var(--mint); }
#limits { --wash: var(--pink); }
#across { --wash: var(--butter); }
#exam   { --wash: var(--lilac); }

/* 可點的卡片：右上角一支墨線小箭頭 */
a.card { color: inherit; text-decoration: none; }
a.card::after {
  content: "↗";
  position: absolute; top: .5rem; right: .85rem;
  font-family: var(--font-read);
  color: var(--ink-soft);
  font-size: 1rem;
  transition: transform .3s;
}
a.card:hover::after { transform: translate(2px, -2px); }
a.card:hover { border-color: var(--ink); }

/* 原創練習卡：左上角的「練習」字樣墊一抹藤黃 */
.sec .card > p:first-child b:first-child {
  position: relative; isolation: isolate;
  display: inline-block;
  padding: 0 .35rem;
  margin-right: .3rem;
  font-family: var(--font-read);
  font-weight: 400;
  font-size: 1rem;
}
.sec .card > p:first-child b:first-child::before {
  content: ""; position: absolute; inset: 15% -10% 0 -5%; z-index: -1;
  background: var(--butter); opacity: var(--wash-op);
  border-radius: 58% 42% 63% 37% / 45% 55% 45% 55%;
  mix-blend-mode: var(--wc-blend); filter: url(#nx-wc);
}

/* ── 按鈕與控制元件 ─────────────────────────────────── */
.btn {
  appearance: none;
  font: inherit;
  font-weight: 500;
  font-size: .95rem;
  letter-spacing: .06em;
  color: var(--ink);
  background: transparent;
  border: 1.2px solid var(--ink);
  border-radius: var(--r-pill);
  padding: .45rem 1.15rem;
  min-height: 44px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  text-decoration: none;
  white-space: nowrap;
  position: relative;
  isolation: isolate;
  transition: transform .15s, background .2s, border-color .2s;
}
.btn:hover  { background: color-mix(in srgb, var(--butter) 16%, transparent); }
.btn:active { transform: translateY(1px) rotate(-.3deg); }
.btn:focus-visible { outline: 1.5px dashed var(--accent); outline-offset: 3px; }
/* 主要按鈕：一抹溢出邊線的水彩 */
.btn.primary { border-color: var(--ink); }
.btn.primary::before {
  content: ""; position: absolute; inset: -4px -8px -3px -5px; z-index: -1;
  background:
    radial-gradient(60% 80% at 30% 55%, var(--pink), transparent 72%),
    radial-gradient(60% 80% at 75% 45%, var(--butter), transparent 72%);
  opacity: calc(var(--wash-op) + .1);
  border-radius: 45% 55% 48% 52% / 60% 40% 60% 40%;
  mix-blend-mode: var(--wc-blend);
  filter: url(#nx-wc);
  transition: opacity .2s;
}
.btn.primary:hover { background: transparent; }
.btn.primary:hover::before { opacity: calc(var(--wash-op) + .25); }
.btn.ghost { border-color: color-mix(in srgb, var(--ink) 45%, transparent); }
.btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--sky) 22%, transparent);
  border-color: var(--ink);
}
select.btn { text-align: left; padding-right: .6rem; background: var(--surface); }

.chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.chip {
  font: inherit;
  font-weight: 400;
  font-size: .88rem;
  padding: .2rem .85rem;
  min-height: 36px;
  border-radius: var(--r-pill);
  border: 1px solid color-mix(in srgb, var(--ink) 55%, transparent);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  transition: border-color .16s, background .2s, color .16s;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--ink);
  background: color-mix(in srgb, currentColor 0%, color-mix(in srgb, var(--butter) 24%, transparent));
}
.chip .dot {
  width: .7em; height: .6em;
  border-radius: 58% 42% 63% 37% / 45% 55% 45% 55%;
  background: currentColor; opacity: .75;
}

/* ── 科別標記 ───────────────────────────────────────── */
.tag {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .8rem; font-weight: 500; letter-spacing: .08em;
  padding: .06rem .6rem;
  color: var(--ink);
}
.tag::before {
  content: ""; position: absolute; inset: 20% -4% 0 0; z-index: -1;
  background: var(--tag-c, var(--butter));
  opacity: var(--wash-op);
  border-radius: 58% 42% 63% 37% / 45% 55% 45% 55%;
  mix-blend-mode: var(--wc-blend); filter: url(#nx-wc);
}
/* 用 style="color:…" 指定顏色的標籤：字維持墨色，水彩取那個顏色 */
.tag[style*="color"]::before { background: currentColor; }
.tag[style*="color"] { -webkit-text-fill-color: var(--ink); }
.sub-phy   { --tag-c: var(--s-phy); }
.sub-chem  { --tag-c: var(--s-chem); }
.sub-bio   { --tag-c: var(--s-bio); }
.sub-earth { --tag-c: var(--s-earth); }
.sub-cross { --tag-c: var(--s-cross); }
.chip.sub-phy, .chip.sub-chem, .chip.sub-bio, .chip.sub-earth, .chip.sub-cross { color: var(--ink-soft); }
.chip.sub-phy .dot { background: var(--s-phy); } .chip.sub-chem .dot { background: var(--s-chem); }
.chip.sub-bio .dot { background: var(--s-bio); } .chip.sub-earth .dot { background: var(--s-earth); }
.chip.sub-cross .dot { background: var(--s-cross); }

/* ── 單元頁 ─────────────────────────────────────────── */
.unit-head { padding: 3.75rem 0 2rem; }
.unit-head .formula {
  position: relative; isolation: isolate;
  font-size: 1.1rem;
  margin: 1.2rem 0 0;
  padding: .7rem 1.3rem;
  display: inline-block;
  border-top: 1px solid color-mix(in srgb, var(--ink) 60%, transparent);
  border-bottom: 1px solid color-mix(in srgb, var(--ink) 60%, transparent);
}
.unit-head .formula::before {
  content: ""; position: absolute; inset: 8% 25% 5% -4%; z-index: -1;
  background: var(--sky); opacity: calc(var(--wash-op) - .12);
  border-radius: 58% 42% 63% 37% / 45% 55% 45% 55%;
  mix-blend-mode: var(--wc-blend); filter: url(#nx-wc);
}
.unit-head .formula .katex-display { margin: 0; text-align: left; }
.unit-head .formula .katex-display > .katex { text-align: left; }

.sec {
  padding: 3.5rem 0;
  scroll-margin-top: 4rem;
}
/* 段與段之間：一條鬆散的長墨線，像畫面底下那條桌線 */
.sec + .sec > .wrap::before {
  content: "";
  display: block;
  height: 10px;
  margin: 0 0 2.4rem;
  background: var(--ink);
  opacity: .45;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 10' preserveAspectRatio='none'%3E%3Cpath d='M0 6c120-2 260-3 420-2s330 3 470-1c40-1 80 0 110 1' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3Cpath d='M640 4c90 1 170 3 250 1' fill='none' stroke='%23000' stroke-width='.8'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 10' preserveAspectRatio='none'%3E%3Cpath d='M0 6c120-2 260-3 420-2s330 3 470-1c40-1 80 0 110 1' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3Cpath d='M640 4c90 1 170 3 250 1' fill='none' stroke='%23000' stroke-width='.8'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.sec > .wrap { display: grid; gap: 1.5rem; }

.sec-label {
  font-size: .8rem; font-weight: 500; letter-spacing: .22em;
  color: var(--ink-soft); margin: 0 0 .2rem;
  display: flex; align-items: center; gap: .55rem;
}

.two-col { display: grid; gap: 1.5rem; }
@media (min-width: 900px) {
  .two-col { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
}

/* 舞台：像一張夾在速寫本裡的紙 */
.stage {
  background: var(--surface);
  border: 1.2px solid color-mix(in srgb, var(--ink) 75%, transparent);
  border-radius: var(--r-lg);
  padding: .7rem;
}
.stage > svg, .stage > canvas, .stage > div { position: relative; }
.stage svg, .stage canvas { display: block; width: 100%; height: auto; }

/* 面板 */
.panel { display: grid; gap: 1rem; align-content: start; }
.panel .row { display: grid; gap: .15rem; }
.panel label {
  font-size: .9rem; font-weight: 400; color: var(--ink-soft);
  display: flex; justify-content: space-between; gap: 1rem; align-items: baseline;
}
.panel label b { font-family: var(--font-read); font-size: 1.05rem; color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 700; }

/* 滑桿：一條墨線，走過的地方暈開一抹水彩；把手是一顆手繪小圓 */
input[type="range"] {
  appearance: none; -webkit-appearance: none;
  width: 100%; height: 44px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 8px; border-radius: 999px;
  background:
    linear-gradient(var(--ink), var(--ink)) 0 50% / 100% 1.2px no-repeat,
    linear-gradient(90deg, color-mix(in srgb, var(--pink) 45%, transparent) var(--fill, 50%), transparent var(--fill, 50%));
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 20px; height: 20px; margin-top: -6px;
  border-radius: 52% 48% 55% 45% / 48% 55% 45% 52%;
  background: var(--surface); border: 1.4px solid var(--ink);
}
input[type="range"]::-moz-range-track { height: 1.2px; background: var(--ink); }
input[type="range"]::-moz-range-progress { height: 8px; border-radius: 999px; background: color-mix(in srgb, var(--pink) 45%, transparent); }
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 52% 48% 55% 45% / 48% 55% 45% 52%;
  background: var(--surface); border: 1.4px solid var(--ink);
}
input[type="range"]:focus-visible { outline: 1.5px dashed var(--accent); outline-offset: 4px; }

input[type="search"] {
  font: inherit;
  border: 1.2px solid var(--ink); border-radius: var(--r-pill);
  padding: .5rem 1.1rem; min-height: 44px;
  background: var(--surface); color: var(--ink);
}
input[type="search"]:focus-visible { outline: 1.5px dashed var(--accent); outline-offset: 3px; }

/* 讀數：沒有框，只有一條墨線靠左，底下一抹極淡的水痕 */
.readout {
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--butter) 8%, transparent);
  border-left: 1.5px solid var(--ink);
  border-radius: 2px 12px 14px 2px / 2px 14px 12px 2px;
  padding: .7rem 1rem;
  font-size: .96rem;
}

.transport { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

/* 資料表：只有細線 */
.datatable { width: 100%; border-collapse: collapse; font-size: .88rem; font-variant-numeric: tabular-nums; }
.datatable th, .datatable td { text-align: right; padding: .35rem .55rem; border-bottom: 1px solid var(--line); }
.datatable th { color: var(--ink-soft); font-weight: 500; border-bottom-color: var(--ink); }
.datatable caption { caption-side: top; text-align: left; color: var(--ink-soft); font-size: .85rem; padding-bottom: .35rem; font-family: var(--font-read); }

/* 預測題 */
.guess { display: grid; gap: .7rem; max-width: var(--measure); }
.opt {
  text-align: left; font: inherit; cursor: pointer; color: inherit;
  border: 1px solid color-mix(in srgb, var(--ink) 55%, transparent);
  background: transparent;
  border-radius: var(--r-sm); padding: .8rem 1.05rem; min-height: 44px;
  isolation: isolate;
  transition: border-color .16s;
}
.opt:hover { border-color: var(--ink); }
.opt::before {
  content: ""; position: absolute; inset: -3px -6px -3px 30%; z-index: -1;
  border-radius: 58% 42% 63% 37% / 45% 55% 45% 55%;
  opacity: 0; transition: opacity .3s;
  mix-blend-mode: var(--wc-blend); filter: url(#nx-wc);
}
.opt[data-state="right"] { border-color: var(--ink); }
.opt[data-state="right"]::before { background: var(--mint); opacity: var(--wash-op); }
.opt[data-state="wrong"]::before { background: var(--pink); opacity: calc(var(--wash-op) - .12); }
.opt .why { display: none; margin: .5rem 0 0; font-size: .93rem; color: var(--ink-soft); }
.opt[data-state] .why { display: block; }
.opt .mark {
  font-family: var(--font-read);
  margin-right: .55rem;
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.6rem; height: 1.6rem;
  border: 1px solid var(--ink);
  border-radius: 52% 48% 55% 45% / 48% 55% 45% 52%;
  color: var(--ink);
}

/* 邊界／迷思段 */
.caution {
  border: none;
  border-left: 1.5px solid var(--ink);
  padding: .5rem 1.1rem .6rem;
  max-width: var(--measure);
  isolation: isolate;
}
.caution::before {
  content: ""; position: absolute; left: -.6rem; top: .2rem; width: 3.2rem; height: 2rem; z-index: -1;
  background: var(--warn); opacity: calc(var(--wash-op) - .08);
  border-radius: 58% 42% 63% 37% / 45% 55% 45% 55%;
  mix-blend-mode: var(--wc-blend); filter: url(#nx-wc);
}
.caution h3 { color: var(--ink); font-size: 1.02rem; margin-bottom: .25rem; font-family: var(--font-read); font-weight: 400; }

/* 模型界線聲明 */
.model-note {
  font-size: .88rem; color: var(--ink-soft);
  border-top: 1px dashed color-mix(in srgb, var(--ink) 45%, transparent); padding-top: .8rem; margin-top: .3rem;
}
.model-note b { color: var(--ink); }
.model-note ul { margin: .35rem 0 0; padding-left: 1.2em; }

/* 考點 */
.codes { display: flex; flex-wrap: wrap; gap: .4rem; }
.code {
  font-family: ui-monospace, "SFMono-Regular", Menlo, monospace;
  font-size: .76rem; padding: .1rem .55rem;
  white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--ink) 40%, transparent);
  border-radius: var(--r-pill);
  color: var(--ink-soft);
}

/* ── 進度 ───────────────────────────────────────────── */
.progress-bar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.got-it[data-state="got"]   { background: color-mix(in srgb, var(--mint) 30%, transparent); }
.got-it[data-state="stuck"] { background: color-mix(in srgb, var(--butter) 30%, transparent); }

/* ── 頂列 ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 30;
  padding: .55rem 0;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
}
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: var(--ink); opacity: .35;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 6' preserveAspectRatio='none'%3E%3Cpath d='M0 3c200-1 400 1 600 0s300-1 400 1' fill='none' stroke='%23000' stroke-width='1'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 6' preserveAspectRatio='none'%3E%3Cpath d='M0 3c200-1 400 1 600 0s300-1 400 1' fill='none' stroke='%23000' stroke-width='1'/%3E%3C/svg%3E") center / 100% 100% no-repeat;
}
.topbar .wrap { display: flex; align-items: center; gap: .6rem; }
.topbar .spacer { flex: 1; }
.brand {
  font-family: var(--font-read);
  font-size: 1.15rem;
  letter-spacing: .08em; text-decoration: none;
  color: inherit; white-space: nowrap;
  display: inline-flex; align-items: center; gap: .45rem;
}

/* ── 上課模式：一次只顯示一段 ───────────────────────── */
:root[data-mode="class"] .sec { min-height: 100svh; display: flex; align-items: center; }
:root[data-mode="class"] .sec[hidden] { display: none; }
:root[data-mode="class"] .sec + .sec > .wrap::before { display: none; }
:root[data-mode="class"] .unit-head { min-height: 60svh; display: flex; align-items: center; }

/* ── 手機 ───────────────────────────────────────────── */
@media (max-width: 719px) {
  body { font-size: .97rem; }

  /* 頂列：單元名稱收起來，只留站名與按鈕 */
  .topbar .wrap > .faint { display: none; }
  .topbar .btn { padding: .4rem .8rem; letter-spacing: .02em; }

  /* 首頁：那瓶花移到文字下面，不壓在字後 */
  .stage-hero { display: flex; flex-direction: column; }
  .stage-hero > .wrap { order: 1; }
  .stage-hero .deco.bouquet { position: relative; inset: auto; order: 2; height: 250px; margin-top: -2rem; z-index: 0; opacity: 1; }
  .sec { padding: 2.5rem 0; }
  .unit-head { padding: 2.4rem 0 1.5rem; }

  /* 舞台吸附在上方，參數變成可橫捲的膠囊列 */
  .two-col.sticky-stage > .stage {
    position: sticky; top: 3.2rem; z-index: 5;
    box-shadow: var(--shadow-lg);
  }
  .panel.capsules {
    display: flex; gap: .6rem; overflow-x: auto; padding-bottom: .4rem;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
  }
  .panel.capsules > .row {
    min-width: 13rem; flex: 0 0 auto; scroll-snap-align: start;
    background: var(--surface); border: 1px solid color-mix(in srgb, var(--ink) 50%, transparent);
    border-radius: var(--r-sm); padding: .5rem .8rem;
  }
  .panel.capsules > .readout,
  .panel.capsules > .transport { min-width: 13rem; flex: 0 0 auto; }
  .deco { opacity: .5; }
}

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

@media print {
  body::before, body::after, .topbar, .transport, .btn, .stage-hero .deco { display: none !important; }
  body { background: #fff; }
  .sec { break-inside: avoid; }
}

/* 有裝飾帶的段落不再畫分隔線，避免兩條疊在一起 */
.sec + .sec > .wrap:has(> .deco-band:first-child)::before { display: none; }
