:root {
  color-scheme: dark;
  --bg: #02040a;
  --ink: #e8e8ea;
  --muted: #a1a8b5;
  --line: #252c38;
  --panel: #080c14;
  --panel-2: #0d121c;
  --n: #70e0c2;
  --omega: #f0c15a;
  --coef: #ef7f72;
  --falloff: #b79cf0;
  --link: #d9b585;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

body {
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

.site-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

.brand {
  color: #d9b585;
  font-weight: 700;
  text-decoration: none;
}

.page-shell {
  width: min(1040px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 42px 0 72px;
}

.intro {
  margin-bottom: 34px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 820px;
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(2rem, 7vw, 4.7rem);
  line-height: 1.04;
  letter-spacing: -0.025em;
}

h2 {
  margin-bottom: 10px;
  font-size: 1.18rem;
  line-height: 1.25;
  letter-spacing: 0;
}

/* 主題的英文/中文 companion：小一號、次要色，永遠與主題同行不被埋沒 */
.topic-en,
.topic-zh {
  font-size: 0.5em;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* aha 一句話：副標，重量介於 H1 與內文之間 */
.deck {
  max-width: 760px;
  margin: 16px 0 0;
  color: #d5deee;
  font-size: clamp(1.15rem, 3.2vw, 1.7rem);
  line-height: 1.32;
  font-weight: 400;
}

/* ---- 生活比喻入口（SPEC C7）---- */
.metaphor {
  max-width: 460px;
  margin: 22px 0 0;
}

.metaphor-art {
  display: block;
  width: 100%;
  height: auto;
}

.metaphor figcaption {
  margin-top: 6px;
  color: #ced8ea;
  font-size: 0.95rem;
  line-height: 1.55;
}

.m-sine { fill: none; stroke: var(--n); }
.m-sine.s1 { stroke-width: 2.5; }
.m-sine.s2 { stroke-width: 2; opacity: 0.72; }
.m-sine.s3 { stroke-width: 1.5; opacity: 0.5; }
.m-plus { fill: var(--muted); font: 700 20px system-ui, sans-serif; }
.m-square { fill: none; stroke: var(--omega); stroke-width: 2.5; stroke-dasharray: 6 4; }

/* ---- 步驟鏈（SPEC C7）---- */
.step-no {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-right: 8px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #dce4f2;
}

/* ---- 三重對應色塊 + 圖例（SPEC C6）：圖例走 HTML，不塞 canvas 小字 ---- */
.chip {
  display: inline-block;
  width: 11px;
  height: 11px;
  margin-right: 8px;
  border-radius: 3px;
  vertical-align: -1px;
}

.chip-n,
.chip-synth { background: var(--n); }
.chip-target { background: transparent; border: 2px dashed var(--omega); }
.chip-gap { background: rgba(240, 193, 90, 0.16); border: 1px solid rgba(240, 193, 90, 0.45); }
.chip-new { background: var(--falloff); }

.canvas-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  margin: 0 0 12px;
  color: #b8c5d8;
  font-size: 0.86rem;
  font-weight: 500;
}

.legend-item { white-space: nowrap; }

/* ---- 公式預設收合（SPEC C7）---- */
.formal-details {
  border: 1px solid var(--line);
  background: var(--panel);
}

.formal-details summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
}

.formal-details summary::-webkit-details-marker { display: none; }

.formal-details summary::before {
  content: '▸';
  color: var(--muted);
  font-size: 0.9rem;
  transition: transform 0.15s ease;
}

.formal-details[open] summary::before { transform: rotate(90deg); }

.formal-details summary h2 { margin: 0; }

.summary-hint {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.82rem;
  white-space: nowrap;
}

.details-body { padding: 0 16px 18px; }

@media (prefers-reduced-motion: reduce) {
  .formal-details summary::before { transition: none; }
}

.lab-surface {
  padding: 28px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.surface-copy {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: baseline;
  margin-bottom: 12px;
}

.surface-copy h2 {
  font-size: 1.35rem;
}

.canvas-wrap {
  width: 100%;
  aspect-ratio: 16 / 7;
  min-height: 300px;
  border: 1px solid #2a3b55;
  background: #04070d;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
  margin-top: 18px;
}

.control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  min-width: 0;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  background: transparent;
}

.control span,
.control output {
  min-width: 0;
  white-space: nowrap;
}

.control output {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.control input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  min-height: 44px; /* 觸控目標 ≥44px（spec §1 手機要求）*/
  accent-color: currentColor;
  touch-action: manipulation;
  cursor: pointer;
}

.control-n {
  color: var(--n);
}

.usecase-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 1.25rem;
  max-width: 820px;
  color: #ced8ea;
}

.usecase-list b {
  color: var(--ink);
}

.tasks,
.usecases,
.formal,
.links {
  padding-top: 34px;
  margin-top: 34px;
  border-top: 1px solid var(--line);
}

.tasks ol {
  display: grid;
  gap: 10px;
  margin: 0;
  padding-left: 1.25rem;
  color: #d5deee;
}

.formula {
  margin: 12px 0 16px;
  padding: 18px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: clamp(1.35rem, 4.4vw, 2.3rem);
  line-height: 1.3;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.sym {
  font-weight: 700;
}

.sym.n {
  color: var(--n);
}

.sym.omega {
  color: var(--omega);
}

.sym.coef {
  color: var(--coef);
}

.sym.falloff {
  color: var(--falloff);
}

/* ---- 公式符號懸浮註釋（SPEC_DELTA C5，共用 sym-tooltip.js 驅動）---- */
.symbol-gloss {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  align-items: center;
  margin: 14px 0 0;
  padding: 0;
}

.symbol-gloss dt {
  margin: 0;
  white-space: nowrap;
}

/* 詞彙表＝鍵盤／輔助科技的正式互動圖例：乾淨 tab 停點，觸控目標 ≥44px */
.symbol-gloss dt[data-sym] {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: 4px 6px;
  border-radius: 3px;
  cursor: pointer;
}

.symbol-gloss dt[data-sym].is-active {
  outline: 1px solid currentColor;
}

.symbol-gloss dt[data-sym]:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

.symbol-gloss dd {
  margin: 0;
  color: #ced8ea;
}

.formal .sym[data-sym] {
  padding: 0 2px;
  border-radius: 3px;
  cursor: pointer;
}

/* .is-active 以底線＋外框標示，色彩非唯一通道 */
.formal .sym[data-sym].is-active {
  text-decoration: underline;
  outline: 1px solid currentColor;
}

.sym-explainer {
  min-height: 1.6em;
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: #ced8ea;
  font-size: 0.92rem;
  line-height: 1.5;
}

.sym-tip {
  position: fixed;
  z-index: 40;
  max-width: 260px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: #0a0f18;
  color: var(--ink);
  font-size: 0.85rem;
  line-height: 1.45;
  pointer-events: none;
}

.sym-tip[hidden] {
  display: none;
}

.links p,
.formal p {
  max-width: 820px;
  color: #ced8ea;
}

.formal .aside {
  color: var(--muted);
  font-size: 0.95rem;
}

.graph-link {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  padding: 0 16px;
  border: 1px solid var(--link);
  color: var(--link);
  text-decoration: none;
}

.graph-link:hover {
  background: rgba(217, 181, 133, 0.08);
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100vw - 24px, 640px);
    padding-top: 28px;
  }

  .site-header {
    padding: 0 14px;
  }

  .lab-surface {
    padding: 26px 0 0;
  }

  .surface-copy {
    display: block;
  }

  .canvas-wrap {
    aspect-ratio: 1 / 1;
    min-height: 280px;
  }

  .controls {
    grid-template-columns: 1fr;
  }

  .control span,
  .control output {
    white-space: normal;
  }
}

/* Quiet reading rhythm shared across Depth; diagrams retain their own scales. */
.site-header{padding-inline:max(24px,calc((100vw - 1040px)/2));gap:16px;border-bottom-color:rgba(161,168,181,.12)}
.brand{letter-spacing:.035em;font-size:.95rem}
.site-header>span{font-size:.75rem;letter-spacing:.1em;color:var(--muted)}
.page-shell,body>main{padding-top:52px}
h1{font-size:clamp(40px,7vw,75px);font-weight:650;text-wrap:balance}
.topic-en,.topic-zh{display:block;margin:12px 0 0;font-size:clamp(18px,2.2vw,25px);font-weight:400;line-height:1.4;white-space:normal}
h2{font-weight:600;line-height:1.45;text-wrap:balance}
p,li{line-height:1.8}
.deck{line-height:1.55;max-width:38em;color:#d8d9dd}
.intro{margin-bottom:40px}
.tasks,.usecases,.formal,.links{margin-top:48px;padding-top:32px}
.tasks ol,.usecase-list{gap:16px;max-width:70ch}
.details-body,.formal-body{max-width:78ch}
.formal-details{border-color:rgba(161,168,181,.18);background:var(--panel)}
.formal-details summary{min-height:60px;padding:16px 20px}
.formal-details summary:hover{background:rgba(217, 181, 133,.035)}
.canvas-wrap{border-color:rgba(161,168,181,.22)}
.control{padding:16px 12px 4px;background:var(--panel);border-top-color:rgba(161,168,181,.18)}
.control-row{padding:16px 18px 10px;background:var(--panel);border-top-color:rgba(161,168,181,.18)}
button:focus-visible,a:focus-visible,summary:focus-visible,input:focus-visible{outline:2px solid #d9b585;outline-offset:4px}
a{ text-underline-offset:.25em }
@media(max-width:760px){
 .site-header{padding-inline:20px}
 .page-shell,body>main{width:calc(100% - 40px);padding-top:32px}
 h1{overflow-wrap:break-word}
 .deck{font-size:1.12rem;line-height:1.65}
 .topic-en,.topic-zh{font-size:20px;line-height:1.4}
 .controls{display:grid;grid-template-columns:minmax(0,1fr);gap:12px;overflow:visible}
 .control{width:100%;min-width:0}
 .control input{min-width:0}
 .control{padding-inline:8px}
 .tasks,.usecases,.formal,.links{margin-top:36px;padding-top:28px}
 .summary-hint{white-space:normal;text-align:right}
}
