/* 05 面《作图》的两张 SVG 图纸。viewBox 用 mm 作单位，所以这里的字号、
   线宽都是毫米数；不并进 sheets.css 是因为那文件改动频繁，单独一份好回滚。 */

.dwg { display: block; width: 100%; height: auto; max-height: 62vh; }
.dwg-empty { padding: 28px 4px; text-align: center; font-size: 12.5px; color: #94a3b8; }

/* 原理图符号 —— 线宽按 KiCad 默认值：本体/引脚 10mil(0.254)，导线 6mil(0.1524)，文字 50mil(1.27) */
.sw-body { fill: #fff; stroke: #334155; stroke-width: 0.254; }
.sw-pin { stroke: #334155; stroke-width: 0.254; }
.sw-pwr { stroke-width: 0.254; stroke: #b45309; }
.sw-num { font-size: 0.9px; fill: #64748b; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sw-name { font-size: 1.0px; fill: #0f172a; }
/* 位号与块标题给一个"屏幕像素下限"：拉近时按 mm 走（和 KiCad 一样跟着图放大），
   拉到整页时不再缩成 4 像素的渣 —— 没有这个下限，"一次看全图"和"看得清字"只能二选一。
   脚号/脚名/标称值不给下限：它们按 2.54mm 排，一旦放大必撞（去耦排六个 100nF 会糊成一条）。 */
.sw-ref { font-size: max(1.27px, calc(10px * var(--u, 0.18))); font-weight: 600; fill: #0f172a; }
.sw-label { font-size: 1.27px; fill: #334155; }

/* PCB 封装 */
.sw-pad { fill: #16a34a; fill-opacity: .5; stroke: #15803d; stroke-width: .06; }
.sw-bot { fill: #2563eb; fill-opacity: .28; stroke: #1d4ed8; }
.sw-hole { fill: #fff; stroke: #475569; stroke-width: .06; }
.sw-padnum { font-size: .85px; fill: #0f172a; text-anchor: middle; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.sw-body-out { fill: none; stroke: #94a3b8; stroke-width: .06; stroke-dasharray: .5 .4; }

.sw-part { font-size: 1.05px; fill: #64748b; }

/* 整张原理图（几何由 /eda/analyze 返回，这里只管画法） */
.dwg-full { min-width: 680px; max-height: none; }
.sw-paper { fill: #fff; stroke: none; }
.sw-net { fill: none; stroke: #0e7c99; stroke-width: .1524; stroke-linecap: round; stroke-linejoin: round; }
.sw-net-pwr { fill: none; stroke: #b45309; stroke-width: .1524; stroke-linecap: round; }
.sw-rail { fill: none; stroke: #475569; stroke-width: .1524; stroke-linecap: round; }
.sw-gndsym { fill: none; stroke: #475569; stroke-width: .2; stroke-linecap: round; }
.sw-pwrsym { fill: none; stroke: #b45309; stroke-width: .2; stroke-linecap: round; }
.sw-pwrsym-bar { stroke: #b45309; stroke-width: .4; stroke-linecap: round; }
.sw-bar { stroke: #b45309; stroke-width: .254; stroke-linecap: round; }
.sw-raillabel { font-size: 1.27px; fill: #b45309; font-weight: 600; paint-order: stroke; stroke: #fff; stroke-width: .45px; }
/* 二端器件的标准图形 */
.sw-glyph { stroke: #334155; stroke-width: .254; stroke-linecap: round; }
.sw-glyph-fill { fill: #334155; stroke: #334155; stroke-width: .12; }
.sw-glyph-fill0 { fill: none; stroke: #334155; stroke-width: .16; }
.sw-arrow { stroke: #0f9d6b; stroke-width: .12; }
.sw-junction { fill: #0f172a; }
/* 没连线的引脚：淡灰短桩，保留"这是一颗 48 脚的芯片"的信息，又不抢视线 */
.sw-off { stroke: #b7c4cf; stroke-width: .12; }
.sw-offt { fill: #aab7c2; }
.lod-0 .sw-off, .lod-1 .sw-offt { display: none; }
.sw-end { fill: none; stroke: #64748b; stroke-width: .1; }
.sw-dot { fill: #0e7c99; }
.sw-dot-pwr { fill: #b45309; }
/* 网络名标签：KiCad local label 的六边形牌（左边平、右边尖），牌体就是连接线的一部分 */
.sw-tag { stroke-width: .2; stroke-linejoin: round; fill-opacity: .28; }
.sw-netlabel { font-size: 1.27px; font-weight: 600; paint-order: stroke; stroke-width: .4px; stroke-linejoin: round; }
.sw-halo { paint-order: stroke; stroke: #fff; stroke-width: .5px; stroke-linejoin: round; }
.sw-halo-box { fill: #fff; fill-opacity: .82; stroke: none; }
.sw-title-box { fill: #fff; stroke: #cbd5e1; stroke-width: .12; }
.sw-title-t { font-size: 1.6px; font-weight: 600; fill: #0f172a; }
.sw-title-s { font-size: 1.05px; fill: #64748b; }

/* ---- 交互查看器（draw.js + src/ui/schematic-svg.mjs） ---- */
/* 视口高度固定，缩放/平移都改 viewBox，不动 DOM 尺寸 */
.sheet-wrap {
  height: clamp(360px, 62vh, 720px);
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  background: radial-gradient(120% 90% at 50% 0%, #fff 0%, #fbfdfe 60%, #f4f8fa 100%);
}
.sheet-wrap.grabbing { cursor: grabbing; }
.sheet-wrap svg { display: block; width: 100%; height: 100%; outline: none; }

/* 图纸是这一面的主角，可 DOM 里 JSON 输入框排在它前面 —— 实测 1280×800 的容器里
   图纸顶边在 866px，打开时整张图都在首屏之外（要滚过标题+说明+204px 的输入框才看见）。
   这里只换视觉次序：DOM、tab 顺序、init() 的查询都不动。 */
.dwg-flow { display: flex; flex-direction: column; }
.dwg-flow [data-stage] { order: 1; margin-top: .75rem; }
.dwg-flow [data-input] { order: 2; }
.dwg-flow > details { order: 3; }
/* 顶部留白也收一下，并把图纸高度钉在"chrome 之外的剩余空间"里：
   1280×800 实测改前图纸顶边 866px（整张图在首屏外），收完是 226px、整块可见；
   窗口矮的时候图纸自己缩，不会把工具条挤出屏幕。
   写在 draw.css 而不是换 Tailwind 类名：pt-9/mt-3 这类新名字不重新构建就不存在于 tw.gen.css。 */
.dwg-flow { padding-top: 2rem; padding-bottom: 4rem; }
@media (min-width: 1024px) { .dwg-flow { padding-top: 2.25rem; } }
/* 这一面的主角是图纸，不是标题。真面板只有 724px 宽：44px 的标题折两行 +
   2.05 倍行距的导语九行，图纸顶边被推到 579px，再怎么算高度都在首屏外。
   字距收一档（只作用于这一面），图纸才真的落在眼睛前面。 */
.dwg-flow > h1 { margin-top: 1rem; font-size: 26px; line-height: 1.28; }
.dwg-flow > [data-d="lead"] { margin-top: .7rem; font-size: 13.5px; line-height: 1.75; }
.dwg-flow .sheet-wrap { height: max(300px, min(clamp(360px, 62vh, 720px), calc(100vh - 340px))); }

/* 导线底衬：交叉处先垫一圈白，线交叉就不会糊成一坨 */
.sw-net-halo { fill: none; stroke: #fff; stroke-width: .52; stroke-linecap: round; stroke-linejoin: round; opacity: .75; }
/* 拖线用的透明粗命中区（看得见的是 .sw-net，点得到的是它） */
.sw-hit { stroke: transparent; stroke-width: 1.8; fill: none; }
.sw-net-g, .sw-flag-g, .sw-netlabel-g { cursor: move; }
.sw-part-g { cursor: move; }

/* 栅格（可选开关） */
.sw-grid { fill: none; stroke: #e6eef2; stroke-width: .06; }
.sw-grid-bg { pointer-events: none; }

/* 功能块：虚线框 + 标题，先认块再认线 */
.sw-block-box { fill: #f7fbfc; fill-opacity: .5; stroke: #b9ccd4; stroke-width: .1; stroke-dasharray: 1.6 1.1; }
.sw-block-title { font-size: max(1.9px, calc(12px * var(--u, 0.18))); fill: #6b8494; font-weight: 600; }
/* 字描一层白边再压上去：块标题常落在上一块器件的正下方，
   没有这圈光晕时"复位 R2 S1"会被 C8/Y1 的引线切成两截，一眼读不出是标题。 */
.sw-block-title, .sw-ref, .sw-part { paint-order: stroke; stroke: #fff; stroke-width: .55; stroke-linejoin: round; }

/* 搜索/点选：命中的加粗，其余压淡而不是删掉（删了图就"缺件"） */
.is-dim { opacity: .15; }
.is-hit .sw-net, .is-soft .sw-net { stroke-width: .34; }
/* 悬停比"选中"轻一档：只加粗，不染色，免得鼠标扫过整张图就花 */
.is-soft .sw-net { stroke-width: .42; }
/* 小地图：`tools/check-classes.mjs` 查到 markup 里的 right-2/top-2/p-0.5/shadow-sm/
   backdrop-blur-[1px]/sm:block 这六个工具类**不在构建期的 tw.gen.css 里**
   （新类名不重新构建就不存在），于是它一直是 display:none —— 提示语却在说"点右上角小地图"。
   位置与外观改由这里给，窄屏仍然藏起来。 */
[data-minimap] {
  position: absolute;
  right: .5rem;
  top: .5rem;
  padding: 2px;
  display: none;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: rgba(255, 255, 255, .9);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .14);
  cursor: pointer;
  touch-action: none;
}
@media (min-width: 640px) { [data-minimap] { display: block; } }

/* 悬停读数钉住宽度：网络名可以很长（SPI_MISO / 3V3 这种），
   工具条一旦被撑高，图纸顶边就变、sizeSheet 又得重算 —— 不该靠那个循环。 */
.dwg-readout { max-width: 40ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-hit .sw-netlabel { text-decoration: underline; }

/* 细节层级：远处先藏脚号脚名，拉近才出现 —— 48 只脚的名字一起糊上去就是"乱"。
   lod-1（适应视图）留脚名藏脚号：读图的人先要"PA13/PB6"这种功能名，
   引脚序号是查网表用的，2.54mm 一行里它最挤也最没人看。
   没连线的脚在 lod-0/1 整条不画：48 只脚里 34 只悬空，那些灰短桩就是
   "主控是一根长满刺的空柱子"的来源，缩略图上它不携带任何信息。 */
.lod-0 .sw-num, .lod-0 .sw-name, .lod-0 .sw-part, .lod-0 .sw-raillabel { display: none; }
.lod-0 .sw-off, .lod-1 .sw-off { display: none; }
.lod-1 .sw-num { display: none; }
/* 位号在 lod-0/lod-1 本身已经看得清（有屏幕像素下限），块标题再念一遍就是重影；
   而且标题带上位号后宽度会顶到隔壁块，所以只在拉近到 lod-2 时才显示。 */
.lod-0 .sw-blk-refs, .lod-1 .sw-blk-refs { display: none; }

/* 全图缩略图：只表达"哪里有器件 + 现在看的是哪一块"，
   132px 宽里画导线只会糊成一团，所以线一根都不画。 */
.mini-sheet { fill: #fff; stroke: #cbd5e1; stroke-width: .6; }
.mini-part { fill: #7f97a8; fill-opacity: .6; }
.mini-two { fill: #c3d0d9; fill-opacity: .8; }
.mini-view { fill: #0e7c99; fill-opacity: .12; stroke: #0e7c99; stroke-width: 1; }

textarea.is-over { border-color: #0e7c99; background: #f0f7fa; }
