:root {
  --paper: #f2efe8;
  --paper-2: #eae6dc;
  --card: #fbf9f4;
  --ink: #17181b;
  --ink-2: #55585f;
  --ink-3: #8b8d93;
  --line: rgba(23, 24, 27, 0.13);
  --line-soft: rgba(23, 24, 27, 0.07);
  --accent: #b8442a;
  --accent-ink: #8f3320;
  --accent-soft: rgba(184, 68, 42, 0.10);
  --gold: #b3862c;
  --serif: "Songti SC", "STSong", "Source Han Serif SC", "Noto Serif SC", "Times New Roman", Georgia, serif;
  --sans: system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --radius: 4px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101114;
    --paper-2: #171a1f;
    --card: #171a1f;
    --ink: #eeeff1;
    --ink-2: #a8adb5;
    --ink-3: #7c818a;
    --line: rgba(238, 239, 241, 0.15);
    --line-soft: rgba(238, 239, 241, 0.08);
    --accent: #e2704f;
    --accent-ink: #ee8a6c;
    --accent-soft: rgba(226, 112, 79, 0.14);
    --gold: #d9a94b;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; letter-spacing: 0; }
p { margin: 0; }
button { font: inherit; color: inherit; }

.wrap { width: 100%; max-width: 1280px; margin: 0 auto; padding: 0 clamp(16px, 4vw, 44px); }

/* ---------------- hero ---------------- */
.hero { padding: clamp(40px, 7vw, 92px) 0 clamp(28px, 4vw, 46px); }
.kicker {
  display: flex; align-items: center; gap: 14px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.22em;
  color: var(--ink-3); text-transform: uppercase;
}
.kicker-rule { flex: 1; height: 1px; background: var(--line); max-width: 180px; }
.hero h1 {
  font-size: clamp(38px, 7.4vw, 84px);
  line-height: 1.02;
  margin: clamp(20px, 3vw, 34px) 0 0;
  letter-spacing: -0.01em;
}
.hero h1 em { font-style: normal; color: var(--accent); }
.lede {
  max-width: 46ch; margin-top: clamp(18px, 2.4vw, 28px);
  color: var(--ink-2); font-size: clamp(15px, 1.55vw, 17px); line-height: 1.85;
}
.hero-meta {
  display: flex; gap: clamp(20px, 5vw, 56px);
  margin-top: clamp(26px, 4vw, 40px);
  padding-top: 18px; border-top: 1px solid var(--line);
}
.hero-meta div { display: flex; align-items: baseline; gap: 8px; }
.hero-meta b { font-family: var(--serif); font-size: 26px; font-weight: 500; }
.hero-meta span { font-size: 12px; color: var(--ink-3); letter-spacing: 0.06em; }

/* ---------------- workbench ---------------- */
.workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
  gap: clamp(20px, 3vw, 40px);
  align-items: start;
  padding-bottom: clamp(40px, 6vw, 90px);
}
.stage-col { position: sticky; top: 16px; min-width: 0; }

.stage {
  position: relative;
  height: clamp(340px, 62vh, 620px);
  background:
    radial-gradient(115% 85% at 50% 4%, color-mix(in srgb, var(--card) 96%, var(--paper)) 0%, var(--paper) 62%, var(--paper-2) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(var(--line-soft) 1px, transparent 1px);
  background-size: 100% 92px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent 55%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,0.55), transparent 55%);
  opacity: 0.5;
}
#gl { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#gl:active { cursor: grabbing; }

.anno-layer { position: absolute; inset: 0; pointer-events: none; z-index: 2; }
.anno-label {
  position: absolute; top: 0; left: 0;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.06em;
  color: var(--ink); background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--line); border-radius: 2px;
  padding: 2px 6px; white-space: nowrap;
  transition: opacity 0.2s;
}
.anno-label--trail { border-color: color-mix(in srgb, var(--gold) 55%, transparent); }

.stage-top {
  position: absolute; top: 0; left: 0; right: 0; z-index: 3;
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; padding: 14px 14px 0; pointer-events: none;
}
.stage-name { display: flex; flex-direction: column; line-height: 1.25; }
.stage-name span { font-family: var(--mono); font-size: 10px; letter-spacing: 0.2em; color: var(--ink-3); }
.stage-name b { font-family: var(--serif); font-size: 21px; font-weight: 500; }
.view-btns { display: flex; gap: 4px; pointer-events: auto; }
.vbtn {
  border: 1px solid var(--line); background: color-mix(in srgb, var(--card) 70%, transparent);
  font-family: var(--mono); font-size: 11px; color: var(--ink-2);
  width: 30px; height: 28px; border-radius: 2px; cursor: pointer;
  backdrop-filter: blur(6px);
}
.vbtn.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.vbtn:hover { border-color: var(--ink-2); }

.stage-hint {
  position: absolute; left: 14px; bottom: 58px; z-index: 3;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.04em;
  color: var(--ink-3); pointer-events: none;
}

.stage-readout {
  position: absolute; right: 12px; bottom: 12px; left: 12px; z-index: 3;
  display: flex; gap: 10px; justify-content: flex-end;
  pointer-events: none;
}
.stage-readout div {
  display: flex; flex-direction: column; align-items: flex-end;
  padding: 4px 9px; min-width: 74px;
  background: color-mix(in srgb, var(--card) 74%, transparent);
  border: 1px solid var(--line-soft); border-radius: 2px;
  backdrop-filter: blur(8px);
}
.stage-readout span { font-size: 9.5px; color: var(--ink-3); letter-spacing: 0.08em; }
.stage-readout b { font-family: var(--mono); font-size: 14px; font-weight: 500; font-variant-numeric: tabular-nums; }
.stage-readout small { font-size: 9px; color: var(--ink-3); margin-left: 2px; }

.stage-fallback {
  position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px; padding: 32px;
  background: var(--paper-2); text-align: center;
}
.stage-fallback[hidden] { display: none; }
.stage-fallback b { font-family: var(--serif); font-size: 18px; }
.stage-fallback span { font-size: 13px; color: var(--ink-2); max-width: 36ch; }

.type-row {
  display: flex; gap: 6px; margin-top: 10px; overflow-x: auto;
  padding-bottom: 4px; scrollbar-width: thin;
}
.type-chip {
  flex: 0 0 auto; cursor: pointer;
  border: 1px solid var(--line); background: transparent;
  border-radius: 2px; padding: 7px 11px;
  font-size: 12.5px; color: var(--ink-2); white-space: nowrap;
  transition: background 0.18s, color 0.18s, border-color 0.18s;
}
.type-chip:hover { border-color: var(--ink-2); color: var(--ink); }
.type-chip.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }

.stage-tools { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.tbtn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: transparent; border-radius: 2px;
  padding: 6px 10px; font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.tbtn:hover { border-color: var(--ink-2); color: var(--ink); }
.tbtn .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ink-3); }
.tbtn[aria-pressed="true"] .dot { background: var(--gold); }
.stage-note { font-family: var(--mono); font-size: 10px; color: var(--ink-3); margin-left: auto; }

/* ---------------- chapters ---------------- */
.flow-col { min-width: 0; }
.chapter { padding: clamp(22px, 3vw, 34px) 0; border-top: 1px solid var(--line); }
.chapter:first-child { border-top: 0; padding-top: 0; }
.ch-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.ch-num {
  font-family: var(--mono); font-size: 11px; color: var(--accent);
  padding-top: 6px; letter-spacing: 0.1em;
}
.ch-head h2 { font-size: clamp(22px, 2.6vw, 30px); line-height: 1.2; }
.ch-sub { font-size: 13.5px; color: var(--ink-2); margin-top: 8px; line-height: 1.7; max-width: 44ch; }

/* parts */
.part-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.part-btn {
  border: 1px solid var(--line); background: transparent; border-radius: 2px;
  padding: 6px 10px; font-size: 12.5px; color: var(--ink-2); cursor: pointer;
  transition: all 0.16s;
}
.part-btn:hover { border-color: var(--ink-2); color: var(--ink); }
.part-btn.is-on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-ink); }
.part-card {
  margin-top: 14px; padding: 16px 18px; min-height: 132px;
  border-left: 2px solid var(--accent); background: color-mix(in srgb, var(--card) 70%, transparent);
}
.part-card .pc-top { display: flex; align-items: baseline; gap: 10px; }
.part-card b { font-family: var(--serif); font-size: 19px; font-weight: 500; }
.part-card .pc-en { font-family: var(--mono); font-size: 10px; letter-spacing: 0.16em; color: var(--ink-3); }
.part-card p { font-size: 13.5px; color: var(--ink-2); line-height: 1.8; margin-top: 8px; }

.part-card .pc-what { color: var(--ink-2); }
.part-card .pc-why {
  margin-top: 12px; padding: 12px 14px 12px 13px;
  background: var(--accent-soft); border-radius: 2px;
}
.part-card .pc-why-label {
  display: inline-block; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.18em;
  color: var(--accent-ink); margin-bottom: 4px;
}
.part-card .pc-why p { margin-top: 0; color: var(--ink); font-size: 13.5px; line-height: 1.85; }
.part-card .pc-trade {
  margin-top: 10px; padding-left: 11px; border-left: 1px solid var(--line);
  font-size: 13px; color: var(--ink-2); line-height: 1.8;
}
.part-card .pc-trade b {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.16em;
  color: var(--ink-3); margin-right: 8px; font-weight: 400;
}

/* 为什么：三条约束 */
.constraint { padding: 16px 0; border-top: 1px solid var(--line-soft); }
.constraint:first-of-type { border-top: 0; padding-top: 0; }
.constraint h3 { font-size: 17px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.constraint h3 i {
  font-family: var(--mono); font-style: normal; font-size: 9.5px; letter-spacing: 0.16em;
  color: var(--accent); border: 1px solid currentColor; border-radius: 2px; padding: 1px 5px;
}
.constraint p { margin-top: 8px; font-size: 13.5px; line-height: 1.85; color: var(--ink-2); }
.constraint p b { color: var(--ink); font-weight: 600; }
.caster { margin: 14px 0 0; padding: 10px 12px 6px; background: color-mix(in srgb, var(--card) 72%, transparent); border: 1px solid var(--line-soft); border-radius: 2px; }
.caster svg { display: block; width: 100%; max-width: 340px; height: auto; margin: 0 auto; }
.caster .cg { stroke: var(--ink-3); stroke-width: 1.2; }
.caster .cw { fill: none; stroke: var(--ink-2); stroke-width: 2; }
.caster .cv { stroke: var(--ink-3); stroke-width: 1; }
.caster .ca { stroke: var(--gold); stroke-width: 2; }
.caster .cd { fill: var(--ink); }
.caster .ct { stroke: var(--accent); stroke-width: 2; }
.caster .cl { fill: var(--ink-2); font-family: var(--mono); font-size: 9.5px; }
.caster figcaption { margin-top: 6px; font-size: 12px; line-height: 1.7; color: var(--ink-3); }

/* 因果链 */
.chains { display: grid; gap: 8px; margin-top: 16px; }
.chain {
  display: grid; gap: 4px; padding: 12px 14px;
  border: 1px solid var(--line); border-left: 2px solid var(--gold); border-radius: 2px;
}
.chain span { font-size: 12.8px; line-height: 1.75; }
.chain-need { color: var(--ink); font-weight: 600; }
.chain-do { color: var(--ink-2); }
.chain-cost { color: var(--ink-3); }
.chain-cost::before { content: ""; }

/* 所选车型的设计理由 */
.type-why {
  margin-top: 16px; padding: 16px 18px;
  background: color-mix(in srgb, var(--card) 78%, transparent);
  border: 1px solid var(--line); border-radius: 2px;
}
.type-why:empty { display: none; }
.type-why .tw-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.type-why .tw-head b { font-family: var(--serif); font-size: 17px; font-weight: 500; }
.type-why .tw-head span { font-size: 12px; color: var(--ink-3); }
.type-why .tw-why { margin-top: 8px; font-size: 13.5px; line-height: 1.85; color: var(--ink-2); }
.type-why .tw-cur { margin-top: 10px; font-family: var(--mono); font-size: 11px; color: var(--ink-3); line-height: 1.7; }
.type-why .tw-cur b { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }

/* sliders */
.sliders { display: grid; gap: 2px; }
.slider { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.slider:first-child { padding-top: 0; }
.sl-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sl-head label { font-size: 13.5px; }
.sl-head .val { font-family: var(--mono); font-size: 16px; font-variant-numeric: tabular-nums; }
.sl-head .val small { font-size: 10px; color: var(--ink-3); margin-left: 1px; }
.sl-ends {
  display: flex; justify-content: space-between;
  font-family: var(--mono); font-size: 9.5px; color: var(--ink-3); margin-top: 2px;
}
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 26px; background: transparent; cursor: pointer; margin: 0;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px; background: var(--line); border-radius: 2px;
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line); border-radius: 2px; }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; margin-top: -7px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--card); border: 2px solid var(--accent);
}
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

.effect { margin-top: 18px; padding: 16px; background: color-mix(in srgb, var(--card) 78%, transparent); border: 1px solid var(--line-soft); }
.effect-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.12em; color: var(--ink-3); }
.linkbtn { border: 0; background: none; padding: 0; font-size: 11.5px; color: var(--accent); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; font-family: var(--sans); letter-spacing: 0; }
.spark-row { display: grid; gap: 8px; margin: 14px 0 12px; }
.spark { display: grid; grid-template-columns: 74px 1fr 58px; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-2); }
.spark .bar { height: 5px; background: var(--line-soft); border-radius: 3px; overflow: hidden; position: relative; }
.spark .bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 3px; transition: width 0.4s ease; }
.spark .bar b { position: absolute; top: -1px; bottom: -1px; width: 1px; background: var(--ink-3); }
.spark .num { font-family: var(--mono); font-size: 11px; text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.effect-text { font-size: 13px; line-height: 1.8; color: var(--ink-2); }
.effect-text strong { color: var(--ink); font-weight: 600; }

.formula { margin-top: 18px; padding-left: 14px; border-left: 2px solid var(--line); }
.formula-label { font-family: var(--mono); font-size: 10px; letter-spacing: 0.18em; color: var(--ink-3); }
.formula code {
  display: block; font-family: var(--mono); font-size: 13px;
  margin: 6px 0 8px; color: var(--ink); word-break: break-word;
}
.formula p { font-size: 12.5px; color: var(--ink-3); line-height: 1.75; }

/* spectrum */
.spectrum { display: grid; gap: 1px; background: var(--line-soft); border: 1px solid var(--line-soft); }
.spec-item {
  display: grid; grid-template-columns: 92px 1fr; gap: 14px;
  background: var(--paper); padding: 14px; cursor: pointer; text-align: left;
  border: 0; width: 100%; transition: background 0.16s;
}
.spec-item:hover { background: color-mix(in srgb, var(--card) 80%, transparent); }
.spec-item.is-on { background: color-mix(in srgb, var(--accent) 8%, var(--paper)); }
.spec-name b { font-family: var(--serif); font-size: 16px; font-weight: 500; display: block; }
.spec-name span { font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; color: var(--ink-3); }
.spec-body { min-width: 0; }
.spec-nums { display: flex; gap: 14px; flex-wrap: wrap; font-family: var(--mono); font-size: 10.5px; color: var(--ink-3); }
.spec-nums b { color: var(--ink); font-weight: 500; }
.spec-desc { font-size: 12.5px; color: var(--ink-2); line-height: 1.7; margin-top: 6px; }

/* materials */
.mat-list { display: grid; gap: 10px; }
.mat-item { border: 1px solid var(--line-soft); padding: 14px 16px; }
.mat-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.mat-top b { font-family: var(--serif); font-size: 17px; font-weight: 500; }
.mat-top span { font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.14em; color: var(--ink-3); }
.mat-item p { font-size: 12.5px; color: var(--ink-2); line-height: 1.75; margin-top: 6px; }
.mat-bars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 12px; }
.mat-bar { font-size: 10px; color: var(--ink-3); }
.mat-bar .label { display: flex; justify-content: space-between; margin-bottom: 4px; }
.mat-bar .dots { display: flex; gap: 3px; }
.mat-bar .dots i { flex: 1; height: 3px; background: var(--line); border-radius: 2px; }
.mat-bar .dots i.on { background: var(--ink-2); }
.foot-note { font-size: 11px; color: var(--ink-3); margin-top: 12px; line-height: 1.7; }

/* quiz */
.quiz { display: grid; gap: 14px; }
.q { border: 1px solid var(--line-soft); padding: 16px; }
.q-title { font-size: 14px; line-height: 1.7; }
.q-title i { font-family: var(--mono); font-size: 10px; font-style: normal; color: var(--accent); margin-right: 6px; }
.q-opts { display: grid; gap: 6px; margin-top: 12px; }
.q-opt {
  text-align: left; border: 1px solid var(--line); background: transparent;
  padding: 9px 12px; font-size: 13px; color: var(--ink-2); cursor: pointer; border-radius: 2px;
  transition: all 0.16s;
}
.q-opt:hover:not(:disabled) { border-color: var(--ink-2); color: var(--ink); }
.q-opt:disabled { cursor: default; }
.q-opt.is-right { border-color: #3f7a54; background: rgba(63, 122, 84, 0.12); color: var(--ink); }
.q-opt.is-wrong { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); }
.q-exp { margin-top: 10px; font-size: 12.5px; color: var(--ink-2); line-height: 1.75; padding-left: 10px; border-left: 2px solid var(--line); }
.quiz-score { margin-top: 14px; font-family: var(--mono); font-size: 12px; color: var(--ink-3); }

.end {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 16px; margin-top: 10px;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; color: var(--ink-3);
}

/* ---------------- responsive ---------------- */
@media (max-width: 900px) {
  .workbench { grid-template-columns: 1fr; gap: 8px; }
  .stage-col { position: sticky; top: 0; z-index: 20; background: var(--paper); padding-top: 6px; padding-bottom: 6px; }
  .stage { height: clamp(240px, 42vh, 340px); }
  .stage-hint { display: none; }
  .stage-readout { left: 8px; right: 8px; gap: 6px; bottom: 8px; }
  .stage-readout div { padding: 3px 7px; min-width: 0; flex: 1; }
  .stage-readout b { font-size: 12.5px; }
  .stage-name b { font-size: 17px; }
  .type-row { margin-top: 8px; }
  .stage-tools { margin-top: 8px; }
  .stage-note { display: none; }
  .flow-col { padding-top: 12px; }
  .chapter:first-child { padding-top: 18px; }
  .spec-item { grid-template-columns: 1fr; gap: 6px; }
  .mat-bars { grid-template-columns: repeat(2, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.01ms !important; }
}
