/* ==========================================================================
   Gerber 立体查看 —— 视觉基调

   **曝光台 / 对位台**。这个工具干的活本质上只有一件：把图形对到正确的位置上。
   拼板是给每一块小板找对位，Mark 点是给贴片机找对位，坐标量测是把画面上的位置
   读成一个数。所以整套视觉的母题是「对位」：栅格、对位靶、坐标刻度、十字标——
   它们只出现在**真有位置含义**的地方（板原点、指针、选中的那块板），不是花纹。

   底色是石墨蓝的舞台（不是纯黑，也不是中性灰）：栅格与紫光都要落在它上面才不
   发脏。颜色只有四支，每支只承担一个意思，面上永远是灰的：

     紫 --beam   可操作：主按钮、焦点环、当前页签、当前操作的那一层/那一块
     黄 --align  注意：警告、待办、提示
     青 --probe  量出来的数：比例尺、悬停读数、尺寸标注、通过
     红 --alert  错

   灯源取自制板现场真实存在的两种光：曝光台的紫外（紫）与对位显微镜的黄光。
   同族的暖色只留一支黄，所以「注意」和「已选中」共用一个色相并不冲突——它们
   本来就是同一件事：要你看这里。

   唯一一处「发光」是载入新数据时画布上的那一次曝光扫描（.exposure），以及面板
   上的光束发丝线（.bench 的下沿）。别处一律不发光。

   右下角的读数、左下角的比例尺、面板里的单位，都是这台仪器的刻度盘——常驻、
   等宽、带单位、右对齐。少一样，量出来的数就不可信。
   ========================================================================== */

:root {
  color-scheme: dark;

  /* ── 表面：三个台阶 + 两条发丝线 ─────────────────────────────── */
  --ink:        #090c12;   /* 应用底 / 画布底（也 = 三维背景） */
  --film:       #111726;   /* 面板面、板面 */
  --film-2:     #171e30;   /* 次级面：输入框、行悬停 */
  --film-3:     #1e2740;   /* 抬起面：选中行、标签、chip */
  --rule:       #2b3550;   /* 发丝分隔线 */
  --rule-soft:  #1c2436;   /* 更弱的内部分隔线 */

  /* ── 文字：三级，弱的一级也对最亮的面负责（≥4.5） ───────────── */
  --text:       #e7ebf4;
  --text-2:     #b3bdd0;
  --text-3:     #8b95ad;

  /* ── 意义色：一支一个意思 ───────────────────────────────────── */
  --beam:       #7b6bff;   /* 填充色 */
  --beam-hi:    #9b8dff;   /* 上面那支的文字/描边形态 */
  --beam-lo:    #4a3fd0;   /* 暗态：禁用、滚动条 */
  --on-beam:    #0b0716;   /* 落在紫填充上的字 */
  --align:      #ffd166;
  --probe:      #6fd8e8;
  --alert:      #ff5c72;

  /* ── 尺规 ───────────────────────────────────────────────────── */
  --radius:     3px;
  --gut:        14px;
  --panel-w:    272px;
  --read-w:     336px;
  --rail:       46px;      /* 顶栏高度 */
  --float:      rgba(12, 17, 28, .94);   /* 浮层（进度、悬停读数、图例）的底 */
  --lift:       0 18px 44px -16px rgba(0, 0, 0, .85);

  --f-ui: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI",
          "PingFang SC", "Microsoft YaHei", sans-serif;
  --f-num: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas,
           monospace;
}

*, *::before, *::after { box-sizing: border-box; }

/* hidden 属性必须能压过组件自身的 display（例如 .switch 的 inline-flex），
   否则「未进入立体视图时隐藏展开/旋转控件」这类逻辑会失效 */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: var(--text);
  font-family: var(--f-ui);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* 键盘焦点。**不许省**：整个界面是按钮与输入框堆起来的，焦点看不见就等于
   键盘不可用。用亮一档的紫 + 一圈同色的外晕，在深底上任何一处都找得到。 */
:focus-visible {
  outline: 2px solid var(--beam-hi);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ── 顶栏 ─────────────────────────────────────────────────────────── */

.bench {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: var(--rail);
  padding: 0 var(--gut);
  background: var(--film);
  flex: 0 0 auto;
}

/* 下沿那道光束：在标识底下最亮、往右衰减到没有。它同时是这一栏的分隔线，
   所以不留 border——两条线会差半个像素，屏幕上看得出来。 */
.bench::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg,
    var(--beam) 0%, rgba(123, 107, 255, .42) 22%,
    rgba(123, 107, 255, .10) 52%, var(--rule) 100%);
  pointer-events: none;
}

.mark { display: flex; align-items: center; gap: 10px; }

/* 标识就是一枚**对位靶标**（fiducial）：外圈 + 内圈 + 十字 + 中心点。
   这个工具帮你摆的就是这种标记，拿它当标识是拿本行当的东西当标识。 */
.mark-glyph {
  width: 20px; height: 20px;
  display: block;
  color: var(--beam);
  flex: 0 0 auto;
}
.mark-glyph .ring { stroke: currentColor; stroke-width: 1.4; fill: none; }
.mark-glyph .ring-in { stroke: var(--beam-hi); stroke-width: 1.4; fill: none; }
.mark-glyph .cross { stroke: currentColor; stroke-width: 1.3; }
.mark-glyph .core { fill: var(--beam-hi); }
/* 载入时外圈自己画一圈（0.9 s），像一次曝光扫过。整套界面只有这一处和
   画布上那次扫描是「无人操作也动」的动效，其余动效都只回应操作。
   54.03 这个数不是编的：外圈半径 8.6，周长 2π·8.6 = 54.03——它必须与 SVG 里那个
   `r` 对得上，不然扫到一半就停住或者先画满再等一圈。 */
.mark-glyph .ring {
  stroke-dasharray: 54.03;
  animation: ring-draw .9s cubic-bezier(.3, .7, .3, 1) both;
}
@keyframes ring-draw {
  from { stroke-dashoffset: 54.03; opacity: .25; }
  to   { stroke-dashoffset: 0;     opacity: 1; }
}

.mark-text {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.005em;
}

.bench-actions { display: flex; align-items: center; gap: 8px; }

/* ── 按钮 ─────────────────────────────────────────────────────────── */

.btn {
  font: inherit;
  font-size: 12.5px;
  padding: 6px 13px;
  border-radius: var(--radius);
  border: 1px solid var(--rule);
  background: var(--film-2);
  color: var(--text);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover:not(:disabled) {
  background: var(--film-3);
  border-color: #3a4568;
}
.btn:disabled { opacity: .38; cursor: not-allowed; }
.btn:active:not(:disabled) { background: #131a2c; }

.btn-beam {
  background: var(--beam);
  border-color: var(--beam);
  color: var(--on-beam);
  font-weight: 600;
}
.btn-beam:hover:not(:disabled) {
  background: var(--beam-hi);
  border-color: var(--beam-hi);
}
.btn-beam:active:not(:disabled) { background: var(--beam-lo); border-color: var(--beam-lo); }

.btn-ghost { background: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--film-2); }
.btn-tiny { padding: 3px 9px; font-size: 11.5px; }

/* 已激活的开关型按钮：靠紫色描边 + 极淡的底表示「当前生效」，
   不靠填充抢视线——这一栏里真正要抢视线的是画布。 */
.btn-on {
  background: rgba(123, 107, 255, .14);
  border-color: var(--beam);
  color: var(--beam-hi);
}
.btn-on:hover:not(:disabled) {
  background: rgba(123, 107, 255, .20);
  border-color: var(--beam-hi);
}

/* 文件投放区：虚线边框即「待投放」的语义 */
.drop {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 6px 13px;
  border: 1px dashed #3a4568;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-2);
  transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.drop:hover, body[data-drag="on"] .drop {
  border-color: var(--beam-hi);
  color: var(--text);
  background: rgba(123, 107, 255, .08);
}
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ── 三栏舞台 ─────────────────────────────────────────────────────── */

.stage {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--read-w);
  min-height: 0;
}

.panel { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.panel-stack { border-right: 1px solid var(--rule); background: var(--film); }
.panel-read  { border-left: 1px solid var(--rule); background: var(--film); }

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 8px;
  padding: 11px var(--gut) 9px;
  border-bottom: 1px solid var(--rule-soft);
}
.panel-head h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0;
}
.panel-note {
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-3);
}
/* 面板头右侧那一组（计数 + 按钮）：`space-between` 只有两个子元素时才好看，
   三个会把计数顶到中间。 */
.panel-head-side { display: flex; align-items: center; gap: 8px; }

/* ── 叠层剖面 ─────────────────────────────────────────────────────── */

/* 剖面按真实厚度等比例堆叠（仅整体缩放），铜箔薄、介质厚一目了然 */
.xsec {
  padding: 12px var(--gut);
  border-bottom: 1px solid var(--rule-soft);
  background: var(--film-2);
}
.xsec-strip {
  display: flex;
  flex-direction: column-reverse;  /* 自下而上堆叠，与板面朝上的直觉一致 */
  height: 132px;
  border: 1px solid var(--rule);
  border-radius: 2px;
  overflow: hidden;
  background: var(--ink);
}
.xsec-seg {
  position: relative;
  min-height: 1px;
  transition: filter .12s ease;
  cursor: default;
}
.xsec-seg[data-kind="copper"]   { background: linear-gradient(90deg, #b56232, #d98c4e); }
.xsec-seg[data-kind="soldermask"] { background: #1f5c33; }
.xsec-seg[data-kind="paste"]    { background: #5c5c5c; }
.xsec-seg[data-kind="silk"]     { background: #cdc9c0; }
.xsec-seg[data-kind="core"]     { background: #2b2f24; }
.xsec-seg[data-kind="profile"]  { background: #4a3b2a; }
.xsec-seg[data-kind="mechanical"] { background: #333a40; }
.xsec-seg.is-dim { filter: brightness(.42) saturate(.4); }
.xsec-seg.is-hot { filter: brightness(1.45); }

.xsec-legend {
  display: flex; justify-content: space-between;
  margin-top: 7px;
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--text-3);
}

/* ── 图层列表 ─────────────────────────────────────────────────────── */

.stack { overflow-y: auto; padding: 6px 0 12px; }

.layer {
  display: grid;
  grid-template-columns: 3px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 7px var(--gut) 7px 0;
  border-bottom: 1px solid var(--rule-soft);
  cursor: pointer;
  transition: background .1s ease;
}
.layer:hover { background: var(--film-2); }
.layer.is-hot { background: var(--film-2); }
.layer.is-off .layer-name,
.layer.is-off .layer-file { color: var(--text-3); }
.layer.is-off .layer-chip { opacity: .25; }

/* 正被「只看这一层」的那一行。**只动颜色与字重，不动任何尺寸**：列表一行都不该
   因为可见性变化而挪位——点一次行、下一行就换了位置的话，第二次点击会落到别处。
   用紫（可操作）而不是黄：它是「你正在操作的对象」，不是一句提醒。 */
.layer.is-solo { background: var(--film-2); }
.layer.is-solo .layer-name { color: var(--beam-hi); font-weight: 600; }
.layer.is-solo .layer-chip { box-shadow: 0 0 0 1px var(--beam); }

.layer-chip { width: 3px; align-self: stretch; border-radius: 1px; }

.layer-name {
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.layer-file {
  display: block;
  font-family: var(--f-num);
  font-size: 10.5px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.layer-eye {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--text-3);
  background: none;
  cursor: pointer;
  font-size: 12px;
}
.layer-eye:hover { color: var(--text); border-color: var(--rule); }

/* ── 画布 ─────────────────────────────────────────────────────────── */

.panel-view { background: var(--ink); }

.tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 7px var(--gut) 0;
  border-bottom: 1px solid var(--rule);
  background: var(--film);
}
.tabs-right { margin-left: auto; display: flex; align-items: center; gap: 12px; padding-bottom: 6px; }

.tab {
  font: inherit;
  font-size: 12.5px;
  padding: 6px 12px 7px;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-3);
  cursor: pointer;
  margin-bottom: -1px;
  transition: color .12s ease, border-color .12s ease;
}
.tab:hover { color: var(--text-2); }
.tab.is-on { color: var(--text); border-bottom-color: var(--beam); }

.tabs-sub { padding-top: 0; }
.tabs-sub .tab { padding: 9px 11px 8px; font-size: 12px; }

.switch {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-3);
}
.switch input[type="range"] { width: 84px; accent-color: var(--beam); }
.switch input[type="checkbox"] { accent-color: var(--beam); }

.canvas-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; }
#canvas-2d { display: block; width: 100%; height: 100%; cursor: crosshair; }
/* 人工修正的覆盖层：与主画布逐像素重合，只画编辑态的东西。
   pointer-events:none 让指针事件全部落到下面的主画布上——交互只有一处处理。
   不设 z-index，靠 DOM 顺序压在 #canvas-2d 之上、在进度浮层（z-index 6）之下。 */
.edit-overlay { position: absolute; inset: 0; pointer-events: none; }
#canvas-3d { position: absolute; inset: 0; }
/* canvas 必须贴合容器，否则会按绘制缓冲的像素尺寸撑开版面 */
#canvas-3d canvas { display: block; width: 100%; height: 100%; }

/* ── 悬停十字标 ───────────────────────────────────────────────────────
   量位置是这个工具的核心动作，所以指针处给的是一条**贯穿画布的十字丝**
   （量测台/显微镜就是这么读的），而不是跟着指针飘的一张小卡。
   两根线是 .canvas-wrap 的两个伪元素，位置由 --hx / --hy 两个自定义属性驱动
   （app.js 在既有的 hover 回调里顺手写这两个值，不为它单开一条事件链）。
   只在指针真的落在画布上时才亮：body[data-reticle="on"]。 */
.canvas-wrap::before,
.canvas-wrap::after {
  content: "";
  position: absolute;
  z-index: 5;
  pointer-events: none;
  background: rgba(155, 141, 255, .38);
  opacity: 0;
  transition: opacity .12s ease;
}
.canvas-wrap::before { left: var(--hx, 0px); top: 0; bottom: 0; width: 1px; }
.canvas-wrap::after  { top: var(--hy, 0px); left: 0; right: 0; height: 1px; }
body[data-reticle="on"] .canvas-wrap::before,
body[data-reticle="on"] .canvas-wrap::after { opacity: 1; }

/* ── 曝光扫描 ─────────────────────────────────────────────────────────
   载入/换一批数据时，一条紫光从左到右扫过一次（.6 s），扫完自己消失。
   一次数据只扫一次：它交代的是「画面上的东西刚刚换过了」——拖着看、缩放、
   切换图层都不会触发它，否则这条光就成了背景噪音。 */
.exposure {
  position: absolute; inset: 0;
  z-index: 7;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(90deg,
    transparent 0%,
    rgba(123, 107, 255, .08) 34%,
    rgba(155, 141, 255, .34) 50%,
    rgba(123, 107, 255, .08) 66%,
    transparent 100%);
  transform: translateX(-105%);
}
.exposure.is-firing { animation: exposure-sweep .62s cubic-bezier(.22, .61, .36, 1) 1 both; }
@keyframes exposure-sweep {
  0%   { opacity: 0; transform: translateX(-105%); }
  14%  { opacity: 1; }
  86%  { opacity: 1; }
  100% { opacity: 0; transform: translateX(105%); }
}

/* WebGL 给不出来时的占位说明。空画布看起来就像卡住了，所以原因写在画布正中间，
   而不是只留在底部状态条上。 */
.view-note {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; padding: 24px; text-align: center;
  font-size: 12.5px; line-height: 1.7; color: var(--text-3);
}
.view-note p { margin: 0; max-width: 46ch; }
.view-note-lead { color: var(--align); font-size: 13.5px; }

/* 走软件渲染（Canvas2D）时的角标。**故意做得比 .view-note 小得多**：那种情况立体图
   是画得出来的，只是慢，所以不该拿一块盖住画面的说明去说它「不可用」。左下角一小条，
   点一下才展开那几条出路——常驻的东西要小，但「想让立体图变快」怎么办不能不给。 */
.view-badge {
  position: absolute; left: 10px; bottom: 10px; z-index: 5;
  max-width: min(52ch, 62%);
  font-size: 11.5px; line-height: 1.65; color: var(--text-3);
  background: var(--float);
  border: 1px solid var(--rule); border-radius: var(--radius);
  backdrop-filter: blur(6px);
}
.view-badge-lead {
  display: block; width: 100%; text-align: left;
  padding: 6px 9px; background: none; border: 0;
  font: inherit; color: var(--align); cursor: pointer;
}
.view-badge-lead::after { content: ' ▾'; }
.view-badge.is-open .view-badge-lead::after { content: ' ▴'; }
.view-badge-body { padding: 0 9px 8px; max-height: 44vh; overflow-y: auto; }
.view-badge-body p { margin: 0 0 6px; }
.view-badge-body p:last-child { margin-bottom: 0; }

/* ── 人工修正工具条 ───────────────────────────────────────────────── */

/* 独立一行而不是塞进 tabs-right：那里已经有四个控件，再放六个按钮会挤成一团，
   而「改元件」这组操作与「看」的开关是两类事，分开也更好找。 */
.edit-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 var(--gut) 8px;
  border-bottom: 1px solid var(--rule);
  background: var(--film);
}
.edit-sep { width: 1px; height: 15px; background: var(--rule); margin: 0 3px; }
#edit-load-label { display: inline-flex; align-items: center; }
.edit-note {
  margin-left: auto;
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 「还没装封装库」那条。复用 .edit-bar 的骨架（同一位置、同一高度），只把颜色
   换成提醒色——它和修正工具条永远不会同时出现（一个只在平面页、一个只在立体页）。
   文案不省略号截断：整条提示的意义就是那句话必须被读到。 */
.edit-bar-warn { border-bottom-color: var(--align); }
.models-bar-text {
  font-size: 12px;
  line-height: 1.5;
  color: var(--align);
  white-space: normal;
}
/* 把按钮推到右边。用不着 .edit-note 那句 margin-left:auto（那是给单行读数用的），
   文字会换行，靠一个弹性占位更稳。 */
.models-bar-fill { flex: 1 1 auto; }

.empty {
  position: absolute; inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  padding: 0 40px;
  pointer-events: none;
}
/* 第一眼看到的就是这一句，所以它是整套界面里唯一一处显示级的排版：
   大字、紧字距、字重 600。左侧那道短紫线是「待投放」的对位标记。 */
.empty-lead {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.25;
  color: var(--text);
}
.empty-lead::before {
  content: "";
  display: block;
  width: 28px; height: 2px;
  margin: 0 auto 14px;
  background: var(--beam);
}
.empty-hint {
  margin: 0 auto;
  font-size: 12px;
  color: var(--text-3);
  max-width: 46ch;
  line-height: 1.75;
}
body:not([data-state="empty"]) .empty { display: none; }

/* ── 图元类型图例 ─────────────────────────────────────────────────── */

/* 按类型着色时的配色说明。放在左下角、紧挨比例尺之上：
   这两个东西服务于同一件事——把画面上的颜色和尺寸读成信息。 */
.type-legend {
  position: absolute;
  left: 14px;
  bottom: 34px;
  display: grid;
  gap: 3px;
  padding: 9px 11px;
  background: var(--float);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  font-size: 11px;
  line-height: 1.5;
  z-index: 4;
  pointer-events: none;
}
.type-legend-title {
  margin-bottom: 5px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--rule-soft);
  font-size: 10.5px;
  color: var(--text-2);
}
.type-legend-row {
  display: grid;
  grid-template-columns: 9px 1fr auto;
  align-items: center;
  gap: 8px;
}
.type-legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 2px;
}
.type-legend-count {
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--text-3);
  text-align: right;
}

/* ── 进度 ─────────────────────────────────────────────────────────── */

/* 分析大板时唯一需要占住视线的东西：说清在做什么、还剩多少 */
.progress {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 64px));
  padding: 18px 20px 15px;
  background: var(--float);
  backdrop-filter: blur(8px);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--lift);
  z-index: 6;
}
.progress-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 11px;
}
.progress-track {
  height: 3px;
  border-radius: 2px;
  background: var(--film-3);
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--beam-lo), var(--beam), var(--beam-hi));
  box-shadow: 0 0 12px -2px rgba(123, 107, 255, .9);
  transition: width .18s ease;
}
/* 导出 PDF 那一路每几毫秒就写一次宽度，上面那 0.18s 的缓动**永远追不上**：每次写都把
   过渡重新起一个头，画出来的宽度始终落在真值后面，最后收遮罩时还差一大截（看着就是
   「走到九成就没了」）。流式那一路关掉缓动，让它一格一格如实跳。 */
.progress[data-stream] .progress-bar { transition: none; }
.progress-detail {
  margin-top: 9px;
  min-height: 1.4em;
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 无法给出百分比的等待（例如立体几何的单次布尔运算）：来回扫动的光带 */
.progress[data-mode="indeterminate"] .progress-bar {
  width: 32%;
  animation: indeterminate 1.15s ease-in-out infinite;
}
@keyframes indeterminate {
  0%   { transform: translateX(-115%); }
  100% { transform: translateX(330%); }
}

/* 悬停读数：贴着指针的浮动标签。等宽、表格数字、单位齐全——
   它是量出来的数，就按量的规矩排。 */
.hover-readout {
  position: absolute;
  pointer-events: none;
  padding: 6px 10px;
  background: var(--float);
  backdrop-filter: blur(6px);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--probe);
  border-radius: 2px;
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  line-height: 1.6;
  white-space: pre;
  color: var(--text);
  z-index: 5;
}

/* ── 读数面板 ─────────────────────────────────────────────────────── */

.read-body { overflow-y: auto; padding: 12px var(--gut) 20px; }

.group + .group { margin-top: 18px; }
.group-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
  margin: 0 0 7px;
}

.kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  font-size: 12px;
}
/* 标签要整串不折：`1fr` 轨道的最小尺寸是 dt 的 min-content，而中文标签的 min-content
   就是**一个字**——右边的读数一长（「上 0.000 / 下 0.000 / 左 0.000 / 右 0.000 mm」），
   轨道就被挤到一个字宽、标签竖排成一条。nowrap 之后让不掉的是标签，轮到 dd 折行，
   所以 dd 得允许任意断词；`.pp-sel-kv` 照这一份抄（见「选中」那一节的注释）。 */
.kv dt { color: var(--text-3); white-space: nowrap; }
.kv dd {
  margin: 0;
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  text-align: right;
  color: var(--text);
  overflow-wrap: anywhere;
}

.table { width: 100%; border-collapse: collapse; font-family: var(--f-num); font-size: 11px; }
.table th {
  text-align: left;
  font-weight: 500;
  color: var(--text-3);
  border-bottom: 1px solid var(--rule);
  padding: 4px 6px 4px 0;
  position: sticky; top: 0;
  background: var(--film);
}
.table td { padding: 3px 6px 3px 0; border-bottom: 1px solid var(--rule-soft); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 2px;
  font-size: 10.5px;
  font-family: var(--f-num);
}
.tag-pass { background: rgba(111, 216, 232, .16); color: var(--probe); }
.tag-warn { background: rgba(255, 209, 102, .15); color: var(--align); }
.tag-fail { background: rgba(255, 92, 114, .16); color: var(--alert); }
.tag-mute { background: var(--film-3); color: var(--text-3); }

.note {
  margin: 9px 0 0;
  padding: 8px 10px;
  border-left: 2px solid var(--rule);
  background: var(--film-2);
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--text-2);
}
.note.warn { border-left-color: var(--align); }
.note.alert { border-left-color: var(--alert); }
.note.ok { border-left-color: var(--probe); }

/* ── 状态条 ───────────────────────────────────────────────────────── */

/* 仪器铭牌：等宽、分段、段间一道细竖线。分隔符是**结构**（哪几段是同一类读数），
   不是装饰，所以用竖线而不是居中的点。 */
.strip {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 0;
  border-top: 1px solid var(--rule);
  background: var(--film);
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--text-3);
  flex: 0 0 auto;
  overflow: hidden;
}
.strip-item {
  padding: 0 var(--gut);
}
/* 段与段之间一道细竖线。中间那个 .strip-spacer 也是 span，所以判据用
   :not(:first-child)（按元素位置）而不是相邻兄弟——相邻兄弟遇上游标就断了。 */
.strip-item:not(:first-child) {
  border-left: 1px solid var(--rule-soft);
}
.strip-spacer { flex: 1 1 auto; }
.strip-warn { color: var(--align); }

/* 载入中的进度细线 */
body[data-state="busy"] .strip::after {
  content: "";
  position: absolute; left: 0; bottom: 0; height: 1px; width: 34%;
  background: linear-gradient(90deg, transparent, var(--beam), transparent);
  animation: sweep 1.1s linear infinite;
}
@keyframes sweep {
  from { transform: translateX(-100%); }
  to   { transform: translateX(340%); }
}

/* ── 拼板页 ───────────────────────────────────────────────────────── */

/* 左栏与右栏各是「两套内容二选一」：叠层 / 拼板参数、读数 / 检查。
   两套各是一个 .aside-view，同一时刻只有一个是可见的。**不另加 <aside>**——
   main.stage 是三列网格，多一个兄弟节点会被挤到第二行去；而按 grid-column
   手工摆位又会在自适应断点里多出一套要同步的规则。 */
.aside-view { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
#canvas-2d, #canvas-panel { display: block; width: 100%; height: 100%; cursor: crosshair; }

/* ── 参数表（panelform.js 生成的那棵 DOM） ────────────────────────── */

.panel-form { overflow-y: auto; padding: 10px 0 20px; }

.pf-group { padding: 0 var(--gut) 4px; }
.pf-group + .pf-group {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--rule-soft);
}
.pf-group-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-2);
}
.pf-group-note, .pf-note {
  margin: 3px 0 0;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-3);
}

/* 说明文字里的着重与代码记号（``panelform.withEmphasis`` 生成的 <b> / <code>）。
   记号本身——星号、双反引号——不该印在屏幕上，但不能只是把字加粗了事：11px 的
   次级色正文里「加粗」几乎看不出来，所以 <b> 连色阶一起提一级。 */
.pf-group-note b, .pf-note b { font-weight: 600; color: var(--text-2); }
.pf-group-note code, .pf-note code {
  font-family: var(--f-num);
  font-size: 10.5px;
  color: var(--text-2);
  background: var(--film-2);
  padding: 0 3px;
  border-radius: 2px;
}

/* 一行三项：标签 | 输入 | 单位。没有单位时那一列是空的，不影响对齐。 */
.pf-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}
.pf-label { font-size: 12px; color: var(--text-2); }
.pf-unit {
  font-family: var(--f-num);
  font-size: 10.5px;
  color: var(--text-3);
}
.pf-input {
  justify-self: end;
  width: 92px;
  font: inherit;
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  text-align: right;
  padding: 4px 7px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--film-2);
  color: var(--text);
  transition: border-color .12s ease, background .12s ease;
}
.pf-input:hover { border-color: #3a4568; }
.pf-input:focus { outline: none; border-color: var(--beam); background: var(--film-3); }
.pf-check { width: 15px; height: 15px; accent-color: var(--beam); padding: 0; }

/* 当前这一档用不上的项：「变灰」而不是「藏起来」。值仍会提交，藏起来的话
   用户根本不知道有这一项、也不知道它现在算不算数（见 panelform.js 文件头）。 */
.pf-row.pf-off .pf-label, .pf-row.pf-off .pf-unit { opacity: .45; }
.pf-row.pf-bad .pf-input { border-color: var(--alert); }
.pf-error { margin: 3px 0 0; font-size: 11px; line-height: 1.5; color: var(--alert); }
.pf-error:empty { display: none; }

/* ── 检查栏 ───────────────────────────────────────────────────────── */

/* 「读数」一栏复用 .kv / .group-title 那套（见「读数面板」一节）：
   两处读数是同一类东西，样式也应当只有一处。 */

.pp-toggle {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 7px;
  margin-top: 7px;
  font-size: 12px;
  color: var(--text-2);
  cursor: pointer;
}
.pp-check { width: 14px; height: 14px; accent-color: var(--beam); }
.pp-toggle-count {
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  color: var(--text-3);
}

.pp-issues { list-style: none; margin: 8px 0 0; padding: 0; }
.pp-issue {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 7px;
  margin-bottom: 6px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-2);
}
/* 出处标签：「参数 / 拼板 / 分板 / 工艺标记 / 导出」——用户据此知道该看哪一块。
   拼板参数的问题与导出层才发现的问题长得一样，不标出来就要靠自己猜。 */
.pp-source {
  height: fit-content;
  font-family: var(--f-num);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 2px;
  white-space: nowrap;
  background: var(--film-3);
  color: var(--text-3);
}
.pp-issue.pp-error .pp-source { background: rgba(255, 92, 114, .16); color: var(--alert); }
.pp-issue.pp-warn .pp-source { background: rgba(255, 209, 102, .15); color: var(--align); }

/* 导出按钮占满一栏：它是这一页的终点，不该和旁边的小按钮抢不到点击 */
.pp-export { width: 100%; margin-top: 2px; }

/* ── 选中：逐块换角度 / 换面 ───────────────────────────────────────── */

/* 这一栏的读数与「读数」栏是同一类东西，排版也就该只有一处——所以照 .kv 抄一份，
   而不是另起一套观感。用不同的类名是因为「读数」那一栏要能被唯一定位到
   （测试按类名取第一个 ``.kv``）。 */
.pp-sel-kv {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 12px;
  margin: 0;
  font-size: 12px;
}
.pp-sel-kv dt { color: var(--text-3); white-space: nowrap; }
.pp-sel-kv dd {
  margin: 0;
  font-family: var(--f-num);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  text-align: right;
  color: var(--text);
  overflow-wrap: anywhere;
}

/* 逐块那一眼。行与行之间只用一道细线分隔：这里要的是「一眼扫过去」，不是卡片。 */
.pp-sel-list { list-style: none; margin: 9px 0 0; padding: 0; }
.pp-sel-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  padding: 4px 0;
  border-top: 1px solid var(--rule-soft);
  font-size: 11.5px;
}
.pp-sel-place { color: var(--text-3); }
.pp-sel-value { font-family: var(--f-num); font-variant-numeric: tabular-nums; text-align: right; }
.pp-sel-pin { grid-column: 1 / -1; font-size: 10.5px; color: var(--text-3); }
.pp-sel-more { padding-top: 5px; font-size: 11px; color: var(--text-3); }

.pp-sel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
}
.pp-sel-label { min-width: 30px; font-size: 11px; color: var(--text-3); }
.pp-sel-actions .btn-tiny { padding: 3px 8px; }

/* ── 自适应 ───────────────────────────────────────────────────────── */

@media (max-width: 1180px) {
  :root { --panel-w: 224px; --read-w: 286px; }
}
@media (max-width: 940px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto minmax(0,1fr) auto; }
  .panel-stack { border-right: 0; border-bottom: 1px solid var(--rule); max-height: 232px; }
  .panel-read { border-left: 0; border-top: 1px solid var(--rule); max-height: 260px; }
}

/* 少动一点。**不是把动效关掉**：这里的几处动效都在交代「什么变了」，只是不再
   沿时间铺开——曝光扫描与靶标画圈改成瞬时完成，悬停与焦点仍然立刻可见。 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}
