:root {
  --bg: #f7f6f2;
  --paper: #ffffff;
  --ink: #1b1d22;
  --ink-2: #4a4f5a;
  --ink-3: #7b8190;
  --line: #e4e2db;
  --line-2: #efede7;
  --accent: #1f5eff;
  --accent-soft: #e8efff;
  --accent-ink: #1440b8;
  --warn: #b45309;
  --warn-soft: #fff4e5;
  --danger: #c0262d;
  --danger-soft: #fdecec;
  --ok: #0f7a4f;
  --ok-soft: #e6f6ee;
  --code: #f1efe9;
  --shadow: 0 1px 2px rgba(20, 22, 30, .04), 0 8px 24px rgba(20, 22, 30, .05);
  --radius: 14px;
  --sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --toc-w: 248px;
  --content-w: 760px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317;
    --paper: #181b21;
    --ink: #eceef2;
    --ink-2: #b8bdc8;
    --ink-3: #8a90a0;
    --line: #2a2f38;
    --line-2: #22262e;
    --accent: #6f9bff;
    --accent-soft: #1b2540;
    --accent-ink: #a9c1ff;
    --warn: #f5a524;
    --warn-soft: #2c2214;
    --danger: #ff6b70;
    --danger-soft: #2e1a1c;
    --ok: #3ccf8e;
    --ok-soft: #142a20;
    --code: #222630;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #111317;
  --paper: #181b21;
  --ink: #eceef2;
  --ink-2: #b8bdc8;
  --ink-3: #8a90a0;
  --line: #2a2f38;
  --line-2: #22262e;
  --accent: #6f9bff;
  --accent-soft: #1b2540;
  --accent-ink: #a9c1ff;
  --warn: #f5a524;
  --warn-soft: #2c2214;
  --danger: #ff6b70;
  --danger-soft: #2e1a1c;
  --ok: #3ccf8e;
  --ok-soft: #142a20;
  --code: #222630;
  --shadow: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 76px; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16.5px;
  line-height: 1.85;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: var(--accent-ink); text-underline-offset: .18em; }
img, svg { max-width: 100%; }
p { margin: 0 0 1em; }
strong { font-weight: 650; }
.en { color: var(--ink-3); font-size: .9em; font-weight: 400; }
abbr { text-decoration: none; border-bottom: 1px dotted var(--ink-3); cursor: help; }
kbd, code {
  font-family: var(--mono);
  font-size: .86em;
  background: var(--code);
  padding: .08em .38em;
  border-radius: 5px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 12px;
  height: 56px; padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; color: var(--ink); text-decoration: none; min-width: 0; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand svg { flex: none; }
.topbar .spacer { flex: 1; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; min-width: 34px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--paper); color: var(--ink-2);
  font: inherit; font-size: 13px; cursor: pointer;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 16px; height: 16px; }
#toc-toggle { display: none; }
.progress { position: absolute; left: 0; bottom: -1px; height: 2px; width: 0; background: var(--accent); transition: width .1s linear; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--toc-w) minmax(0, var(--content-w));
  gap: 56px;
  justify-content: center;
  padding: 0 24px 96px;
}
.toc {
  position: sticky; top: 76px; align-self: start;
  max-height: calc(100vh - 96px); overflow: auto;
  padding: 28px 4px 24px 0;
  font-size: 14px; line-height: 1.5;
}
.toc-title { font-size: 12px; letter-spacing: .08em; color: var(--ink-3); margin: 0 0 10px 12px; text-transform: uppercase; }
.toc ol { list-style: none; margin: 0; padding: 0; }
.toc li a {
  display: block; padding: 6px 12px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none;
  border-left: 2px solid transparent;
}
.toc li a:hover { background: var(--line-2); color: var(--ink); }
.toc li a.active { color: var(--accent-ink); background: var(--accent-soft); font-weight: 600; }
.toc li.sub a { padding-left: 26px; font-size: 13px; color: var(--ink-3); }
.toc li.sub a.active { color: var(--accent-ink); }
.toc .num { display: inline-block; min-width: 1.6em; color: var(--ink-3); font-variant-numeric: tabular-nums; }

main { min-width: 0; }

/* ---------- hero ---------- */
.hero { padding: 56px 0 28px; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--accent-ink); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; margin-bottom: 18px; }
.hero h1 { font-size: clamp(30px, 5vw, 44px); line-height: 1.25; margin: 0 0 16px; letter-spacing: -.01em; }
.hero .lead { font-size: 18px; color: var(--ink-2); margin: 0 0 28px; }
.meta-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 0 0 8px; }
.meta-grid div { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.meta-grid dt { font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.meta-grid dd { margin: 0; font-size: 14.5px; line-height: 1.55; font-weight: 550; }

/* ---------- sections ---------- */
section.chapter { padding-top: 40px; margin-top: 40px; border-top: 1px solid var(--line); }
.chapter-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; }
.chapter-no { font-family: var(--mono); font-size: 13px; color: var(--accent-ink); background: var(--accent-soft); border-radius: 6px; padding: 2px 8px; flex: none; transform: translateY(-4px); }
h2 { font-size: clamp(24px, 3.4vw, 30px); line-height: 1.35; margin: 0; letter-spacing: -.005em; }
h3 { font-size: 20px; line-height: 1.45; margin: 40px 0 12px; }
h4 { font-size: 16.5px; margin: 24px 0 8px; }
.chapter-intro { font-size: 17px; color: var(--ink-2); margin: 10px 0 8px; }
.goals { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 4px; padding: 0; list-style: none; }
.goals li { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); color: var(--ink-2); }
.goals li::before { content: "✓ "; color: var(--ok); font-weight: 700; }

ul.list, ol.list { padding-left: 1.3em; margin: 0 0 1.2em; }
ul.list li, ol.list li { margin: .3em 0; }
ol.list ol { list-style: lower-alpha; padding-left: 1.3em; margin: .2em 0 .5em; }

/* ---------- callouts ---------- */
.callout {
  display: grid; grid-template-columns: 22px 1fr; gap: 12px;
  border-radius: var(--radius); padding: 16px 18px; margin: 22px 0;
  background: var(--accent-soft); color: var(--ink);
  border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
}
.callout svg { width: 20px; height: 20px; margin-top: 3px; color: var(--accent-ink); }
.callout .t { font-weight: 650; margin-bottom: 2px; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout ul { padding-left: 1.1em; margin: 4px 0 0; }
.callout.warn { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 30%, transparent); }
.callout.warn svg, .callout.warn .t { color: var(--warn); }
.callout.danger { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.callout.danger svg, .callout.danger .t { color: var(--danger); }
.callout.ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.callout.ok svg, .callout.ok .t { color: var(--ok); }

/* ---------- cards & grids ---------- */
.card { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.card h4 { margin: 0 0 6px; font-size: 16px; }
.card p { margin: 0; font-size: 14.5px; color: var(--ink-2); line-height: 1.7; }
.card .tag { display: inline-block; font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }

/* robot type gallery */
.type-card { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.type-card figure { margin: 0; background: linear-gradient(180deg, var(--line-2), transparent); border-bottom: 1px solid var(--line); aspect-ratio: 16 / 10; display: grid; place-items: center; }
.type-card figure svg { width: 82%; height: 82%; }
.type-card .body { padding: 14px 16px 16px; }
.type-card h4 { margin: 0 0 2px; }
.type-card .en { display: block; margin-bottom: 8px; }
.type-card dl { margin: 0; font-size: 13.5px; line-height: 1.6; }
.type-card dt { color: var(--ink-3); float: left; width: 3.4em; clear: left; }
.type-card dd { margin: 0 0 4px 3.6em; color: var(--ink-2); }

/* illustration palette */
.ill { color: var(--ink); }
.ill .s { stroke: currentColor; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ill .f { fill: var(--paper); stroke: currentColor; stroke-width: 2.4; stroke-linejoin: round; }
.ill .a { fill: var(--accent); }
.ill .as { stroke: var(--accent); fill: none; stroke-width: 2.4; stroke-linecap: round; }
.ill .af { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2.2; }
.ill .m { fill: var(--ink-3); }
.ill .g { stroke: var(--ink-3); fill: none; stroke-width: 1.4; stroke-dasharray: 4 4; }
.ill .d { fill: var(--danger); }
.ill text { font-family: var(--sans); fill: var(--ink-2); font-size: 13px; }
.ill text.b { fill: var(--ink); font-weight: 650; }
.ill text.acc { fill: var(--accent-ink); font-weight: 650; }

figure.fig { margin: 26px 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
figure.fig > svg { display: block; width: 100%; height: auto; }
figure.fig figcaption { font-size: 13.5px; color: var(--ink-3); margin-top: 14px; line-height: 1.6; }
figure.fig figcaption b { color: var(--ink-2); }

/* flow (HTML-based diagrams) */
.flow { display: flex; align-items: stretch; gap: 0; margin: 4px 0; }
.flow .node { flex: 1; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.flow .node.hl { border-color: var(--accent); background: var(--accent-soft); }
.flow .node b { display: block; font-size: 15px; }
.flow .node small { display: block; color: var(--ink-3); font-size: 12.5px; line-height: 1.5; margin-top: 2px; }
.flow .arrow { flex: none; width: 34px; display: grid; place-items: center; color: var(--ink-3); font-size: 12px; text-align: center; line-height: 1.2; }
.flow .arrow::before { content: "→"; font-size: 18px; display: block; }
.flow-wrap { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 22px 0; box-shadow: var(--shadow); }
.flow-wrap .note { font-size: 13px; color: var(--ink-3); margin: 12px 2px 0; }
.flow-wrap .flow .node { background: var(--bg); }
.flow-wrap .flow .node.hl { background: var(--accent-soft); }

/* steps */
.steps { list-style: none; counter-reset: s; padding: 0; margin: 18px 0; }
.steps > li { counter-increment: s; position: relative; padding: 0 0 18px 46px; }
.steps > li::before {
  content: counter(s); position: absolute; left: 0; top: 2px;
  width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line); color: var(--accent-ink);
  font-weight: 700; font-size: 14px; font-family: var(--mono);
}
.steps > li::after { content: ""; position: absolute; left: 15px; top: 36px; bottom: 4px; width: 1px; background: var(--line); }
.steps > li:last-child::after { display: none; }
.steps > li b { display: block; }
.steps > li span { color: var(--ink-2); font-size: 15px; }

/* ---------- tables ---------- */
.table-wrap { margin: 20px 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; line-height: 1.6; }
th, td { text-align: left; vertical-align: top; padding: 11px 14px; border-bottom: 1px solid var(--line-2); }
thead th { background: var(--line-2); font-size: 13px; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { font-weight: 600; }
td .en { display: block; font-size: 12.5px; }
.check { color: var(--ok); font-weight: 700; }
.maybe { color: var(--warn); font-weight: 700; }
.cross { color: var(--ink-3); }

/* glossary */
.gloss-tools { display: flex; gap: 10px; align-items: center; margin: 14px 0 0; }
.gloss-tools input {
  flex: 1; height: 42px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink);
  font: inherit; font-size: 15px;
}
.gloss-tools input:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.gloss-count { font-size: 13px; color: var(--ink-3); white-space: nowrap; }
.gloss-group td { background: var(--bg); color: var(--ink-3); font-size: 12px; letter-spacing: .06em; font-weight: 600; padding: 7px 14px; }

/* dialogue */
.dialog { margin: 18px 0; display: grid; gap: 10px; }
.msg { display: grid; grid-template-columns: 54px 1fr; gap: 10px; align-items: start; }
.msg .who { font-size: 12px; color: var(--ink-3); padding-top: 10px; text-align: right; }
.msg .bubble { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; font-size: 15px; line-height: 1.65; }
.msg.sales .bubble { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 20%, transparent); }
.msg .zh { display: block; color: var(--ink-3); font-size: 13px; margin-top: 4px; }
.analysis { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; color: var(--ink-2); font-size: 15px; margin: 14px 0 0; }

/* case */
.case { display: grid; gap: 0; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin: 18px 0; background: var(--paper); box-shadow: var(--shadow); }
.case > div { padding: 14px 18px; border-bottom: 1px solid var(--line-2); display: grid; grid-template-columns: 64px 1fr; gap: 10px; font-size: 15px; line-height: 1.7; }
.case > div:last-child { border-bottom: 0; }
.case .k { font-size: 12.5px; font-weight: 700; color: var(--ink-3); padding-top: 2px; }
.case .fix { background: var(--ok-soft); }
.case .fix .k { color: var(--ok); }

/* objection */
details.obj { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; box-shadow: var(--shadow); }
details.obj summary { cursor: pointer; padding: 14px 18px; font-weight: 600; list-style: none; display: flex; gap: 10px; align-items: baseline; }
details.obj summary::-webkit-details-marker { display: none; }
details.obj summary::before { content: "+"; font-family: var(--mono); color: var(--accent-ink); width: 1em; flex: none; }
details.obj[open] summary::before { content: "−"; }
details.obj summary .en { margin-left: auto; font-size: 13px; }
details.obj .inner { padding: 0 18px 16px 46px; font-size: 15px; color: var(--ink-2); }
details.obj .say { background: var(--bg); border-radius: 8px; padding: 10px 12px; margin-top: 8px; font-size: 14.5px; color: var(--ink); }
details.obj .say::before { content: "参考话术 · "; color: var(--ink-3); font-size: 12px; }

/* exercises & key points */
.box-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 30px 0 8px; }
.keypoints, .exercise { border-radius: var(--radius); padding: 18px 20px; font-size: 15px; }
.keypoints { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.exercise { background: var(--ok-soft); border: 1px dashed color-mix(in srgb, var(--ok) 45%, transparent); }
.keypoints h4, .exercise h4 { margin: 0 0 8px; font-size: 14px; letter-spacing: .04em; }
.keypoints h4 { color: var(--accent-ink); }
.exercise h4 { color: var(--ok); }
.keypoints ul, .exercise ul { margin: 0; padding-left: 1.1em; }
.keypoints li, .exercise li { margin: .25em 0; line-height: 1.7; }

/* resources */
.res { list-style: none; padding: 0; margin: 14px 0; display: grid; gap: 8px; }
.res a {
  display: grid; grid-template-columns: 34px 1fr auto; gap: 12px; align-items: center;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; text-decoration: none; color: var(--ink);
}
.res a:hover { border-color: var(--accent); }
.res .ic { width: 34px; height: 34px; border-radius: 8px; background: var(--line-2); display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--ink-2); }
.res .ic.yt { background: #ffe9e9; color: #d61f1f; }
.res .t { display: block; font-size: 14.5px; font-weight: 550; line-height: 1.45; }
.res .s { display: block; font-size: 12.5px; color: var(--ink-3); }
.res .go { color: var(--ink-3); font-size: 14px; }

/* checklist */
.plan { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 18px 0; }
.week { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; box-shadow: var(--shadow); }
.week .w { font-family: var(--mono); font-size: 12px; color: var(--accent-ink); }
.week b { display: block; margin: 2px 0 4px; }
.week p { margin: 0; font-size: 14px; color: var(--ink-2); line-height: 1.65; }
.checklist { list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 8px; }
.checklist label {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px;
  font-size: 15px; line-height: 1.6;
}
.checklist input { width: 18px; height: 18px; margin-top: 4px; accent-color: var(--ok); flex: none; }
.checklist input:checked + span { color: var(--ink-3); text-decoration: line-through; }
.score { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-2); }
.score .bar { flex: 1; height: 8px; background: var(--line-2); border-radius: 99px; overflow: hidden; }
.score .bar i { display: block; height: 100%; width: 0; background: var(--ok); transition: width .25s; }

/* ROI calculator */
.calc { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.calc label { display: grid; gap: 4px; font-size: 13px; color: var(--ink-2); }
.calc input {
  height: 40px; padding: 0 12px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 15px; font-variant-numeric: tabular-nums;
}
.calc-out { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.calc-out div { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.calc-out small { display: block; font-size: 12px; color: var(--ink-3); }
.calc-out b { font-size: 20px; font-variant-numeric: tabular-nums; }
.calc-out .big b { color: var(--accent-ink); }

/* question list */
.qlist { counter-reset: q; list-style: none; padding: 0; margin: 16px 0; display: grid; gap: 10px; }
.qlist li { counter-increment: q; background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 12px 52px; position: relative; font-size: 15px; line-height: 1.7; }
.qlist li::before { content: counter(q, decimal-leading-zero); position: absolute; left: 16px; top: 13px; font-family: var(--mono); font-size: 13px; color: var(--accent-ink); font-weight: 700; }
.qlist li b { display: block; }
.qlist li .q-en { display: block; color: var(--ink-3); font-size: 13.5px; font-style: italic; }

footer.foot { margin-top: 64px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-3); line-height: 1.7; }

.to-top {
  position: fixed; right: 20px; bottom: 20px; z-index: 20;
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-2);
  display: grid; place-items: center; cursor: pointer; box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.to-top.show { opacity: 1; pointer-events: auto; }

/* ---------- responsive ---------- */
@media (max-width: 1080px) {
  .layout { grid-template-columns: minmax(0, var(--content-w)); gap: 0; }
  #toc-toggle { display: inline-flex; }
  .toc {
    position: fixed; top: 56px; left: 0; bottom: 0; z-index: 40;
    width: min(86vw, 320px); max-height: none;
    background: var(--paper); border-right: 1px solid var(--line);
    padding: 20px 12px; transform: translateX(-102%); transition: transform .22s ease;
  }
  body.toc-open .toc { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.28); }
}
@media (max-width: 720px) {
  body { font-size: 16px; line-height: 1.8; }
  .layout { padding: 0 16px 80px; }
  .topbar { padding: 0 12px; }
  .hero { padding-top: 36px; }
  .meta-grid, .grid-2, .grid-3, .box-row, .plan, .calc, .calc-out { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  figure.fig { padding: 14px; }
  .flow { flex-direction: column; }
  .flow .arrow { width: auto; height: 30px; }
  .flow .arrow::before { content: "↓"; }
  .case > div { grid-template-columns: 1fr; gap: 2px; }
  .msg { grid-template-columns: 1fr; gap: 2px; }
  .msg .who { text-align: left; padding: 0 2px; }
  details.obj .inner { padding-left: 18px; }
  details.obj summary .en { display: none; }
  /* stacked tables: every cell shows its column label */
  table.stack thead { display: none; }
  table.stack, table.stack tbody, table.stack tr, table.stack td { display: block; width: 100%; }
  table.stack tr { border-bottom: 1px solid var(--line); padding: 10px 0; }
  table.stack tbody tr:last-child { border-bottom: 0; }
  table.stack td { border: 0; padding: 3px 16px; display: grid; grid-template-columns: 6.2em 1fr; gap: 10px; }
  table.stack td::before { content: attr(data-label); color: var(--ink-3); font-size: 12.5px; font-weight: 500; padding-top: 2px; }
  table.stack td:first-child { font-size: 15.5px; }
  table.stack td:first-child::before { content: ""; display: none; }
  table.stack td:first-child { display: block; padding-bottom: 6px; }
  .gloss-group td { display: block !important; }
  .gloss-group td::before { display: none !important; }
}

@media print {
  :root { --bg: #fff; --paper: #fff; --shadow: none; }
  .topbar, .toc, .to-top, .gloss-tools { display: none !important; }
  .layout { display: block; padding: 0; }
  body { font-size: 11pt; line-height: 1.7; }
  section.chapter { break-before: page; border-top: 0; margin-top: 0; }
  figure.fig, .table-wrap, .card, .case, .callout { break-inside: avoid; }
  details.obj { break-inside: avoid; }
  details.obj .inner { display: block; }
  a { color: inherit; text-decoration: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}

/* robot link strokes used by illustrations */
.ill .L { stroke: currentColor; stroke-width: 12; stroke-linecap: round; fill: none; }
.ill .Lm { stroke: currentColor; stroke-width: 8; stroke-linecap: round; fill: none; }
.ill .Ls { stroke: currentColor; stroke-width: 4; stroke-linecap: round; fill: none; }
.ill .Lc { stroke: var(--ink-3); stroke-width: 9; stroke-linecap: round; fill: none; }
.ill .j { fill: var(--accent); stroke: var(--paper); stroke-width: 2.5; }
.ill .ring { fill: var(--paper); stroke: var(--accent); stroke-width: 4; }
.ill .ground { stroke: var(--ink-3); stroke-width: 1.6; }
.ill .lead { stroke: var(--ink-3); stroke-width: 1.2; fill: none; }
.ill .box { fill: var(--paper); stroke: var(--line); stroke-width: 1.5; }
.ill .boxa { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 1.5; }
.ill .boxd { fill: var(--paper); stroke: var(--ink-3); stroke-width: 1.5; stroke-dasharray: 5 4; }
.ill .arr { stroke: var(--ink-3); stroke-width: 1.6; fill: none; marker-end: url(#ah); }
.ill .wpc { fill: #e9b949; stroke: currentColor; stroke-width: 2; }
.ill .water { fill: color-mix(in srgb, var(--accent) 12%, transparent); }
.ill .ice { fill: var(--paper); stroke: var(--accent); stroke-width: 2; }
.ill .ice2 { fill: var(--accent-soft); stroke: var(--accent); stroke-width: 2; }

/* wide diagrams scroll horizontally on phones so labels stay legible */
@media (max-width: 720px) {
  figure.fig.wide { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  figure.fig.wide > svg { min-width: 600px; }
  figure.fig.wide::after { content: "← 左右滑动查看完整图示 →"; display: block; position: sticky; left: 0; font-size: 12px; color: var(--ink-3); margin-top: 8px; }
  figure.fig.wide figcaption { position: sticky; left: 0; max-width: calc(100vw - 64px); }
}

/* inline videos (click-to-load, no YouTube requests until played) */
.videos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin: 26px 0; }
.videos.one { grid-template-columns: minmax(0, 1fr); max-width: 560px; }
.videos-h { grid-column: 1 / -1; margin: 0; font-size: 13px; font-weight: 650; color: var(--ink-2); display: flex; align-items: center; gap: 8px; }
.videos-h span { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; background: #ffe9e9; color: #d61f1f; font-size: 9px; }
.vid { margin: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.vid-play, .vid iframe { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border: 0; padding: 0; margin: 0; background: #111; cursor: pointer; overflow: hidden; }
.vid-play img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .3s, opacity .2s; opacity: .92; }
.vid-play:hover img { transform: scale(1.03); opacity: 1; }
.vid-badge { position: absolute; left: 50%; top: 50%; width: 58px; height: 40px; margin: -20px 0 0 -29px; border-radius: 12px; background: rgba(214, 31, 31, .92); box-shadow: 0 4px 14px rgba(0,0,0,.3); }
.vid-badge::after { content: ""; position: absolute; left: 24px; top: 12px; border-style: solid; border-width: 8px 0 8px 13px; border-color: transparent transparent transparent #fff; }
.vid-len { position: absolute; right: 8px; bottom: 8px; background: rgba(0,0,0,.75); color: #fff; font-size: 12px; font-family: var(--mono); padding: 1px 6px; border-radius: 4px; }
.vid-play:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }
.vid figcaption { padding: 12px 14px 14px; font-size: 14px; line-height: 1.6; display: grid; gap: 4px; }
.vid figcaption b { font-size: 15px; }
.vid-src { font-size: 12.5px; color: var(--ink-3); }
.vid-src a { color: var(--ink-3); }
.vid-tip { color: var(--ink-2); }
@media (max-width: 720px) { .videos { grid-template-columns: minmax(0, 1fr); } }
@media print { .vid-play { display: none; } .vid { break-inside: avoid; } }
