:root {
  --paper: #f4f0e8;
  --paper-bright: #fbfaf6;
  --grid: #ded7cd;
  --grid-strong: #cabfb2;
  --ink: #172431;
  --ink-soft: #46515b;
  --brown: #6b4c3b;
  --brown-dark: #4c342a;
  --brown-soft: #a48272;
  --red: #d64232;
  --red-dark: #9c261e;
  --brass: #c58a2b;
  --green: #2e7d64;
  --amber: #d98a24;
  --blue: #356d88;
  --line: #d9cec1;
  --shadow: 0 16px 42px rgba(55, 39, 28, .12);
  --display: "STKaiti", "KaiTi", "Songti SC", serif;
  --body: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  --utility: "DIN Alternate", "Avenir Next Condensed", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--body);
  overflow: hidden;
}

button, input { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 3px solid rgba(46, 125, 100, .34);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.brand-bar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(251, 250, 246, .94);
  backdrop-filter: blur(18px);
  position: relative;
  z-index: 30;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
}

.brand strong {
  font: 700 16px/1 var(--display);
  letter-spacing: .08em;
}

.brand-mark {
  position: relative;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border: 1px solid var(--brown);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fffdf8;
  box-shadow: inset -6px -2px 0 rgba(197, 138, 43, .10);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  content: "";
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--brown);
}
.brand-mark::before { transform: translate(-6px, -7px); }
.brand-mark::after { transform: translate(6px, 4px); }
.brand-mark span { transform: translate(0, 0); }

.brand-actions { display: flex; align-items: center; gap: 9px; }

.brand-actions button,
.brand-actions a {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  text-decoration: none;
  cursor: pointer;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 650;
}

.brand-actions button:hover,
.brand-actions a:hover { background: #eee7de; color: var(--brown-dark); }

.model-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #f1ece4;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 700;
}

.model-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 5px rgba(217, 138, 36, .1);
  animation: statusPulse 1.25s ease-in-out infinite;
}

.model-status.ready { background: #e6f1eb; color: #24644f; }
.model-status.ready i { background: var(--green); animation: none; }
.model-status.error { background: #f7e6e3; color: #8c3028; }
.model-status.error i { background: var(--red); animation: none; }

@keyframes statusPulse { 50% { opacity: .35; transform: scale(.78); } }

.app-shell {
  height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: 316px minmax(0, 1fr);
  grid-template-rows: 64px minmax(0, 1fr);
  min-width: 0;
}

.workspace-title {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(248,245,239,.92);
}

.workspace-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--green);
  font: 800 9px/1 var(--utility);
  letter-spacing: .16em;
  text-transform: uppercase;
}

.workspace-title h1 {
  margin: 0;
  color: var(--brown-dark);
  font: 700 21px/1.1 var(--display);
  letter-spacing: .09em;
}

.workspace-hint {
  color: #897c72;
  font: 700 10px/1 var(--utility);
  letter-spacing: .08em;
}

.parts-panel {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 22px 18px 18px;
  border-right: 1px solid var(--line);
  background: #f8f5ef;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

.canvas-extent {
  position: relative;
  width: 2200px;
  height: 1400px;
}

.parts-heading { display: flex; justify-content: space-between; align-items: flex-start; }
.parts-heading h2 { margin: 0 0 4px; font: 700 24px/1 var(--display); letter-spacing: .08em; }
.parts-heading span { color: #80756b; font-size: 12px; }

.asset-badge {
  font: 800 10px/1 var(--utility) !important;
  letter-spacing: .14em;
  color: var(--green) !important;
  border: 1px solid rgba(46,125,100,.28);
  background: rgba(46,125,100,.08);
  border-radius: 6px;
  padding: 6px 7px;
}

.asset-badge.error { color: var(--red) !important; border-color: rgba(214,66,50,.3); }

.stage-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  margin: 18px 0 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #eee7de;
}

.stage-tabs button {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: #76695f;
  padding: 9px 4px;
  font-weight: 750;
  font-size: 13px;
}

.stage-tabs button.active { background: var(--brown-soft); color: white; box-shadow: 0 3px 8px rgba(80,54,42,.16); }
.stage-tabs button:disabled { opacity: .7; }

.insert-example {
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  width: 100%;
  border: 1px solid #e7bd75;
  border-radius: 12px;
  background: #fff1d6;
  color: #775226;
  padding: 12px 13px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.insert-example:hover { transform: translateY(-1px); box-shadow: 0 8px 18px rgba(170,104,26,.13); background: #ffedc7; }
.insert-example > span:first-child { font-size: 22px; line-height: 1; }
.insert-example > span:nth-child(2) { text-align: left; }
.insert-example small { font-size: 10px; color: #9f7441; }

.parts-list {
  min-height: 0;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-content: start;
  gap: 10px;
  padding: 15px 3px 18px 1px;
  scrollbar-color: #cdbeb0 transparent;
  scrollbar-width: thin;
}

.part-card {
  min-width: 0;
  border: 1px solid transparent;
  border-radius: 13px;
  background: transparent;
  padding: 7px 6px 9px;
  cursor: grab;
  color: var(--ink);
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}

.part-card:hover {
  border-color: var(--line);
  background: #fffdfa;
  transform: translateY(-2px);
}

.part-card:active { cursor: grabbing; }
.part-card strong, .part-card small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part-card strong { margin-top: 4px; font: 700 13px/1.3 var(--display); }
.part-card small { margin-top: 3px; color: #92867b; font: 650 9px/1.2 var(--utility); }

.part-preview {
  height: 92px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(255,255,255,.9), rgba(231,225,216,.5));
  position: relative;
}

.part-preview::after {
  content: "";
  position: absolute;
  left: 14%; right: 14%; bottom: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(36, 33, 30, .18);
  filter: blur(8px);
}

.part-preview img { width: 100%; height: 100%; object-fit: contain; position: relative; z-index: 1; filter: drop-shadow(0 7px 5px rgba(30,28,27,.16)); }
.part-preview i { position: relative; z-index: 1; font: 700 23px/1 var(--utility); color: #897668; font-style: normal; }

.science-note {
  border-top: 1px solid var(--line);
  padding: 12px 4px 0;
  color: #81766d;
}

.science-note summary { color: var(--green); cursor: pointer; font-size: 11px; font-weight: 800; }
.science-note p { margin: 8px 0 0; color: #81766d; font-size: 10px; line-height: 1.5; }

.canvas-pane {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: 52px 46px minmax(0, 1fr);
  background: var(--paper-bright);
  position: relative;
  overflow: hidden;
}

.canvas-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.82);
  position: relative;
  z-index: 8;
}

.zoom-toolbar, .topbar-actions { display: flex; align-items: center; gap: 6px; }

.canvas-topbar button {
  min-height: 35px;
  border: 1px solid #ddd3c9;
  border-radius: 9px;
  background: #fffefa;
  color: #564b43;
  padding: 0 11px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.canvas-topbar button:hover:not(:disabled) { background: #f1eae2; border-color: #cdbcae; }
.canvas-topbar button:active:not(:disabled) { transform: translateY(1px); }
.canvas-topbar button:disabled { opacity: .34; cursor: default; }
.zoom-toolbar button:nth-child(-n+3) { min-width: 34px; padding: 0 8px; font: 800 12px/1 var(--utility); }
.zoom-toolbar #zoomValueButton { min-width: 58px; }

.canvas-topbar .ideal-button.active { border-color: rgba(46,125,100,.45); background: #e7f1ec; color: #24634f; }
.feedback-button span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--amber); margin-right: 4px; }
.canvas-topbar .diagram-button { color: white; background: var(--brown); border-color: var(--brown); padding-inline: 15px; }
.canvas-topbar .diagram-button:hover:not(:disabled) { background: var(--brown-dark); border-color: var(--brown-dark); }
.canvas-topbar .clear-canvas { color: #a13a30; }

.status-strip {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #f5f1eb;
  position: relative;
  z-index: 7;
}

.circuit-badge { display: flex; align-items: center; gap: 9px; padding: 0 18px; font-size: 11px; font-weight: 750; }
.circuit-badge i { width: 8px; height: 8px; border-radius: 50%; background: #aaa096; box-shadow: 0 0 0 5px rgba(120,110,100,.08); }
.circuit-badge[data-tone="live"] i { background: var(--green); box-shadow: 0 0 0 5px rgba(46,125,100,.1); }
.circuit-badge[data-tone="warn"] i { background: var(--amber); box-shadow: 0 0 0 5px rgba(217,138,36,.1); }
.circuit-badge[data-tone="danger"] i { background: var(--red); box-shadow: 0 0 0 5px rgba(214,66,50,.1); }

.live-readings { display: flex; }
.live-readings > span { display: flex; align-items: baseline; gap: 7px; min-width: 135px; padding: 8px 15px; border-left: 1px solid var(--line); }
.live-readings small { color: #8a7f75; font-size: 9px; }
.live-readings strong { color: var(--brown-dark); font: 800 13px/1 var(--utility); }

.canvas-viewport {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  background: #e6ded4;
  position: relative;
  cursor: grab;
  user-select: none;
  overscroll-behavior: none;
}

.canvas-viewport.is-panning { cursor: grabbing; }

.canvas-world {
  --zoom: 1;
  width: 2200px;
  height: 1400px;
  transform: scale(var(--zoom));
  transform-origin: left top;
  position: relative;
  overflow: hidden;
  background-color: #faf8f3;
  background-image:
    linear-gradient(var(--grid-strong) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-strong) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
  box-shadow: inset 0 0 90px rgba(89, 64, 45, .035);
}

.canvas-world::before {
  content: "实验工作面 / 2200 × 1400";
  position: absolute;
  right: 20px;
  bottom: 14px;
  color: #b4a89d;
  font: 700 9px/1 var(--utility);
  letter-spacing: .08em;
}

.wire-layer, .component-layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.wire-layer { z-index: 7; pointer-events: none; overflow: visible; }
.component-layer { pointer-events: none; }

.wire-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 18;
  pointer-events: stroke;
  cursor: pointer;
}

.wire-visible {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 8;
  filter: url(#wireShadow);
  pointer-events: none;
}

.wire-highlight { fill: none; stroke: rgba(255,255,255,.52); stroke-width: 2; stroke-linecap: round; pointer-events: none; }

.wire-flow {
  fill: none;
  stroke: #ffd27b;
  stroke-width: 2.5;
  stroke-dasharray: 2 18;
  stroke-linecap: round;
  pointer-events: none;
  opacity: 0;
  filter: url(#chargeGlow);
}

.wire-group.energized .wire-flow { opacity: .95; animation: currentFlow .75s linear infinite; }
.wire-group.selected .wire-visible { stroke-width: 11; }
.wire-group.selected .wire-highlight { stroke-width: 3; }

@keyframes currentFlow { to { stroke-dashoffset: -20; } }

.wire-preview { fill: none; stroke: var(--red); stroke-width: 6; stroke-dasharray: 9 7; stroke-linecap: round; pointer-events: none; filter: url(#wireShadow); }

.circuit-component {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
}

.component-body { position: absolute; inset: 0; cursor: grab; z-index: 1; }
.component-body:active { cursor: grabbing; }
.circuit-component.selected .component-body::after {
  content: "";
  position: absolute;
  inset: 5px;
  border: 2px solid rgba(46,125,100,.7);
  border-radius: 17px;
  box-shadow: 0 0 0 6px rgba(46,125,100,.08);
  pointer-events: none;
}

.model-image { width: 100%; height: 100%; object-fit: contain; pointer-events: none; transition: opacity .22s ease, filter .2s ease; filter: drop-shadow(0 10px 8px rgba(33,29,26,.13)); }
.model-image.loading { opacity: .12; }

.model-fallback {
  position: absolute;
  inset: 14%;
  display: grid;
  place-items: center;
  border: 1px dashed #b8aa9d;
  border-radius: 14px;
  color: #7d7065;
  font: 800 30px/1 var(--utility);
}

.device-label {
  position: absolute;
  left: 50%;
  bottom: -5px;
  transform: translate(-50%, 100%);
  white-space: nowrap;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(255,253,248,.9);
  color: #5f534a;
  border: 1px solid #ddd1c5;
  font-size: 10px;
  font-weight: 750;
  box-shadow: 0 4px 10px rgba(50,40,32,.08);
}

.terminal {
  position: absolute;
  left: var(--tx);
  top: var(--ty);
  transform: translate(-50%, -50%);
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  box-shadow: none;
  cursor: crosshair;
  z-index: 20;
  transition: transform .13s ease, box-shadow .13s ease;
}

.terminal:hover, .terminal.wire-start { transform: translate(-50%, -50%) scale(1.08); box-shadow: 0 0 0 5px rgba(213,151,55,.24); }
.terminal.connected::after { display: none; }

.terminal-tip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  opacity: 0;
  pointer-events: none;
  background: #24313a;
  color: white;
  padding: 4px 6px;
  border-radius: 5px;
  white-space: nowrap;
  font: 700 9px/1 var(--utility);
  transition: opacity .12s ease;
}

.terminal:hover .terminal-tip { opacity: 1; }

.polarity-tag { position: absolute; left: var(--polarity-x); top: calc(var(--polarity-y) - 19px); z-index: 16; transform: translateX(-50%); min-width: 17px; height: 17px; display: grid; place-items: center; border: 1px solid currentColor; border-radius: 50%; background: rgba(255,253,248,.94); box-shadow: 0 1px 4px rgba(41,34,29,.18); font: 800 12px/1 var(--utility); pointer-events: none; }
.polarity-tag.neg { color: #182126; }
.polarity-tag.pos { color: #c93b2d; }

.device-reading {
  position: absolute;
  right: 7px;
  bottom: 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 5px 7px;
  border-radius: 7px;
  color: white;
  background: rgba(22,34,43,.86);
  backdrop-filter: blur(8px);
  font: 800 10px/1.15 var(--utility);
  z-index: 6;
}

.device-reading small { color: #cbd5da; font-size: 7px; margin-bottom: 2px; }
.device-reading.overload { background: rgba(166,42,30,.92); }

.switch-toggle {
  position: absolute;
  left: 50%;
  bottom: 2px;
  transform: translateX(-50%);
  z-index: 7;
  border: 1px solid #cfc1b5;
  border-radius: 999px;
  color: #5c4d44;
  background: #fffaf4;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 9px;
  font-weight: 800;
}

.switch-handle-zone {
  position: absolute;
  left: var(--hx);
  top: var(--hy);
  transform: translate(-50%, -50%);
  z-index: 9;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: ns-resize;
  touch-action: none;
}

.switch-handle-zone:hover { box-shadow: 0 0 0 5px rgba(213,151,55,.18); }
.switch-handle-zone:focus-visible { outline: 3px solid rgba(46,125,100,.5); outline-offset: -5px; }


.circuit-component.switch.closed .switch-toggle { color: white; background: var(--green); border-color: var(--green); }

.rheostat-control {
  position: absolute;
  left: 24%;
  right: 24%;
  top: 5px;
  z-index: 7;
  accent-color: var(--brass);
  cursor: ew-resize;
}

.lamp-glow {
  position: absolute;
  width: 44%;
  aspect-ratio: 1;
  left: 50%;
  top: 2%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,239,155,.92), rgba(255,187,50,.36) 45%, transparent 72%);
  opacity: var(--brightness, 0);
  filter: blur(4px);
  mix-blend-mode: screen;
  pointer-events: none;
  z-index: 5;
  transition: opacity .2s ease;
}

.circuit-component.lamp.hot .model-image { filter: sepia(.15) saturate(1.3) drop-shadow(0 0 18px rgba(255,122,38,.85)); }

.meter-needle {
  position: absolute;
  left: 50%;
  top: 49%;
  width: 34%;
  height: 2px;
  border-radius: 3px;
  background: #f14534;
  transform-origin: 0 50%;
  transform: rotate(var(--needle-angle, -135deg));
  box-shadow: 0 1px 2px rgba(100,20,10,.45);
  z-index: 6;
  transition: transform .26s cubic-bezier(.2,.7,.2,1);
}

.meter-needle::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--brass); border: 1px solid #714719; }

.meter-face-detail {
  position: absolute;
  left: 19%;
  top: 12%;
  width: 62%;
  height: 47%;
  z-index: 5;
  overflow: visible;
  pointer-events: none;
  opacity: .78;
  filter: drop-shadow(0 1px 0 rgba(255,255,255,.8));
}

.meter-face-detail path {
  fill: none;
  stroke: #26343d;
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
}

.meter-face-detail text {
  fill: #26343d;
  font: 700 9px/1 var(--utility);
  text-anchor: middle;
}

.meter-face-detail .meter-letter {
  font: 800 20px/1 Georgia, serif;
}

.schematic-symbol {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 13px;
  background: transparent;
}

.schematic-id {
  display: none;
  position: absolute;
  left: 50%;
  top: -3px;
  transform: translate(-50%, -100%);
  z-index: 12;
  padding: 3px 7px;
  border: 1px solid rgba(190,180,169,.7);
  border-radius: 5px;
  color: #20282e;
  background: rgba(255,253,249,.96);
  box-shadow: 0 2px 5px rgba(60,48,40,.08);
  font: 800 13px/1 var(--utility);
  pointer-events: none;
}

.schematic-id sub { font-size: .68em; vertical-align: -.24em; }

.schematic-symbol svg { width: 78%; height: 78%; overflow: visible; }
.canvas-pane.schematic-mode .schematic-symbol svg { width: 100%; height: 100%; }
.schematic-symbol path, .schematic-symbol line, .schematic-symbol circle, .schematic-symbol rect { vector-effect: non-scaling-stroke; }

.canvas-pane.schematic-mode .canvas-world {
  background-color: #fffdf9;
  background-image: linear-gradient(rgba(216,207,198,.5) 1px, transparent 1px), linear-gradient(90deg, rgba(216,207,198,.5) 1px, transparent 1px);
  background-size: 20px 20px;
}

.canvas-pane.schematic-mode .model-image,
.canvas-pane.schematic-mode .model-fallback,
.canvas-pane.schematic-mode .device-reading,
.canvas-pane.schematic-mode .switch-toggle,
.canvas-pane.schematic-mode .switch-handle-zone,
.canvas-pane.schematic-mode .rheostat-control,
.canvas-pane.schematic-mode .lamp-glow,
.canvas-pane.schematic-mode .meter-needle,
.canvas-pane.schematic-mode .meter-face-detail,
.canvas-pane.schematic-mode .device-label { display: none; }

.canvas-pane.schematic-mode .schematic-symbol { display: flex; }
.canvas-pane.schematic-mode .schematic-id { display: block; }
.canvas-pane.schematic-mode .component-body { z-index: 4; }
.canvas-pane.schematic-mode .wire-layer { z-index: 3; }
.canvas-pane.schematic-mode .terminal { width: 26px; height: 26px; border: 0; background: transparent; box-shadow: none; }
.canvas-pane.schematic-mode .terminal:hover,
.canvas-pane.schematic-mode .terminal.wire-start { box-shadow: 0 0 0 4px rgba(213,151,55,.24); }
.canvas-pane.schematic-mode .wire-visible { stroke: #20282e !important; stroke-width: 3; filter: none; }
.canvas-pane.schematic-mode .wire-highlight, .canvas-pane.schematic-mode .wire-flow { display: none; }

.empty-state {
  position: absolute;
  left: 50%; top: 48%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: #897d73;
  z-index: 2;
}

.empty-symbol { width: 62px; height: 62px; display: grid; place-items: center; margin: 0 auto 12px; border: 1px solid #d8cdc2; border-radius: 50%; background: rgba(255,255,255,.7); font-size: 30px; color: var(--brown-soft); }
.empty-state strong { display: block; color: var(--brown-dark); font: 700 18px/1.2 var(--display); }
.empty-state p { font-size: 12px; }
.empty-state button { border: 0; border-radius: 9px; background: var(--brown); color: white; padding: 9px 13px; cursor: pointer; font-size: 11px; font-weight: 750; }

.wire-cancel-bar {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 520px;
  padding: 10px 11px 10px 15px;
  border-radius: 13px;
  color: white;
  background: rgba(29,39,46,.94);
  box-shadow: 0 14px 40px rgba(25,22,19,.28);
  backdrop-filter: blur(14px);
}

.wire-cancel-bar > span { display: flex; align-items: center; gap: 7px; font-size: 11px; }
.wire-cancel-bar > span i { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 5px rgba(214,66,50,.15); }
.wire-cancel-bar p { margin: 0; flex: 1; color: #bfc8cc; font-size: 10px; }
.wire-cancel-bar button { border: 1px solid #657078; border-radius: 8px; color: white; background: #46535b; padding: 7px 9px; cursor: pointer; font-size: 10px; }
.wire-cancel-bar kbd { padding: 2px 4px; border-radius: 4px; background: #29343a; font: 700 8px/1 var(--utility); }

.inspector {
  position: absolute;
  right: 15px;
  top: 175px;
  z-index: 18;
  width: 248px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,253,248,.94);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
  padding: 14px;
}

.inspector-head { display: flex; align-items: flex-start; justify-content: space-between; }
.inspector-head small, .inspector-head strong { display: block; }
.inspector-head small { color: #92867d; font: 800 9px/1 var(--utility); letter-spacing: .08em; }
.inspector-head strong { margin-top: 4px; font: 700 17px/1.2 var(--display); }
.inspector-head button { width: 26px; height: 26px; border: 0; border-radius: 8px; background: #eee7df; color: #6e6259; cursor: pointer; }
.inspector label { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; margin-top: 14px; font-size: 11px; font-weight: 700; color: #6e6258; }
.inspector input[type="range"] { grid-column: 1 / -1; width: 100%; accent-color: var(--brass); }
.inspector input[type="number"] { width: 76px; border: 1px solid #d7c9bc; border-radius: 7px; background: #fffdf8; color: var(--brown-dark); padding: 5px 7px; }
.inspector select { min-width: 82px; border: 1px solid #d7c9bc; border-radius: 7px; background: #fffdf8; color: var(--brown-dark); padding: 5px 7px; font-size: 10px; font-weight: 750; }
.inspector-copy { margin: 13px 0 2px; color: #786b62; font-size: 11px; line-height: 1.55; }
.pose-controls { margin-top: 13px; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: #f5efe7; }
.pose-controls > span { display: block; margin-bottom: 7px; color: var(--brown-dark); font-size: 10px; font-weight: 800; }
.pose-controls label { margin-top: 8px; }
.inspector .inspector-action { width: 100%; margin-top: 11px; border: 0; border-radius: 9px; background: var(--brown); color: white; padding: 9px; cursor: pointer; font-size: 11px; font-weight: 750; }
.inspector .danger-action { background: #f3e3e0; color: #9b332a; }
.inspector-reading { border-top: 1px solid var(--line); margin: 13px 0 0; padding-top: 11px; color: #45545c; font: 700 10px/1.6 var(--utility); }

.toast {
  position: absolute;
  left: 50%;
  top: 175px;
  transform: translateX(-50%);
  z-index: 40;
  max-width: 520px;
  color: white;
  background: rgba(31,43,50,.94);
  border-radius: 10px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 700;
}

dialog {
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fbf8f3;
  box-shadow: 0 28px 90px rgba(49,35,27,.26);
}

dialog::backdrop { background: rgba(35,32,29,.42); backdrop-filter: blur(5px); }

.template-dialog { width: min(1120px, calc(100vw - 42px)); max-height: min(780px, calc(100vh - 42px)); padding: 20px; }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 4px 5px 17px; }
.dialog-heading h2 { margin: 3px 0 6px; font: 700 25px/1.2 var(--display); letter-spacing: .05em; }
.dialog-heading span { color: #887b71; font-size: 12px; }
.dialog-kicker { margin: 0; color: var(--green); font: 850 9px/1 var(--utility); letter-spacing: .18em; }
.dialog-close { width: 34px; height: 34px; border: 0; border-radius: 10px; color: #6a5c52; background: #eee7df; cursor: pointer; font-size: 20px; }

.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; overflow-y: auto; max-height: 620px; padding: 2px 5px 5px; }
.template-card { display: grid; grid-template-columns: 150px minmax(0,1fr); gap: 15px; align-items: center; min-height: 150px; border: 1px solid #dfd4ca; border-radius: 16px; background: #fffdfa; padding: 13px; text-align: left; cursor: pointer; transition: border-color .16s ease, transform .16s ease, box-shadow .16s ease; }
.template-card:hover { border-color: var(--brown-soft); transform: translateY(-2px); box-shadow: 0 11px 28px rgba(75,51,38,.10); }
.template-schematic { height: 120px; display: grid; place-items: center; border: 1px solid #e5dbd1; border-radius: 12px; background: #fbf9f5; }
.template-schematic svg { width: 90%; height: 90%; }
.template-copy strong { display: block; color: var(--brown-dark); font: 700 17px/1.25 var(--display); }
.template-copy p { margin: 7px 0 11px; color: #85786f; font-size: 11px; line-height: 1.55; }
.template-copy span { display: inline-block; border-radius: 8px; color: white; background: var(--brown); padding: 7px 10px; font-size: 10px; font-weight: 750; }

.help-dialog { width: min(470px, calc(100vw - 32px)); padding: 25px; }
.help-dialog > .dialog-close { position: absolute; right: 18px; top: 18px; }
.help-dialog h2 { margin: 8px 0 20px; font: 700 26px/1.2 var(--display); }
.help-dialog ol { list-style: none; padding: 0; margin: 0; display: grid; gap: 15px; }
.help-dialog li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; }
.help-dialog li > span { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--brown); color: white; font: 800 12px/1 var(--utility); }
.help-dialog li strong { font: 700 16px/1.2 var(--display); }
.help-dialog li p { margin: 4px 0 0; color: #84776d; font-size: 11px; line-height: 1.55; }

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 268px minmax(0,1fr); }
  .parts-panel { padding-inline: 13px; }
  .topbar-actions #saveButton, .topbar-actions #idealButton { display: none; }
  .live-readings > span { min-width: 106px; }
}

@media (max-width: 820px) {
  html, body { overscroll-behavior: none; }
  body { overflow: hidden; }
  .app-shell { position: relative; }
  .brand-bar { height: 56px; padding-inline: 12px; }
  .brand-actions .model-status, .brand-actions button { display: none; }
  .app-shell {
    height: calc(100vh - 56px);
    height: calc(100dvh - 56px);
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  .workspace-title {
    position: absolute;
    top: 44px;
    left: 0;
    z-index: 16;
    width: 100%;
    height: 30px;
    padding: 0 14px;
    justify-content: flex-start;
    pointer-events: none;
    border: 0;
    background: transparent;
  }
  .workspace-kicker { display: none; }
  .workspace-title h1 {
    display: inline-block;
    padding: 5px 9px 6px;
    border: 1px solid rgba(217,206,193,.9);
    border-radius: 9px;
    background: rgba(251,250,246,.88);
    box-shadow: 0 4px 14px rgba(55,39,28,.08);
    font-size: 17px;
    letter-spacing: .08em;
  }
  .workspace-hint { display: none; }
  .parts-panel {
    order: 2;
    height: clamp(112px, 20vh, 164px);
    min-height: 112px;
    max-height: 164px;
    flex: 0 0 clamp(112px, 20vh, 164px);
    border-right: 0;
    border-top: 1px solid var(--line);
    border-bottom: 0;
    padding: 10px 12px;
  }
  .parts-heading { display: none; }
  .stage-tabs, .insert-example { display: none; }
  .parts-list {
    flex: 1 1 auto;
    display: flex;
    align-items: stretch;
    width: 100%;
    height: 100%;
    gap: 8px;
    padding: 0 2px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .part-card {
    flex: 0 0 clamp(104px, 28vw, 132px);
    min-width: 0;
    padding: 5px;
    scroll-snap-align: start;
    touch-action: pan-x;
  }
  .part-preview {
    height: calc(100% - 40px);
    min-height: 72px;
  }
  .part-card strong { margin-top: 3px; font-size: 13px; }
  .science-note { display: none; }
  .canvas-pane {
    order: 1;
    height: auto;
    min-height: 0;
    flex: 1 1 auto;
    grid-template-rows: minmax(0,1fr);
    position: relative;
  }
  .canvas-topbar {
    position: absolute;
    left: 10px;
    top: 8px;
    z-index: 30;
    width: max-content;
    min-height: 31px;
    padding: 0;
    border: 0;
    background: transparent;
    align-items: center;
    overflow: visible;
  }
  .zoom-toolbar { display: none; }
  .topbar-actions { min-width: max-content; width: 100%; justify-content: flex-start; }
  .topbar-actions #saveButton, .topbar-actions #idealButton { display: inline-flex; }
  .status-strip { display: none; }
  .canvas-topbar button { min-height: 31px; padding-inline: 9px; font-size: 10px; }
  .live-readings > span { min-width: 96px; padding-inline: 9px; }
  .live-readings small { display: none; }
  .wire-cancel-bar { min-width: 0; width: calc(100% - 24px); bottom: 12px; }
  .wire-cancel-bar p { display: none; }
  .canvas-viewport { touch-action: none; -webkit-user-select: none; }
  .inspector {
    top: 48px;
    right: 8px;
    width: min(198px, calc(100% - 16px));
    max-height: calc(100% - 56px);
    overflow-y: auto;
    padding: 8px;
    z-index: 60;
  }
  .inspector-head { cursor: grab; touch-action: none; }
  .inspector-head:active { cursor: grabbing; }
  .inspector-head strong { font-size: 14px; }
  .inspector-head button { width: 24px; height: 24px; }
  .inspector label { margin-top: 8px; font-size: 10px; }
  .inspector select { min-width: 70px; padding: 4px 5px; }
  .pose-controls { margin-top: 7px; padding: 7px; }
  .pose-controls > span { margin-bottom: 5px; font-size: 9px; }
  .pose-controls label { margin-top: 6px; }
  .inspector-copy { margin-top: 7px; font-size: 9px; line-height: 1.45; }
  .inspector .inspector-action { margin-top: 8px; padding: 7px; font-size: 10px; }
  .inspector-reading { margin-top: 7px; padding-top: 7px; font-size: 9px; }
  .template-grid { grid-template-columns: 1fr; }
}

.part-drag-ghost {
  position: fixed;
  z-index: 1000;
  width: 118px;
  pointer-events: none;
  opacity: .88;
  transform: translate(-50%, -50%) rotate(2deg);
  box-shadow: 0 16px 28px rgba(55,39,28,.22);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}
