/* =========================================================
   LLM 101 互動教學｜UNIT 01
   1. Design tokens
   2. Base
   3. Header / hero
   4. Layout / TOC
   5. Article / figures
   6. Components
   7. Interactive labs
   8. Quiz / glossary / references
   9. Responsive & motion
   ========================================================= */

/* ---------- 1. Design tokens ---------- */
:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef4fb;
  --text: #0b1f33;
  --muted: #4b6478;
  --border: #d8e2ee;
  --primary: #1d4ed8;
  --primary-weak: #dbeafe;
  --accent: #0f766e;
  --warn: #b45309;
  --danger: #b91c1c;
  --shadow: 0 10px 30px rgba(11, 31, 51, .08);

  --on-primary: #ffffff;
  --header-bg: rgba(246, 248, 252, .88);
  --code-bg: #eef4fb;
  --ok: #15803d;
  --ok-weak: #dcfce7;
  --danger-weak: #fee2e2;
  --warn-weak: #fef3c7;
  --focus: #1d4ed8;

  --font-sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", "Heiti TC", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --maxw: 1180px;
  --radius: 16px;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #08111f;
  --surface: #0f1b2d;
  --surface-2: #15243a;
  --text: #e8eff8;
  --muted: #9db0c6;
  --border: #253850;
  --primary: #7cb3ff;
  --primary-weak: #132a4a;
  --accent: #4fd1c5;
  --warn: #fbbf24;
  --danger: #fca5a5;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);

  --on-primary: #08111f;
  --header-bg: rgba(8, 17, 31, .88);
  --code-bg: #0b1728;
  --ok: #6ee7b7;
  --ok-weak: #0c2f26;
  --danger-weak: #3a1518;
  --warn-weak: #3a2a0a;
  --focus: #93c5fd;
  color-scheme: dark;
}

/* ---------- 2. Base ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  line-height: 1.85;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  line-height: 1.3;
  letter-spacing: -.015em;
  text-wrap: balance;
}

p { margin: 0 0 1.1em; }

a {
  color: var(--primary);
  text-decoration-thickness: 1px;
  text-underline-offset: .18em;
}

a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 800; }

code, .mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--primary);
  color: var(--on-primary);
}

[hidden] { display: none !important; }

.skip-link {
  position: absolute;
  left: 16px;
  top: -80px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: 0 0 10px 10px;
  font-weight: 700;
  text-decoration: none;
  transition: top .15s ease;
}

.skip-link:focus { top: 0; }

/* ---------- 3. Header / hero ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.header-inner {
  max-width: var(--maxw);
  height: 64px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 800;
  letter-spacing: -.01em;
}

.brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  background: var(--primary-weak);
}

.brand-mark svg { width: 24px; height: 24px; }

.brand-bar-1 { fill: var(--primary); opacity: .38; }
.brand-bar-2 { fill: var(--primary); opacity: .66; }
.brand-bar-3 { fill: var(--primary); }

.brand-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  line-height: 1.15;
}

.brand-text strong { font-size: 1.02rem; letter-spacing: .01em; }

.header-sub {
  font-size: .76rem;
  font-weight: 600;
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-toc {
  display: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  padding: 7px 12px;
  border-radius: 9px;
  cursor: pointer;
}

.header-toc:hover { border-color: var(--primary); color: var(--primary); }

.icon-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.icon-btn:hover { border-color: var(--primary); color: var(--primary); }

.icon {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-sun { display: none; }
.icon-moon { display: block; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

.reading-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 3px;
  background: var(--surface-2);
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .12s linear;
}

.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
}

.hero-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(520px 320px at 12% 8%, rgba(29, 78, 216, .13), transparent 70%),
    radial-gradient(430px 300px at 90% 22%, rgba(15, 118, 110, .11), transparent 70%),
    linear-gradient(180deg, transparent, var(--bg));
}

.hero-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(29, 78, 216, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(29, 78, 216, .045) 1px, transparent 1px);
  background-size: 44px 44px;
  -webkit-mask-image: linear-gradient(180deg, rgba(0, 0, 0, .7), transparent 78%);
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, .7), transparent 78%);
}

[data-theme="dark"] .hero-bg {
  background:
    radial-gradient(520px 320px at 12% 8%, rgba(124, 179, 255, .14), transparent 70%),
    radial-gradient(430px 300px at 90% 22%, rgba(79, 209, 197, .10), transparent 70%),
    linear-gradient(180deg, transparent, var(--bg));
}

[data-theme="dark"] .hero-bg::after {
  background-image:
    linear-gradient(rgba(124, 179, 255, .06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 179, 255, .06) 1px, transparent 1px);
}

.hero-inner {
  position: relative;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 72px 24px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(320px, .92fr);
  gap: 56px;
  align-items: center;
}

.eyebrow {
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .14em;
  color: var(--primary);
  margin: 0 0 14px;
}

.hero h1 {
  font-size: clamp(2.2rem, 4.7vw, 3.45rem);
  line-height: 1.1;
  letter-spacing: -.035em;
  margin: 0 0 20px;
}

.hero h1 span {
  display: block;
  margin-top: .32em;
  font-size: .56em;
  line-height: 1.25;
  letter-spacing: -.015em;
  color: var(--primary);
  font-weight: 800;
}

.lead {
  font-size: 1.11rem;
  line-height: 1.8;
  color: var(--muted);
  max-width: 54ch;
}

.hero-meta {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0;
  margin: 24px 0 28px;
}

.hero-meta li {
  font-size: .8rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 11px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: .68rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 11px;
  font: inherit;
  font-size: .95rem;
  font-weight: 700;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease, color .15s ease, background .15s ease;
}

.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 6px 18px rgba(29, 78, 216, .22);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(29, 78, 216, .28);
  text-decoration: none;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  text-decoration: none;
}

.btn-sm {
  padding: .45rem .8rem;
  font-size: .86rem;
  border-radius: 9px;
}

.hero-map {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 20px 20px 16px;
  box-shadow: var(--shadow);
}

.hero-map-title {
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .13em;
  color: var(--muted);
  margin: 0 0 10px;
}

.hero-map ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.hero-map li a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 9px;
  border-radius: 9px;
  color: var(--text);
  text-decoration: none;
  font-size: .92rem;
  line-height: 1.45;
  transition: background .15s ease, color .15s ease;
}

.hero-map li a:hover {
  background: var(--surface-2);
  color: var(--primary);
}

.hero-map li span {
  flex: none;
  width: 2.3em;
  font-family: var(--font-mono);
  font-size: .76rem;
  font-weight: 800;
  color: var(--primary);
}

.hero-map-foot {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-size: .8rem;
  line-height: 1.7;
  color: var(--muted);
}

/* ---------- 4. Layout / TOC ---------- */
.layout {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 48px 24px 72px;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 52px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 88px;
  min-width: 0;
}

.toc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 8px;
  box-shadow: var(--shadow);
}

.toc-card > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 800;
  list-style: none;
  border-radius: 8px;
}

.toc-card > summary::-webkit-details-marker { display: none; }

.toc-card > summary::after {
  content: "▾";
  margin-left: 2px;
  color: var(--muted);
  font-size: .8rem;
  transition: transform .2s ease;
}

.toc-card[open] > summary::after { transform: rotate(180deg); }

.toc-count {
  margin-left: auto;
  font-size: .72rem;
  font-weight: 700;
  color: var(--muted);
}

.toc-nav { padding: 4px 2px 8px; }

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1px;
}

.toc-link {
  display: grid;
  grid-template-columns: 2.5em minmax(0, 1fr);
  gap: 6px;
  align-items: baseline;
  padding: 7px 9px;
  border-left: 3px solid transparent;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
  font-size: .86rem;
  line-height: 1.45;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}

.toc-link:hover {
  background: var(--surface-2);
  color: var(--text);
}

.toc-link[aria-current="true"] {
  background: var(--primary-weak);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 800;
}

.toc-num {
  font-family: var(--font-mono);
  font-size: .74rem;
  font-weight: 800;
  opacity: .85;
}

.toc-group {
  border-top: 1px solid var(--border);
}

.toc-group:first-of-type { border-top: 0; }

.toc-group-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 10px;
  grid-template-areas:
    "num count chevron"
    "title title chevron";
  align-items: center;
  column-gap: 8px;
  row-gap: 1px;
  padding: 10px 9px;
  list-style: none;
  cursor: pointer;
  border-radius: 8px;
  color: var(--text);
  font-size: .82rem;
  line-height: 1.45;
  transition: background .15s ease, color .15s ease;
}

.toc-group-summary::-webkit-details-marker { display: none; }

.toc-group-summary:hover { background: var(--surface-2); }

.toc-group-summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: -2px;
}

.toc-group-num {
  grid-area: num;
  font-family: var(--font-mono);
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--muted);
}

.toc-group-title {
  grid-area: title;
  min-width: 0;
  font-size: .88rem;
  font-weight: 700;
  line-height: 1.45;
}

.toc-group-count {
  grid-area: count;
  justify-self: end;
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.toc-group-summary::after {
  content: "";
  grid-area: chevron;
  justify-self: end;
  align-self: center;
  width: 6px;
  height: 6px;
  margin-bottom: 2px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  opacity: .65;
  transition: transform .2s ease, opacity .2s ease;
}

.toc-group[open] > .toc-group-summary { color: var(--primary); }
.toc-group[open] > .toc-group-summary .toc-group-title { color: var(--primary); }
.toc-group[open] > .toc-group-summary::after {
  transform: rotate(225deg);
  opacity: 1;
}

.toc-group .toc-list { padding: 0 0 8px; }

.toc-list-sub .toc-link { font-size: .84rem; }

.article {
  min-width: 0;
  max-width: 760px;
}

.lesson-section {
  margin-bottom: 72px;
  scroll-margin-top: 96px;
}

.section-head { margin-bottom: 16px; }

.section-kicker {
  margin: 0 0 4px;
  font-family: var(--font-mono);
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--primary);
}

.section-head h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.7vw, 1.95rem);
  letter-spacing: -.02em;
}

.section-lead {
  font-size: 1.1rem;
  line-height: 1.85;
}

.cite {
  font-size: .7em;
  font-weight: 800;
  vertical-align: super;
  line-height: 0;
  text-decoration: none;
  padding: 0 .08em;
  color: var(--primary);
}

.cite:hover { text-decoration: underline; }

/* ---------- 5. Article / figures ---------- */
.figure {
  margin: 30px 0;
  scroll-margin-top: 88px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.figure-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  padding: 12px 18px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.figure-tag {
  flex: none;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .07em;
  color: var(--primary);
  background: var(--primary-weak);
  padding: 3px 9px;
  border-radius: 999px;
}

.figure-title {
  font-size: .9rem;
  font-weight: 700;
  line-height: 1.5;
  margin-right: auto;
}

.scroll-hint {
  display: none;
  flex: none;
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  white-space: nowrap;
}

.u3-table-hint,
.u4-table-hint {
  margin: 0 0 8px;
}

.figure-body { padding: 20px; }

.figure-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  border-radius: 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.figure-scroll::-webkit-scrollbar { height: 8px; }
.figure-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }

.figure-inner { min-width: 680px; }

.player-inner { min-width: 700px; }

.diagram {
  display: block;
  width: 100%;
  height: auto;
}

.figure figcaption {
  padding: 0 20px 18px;
  font-size: .85rem;
  line-height: 1.75;
  color: var(--muted);
}

.hint {
  margin: 12px 0 0;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--muted);
}

.callout {
  margin: 24px 0;
  padding: 15px 18px;
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  background: var(--surface);
}

.callout strong {
  display: block;
  margin-bottom: 3px;
  font-size: .8rem;
  letter-spacing: .08em;
  color: var(--primary);
}

.callout p {
  margin: 0;
  font-size: .93rem;
  line-height: 1.8;
}

.callout-note { background: var(--surface-2); }

.callout-warn {
  border-color: var(--border);
  border-left-color: var(--warn);
  background: var(--warn-weak);
}

.callout-warn strong { color: var(--warn); }

/* ---------- 6. Components ---------- */
/* 1-2 flow compare */
.flow-compare {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.flow-card {
  padding: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.flow-card-accent {
  background: var(--primary-weak);
  border-color: var(--primary);
}

.flow-label {
  margin: 0 0 3px;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--primary);
}

.flow-card h3 { margin: 0 0 10px; font-size: 1.02rem; }

.flow-steps {
  margin: 0;
  padding-left: 1.15em;
  font-size: .9rem;
  line-height: 1.65;
}

.flow-steps li { margin: 5px 0; padding-left: 2px; }

.flow-foot {
  margin: 12px 0 0;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  font-size: .8rem;
  line-height: 1.65;
  color: var(--muted);
}

.flow-arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 62px;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 700;
  text-align: center;
}

.flow-arrow svg {
  width: 48px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* segmented control */
.segmented {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 14px;
}

.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .86rem;
  font-weight: 700;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}

.seg-btn:hover { color: var(--text); }

.seg-btn.is-active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(11, 31, 51, .12);
}

/* 1-3 token demo */
.token-demo { min-width: 0; }

.token-sentence {
  margin: 2px 0 10px;
  font-size: .86rem;
  color: var(--muted);
  font-family: var(--font-mono);
}

.token-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 48px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px dashed var(--border);
  border-radius: 12px;
}

.token-chip {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 8px;
  padding: 4px 9px;
  font-family: var(--font-mono);
  font-size: .88rem;
  line-height: 1.5;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .15s ease;
}

.token-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.token-chip.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--on-primary);
}

.token-detail {
  margin-top: 12px;
  min-height: 62px;
  padding: 12px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.token-detail-empty {
  margin: 0;
  font-size: .88rem;
  color: var(--muted);
  line-height: 1.7;
}

.token-detail-title {
  margin: 0 0 8px;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--primary);
}

.token-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.token-meta div { min-width: 0; }

.token-meta dt {
  font-size: .7rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .05em;
}

.token-meta dd {
  margin: 1px 0 0;
  font-family: var(--font-mono);
  font-size: .92rem;
  overflow-wrap: anywhere;
}

/* 1-5 attention */
.attention-demo { min-width: 0; }

.demo-caption {
  margin: 14px 0 0;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--primary-weak);
  font-size: .88rem;
  line-height: 1.75;
  color: var(--muted);
}

/* 1-6 player */
.player-track {
  display: flex;
  align-items: stretch;
  gap: 7px;
  padding: 4px 2px 10px;
}

.step-card {
  flex: 1 0 118px;
  min-width: 118px;
  display: grid;
  gap: 5px;
  padding: 10px 11px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.step-card:hover { border-color: var(--primary); }

.step-card.is-active {
  background: var(--primary-weak);
  border-color: var(--primary);
  box-shadow: inset 0 0 0 1px var(--primary);
}

.step-num {
  font-family: var(--font-mono);
  font-size: .7rem;
  font-weight: 800;
  color: var(--muted);
  letter-spacing: .04em;
}

.step-card.is-active .step-num { color: var(--primary); }

.step-name {
  font-size: .86rem;
  font-weight: 700;
  line-height: 1.4;
}

.step-arrow {
  align-self: center;
  color: var(--muted);
  font-size: .9rem;
  user-select: none;
}

.player-status {
  margin-top: 8px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
}

.player-step-label {
  margin: 0 0 2px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--primary);
}

.player-status h3 { margin: 0 0 4px; font-size: 1.04rem; }

.player-status p:last-child {
  margin: 0;
  font-size: .9rem;
  line-height: 1.7;
  color: var(--muted);
}

.player-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.player-controls .btn[disabled] {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Temperature */
.temp-lab {
  display: grid;
  grid-template-columns: minmax(0, 230px) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
}

.temp-controls {
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.temp-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: .86rem;
  font-weight: 800;
}

.temp-label output {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--primary);
}

.temp-range {
  width: 100%;
  margin: 10px 0 2px;
  accent-color: var(--primary);
  cursor: pointer;
}

.range-scale {
  display: flex;
  justify-content: space-between;
  font-size: .7rem;
  color: var(--muted);
}

.temp-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.prob-list {
  display: grid;
  gap: 12px;
  padding-top: 5px;
}

.prob-row {
  display: grid;
  grid-template-columns: 3.2em minmax(0, 1fr) 3.6em;
  align-items: center;
  gap: 10px;
}

.prob-label {
  font-size: .9rem;
  font-weight: 800;
  text-align: right;
}

.prob-track {
  height: 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.prob-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .18s ease;
}

.prob-pct {
  font-family: var(--font-mono);
  font-size: .8rem;
  color: var(--muted);
  text-align: right;
}

.temp-result {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.temp-result > span:first-child {
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--muted);
}

.temp-result strong {
  font-size: 1.02rem;
  color: var(--primary);
}

.temp-result-note {
  font-size: .78rem;
  color: var(--muted);
}

/* small cards */
.card-grid {
  display: grid;
  gap: 14px;
  margin: 24px 0;
}

.card-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.mini-card {
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.mini-card h3 { margin: 0 0 6px; font-size: 1rem; }

.mini-card p {
  margin: 0;
  font-size: .88rem;
  line-height: 1.75;
  color: var(--muted);
}

/* next chapters */
.next-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.next-card {
  position: relative;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}

.next-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  opacity: .7;
}

.next-badge {
  display: inline-block;
  font-size: .66rem;
  font-weight: 800;
  letter-spacing: .08em;
  color: var(--primary);
  background: var(--primary-weak);
  padding: 3px 8px;
  border-radius: 999px;
}

.next-num {
  margin: 10px 0 2px;
  font-family: var(--font-mono);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .05em;
  color: var(--muted);
}

.next-card h3 { margin: 0 0 6px; font-size: 1.02rem; }

.next-card > p:last-child {
  margin: 0;
  font-size: .86rem;
  line-height: 1.75;
  color: var(--muted);
}

/* ---------- 7. Quiz ---------- */
.quiz-app {
  display: grid;
  gap: 16px;
  margin-top: 22px;
}

.quiz-score {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 11px 15px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: .88rem;
  font-weight: 700;
}

.quiz-score span:last-child { color: var(--muted); font-weight: 600; }

.quiz-q {
  margin: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

.quiz-q legend {
  padding: 0 4px;
  font-size: .98rem;
  font-weight: 700;
  line-height: 1.7;
}

.q-num {
  display: inline-block;
  margin-right: 7px;
  font-family: var(--font-mono);
  font-size: .74rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: .04em;
}

.options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: .9rem;
  line-height: 1.65;
  text-align: left;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}

.option:hover { border-color: var(--primary); background: var(--surface-2); }

.option-key {
  flex: none;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  margin-top: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted);
}

.option.is-correct {
  border-color: var(--ok);
  background: var(--ok-weak);
}

.option.is-correct .option-key {
  background: var(--ok);
  border-color: var(--ok);
  color: var(--surface);
}

.option.is-wrong {
  border-color: var(--danger);
  background: var(--danger-weak);
}

.option.is-wrong .option-key {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--surface);
}

.option[aria-disabled="true"] { cursor: default; }
.option[aria-disabled="true"]:hover { border-color: var(--border); background: var(--surface); }
.option.is-correct[aria-disabled="true"]:hover { border-color: var(--ok); background: var(--ok-weak); }
.option.is-wrong[aria-disabled="true"]:hover { border-color: var(--danger); background: var(--danger-weak); }

.feedback {
  margin: 12px 0 0;
  padding: 11px 13px;
  background: var(--surface-2);
  border-left: 3px solid var(--border);
  border-radius: 8px;
  font-size: .87rem;
  line-height: 1.75;
}

.feedback strong { display: block; margin-bottom: 2px; }

.feedback.is-correct { border-left-color: var(--ok); }
.feedback.is-wrong { border-left-color: var(--danger); }

.quiz-summary {
  padding: 14px 16px;
  background: var(--primary-weak);
  border: 1px solid var(--primary);
  border-radius: 12px;
  font-size: .9rem;
  line-height: 1.7;
}

.quiz-summary strong { color: var(--primary); }

/* ---------- 8. Glossary / references / footer ---------- */
.glossary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 26px;
  margin: 22px 0 0;
}

.glossary > div {
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.glossary dt { font-weight: 700; font-size: .93rem; }

.glossary dd {
  margin: 2px 0 0;
  font-size: .86rem;
  line-height: 1.7;
  color: var(--muted);
}

.ref-list {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.ref-list li {
  display: grid;
  grid-template-columns: 3em minmax(0, 1fr);
  gap: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  scroll-margin-top: 100px;
}

.ref-num {
  font-family: var(--font-mono);
  font-size: .82rem;
  font-weight: 800;
  color: var(--primary);
}

.ref-list a { font-weight: 700; font-size: .92rem; }

.ref-list p {
  margin: 3px 0 0;
  font-size: .8rem;
  line-height: 1.65;
  color: var(--muted);
}

.ref-note {
  margin-top: 14px;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--muted);
}

.site-footer {
  margin-top: 20px;
  padding: 28px 0 56px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px;
  font-size: .8rem;
  line-height: 1.7;
  color: var(--muted);
}

.site-footer p { margin: 0; }

.footer-brand {
  font-weight: 800;
  color: var(--text);
  margin-bottom: 2px !important;
}

.footer-note { max-width: 44ch; }

/* ---------- 9. SVG ---------- */
.diagram text {
  font-family: var(--font-sans);
  fill: var(--text);
}

.svg-label-lg { font-size: 22px; font-weight: 800; }
.svg-label-md { font-size: 17px; font-weight: 700; }
.svg-label-sm { font-size: 14px; font-weight: 600; }
.diagram .svg-label-xs { font-size: 11.5px; font-weight: 500; fill: var(--muted); }
.svg-strong { font-weight: 800; }

.svg-card { fill: var(--surface-2); stroke: var(--border); stroke-width: 1.5; }
.svg-chip { fill: var(--surface); stroke: var(--border); stroke-width: 1.2; }
.svg-target { fill: var(--primary-weak); stroke: var(--primary); stroke-width: 2; }

.svg-arrow {
  stroke: var(--muted);
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .8;
}

.svg-grid rect {
  fill: var(--primary-weak);
  stroke: var(--primary);
  stroke-opacity: .28;
  stroke-width: 1;
}

.svg-layer {
  fill: var(--surface);
  stroke: var(--primary);
  stroke-opacity: .35;
  stroke-width: 1.2;
}

.svg-bar-track { fill: var(--surface-2); stroke: var(--border); stroke-width: 1; }
.svg-bar-fill { fill: var(--primary); }
.svg-bar-fill-2 { fill: var(--accent); opacity: .85; }
.svg-bar-fill-3 { fill: var(--accent); opacity: .6; }
.svg-bar-fill-4 { fill: var(--muted); opacity: .5; }

.svg-word { font-size: 19px; font-weight: 600; }
.diagram .svg-word-strong { font-weight: 800; fill: var(--primary); }

.svg-arc {
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
  stroke-linecap: round;
  opacity: .5;
}

.svg-arc-strong { stroke: var(--accent); stroke-width: 3.5; opacity: .9; }
.svg-dot { fill: var(--accent); }

.ring-fill-1 {
  fill: var(--primary);
  fill-opacity: .035;
  stroke: var(--primary);
  stroke-opacity: .24;
  stroke-width: 1.5;
}

.ring-fill-2 {
  fill: var(--primary);
  fill-opacity: .05;
  stroke: var(--primary);
  stroke-opacity: .34;
  stroke-width: 1.5;
}

.ring-fill-3 {
  fill: var(--accent);
  fill-opacity: .06;
  stroke: var(--accent);
  stroke-opacity: .4;
  stroke-width: 1.5;
}

.ring-fill-4 {
  fill: var(--primary-weak);
  stroke: var(--primary);
  stroke-opacity: .75;
  stroke-width: 2;
}

/* reveal animations */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .55s ease, transform .55s ease;
}

.js .reveal.is-visible {
  opacity: 1;
  transform: none;
}

.js .reveal .ring {
  opacity: 0;
  transform: scale(.97);
  transform-origin: 360px 235px;
  transition: opacity .55s ease, transform .55s ease;
}

.js .reveal.is-visible .ring { opacity: 1; transform: none; }

.ring-ai { transition-delay: .05s !important; }
.ring-ml { transition-delay: .18s !important; }
.ring-gen { transition-delay: .31s !important; }
.ring-llm { transition-delay: .44s !important; }
.ring-note { transition-delay: .57s !important; }

/* ---------- 10. Responsive ---------- */
@media (max-width: 1080px) {
  .hero-inner { gap: 36px; }
  .layout { grid-template-columns: 220px minmax(0, 1fr); gap: 36px; }
}

@media (max-width: 859px) {
  body { font-size: 1.02rem; }

  .header-inner { height: 58px; padding: 0 16px; }
  .header-toc { display: inline-flex; }
  .header-sub { font-size: .75rem; }
  .brand-mark { width: 29px; height: 29px; }

  .hero-inner {
    grid-template-columns: 1fr;
    padding: 46px 18px 40px;
    gap: 30px;
  }

  .hero h1 { font-size: clamp(1.95rem, 8vw, 2.6rem); }
  .hero h1 span { font-size: .6em; }
  .lead { font-size: 1rem; }
  .hero-map { padding: 16px; }

  .layout {
    grid-template-columns: 1fr;
    padding: 26px 16px 48px;
    gap: 26px;
  }

  .sidebar {
    position: static;
    order: 0;
  }

  /* 手機目錄：固定覆蓋層，不再把頁面捲到最上方 */
  .toc-card { display: none; }
  .toc-card[open] {
    display: block;
    position: fixed;
    top: 70px;
    left: 12px;
    right: 12px;
    z-index: 130;
    max-height: calc(100vh - 86px);
    max-height: calc(100dvh - 86px);
    overflow-y: auto;
    overscroll-behavior: contain;
    box-shadow: 0 24px 70px rgba(8, 17, 31, .3);
  }
  .toc-card[open] > summary {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface);
    padding: 10px 12px;
  }
  body.toc-open { overflow: hidden; }
  body.toc-open::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 90;
    background: rgba(8, 17, 31, .45);
  }
  .toc-card > summary { padding: 10px 12px; }

  .toc-group-summary { padding: 11px 10px; }
  .toc-group-title { font-size: .86rem; }

  .article { max-width: none; }
  .lesson-section { margin-bottom: 54px; scroll-margin-top: 78px; }

  .section-head h2 { font-size: clamp(1.35rem, 5.5vw, 1.7rem); }
  .section-lead { font-size: 1.02rem; }

  .figure-body { padding: 14px; }
  .figure-head { padding: 11px 14px; }
  .figure-title { font-size: .85rem; }
  .scroll-hint { display: inline; }
  .figure figcaption { padding: 0 14px 15px; font-size: .82rem; }

  .flow-compare { grid-template-columns: 1fr; }
  .flow-arrow {
    flex-direction: row;
    min-width: 0;
    padding: 2px 0;
  }
  .flow-arrow svg { transform: rotate(90deg); }

  .card-grid-3,
  .next-grid { grid-template-columns: 1fr; }

  .temp-lab { grid-template-columns: 1fr; gap: 18px; }
  .temp-controls { width: 100%; }

  .glossary { grid-template-columns: 1fr; }

  .site-footer { flex-direction: column; padding-bottom: 36px; }
  .footer-note { max-width: none; }

  .token-meta { grid-template-columns: 1fr 1fr; }

  .ref-list li { grid-template-columns: 2.6em minmax(0, 1fr); }
}

@media (max-width: 460px) {
  .hero-meta li { font-size: .74rem; }
  .hero-actions .btn { flex: 1 1 auto; }
  .prob-row { grid-template-columns: 2.6em minmax(0, 1fr) 3.2em; }
  .token-meta { grid-template-columns: 1fr; }
}

/* ---------- PART 01 integration ---------- */
.unit-block {
  scroll-margin-top: 96px;
  margin-bottom: 96px;
}

.unit-band-01 {
  position: relative;
  overflow: hidden;
  margin: 0 0 42px;
  padding: 30px 32px 28px;
  background:
    radial-gradient(1100px 260px at 100% -10%, var(--primary-weak), transparent 62%),
    var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.unit-band-01::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--primary), var(--accent));
}

.unit-kicker,
.unit-number {
  margin: 0;
  font-family: var(--font-mono);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .1em;
  color: var(--primary);
}

.unit-band-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 6px;
}

.unit-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.unit-meta li {
  padding: 3px 9px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  font-size: .74rem;
  font-weight: 700;
}

.unit-band-01 h2 {
  margin: 12px 0 0;
  font-size: clamp(1.85rem, 3.8vw, 2.7rem);
}

.unit-sub {
  margin: 4px 0 0;
  color: var(--primary);
  font-size: clamp(1.05rem, 2vw, 1.3rem);
  font-weight: 700;
}

.unit-band-01 .unit-lead {
  max-width: 68ch;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.85;
}

.section-head h3 {
  margin: 0;
  font-size: clamp(1.5rem, 2.7vw, 1.95rem);
  letter-spacing: -.02em;
  line-height: 1.3;
}

.section-head h4 {
  margin: 18px 0 6px;
  font-size: 1.05rem;
  line-height: 1.4;
}


@media (min-width: 860px) {
  .toc-card[open] .toc-nav {
    max-height: calc(100vh - 190px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
  }
  .toc-card[open] .toc-nav::-webkit-scrollbar { width: 7px; }
  .toc-card[open] .toc-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 999px;
  }
}

@media (max-width: 859px) {
  .unit-block { margin-bottom: 64px; }
  .unit-band-01 { padding: 22px 18px; border-radius: 18px; }
  .unit-band-01 .unit-lead { font-size: .98rem; }
}


/* UNIT 03 mobile: 重設按鈕不要被 flex stretch 拉高（scoped override） */
@media (max-width: 859px) {
  body #unit-03 .u3-memory-controls { align-items: flex-start; }
  body #unit-03 .u3-memory-controls [data-u3-reset] {
    align-self: flex-start;
    height: auto;
    flex: 0 0 auto;
  }
}

/* ---------- 11. Motion & print ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }

  .js .reveal,
  .js .reveal .ring {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .prob-fill { transition: none !important; }
}

@media print {
  .site-header,
  .sidebar,
  .hero-actions,
  .hero-map,
  .player-controls,
  .temp-actions,
  .skip-link { display: none !important; }

  body { background: #fff; color: #000; font-size: 11pt; }
  .layout { display: block; padding: 0; }
  .article { max-width: none; }
  .figure { break-inside: avoid; box-shadow: none; }
  .unit-band-01, .unit-band { background: #fff !important; box-shadow: none; }
  a { color: #000; text-decoration: none; }
}

/* ---------- PART 01 差異補回：UNIT 01 ---------- */
.u1-token-count {
  margin: 14px 0 0;
  font-size: .86rem;
  line-height: 1.75;
  color: var(--muted);
}

.u1-temp-compare {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 24px 0 0;
}

.u1-temp-col {
  position: relative;
  padding: 15px 15px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
}

.u1-temp-label {
  margin: 0 0 8px;
  font-size: .78rem;
  font-weight: 800;
  letter-spacing: .04em;
  color: var(--primary);
}

.u1-temp-sample {
  margin: 0 0 8px;
  font-weight: 700;
  line-height: 1.65;
}

.u1-temp-desc {
  margin: 0;
  color: var(--muted);
  font-size: .84rem;
  line-height: 1.7;
}

.u1-temp-flag {
  display: inline-block;
  margin-top: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--primary-weak);
  color: var(--primary);
  font-size: .68rem;
  font-weight: 800;
}

.u1-temp-note {
  margin: 12px 0 0;
  font-size: .84rem;
  line-height: 1.75;
  color: var(--muted);
}

@media (max-width: 760px) {
  .u1-temp-compare { grid-template-columns: 1fr; }
}

/* =========================================================
   Round 3 fixes（A1–A11）
   ========================================================= */

/* A1：手機 TOC 關閉鈕 */
.toc-close { display: none; }

@media (max-width: 859px) {
  .toc-card[open] > summary { padding-right: 72px; }
  .toc-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    top: 9px;
    right: 10px;
    z-index: 2;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: .76rem;
    font-weight: 800;
    cursor: pointer;
  }
}

/* A2／A9：表格滑動提示與可聚焦容器 */
.u2-table-hint,
.u3-table-hint,
.u4-table-hint {
  margin: 0 0 8px;
}

.u2-table-wrap:focus-visible,
.u3-arch-table-wrap:focus-visible,
.u4-table-wrap:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 10px;
}

@media (max-width: 859px) {
  .scroll-hint.u2-table-hint,
  .scroll-hint.u3-table-hint,
  .scroll-hint.u4-table-hint {
    display: inline-block;
    margin: 0 0 8px;
    padding: 3px 9px;
    border-radius: 999px;
    background: var(--primary-weak);
    color: var(--primary);
    font-size: .78rem;
    white-space: normal;
  }
}

/* A3：回到頂端 */
.back-to-top {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 90;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow);
  font-size: 1.2rem;
  font-weight: 800;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
}

.back-to-top.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

/* A6：TOC summary 不拆行 */
.toc-title,
.toc-count { white-space: nowrap; }

@media (max-width: 1080px) {
  .toc-card > summary {
    gap: 6px;
    font-size: .84rem;
  }
  .toc-count { font-size: .68rem; }
}

/* A10：4-1 五段在桌面更緊湊 */
@media (min-width: 860px) {
  .u4-load-stage { padding: 12px 9px; }
  .u4-load-stage strong { font-size: .84rem; }
  .u4-load-stage > span:last-child { font-size: .76rem; }
}

/* A11：日期不要斷行 */
.nowrap { white-space: nowrap; }
