:root {
  --c-measured: #f2b544;
  --c-finite: #3fd0c0;
  --c-ideal: #a98bff;
  --c-gold: #ffc94d;
  --c-pos: #ef4b4b;
  --c-neg: #3b82f0;
  --font: "PingFang SC", "HarmonyOS Sans SC", "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --num-font: "SF Pro Text", "Inter", "PingFang SC", system-ui, sans-serif;
  --radius: 12px;
  --side-w: 430px;
  --plot-h: 330px;
}

[data-theme="dark"] {
  --bg: #080c18;
  --bg-2: #0d1324;
  --panel: #111a2e;
  --panel-2: #16213a;
  --line: rgba(160, 185, 230, 0.12);
  --line-2: rgba(160, 185, 230, 0.22);
  --ink: #e9eef9;
  --ink-2: #aab5cf;
  --ink-3: #7784a3;
  --stage: radial-gradient(1200px 700px at 30% 20%, #16244a 0%, #0b1226 55%, #070b17 100%);
  --btn: #1a2542;
  --btn-h: #22305a;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg: #eef1f6;
  --bg-2: #e6eaf2;
  --panel: #ffffff;
  --panel-2: #f5f7fb;
  --line: rgba(30, 45, 80, 0.1);
  --line-2: rgba(30, 45, 80, 0.2);
  --ink: #18223a;
  --ink-2: #4a5775;
  --ink-3: #75819c;
  --stage: radial-gradient(1200px 700px at 30% 20%, #1c2c55 0%, #111a33 60%, #0b1122 100%);
  --btn: #eef2f9;
  --btn-h: #e2e8f4;
  --shadow: 0 10px 30px rgba(20, 30, 60, 0.12);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 14px; -webkit-font-smoothing: antialiased; }
body.resizing { cursor: grabbing; user-select: none; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- 顶栏 ---------- */
.topbar {
  display: flex; align-items: center; gap: 18px; padding: 10px 18px;
  border-bottom: 1px solid var(--line); background: var(--bg-2);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand b { display: block; font-size: 15px; letter-spacing: 0.02em; }
.brand small { color: var(--ink-3); font-size: 12px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: conic-gradient(from 210deg, var(--c-pos), var(--c-gold), var(--c-finite), var(--c-neg), var(--c-ideal), var(--c-pos));
  box-shadow: inset 0 0 0 8px var(--bg-2);
}
.layer-tabs { display: flex; gap: 6px; margin: 0 auto; background: var(--panel); padding: 4px; border-radius: 12px; border: 1px solid var(--line); }
.layer-tab {
  display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 8px 16px; border-radius: 9px;
  cursor: pointer; color: var(--ink-2); font-weight: 600; white-space: nowrap;
}
.layer-tab i { width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 25%, transparent); }
.layer-tab:hover { background: var(--btn); color: var(--ink); }
.layer-tab[aria-selected="true"] { background: var(--btn-h); color: var(--ink); box-shadow: inset 0 -2px 0 var(--c-active, var(--c-gold)); }
.top-links { display: flex; gap: 8px; align-items: center; }
.link-btn { text-decoration: none; padding: 7px 12px; border-radius: 9px; background: var(--btn); border: 1px solid var(--line); font-size: 13px; white-space: nowrap; cursor: pointer; }
.link-btn:hover { background: var(--btn-h); }
.link-btn.ghost { background: transparent; }
.icon-btn { width: 34px; height: 34px; border-radius: 9px; border: 1px solid var(--line); background: var(--btn); cursor: pointer; }

/* ---------- 情境条 ---------- */
.scenebar { display: flex; align-items: center; gap: 14px; padding: 8px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.scene-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.scene-chip {
  border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 7px; color: var(--ink-2); font-weight: 500;
}
.scene-chip svg { width: 22px; height: 22px; }
.scene-chip:hover { color: var(--ink); border-color: var(--line-2); }
.scene-chip[aria-checked="true"] { color: var(--ink); border-color: var(--c-active, var(--c-gold)); background: var(--panel-2); box-shadow: 0 0 0 1px var(--c-active, var(--c-gold)) inset; }
.scene-info { color: var(--ink-3); font-size: 13px; flex: 1; min-width: 160px; }
.scene-info b { color: var(--ink); font-weight: 600; }
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; cursor: pointer; color: var(--ink-2); font-weight: 600; white-space: nowrap; }
.seg button:hover:not(:disabled) { color: var(--ink); }
.seg button[aria-checked="true"], .seg button.on { background: var(--btn-h); color: var(--ink); }
.seg button:disabled { opacity: 0.38; cursor: not-allowed; }

/* ---------- 工作区 ---------- */
.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) 10px var(--side-w);
  height: calc(100vh - 116px); min-height: 600px; padding: 12px 12px 4px 12px; gap: 0;
}
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.stage-view { position: relative; flex: 1; min-height: 0; background: var(--stage); }
.view-host { position: absolute; inset: 0; }
.field2d-canvas, .scene3d-canvas { position: absolute; inset: 0; display: block; touch-action: none; outline: none; }
.field2d-canvas:focus-visible { box-shadow: inset 0 0 0 2px var(--c-gold); }
.identity-badge {
  position: absolute; top: 10px; left: 10px; z-index: 3; display: flex; align-items: center; gap: 8px;
  padding: 6px 12px 6px 10px; border-radius: 10px; background: rgba(8, 12, 24, 0.8); backdrop-filter: blur(6px);
  color: #f2f5fc; font-weight: 700; font-size: 13.5px; border: 1px solid rgba(255, 255, 255, 0.12); max-width: min(360px, calc(100% - 440px));
}
.identity-badge > div { min-width: 0; }
.identity-badge i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 30%, transparent); }
.identity-badge small { display: block; color: #c3cde3; font-weight: 500; font-size: 12px; margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage-note {
  /* 本视图说明：切换视图时弹出几秒，之后收进右上角“ⓘ 说明”按钮，不长期遮住坐标 */
  position: absolute; left: 12px; bottom: 12px; z-index: 6; max-width: min(560px, calc(100% - 130px)); display: none;
  padding: 9px 14px 9px 34px; border-radius: 10px; background: rgba(8, 12, 24, 0.9); color: #e8edf8; font-size: 13px; line-height: 1.6;
  border: 1px solid rgba(255, 201, 77, 0.35); box-shadow: 0 8px 26px rgba(0, 0, 0, 0.4); pointer-events: none;
}
.stage-note::before { content: "ⓘ"; position: absolute; left: 12px; top: 8px; color: var(--c-gold); font-weight: 800; }
.stage-note.pop { display: block; }
.stage-tools { position: absolute; top: 12px; right: 12px; z-index: 4; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; max-width: 60%; }
.tool-btn, .toggle-group button {
  border: 1px solid rgba(255, 255, 255, 0.14); background: rgba(10, 15, 30, 0.72); color: #e8edf8; padding: 6px 10px; border-radius: 8px;
  cursor: pointer; font-size: 12.5px; backdrop-filter: blur(6px); white-space: nowrap;
}
.tool-btn:hover, .toggle-group button:hover { background: rgba(30, 42, 75, 0.9); }
.tool-btn.active { border-color: var(--c-gold); color: var(--c-gold); }
.toggle-group { display: flex; gap: 4px; }
.toggle-group button[aria-pressed="false"] { color: #8894b0; text-decoration: line-through; text-decoration-color: rgba(255, 255, 255, 0.25); }
.toggle-group button[aria-pressed="true"] { border-color: rgba(255, 201, 77, 0.45); }
.busy { position: absolute; inset: auto 0 0 0; margin: auto; top: 0; width: 260px; height: 44px; display: flex; align-items: center; justify-content: center; gap: 10px; background: rgba(8, 12, 24, 0.8); color: #dde5f5; border-radius: 12px; z-index: 5; }
.busy span { width: 14px; height: 14px; border: 2px solid var(--c-finite); border-top-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.stage-empty {
  position: absolute; left: 50%; bottom: 58px; transform: translateX(-50%); z-index: 4; width: min(560px, calc(100% - 32px));
  background: rgba(10, 15, 30, 0.9); border: 1px solid rgba(242, 181, 68, 0.45); border-radius: 12px; padding: 12px 14px; color: #e9eef9;
  display: flex; flex-direction: column; gap: 6px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}
.stage-empty b { color: var(--c-measured); font-size: 14px; }
.stage-empty span { font-size: 12.5px; color: #c3cde3; line-height: 1.6; }
.stage-empty .btn { color: #e9eef9; background: #1a2542; border-color: rgba(255, 255, 255, 0.16); }
.stage-empty .btn.primary { background: var(--c-gold); color: #1b1606; }
.seg button.na { opacity: 0.55; }
.probe-tip {
  position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none; opacity: 0; transition: opacity 0.12s;
  background: rgba(8, 12, 24, 0.9); color: #eef2fa; border: 1px solid rgba(255, 255, 255, 0.12); border-radius: 6px; padding: 4px 7px;
  font-size: 11.5px; line-height: 1.4; width: max-content; max-width: min(260px, calc(100% - 16px)); font-family: var(--num-font);
}
.probe-tip small { display: inline; color: #b8c5dd; font-size: 10.5px; margin-right: 7px; }
.probe-tip b { display: inline; font-size: 11.5px; font-weight: 600; }
.probe-tip span { display: block; color: #c9d4ea; }
.probe-tip em { display: block; font-style: normal; color: var(--c-measured); margin-top: 2px; }

.label-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.lbl { position: absolute; left: 0; top: 0; color: #eef3fc; font-size: 12.5px; font-weight: 600; white-space: nowrap; text-shadow: 0 0 3px rgba(0, 0, 0, 0.95), 0 1px 2px rgba(0, 0, 0, 0.95); font-family: var(--num-font); }
.lbl.axis { background: rgba(6, 10, 22, 0.55); padding: 0 4px; border-radius: 4px; }
.lbl.axis-title { font-weight: 700; font-size: 13.5px; color: #ffffff; background: rgba(6, 10, 22, 0.66); padding: 1px 6px; border-radius: 5px; }
.lbl.note { color: #d3dcef; font-size: 12px; font-weight: 500; background: rgba(8, 12, 24, 0.66); padding: 2px 7px; border-radius: 6px; }
.lbl.sec { color: var(--c-gold); font-weight: 800; font-size: 14px; }
.lbl.charge { font-size: 16px; font-weight: 800; }
.lbl.charge.pos { color: #ffb3b3; }
.lbl.charge.neg { color: #b3d1ff; }

/* ---------- 色标 ---------- */
.colorbar-host { position: absolute; right: 14px; top: 64px; bottom: 48px; z-index: 3; width: 78px; pointer-events: none; }
.colorbar { position: relative; height: 100%; max-height: 360px; pointer-events: auto; }
.cb-title { color: #f2f5fc; font-size: 13px; font-weight: 700; text-align: left; margin-bottom: 6px; line-height: 1.2; text-shadow: 0 1px 2px rgba(0, 0, 0, 0.9); }
.cb-sub { display: block; font-weight: 500; color: #c4cee4; font-size: 11px; }
.cb-bar { position: absolute; left: 0; top: 34px; bottom: 0; width: 18px; padding: 0; border: 1px solid rgba(255, 255, 255, 0.35); border-radius: 6px; cursor: pointer; background: none; overflow: visible; }
.cb-bar:focus-visible { outline: 2px solid var(--c-gold); outline-offset: 2px; }
.cb-grad { position: absolute; inset: 0; border-radius: 5px; }
.cb-hint { position: absolute; left: 50%; bottom: -22px; transform: translateX(-50%); font-size: 10.5px; color: #cfd8ea; white-space: nowrap; background: rgba(8, 12, 24, 0.7); padding: 1px 6px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, 0.12); }
.cb-bar:hover .cb-hint { color: var(--c-gold); border-color: var(--c-gold); }
.cb-ticks { position: absolute; left: 24px; top: 34px; bottom: 0; right: 0; }
.cb-ticks span { position: absolute; left: 0; transform: translateY(50%); color: #f2f5fc; font-size: 12px; font-weight: 600; font-family: var(--num-font); text-shadow: 0 0 3px rgba(0, 0, 0, 0.95), 0 1px 2px rgba(0, 0, 0, 0.95); }
.cb-ticks span::before { content: ""; position: absolute; left: -6px; top: 50%; width: 4px; height: 1px; background: rgba(255, 255, 255, 0.7); }
.cb-pop { position: absolute; right: 0; top: 30px; width: 250px; background: #0e1528; border: 1px solid rgba(255, 255, 255, 0.14); border-radius: 12px; padding: 6px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5); z-index: 10; }
.cb-opt { display: flex; gap: 10px; align-items: center; padding: 7px 8px; border-radius: 8px; cursor: pointer; color: #e8edf8; outline: none; }
.cb-opt:hover, .cb-opt:focus { background: #1b2748; }
.cb-opt[aria-selected="true"] { box-shadow: inset 0 0 0 1px var(--c-gold); }
.cb-sw { width: 72px; height: 14px; border-radius: 4px; flex: none; }
.cb-txt b { display: block; font-size: 13px; }
.cb-txt small { color: #9eabc8; font-size: 11px; }

/* ---------- 底部控制条 ---------- */
.control-strip { display: flex; flex-wrap: wrap; gap: 10px 22px; padding: 10px 14px; border-top: 1px solid var(--line); background: var(--panel); align-items: center; }
.cgroup { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cg-title { font-size: 12px; color: var(--ink-3); font-weight: 600; letter-spacing: 0.04em; }
.chip-row { display: flex; gap: 5px; flex-wrap: wrap; }
.chip-row button, .btn {
  border: 1px solid var(--line-2); background: var(--btn); padding: 6px 11px; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: 13px; white-space: nowrap;
  transition: background 0.12s, transform 0.08s;
}
.chip-row button:hover, .btn:hover { background: var(--btn-h); }
.chip-row button:active, .btn:active { transform: translateY(1px); }
.chip-row button.on { border-color: var(--c-gold); color: var(--c-gold); }
.chip-row button.soft { font-weight: 500; color: var(--ink-2); }
.chip-row button:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary { background: var(--c-gold); color: #1b1606; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.06); background: var(--c-gold); }
.btn.danger { color: #ff8b8b; }
.btn.small { padding: 4px 8px; font-size: 12px; }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.check.small { font-size: 12px; }
.section-toggle { min-height: 40px; padding: 7px 11px; border: 2px solid #3684d8; border-radius: 8px; background: var(--btn); color: var(--ink); font-weight: 700; }
.section-toggle input { width: 18px; height: 18px; margin: 0; accent-color: #0b63c7; }
.section-toggle strong { font-size: 11px; font-weight: 500; }
.section-toggle:has(input:checked) { background: #0b63c7; border-color: #0b63c7; color: #fff; }
.section-toggle:focus-within { outline: 2px solid var(--ink); outline-offset: 3px; }
.sec-readout { font-family: var(--num-font); font-size: 12px; color: var(--ink-3); }
.param { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--ink-2); }
.param input[type="range"] { width: 120px; accent-color: var(--c-gold); }
.param input[type="number"], .field input, .field select, select.sel {
  width: 78px; padding: 5px 7px; border-radius: 7px; border: 1px solid var(--line-2); background: var(--bg-2); font-family: var(--num-font);
}
select.sel { width: auto; }
.param .unit { color: var(--ink-3); font-size: 12px; }
.param b { color: var(--ink); font-family: var(--num-font); }
.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.stepper button { border: 0; background: var(--btn); padding: 5px 10px; cursor: pointer; font-weight: 700; }
.stepper button:hover { background: var(--btn-h); }
.stepper output { padding: 0 10px; font-family: var(--num-font); min-width: 70px; text-align: center; }

/* ---------- 分隔条 ---------- */
.splitter-v { cursor: col-resize; position: relative; touch-action: none; outline: none; }
.splitter-v::after { content: ""; position: absolute; left: 3px; top: 50%; width: 4px; height: 44px; margin-top: -22px; border-radius: 3px; background: var(--line-2); }
.splitter-v:hover::after, .splitter-v.dragging::after, .splitter-v:focus-visible::after { background: var(--c-gold); }
.splitter-h { height: 12px; cursor: row-resize; position: relative; touch-action: none; flex: none; outline: none; }
.splitter-h::after { content: ""; position: absolute; top: 4px; left: 50%; width: 44px; height: 4px; margin-left: -22px; border-radius: 3px; background: var(--line-2); }
.splitter-h:hover::after, .splitter-h.dragging::after, .splitter-h:focus-visible::after { background: var(--c-gold); }
.layout-reset { display: flex; justify-content: flex-end; padding: 0 14px; }
.layout-reset .link-btn { font-size: 12px; padding: 4px 10px; color: var(--ink-3); }

/* ---------- 右侧 ---------- */
.side { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.plot-card, .panel-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.plot-card { height: var(--plot-h); display: flex; flex-direction: column; flex: none; min-height: 200px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 12px 4px; }
.card-head h3 { margin: 0; font-size: 14px; }
.head-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.mini { border: 1px solid var(--line-2); background: var(--btn); border-radius: 6px; padding: 2px 8px; cursor: pointer; font-size: 12px; }
.mini:hover { background: var(--btn-h); }
.plot-host { position: relative; flex: 1; min-height: 0; margin: 0 6px; }
.plot-canvas { position: absolute; inset: 0; touch-action: none; }
.plot-foot { margin: 0; padding: 4px 12px 8px; color: var(--ink-3); font-size: 11.5px; line-height: 1.45; }
.panel-card { flex: 1; min-height: 160px; overflow: hidden; display: flex; flex-direction: column; }

/* 面板内容 */
.ptabs { display: flex; gap: 2px; padding: 8px 8px 0; border-bottom: 1px solid var(--line); flex: none; overflow-x: auto; }
.ptab { border: 0; background: transparent; padding: 8px 12px; border-radius: 8px 8px 0 0; cursor: pointer; color: var(--ink-3); font-weight: 600; white-space: nowrap; position: relative; }
.ptab[aria-selected="true"] { color: var(--ink); background: var(--panel-2); }
.ptab .dot { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px; background: var(--btn-h); font-size: 11px; color: var(--ink-2); }
.ptab .dot.warn { background: #ff9f43; color: #1b1206; }
.pbody { padding: 12px 14px 16px; overflow: auto; flex: 1; min-height: 0; }
.pbody h4 { margin: 14px 0 8px; font-size: 13px; color: var(--ink); }
.pbody h4:first-child { margin-top: 0; }
.pbody p { margin: 6px 0; line-height: 1.6; color: var(--ink-2); font-size: 13px; }
.muted { color: var(--ink-3) !important; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 13px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; font-family: var(--num-font); }
.callout { border-left: 3px solid var(--c, var(--c-gold)); background: var(--panel-2); padding: 8px 10px; border-radius: 0 8px 8px 0; font-size: 12.5px; line-height: 1.6; color: var(--ink-2); margin: 8px 0; }
.callout.warn { --c: #ff9f43; }
.callout.bad { --c: #ff5d5d; }
.callout.ok { --c: #5ed39a; }
.callout b { color: var(--ink); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row + .row { margin-top: 8px; }
.field { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--ink-3); }
.field input, .field select { width: 100%; font-size: 13px; color: var(--ink); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
textarea.paste { width: 100%; min-height: 80px; border-radius: 8px; border: 1px solid var(--line-2); background: var(--bg-2); padding: 8px; font-family: var(--num-font); font-size: 12.5px; }
details.fold { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin: 10px 0; background: var(--panel-2); }
details.fold summary { cursor: pointer; font-weight: 600; font-size: 13px; }

/* 测点表 */
.ptable { width: 100%; border-collapse: collapse; font-size: 12.5px; font-family: var(--num-font); }
.ptable th { text-align: left; color: var(--ink-3); font-weight: 600; padding: 5px 4px; border-bottom: 1px solid var(--line); position: sticky; top: -12px; background: var(--panel); z-index: 1; }
.ptable td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.ptable tr { cursor: pointer; }
.ptable tr:hover td { background: var(--panel-2); }
.ptable tr.sel td { background: color-mix(in srgb, var(--c-gold) 14%, transparent); }
.ptable tr.excl td { opacity: 0.55; }
.ptable tr.sub td:first-child { padding-left: 14px; }
.ptable input { width: 58px; padding: 3px 5px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg-2); font-family: var(--num-font); font-size: 12.5px; }
.badge { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; font-weight: 600; background: var(--btn-h); color: var(--ink-2); white-space: nowrap; }
.badge.fit { background: rgba(94, 211, 154, 0.16); color: #5ed39a; }
.badge.hold { background: rgba(123, 92, 255, 0.2); color: #b9a6ff; }
.badge.excl { background: rgba(255, 93, 93, 0.16); color: #ff8b8b; }
.badge.warn { background: rgba(255, 159, 67, 0.18); color: #ffb86b; }
.badge.demo { background: rgba(255, 201, 77, 0.2); color: var(--c-gold); }
.src-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: -1px; margin-right: 4px; border: 1.5px solid rgba(0, 0, 0, 0.6); }
.src-dot.ring { background: transparent; border-width: 3px; }
.iconb { border: 0; background: transparent; cursor: pointer; padding: 2px 5px; border-radius: 5px; color: var(--ink-3); font-size: 13px; }
.iconb:hover { background: var(--btn-h); color: var(--ink); }

.statbar { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 4px 0 10px; }
.stat { background: var(--panel-2); border-radius: 9px; padding: 7px 9px; border: 1px solid var(--line); }
.stat b { display: block; font-size: 17px; font-family: var(--num-font); }
.stat small { color: var(--ink-3); font-size: 11px; }

.empty { text-align: center; padding: 18px 10px; color: var(--ink-3); border: 1px dashed var(--line-2); border-radius: 10px; font-size: 13px; line-height: 1.7; }

/* 颜色—电势表 */
.cmap { width: 100%; border-collapse: collapse; font-size: 13px; }
.cmap td, .cmap th { padding: 6px 4px; border-bottom: 1px solid var(--line); text-align: left; }
.cmap th { color: var(--ink-3); font-weight: 600; font-size: 12px; }
.cmap input[type="number"] { width: 70px; padding: 4px 6px; border-radius: 6px; border: 1px solid var(--line-2); background: var(--bg-2); font-family: var(--num-font); }
.swatch { display: inline-block; width: 16px; height: 16px; border-radius: 50%; border: 4px solid var(--c); vertical-align: -3px; margin-right: 6px; }

/* 步骤 */
.steps { display: flex; gap: 4px; margin-bottom: 10px; }
.step { flex: 1; text-align: center; font-size: 11.5px; padding: 6px 2px; border-radius: 8px; background: var(--panel-2); color: var(--ink-3); border: 1px solid var(--line); cursor: pointer; }
.step.on { color: var(--ink); border-color: var(--c-measured); }
.step.done { color: #5ed39a; }

/* 照片工作区 */
.photo-host { background: #05080f; }
.photo-host canvas { position: absolute; inset: 0; touch-action: none; }
.photo-bar { position: absolute; left: 12px; right: 12px; bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; z-index: 4; }
.photo-bar .seg { background: rgba(10, 15, 30, 0.85); }
.photo-bar .seg button { color: #cfd8ea; }
.photo-legend { position: absolute; left: 12px; top: 60px; z-index: 3; background: rgba(8, 12, 24, 0.78); color: #dfe6f5; font-size: 12px; padding: 8px 10px; border-radius: 10px; line-height: 1.6; max-width: 280px; }
.quality li { margin: 3px 0; font-size: 12.5px; line-height: 1.5; color: var(--ink-2); }
.quality { padding-left: 18px; margin: 6px 0; }
.q-ok::marker { color: #5ed39a; }
.q-warn::marker { color: #ff9f43; }
.q-bad::marker { color: #ff5d5d; }

/* 相机 */
.cam { display: flex; flex-direction: column; gap: 10px; }
.cam video { width: 100%; max-height: 60vh; background: #000; border-radius: 10px; object-fit: contain; }
.cam img { width: 100%; max-height: 60vh; object-fit: contain; border-radius: 10px; background: #000; }

/* 弹窗与提示 */
.modal { border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel); color: var(--ink); padding: 0; width: min(640px, 94vw); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(3, 6, 14, 0.6); }
.modal header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.modal header h3 { margin: 0; font-size: 15px; }
.modal .mbody { padding: 14px 16px 16px; max-height: 76vh; overflow: auto; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(20px); opacity: 0; background: #16213a; color: #eef2fa; border: 1px solid rgba(255, 255, 255, 0.14); padding: 10px 14px; border-radius: 10px; z-index: 100; transition: all 0.2s; max-width: 90vw; font-size: 13px; display: flex; gap: 10px; align-items: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast button { border: 0; background: var(--c-gold); color: #1b1606; border-radius: 7px; padding: 4px 10px; cursor: pointer; font-weight: 700; }

/* 全屏 */
.stage-view:fullscreen, .stage-view.pseudo-fs { background: var(--stage); }
.stage-view.pseudo-fs { position: fixed; inset: 0; z-index: 1000; }
body.has-pseudo-fs { overflow: hidden; }

/* ---------- 教学说明 ---------- */
.teaching { max-width: 1120px; margin: 26px auto 10px; padding: 0 18px; }
.teaching h2 { font-size: 22px; margin: 10px 0 4px; }
.teaching .lead { color: var(--ink-2); margin: 0 0 18px; line-height: 1.7; }
.tgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.tcard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.tcard h3 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.tcard h3 i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--c-gold)); }
.tcard p, .tcard li { line-height: 1.75; color: var(--ink-2); font-size: 13.5px; }
.tcard ul { padding-left: 18px; margin: 6px 0; }
.tcard .formula { font-family: "Times New Roman", serif; font-style: italic; font-size: 16px; color: var(--ink); }
.tcard.wide { grid-column: 1 / -1; }
.vtable { width: 100%; border-collapse: collapse; font-size: 13px; }
.vtable th, .vtable td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; vertical-align: top; line-height: 1.6; }
.vtable th { color: var(--ink-3); font-weight: 600; }
.foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 20px 10px 30px; }

/* ---------- 自由电荷页 ---------- */
.free-tools { display: flex; gap: 6px; margin: 0 auto; flex-wrap: wrap; }
.add-btn.pos { color: #ff9a9a; }
.add-btn.neg { color: #9ac4ff; }
.add-btn.pos[aria-pressed="true"] { background: #ef4b4b; color: #fff; border-color: transparent; }
.add-btn.neg[aria-pressed="true"] { background: #3b82f0; color: #fff; border-color: transparent; }
.free-page .btn:disabled { opacity: 0.4; cursor: not-allowed; }
.add-hint { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: rgba(8, 12, 24, 0.86); color: #eef3ff; padding: 7px 14px; border-radius: 10px; font-size: 12.5px; z-index: 4; pointer-events: none; }
.free-page .stage-view.adding .field2d-canvas { cursor: crosshair; }
.qdot { display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; color: #fff; font-weight: 700; font-size: 12px; line-height: 1; }
.qdot.pos { background: #ef4b4b; }
.qdot.neg { background: #3b82f0; }
.ctable input { width: 64px; }
.ctable .off { color: #ffb86b; font-size: 11.5px; }
.ctable td:last-child { text-align: right; }
.iconb.del { border: 0; background: transparent; color: var(--ink-3); cursor: pointer; font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.iconb.del:hover { color: #ff8b8b; background: var(--btn-h); }

/* ---------- 窄屏 ---------- */
@media (max-width: 1180px) {
  :root { --side-w: 380px; }
  .layer-tab { padding: 8px 10px; }
  .brand small { display: none; }
}
@media (max-width: 1000px) {
  .topbar { flex-wrap: wrap; gap: 8px 12px; }
  .layer-tabs { order: 3; width: 100%; margin: 0; overflow-x: auto; }
  .layer-tab { flex: 1; justify-content: center; }
  .workspace { display: flex; flex-direction: column; height: auto; min-height: 0; gap: 12px; }
  .stage { height: 72vh; min-height: 460px; }
  .splitter-v, .splitter-h { display: none; }
  .side { gap: 12px; }
  .plot-card { height: 340px; }
  .panel-card { min-height: 420px; max-height: none; }
  .identity-badge { max-width: calc(100% - 120px); }
  .stage-tools { max-width: 70%; }
  .tgrid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  html, body { font-size: 13.5px; }
  .topbar { padding: 8px 10px; }
  .brand b { font-size: 13.5px; }
  .top-links .ghost { display: none; }
  .scenebar { padding: 6px 10px; gap: 8px; }
  .scene-chips { flex-wrap: nowrap; overflow-x: auto; width: 100%; padding-bottom: 2px; }
  .scene-chip { flex: none; }
  .scene-info { display: none; }
  .view-switch { width: 100%; }
  .view-switch button { flex: 1; padding: 6px 4px; }
  .workspace { padding: 8px; }
  .stage { height: 66vh; min-height: 380px; }
  .identity-badge { top: 8px; left: 8px; font-size: 12px; max-width: calc(100% - 16px); }
  .identity-badge small { display: none; }
  .layer-tabs { overflow: visible; gap: 3px; }
  .layer-tab { flex: 1 1 0; min-width: 0; padding: 7px 4px; gap: 5px; font-size: 12px; white-space: normal; line-height: 1.25; text-align: center; }
  .layer-tab i { flex: none; width: 7px; height: 7px; }
  .stage-note { top: 46px; bottom: auto; left: 8px; right: 8px; max-width: none; font-size: 12.5px; }
  .stage-tools { top: auto; bottom: 8px; right: 8px; max-width: 100%; }
  .toggle-group { display: none; }
  .colorbar-host { top: 56px; bottom: 56px; right: 6px; width: 62px; }
  .control-strip { gap: 8px; padding: 8px; }
  .param input[type="range"] { width: 90px; }
  .statbar { grid-template-columns: repeat(2, 1fr); }
  .grid4 { grid-template-columns: repeat(2, 1fr); }
}

/* 典型电荷预设使用 aria-pressed；选中状态用实色突出。 */
.scene-chip[aria-pressed="true"] { background:#dce9ff; color:#17365c; border-color:#427fc1; box-shadow:inset 0 0 0 1px #427fc1; font-weight:700; }
[data-theme="dark"] .scene-chip[aria-pressed="true"] { background:#274e7b; color:#fff; border-color:#83b5f4; }

/* 更多实验入口仍能在窄屏完整访问，不挤出页面。 */
.topbar { flex-wrap:wrap; }
.top-links { flex-wrap:wrap; max-width:100%; }
.teaching { scroll-margin-top:170px; }
.formula { margin:16px 0; padding:12px; text-align:center; font-size:22px; color:var(--ink); background:var(--panel-2); border-radius:8px; }
@media (max-width:1520px) {
  .topbar > .layer-tabs { order:3; flex-basis:100%; margin:0; }
  .topbar > .layer-tabs .layer-tab { flex:1; justify-content:center; }
}
@media (max-width:640px) {
  .top-links { gap:5px; }
  .top-links .link-btn { padding:7px 9px; }
  .teaching { scroll-margin-top:220px; }
  .formula { font-size:20px; }
}
