/* arcam web UI（GitHub Pages 版） — 原生 CSS，零依赖。
 * tokens 与组件规格来自 docs/WEB-STYLE.md（挖掘自 sess_0312ae9e）：
 * 深浅色跟随系统 prefers-color-scheme，不写死颜色；反渐变/反阴影/反玻璃拟态。
 * 布局与本地 webui/ 逐字同构（左输入/右预览两栏，<900px 上下堆叠），
 * 仅删掉 LiDAR 专属的 .env-box（Pages 版无深度帧）。 */

/* ── [hidden] 兜底（v1.12.1 必修）────────────────────────────────────────
 * 作者样式在同权重下优先于 UA 样式，所以 .kind-modal{.kind-modal 的 display:flex}
 * 会把 UA 的 [hidden]{display:none} 盖掉 —— 靠 hidden 属性切换可见性的元素全部
 * 常驻可见：kind-modal 从进站就盖住整页（用户点不到任何上传区，"卡在全身/半身
 * 弹窗"）、row-edge-bar 在贴地模式也该藏、model3dRow/pose3dRow/live-row/zoom-cell
 * 在没模型/没开相机时同样如此。!important 是让属性选择器赢过 class 的标准做法。
 * ⚠ 新组件只要同时用 hidden 属性和 display 规则，就依赖这条兜底——别删。 */
[hidden] { display: none !important; }

:root {
  color-scheme: light dark; /* 让原生下拉/复选/滚动条也跟随系统（WEB-STYLE §2） */
  --bg: #ffffff;
  --surface: #fafafa;
  --text: #1a1a1a;
  --muted: #666666;
  --hint: #777777;
  --border: #d0d0d0;
  --input-bg: #ffffff;
  --input-border: #bbbbbb;
  --input-fg: #1a1a1a;
  --btn-bg: #f5f5f5;
  --btn-bg-hover: #e8e8e8;
  --btn-border: #444444;
  --accent: #2563eb;
  --danger: #b3261e;
  --ok: #0a7a2f;
  --info: #555555;
  --label-fg: #333333;
  --inline-fg: #444444;
  --ctrl-h: 34px;
  --gap: 12px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --surface: #171b21;
    --text: #e7e9ee;
    --muted: #9aa2ae;
    --hint: #8b939e;
    --border: #2f353f;
    --input-bg: #1b1f26;
    --input-border: #3b4351;
    --input-fg: #e7e9ee;
    --btn-bg: #232935;
    --btn-bg-hover: #2d3441;
    --btn-border: #4a5261;
    --accent: #6ea8ff;
    --danger: #f87171;
    --ok: #4ade80;
    --info: #97a0ad;
    --label-fg: #c9cfd9;
    --inline-fg: #b9c0cb;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
}

#app {
  max-width: 1100px; /* 两栏工具页版心（WEB-STYLE 的 860px 是单栏文档页建议，此处放宽） */
  margin: 24px auto;
  padding: 0 16px;
}

/* ---------- 顶栏（格式对齐 forjiang-crypto：h1 20px / .sub 13px muted + 20px 下边距） ---------- */
#topbar h1 {
  margin: 0 0 4px;
  font-size: 20px;
}
#app-sub {
  /* ⚠ 与 forjiang-crypto 的 .sub 逐字同规格：margin-bottom: 20px。
     grid 的 gap 不作用于 header 与 main 之间，副标题下边距为 0 时行盒直接
     贴住卡片上沿——字体度量差异（更高的行盒/descender）会让卡片边框削到
     文字底部（用户实报的「文字有遮挡」）。20px 与 crypto 页同频。 */
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- 卡片（WEB-STYLE §4：1px 边框 / 6px 圆角 / 14px 16px 内边距 / 卡片间 16px） ---------- */
#layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr;
  gap: var(--gap);
  align-items: start;
}
.col, #panel-params, #footer > * {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--bg);
}
.col h2, #panel-params h2 {
  margin: 0 0 10px;
  font-size: 15px;
}

/* ---------- 上传区（input 同款规格；拖拽高亮只换边框色） ---------- */
.drop-zone {
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: var(--input-bg);
  color: var(--input-fg);
  padding: 6px 8px;
  margin-bottom: 10px;
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drop-zone.drag { border-color: var(--accent); }
.drop-zone strong { font-size: 13px; }
.dz-hint { font-size: 12px; color: var(--hint); }
.dz-name { font-size: 12px; color: var(--accent); word-break: break-all; }
.dz-name.empty { color: var(--hint); }

.hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--hint);
  min-height: 16px;
}
.hint:empty { min-height: 0; margin: 0; }

/* ---------- 按钮（WEB-STYLE §4：34px 高 / 0 18px / 灰系，无填充色大按钮） ---------- */
.btn-row { display: flex; gap: var(--gap); flex-wrap: wrap; align-items: center; }
button {
  font-family: inherit;
  height: var(--ctrl-h);
  padding: 0 18px;
  font-size: 13px;
  color: var(--text);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 4px;
  cursor: pointer;
}
button:hover { background: var(--btn-bg-hover); }

/* ---------- 预览（日志区同款边框/底色，WEB-STYLE §4） ---------- */
.canvas-wrap {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: var(--gap);
}
#preview-canvas { max-width: 100%; max-height: 62vh; display: block; }
/* 拖拽摆位：抓手光标 + 禁掉触屏滚动手势（少了 touch-action，手机上拖动会被
   浏览器平移/刷新整个页面吃掉，pointermove 一个都收不到） */
#preview-canvas { cursor: grab; touch-action: none; }
#preview-canvas:active { cursor: grabbing; }

/* scene.json 与日志区同规格：等宽 12.5px / pre-wrap / 断行 */
#scene-json {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.4;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- 参数面板（WEB-STYLE §4 输入框规格） ---------- */
#param-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px var(--gap);
}
.param-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
}
.param-row label { font-size: 13px; color: var(--label-fg); }
.param-row .val { font-size: 12px; color: var(--muted); }
.param-row input[type="number"],
.param-row select {
  font-family: inherit;
  width: 100%;
  height: var(--ctrl-h);
  padding: 6px 8px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--input-fg);
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 4px;
}
/* 滑块参考里没有：按 WEB-STYLE §4 推导做法——34px 高 + accent-color 跟随主题 */
.param-row input[type="range"] {
  width: 100%;
  height: var(--ctrl-h);
  accent-color: var(--accent);
}
.param-row-check {
  grid-template-columns: 1fr auto;
  align-items: center;
}
/* 行内勾选标签文字取 --inline-fg（WEB-STYLE §2 的该 token 用途） */
.param-row-check label { color: var(--inline-fg); }
.param-row-check input { accent-color: var(--accent); width: 16px; height: 16px; }

/* ---------- 状态条 ---------- */
#footer { display: flex; flex-direction: column; }
#status-bar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  font-size: 13px;
  color: var(--info);
}
#status-bar .spacer { flex: 1; }
#status-msg.ok { color: var(--ok); }
#status-msg.error { color: var(--danger); }
#status-time {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--muted);
}
#local-chip {
  font-size: 12px;
  color: var(--label-fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 10px;
  white-space: nowrap;
}

#scene-details { font-size: 13px; }
#scene-details summary { cursor: pointer; color: var(--muted); margin-bottom: 8px; }
#scene-json { margin: 0; max-height: 320px; overflow: auto; }
#scene-json:empty { display: none; }

/* ---------- 响应式：<900px 两栏上下堆叠（同本地 webui） ---------- */
@media (max-width: 900px) {
  #layout { grid-template-columns: 1fr; }
  #preview-canvas { max-height: 48vh; }
  #local-chip { display: none; }
}

/* ---------- 实时相机层（FEATURE-SPEC §4） ---------- */
/* #stage 是视频/HUD/预览三层的定位容器：HUD 浮层要绝对覆盖在预览上 */
#stage { position: relative; }
#cam-video {
  position: absolute; inset: 0; width: 100%; height: 100%;
  object-fit: cover; z-index: 0; background: #000;
}
#preview-canvas { position: relative; z-index: 1; }
#hud-canvas {
  position: absolute; inset: 0; width: 100%; height: 100%;
  z-index: 2; pointer-events: none;          /* 浮层不吃指针事件 */
}
#live-row { align-items: center; gap: 12px; }
.zoom-cell { display: inline-flex; align-items: center; gap: 8px; }
.zoom-cell input[type="range"] { width: 140px; }

/* 拖动提示（原版 TIP_MS=3600 / TIP_FADE=600，index.html:2519-2540） */
.tip {
  position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%);
  background: rgba(0, 0, 0, .78); color: #fff; font-size: 13px;
  padding: 6px 14px; border-radius: 999px; z-index: 3; pointer-events: none;
  max-width: 80%; text-align: center;
}

/* ---------- 效果开关（光影/HUD 复选框网格，与本地 webui 逐字同规格） ---------- */
.check-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; margin: 10px 0;
}
.check-grid .chk {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text); cursor: pointer;
}
.check-grid .chk input { accent-color: var(--accent); width: 15px; height: 15px; }

/* ---------- 修图折叠区（原版折叠区，index.html:242-246） ---------- */
.fold { margin-top: 14px; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.fold > summary { cursor: pointer; font-weight: 600; color: var(--text); }
.fold > .fold-tip { font-size: 12px; color: var(--muted); margin: 8px 0 10px; }
.fold .btn-row { margin: 0; }

/* ---------- 全屏取景（stage 推入 fullscreen 后：黑底 + 画布撑满视口） ---------- */
#stage:fullscreen { background: #000; display: flex; align-items: center; justify-content: center; }
#stage:fullscreen #preview-canvas { max-width: 100vw; max-height: 100vh; }
#stage:fullscreen #hud-canvas { max-width: 100vw; max-height: 100vh; }
#stage:fullscreen #cam-video { max-width: 100vw; max-height: 100vh; }
#stage:fullscreen .tip { bottom: 48px; }

/* ---------- 3D 立绘折叠区（C1；上游 index.html:258-306 / 1508-1710） ---------- */
/* 选中态：只换字色 + 边框色（原版 .btns .on 的克制版，不填充） */
.fold button.on { color: var(--accent); border-color: var(--accent); }
/* 切换模型时的进行态：等 M3D.switchModel/dropModel 那一下 */
.fold button[data-busy] { opacity: .55; cursor: progress; }
/* 行标题（模型 / 姿势）：12px muted，跟 .hint 同规格但不当提示 */
.fold .sub { font-size: 12px; color: var(--hint); margin: 10px 0 4px; }
/* 参数滑条行：标签 + 滑块 + 读数一行（原版 .row，minmax 让滑块可压缩） */
.d3d-row {
  display: grid;
  grid-template-columns: minmax(64px, auto) 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.d3d-row label { font-size: 13px; color: var(--label-fg); }
.d3d-row input[type="range"] { width: 100%; height: var(--ctrl-h); accent-color: var(--accent); }
.d3d-row .val { font-size: 12px; color: var(--muted); min-width: 44px; text-align: right; }
/* 3D 面板的报错（note.3dFail / note.3dDrawFail）：红字，跟状态条同一 token */
.hint.error { color: var(--danger); }

/* ---------- 全身/半身弹窗（index.html:443-460） ---------- */
.kind-modal {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
}
.kind-card {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 20px 22px; max-width: 420px; margin: 0 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.kd-title { font-weight: 700; font-size: 15px; margin: 0 0 8px; }
.kd-tip { font-size: 13px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }

/* 语言开关钮（右上角，原版 #lang） */
.lang-btn {
  position: absolute; top: 14px; right: 16px;
  border: 1px solid var(--border); background: var(--btn-bg, #fff);
  color: var(--text); border-radius: 8px; padding: 4px 10px;
  font-size: 13px; cursor: pointer;
}
.lang-btn:hover { background: var(--btn-bg-hover, #f3f4f6); }
#topbar { position: relative; }

/* 取景框读数（原版 frameRead，index.html:355）——选完画幅就知道出图裁到多大。
   与本地 webui 逐字同规格：docs/index.html:267 有这个 span、app.js 的
   updateFrameRead 每帧刷它，少了这条规则会掉回正文 13px/正文色（v1.9.0 审计补）。 */
.frame-read {
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
