/* ═══ Zio — Expression Space · Quiet Tactile ═══
   令牌单源:groiz/design-system/tokens.css(本文件头部区块由
   groiz/tools/sync-design-tokens.sh 按标记分发,不要手改)。
   其余规则沿用原选择器与布局逻辑;调色板经页面级映射
   (legacy 名 → semantic 令牌)接管,双主题自适应。 */

/* zt-tokens:begin (generated — edit groiz/design-system/tokens.css, run tools/sync-design-tokens.sh) */
/* ═══ Quiet Tactile v2 — Zio 生态共享设计令牌(单源) ═══
   canonical: groiz/design-system/tokens.css
   分发副本(不要直接改):
     · groiz/site/tokens.css            —— <link> 引用,site/Dockerfile COPY
     · zio/apps/loom/web/index.html     —— loom serve 只托管 index.html,令牌内联
   修改后运行 groiz/tools/sync-design-tokens.sh 重新分发。

   v2 (2026-11-01, 总纲 §3.2 色板): 语义令牌名全部保持,只换值。
   变更: 色板换 Modern Chinese Colors(蓝主); M3 颗粒材质废弃移除;
   M2 玻璃收敛为仅粘性栏可用; 阶段色/按钮色随新板重推导。
   逐值映射见 zio-eco-docs/docs/design-system/tokens.md。

   三层令牌(页面禁止引用原始色值):
     Layer 1  primitive  --zt-*       原始色值/尺寸/圆角/阴影/字体/动效
     Layer 2  semantic   --bg-* --text-* --border-* --accent-* --status-*
     Layer 3  component  --button-* --input-* --card-* --ph-*

   主题合同:默认(:root)= light;html[data-theme="dark"] 整体覆盖。
   主题脚本必须在首帧前解析 system/light/dark 并写 data-theme(无闪烁);
   用户偏好存 localStorage "zt-theme",三个产品共用同一个键。 */

/* ── Layer 1 · primitive ─────────────────────────────────────────── */
:root {
  /* 字体栈:不加载 webfont(离线可靠 / 授权 / 性能),按栈内系统字体回退。
     editorial/mono 是拉丁导向的栈,CJK 必须显式回退到黑体,
     否则中文标题会落到系统衬线(宋体)。
     注:本副本与 groiz 单源的 Inter/Geist 前缀已分叉 —— 站点不再引入
     Google Fonts,拉丁文一律走 system-ui;若单源同步回 Inter 前缀,
     本地未装 Inter 时仍会自然落到 system-ui,无回归风险。 */
  --zt-font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --zt-font-editorial: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial,
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --zt-font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas,
    "Liberation Mono", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", monospace;

  /* 间距,4px 基准 */
  --zt-space-1: 4px;  --zt-space-2: 8px;   --zt-space-3: 12px; --zt-space-4: 16px;
  --zt-space-5: 20px; --zt-space-6: 24px;  --zt-space-8: 32px; --zt-space-10: 40px;
  --zt-space-12: 48px; --zt-space-16: 64px; --zt-space-20: 80px;

  /* 圆角:按用途选择,不要全站同一圆角 */
  --zt-radius-sm: 6px;  --zt-radius-md: 10px;  --zt-radius-lg: 14px;
  --zt-radius-xl: 20px; --zt-radius-2xl: 28px; --zt-radius-full: 999px;

  /* 阴影:柔和、低对比 —— 触感,不是悬浮 */
  --zt-shadow-sm: 0 1px 2px rgba(32, 43, 56, .05), 0 1px 3px rgba(32, 43, 56, .04);
  --zt-shadow-md: 0 2px 4px rgba(32, 43, 56, .05), 0 6px 16px rgba(32, 43, 56, .07);
  --zt-shadow-lg: 0 4px 8px rgba(32, 43, 56, .06), 0 16px 40px rgba(32, 43, 56, .12);

  /* 动效时长与统一缓动;执行状态动画必须对应真实状态 */
  --zt-motion-fast: 120ms;  --zt-motion-base: 150ms;  --zt-motion-pop: 180ms;
  --zt-motion-panel: 220ms; --zt-motion-page: 280ms;
  --zt-ease: cubic-bezier(.2, 0, 0, 1);

  /* 字号层级 */
  --zt-fs-display: 52px; --zt-fs-h1: 36px; --zt-fs-h2: 28px; --zt-fs-h3: 22px;
  --zt-fs-h4: 18px; --zt-fs-body-lg: 16px; --zt-fs-body: 14px;
  --zt-fs-caption: 12px; --zt-fs-code: 13px;

  /* 次级色板(传统色现代转译):仅少量状态、图表与辅助,不与主色竞争 */
  --zt-sec-cang:   #829B91;  /* 苍 */
  --zt-sec-cingci: #A7C1B9;  /* 青瓷 */
  --zt-sec-sha:    #C5BCA9;  /* 砂 */
  --zt-sec-huizi:  #A6A2B5;  /* 灰紫 */
  --zt-sec-tao:    #B98F84;  /* 陶 */
}

/* ── Layer 2 · semantic(light = 默认) ────────────────────────────── */
:root {
  color-scheme: light;
  --bg-canvas: #F5F7FA;      /* background:页面底 */
  --bg-surface: #FFFFFF;     /* surface:内容表面 */
  --bg-elevated: #FFFFFF;    /* surface-elevated:浮起表面 */
  --bg-subtle: #F0F3F8;      /* surface-secondary:次级表面 */
  --bg-inset: #E4E9F0;       /* 内嵌表面:代码/日志/编辑器(比 canvas 深一档) */
  --text-primary: #202B38;
  --text-secondary: #647285;  /* 总纲 #697789 加深至 AA 4.56:1 */
  --text-tertiary: #8C99A9;
  --border-default: #DDE3EB;
  --border-strong: #C7D0DC;
  --accent-primary: #315E91; /* primary:靛青蓝 */
  --accent-hover: #284F7C;   /* primary-hover */
  --accent-subtle: #DCE6F0;  /* primary 12% on canvas */
  --focus-ring: #527EAA;     /* info 兼任焦点环 */
  --status-success: #398C72;
  --status-warning: #B68A40;
  --status-danger: #C45C5C;
  --status-info: #47719C;  /* 总纲 #527EAA 加深至 AA 4.76:1(兼 focus-ring 文本场景) */

  /* M2 毛玻璃:仅粘性导航/浮层可用;不支持 backdrop-filter 时降级为实心表面 */
  --glass-background: rgba(255, 255, 255, .80);
  --glass-border: rgba(221, 227, 235, .72);

  /* 教学端口五阶段色(低饱和,随新板重推导;两主题各一套) */
  --ph-ask: #46688F;      /* ask 模型 · 蓝青 */
  --ph-extract: #4F8375;  /* extract 提取 · 苍绿 */
  --ph-exec: #A98B4E;     /* execute 执行 · 砂 */
  --ph-check: #7C78A0;    /* candidate? 判定 · 灰紫 */
  --ph-revise: #B47368;   /* revise 修订 · 陶 */
  --ph-other: #8C99A9;
}

/* ── Layer 2 · semantic(dark) ───────────────────────────────────── */
html[data-theme="dark"] {
  color-scheme: dark;
  --bg-canvas: #10151D;
  --bg-surface: #181F2A;
  --bg-elevated: #242E3C;
  --bg-subtle: #202A37;
  --bg-inset: #0C1117;
  --text-primary: #E5EAF1;
  --text-secondary: #9BA9BA;
  --text-tertiary: #7889A0;
  --border-default: #303B49;
  --border-strong: #43505F;
  --accent-primary: #83A9D4;
  --accent-hover: #9ABAE0;
  --accent-subtle: #24384E;
  --focus-ring: #83A9D4;
  --status-success: #65B69A;
  --status-warning: #D5AD68;
  --status-danger: #E17D7D;
  --status-info: #83A9D4;

  --glass-background: rgba(24, 31, 42, .80);
  --glass-border: rgba(48, 59, 73, .72);

  --ph-ask: #83A9D4;
  --ph-extract: #65B69A;
  --ph-exec: #D5AD68;
  --ph-check: #B0AACF;
  --ph-revise: #DDA294;
  --ph-other: #7889A0;
}

/* ── Layer 3 · component ─────────────────────────────────────────── */
:root {
  /* 实心按钮:light 用 primary+白字,dark 用亮 primary+深字(禁渐变/发光) */
  --button-radius: var(--zt-radius-md);
  --button-bg: #315E91;
  --button-bg-hover: #284F7C;
  --button-fg: #FFFFFF;
  --input-border: var(--border-default);
  --card-bg: var(--bg-surface);
  --card-border: var(--border-default);
  --card-shadow: var(--zt-shadow-sm);
}
html[data-theme="dark"] {
  --button-bg: var(--accent-primary);
  --button-bg-hover: var(--accent-hover);
  --button-fg: #10151D;
}

/* ── 共享材质 ────────────────────────────────────────────────────── */
/* M2 Frosted Glass:仅粘性导航/浮层。不支持 backdrop-filter 时降级为实心表面。
   (v2 收敛:普通表面禁止玻璃;大面积品牌背景禁用) */
.zt-glass {
  -webkit-backdrop-filter: blur(20px) saturate(120%);
  backdrop-filter: blur(20px) saturate(120%);
  background: var(--glass-background);
  border: 1px solid var(--glass-border);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .zt-glass { background: var(--bg-elevated); }
}

/* M3 Grain 已废弃(v2):总纲 §3.1 禁大面积纹理装饰。
   页面残留的 .zt-grain 类不再产生任何样式,由 P4 逐产品摘除引用。 */

/* 数字优先 tabular(指标/游标/预算) */
.zt-num { font-variant-numeric: tabular-nums; }

/* ── 无障碍与滚动条 ─────────────────────────────────────────────── */
/* hidden 属性兜底:作者样式给元素设 display(如 .zio-repl-panel 的 flex)
   会与 UA 的 [hidden]{display:none} 同特异性竞胜,面板常显挡内容。 */
[hidden] { display: none !important; }

:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent-primary) 25%, transparent); }

* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--zt-radius-full); }
::-webkit-scrollbar-track { background: transparent; }

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

/* ── 主题引导合同(每页自行内联,首帧前执行) ─────────────────────
   脚本内容:读 localStorage "zt-theme"(system/light/dark,默认 system);
   system 时按 prefers-color-scheme 解析;结果写 html 的 data-theme 与
   data-themePref 两个 dataset。切换循环 system → light → dark 由页面的
   ztTheme.cycle() 提供,三个产品共用同一实现。 */
/* zt-tokens:end */

/* ── 页面级映射:原变量名 → 语义令牌 ────────────────────────────── */
:root {
  --bg-dark: var(--bg-canvas);
  --bg-card: var(--bg-elevated);
  --bg-card-hover: var(--bg-elevated);
  --bg-terminal: var(--bg-inset);

  --border-color: var(--border-default);
  --border-highlight: var(--border-strong);

  --text-main: var(--text-primary);
  --text-muted: var(--text-secondary);
  --text-dim: var(--text-tertiary);

  --accent-cyan: var(--accent-primary);
  --accent-purple: var(--ph-check);
  --accent-pink: var(--ph-revise);
  --accent-green: var(--ph-extract);
  --accent-amber: var(--ph-exec);

  --font-sans: var(--zt-font-sans);
  --font-mono: var(--zt-font-mono);

  /* 代码语法色(doc-rich.js 重分词的 lisp 块) */
  --syn-code: var(--text-secondary);
  --syn-comment: var(--text-tertiary);
  --syn-string: var(--ph-extract);
  --syn-keyword: var(--ph-revise);
  --syn-kwtoken: var(--ph-check);
  --syn-number: var(--ph-ask);
  --syn-macro: var(--ph-exec);

  /* 彩虹括号:功能性配色(括号配对),8 色低饱和轮转 */
  --rp-0: #6E8FB3; --rp-1: #B08BA3; --rp-2: #A89860; --rp-3: #7FA98C;
  --rp-4: #C08A7A; --rp-5: #8B93C4; --rp-6: #6FA8A0; --rp-7: #A78BC0;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  line-height: 1.65;
  overflow-x: hidden;
}

/* Background Atmosphere:低饱和黛蓝/天青晕,双主题自适应 */
/* .bg-glow 已废弃(总纲 §3.1 禁大面积发光/装饰光效),P4 摘除 */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header & Navigation:M2 毛玻璃,透明度来自令牌。
   只作用于站点顶栏(body 的直接子元素)——正文里的 <header>(页头、分册头、
   应用顶栏)是语义标签,不该被套上顶栏的 sticky/毛玻璃/层级。 */
body > header {
  position: sticky;
  top: 0;
  background: var(--glass-background);
  -webkit-backdrop-filter: blur(20px) saturate(120%);
  backdrop-filter: blur(20px) saturate(120%);
  border-bottom: 1px solid var(--glass-border);
  z-index: 100;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  body > header { background: var(--bg-elevated); }
}

.nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 72px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  font-family: var(--zt-font-editorial);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
}

.logo-brackets {
  color: var(--accent-primary);
}

.logo-tag {
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--zt-radius-full);
  background: var(--accent-subtle);
  color: var(--accent-primary);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 25%, transparent);
}

.nav-links {
  display: flex;
  gap: 28px;
  list-style: none;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  transition: color var(--zt-motion-fast) var(--zt-ease);
}

.nav-links a:hover {
  color: var(--text-primary);
}

/* 当前区域:实底药丸,一眼可见自己在哪(寻路反馈)
   负外边距抵消内边距,行内布局不因药丸增宽而移位 */
.nav-links a[aria-current="page"] {
  color: var(--accent-primary);
  background: var(--accent-subtle);
  font-weight: 600;
  padding: 4px 12px;
  margin: -4px -6px;
  border-radius: var(--zt-radius-full);
}

/* 顶栏操作区:主题切换 + 汉堡(≤640px)+ 页面级 slot 动作 */
.nav-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ≤640px 顶栏汉堡:开 .nav-links 抽屉(见 640px 媒体查询) */
.nav-toggle {
  display: none;
  width: 36px; height: 36px;
  align-items: center; justify-content: center;
  border: 1px solid var(--border-default); border-radius: var(--zt-radius-md);
  background: var(--bg-elevated); color: var(--text-primary);
  font-size: 1rem; line-height: 1; cursor: pointer;
  transition: color var(--zt-motion-fast) var(--zt-ease), border-color var(--zt-motion-fast) var(--zt-ease);
}
.nav-toggle:hover { color: var(--text-primary); border-color: var(--border-strong); }

/* ── 抽屉遮罩:顶栏导航抽屉(≤640px)与文档目录抽屉(≤980px)共用 ── */
.drawer-scrim {
  position: fixed; inset: 0; z-index: 230;
  background: color-mix(in srgb, var(--bg-inset) 55%, transparent);
  opacity: 0; pointer-events: none;
  transition: opacity var(--zt-motion-panel) var(--zt-ease);
}
.drawer-scrim.on { opacity: 1; pointer-events: auto; }

/* 主题切换按钮(Base.astro nav-actions) */
.theme-btn {
  width: 32px; height: 32px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-default); border-radius: var(--zt-radius-full);
  background: var(--bg-elevated); color: var(--text-secondary);
  font-size: 14px; cursor: pointer;
  transition: color var(--zt-motion-fast) var(--zt-ease), border-color var(--zt-motion-fast) var(--zt-ease);
}
.theme-btn:hover { color: var(--text-primary); border-color: var(--border-strong); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--button-radius);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: background var(--zt-motion-base) var(--zt-ease),
              border-color var(--zt-motion-base) var(--zt-ease),
              transform var(--zt-motion-fast) var(--zt-ease);
  cursor: pointer;
  border: none;
}

.btn-primary {
  background: var(--button-bg);
  color: var(--button-fg);
  box-shadow: var(--zt-shadow-sm);
}

.btn-primary:hover {
  background: var(--button-bg-hover);
  color: var(--button-fg);
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  box-shadow: var(--zt-shadow-sm);
}

.btn-secondary:hover {
  border-color: var(--border-strong);
}

.btn:active { transform: translateY(1px); }

/* Hero Section */
.hero {
  padding: 80px 0 60px;
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
}

/* .eyebrow / .eyebrow-dot 已废弃(hallmark Floor #9/#10:禁眉题与装饰状态点) */

.hero h1 {
  font-family: var(--zt-font-editorial);
  /* 全宽段 clamp:窄视口(≤980px)与中间档都平滑缩放,不再等断点跳变 */
  font-size: clamp(2rem, 3.5vw + 1.25rem, 3.25rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.hero p {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
}

.hero-cta {
  display: flex;
  gap: 16px;
}

/* Interactive REPL Terminal:编辑器是 Hero 的视觉重点(M4 内嵌表面) */
.terminal-card {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-lg);
  overflow: hidden;
  box-shadow: var(--zt-shadow-lg);
}

.terminal-header {
  background: var(--bg-surface);
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-default);
}

.terminal-dots {
  display: flex;
  gap: 8px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}
.dot-red { background: var(--status-danger); }
.dot-yellow { background: var(--status-warning); }
.dot-green { background: var(--status-success); }

.terminal-title {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-tertiary);
}

.terminal-presets {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  overflow-x: auto;
}

.preset-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: var(--zt-radius-sm);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--zt-motion-fast) var(--zt-ease);
}

.preset-btn:hover, .preset-btn.active {
  background: var(--accent-subtle);
  color: var(--text-primary);
  border-color: color-mix(in srgb, var(--accent-primary) 35%, transparent);
}

.terminal-body {
  padding: 20px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  min-height: 280px;
}

.terminal-line {
  margin-bottom: 8px;
  display: flex;
  gap: 8px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.prompt {
  color: var(--accent-primary);
}

.output {
  color: var(--text-secondary);
  margin-left: 20px;
  white-space: pre-wrap;
}

.output-value {
  color: var(--ph-extract);
}

.output-type {
  color: var(--ph-check);
  font-size: 0.8rem;
  margin-left: 8px;
}

/* Feature Grid Section */
.section {
  padding: 100px 0;
  border-top: 1px solid var(--border-default);
}

.section-header {
  text-align: center;
  max-width: 700px;
  margin: 0 auto 60px;
}

.section-header h2 {
  font-family: var(--zt-font-editorial);
  font-size: 2.25rem;
  font-weight: 650;
  margin-bottom: 16px;
  letter-spacing: -.01em;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 28px;
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--zt-radius-lg);
  padding: 32px;
  box-shadow: var(--card-shadow);
  transition: border-color var(--zt-motion-base) var(--zt-ease),
              transform var(--zt-motion-base) var(--zt-ease),
              box-shadow var(--zt-motion-panel) var(--zt-ease);
}

.card:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: var(--zt-shadow-md);
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--zt-radius-md);
  background: var(--accent-subtle);
  color: var(--accent-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.card h3 {
  font-size: 1.25rem;
  margin-bottom: 12px;
}

.card p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}


/* Stats Counter Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  text-align: center;
}

.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 32px;
  border-radius: var(--zt-radius-lg);
  box-shadow: var(--card-shadow);
}

.stat-number {
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-top: 8px;
}

/* Footer */
footer {
  padding: 60px 0;
  border-top: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-tertiary);
  font-size: 0.9rem;
}

.footer-grid {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 20px;
}

.footer-links a {
  color: var(--text-secondary);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--text-primary);
}

/* ── Agent & LLM Page ── */
.agent-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
  gap: 24px;
  align-items: stretch;
}

.code-panel {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.code-panel-header {
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-tertiary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.code-panel pre {
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow: auto;
  flex: 1;
  max-height: 420px;
  margin: 0;
}

.chart-panel {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chart-panel canvas {
  width: 100%;
  height: 220px;
  display: block;
  background: var(--bg-canvas);
  border-radius: var(--zt-radius-md);
}

.q-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.q-bar-row {
  display: grid;
  /* minmax(0,…) 允许列在窄视口收缩,长标签截断而非撑破行 */
  grid-template-columns: minmax(0, 88px) minmax(0, 1fr) minmax(0, 96px);
  gap: 10px;
  align-items: center;
  color: var(--text-secondary);
}
.q-bar-row > *:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.q-bar-track {
  height: 10px;
  background: var(--bg-subtle);
  border-radius: var(--zt-radius-full);
  overflow: hidden;
}

.q-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--zt-radius-full);
  background: var(--accent-primary);
  transition: width var(--zt-motion-panel) var(--zt-ease);
}

.q-bar-val {
  text-align: right;
  color: var(--accent-primary);
  font-variant-numeric: tabular-nums;
}

.agent-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.agent-controls label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.stat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
}

.stat-chip {
  background: var(--accent-subtle);
  border: 1px solid color-mix(in srgb, var(--accent-primary) 25%, transparent);
  color: var(--accent-primary);
  padding: 4px 12px;
  border-radius: var(--zt-radius-full);
  font-variant-numeric: tabular-nums;
}

.sim-note {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  font-family: var(--font-mono);
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}

/* grid/flex items must be allowed to shrink below content min-width
   (pre blocks hold long unbreakable lines) */
.scenario-grid > *, .agent-grid > *, .grid-2x2 > *, .grid-3 > *, .hero-grid > * {
  min-width: 0;
}

.scenario-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--zt-radius-lg);
  box-shadow: var(--card-shadow);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.scenario-card h3 {
  font-size: 1.1rem;
}

.scenario-card > p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  flex: 0;
}

.scenario-card pre.src {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-md);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.6;
  color: var(--text-secondary);
  overflow: auto;
  max-height: 220px;
  margin: 0;
}

.scenario-output {
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-md);
  padding: 12px;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ph-extract);
  white-space: pre-wrap;
  min-height: 64px;
  flex: 1;
}

.scenario-output.err { color: var(--status-danger); }

.grid-2x2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

/* ── Responsive ── */
@media (max-width: 980px) {
  .nav-bar { height: auto; flex-wrap: wrap; gap: 8px 16px; padding-top: 12px; padding-bottom: 12px; }
  .nav-links { width: 100%; order: 3; flex-wrap: wrap; gap: 8px 20px; }
  .hero-grid { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-2x2 { grid-template-columns: 1fr 1fr; }
  .scenario-grid { grid-template-columns: 1fr; }
  .agent-grid { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .section { padding: 64px 0; }
  .hero { padding: 48px 0 40px; }
  .section-header { margin-bottom: 40px; }
  .section-header h2 { font-size: 1.75rem; }
}

@media (max-width: 640px) {
  .container { padding: 0 16px; }
  /* 顶栏:单行 logo + 操作;六个一级星球的导航链接收进左侧抽屉(汉堡触发)。
     水平内边距只由 .container 给(这里不能写 padding 简写,否则会把它的
     左右 16px 清成 0,内容贴屏幕边);另外 header 必须去毛玻璃:
     backdrop-filter 会为 fixed 后代建立 containing block,把 .nav-links
     抽屉压进 57px 高的 header 里。 */
  body > header { background: var(--bg-elevated); -webkit-backdrop-filter: none; backdrop-filter: none; }
  .nav-bar { height: auto; padding-top: 10px; padding-bottom: 10px; gap: 8px; }
  .nav-links {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 240;
    width: min(300px, 82vw);
    margin: 0; padding: 20px 16px 40px;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-default);
    box-shadow: var(--zt-shadow-lg);
    flex-direction: column; align-items: stretch; gap: 2px;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform var(--zt-motion-panel) var(--zt-ease),
                visibility 0s linear var(--zt-motion-panel);
    overflow-y: auto;
  }
  body.nav-open .nav-links { transform: none; visibility: visible; transition-delay: 0s, 0s; }
  .nav-links li { width: 100%; }
  .nav-links a { display: block; padding: 10px 12px; border-radius: var(--zt-radius-md); font-size: 1rem; }
  .nav-links a[aria-current="page"] { padding: 10px 12px; margin: 0; }
  .nav-actions { margin-left: auto; }
  .nav-actions .btn { display: none; }  /* 抽屉里有等价入口,窄屏保单行 */
  .nav-toggle { display: inline-flex; }
  .hero p { font-size: 1rem; }
  .hero-cta { flex-direction: column; }
  .btn { justify-content: center; }
  .grid-3, .grid-2x2, .stats-grid { grid-template-columns: 1fr; }
  .terminal-body { min-height: 220px; padding: 14px; font-size: 0.82rem; }
  .terminal-title { display: none; }
  .terminal-presets { flex-wrap: wrap; }
  .code-panel pre { max-height: 300px; }
  .q-bar-row { grid-template-columns: minmax(0, 56px) minmax(0, 1fr) minmax(0, 72px); }
  .q-bar-row > *:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .footer-grid { flex-direction: column; gap: 24px; text-align: center; align-items: center; }
  .footer-grid > div { text-align: center; }
  .footer-grid .logo { justify-content: center; }
  .footer-links { flex-wrap: wrap; justify-content: center; }
  .card, .scenario-card { padding: 20px; }
  .stat-number { font-size: 2.25rem; }
  .agent-controls { gap: 10px; }
  .agent-controls label { width: 100%; }
}

/* Shared multiline Zio editor, retaining the existing terminal surface. */
.repl-editor {
  padding: 12px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-default);
  display: grid;
  gap: 12px;
}

.repl-editor textarea {
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
  background: var(--bg-inset);
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 0.9rem;
}

.repl-editor textarea:focus-visible { outline: 2px solid var(--focus-ring); }
.repl-editor button { justify-self: start; }
.repl-editor button:disabled { opacity: 0.5; cursor: wait; }

/* ── Engine badge states ── */
.logo-tag.is-live {
  background: color-mix(in srgb, var(--status-success) 15%, transparent);
  color: var(--status-success);
  border-color: color-mix(in srgb, var(--status-success) 35%, transparent);
}

.logo-tag.is-failed,
.stat-chip.is-error {
  background: color-mix(in srgb, var(--status-danger) 15%, transparent);
  color: var(--status-danger);
  border-color: color-mix(in srgb, var(--status-danger) 35%, transparent);
}

.stat-chip.is-error { padding: 4px 12px; border-radius: var(--zt-radius-full); }

/* ── Page head variants ── */
.hero-lead { max-width: 820px; }
.section-tight { padding: 56px 0; }
.hero-page-head { padding-bottom: 24px; }

/* ── MDX subpage prose ── */
.prose { max-width: 900px; }
.prose > :first-child { margin-top: 0; }
.prose h2 {
  font-family: var(--zt-font-editorial);
  font-size: 1.75rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 56px 0 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-default);
}
.prose h3 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 36px 0 12px; }
.prose p { color: var(--text-secondary); margin-bottom: 18px; }
.prose ul, .prose ol { color: var(--text-secondary); margin: 0 0 18px 22px; }
.prose li { margin-bottom: 8px; }
.prose strong { color: var(--text-primary); }
/* 富文本媒体不撑破容器(长截图/录屏常见溢出源) */
.prose img, .prose video { max-width: 100%; height: auto; }
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--accent-primary);
  padding: 1px 6px;
  border-radius: var(--zt-radius-sm);
  overflow-wrap: anywhere;
}
.prose a { color: var(--accent-primary); }

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 24px;
  font-size: 0.9rem;
}
.prose th, .prose td {
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--border-default);
  vertical-align: top;
}
.prose th { background: var(--bg-subtle); color: var(--text-primary); font-weight: 600; }
.prose td { color: var(--text-secondary); }

/* ── Library reference (extracted from ;; doc comments) ── */
.symbol-chip {
  display: inline-block;
  margin: 2px 4px 2px 0;
  padding: 1px 7px;
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-full);
  font-size: 0.72rem;
}

.symbol-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 32px;
  padding: 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-md);
  background: var(--bg-surface);
}

.symbol-toc a { font-size: 0.78rem; }

/* ── Shiki 双主题:defaultColor=false 时颜色走 CSS 变量,按 data-theme 切换;
   容器底统一用 --bg-inset(不用 Shiki 自带底色),浅色下不再是黑盒子。 ── */
.astro-code {
  background: var(--bg-inset) !important;
  color: var(--text-secondary) !important;
  border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-md);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: var(--zt-fs-code);   /* 13px,与 zio-block 编辑器一致 */
  line-height: 1.6;
  overflow-x: auto;               /* 长代码块横向滚动,不撑破页面 */
}
.astro-code span { color: var(--shiki-light) !important; }
html[data-theme="dark"] .astro-code span { color: var(--shiki-dark) !important; }
.zio-rich, .zio-rich code { font-family: var(--font-mono); }

/* ── Doc rich layer (doc-rich.js): rainbow parens, pairs, tables, mermaid ── */

/* Lisp-family blocks re-tokenized by doc-rich.js replace Shiki's flat
   lisp grammar. Depth classes repeat every 8 levels like rainbow-delimiters. */
.zio-rich code {
  color: var(--syn-code);
  background: none;
  padding: 0;
  border-radius: 0;
}
.zio-rich .tk-c { color: var(--syn-comment); font-style: italic; }
.zio-rich .tk-s { color: var(--syn-string); }
.zio-rich .tk-k { color: var(--syn-keyword); font-weight: 600; }
.zio-rich .tk-kw { color: var(--syn-kwtoken); }
.zio-rich .tk-n { color: var(--syn-number); }
.zio-rich .tk-m { color: var(--syn-macro); }
.zio-rich .tk-p { color: var(--syn-code); }
.zio-rich .rp-0 { color: var(--rp-0); }
.zio-rich .rp-1 { color: var(--rp-1); }
.zio-rich .rp-2 { color: var(--rp-2); }
.zio-rich .rp-3 { color: var(--rp-3); }
.zio-rich .rp-4 { color: var(--rp-4); }
.zio-rich .rp-5 { color: var(--rp-5); }
.zio-rich .rp-6 { color: var(--rp-6); }
.zio-rich .rp-7 { color: var(--rp-7); }
.zio-rich .rp-0, .zio-rich .rp-1, .zio-rich .rp-2, .zio-rich .rp-3,
.zio-rich .rp-4, .zio-rich .rp-5, .zio-rich .rp-6, .zio-rich .rp-7 {
  cursor: pointer;
  border-radius: 3px;
  transition: background var(--zt-motion-fast) var(--zt-ease), box-shadow var(--zt-motion-fast) var(--zt-ease);
}

/* Hover previews the partner; click pins the pair; second click jumps. */
.zio-rich .hp-hover { background: color-mix(in srgb, var(--text-primary) 8%, transparent); }
.zio-rich .hp-sel {
  background: var(--accent-subtle);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent-primary) 40%, transparent);
}
.zio-rich .hp-flash { animation: paren-flash 0.4s ease-in-out 3; }
@keyframes paren-flash {
  0%, 100% { background: transparent; }
  50% { background: var(--accent-subtle); }
}

/* Prose tables: scroll horizontally instead of overflowing, striped rows. */
.table-wrap { overflow-x: auto; margin-bottom: 24px; }
.table-wrap .prose table, .prose .table-wrap table { margin-bottom: 0; }
.prose table tbody tr:nth-child(even) { background: color-mix(in srgb, var(--text-primary) 3%, transparent); }
.prose table tbody tr:hover { background: color-mix(in srgb, var(--accent-primary) 6%, transparent); }
.prose table code { white-space: nowrap; }

/* Mermaid diagrams rendered from ```mermaid fences. */
.mermaid {
  display: flex;
  justify-content: center;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--zt-radius-lg);
  padding: 20px 16px;
  margin: 0 0 24px;
  overflow-x: auto;
}
.mermaid svg { max-width: 100%; height: auto; }

/* org 管线的裸代码块(pre[data-zio-block]、pre>code.language-*)不带
   .astro-code 的滚动容器,窄视口长行会撑破页面 —— 与 Shiki 块同等兜底:
   pre 横向滚动,长 code 行不参与布局溢出。 */
.prose pre, .doc-body pre { overflow-x: auto; }

/* Language-first navigation and build provenance. */
.logo-tag { white-space: nowrap; }
.hero-cta { flex-wrap: wrap; }
.card a, .section-link a, .build-provenance a { color: var(--accent-primary); text-underline-offset: 4px; }
.card a { display: inline-block; margin-top: 18px; }
.section-link { margin-top: 28px; text-align: center; }
.learning-links { justify-content: center; margin-top: 28px; }
.build-provenance {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 24px;
  margin-top: 24px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
}
a:focus-visible, button:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
@media (max-width: 640px) {
  .logo { gap: 6px; font-size: 1.1rem; }
  .build-provenance { justify-content: center; text-align: center; }
}

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

/* ── 文档三栏壳(P4:目录/正文/锚点)与签名闭环 ─────────────────── */
.doc-crumbs {
  max-width: 1200px; margin: 0 auto; padding: 18px 24px 0;
  color: var(--text-tertiary); font-size: 0.8rem;
}
.doc-crumbs a { color: var(--text-secondary); }
.doc-crumbs b { color: var(--text-primary); font-weight: 500; }

.doc-layout {
  max-width: 1200px; margin: 0 auto; padding: 8px 24px 56px;
  display: grid; grid-template-columns: 220px minmax(0, 1fr) 180px; gap: 44px;
  align-items: start;
}
.doc-toc h4 {
  margin: 22px 0 6px; font-size: 0.78rem; font-weight: 600;
  color: var(--text-tertiary);
}
.doc-toc a {
  display: block; padding: 5px 10px; margin: 1px 0;
  border-radius: var(--zt-radius-sm);
  color: var(--text-secondary); font-size: 0.85rem;
}
.doc-toc a:hover { background: var(--bg-subtle); color: var(--text-primary); text-decoration: none; }
.doc-toc a[aria-current="page"] {
  background: var(--accent-subtle); color: var(--accent-primary); font-weight: 600;
}
.doc-search { margin-top: 18px; position: relative; }
.doc-search .pagefind-ui__search-input {
  width: 100%; height: 36px; padding: 0 52px 0 12px;
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-md); color: var(--text-primary);
  font-family: var(--font-sans); font-size: 0.85rem;
}
.doc-search .pagefind-ui__search-input:focus { border-color: var(--accent-primary); outline: none; }
.doc-search .pagefind-ui__results {
  margin-top: 10px; padding: 0; list-style: none; font-size: 0.82rem;
}
.doc-search .pagefind-ui__result { padding: 8px 0; border-bottom: 1px solid var(--border-default); }
.doc-search .pagefind-ui__result-title a { color: var(--accent-primary); }
.doc-search .pagefind-ui__result-excerpt { color: var(--text-tertiary); }
.doc-search .pagefind-ui__message { color: var(--text-tertiary); font-size: 0.78rem; }
.doc-search .pagefind-ui__search-clear {
  background: none; border: none; color: var(--text-tertiary); cursor: pointer;
  position: absolute; top: 8px; right: 12px;   /* 收进输入框右侧,不再孤行 */
}

.doc-body { min-width: 0; padding-top: 4px; }
.doc-body h1 {
  font-family: var(--zt-font-editorial); font-size: 2.25rem;
  letter-spacing: -0.01em;
  line-height: 1.2; margin: 0 0 8px; color: var(--text-primary);
}
.doc-lead { color: var(--text-secondary); margin: 0 0 24px; }
.doc-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 28px; }
.doc-actions .btn { padding: 7px 14px; font-size: 0.85rem; }

/* 右侧锚点:长文(>3 个 h2)才渲染,粘性跟随 */
.doc-anchors {
  position: sticky; top: 76px; font-size: 0.78rem; padding-top: 8px;
}
.doc-anchors h5 { margin: 0 0 8px; color: var(--text-tertiary); font-weight: 600; }
.doc-anchors a {
  display: block; padding: 3px 0 3px 10px;
  color: var(--text-tertiary); border-left: 2px solid var(--border-default);
}
.doc-anchors a:hover { color: var(--text-primary); text-decoration: none; }

/* 锚点跳过吸顶导航(≤980px 双行头部在上方媒体查询加到 108px) */
.prose [id], .doc-body [id] { scroll-margin-top: 76px; }

/* 上下篇:flex-basis 让位、可收缩,长标题换行 —— 不再用固定 min-width 撑破窄屏 */
.doc-pager {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px 16px;
  margin-top: 44px; padding-top: 20px; border-top: 1px solid var(--border-default);
}
.doc-pager a {
  display: grid; gap: 2px; padding: 12px 16px;
  flex: 1 1 220px; max-width: 100%; min-width: 0;
  border: 1px solid var(--border-default); border-radius: var(--zt-radius-lg);
}
.doc-pager a:hover { border-color: var(--border-strong); text-decoration: none; }
.doc-pager a.next { text-align: right; justify-items: end; margin-left: auto; }
.doc-pager small { color: var(--text-tertiary); font-size: 0.75rem; }
.doc-pager b { color: var(--text-primary); font-size: 0.9rem; overflow-wrap: anywhere; }

/* 代码块签名闭环:文档里的 Zio 代码一键进 Playground */
.doc-code { margin: 0 0 20px; }
.doc-code .prose pre, .prose .doc-code pre { margin: 0; }
.doc-code-bar {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 6px 10px; margin-bottom: -1px;
  background: var(--bg-subtle); border: 1px solid var(--border-default);
  border-bottom: none; border-radius: var(--zt-radius-md) var(--zt-radius-md) 0 0;
}
.doc-code-bar .pg-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: var(--zt-radius-sm);
  border: 1px solid var(--border-default); background: var(--bg-surface);
  color: var(--accent-primary); font-size: 0.78rem; cursor: pointer;
}
.doc-code-bar .pg-btn:hover { border-color: var(--accent-primary); }
.doc-code .astro-code { border-radius: 0 0 var(--zt-radius-md) var(--zt-radius-md) !important; }

/* 首页快速开始三步 */
.steps-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; counter-reset: step; }
.step-card {
  position: relative; padding: 22px 24px 20px;
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-lg);
}
.step-card::before {
  counter-increment: step; content: counter(step);
  display: grid; place-items: center;
  width: 28px; height: 28px; margin-bottom: 12px;
  background: var(--accent-subtle); color: var(--accent-primary);
  border-radius: var(--zt-radius-full); font-size: 0.85rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.step-card h3 { font-size: 1.05rem; margin: 0 0 6px; }
.step-card p { color: var(--text-secondary); font-size: 0.9rem; margin: 0 0 12px; }
.step-card a { font-size: 0.9rem; }

/* 参考页符号过滤 */
.ref-filter {
  width: 100%; max-width: 360px; height: 36px; padding: 0 12px; margin-bottom: 18px;
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--zt-radius-md); color: var(--text-primary);
  font-family: var(--font-mono); font-size: 0.85rem;
}
.ref-filter:focus { border-color: var(--accent-primary); outline: none; }
.ref-empty { display: none; color: var(--text-tertiary); font-size: 0.85rem; }
.ref-empty.on { display: block; }

/* ── 文档移动端导航部件(≤980px 才显示;桌面栅格不受影响) ─────────── */
/* 抽屉触发按钮(DocNav 渲染,栅格首项)与抽屉头部的关闭钮 */
.doc-drawer-btn,
.doc-toc-head { display: none; }
.doc-toc-close {
  width: 32px; height: 32px; flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border-default); border-radius: var(--zt-radius-full);
  background: var(--bg-surface); color: var(--text-secondary);
  font-size: 0.9rem; cursor: pointer;
}
.doc-toc-close:hover { color: var(--text-primary); border-color: var(--border-strong); }

@media (max-width: 980px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .steps-grid { grid-template-columns: 1fr; }

  /* 侧栏 → off-canvas 抽屉(汉堡/「目录与搜索」按钮触发) */
  .doc-toc {
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 240;
    width: min(320px, 84vw);
    margin: 0;
    background: var(--bg-elevated);
    border-right: 1px solid var(--border-default);
    box-shadow: var(--zt-shadow-lg);
    padding: 14px 18px 40px;
    overflow-y: auto;
    transform: translateX(-105%);
    visibility: hidden;
    transition: transform var(--zt-motion-panel) var(--zt-ease),
                visibility 0s linear var(--zt-motion-panel);
  }
  .doc-toc.open { transform: none; visibility: visible; transition-delay: 0s, 0s; }
  .doc-toc-head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 10px; padding-bottom: 10px;
    border-bottom: 1px solid var(--border-default);
  }
  .doc-toc-title { font-weight: 650; font-size: 0.95rem; color: var(--text-primary); }
  .doc-toc .doc-search { margin-top: 12px; }
  .doc-drawer-btn {
    display: inline-flex; align-items: center; gap: 8px;
    order: -2;
    padding: 8px 14px;
    border: 1px solid var(--border-default); border-radius: var(--zt-radius-md);
    background: var(--bg-surface); color: var(--text-primary);
    font-size: 0.85rem; font-weight: 600; cursor: pointer;
    transition: border-color var(--zt-motion-fast) var(--zt-ease), background var(--zt-motion-fast) var(--zt-ease);
  }
  .doc-drawer-btn:hover { border-color: var(--border-strong); background: var(--bg-subtle); }

  /* 右栏锚点 → 「本页目录」可折叠面板(details 由 Base.astro 内联脚本
     仅在窄视口生成;order 让它排在正文之前,内联 padding-left 保留层级缩进) */
  .doc-anchors { order: -1; position: static; padding-top: 0; font-size: 0.85rem; }
  .doc-anchors-panel {
    border: 1px solid var(--border-default); border-radius: var(--zt-radius-md);
    background: var(--bg-surface); overflow: hidden;
  }
  .doc-anchors-panel summary {
    display: flex; align-items: center; gap: 8px;
    padding: 11px 14px; cursor: pointer; list-style: none;
    font-size: 0.85rem; font-weight: 600; color: var(--text-primary);
  }
  .doc-anchors-panel summary::-webkit-details-marker { display: none; }
  .doc-anchors-panel summary::after {
    content: "▾"; margin-left: auto; color: var(--text-tertiary); font-size: 0.8rem;
  }
  .doc-anchors-panel[open] summary::after { transform: rotate(180deg); }
  .doc-anchors-panel h5 { display: none; }   /* 面板标题由 summary 承担 */
  .doc-anchors-panel a {
    color: var(--text-secondary);
    padding-block: 8px;                       /* 只加纵向触达,缩进交给内联样式 */
    border-left-color: color-mix(in srgb, var(--border-default) 60%, transparent);
  }
  .doc-anchors-panel a:hover { background: var(--bg-subtle); }

  /* 双行吸顶头部更高,锚点跳转落点多留 */
  .prose [id], .doc-body [id] { scroll-margin-top: 108px; }
}

/* ── REPL 流畅度(P4 迭代):加载反馈/studio 布局/错误高亮 ────────── */
.logo-tag.is-loading { color: var(--text-tertiary); }
.logo-tag.is-loading::before {
  content: "◌"; display: inline-block; margin-right: 6px;
  animation: repl-spin 1.2s linear infinite;
}
@keyframes repl-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .logo-tag.is-loading::before { animation: none; } }

.output.err { color: var(--status-danger); }
.repl-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.repl-hint { color: var(--text-tertiary); font-size: 0.8rem; }
.repl-clear { margin-left: auto; }

/* studio(在线运行页):编辑器优先,宽屏左右分栏 */
.repl-studio .terminal-body { min-height: 260px; max-height: 420px; overflow-y: auto; }
@media (min-width: 1100px) {
  .repl-studio .repl-editor { border-top: 1px solid var(--border-color); }
  .repl-studio .repl-studio-cols { display: grid; }
  .repl-studio { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  .repl-studio .terminal-header,
  .repl-studio .terminal-presets { grid-column: 1 / -1; }
  .repl-studio .repl-editor { grid-row: 3; grid-column: 1; border-right: 1px solid var(--border-color); border-top: 0; }
  .repl-studio .terminal-body { grid-row: 3; grid-column: 2; max-height: none; min-height: 380px; }
}

/* 任务行列表(首页:按任务选库/语言特性)——替代 6 卡墙 */
.task-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 40px; max-width: 980px; margin: 0 auto; }
.task-row {
  display: grid; grid-template-columns: minmax(96px, 130px) minmax(0, 1fr) auto; gap: 4px 18px; align-items: baseline;
  padding: 14px 6px; border-bottom: 1px solid var(--border-default);
  color: inherit; text-decoration: none;
  transition: background var(--zt-motion-fast) var(--zt-ease);
}
.task-row:hover { background: var(--bg-subtle); }
.task-row b { font-size: 0.95rem; color: var(--text-primary); overflow-wrap: anywhere; }
.task-row span { color: var(--text-secondary); font-size: 0.88rem; grid-column: 2; }
.task-row em { font-style: normal; color: var(--accent-primary); font-size: 0.85rem; white-space: nowrap; }
@media (max-width: 900px) {
  .task-list { grid-template-columns: 1fr; }
  .task-row { grid-template-columns: minmax(0, 1fr) auto; }
  .task-row span { grid-column: 1 / -1; }
}

/* ===== 交互式 zio 代码块（org 语料 pre[data-zio-block]）与常驻 REPL ===== */
.zio-block-toolbar {
  display: flex; align-items: center; gap: var(--zt-space-2);
  padding: 6px 10px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color); border-bottom: 0;
  border-radius: var(--zt-radius-md) var(--zt-radius-md) 0 0;
  font-size: var(--zt-fs-caption); color: var(--text-secondary);
}
.zio-block-badge {
  font-family: var(--zt-font-mono);
  color: var(--accent-primary); font-weight: 600;
}
.zio-block-status { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zio-block-status[data-error] { color: var(--status-danger, #b3446c); }
.zio-block-btn {
  border: 1px solid var(--border-color); background: var(--bg-surface);
  color: var(--text-primary); border-radius: var(--zt-radius-sm);
  padding: 3px 10px; font-size: var(--zt-fs-caption); cursor: pointer;
  transition: background var(--zt-motion-fast) var(--zt-ease);
}
.zio-block-btn:hover { background: var(--bg-subtle); }
.zio-block-run {
  background: var(--accent-primary); border-color: var(--accent-primary);
  color: #fff; font-weight: 600;
}
.zio-block-run:hover { background: var(--accent-hover); }
.zio-block-run:disabled { opacity: 0.55; cursor: wait; }
/* 运行态:工具栏取代原生 code 块顶边,原 pre 去掉上圆角 */
.zio-block-toolbar + pre[data-zio-block] {
  border-top-left-radius: 0; border-top-right-radius: 0;
}
.zio-block-editor {
  width: 100%; box-sizing: border-box;
  font-family: var(--zt-font-mono); font-size: var(--zt-fs-code);
  line-height: 1.55; padding: 12px 14px;
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px dashed var(--border-color); border-radius: var(--zt-radius-md);
  resize: vertical; min-height: 3.2em;
}
.zio-block-editor:focus-visible { outline: 2px solid var(--focus-ring); }
.zio-block-output {
  margin: 0; padding: 10px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--border-color); border-top: 1px dashed var(--border-color);
  border-radius: 0 0 var(--zt-radius-md) var(--zt-radius-md);
  font-family: var(--zt-font-mono); font-size: var(--zt-fs-code);
  color: var(--text-secondary); white-space: pre-wrap; overflow-x: auto;
}
.zio-block-output[data-error] { color: var(--status-danger, #b3446c); }
/* 底部常驻 REPL */
.zio-repl-dock { position: fixed; right: 20px; bottom: 18px; z-index: 60; }
.zio-repl-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: var(--zt-radius-full);
  border: 1px solid var(--border-color); background: var(--bg-elevated);
  color: var(--text-primary); font-weight: 700; font-size: 0.9rem;
  box-shadow: var(--zt-shadow-lg); cursor: pointer;
}
.zio-repl-pill:hover { background: var(--accent-subtle); }
.zio-repl-pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-primary); box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-primary) 45%, transparent);
  animation: zio-repl-pulse 2.4s infinite;
}
@keyframes zio-repl-pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent-primary) 45%, transparent); }
  70% { box-shadow: 0 0 0 9px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}
.zio-repl-panel {
  position: fixed; right: 20px; bottom: 74px; z-index: 60;
  width: min(560px, calc(100vw - 32px));
  max-height: min(62vh, 560px);
  display: flex; flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color); border-radius: var(--zt-radius-lg);
  box-shadow: var(--zt-shadow-lg); overflow: hidden;
}
.zio-repl-header {
  display: flex; align-items: center; gap: var(--zt-space-2);
  padding: 10px 14px; border-bottom: 1px solid var(--border-color);
  background: var(--bg-surface); font-size: var(--zt-fs-caption); color: var(--text-secondary);
}
.zio-repl-title { flex: 1; font-weight: 600; color: var(--text-primary); }
.zio-repl-status { color: var(--accent-primary); }
.zio-repl-log {
  flex: 1; overflow-y: auto; padding: 12px 14px;
  font-family: var(--zt-font-mono); font-size: var(--zt-fs-code); line-height: 1.6;
  background: var(--bg-canvas); min-height: 160px; max-height: 320px;
}
.zio-repl-line { white-space: pre-wrap; word-break: break-word; }
.zio-repl-input-line { color: var(--accent-primary); font-weight: 600; }
.zio-repl-error { color: var(--status-danger, #b3446c); }
.zio-repl-output { color: var(--text-primary); }
.zio-repl-entry {
  display: flex; gap: var(--zt-space-2); align-items: flex-end;
  padding: 10px 14px; border-top: 1px solid var(--border-color); background: var(--bg-surface);
}
.zio-repl-entry textarea {
  flex: 1; resize: none; max-height: 120px;
  font-family: var(--zt-font-mono); font-size: var(--zt-fs-code);
  padding: 8px 10px; border-radius: var(--zt-radius-sm);
  border: 1px solid var(--border-color); background: var(--bg-canvas); color: var(--text-primary);
}
.zio-repl-entry textarea:focus-visible { outline: 2px solid var(--focus-ring); }
@media (max-width: 640px) {
  .zio-repl-panel { right: 12px; left: 12px; width: auto; }
  .zio-repl-dock { right: 12px; bottom: 12px; }
}

/* ===== 函数地图 ===== */
.fm-controls { display: flex; flex-wrap: wrap; gap: var(--zt-space-3); align-items: center; margin: var(--zt-space-5) 0; }
.fm-controls input[type="search"] {
  flex: 1 1 240px; padding: 9px 14px;
  border: 1px solid var(--border-color); border-radius: var(--zt-radius-full);
  background: var(--bg-surface); color: var(--text-primary); font-size: var(--zt-fs-body);
}
.fm-controls input[type="search"]:focus-visible { outline: 2px solid var(--focus-ring); }
.fm-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.fm-chip {
  border: 1px solid var(--border-color); background: var(--bg-surface); color: var(--text-secondary);
  border-radius: var(--zt-radius-full); padding: 6px 14px; font-size: var(--zt-fs-caption); cursor: pointer;
}
.fm-chip[aria-pressed="true"] { background: var(--accent-primary); border-color: var(--accent-primary); color: #fff; font-weight: 600; }
.fm-count { font-size: var(--zt-fs-caption); color: var(--text-secondary); white-space: nowrap; }
/* minmax(0,1fr)：卡片列宽锁到容器宽度——示例 pre 的长行与长符号名
   （如 core--format-scan）会撑大 grid 的 min-content，把页面顶出横向滚动 */
.fm-list { display: grid; gap: var(--zt-space-4); grid-template-columns: minmax(0, 1fr); }
.fm-card {
  border: 1px solid var(--border-color); border-radius: var(--zt-radius-md);
  background: var(--bg-surface); padding: var(--zt-space-4) var(--zt-space-5);
  min-width: 0; overflow-wrap: break-word;
}
.fm-card-head { display: flex; align-items: baseline; gap: var(--zt-space-3); flex-wrap: wrap; }
.fm-name { font-size: 1.02rem; font-weight: 700; color: var(--accent-primary); }
.fm-kind, .fm-origin {
  font-size: var(--zt-fs-caption); color: var(--text-secondary);
  border: 1px solid var(--border-color); border-radius: var(--zt-radius-full); padding: 1px 9px;
}
.fm-signature { font-family: var(--zt-font-mono); font-size: var(--zt-fs-code); color: var(--text-primary); margin-top: 6px; }
.fm-doc { color: var(--text-secondary); font-size: var(--zt-fs-body); margin-top: 8px; white-space: pre-line; }
.fm-source { font-size: var(--zt-fs-caption); color: var(--text-secondary); margin-top: 8px; opacity: 0.75; }
.fm-note { font-size: var(--zt-fs-caption); color: var(--text-secondary); padding: 0 10px; }

/* ── 文档页 ≤640px:边距收紧、排版密度提升(置于文末,覆盖上方基础规则) ── */
@media (max-width: 640px) {
  .doc-crumbs { padding: 14px 16px 0; font-size: 0.75rem; }
  .doc-layout { padding: 8px 16px 44px; gap: 12px; }
  .doc-body h1 { font-size: 1.65rem; }
  .prose h2 { font-size: 1.4rem; margin: 40px 0 14px; padding-bottom: 10px; }
  .prose h3 { margin: 28px 0 10px; }
  .prose table { font-size: 0.85rem; }
  .prose th, .prose td { padding: 9px 10px; }
  .astro-code { padding: 12px; border-radius: var(--zt-radius-sm); font-size: 0.78rem; }
  .doc-pager a { flex-basis: 100%; }
  .doc-actions { gap: 8px; }
  .doc-actions .btn { padding: 7px 12px; font-size: 0.8rem; }
  .mermaid { padding: 14px 10px; }
  /* 单行吸顶头部(约 57px),锚点落点收回到与头部等高的余量 */
  .prose [id], .doc-body [id] { scroll-margin-top: 68px; }
}
