/* ============================================================
   AI Block World — 深色玻璃拟态面板 + 高饱和玩具色
   世界是主角，面板浮在 3D 世界之上（backdrop-blur 是有意义的）。
   ============================================================ */

/* —— 全局手感（WebView）：禁图片长按/拖拽出系统效果、禁文本选中、去点按高亮；
      输入框保留可选中（兑换码等要粘贴） —— */
img { -webkit-user-drag: none; -webkit-touch-callout: none; }
body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
input, textarea { -webkit-user-select: text; user-select: text; }


:root {
  /* 面板宽度 + 悬浮外边距（桌面） */
  --panel: 372px;
  --gap: 16px;

  /* 底部三个常驻入口的统一离底距离：语音药丸、右下文本入口、选中后的工具条。
     它们是【互斥出现】的（选中时药丸淡出、工具条露面），共用一个值才不会在
     切换时看到底部跳一下。2026-08-17 用户拍板：整体再下移 8px（13 → 5）。 */
  --dock-gap: 5px;                                              /* 离屏幕边缘的统一间距 */
  --dock-bottom: calc(var(--dock-gap) + env(safe-area-inset-bottom, 0px));
  /* 左下摇杆用同一个 gap 贴左边（2026-08-18 用户拍板：「左边距离最左边间距与
     最底部间距相同」）。写成引用而不是再抄一个 5px，改 --dock-gap 两边一起动。 */
  --dock-left: max(var(--dock-gap), env(safe-area-inset-left, 0px));

  /* 摇杆整体尺寸按屏宽等比缩放（2026-08-18 用户拍板：不要一刀切写死小尺寸，
     否则宽屏上也跟着变小）。38vw 是比例项，两端夹住：
       320px 屏 → 128（下限，再小按不准）
       375px 屏 → 142.5
       430px 屏 → 163
       ≥526px   → 200（上限，与原稿一致，桌面观感不变）
     环、knob、四向箭头、以及 JS 里的最大偏移半径全部从这一个值派生，改它一处全跟着动。 */
  --stick-size: clamp(128px, 38vw, 200px);

  /* 选中物体后底部那一摞的层叠关系（自下而上：工具条 → 旋转条 → 已装载彩带）。
     写成互相引用而不是各写一个魔数，改一处全跟着动。
     --toolbar-h 是实测值（71.4 取整）——CSS 读不到别的元素高度，只能钉住；
     工具条内容改高了要回来更新这里。 */
  --toolbar-h: 72px;
  --rot-bottom: calc(var(--dock-bottom) + var(--toolbar-h) + 12px);  /* 距工具条 12px */
  --installed-bottom: calc(var(--rot-bottom) + 40px + 8px);          /* 40=旋转轨道高 */

  /* 右上角自上而下的一列：小地图(top16、120 见方) → 升降油门 / 镜头升降。
     升降油门原本是 top:50% 垂直居中，屏幕一矮就顶到上面的身上（横屏 812×375
     实测：油门 top 103.5，同时压住小地图和能量条）。所以把这一列的几何抽出来，
     油门取「垂直居中」与「地图下方」中【靠下】的那个。
     能量徽章 2026-08-19 从「地图正下方」挪到了「地图左边、与地图顶对齐」，
     所以让位基准从徽章底边改成【地图底边】。
     energy.js 建徽章、voice.css 定位地图、油门算让位，三处读的是同一份几何。 */
  --map-top: calc(16px + env(safe-area-inset-top, 0px));
  --map-right: max(24px, env(safe-area-inset-right, 0px));
  --map-size: 120px;
  --map-bottom: calc(var(--map-top) + var(--map-size));

  /* —— 表面 / 墨色 —— */
  --glass: rgba(12, 14, 20, 0.82);      /* 面板主体：偏暗，保证亮空背景下文字清晰；仍靠 backdrop-blur 透出世界 */
  --glass-solid: rgb(18, 20, 28);        /* 不透明兜底 */
  --surface-1: rgba(255, 255, 255, 0.055);
  --surface-2: rgba(255, 255, 255, 0.09);
  --surface-3: rgba(255, 255, 255, 0.13);
  --border: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);
  --ink: #f3f5fb;
  --ink-dim: #b3bccf;
  --ink-mute: #7e889d;

  /* —— 玩具色板（高饱和，OKLCH） —— */
  --brand: oklch(0.72 0.17 45);          /* 珊瑚橙：生成主色 ≈ #ff7d4d */
  --brand-strong: oklch(0.66 0.19 42);   /* 按下 */
  --brand-ink: #2a1206;                  /* 主色上的深墨 */
  --brand-soft: color-mix(in oklch, var(--brand) 20%, transparent);
  --edit: #ffd83b;                       /* 编辑模式专用（沿用现有语言） */
  --edit-ink: #2a2410;
  --ok: oklch(0.80 0.15 158);            /* 薄荷绿：完成/通过 ≈ #4fe0a5 */
  --warn: oklch(0.82 0.14 78);           /* 琥珀：注意 */
  --danger: oklch(0.70 0.19 22);         /* 暖红：出错/打回 ≈ #ff6f5f */
  --vision: oklch(0.74 0.13 300);        /* 柔紫：视觉验收 */

  /* —— 圆角 —— */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 22px;
  --r-pill: 999px;

  /* —— 阴影 —— */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.30);
  --shadow-lg: 0 16px 44px rgba(0, 0, 0, 0.38);
  --glow-brand: 0 4px 18px -2px color-mix(in oklch, var(--brand) 55%, transparent);

  /* —— 语义 z-index 标度 —— */
  --z-canvas: 0;
  /* 【别为了压住某个 HUD 就抬这个值】试过抬到 32 让面板盖住能量徽章(30)，
     结果把工具条(26)、旋转拨盘(26)、升降油门(24) 一并压到面板底下 ——
     844×390 实测工具条横跨 253..575、面板从 519 起，「完成」按钮直接被吃掉。
     谁挡了面板就单独把谁压下去（徽章已改到 7，与小地图同一层）。 */
  --z-panel: 20;
  --z-float: 40;   /* 编辑开关 / 工具栏 / 抽屉手柄 */
  --z-sheet: 50;   /* 移动端底部抽屉 */
  --z-toast: 60;

  /* —— 动效 —— */
  --dur-1: 140ms;
  --dur-2: 220ms;
  --dur-3: 380ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);      /* ease-out-quint */
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  /* 禁止双指/双击把整个界面放大（配合 viewport meta 与 src/nozoom.js）。
     manipulation = 保留点击与滚动，只去掉缩放和双击缩放【以及 300ms 点击延迟】；
     不能用 none——那会连按钮点击、输入框、列表滚动一起废掉。
     画布另有一档（见下面 canvas 规则）。 */
  touch-action: manipulation;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* 三维画布：双指【全部】交给 OrbitControls（它用 PointerEvent 自己算捏合距离）。
   必须是 none 而不是 manipulation——只要浏览器还保留一点手势解释权，它判定接管的
   那一刻就会给页面发 pointercancel，OrbitControls 当成"手指抬起"，镜头缩到一半断掉。
   所以这条不是"禁用手势"，是把手势【完整交出去】。 */
canvas {
  touch-action: none;
}

/* 通用可见焦点环（键盘可达性） */
:where(button, input, a, [tabindex]):focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* ============================================================
   3D 世界
   ============================================================ */
#world {
  position: fixed;
  inset: 0;               /* 世界全幅铺满，面板悬浮其上 */
  z-index: var(--z-canvas);
}
#world canvas {
  display: block;
}
#world.editing-cursor canvas {
  cursor: pointer;
}

/* ============================================================
   聊天面板（玻璃）
   ============================================================ */
#chat {
  position: fixed;
  top: var(--gap);
  right: var(--gap);
  bottom: var(--gap);
  width: var(--panel);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
  overflow: hidden;                 /* 让子元素跟随圆角裁切 */
  color: var(--ink);
  background: var(--glass);
  backdrop-filter: blur(26px) saturate(1.5);
  -webkit-backdrop-filter: blur(26px) saturate(1.5);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
@supports not (backdrop-filter: blur(1px)) {
  #chat { background: var(--glass-solid); }
}

/* —— 头部 —— */
#chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px 14px;
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: 1;
  min-width: 0;
}
.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  font-size: 20px;
  border-radius: var(--r-md);
  background: linear-gradient(145deg, var(--surface-3), var(--surface-1));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
/* 新 HUD（2026-08-06 稿）：用户头像 + 橙色描边环 */
.brand-ava {
  flex: none; width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  box-shadow: 0 0 0 2px #f78a4a, 0 0 10px rgba(247, 138, 74, 0.35);
  background: #2a2016;
}
/* 创作剩余次数胶囊（砖块图 + 数字） */
#quota-pill {
  flex: none; height: 32px; display: inline-flex; align-items: center; gap: 6px;
  padding: 0 12px; border-radius: var(--r-pill);
  background: var(--surface-1); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
#quota-pill img { width: 18px; height: 18px; object-fit: contain; }
#quota-pill b { font-size: 14px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.brand-text { min-width: 0; }
.brand-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
.brand-text p {
  font-size: 11.5px;
  color: var(--ink-mute);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 抽屉收起按钮（仅移动端显示） */
#sheet-collapse {
  display: none;
  flex: none;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: var(--r-md);
  background: var(--surface-1);
  color: var(--ink-dim);
  font-size: 18px;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
#sheet-collapse:hover { background: var(--surface-2); }

/* —— 消息流 —— */
#messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--surface-3) transparent;
}
#messages::-webkit-scrollbar { width: 8px; }
#messages::-webkit-scrollbar-thumb {
  background: var(--surface-3);
  border-radius: var(--r-pill);
}

/* —— 气泡 —— */
.msg {
  max-width: 90%;
  padding: 10px 13px;
  border-radius: var(--r-lg);
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  animation: msg-in var(--dur-3) var(--ease-expo) both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  border-bottom-right-radius: 5px;
  box-shadow: var(--glow-brand);
}
.msg.bot {
  align-self: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.msg.bot.error {
  background: color-mix(in oklch, var(--danger) 16%, var(--glass-solid));
  border-color: color-mix(in oklch, var(--danger) 40%, transparent);
  color: #ffd9d4;
}
/* 「AI 正在思考」打字点 */
.msg.bot.pending {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink-dim);
}
.msg.bot.pending .dots {
  display: inline-flex;
  gap: 4px;
}
.msg.bot.pending .dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand);
  animation: dot-bounce 1.1s var(--ease) infinite;
}
.msg.bot.pending .dots i:nth-child(2) { animation-delay: 0.15s; }
.msg.bot.pending .dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* 气泡里的行内「重试」按钮 */
.msg .retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 5px 12px;
  border: 1px solid color-mix(in oklch, var(--danger) 45%, transparent);
  border-radius: var(--r-pill);
  background: transparent;
  color: #ffd9d4;
  font-size: 12.5px;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
.msg .retry-btn:hover { background: color-mix(in oklch, var(--danger) 18%, transparent); }

/* ============================================================
   流水线卡（PM 状态可视化 —— 核心）
   ============================================================ */
.pipeline {
  align-self: stretch;
  border-radius: var(--r-lg);
  background: var(--surface-1);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: msg-in var(--dur-3) var(--ease-expo) both;
}
.pl-reference {
  margin: 0;
  padding: 8px 12px 10px;
  border-bottom: 1px solid var(--border);
}
.pl-reference figcaption {
  font-size: 11px;
  color: var(--ink-mute);
  margin-bottom: 6px;
}
.pl-reference img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.pl-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--border);
}
.pl-pm {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 14px;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  box-shadow: var(--glow-brand);
}
.pl-title {
  flex: 1;
  min-width: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-dim);
}
.pl-count {
  flex: none;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-mute);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
}

/* 泳道 */
.lane {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "avatar body chip"
    "avatar prog prog";
  align-items: center;
  gap: 3px 10px;
  padding: 10px 13px;
  border-top: 1px solid var(--border);
  transition: background var(--dur-2) var(--ease);
}
.lane:first-of-type { border-top: none; }
.lane.is-active { background: color-mix(in oklch, var(--brand) 7%, transparent); }
.lane.is-done { background: color-mix(in oklch, var(--ok) 6%, transparent); }
.lane.is-error { background: color-mix(in oklch, var(--danger) 8%, transparent); }

/* 设计师头像 */
.lane-avatar {
  grid-area: avatar;
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
}
/* 干活时头像外圈转动光环 */
.lane.is-working .lane-avatar::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--brand);
  border-right-color: var(--brand);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lane-body { grid-area: body; min-width: 0; }
.lane-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.lane-sub {
  font-size: 10.5px;
  color: var(--ink-mute);
  margin-top: 1px;
}

/* 状态胶囊 */
.lane-chip {
  grid-area: chip;
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--ink-dim);
  transition: all var(--dur-2) var(--ease);
}
.lane-chip .ci { font-size: 12px; line-height: 1; }
.lane-chip.st-designing,
.lane-chip.st-building,
.lane-chip.st-revising {
  background: var(--brand-soft);
  color: color-mix(in oklch, var(--brand) 65%, white);
}
.lane-chip.st-vision {
  background: color-mix(in oklch, var(--vision) 20%, transparent);
  color: color-mix(in oklch, var(--vision) 60%, white);
}
.lane-chip.st-done {
  background: color-mix(in oklch, var(--ok) 20%, transparent);
  color: color-mix(in oklch, var(--ok) 55%, white);
  animation: chip-pop var(--dur-3) var(--ease-expo);
}
.lane-chip.st-reused {
  background: color-mix(in oklch, var(--vision) 16%, transparent);
  color: color-mix(in oklch, var(--vision) 55%, white);
}
.lane-chip.st-pass {
  background: color-mix(in oklch, var(--ok) 18%, transparent);
  color: color-mix(in oklch, var(--ok) 55%, white);
}
.lane-chip.st-fail,
.lane-chip.st-error {
  background: color-mix(in oklch, var(--danger) 20%, transparent);
  color: color-mix(in oklch, var(--danger) 62%, white);
}
.lane-chip.st-fail { animation: shake 0.4s var(--ease); }
@keyframes chip-pop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* 建造进度条 */
.lane-prog {
  grid-area: prog;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 5px;
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease);
}
.lane.show-prog .lane-prog { opacity: 1; }
.lane-prog i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand), var(--ok));
  transition: width 90ms linear;
}

/* 问题 / 返工明细（渐进披露） */
.lane-issues {
  position: relative;
  grid-column: 1 / -1;
  margin-top: 6px;
  padding: 8px 26px 8px 10px;   /* 右侧留位给收起/展开箭头 */
  border-radius: var(--r-sm);
  background: color-mix(in oklch, var(--warn) 10%, transparent);
  border: 1px solid color-mix(in oklch, var(--warn) 22%, transparent);
  font-size: 11.5px;
  line-height: 1.5;
  color: color-mix(in oklch, var(--warn) 45%, white);
}
/* 收起态：只显示 1 行 */
.lane-issues:not(.open) .issues-text {
  display: -webkit-box;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.issues-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  opacity: 0.65;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
.issues-toggle:hover { background: rgba(255, 255, 255, 0.1); opacity: 1; }
.lane-issues.vision {
  background: color-mix(in oklch, var(--vision) 10%, transparent);
  border-color: color-mix(in oklch, var(--vision) 22%, transparent);
  color: color-mix(in oklch, var(--vision) 50%, white);
}

/* ============================================================
   建议 chips
   ============================================================ */
.suggestions {
  display: flex;
  flex-wrap: nowrap;              /* 不换行，超出横向滚动 */
  gap: 7px;
  padding: 2px 16px 4px;          /* 顶部留 2px 给 chip hover 的上浮 */
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;          /* Firefox 隐藏滚动条 */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  /* 右侧淡出，暗示还有更多可滑 */
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
}
.suggestions::-webkit-scrollbar { display: none; }  /* Chrome/Safari 隐藏滚动条 */
.suggestions:empty { display: none; }
.chip {
  flex: none;                     /* 保持自然宽度，不被压缩 */
  scroll-snap-align: start;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  border-radius: var(--r-pill);
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--ink-dim);
  font-size: 12.5px;
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.chip:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.chip:active { transform: translateY(0) scale(0.97); }

/* ============================================================
   输入区
   ============================================================ */
#chat-form {
  display: flex;
  align-items: center;
  gap: 9px;
  /* 底部/左右留出 iPhone 安全区（刘海/home 指示条），输入框才不会被挡住或看着没贴边 */
  padding: 12px max(16px, env(safe-area-inset-right, 0px)) calc(16px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  border-top: 1px solid var(--border);
}
#chat-input {
  flex: 1;
  min-width: 0;
  padding: 12px 15px;
  border-radius: var(--r-xl);
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--ink);
  font-size: 13.5px;
  outline: none;
  transition: border-color var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
#chat-input::placeholder { color: var(--ink-mute); }
#chat-input:focus {
  border-color: var(--brand);
  background: var(--surface-2);
}
#chat-input.editing {
  border-color: var(--edit);
  background: color-mix(in oklch, var(--edit) 8%, transparent);
}

#chat-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  box-shadow: var(--glow-brand);
  transition: transform var(--dur-1) var(--ease), filter var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease);
}
#chat-send:hover { transform: translateY(-1px) scale(1.05); }
#chat-send:active { transform: scale(0.94); }
#chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}
/* 生成中 → 停止态 */
#chat-send.is-stop {
  background: var(--surface-3);
  box-shadow: none;
  color: var(--ink);
}

/* 生成模式三段开关：🎨完整 / ⚡极速(免生图免质检) / 🚀直达(连 PM 也免) */
/* 基础规则的 display:flex 会压过 hidden 属性的 UA 样式,必须显式补一条(否则 hidden 形同虚设) */
#mode-switch[hidden] { display: none; }
#mode-switch {
  display: flex;
  gap: 4px;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 7px max(16px, env(safe-area-inset-left, 0px));
  justify-content: flex-end;
}
#mode-switch button {
  font-size: 11px;
  line-height: 1;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-1);
  color: var(--ink-mute);
  cursor: pointer;
  filter: grayscale(1);
  transition: filter var(--dur-1) var(--ease), color var(--dur-1) var(--ease),
    background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease),
    box-shadow var(--dur-1) var(--ease);
}
#mode-switch button:hover { background: var(--surface-2); }
#mode-switch button.on { filter: none; color: var(--ink); }
#mode-switch button[data-mode="full"].on {
  border-color: color-mix(in oklch, var(--brand) 55%, var(--border-strong));
  background: color-mix(in oklch, var(--brand) 14%, var(--surface-1));
}
#mode-switch button[data-mode="fast"].on {
  border-color: color-mix(in oklch, #ffb02e 55%, var(--border-strong));
  background: color-mix(in oklch, #ffb02e 14%, var(--surface-1));
  box-shadow: 0 0 10px color-mix(in oklch, #ffb02e 30%, transparent);
}
#mode-switch button[data-mode="direct"].on {
  border-color: color-mix(in oklch, #ff6b4a 55%, var(--border-strong));
  background: color-mix(in oklch, #ff6b4a 14%, var(--surface-1));
  box-shadow: 0 0 10px color-mix(in oklch, #ff6b4a 30%, transparent);
}

/* ============================================================
   浮动控件：编辑开关 / 工具栏
   ============================================================ */
#edit-toggle {
  position: fixed;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  z-index: var(--z-float);
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
#edit-toggle:hover { transform: translateY(-1px); }
#edit-toggle.on {
  background: var(--edit);
  color: var(--edit-ink);
  font-weight: 700;
  border-color: transparent;
}

/* 世界场景切换按钮：与编辑按钮同款玻璃胶囊，位于其正下方 */
#scene-toggle {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  z-index: var(--z-float);
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform var(--dur-1) var(--ease), background var(--dur-1) var(--ease);
}
#scene-toggle:hover { transform: translateY(-1px); }
#scene-toggle[hidden] { display: none; }

/* 场景选单：点按钮弹出，竖排三个 biome chip */
#scene-menu {
  position: fixed;
  top: calc(112px + env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  z-index: var(--z-float);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  box-shadow: var(--shadow-md);
}
#scene-menu[hidden] { display: none; }
#scene-menu button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
#scene-menu button:hover { background: var(--surface-3); }
#scene-menu button.on {
  background: var(--surface-3);
  border-color: var(--border);
  font-weight: 600;
}
/* 地图行：名字（占满）+ 重命名 + 删除 */
.map-row { display: flex; align-items: center; gap: 2px; }
.map-row .map-pick { flex: 1; min-width: 132px; }
.map-row .map-act {
  min-height: 30px;
  padding: 4px 7px;
  color: var(--muted);
  font-size: 12px;
  opacity: 0;
  transition: opacity var(--dur-1) var(--ease), color var(--dur-1) var(--ease);
}
.map-row:hover .map-act { opacity: 1; }
.map-row .map-act:hover { color: var(--ink); }
/* 触屏没有 hover，直接常显 */
@media (hover: none) { .map-row .map-act { opacity: 1; } }
/* 地图四边的「扩建」按钮：贴在世界边缘，位置每帧由投影算出来 */
#expand-btns { position: fixed; inset: 0; pointer-events: none; z-index: var(--z-float); }
.expand-anchor {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid rgba(120, 190, 255, 0.55);
  border-radius: var(--r-pill);
  background: rgba(16, 26, 38, 0.62);
  backdrop-filter: blur(10px) saturate(1.2);
  -webkit-backdrop-filter: blur(10px) saturate(1.2);
  color: #cfe8ff;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.28);
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
.expand-anchor:hover { background: rgba(30, 92, 150, 0.8); transform: translate(-50%, -50%) scale(1.05); }
.expand-anchor[hidden] { display: none; }
/* 扩建券角标：券图标 +「库存 N」。
   ⚠️ 别写成「×N」——那看着像"这次要花几张"（2026-09-11 玩家反馈）。
   用词与确认弹窗的库存行、赋魂详情卡的 .sp-stock 一致：暗一档的标签 + 亮色数字。
   0 张时数字转红提示要买（与首页开荒券角标同语义）。 */
.expand-anchor .xt { margin-left: 6px; display: inline-flex; align-items: center; gap: 4px; }
.expand-anchor .xt img { width: 16px; height: 16px; object-fit: contain;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.55)); }
.expand-anchor .xt i { font: 600 11px/1 "PingFang SC", sans-serif; font-style: normal;
  color: rgba(255, 226, 197, 0.7); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.expand-anchor .xt b { font: 800 12px/1 "Inter", "PingFang SC", sans-serif; color: #ffa94d;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); font-variant-numeric: tabular-nums; }
.expand-anchor .xt.zero b { color: #ff6b5a; }

/* 通用确认弹窗 */
#confirm-mask {
  position: fixed; inset: 0; z-index: 400;
  display: flex; align-items: center; justify-content: center;
  background: rgba(8, 12, 18, 0.5);
  backdrop-filter: blur(3px);
}
#confirm-mask[hidden] { display: none; }
/* 通用确认弹窗（扩建/删图/去商店/改名都走它）。2026-09-11 改皮两轮：
   ① 原来是灰玻璃 + 蓝色系统按钮，在游戏里像误入的网页控件；
   ② 一度改成弹窗那套奶油芯，玩家拍板【要游戏内的深色面板】——它是浮在 3D 世界上的，
      跟身边的工具条/语音药丸/扩建浮钮一家，不是商店那种整屏接管的奶油弹窗。
   面板配方 = 选中工具条 #toolbar（voice.css，稿面 170:16949）那一套深色玻璃，
   一模一样地抄过来：改那边记得看这边。 */
#confirm-box {
  box-sizing: border-box;
  /* 定宽 360：文案收短之后（标题一行 + 说明一句）盒子会缩成一条，看着窄得别扭
     （2026-09-11 玩家反馈"以前宽度挺合适"）。宽度不该跟着文案长短跳。
     窄屏兜底 calc(100vw-32px)——这层是 fixed 定位、按真实视口算，不吃 852 舞台缩放。 */
  width: 360px;
  max-width: calc(100vw - 32px);
  padding: 18px 20px 16px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(31, 36, 34, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.4), inset 0 0 4px rgba(255, 255, 255, 0.25),
    0 18px 48px rgba(0, 0, 0, 0.45);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}
/* 标题：一句话说清"这是什么事"，与购买弹窗把商品名放在最上同一层级 */
#confirm-title {
  margin: 0 0 8px;
  font: 800 17px/1.3 "PingFang SC", "Inter", sans-serif; color: #fff;
  letter-spacing: -0.2px;
}
#confirm-title[hidden] { display: none; }
/* 描述：细则放这儿，字号降一档、颜色压到七成，别和标题抢 */
#confirm-text {
  margin: 0 0 16px;
  /* pre-line：正文里的 \n 是调用方特意分的行（扩建那条有三句），原来被折叠成一整段
     糊在一起，读起来费劲 */
  white-space: pre-line;
  font: 500 13px/1.7 "PingFang SC", sans-serif; color: rgba(255, 255, 255, 0.7);
}
#confirm-text:empty { display: none; }
/* 改名用的输入框：只有需要输入时才 unhide（askText），深色面板上的凹槽输入框 */
#confirm-input {
  width: 100%; box-sizing: border-box; margin: -4px 0 16px;
  padding: 9px 12px; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 10px;
  background: rgba(0, 0, 0, 0.3); color: #fff;
  font: 600 14px/1.4 "PingFang SC", sans-serif; outline: none;
}
#confirm-input:focus { border-color: rgba(250, 125, 75, 0.7); background: rgba(0, 0, 0, 0.38); }
#confirm-input[hidden] { display: none; }
/* 消耗道具条：深面板上的一格凹槽 —— 左边品质格（quality.js，铁律 11），
   中间名字 + 现有多少，右边扣几件。纯文字"消耗 1 张扩建券"没有游戏感（2026-09-11 玩家反馈）。 */
#confirm-cost {
  display: flex; align-items: center; gap: 12px;
  margin: 0 0 16px; padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08); border-radius: 12px;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.35);
}
#confirm-cost[hidden] { display: none; }
.cf-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.cf-meta b {
  font: 800 14px/1 "PingFang SC", "Inter", sans-serif; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* 库存行：说法与配色对齐赋魂详情卡的 .sp-stock —— 暖白标签 + 金色数字 */
.cf-meta i {
  font: 600 11px/1 "PingFang SC", sans-serif; font-style: normal;
  color: rgba(255, 226, 197, 0.7); font-variant-numeric: tabular-nums;
}
.cf-meta i b { font-weight: 800; color: #ffd76a; }
/* 扣减量：橙色带负号，和「现有 N」形成一收一支 */
.cf-amt {
  flex: none; font: 800 16px/1 "Inter", "PingFang SC", sans-serif; color: #ff9a62;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); font-variant-numeric: tabular-nums;
}
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }
/* 次要键：深色面板上的描边胶囊，同高同圆角，只是不抢戏 */
.confirm-actions button {
  min-height: 38px; height: 38px; padding: 0 18px;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 8px;
  background: rgba(255, 255, 255, 0.08); color: rgba(255, 255, 255, 0.82);
  font: 800 14px/1 "PingFang SC", "Inter", sans-serif; cursor: pointer;
  transition: transform 0.08s ease, filter 0.08s ease, background-color 0.15s ease;
}
.confirm-actions button:hover { background: rgba(255, 255, 255, 0.14); }
.confirm-actions button:active { transform: translateY(1px) scale(0.96); filter: brightness(0.9); }
/* 主键 = 游戏内小按钮统一皮（同编辑工具条「完成」，Figma 252:19612 的橙糖果） */
#confirm-yes {
  border: none; color: #fff;
  background: linear-gradient(180deg, #fa7d4b, #fa612b);
  box-shadow: inset 0 -2px 0.5px #b73100, inset 0 0.5px 0 rgba(255, 254, 183, 0.57);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}
#confirm-yes:hover { background: linear-gradient(180deg, #fa7d4b, #fa612b); }
#confirm-yes:active { transform: translateY(1px) scale(0.96); filter: brightness(0.9); }

.map-expand-label { white-space: nowrap; }
.map-dirs { display: flex; gap: 3px; }
.map-dirs button {
  flex: 1;
  justify-content: center;
  min-height: 32px;
  padding: 5px 0;
  border-color: var(--border);
  font-size: 14px;
}
.map-new-label {
  margin: 6px 4px 2px;
  padding-top: 7px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}
.map-new-chips { display: flex; gap: 3px; }
.map-new-chips button { padding: 7px 9px; font-size: 12px; }

/* 远景项(树/石/山)选中后的删除按钮：底部居中，红色调玻璃胶囊 */
#scenery-del {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-float);
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 10px 20px;
  border: 1px solid rgba(229, 72, 77, 0.5);
  border-radius: var(--r-pill);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  color: #e5484d;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-md);
}
#scenery-del:hover { transform: translateX(-50%) translateY(-1px); }
#scenery-del[hidden] { display: none; }

#toolbar {
  position: fixed;
  bottom: var(--dock-bottom);   /* 注意：新 HUD 的 voice.css 后加载、会覆盖本行，真正生效的是那边 */
  left: calc((100vw - var(--panel) - var(--gap) * 2) / 2);
  transform: translateX(-50%);
  z-index: var(--z-float);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: var(--r-xl);
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(1.3);
  -webkit-backdrop-filter: blur(16px) saturate(1.3);
  border: 1px solid var(--border);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  animation: msg-in var(--dur-2) var(--ease-expo) both;
}
#toolbar[hidden] { display: none; }
#toolbar .sel {
  font-size: 13px;
  font-weight: 600;
  color: var(--edit);
  padding: 0 4px;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#toolbar button {
  display: grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  padding: 8px 13px;
  border: none;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
#toolbar button:hover { background: var(--surface-3); transform: translateY(-1px); }
#toolbar button:active { transform: scale(0.95); }
#toolbar #delete { background: color-mix(in oklch, var(--danger) 78%, transparent); }
#toolbar #delete:hover { background: var(--danger); }
#toolbar #deselect { background: var(--surface-1); }

/* 悬浮撤销板：编辑模式常驻，位于编辑开关下方（手机端可点） */
#undo-bar {
  position: fixed;
  top: calc(64px + env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  z-index: var(--z-float);
  display: flex;
  gap: 6px;
  padding: 6px;
  border-radius: var(--r-pill);
  background: var(--glass);
  backdrop-filter: blur(14px) saturate(1.3);
  -webkit-backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}
#undo-bar[hidden] { display: none; }
#undo-bar button {
  display: grid;
  place-items: center;
  min-width: 40px;
  min-height: 40px;
  border: none;
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 17px;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease), transform var(--dur-1) var(--ease);
}
#undo-bar button:hover:not(:disabled) { background: var(--surface-3); transform: translateY(-1px); }
#undo-bar button:active:not(:disabled) { transform: scale(0.95); }
#undo-bar button:disabled { opacity: 0.38; cursor: default; }

/* ============================================================
   移动端底部抽屉手柄 + 实况浮标
   ============================================================ */
#sheet-handle {
  display: none;
  position: fixed;
  left: max(12px, env(safe-area-inset-left, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-float);
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  background: var(--glass);
  backdrop-filter: blur(18px) saturate(1.3);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  color: var(--ink);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  text-align: left;
}
#sheet-handle .grip {
  flex: none;
  width: 30px;
  height: 4px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
}
#live-status {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--ink-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#live-status .live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 7px;
  border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 var(--brand-soft);
  animation: pulse 1.4s var(--ease) infinite;
  vertical-align: middle;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in oklch, var(--brand) 55%, transparent); }
  100% { box-shadow: 0 0 0 10px transparent; }
}
#sheet-handle .up-arrow { flex: none; color: var(--ink-mute); font-size: 14px; }

/* ============================================================
   移动端布局：世界全幅 + 面板变底部抽屉
   ============================================================ */
@media (max-width: 640px) {
  :root { --panel: 0px; }

  #world { right: 0; }

  #chat {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    height: 82vh;
    max-height: 82vh;
    width: 100%;
    border: none;
    border-top: 1px solid var(--border-strong);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    z-index: var(--z-sheet);
    transform: translateY(100%);
    transition: transform var(--dur-3) var(--ease-expo);
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
  }
  body.sheet-open #chat { transform: translateY(0); }
  body.sheet-open #sheet-handle { display: none; }

  /* 抽屉顶部拖动条 */
  #chat-head { position: relative; padding-top: 20px; }
  #chat-head::before {
    content: "";
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 4px;
    border-radius: var(--r-pill);
    background: var(--surface-3);
  }
  #sheet-collapse { display: grid; place-items: center; }

  /* 收起态：显示实况浮标 */
  #sheet-handle { display: flex; }

  /* 触摸目标放大 */
  .chip { padding: 9px 14px; font-size: 13px; }
  #chat-input { padding: 13px 16px; font-size: 15px; }
  #edit-toggle { min-height: 44px; }
  #scene-toggle { min-height: 44px; }

  /* 编辑工具栏移到抽屉之上、居中 */
  #toolbar {
    left: 50%;
    /* bottom 不再单独给：跟 :root --dock-bottom 走，与语音药丸对齐 */
  }
  body.sheet-open #toolbar { bottom: calc(82vh + 12px); }
}

/* ============================================================
   Reduced motion：动效降级为淡入/瞬切
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .msg, .pipeline { animation: none; }
  .lane.is-working .lane-avatar::after { display: none; }
  #live-status .live-dot { animation: none; }
  #chat { transition: transform var(--dur-1) linear; }
}

/* ============ 结构层：纵向泳道 + 步骤时间线 + 草稿 + 单气泡对话容器 ============ */
/* （功能/结构由 main.js 保证；以下只给不破的基础样式，视觉可再美化） */
.lane {
  display: flex;
  flex-direction: column;
  align-items: stretch;   /* 覆盖旧网格规则残留的 align-items:center，避免标题被居中 */
  gap: 6px;
  grid-template-areas: none;
}
.lane-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas:
    "avatar body chip"
    "avatar prog prog";
  align-items: center;
  gap: 3px 10px;
}
.lane-sketch {
  display: block;
  width: 100%;
  max-width: 100%;      /* 不超出设计师节点的内容区，避免右侧溢出 */
  height: auto;         /* 保持 260:160 比例缩放 */
  border-radius: 8px;
  background: #fff;
}
/* 质检员"AI 看一眼"送去判定的截图，显示在质检节点下 */
.lane-shot {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 6px 0 2px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.lane-steps { display: flex; flex-direction: column; gap: 2px; padding-left: 46px; }
.lane-step {
  display: flex; gap: 6px;
  font-size: 11px; line-height: 1.5; color: #9aa3b5;
}
.lane-step .ls-i { flex: none; opacity: 0.9; }
.lane-step .ls-t { min-width: 0; }

.turn { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; }
.turn-avatar {
  flex: none; width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 19px;
  background: color-mix(in oklch, var(--brand) 18%, transparent);
}
.turn-main { flex: 1; min-width: 0; }
.turn-name { font-size: 12px; color: #9aa3b5; font-weight: 600; margin: 2px 0 5px; }
.turn-content { display: flex; flex-direction: column; gap: 8px; }

/* 角色流转：设计师 → 质检员 → 工人（分隔 + 状态色；箭头/头像留给后续美化） */
.lane-role-head {
  font-size: 11px; font-weight: 700; margin: 7px 0 1px; color: #cdd3e0;
}
.lane-role-head[data-role="qc"] { color: #cbb2ff; }
.lane-role-head[data-role="builder"] { color: #e0b070; }
.lane-steps .lane-step { padding-left: 14px; }
.lane-step[data-kind="pass"] .ls-t { color: #7fd493; }
.lane-step[data-kind="fail"] .ls-t { color: #ff9c9c; }

/* 折叠式步骤：默认只显示"当前步 + 箭头"，展开看全部（左对齐，数据不丢只隐藏） */
.lane-row { width: 100%; }
.lane-cur {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding-left: 46px; margin-top: 2px;
  font-size: 12px; color: #cbd2e0;
}
.lane-cur-t { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane-expand {
  flex: none; background: none; border: none; cursor: pointer;
  color: #9aa3b5; font-size: 11px; line-height: 1; padding: 3px 7px; border-radius: 6px;
}
.lane-expand:hover { background: rgba(255,255,255,0.08); }
.lane-detail { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 4px; }
.lane-detail.collapsed { display: none; }
.lane-sketch { margin: 6px 0 2px; }   /* 在设计师节点内，跟随节点缩进，不再额外左移 */
.lane-steps { align-items: flex-start; text-align: left; }

/* 主体标题：左对齐、加重，作为"这个模型的工作量"的小节标题；下方内容挂在它下面 */
.lane-subject {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  padding-bottom: 7px;
  margin-bottom: 5px;
  border-bottom: 1px solid var(--border);
}
.lane-subj-name {
  flex: 0 1 auto;
  min-width: 0;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: #f5f7fc;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lane-subject .lane-prog { display: none; }

/* ——— 角色流程：序号圆圈时间线，从上往下 1→2→3 依次流转 ——— */
.lane-flow { display: flex; flex-direction: column; width: 100%; }
.flow-node {
  position: relative;
  padding: 4px 0 6px 44px;   /* 头像 36 + 间距 8 */
  min-height: 40px;
}
/* 连接线：穿过头像中心连到下一节点 */
.flow-node::before {
  content: "";
  position: absolute;
  left: 17px;
  top: 43px;
  bottom: -6px;
  width: 2px;
  background: var(--border-strong);
}
.flow-node:last-child::before { display: none; }

/* 头像圆圈：放大、跨两行（名字 + 最新动态）；里面是名字，底色按角色 */
.flow-av {
  position: absolute;
  left: 0;
  top: 3px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);                 /* 设计师 */
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--glass-solid) 70%, transparent);
}
.flow-av[data-role="qc"] { background: var(--vision); }
.flow-av[data-role="builder"] { background: var(--warn); color: #2a2410; }
/* 角色头像切图（assets/roles，已去紫边）：撑满圆圈，色环仍按角色区分。
   容器裁圆 + 显式锁 36×36——全局 img 规则会把 height:100% 顶成原比例（36×43 椭圆下坠） */
.flow-av { overflow: hidden; }
.flow-av img { width: 36px; height: 36px; object-fit: cover; object-position: top center;
  border-radius: 50%; display: block; }
/* 悬浮效果：流程节点与结果卡轻抬 */
.flow-node { transition: transform 0.18s ease; }
.flow-node:hover { transform: translateY(-1px); }
/* 走了不止一步的角色卡：整张卡都是展开/收起热区（main.js 里挂在 node 上），给手型提示 */
.flow-node.has-more { cursor: pointer; }

/* 名字行（头像右上） */
.flow-head { display: flex; align-items: center; gap: 6px; min-height: 20px; }
.flow-nm { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-expand {
  flex: none;
  width: 22px; height: 22px;
  border: none; border-radius: 6px;
  background: transparent; color: var(--ink-mute);
  font-size: 10px; cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
.flow-expand[hidden] { display: none; }
.flow-expand:hover { background: var(--surface-2); }

/* 步骤序号（第几步）：半透明白色圆形底，凸显序列感 */
.fs-i {
  flex: none;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: var(--ink-dim);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* 最新一步（头像右下）：一行高的窗口，切换时旧行上滑出、新行下往上滑入 */
.flow-latest {
  position: relative;
  overflow: hidden;
  height: 20px;
  margin-top: 2px;
}
.fl-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 20px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--ink-dim);
  transform: translateY(105%);
  opacity: 0;
  transition: transform var(--dur-3) var(--ease-expo), opacity var(--dur-2) var(--ease);
}
.fl-line.enter { transform: translateY(0); opacity: 1; }
.fl-line.exit { transform: translateY(-105%); opacity: 0; }
.fl-line[data-kind="pass"] .fs-t { color: color-mix(in oklch, var(--ok) 55%, white); }
.fl-line[data-kind="fail"] .fs-t { color: color-mix(in oklch, var(--danger) 60%, white); }
@media (prefers-reduced-motion: reduce) {
  .fl-line { transition: none; }
}

/* 完整步骤（展开才显示；展开时隐藏"最新一步"避免重复） */
.flow-steps { display: none; flex-direction: column; gap: 4px; margin-top: 5px; }
.flow-node.open .flow-steps { display: flex; }
.flow-node.open .flow-latest { display: none; }

/* 开合时内容自己淡入 + 上移就位（卡片高度由 JS 的 animateHeight 补间）。
   不用挂临时类：元素从 display:none 变回显示时，CSS 动画会重新起跑，每次开合都会重播。 */
@keyframes flow-swap-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.flow-node.open .flow-step,
.flow-node:not(.open) .flow-latest {
  animation: flow-swap-in var(--dur-2) var(--ease-expo) both;
}
/* 步骤逐行错开落下；只错开前 6 行，再多就一起来，免得长流程尾巴拖太久 */
.flow-node.open .flow-step:nth-child(2) { animation-delay: 30ms; }
.flow-node.open .flow-step:nth-child(3) { animation-delay: 60ms; }
.flow-node.open .flow-step:nth-child(4) { animation-delay: 90ms; }
.flow-node.open .flow-step:nth-child(5) { animation-delay: 120ms; }
.flow-node.open .flow-step:nth-child(n + 6) { animation-delay: 150ms; }
@media (prefers-reduced-motion: reduce) {
  .flow-node.open .flow-step,
  .flow-node:not(.open) .flow-latest { animation: none; }
}
.flow-step { display: flex; align-items: center; gap: 7px; font-size: 11.5px; line-height: 1.4; color: var(--ink-mute); }
.flow-step[data-kind="pass"] .fs-t { color: color-mix(in oklch, var(--ok) 55%, white); }
.flow-step[data-kind="fail"] .fs-t { color: color-mix(in oklch, var(--danger) 60%, white); }

/* 问题/返工明细挂在节点内 */
.flow-node .lane-issues { margin-top: 6px; }

/* 当前正在干活的员工＝流程里最后一个节点：序号圆圈脉冲 + 名字/最新步提亮 */
:is(.lane.is-working, .lane.show-prog) .flow-node:last-child .flow-av {
  animation: flow-pulse 1.5s var(--ease) infinite;
}
@keyframes flow-pulse {
  0% { box-shadow: 0 0 0 3px color-mix(in oklch, var(--glass-solid) 70%, transparent), 0 0 0 3px color-mix(in oklch, var(--brand) 55%, transparent); }
  70%, 100% { box-shadow: 0 0 0 3px color-mix(in oklch, var(--glass-solid) 70%, transparent), 0 0 0 10px transparent; }
}
:is(.lane.is-working, .lane.show-prog) .flow-node:last-child .flow-latest .fs-t {
  color: color-mix(in oklch, var(--brand) 62%, white);
  font-weight: 600;
}
@media (prefers-reduced-motion: reduce) {
  :is(.lane.is-working, .lane.show-prog) .flow-node:last-child .flow-av { animation: none; }
}

/* 小地图：俯视所有模型 + 相机视角，左下角，点击飞过去/双击看全部 */
#minimap {
  position: fixed;
  left: 16px; bottom: 16px;
  width: 168px; height: 168px;
  border-radius: 12px;
  background: rgba(18, 24, 32, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 20px rgba(0,0,0,0.3);
  backdrop-filter: blur(6px);
  cursor: pointer;
  z-index: 6;
}
/* 手机端底部有收起浮标(#sheet-handle ~60px)，把小地图抬到它上方，避免遮挡 */
@media (max-width: 640px) { #minimap { width: 116px; height: 116px; left: 10px; bottom: 74px; } }

/* 手机端：选中模型的操作条要完整显示、可点。桌面的居中 calc 依赖侧栏宽度，
   手机没有侧栏会算歪，这里重置为：整屏居中、按钮缩小、抬到输入条上方、放不下就换行。
   选中时隐藏小地图，把底部空间让给操作条。 */
@media (max-width: 640px) {
  #toolbar {
    left: 0;
    right: 0;
    margin: 0 auto;            /* 定宽 + 左右 auto 居中，不依赖 transform（避开入场动画覆盖 transform 的坑） */
    transform: none;
    animation: none;
    width: max-content;
    bottom: 78px;
    max-width: calc(100% - 16px); /* 用 100% 而非 100vw：iOS Safari 的 100vw 会略宽于可见区、造成横向溢出 */
    gap: 5px;
    padding: 7px 9px;
    flex-wrap: wrap;
    justify-content: center;
  }
  #toolbar .sel { max-width: 88px; font-size: 12px; }
  #toolbar button { min-width: 34px; min-height: 34px; padding: 6px 8px; font-size: 13px; }
  body.has-selection #minimap { display: none; }
}

/* ============ 加载屏 ============ */
#loading {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #8fc4ea 0%, #bfe0c0 100%);
  transition: opacity 0.5s ease;
}
#loading.done { opacity: 0; pointer-events: none; }
#loading .load-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 34px;
  width: min(78vw, 340px);
}
#loading .load-logo {
  font-size: 56px;
  animation: load-bob 1.1s ease-in-out infinite;
}
@keyframes load-bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-10px) rotate(4deg); } }
#loading .load-title {
  font-size: 22px;
  font-weight: 800;
  color: #2a3b2e;
  letter-spacing: 0.5px;
}
#loading .load-bar {
  width: 100%;
  height: 12px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.15);
}
#loading .load-bar > i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 6px;
  background: linear-gradient(90deg, #e8823a, #f1c40f);
  transition: width 0.25s ease;
}
#loading .load-status {
  font-size: 13px;
  color: #3a4b3e;
  font-variant-numeric: tabular-nums;
}

/* ============ 右上角性能指示 ============ */
#perf {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: var(--z-float);
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(20, 24, 28, 0.62);
  backdrop-filter: blur(6px);
  color: #d8f0d8;
  font: 600 11px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#perf[hidden] { display: none; }
#perf.warn { color: #ffd24a; }
#perf.bad { color: #ff7a6b; }

/* ============ 成本按钮 + 分账弹窗 ============ */
#cost-btn {
  flex: none;
  width: 34px; height: 34px;
  border: none;
  border-radius: var(--r-md);
  background: var(--surface-1);
  color: var(--ink-dim);
  font-size: 16px;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease);
}
#cost-btn:hover { background: var(--surface-2); }

#cost-modal {
  position: fixed; inset: 0; z-index: var(--z-toast);
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: msg-in var(--dur-2) var(--ease) both;
}
#cost-modal .cost-card {
  width: min(88vw, 380px);
  padding: 18px 20px 20px;
  border-radius: var(--r-xl);
  background: var(--glass-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  color: var(--ink);
}
#cost-modal .cost-head { display: flex; align-items: center; justify-content: space-between; font-size: 15px; margin-bottom: 14px; }
#cost-modal .cost-close { border: none; background: var(--surface-2); color: var(--ink-dim); width: 28px; height: 28px; border-radius: 8px; cursor: pointer; font-size: 13px; }
#cost-modal .cost-pie {
  width: 150px; height: 150px; border-radius: 50%;
  margin: 4px auto 16px;
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1px var(--border);
}
#cost-modal .cost-pie span {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--glass-solid);
  display: grid; place-items: center;
  font-size: 15px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#cost-modal .cost-table { width: 100%; border-collapse: collapse; font-size: 12px; font-variant-numeric: tabular-nums; }
#cost-modal .cost-table th { color: var(--ink-mute); font-weight: 500; text-align: right; padding: 5px 4px; border-bottom: 1px solid var(--border); }
#cost-modal .cost-table th:first-child { text-align: left; }
#cost-modal .cost-table td { text-align: right; padding: 6px 4px; border-bottom: 1px solid var(--surface-1); }
#cost-modal .cost-table td:first-child { text-align: left; }
#cost-modal .cost-table tfoot td { font-weight: 700; border-bottom: none; border-top: 1px solid var(--border); }
#cost-modal .cost-dot { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
#cost-modal .cost-reset { margin-top: 14px; width: 100%; padding: 9px; border: 1px solid var(--border); border-radius: var(--r-md); background: transparent; color: var(--ink-mute); font-size: 12px; cursor: pointer; }
#cost-modal .cost-reset:hover { background: var(--surface-1); color: var(--ink-dim); }

/* ---------- 细节编辑：拆解视图 ---------- */
#detail-bar {
  position: fixed; top: calc(12px + env(safe-area-inset-top, 0px)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px; padding: 9px 10px 9px 18px;
  border-radius: 999px; background: rgba(18, 22, 28, 0.86); color: #e8ecf0;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  z-index: 70; font-size: 14px; box-shadow: 0 6px 26px rgba(0, 0, 0, 0.35);
}
#detail-bar #detail-hint { white-space: nowrap; }
#detail-bar #detail-exit {
  padding: 6px 16px; border: none; border-radius: 999px; cursor: pointer;
  background: #e8823a; color: #fff; font-size: 13px; font-weight: 600;
}
#detail-bar #detail-exit:hover { background: #f0995a; }
/* 沉浸态：藏起对话/小地图/工具条等，只留三维 + 顶部条 */
body.detail-mode #minimap,
body.detail-mode #edit-toggle,
body.detail-mode #scene-toggle,
body.detail-mode #scene-menu,
body.detail-mode #scenery-del,
body.detail-mode #undo-bar,
body.detail-mode #toolbar,
body.detail-mode #sheet-handle,
body.detail-mode #perf { display: none !important; }
/* 拆解模式【保留】右侧对话面板:改件的信息流泳道/耗时/token/成本就展示在这里。
   但收起它的输入框与建议行——改件的输入走底部的改件栏,不给两个输入口。 */
body.detail-mode #chat-form,
body.detail-mode #suggestions { display: none !important; }
/* 手机屏太小:拆解时对话抽屉仍整个隐藏(信息流在退出拆解后可回看,历史已入账) */
@media (max-width: 640px) {
  body.detail-mode #chat,
  body.detail-mode #sheet-collapse { display: none !important; }   /* 把手挂在面板外面，得一起藏 */
}

/* 细节编辑：部件名字标签（跟随各部件，纯前端） */
#detail-labels { position: fixed; inset: 0; pointer-events: none; z-index: 65; overflow: hidden; }
#detail-labels .dl {
  position: absolute; transform: translate(-50%, -140%); white-space: nowrap;
  padding: 2px 9px; border-radius: 999px; font-size: 12px; line-height: 1.5;
  background: rgba(18, 22, 28, 0.78); color: #e8ecf0; border: 1px solid rgba(255, 255, 255, 0.12);
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
}
#detail-labels .dl.sel { background: #e8823a; color: #fff; border-color: #fff; font-weight: 600; }

/* 细节编辑：部件级修改输入条 */
#detail-input {
  position: fixed; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; z-index: 70; width: min(560px, calc(100% - 32px));
  background: rgba(18, 22, 28, 0.9); padding: 8px; border-radius: 14px;
  box-shadow: 0 6px 26px rgba(0, 0, 0, 0.4); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
#detail-input input {
  flex: 1; min-width: 0; border: none; border-radius: 9px; padding: 10px 14px;
  background: rgba(255, 255, 255, 0.08); color: #e8ecf0; font-size: 14px; outline: none;
}
#detail-input input::placeholder { color: rgba(232, 236, 240, 0.45); }
#detail-input button {
  border: none; border-radius: 9px; padding: 0 16px; background: #e8823a; color: #fff;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
#detail-input button:disabled { opacity: 0.5; cursor: default; }
/* ID 选择器的 display:flex 会压过浏览器默认的 [hidden]{display:none}，导致 hidden 属性失效、
   这两条一直显示。显式让 hidden 生效——只在进入细节编辑/选中部件时才现身。 */
#detail-bar[hidden], #detail-input[hidden] { display: none !important; }
