/* ==========================================================================
   Earth Flow Handbook — Design System
   "IDE / Terminal-native" engineering aesthetic
   Themes: EDA Dark (default) / Light   —  via [data-theme] on <html>
   ========================================================================== */

/* ---------- 1. Design tokens ---------- */
:root {
  /* typography */
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "JetBrains Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  --fs-base: 15px;
  --lh-base: 1.65;

  /* spacing scale */
  --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
  --sp-5: 24px; --sp-6: 32px; --sp-7: 48px; --sp-8: 64px;

  /* radius scale */
  --r-sm: 5px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;

  /* layout */
  --topbar-h: 52px;
  --nav-w: 264px;
  --toc-w: 224px;
  --content-max: 960px;

  /* stage category colors (shared across themes) */
  --c-input:    #8B949E;
  --c-impl:     #F0A35E;
  --c-parasitic:#B48CFF;
  --c-timing:   #FF6E6E;
  --c-power:    #F2C94C;
  --c-physical: #3FB9A8;
  --c-formal:   #56B6F7;

  --motion: 160ms cubic-bezier(.33,1,.68,1);
}

/* EDA Dark (default) */
:root, [data-theme="dark"] {
  color-scheme: dark;
  --bg-base:      #0E1218;
  --bg-panel:     #151B24;
  --bg-raised:    #1B2330;
  --bg-hover:     #222C3B;
  --bg-active:    #28344846;
  --border:       #29323F;
  --border-strong:#3B4756;
  --text:         #E6EBF2;
  --text-dim:     #9AA7B8;
  --text-faint:   #66727F;
  --accent:       #4F8CFF;
  --accent-soft:  #4F8CFF1F;
  --accent-hover: #6FA1FF;
  --success:      #3FB950;
  --warn:         #D29922;
  --error:        #F85149;
  --info:         #56B6F7;
  --term-bg:      #0A0E13;
  --term-bar:     #161D27;
  --term-green:   #7EE787;
  --term-dim:     #8B98A9;
  --shadow-1: 0 1px 2px #00000059;
  --shadow-2: 0 4px 16px #00000066;
  --shadow-3: 0 12px 40px #00000080;
  --grid-line: #22304733;
  --grid-line-2: #22304766;
  --sel-bg: #4F8CFF3D;
}

/* Light */
[data-theme="light"] {
  color-scheme: light;
  --bg-base:      #F4F6F9;
  --bg-panel:     #FFFFFF;
  --bg-raised:    #FFFFFF;
  --bg-hover:     #EDF1F6;
  --bg-active:    #E3EAF3;
  --border:       #DDE3EB;
  --border-strong:#C3CDDA;
  --text:         #1B2330;
  --text-dim:     #525E6E;
  --text-faint:   #8A94A3;
  --accent:       #2F6FED;
  --accent-soft:  #2F6FED14;
  --accent-hover: #1F5BD8;
  --success:      #1A7F37;
  --warn:         #9A6700;
  --error:        #CF222E;
  --info:         #0969DA;
  --term-bg:      #0E1218;
  --term-bar:     #1B2330;
  --term-green:   #7EE787;
  --term-dim:     #8B98A9;
  --shadow-1: 0 1px 2px #1B233014;
  --shadow-2: 0 4px 16px #1B233012;
  --shadow-3: 0 12px 40px #1B23301F;
  --grid-line: #2F6FED0D;
  --grid-line-2: #2F6FED1F;
  --sel-bg: #2F6FED30;
}

/* ---------- 2. Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs-base); }
body {
  margin: 0;
  font-family: var(--font-ui);
  line-height: var(--lh-base);
  background: var(--bg-base);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background var(--motion), color var(--motion);
}
::selection { background: var(--sel-bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }
code, kbd, pre, .mono { font-family: var(--font-mono); }
p code, li code, td code, h1 code, h2 code, h3 code {
  font-size: .875em;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: .1em .38em;
  white-space: normal;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4 { line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.9rem; } h2 { font-size: 1.42rem; margin-top: var(--sp-7); }
h3 { font-size: 1.12rem; margin-top: var(--sp-6); } h4 { font-size: .98rem; }
hr { border: none; border-top: 1px solid var(--border); margin: var(--sp-6) 0; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- 3. Shell layout ---------- */
.shell { display: grid; grid-template-columns: var(--nav-w) minmax(0,1fr); min-height: 100vh; }
.shell-main { min-width: 0; display: flex; flex-direction: column; }
.shell-body { display: grid; grid-template-columns: minmax(0,1fr) var(--toc-w); gap: var(--sp-6);
  width: 100%; max-width: calc(var(--content-max) + var(--toc-w) + var(--sp-6)); margin: 0 auto; padding: var(--sp-6) var(--sp-6) var(--sp-8); }
.content { min-width: 0; max-width: var(--content-max); }
@media (max-width: 1380px) { .shell-body { grid-template-columns: minmax(0,1fr); } .toc { display: none; } }
@media (max-width: 980px) {
  .shell { grid-template-columns: minmax(0,1fr); }
  .sidenav { position: fixed; inset: var(--topbar-h) auto 0 0; transform: translateX(-100%); transition: transform var(--motion); z-index: 60; }
  .sidenav.open { transform: none; box-shadow: var(--shadow-3); }
}

/* ---------- 4. Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 70; height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--sp-4); padding: 0 var(--sp-4);
  background: color-mix(in srgb, var(--bg-base) 82%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: var(--sp-3); font-weight: 700; letter-spacing: .02em; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; flex: none;
  background: conic-gradient(from 210deg, var(--accent), var(--c-physical), var(--c-impl), var(--accent));
  box-shadow: inset 0 0 0 2px #ffffff22, var(--shadow-1); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border-radius: 3px; background: var(--bg-base); }
.brand small { color: var(--text-faint); font-weight: 500; }
.topbar .crumbs { color: var(--text-faint); font-size: .86rem; display: flex; gap: var(--sp-2); align-items: center; min-width: 0; }
.topbar .crumbs b { color: var(--text-dim); font-weight: 600; }
.topbar-spacer { flex: 1; }
.search-btn {
  display: flex; align-items: center; gap: var(--sp-2); min-width: 220px;
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--text-faint); padding: 6px 10px; font-size: .86rem; cursor: pointer;
  transition: border-color var(--motion), color var(--motion);
}
.search-btn:hover { border-color: var(--border-strong); color: var(--text-dim); }
.search-btn .kbd { margin-left: auto; }
.icon-btn {
  width: 32px; height: 32px; display: grid; place-items: center; flex: none;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-md);
  color: var(--text-dim); cursor: pointer; transition: all var(--motion);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.nav-toggle { display: none; }
@media (max-width: 980px) { .nav-toggle { display: grid; } .search-btn { min-width: 0; } .search-btn .txt, .search-btn .kbd { display: none; } }

/* ---------- 5. Side nav ---------- */
.sidenav {
  grid-row: 1 / -1; position: sticky; top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto;
  border-right: 1px solid var(--border); background: var(--bg-panel);
  padding: var(--sp-4) var(--sp-3) var(--sp-6); font-size: .9rem;
}
.nav-group { margin-bottom: var(--sp-2); }
.nav-group-title {
  display: flex; align-items: center; gap: var(--sp-2); width: 100%;
  padding: 5px 8px; border: none; background: none; cursor: pointer;
  color: var(--text-faint); font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; border-radius: var(--r-sm);
}
.nav-group-title:hover { color: var(--text-dim); background: var(--bg-hover); }
.nav-group-title .caret { margin-left: auto; transition: transform var(--motion); font-size: .8em; }
.nav-group.closed .caret { transform: rotate(-90deg); }
.nav-group.closed .nav-items { display: none; }
.nav-items { list-style: none; margin: 2px 0 0; padding: 0 0 0 6px; }
.nav-items a {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 4.5px 8px; border-radius: var(--r-sm); color: var(--text-dim);
  border-left: 2px solid transparent; transition: all var(--motion);
}
.nav-items a:hover { color: var(--text); background: var(--bg-hover); text-decoration: none; }
.nav-items a.active { color: var(--accent); background: var(--accent-soft); border-left-color: var(--accent); font-weight: 600; }
.nav-items a .dot { width: 7px; height: 7px; border-radius: 2px; background: var(--dot, var(--text-faint)); flex: none; }
.nav-items a.soon { opacity: .45; }
.nav-items a.soon::after { content: "soon"; margin-left: auto; font-size: .68rem; color: var(--text-faint); }

/* ---------- 6. TOC ---------- */
.toc { position: sticky; top: calc(var(--topbar-h) + var(--sp-5)); align-self: start; font-size: .84rem; padding-top: 4px; }
.toc-title { color: var(--text-faint); font-size: .74rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; margin-bottom: var(--sp-2); }
.toc a { display: block; padding: 3px 0 3px var(--sp-3); color: var(--text-dim); border-left: 2px solid var(--border); }
.toc a:hover { color: var(--text); text-decoration: none; }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
.toc a.lvl3 { padding-left: var(--sp-5); font-size: .92em; }

/* ---------- 7. Buttons & badges ---------- */
.btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: 8px 16px; border-radius: var(--r-md); font-weight: 600; font-size: .92rem;
  border: 1px solid var(--border-strong); background: var(--bg-raised); color: var(--text);
  cursor: pointer; transition: all var(--motion);
}
.btn:hover { background: var(--bg-hover); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow-1); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); color: #fff; }
.btn-ghost { background: transparent; }
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: .74rem; font-weight: 600; padding: 2px 9px; border-radius: 999px;
  background: var(--bg-hover); color: var(--text-dim); border: 1px solid var(--border);
}
.badge.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.badge.warn { color: var(--warn); background: color-mix(in srgb, var(--warn) 12%, transparent); border-color: transparent; }
.kbd {
  font-family: var(--font-mono); font-size: .76em; color: var(--text-dim);
  background: var(--bg-raised); border: 1px solid var(--border-strong); border-bottom-width: 2px;
  border-radius: var(--r-sm); padding: 1px 6px; white-space: nowrap;
}

/* ---------- 8. Cards ---------- */
.card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-5); }
.card-title { margin: 0 0 var(--sp-2); font-size: 1.05rem; }
.card-grid { display: grid; gap: var(--sp-4); grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.card.hoverable { transition: all var(--motion); }
.card.hoverable:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow-2); }

/* stage chip */
.stage-chip { display: inline-flex; align-items: center; gap: 7px; font-family: var(--font-mono); font-size: .84rem;
  padding: 3px 10px; border-radius: 999px; background: var(--bg-raised); border: 1px solid var(--border); }
.stage-chip .dot { width: 8px; height: 8px; border-radius: 2.5px; background: var(--dot, var(--text-faint)); }

/* ---------- 9. Callouts ---------- */
.callout {
  display: flex; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border); border-left-width: 3px; border-radius: var(--r-md);
  background: var(--bg-panel); margin: var(--sp-4) 0; font-size: .92rem;
}
.callout .co-icon { flex: none; font-weight: 700; }
.callout p { margin: 0; } .callout p + p { margin-top: var(--sp-2); }
.callout.info  { border-left-color: var(--info); }   .callout.info .co-icon { color: var(--info); }
.callout.warn  { border-left-color: var(--warn); }   .callout.warn .co-icon { color: var(--warn); }
.callout.error { border-left-color: var(--error); }  .callout.error .co-icon { color: var(--error); }
.callout.tip   { border-left-color: var(--success); } .callout.tip .co-icon { color: var(--success); }
.callout .src { margin-left: auto; flex: none; align-self: flex-start; }

/* ---------- 10. Terminal ---------- */
.terminal {
  background: var(--term-bg); border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; margin: var(--sp-4) 0; box-shadow: var(--shadow-1);
}
.terminal-bar {
  display: flex; align-items: center; gap: var(--sp-2);
  background: var(--term-bar); padding: 8px 12px; border-bottom: 1px solid var(--border);
}
.terminal-bar .tdot { width: 10px; height: 10px; border-radius: 50%; background: var(--border-strong); }
.terminal-bar .tdot:nth-child(1) { background: #FF5F57; } .terminal-bar .tdot:nth-child(2) { background: #FEBC2E; } .terminal-bar .tdot:nth-child(3) { background: #28C840; }
.terminal-title { margin-left: var(--sp-2); color: var(--term-dim); font-size: .78rem; font-family: var(--font-mono); }
.term-copy { margin-left: auto; background: none; border: none; color: var(--term-dim); cursor: pointer; font-size: .78rem;
  font-family: var(--font-mono); padding: 2px 8px; border-radius: var(--r-sm); transition: all var(--motion); }
.term-copy:hover { color: #fff; background: #ffffff14; }
.term-copy.copied { color: var(--term-green); }
.terminal-body { padding: var(--sp-3) var(--sp-4); overflow-x: auto; font-family: var(--font-mono); font-size: .85rem; line-height: 1.7; color: #D5DEEA; }
.terminal-body .ln { display: flex; white-space: pre; }
.terminal-body .prompt { color: var(--term-green); user-select: none; margin-right: .6ch; }
.terminal-body .cmd { color: #FFFFFF; font-weight: 600; }
.terminal-body .out { color: var(--term-dim); }
.terminal-body .info { color: #79C0FF; }
.terminal-body .err { color: #FF7B72; }
.terminal-body .cmt { color: #7A8699; font-style: italic; }
.terminal-body .hl { background: #F2C94C2E; border-radius: 3px; }

/* ---------- 11. Tables ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--r-lg); margin: var(--sp-4) 0; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tbl th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); background: var(--bg-raised); padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl td { padding: 9px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background var(--motion); }
.tbl tbody tr:hover { background: var(--bg-hover); }
.tbl .yes { color: var(--success); font-weight: 700; } .tbl .req { color: var(--warn); font-weight: 700; } .tbl .no { color: var(--text-faint); }

/* ---------- 12. Directory tree ---------- */
.tree { font-family: var(--font-mono); font-size: .86rem; line-height: 1.8; background: var(--bg-panel);
  border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); overflow-x: auto; }
.tree .t-dir { color: var(--accent); font-weight: 600; }
.tree .t-file { color: var(--text); }
.tree .t-cfg { color: var(--c-power); }
.tree .t-run { color: var(--c-physical); }
.tree .t-note { color: var(--text-faint); font-style: italic; font-family: var(--font-ui); font-size: .9em; }
.tree details > summary { cursor: pointer; list-style: none; }
.tree details > summary::before { content: "▸ "; color: var(--text-faint); }
.tree details[open] > summary::before { content: "▾ "; }
.tree .t-kids { margin-left: 1.2ch; border-left: 1px dashed var(--border-strong); padding-left: 1.6ch; }

/* ---------- 13. Hero (homepage) ---------- */
.hero { position: relative; border: 1px solid var(--border); border-radius: var(--r-xl); overflow: hidden;
  background: var(--bg-panel); margin-bottom: var(--sp-7); }
.hero-inner { position: relative; z-index: 1; padding: var(--sp-7) var(--sp-7) var(--sp-6); }
.hero-grid-bg { position: absolute; inset: 0;
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(ellipse 90% 80% at 60% 0%, #000 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 90% 80% at 60% 0%, #000 30%, transparent 75%);
}
.eyebrow { font-family: var(--font-mono); font-size: .78rem; letter-spacing: .18em; color: var(--accent); font-weight: 600; margin-bottom: var(--sp-3); }
.hero h1 { font-size: 2.5rem; margin: 0 0 var(--sp-3); letter-spacing: -.02em; }
.hero .lede { color: var(--text-dim); font-size: 1.06rem; max-width: 56ch; margin: 0 0 var(--sp-5); }
.hero-cta { display: flex; gap: var(--sp-3); flex-wrap: wrap; }
.hero-meta { display: flex; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-5); }

/* ---------- 14. Flow diagram (hero strip / topology) ---------- */
.flow-canvas { background: var(--bg-base); border: 1px solid var(--border); border-radius: var(--r-lg);
  background-image: linear-gradient(var(--grid-line) 1px, transparent 1px), linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 28px 28px; overflow: hidden; }
.flow-canvas svg { display: block; width: 100%; height: auto; }
.fl-node rect { fill: var(--bg-raised); stroke: var(--node-c, var(--accent)); stroke-width: 1.5; rx: 8; }
.fl-node text { fill: var(--text); font-family: var(--font-mono); font-weight: 600; }
.fl-node.dim rect { fill: var(--bg-panel); }
.fl-edge { stroke: var(--text-faint); stroke-width: 1.5; fill: none; }
.fl-edge.head { fill: var(--text-faint); }
.fl-edge.feedback { stroke-dasharray: 5 4; stroke: var(--c-timing); }

/* ---------- 15. Search palette ---------- */
.palette-overlay { position: fixed; inset: 0; background: #05070AB8; backdrop-filter: blur(3px);
  display: none; z-index: 100; }
.palette-overlay.open { display: block; }
.palette { max-width: 620px; margin: 12vh auto 0; background: var(--bg-raised);
  border: 1px solid var(--border-strong); border-radius: var(--r-lg); box-shadow: var(--shadow-3); overflow: hidden; }
.palette-input { display: flex; align-items: center; gap: var(--sp-3); padding: 14px 16px; border-bottom: 1px solid var(--border); }
.palette-input input { flex: 1; background: none; border: none; outline: none; color: var(--text); font-size: 1rem; font-family: var(--font-ui); }
.palette-input input::placeholder { color: var(--text-faint); }
.palette-list { max-height: 46vh; overflow-y: auto; padding: var(--sp-2); }
.palette-item { display: flex; align-items: center; gap: var(--sp-3); padding: 8px 12px; border-radius: var(--r-md); cursor: pointer; color: var(--text-dim); }
.palette-item .p-kind { flex: none; font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px; background: var(--bg-hover); color: var(--text-faint); }
.palette-item .p-title { font-weight: 600; color: var(--text); white-space: nowrap; flex: none; }
.palette-item .p-sub { font-size: .82rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.palette-item.sel, .palette-item:hover { background: var(--accent-soft); }
.palette-item.sel { outline: 1px solid var(--accent-dim, var(--accent)); }
.palette-empty { padding: var(--sp-5); text-align: center; color: var(--text-faint); }
.palette-foot { display: flex; gap: var(--sp-4); padding: 9px 16px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: .76rem; }

/* ---------- 16. Security footer ---------- */
.sec-footer { margin-top: var(--sp-8); padding: var(--sp-3) 0 0; border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: var(--sp-3); color: var(--text-faint); font-size: .76rem; font-family: var(--font-mono); }
.sec-footer .lock { color: var(--warn); }

/* ---------- 17. Page header & misc ---------- */
.page-head { margin-bottom: var(--sp-6); }
.page-head h1 { margin: 0 0 var(--sp-2); }
.page-head .lede { color: var(--text-dim); margin: 0; max-width: 68ch; }
.page-head .head-meta { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); flex-wrap: wrap; }
.section-label { font-family: var(--font-mono); font-size: .74rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-faint); margin: var(--sp-7) 0 var(--sp-3); display: flex; align-items: center; gap: var(--sp-3); }
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.src-ref { font-family: var(--font-mono); font-size: .72rem; color: var(--text-faint);
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 1px 7px; white-space: nowrap; }
.flag-chip { font-family: var(--font-mono); font-size: .8rem; background: var(--bg-hover); border-radius: var(--r-sm); padding: 1px 6px; }
/* 图片自适应 */
.content img { max-width: 100%; height: auto; display: block; }
figure { margin: var(--sp-4) 0; }
figure img { width: 100%; border: 1px solid var(--border); border-radius: var(--r-lg); }
figcaption { color: var(--text-faint); font-size: .82rem; margin-top: 6px; }
/* 纵向堆叠卡片(长路径场景) */
.card-stack { display: grid; gap: var(--sp-4); grid-template-columns: 1fr; }
.mono-block { font-family: var(--font-mono); font-size: .8rem; background: var(--bg-base);
  border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 12px;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-all; color: var(--text-dim); }

/* pillar cards (homepage three pillars) */
.pillar { position: relative; padding-top: var(--sp-4); }
.pillar::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--pillar-c, var(--accent)), transparent); border-radius: 2px; }
.pillar h3 { display: flex; align-items: center; gap: var(--sp-2); margin-top: 0; }
.pillar .p-num { font-family: var(--font-mono); color: var(--pillar-c, var(--accent)); font-size: .85rem; }

/* gallery grid for preview page */
.gallery-item { margin-bottom: var(--sp-6); }
.gallery-item > .g-label { font-family: var(--font-mono); font-size: .76rem; color: var(--text-faint); margin-bottom: var(--sp-2); }

/* ---------- 18. 3D lab (canvas mode, 始终深色) ---------- */
body.lab-mode .toc { display: none; }
body.lab-mode .shell-body { max-width: none; }
body.lab-mode .content { max-width: none; }
.lab-wrap { position: relative; height: calc(100vh - var(--topbar-h) - 96px); min-height: 560px;
  border: 1px solid var(--border); border-radius: var(--r-xl); overflow: hidden; background: #0E1218; }
.lab-canvas { position: absolute; inset: 0; display: block; cursor: grab; }
.lab-canvas.dragging { cursor: grabbing; }
.lab-overlay { position: absolute; z-index: 5; pointer-events: none; }
.lab-overlay > * { pointer-events: auto; }
.lab-actions { left: 16px; top: 16px; display: flex; gap: 8px; }
.lab-btn { font-size: .8rem; padding: 5px 12px; border-radius: var(--r-md); border: 1px solid #3B4756;
  background: #151B24CC; color: #9AA7B8; cursor: pointer; backdrop-filter: blur(6px); transition: all var(--motion); }
.lab-btn:hover { color: #E6EBF2; border-color: #4F8CFF; }
.lab-btn.on { color: #4F8CFF; border-color: #4F8CFF66; }
.lab-hint { right: 16px; top: 16px; font-size: .78rem; color: #66727F; font-family: var(--font-mono);
  background: #151B2499; padding: 6px 12px; border-radius: var(--r-md); backdrop-filter: blur(6px); }
.lab-legend { left: 16px; bottom: 16px; display: flex; gap: 8px; flex-wrap: wrap; max-width: 56%; }
.lab-legend .stage-chip { background: #151B24CC; border-color: #29323F; backdrop-filter: blur(6px); font-size: .76rem; }
.lab-note { right: 16px; bottom: 16px; font-size: .74rem; color: #66727F; font-family: var(--font-mono);
  background: #151B2499; padding: 5px 10px; border-radius: var(--r-md); }
.lab-fail { position: absolute; inset: 0; display: none; place-items: center; color: #9AA7B8; z-index: 20; background: #0E1218; }
/* stage 信息面板(加大版) */
.stage-panel { position: absolute; top: 14px; right: 14px; bottom: 14px; width: 470px; max-width: calc(100% - 28px);
  overflow-y: auto; z-index: 10;
  background: #151B24F2; border: 1px solid #3B4756; border-radius: var(--r-lg);
  box-shadow: 0 12px 40px #00000080; backdrop-filter: blur(10px);
  padding: 22px; color: #E6EBF2; font-size: .9rem;
  transform: translateX(108%); transition: transform 240ms cubic-bezier(.33,1,.68,1); }
.stage-panel.open { transform: translateX(0); }
.stage-panel::-webkit-scrollbar { width: 8px; }
.stage-panel::-webkit-scrollbar-thumb { background: #2A3442; border-radius: 4px; }
.stage-panel h2 { display: flex; align-items: center; gap: 10px; margin: 0 0 4px; font-size: 1.35rem; }
.stage-panel::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: linear-gradient(90deg, var(--sp-accent, #4F8CFF), transparent 70%); border-radius: 12px 12px 0 0; }
.stage-panel .sp-close { margin-left: auto; background: none; border: none; color: #66727F; font-size: 1.3rem; cursor: pointer; line-height: 1; }
.stage-panel .sp-close:hover { color: #E6EBF2; }
.stage-panel .sp-title-en { color: #66727F; font-size: .84rem; margin-bottom: 12px; }
.stage-panel .sp-sec { margin-top: 16px; padding-top: 12px; border-top: 1px solid #222C3B; }
.stage-panel .sp-sec:first-of-type { border-top: none; padding-top: 0; }
.stage-panel .sp-label { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #66727F; margin-bottom: 6px; }
.stage-panel p { margin: 4px 0; color: #B9C2CE; line-height: 1.65; }
.stage-panel code { background: #222C3B; border: 1px solid #2A3442; border-radius: 4px; padding: .1em .35em; font-size: .85em; }
.sp-usage { font-family: var(--font-mono); font-size: .76rem; background: #0A0E13; border: 1px solid #29323F;
  border-radius: 8px; padding: 10px 12px; color: #D5DEEA; white-space: pre; overflow-x: auto; line-height: 1.65; }
.sp-flags { display: flex; gap: 6px; flex-wrap: wrap; }
.sp-src { margin-top: 16px; font-family: var(--font-mono); font-size: .72rem; color: #66727F; }
.sp-flagtable { width: 100%; border-collapse: collapse; font-size: .8rem; }
.sp-flagtable th { text-align: left; color: #66727F; font-weight: 600; font-size: .72rem; padding: 4px 8px; border-bottom: 1px solid #29323F; }
.sp-flagtable td { padding: 5px 8px; border-bottom: 1px solid #222C3B; color: #B9C2CE; font-family: var(--font-mono); font-size: .76rem; }
.sp-flagtable tbody tr:nth-child(odd) { background: #1B233055; }
.stage-panel .stage-chip { padding: 4px 12px; font-size: .84rem; }
.stage-panel .sp-title-en { color: #8B98A9; }
.sp-flagtable tr:last-child td { border-bottom: none; }
.sp-note { border-left: 3px solid var(--warn, #D29922); background: #D2992214; padding: 8px 12px; border-radius: 0 8px 8px 0;
  font-size: .82rem; color: #D8C39A; margin-top: 12px; }
.sp-note.info { border-left-color: #56B6F7; background: #56B6F714; color: #9CC4E8; }
.sp-linkchip { cursor: pointer; }
.sp-linkchip:hover { border-color: #4F8CFF; }

/* ---------- 19. 视图过渡 / 锚点 / 滚动条 / 打印 ---------- */
#view.view-enter { animation: viewIn .24s cubic-bezier(.33,1,.68,1); }
@keyframes viewIn { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }
[id] { scroll-margin-top: calc(var(--topbar-h) + 14px); }
.sidenav::-webkit-scrollbar, .tbl-wrap::-webkit-scrollbar, .terminal-body::-webkit-scrollbar,
.stage-panel::-webkit-scrollbar, .toc::-webkit-scrollbar { width: 8px; height: 8px; }
.sidenav::-webkit-scrollbar-thumb, .tbl-wrap::-webkit-scrollbar-thumb,
.terminal-body::-webkit-scrollbar-thumb, .toc::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 4px; }
.sidenav::-webkit-scrollbar-thumb:hover, .tbl-wrap::-webkit-scrollbar-thumb:hover { background: var(--text-faint); }
@media print {
  .topbar, .sidenav, .toc, .term-copy, .hero-cta { display: none !important; }
  .shell, .shell-body { display: block; }
  body { background: #fff; color: #111; }
  .card, .tbl-wrap, .terminal { border-color: #ccc; box-shadow: none; }
  .terminal-body { color: #111; background: #f6f6f6; }
}
