:root {
  --bg: #f4f5f7; --panel: #fff; --line: #d9dce1; --text: #1f2328; --muted: #6a737d;
  --accent: #1f6feb; --ok: #1a7f37; --bad: #cf222e; --view: #3a3d42;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 13px/1.45 "Microsoft YaHei", "PingFang SC", sans-serif; display: flex; flex-direction: column; }
header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 6px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
header h1 { font-size: 16px; margin: 0 8px 0 0; }
.tools, .layers { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.layers label { color: var(--muted); }
.sep { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }
button { font: inherit; padding: 4px 10px; border: 1px solid var(--line); background: #f6f8fa; border-radius: 5px; cursor: pointer; color: var(--text); }
button:hover { background: #eef1f4; }
button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { filter: brightness(1.08); }
button.danger { color: var(--bad); }
button:disabled { opacity: .5; cursor: default; }
input, select { font: inherit; padding: 2px 4px; border: 1px solid var(--line); border-radius: 4px; }
input[type=range] { vertical-align: middle; }
main { flex: 1; display: flex; min-height: 0; }
#view { flex: 1; position: relative; background: var(--view); overflow: hidden; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#view.tool-pick #cv { cursor: crosshair; }
#view.tool-erase #cv, #view.tool-add #cv { cursor: none; }
#view.dragover { outline: 3px dashed #8ab4f8; outline-offset: -8px; }
.hint { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #cfd3d8; text-align: center; font-size: 16px; pointer-events: none; }
#coords { position: absolute; left: 8px; bottom: 6px; color: #e6e6e6; font-size: 12px; background: rgba(0,0,0,.4); padding: 1px 6px; border-radius: 3px; pointer-events: none; }
#panel { width: 380px; overflow-y: auto; background: var(--panel); border-left: 1px solid var(--line); padding: 4px 12px 24px; }
section { border-bottom: 1px solid var(--line); padding: 8px 0; }
h2 { font-size: 14px; margin: 4px 0 6px; }
h3 { font-size: 13px; margin: 10px 0 4px; }
.row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin: 5px 0; }
.row label.grow, .grow { flex: 1; display: flex; align-items: center; gap: 6px; }
.row label.grow input[type=range] { flex: 1; }
.small { font-size: 12px; color: var(--muted); }
.inline { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.wirelist { display: flex; flex-direction: column; gap: 4px; }
.wire-item { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 5px; cursor: pointer; }
.wire-item.sel { border-color: var(--accent); background: #eef4ff; }
.wire-item .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.wire-item .st { margin-left: auto; font-weight: bold; }
.okc { color: var(--ok); } .badc { color: var(--bad); }
.param-row { display: flex; gap: 6px; align-items: center; margin: 4px 0; }
.param-row input { width: 80px; }
.param-row .x { padding: 1px 7px; }
table.meas { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: 12px; }
table.meas td, table.meas th { border: 1px solid var(--line); padding: 3px 5px; text-align: right; }
table.meas th { background: #f6f8fa; font-weight: normal; color: var(--muted); }
table.meas td:first-child { text-align: left; }
details summary { cursor: pointer; color: var(--accent); margin: 4px 0; }
.help { padding-left: 18px; margin: 6px 0; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #24292f; color: #fff; padding: 8px 16px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 70vw; z-index: 10; }
#toast.show { opacity: .95; }
#toast.err { background: var(--bad); }
