/* ==========================================================
   量子算法漫游 · 样式表
   纯 CSS，无外部字体 / 无框架；动画只使用 transform / opacity
   ========================================================== */

:root {
  --bg: #060912;
  --bg-2: #0a0f1e;
  --surface: #0d1427;
  --surface-2: #131b34;
  --surface-3: #1a2444;
  --line: rgba(140, 160, 255, .12);
  --line-2: rgba(140, 160, 255, .24);
  --text: #e8ebf7;
  --muted: #9ba4c6;
  --faint: #5f6889;
  --c1: #5ee7ff;
  --c2: #a78bfa;
  --c3: #f472b6;
  --c4: #fbbf24;
  --ok: #34d399;
  --bad: #fb7185;
  --c1-soft: rgba(94, 231, 255, .12);
  --c2-soft: rgba(167, 139, 250, .14);
  --c3-soft: rgba(244, 114, 182, .12);
  --c4-soft: rgba(251, 191, 36, .12);
  --sphere-hi: rgba(130, 150, 255, .22);
  --sphere-lo: rgba(20, 28, 64, .30);
  --grad: linear-gradient(120deg, var(--c1), var(--c2) 52%, var(--c3));
  --shadow: 0 24px 60px -24px rgba(0, 0, 0, .7);
  --glow: 0 0 0 1px var(--line), 0 20px 50px -20px rgba(94, 231, 255, .18);
  --radius: 20px;
  --radius-sm: 12px;
  --mono: "JetBrains Mono", "SF Mono", "Cascadia Code", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Source Han Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  --serif: "Cambria Math", "STIX Two Math", "Latin Modern Math", "Times New Roman", "Songti SC", serif;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f6fb;
  --bg-2: #eceff8;
  --surface: #ffffff;
  --surface-2: #f3f5fc;
  --surface-3: #e7ebf7;
  --line: rgba(30, 40, 100, .10);
  --line-2: rgba(30, 40, 100, .20);
  --text: #121830;
  --muted: #4e5878;
  --faint: #8890ab;
  --c1: #0892b5;
  --c2: #7c3aed;
  --c3: #db2777;
  --c4: #c27803;
  --ok: #059669;
  --bad: #e11d48;
  --c1-soft: rgba(8, 146, 181, .09);
  --c2-soft: rgba(124, 58, 237, .08);
  --c3-soft: rgba(219, 39, 119, .08);
  --c4-soft: rgba(194, 120, 3, .10);
  --sphere-hi: rgba(255, 255, 255, .95);
  --sphere-lo: rgba(190, 200, 235, .55);
  --shadow: 0 24px 60px -30px rgba(30, 40, 100, .35);
  --glow: 0 0 0 1px var(--line), 0 20px 50px -26px rgba(60, 80, 180, .35);
  color-scheme: light;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 76px;
}

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.8;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* 固定背景层：单独合成层，滚动时不重绘 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60vmax 50vmax at 85% -10%, var(--c2-soft), transparent 60%),
    radial-gradient(50vmax 40vmax at -10% 20%, var(--c1-soft), transparent 60%),
    radial-gradient(40vmax 40vmax at 60% 120%, var(--c3-soft), transparent 60%),
    var(--bg);
}

img, svg, canvas { display: block; max-width: 100%; }
a { color: var(--c1); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
p { margin: 0 0 1em; }
h1, h2, h3, h4 { line-height: 1.3; margin: 0; font-weight: 700; letter-spacing: .01em; }
strong { color: var(--text); font-weight: 650; }
sub, sup { line-height: 0; }
button { font: inherit; color: inherit; }
::selection { background: var(--c2); color: #fff; }

:focus-visible {
  outline: 2px solid var(--c1);
  outline-offset: 2px;
  border-radius: 6px;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 8px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--surface);
}
.skip:focus { left: 12px; }

/* ---------- 通用排版元素 ---------- */
.wrap { width: min(1120px, 100% - 32px); margin-inline: auto; }
.narrow { max-width: 760px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); }
.grad {
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.ket {
  font-family: var(--serif);
  font-style: normal;
  white-space: nowrap;
  letter-spacing: .02em;
}
.math {
  font-family: var(--serif);
  white-space: nowrap;
}
.math i, .ket i { font-style: italic; }
.formula {
  display: block;
  margin: 18px 0 22px;
  padding: 16px 20px;
  font-family: var(--serif);
  font-size: 1.22em;
  text-align: center;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--line);
  overflow-x: auto;
  white-space: nowrap;
}
.formula .note {
  display: block;
  margin-top: 4px;
  font-family: var(--sans);
  font-size: .68em;
  color: var(--muted);
  white-space: normal;
}
.kbd {
  display: inline-block;
  padding: 0 7px;
  font-family: var(--mono);
  font-size: .82em;
  line-height: 1.7;
  border: 1px solid var(--line-2);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
}
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 10px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: .06em;
  border-radius: 999px;
  color: var(--c1);
  background: var(--c1-soft);
  border: 1px solid color-mix(in srgb, var(--c1) 30%, transparent);
}
.tag.v { color: var(--c2); background: var(--c2-soft); border-color: color-mix(in srgb, var(--c2) 30%, transparent); }
.tag.p { color: var(--c3); background: var(--c3-soft); border-color: color-mix(in srgb, var(--c3) 30%, transparent); }
.tag.a { color: var(--c4); background: var(--c4-soft); border-color: color-mix(in srgb, var(--c4) 30%, transparent); }

/* ---------- 顶栏 ---------- */
.progress {
  position: fixed;
  inset: 0 0 auto 0;
  height: 2px;
  z-index: 60;
  pointer-events: none;
}
.progress i {
  display: block;
  height: 100%;
  background: var(--grad);
  transform-origin: 0 50%;
  transform: scaleX(0);
  will-change: transform;
}

.topbar {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 50;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 max(16px, env(safe-area-inset-left)) 0 max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: .04em;
  white-space: nowrap;
}
.brand:hover { text-decoration: none; }
.brand svg { width: 28px; height: 28px; }
.now {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  color: var(--muted);
  font-size: 14px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .3s, transform .3s;
}
.now.show { opacity: 1; transform: none; }
.now-num { font-family: var(--mono); color: var(--c1); font-size: 12px; }
.now-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, border-color .2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-2); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .sun { display: none; }
:root[data-theme="light"] .icon-btn .sun { display: block; }
:root[data-theme="light"] .icon-btn .moon { display: none; }

/* ---------- 目录浮层 ---------- */
.toc {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: start end;
  padding: 70px 16px 16px;
  background: rgba(3, 5, 12, .5);
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.toc.open { opacity: 1; visibility: visible; }
.toc-panel {
  width: min(420px, 100%);
  max-height: calc(100vh - 90px);
  max-height: calc(100dvh - 90px);
  overflow: auto;
  padding: 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line-2);
  box-shadow: var(--shadow);
  transform: translateY(-8px) scale(.98);
  transition: transform .25s;
}
.toc.open .toc-panel { transform: none; }
.toc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 6px 12px;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .1em;
}
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc a {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 2px 8px;
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--text);
}
.toc a:hover, .toc a.active { background: var(--surface-2); text-decoration: none; }
.toc a.active .n { color: var(--c3); }
.toc .n { grid-row: span 2; font-family: var(--mono); color: var(--c1); font-size: 13px; padding-top: 3px; }
.toc .t { font-weight: 600; }
.toc .d { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* ---------- 按钮 / 控件 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 16px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--surface-2);
  color: var(--text);
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform .15s, background .2s, border-color .2s, box-shadow .2s;
}
.btn:hover { border-color: color-mix(in srgb, var(--c1) 55%, transparent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.primary {
  border-color: transparent;
  color: #061019;
  background: linear-gradient(120deg, var(--c1), color-mix(in srgb, var(--c1) 40%, var(--c2)));
  box-shadow: 0 10px 30px -12px var(--c1);
}
:root[data-theme="light"] .btn.primary { color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 34px; padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }
.btn.gate {
  min-width: 46px;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 700;
}
.btn.on { border-color: var(--c1); background: var(--c1-soft); color: var(--c1); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

.seg {
  display: inline-flex;
  flex-wrap: wrap;
  padding: 3px;
  gap: 2px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  min-height: 32px;
  border-radius: 9px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 var(--line-2) inset; }

select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  min-height: 38px;
  padding: 6px 34px 6px 12px;
  border-radius: 10px;
  border: 1px solid var(--line-2);
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) right 16px top 52% / 5px 5px no-repeat,
    linear-gradient(-45deg, transparent 50%, var(--muted) 50%) right 11px top 52% / 5px 5px no-repeat,
    var(--surface-2);
  cursor: pointer;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--c1), var(--c2)) 0 0 / var(--p, 50%) 100% no-repeat, var(--surface-3);
}
input[type="range"]::-moz-range-track { height: 6px; border-radius: 6px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 6px; background: linear-gradient(90deg, var(--c1), var(--c2)); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--c1);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35);
}
input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--c1);
}
.field { display: grid; gap: 2px; }
.field-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 13.5px;
  color: var(--muted);
}
.field-label b { color: var(--text); font-family: var(--mono); font-weight: 600; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  padding: 100px 0 60px;
  overflow: hidden;
}
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px;
  -webkit-mask-image: radial-gradient(ellipse 70% 60% at 60% 45%, #000 20%, transparent 75%);
  mask-image: radial-gradient(ellipse 70% 60% at 60% 45%, #000 20%, transparent 75%);
  opacity: .55;
}
.hero-grid {
  display: grid;
  grid-template-columns: 1.15fr .85fr;
  gap: 40px;
  align-items: center;
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  padding: 6px 14px 6px 8px;
  font-size: 13.5px;
  color: var(--muted);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}
.eyebrow .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--ok) 22%, transparent);
}
.hero h1 {
  font-size: clamp(2.6rem, 7vw, 5rem);
  line-height: 1.08;
  letter-spacing: -.01em;
  font-weight: 800;
}
.hero h1 .grad { display: inline-block; padding-bottom: .08em; }
.hero .lead {
  margin: 26px 0 32px;
  max-width: 600px;
  font-size: clamp(1.02rem, 1.6vw, 1.15rem);
  color: var(--muted);
}
.hero .btn-row { gap: 12px; }
.hero .btn { min-height: 48px; padding: 10px 22px; font-size: 15.5px; border-radius: 14px; }
.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  margin-top: 44px;
  color: var(--muted);
  font-size: 14px;
}
.hero-meta b {
  display: block;
  font-size: 26px;
  line-height: 1.2;
  color: var(--text);
  font-family: var(--mono);
  font-weight: 600;
}

.hero-art { position: relative; aspect-ratio: 1; width: 100%; max-width: 460px; justify-self: center; }
.hero-art svg { width: 100%; height: 100%; overflow: visible; }
.orbit { transform-origin: 200px 200px; animation: spin 28s linear infinite; }
.orbit.o2 { animation-duration: 40s; animation-direction: reverse; }
.orbit.o3 { animation-duration: 18s; }
.hero-vec { transform-origin: 200px 200px; animation: precess 9s ease-in-out infinite; }
.float-ket {
  position: absolute;
  padding: 6px 12px;
  font-family: var(--serif);
  font-size: 17px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  box-shadow: var(--shadow);
  animation: bob 6s ease-in-out infinite;
  white-space: nowrap;
}
.float-ket.k1 { top: 8%; left: -4%; }
.float-ket.k2 { bottom: 14%; right: -6%; animation-delay: -2s; }
.float-ket.k3 { bottom: 2%; left: 6%; animation-delay: -4s; }
.paused .orbit, .paused .hero-vec, .paused .float-ket { animation-play-state: paused; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes precess {
  0%, 100% { transform: rotate(-24deg); }
  50% { transform: rotate(30deg); }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.scroll-hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  color: var(--faint);
  font-size: 12px;
  letter-spacing: .2em;
  display: grid;
  justify-items: center;
  gap: 6px;
}
.scroll-hint i {
  width: 1px;
  height: 32px;
  background: linear-gradient(var(--faint), transparent);
}

/* ---------- 章节 ---------- */
.chapter { position: relative; padding: 110px 0 40px; }
.ch-head { margin-bottom: 40px; max-width: 820px; }
.ch-num {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: .18em;
  color: var(--c1);
}
.ch-num::after {
  content: "";
  height: 1px;
  width: 80px;
  background: linear-gradient(90deg, var(--c1), transparent);
}
.ch-head h2 { font-size: clamp(1.9rem, 4.2vw, 2.9rem); letter-spacing: -.005em; }
.ch-head h2 small {
  display: block;
  margin-top: 6px;
  font-size: .42em;
  font-weight: 500;
  color: var(--faint);
  letter-spacing: .12em;
  text-transform: uppercase;
}
.ch-head .lead { margin-top: 18px; font-size: 1.1rem; color: var(--muted); }

.prose { max-width: 760px; }
.prose h3 { font-size: 1.32rem; margin: 40px 0 14px; }
.prose ul, .prose ol { padding-left: 1.3em; margin: 0 0 1em; }
.prose li { margin: .3em 0; }
.prose li::marker { color: var(--c1); }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
  align-items: start;
}

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin: 28px 0; }
.card {
  position: relative;
  padding: 24px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface) 60%, transparent));
  border: 1px solid var(--line);
  transition: border-color .25s, transform .25s;
}
.card:hover { border-color: var(--line-2); transform: translateY(-2px); }
.card h3 { font-size: 1.12rem; margin: 12px 0 8px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; line-height: 1.75; }
.card .ico {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: var(--c1-soft);
  color: var(--c1);
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 700;
}
.card .ico.v { background: var(--c2-soft); color: var(--c2); }
.card .ico.p { background: var(--c3-soft); color: var(--c3); }
.card .ico.a { background: var(--c4-soft); color: var(--c4); }
.card .ico svg { width: 22px; height: 22px; }

.callout {
  position: relative;
  margin: 26px 0;
  padding: 18px 22px 18px 56px;
  border-radius: var(--radius-sm);
  background: var(--c1-soft);
  border: 1px solid color-mix(in srgb, var(--c1) 25%, transparent);
  font-size: 15.5px;
}
.callout::before {
  content: "i";
  position: absolute;
  left: 18px;
  top: 19px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--serif);
  font-weight: 700;
  font-style: italic;
  font-size: 14px;
  color: var(--bg);
  background: var(--c1);
}
.callout p:last-child { margin: 0; }
.callout.warn { background: var(--c4-soft); border-color: color-mix(in srgb, var(--c4) 28%, transparent); }
.callout.warn::before { content: "!"; font-style: normal; background: var(--c4); }
.callout.key { background: var(--c2-soft); border-color: color-mix(in srgb, var(--c2) 28%, transparent); }
.callout.key::before { content: "★"; font-style: normal; font-size: 12px; background: var(--c2); }
.callout b.t { display: block; margin-bottom: 4px; }

details.more {
  margin: 22px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
}
details.more summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before {
  content: "+";
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: var(--surface-3);
  color: var(--c1);
  font-family: var(--mono);
  transition: transform .2s;
}
details.more[open] summary::before { transform: rotate(45deg); }
details.more summary .tag { margin-left: auto; }
details.more .body { padding: 2px 20px 18px; color: var(--muted); font-size: 15.5px; }
details.more .body strong { color: var(--text); }

/* 矩阵 */
.matrices { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin: 10px 0 4px; }
.mat-card { padding: 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); text-align: center; }
.mat-card .name { font-weight: 700; color: var(--text); font-family: var(--serif); font-size: 17px; }
.mat {
  display: inline-grid;
  grid-template-columns: auto auto;
  gap: 2px 14px;
  margin-top: 8px;
  padding: 4px 12px;
  font-family: var(--serif);
  color: var(--text);
  border-left: 2px solid var(--muted);
  border-right: 2px solid var(--muted);
  border-radius: 6px;
}
.mat.pre { position: relative; }
.mat-wrap { display: inline-flex; align-items: center; gap: 6px; font-family: var(--serif); color: var(--text); }

/* ---------- 实验面板 ---------- */
.lab {
  position: relative;
  margin: 36px 0;
  border-radius: calc(var(--radius) + 4px);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 96%, transparent), color-mix(in srgb, var(--surface) 80%, transparent));
  border: 1px solid var(--line-2);
  box-shadow: var(--glow);
  overflow: hidden;
}
.lab::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--c1), var(--c2), transparent);
  opacity: .7;
}
.lab-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}
.lab-head h3 { font-size: 1.04rem; }
.lab-head .hint { margin-left: auto; font-size: 13px; color: var(--faint); }
.lab-body { padding: 22px; }
.lab-grid { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 26px; }
.lab-col { display: grid; gap: 18px; align-content: start; min-width: 0; }
.panel {
  padding: 16px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.panel-title {
  margin-bottom: 10px;
  font-size: 12.5px;
  letter-spacing: .12em;
  color: var(--faint);
  font-weight: 600;
}
.readout {
  font-family: var(--serif);
  font-size: 1.18em;
  line-height: 1.6;
  overflow-x: auto;
  white-space: nowrap;
  padding-bottom: 2px;
}
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.stat .k { font-size: 12.5px; color: var(--faint); }
.stat .v { font-family: var(--mono); font-size: 20px; font-weight: 600; line-height: 1.35; }
.stat .v.c1 { color: var(--c1); }
.stat .v.c2 { color: var(--c2); }
.stat .v.c3 { color: var(--c3); }
.stat .v.ok { color: var(--ok); }

.result {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px dashed var(--line-2);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}
.result.good { border-style: solid; border-color: color-mix(in srgb, var(--ok) 45%, transparent); background: color-mix(in srgb, var(--ok) 9%, transparent); color: var(--text); }
.result.bad { border-style: solid; border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: color-mix(in srgb, var(--bad) 8%, transparent); color: var(--text); }
.result.info { border-style: solid; border-color: color-mix(in srgb, var(--c1) 40%, transparent); background: var(--c1-soft); color: var(--text); }
.flash { animation: flash .6s ease; }
@keyframes flash { from { box-shadow: 0 0 0 3px color-mix(in srgb, var(--c1) 50%, transparent); } to { box-shadow: 0 0 0 0 transparent; } }

/* 水平概率条 */
.hbars { display: grid; gap: 8px; }
.hbar { display: grid; grid-template-columns: 52px 1fr 64px; align-items: center; gap: 10px; font-size: 14px; }
.hbar .lbl { font-family: var(--serif); font-size: 16px; }
.hbar .trk { position: relative; height: 12px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.hbar .trk i {
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--c1), var(--c2));
  transform-origin: 0 50%;
  transform: scaleX(0);
  transition: transform .45s cubic-bezier(.2, .8, .2, 1);
}
.hbar .trk b {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text);
  opacity: .55;
  border-radius: 1px;
  transition: left .45s;
}
.hbar .val { font-family: var(--mono); font-size: 13px; text-align: right; color: var(--muted); }

/* 振幅柱状图（竖直，可正可负） */
.bars { position: relative; user-select: none; -webkit-user-select: none; }
.bars-plot {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: var(--gap, 6px);
  height: var(--h, 220px);
  padding: 0 4px;
}
.bars-zero, .bars-mean {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  pointer-events: none;
}
.bars-zero { top: 50%; border-top: 1px solid var(--line-2); }
.bars-mean {
  top: 50%;
  border-top: 2px dashed var(--c4);
  opacity: 0;
  transition: top .45s cubic-bezier(.2, .8, .2, 1), opacity .3s;
  z-index: 2;
}
.bars-mean.show { opacity: .9; }
.bars-mean span {
  position: absolute;
  right: 4px;
  top: -22px;
  font-size: 11.5px;
  color: var(--c4);
  font-weight: 600;
  background: var(--surface);
  padding: 0 6px;
  border-radius: 6px;
}
.bar {
  position: relative;
  flex: 1;
  min-width: 2px;
  border-radius: 4px;
  cursor: default;
}
.bars.clickable .bar { cursor: pointer; }
.bars.clickable .bar:hover { background: var(--surface-3); }
.bar .fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 50%;
  height: 50%;
  border-radius: 3px 3px 0 0;
  background: linear-gradient(0deg, color-mix(in srgb, var(--c1) 55%, transparent), var(--c1));
  transform-origin: 50% 100%;
  transform: scaleY(0);
  transition: transform .45s cubic-bezier(.2, .8, .2, 1);
}
.bar .fill.neg {
  bottom: auto;
  top: 50%;
  border-radius: 0 0 3px 3px;
  transform-origin: 50% 0;
  background: linear-gradient(180deg, color-mix(in srgb, var(--c3) 55%, transparent), var(--c3));
}
.bar.hi .fill { background: linear-gradient(0deg, color-mix(in srgb, var(--c4) 55%, transparent), var(--c4)); }
.bar.hi .fill.neg { background: linear-gradient(180deg, color-mix(in srgb, var(--c4) 55%, transparent), var(--c4)); }
.bar.hit { background: color-mix(in srgb, var(--ok) 20%, transparent); }
.bar-labels { display: flex; gap: var(--gap, 6px); padding: 6px 4px 0; }
.bar-labels span {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--faint);
  overflow: hidden;
}
.bar-labels span.hi { color: var(--c4); font-weight: 700; }

/* ---------- 迷你线路图 ---------- */
.mc {
  display: grid;
  gap: 10px 0;
  margin: 22px 0;
  padding: 22px 20px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--line);
  overflow-x: auto;
}
.mc-row { position: relative; display: flex; align-items: center; gap: 22px; min-height: 44px; min-width: max-content; }
.mc-row::before {
  content: "";
  position: absolute;
  left: 40px;
  right: 6px;
  top: 50%;
  height: 1.5px;
  background: var(--muted);
  opacity: .55;
}
.mc-in { position: relative; width: 40px; font-family: var(--serif); font-size: 17px; color: var(--muted); }
.mc-g {
  position: relative;
  min-width: 44px;
  height: 40px;
  padding: 0 10px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-family: var(--serif);
  font-weight: 700;
  font-size: 17px;
  color: var(--c1);
  background: var(--surface-2);
  border: 1.5px solid color-mix(in srgb, var(--c1) 60%, transparent);
}
.mc-g.v { color: var(--c2); border-color: color-mix(in srgb, var(--c2) 60%, transparent); }
.mc-g.p { color: var(--c3); border-color: color-mix(in srgb, var(--c3) 60%, transparent); }
.mc-g.a { color: var(--c4); border-color: color-mix(in srgb, var(--c4) 60%, transparent); }
.mc-g.tall { height: calc(var(--rows, 3) * 44px + (var(--rows, 3) - 1) * 10px); align-self: flex-start; }
.mc-g.ghost { visibility: hidden; }
.mc-m {
  position: relative;
  width: 40px;
  height: 34px;
  border-radius: 8px;
  border: 1.5px solid var(--muted);
  background: var(--surface-2);
}
.mc-m::before {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  bottom: 8px;
  height: 14px;
  border: 1.5px solid var(--muted);
  border-bottom: 0;
  border-radius: 14px 14px 0 0;
}
.mc-m::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 1.5px;
  height: 18px;
  background: var(--c3);
  transform-origin: 50% 100%;
  transform: rotate(38deg);
}
.mc-sep { position: relative; color: var(--faint); font-size: 13px; padding: 0 2px; background: var(--surface); }
.mc-cap {
  display: flex;
  gap: 22px;
  padding-left: 62px;
  font-size: 12.5px;
  color: var(--faint);
  min-width: max-content;
}

/* ---------- 布洛赫球 ---------- */
.bloch-stage {
  position: relative;
  aspect-ratio: 1;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  border-radius: 18px;
  background: radial-gradient(circle at 50% 45%, var(--surface-2), transparent 70%);
}
.bloch-stage canvas { width: 100%; height: 100%; cursor: grab; touch-action: pan-y; }
.bloch-stage canvas:active { cursor: grabbing; }
.bloch-stage .drag-tip {
  position: absolute;
  left: 50%;
  bottom: 6px;
  transform: translateX(-50%);
  font-size: 12px;
  color: var(--faint);
  pointer-events: none;
  white-space: nowrap;
}
.measure-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  padding: 6px 12px;
  border-radius: 10px;
  font-size: 13.5px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .3s, transform .3s;
  pointer-events: none;
}
.measure-badge.show { opacity: 1; transform: none; }

/* ---------- 干涉 ---------- */
.phasors { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.phasor {
  padding: 12px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  text-align: center;
}
.phasor svg { width: 100%; max-width: 240px; margin: 0 auto; overflow: visible; }
.phasor .cap { font-size: 13.5px; color: var(--muted); }
.phasor .big { font-family: var(--mono); font-size: 22px; font-weight: 700; }
.ph-axis { stroke: var(--line-2); stroke-width: 1; }
.ph-unit { fill: none; stroke: var(--line-2); stroke-dasharray: 3 4; }
.ph-a { stroke: var(--c1); stroke-width: 3.5; stroke-linecap: round; }
.ph-b { stroke: var(--c2); stroke-width: 3.5; stroke-linecap: round; }
.ph-r { stroke: var(--c3); stroke-width: 2.5; stroke-dasharray: 5 4; stroke-linecap: round; }
.ph-dot { fill: var(--c3); }
.mk-a { fill: var(--c1); }
.mk-b { fill: var(--c2); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* ---------- 纠缠 ---------- */
.ent-pair { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; }
.qcard {
  padding: 18px 12px;
  border-radius: 16px;
  text-align: center;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.qcard .who { font-size: 13px; color: var(--faint); }
.qcard .q {
  margin: 8px auto 4px;
  width: 76px;
  height: 76px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 700;
  background: conic-gradient(from 0deg, var(--c1), var(--c2), var(--c3), var(--c1));
  color: #fff;
  position: relative;
  transition: transform .4s;
}
.qcard .q::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--surface-2);
}
.qcard .q span { position: relative; color: var(--text); }
.qcard .q.unk span { color: var(--faint); font-size: 26px; }
.qcard .q.pop { animation: pop .45s ease; }
@keyframes pop { 40% { transform: scale(1.12); } }
.link {
  width: 64px;
  height: 2px;
  background: repeating-linear-gradient(90deg, var(--c2) 0 6px, transparent 6px 11px);
  position: relative;
}
.link.off { background: repeating-linear-gradient(90deg, var(--faint) 0 2px, transparent 2px 11px); }
.link::after {
  content: attr(data-l);
  position: absolute;
  left: 50%;
  top: -24px;
  transform: translateX(-50%);
  font-size: 11.5px;
  color: var(--faint);
  white-space: nowrap;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 30px; }
.chip {
  padding: 2px 9px;
  font-family: var(--mono);
  font-size: 13px;
  border-radius: 8px;
  background: var(--surface-3);
  border: 1px solid var(--line);
}
.chip.same { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.chip.diff { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.chip.new { animation: pop .35s ease; }

/* ---------- 指数增长 ---------- */
.exp-out { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 18px; }
.exp-out .stat .v { font-size: 19px; word-break: break-all; }
.exp-note {
  margin-top: 12px;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--surface-2);
  border-left: 3px solid var(--c2);
  font-size: 15px;
}

/* ---------- 线路编辑器 ---------- */
.cc-tools { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: center; margin-bottom: 16px; }
.palette { display: flex; flex-wrap: wrap; gap: 6px; }
.palette .btn { min-width: 44px; min-height: 42px; padding: 6px 10px; }
.palette .btn.erase { font-family: var(--sans); font-size: 13px; }
.cc-opts { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-left: auto; }
.cc-scroll {
  overflow-x: auto;
  padding: 10px 4px 14px;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
}
.cc-grid { display: grid; grid-auto-rows: 54px; position: relative; min-width: max-content; }
.cc-label {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  font-family: var(--serif);
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
}
.cc-label small { font-family: var(--mono); font-size: 11px; color: var(--faint); margin-right: 6px; }
.cc-cell {
  position: relative;
  width: 54px;
  height: 54px;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
  z-index: 1;
}
.cc-cell::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 1.5px;
  background: var(--muted);
  opacity: .5;
}
.cc-cell::after {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 10px;
  border: 1.5px dashed transparent;
  transition: border-color .15s;
}
.cc-cell:hover::after { border-color: var(--line-2); }
.cc-cell.future { opacity: .32; }
.cc-gate {
  position: absolute;
  inset: 8px;
  display: grid;
  place-items: center;
  border-radius: 9px;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 700;
  color: var(--c1);
  background: var(--surface);
  border: 1.5px solid color-mix(in srgb, var(--c1) 70%, transparent);
  z-index: 2;
}
.cc-gate.g-X, .cc-gate.g-Y { color: var(--c2); border-color: color-mix(in srgb, var(--c2) 70%, transparent); }
.cc-gate.g-Z, .cc-gate.g-S, .cc-gate.g-T { color: var(--c3); border-color: color-mix(in srgb, var(--c3) 70%, transparent); }
.cc-gate.ctrl {
  inset: auto;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 0;
  background: var(--text);
}
.cc-gate.target {
  inset: auto;
  left: 50%;
  top: 50%;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--c2);
  font-size: 0;
}
.cc-gate.target::before,
.cc-gate.target::after { content: ""; position: absolute; background: var(--c2); }
.cc-gate.target::before { left: 50%; top: 3px; bottom: 3px; width: 2px; margin-left: -1px; }
.cc-gate.target::after { top: 50%; left: 3px; right: 3px; height: 2px; margin-top: -1px; }
.cc-link { position: relative; pointer-events: none; z-index: 0; }
.cc-link::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 27px;
  bottom: 27px;
  width: 2px;
  margin-left: -1px;
  background: var(--text);
  opacity: .8;
}
.cc-link.future { opacity: .32; }
.cc-colnum { font-family: var(--mono); font-size: 11px; color: var(--faint); text-align: center; align-self: end; padding-bottom: 2px; }
.cc-step { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; margin: 16px 0 6px; font-size: 14px; color: var(--muted); }
.cc-step b { font-family: var(--mono); color: var(--text); }

.state-list { display: grid; gap: 6px; }
.st-row {
  display: grid;
  grid-template-columns: 68px 1fr 64px minmax(90px, 130px);
  gap: 10px;
  align-items: center;
  font-size: 14px;
  padding: 3px 8px;
  border-radius: 8px;
  transition: background .3s;
}
.st-row.zero { opacity: .38; }
.st-row.hit { background: color-mix(in srgb, var(--ok) 18%, transparent); }
.st-row .ket { font-size: 16px; }
.st-row .trk { position: relative; height: 14px; border-radius: 7px; background: var(--surface-3); overflow: hidden; }
.st-row .trk i { position: absolute; inset: 0; border-radius: 7px; transform-origin: 0 50%; transition: transform .4s cubic-bezier(.2, .8, .2, 1), background .3s; }
.st-row .p { font-family: var(--mono); text-align: right; font-size: 13px; }
.st-row .amp { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phase-key { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
.phase-wheel {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: conic-gradient(from 90deg, hsl(0 80% 60%), hsl(60 80% 55%), hsl(120 70% 50%), hsl(180 75% 50%), hsl(240 80% 65%), hsl(300 75% 60%), hsl(360 80% 60%));
  -webkit-mask: radial-gradient(circle, transparent 5px, #000 6px);
  mask: radial-gradient(circle, transparent 5px, #000 6px);
}

/* ---------- Deutsch-Jozsa ---------- */
.query-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.qbtn {
  display: grid;
  gap: 2px;
  justify-items: center;
  padding: 10px 4px;
  border-radius: 12px;
  border: 1px solid var(--line-2);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.qbtn:hover { border-color: var(--c1); }
.qbtn .x { font-family: var(--mono); font-size: 13px; color: var(--muted); }
.qbtn .f { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--faint); }
.qbtn.done { cursor: default; }
.qbtn.done .f.one { color: var(--c3); }
.qbtn.done .f.zero { color: var(--c1); }
.dj-steps { display: flex; flex-wrap: wrap; gap: 8px; }
.dj-stage { font-size: 14px; color: var(--muted); min-height: 2.6em; }

/* ---------- Grover ---------- */
.gv-chart { width: 100%; height: auto; }
.gv-chart .ln { fill: none; stroke: var(--c2); stroke-width: 2; }
.gv-chart .area { fill: var(--c2-soft); }
.gv-chart .ax { stroke: var(--line-2); }
.gv-chart .dot { fill: var(--c4); stroke: var(--surface); stroke-width: 2; transition: cx .4s, cy .4s; }
.gv-chart .opt { stroke: var(--ok); stroke-dasharray: 3 3; }
.gv-chart text { fill: var(--faint); font-size: 10px; font-family: var(--mono); }

/* ---------- Shor ---------- */
.shor-ctl { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; }
.shor-ctl label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.seq { display: flex; flex-wrap: wrap; gap: 6px; }
.seq .s {
  display: grid;
  justify-items: center;
  min-width: 42px;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, hsl(var(--h) 80% 60%) 16%, var(--surface));
  border-color: color-mix(in srgb, hsl(var(--h) 80% 60%) 50%, transparent);
}
.seq .s small { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.seq .s b { font-family: var(--mono); font-size: 15px; }
.seq .s.one { box-shadow: 0 0 0 2px var(--c4); }
.spec-wrap { position: relative; height: 220px; }
.spec-wrap canvas { width: 100%; height: 100%; }
.shor-log { display: grid; gap: 8px; max-height: 340px; overflow: auto; }
.log-item {
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  font-size: 14px;
  line-height: 1.7;
}
.log-item.good { border-color: color-mix(in srgb, var(--ok) 50%, transparent); }
.log-item.bad { border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.log-item .h { font-weight: 700; margin-bottom: 2px; }
.log-item .m { font-family: var(--mono); font-size: 13px; color: var(--muted); }

.steps { counter-reset: st; display: grid; gap: 14px; margin: 26px 0; }
.step {
  position: relative;
  padding: 18px 20px 18px 66px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.step::before {
  counter-increment: st;
  content: counter(st);
  position: absolute;
  left: 18px;
  top: 18px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-family: var(--mono);
  font-weight: 700;
  color: var(--c1);
  background: var(--c1-soft);
}
.step.q::before { color: var(--c2); background: var(--c2-soft); }
.step h4 { font-size: 1.04rem; margin-bottom: 4px; }
.step p { margin: 0; color: var(--muted); font-size: 15px; }
.step .tag { position: absolute; right: 16px; top: 16px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 26px 0; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 15px; min-width: 640px; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 13px; letter-spacing: .06em; color: var(--faint); font-weight: 600; background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }
td .math { font-size: 1.05em; }
td.speed { font-weight: 600; }
td.speed.ex { color: var(--c3); }
td.speed.sq { color: var(--c1); }
td.speed.cd { color: var(--c4); }

/* ---------- 误区卡片 ---------- */
.myths { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin: 28px 0; }
.myth {
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.myth .no, .myth .yes { display: flex; gap: 12px; align-items: flex-start; }
.myth .no { color: var(--muted); padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px dashed var(--line-2); }
.myth .no s { text-decoration-color: color-mix(in srgb, var(--bad) 70%, transparent); text-decoration-thickness: 1.5px; }
.myth .yes { font-size: 15px; }
.myth .mk {
  flex: none;
  width: 24px;
  height: 24px;
  margin-top: 2px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
}
.myth .no .mk { background: color-mix(in srgb, var(--bad) 16%, transparent); color: var(--bad); }
.myth .yes .mk { background: color-mix(in srgb, var(--ok) 16%, transparent); color: var(--ok); }

/* ---------- 图示 ---------- */
.figure {
  margin: 28px 0;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
}
.figure svg { width: 100%; height: auto; }
.figure figcaption { margin-top: 12px; font-size: 13.5px; color: var(--muted); text-align: center; }
.svg-text { fill: var(--text); font-family: var(--sans); }
.svg-muted { fill: var(--muted); font-family: var(--sans); }
.svg-faint { fill: var(--faint); font-family: var(--sans); }
.svg-line { stroke: var(--line-2); fill: none; }
.svg-c1 { stroke: var(--c1); }
.svg-c2 { stroke: var(--c2); }
.svg-c3 { stroke: var(--c3); }
.svg-c4 { stroke: var(--c4); }
.svg-f1 { fill: var(--c1-soft); }
.svg-f2 { fill: var(--c2-soft); }
.svg-f3 { fill: var(--c3-soft); }
.svg-f4 { fill: var(--c4-soft); }
.svg-box { fill: var(--surface-2); stroke: var(--line-2); }

/* ---------- 硬件 ---------- */
.hw { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin: 26px 0; }
.hw .card { padding: 20px; }
.hw .card h3 { margin-top: 0; }
.hw .who { font-size: 13px; color: var(--faint); margin-top: 8px; }
.meter { display: flex; gap: 3px; margin-top: 10px; }
.meter i { flex: 1; height: 5px; border-radius: 3px; background: var(--surface-3); }
.meter i.on { background: var(--grad); }

/* ---------- 时间线 ---------- */
.timeline { position: relative; margin: 30px 0; padding-left: 0; list-style: none; }
.timeline::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  margin-left: -1px;
  background: linear-gradient(var(--c1), var(--c2), var(--c3));
  opacity: .5;
}
.tl {
  position: relative;
  width: 50%;
  padding: 0 40px 34px 0;
}
.tl:nth-child(even) { margin-left: 50%; padding: 0 0 34px 40px; }
.tl::before {
  content: "";
  position: absolute;
  top: 8px;
  right: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 3px solid var(--c1);
}
.tl:nth-child(even)::before { right: auto; left: -7px; border-color: var(--c2); }
.tl.big::before { box-shadow: 0 0 0 5px var(--c1-soft); border-color: var(--c3); }
.tl-in {
  padding: 16px 18px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.tl .y { font-family: var(--mono); font-size: 13px; color: var(--c1); letter-spacing: .08em; }
.tl:nth-child(even) .y { color: var(--c2); }
.tl h4 { font-size: 1.05rem; margin: 2px 0 6px; }
.tl p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.7; }

/* ---------- 术语表 ---------- */
.gloss { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; margin: 26px 0; }
.gloss div {
  padding: 16px 18px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.gloss dt { font-weight: 700; }
.gloss dt span { margin-left: 8px; font-size: 12.5px; color: var(--faint); font-weight: 500; font-family: var(--mono); }
.gloss dd { margin: 6px 0 0; color: var(--muted); font-size: 14.5px; line-height: 1.7; }

/* ---------- 页脚 ---------- */
.footer {
  margin-top: 100px;
  padding: 60px 0 50px;
  border-top: 1px solid var(--line);
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--surface) 60%, transparent));
}
.foot-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 30px; }
.footer h4 { font-size: 14px; letter-spacing: .1em; color: var(--faint); margin-bottom: 12px; }
.footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; font-size: 14.5px; }
.footer p { color: var(--muted); font-size: 14.5px; }
.footer .copy { margin-top: 40px; font-size: 13px; color: var(--faint); }

/* ---------- 滚动入场 ---------- */
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease, transform .7s cubic-bezier(.2, .8, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-art { max-width: 320px; order: -1; margin-bottom: -10px; }
  .float-ket { font-size: 14px; }
  .lab-grid, .two-col { grid-template-columns: 1fr; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 16px; }
  .now { display: none; }
  .brand span { font-size: 15px; }
  .chapter { padding-top: 84px; }
  .lab-body { padding: 16px; }
  .lab-head { padding: 14px 16px; }
  .lab-head .hint { margin-left: 0; width: 100%; }
  .exp-out { grid-template-columns: 1fr; }
  .phasors { grid-template-columns: 1fr 1fr; gap: 8px; }
  .phasor { padding: 8px; }
  .phasor .big { font-size: 18px; }
  .timeline::before { left: 8px; }
  .tl, .tl:nth-child(even) { width: 100%; margin-left: 0; padding: 0 0 26px 34px; }
  .tl::before, .tl:nth-child(even)::before { left: 1px; right: auto; }
  .foot-grid { grid-template-columns: 1fr; }
  .st-row { grid-template-columns: 58px 1fr 56px; }
  .st-row .amp { display: none; }
  .hbar { grid-template-columns: 40px 1fr 56px; }
  .query-grid { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .step { padding: 16px 16px 16px 60px; }
  .step .tag { position: static; margin-top: 8px; }
  .ent-pair { gap: 6px; }
  .link { width: 36px; }
  .qcard .q { width: 62px; height: 62px; font-size: 28px; }
  .cc-opts { margin-left: 0; }
}

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

@media print {
  body::before, .topbar, .progress, .toc, .lab, .scroll-hint { display: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
