:root {
  --bg: #1b1e24;
  --panel: #232730;
  --panel-2: #2b303b;
  --border: #363c49;
  --text: #e3e6ec;
  --muted: #8c93a3;
  --accent: #4fb3ff;
  --wire: #c9d1dc;
  --dot: #3c4352;
  --red: #ff5a5a;
  --black: #9aa3b5;
  --ok: #7ddc8a;
  --warn: #ffb547;
  --current: #ffd166;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 13px;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: minmax(0, 1fr); /* never wider than the window */
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
}
button:hover {
  border-color: #4a5263;
}
button:disabled {
  color: var(--muted);
  opacity: 0.5;
  cursor: default;
}
button:disabled:hover {
  border-color: var(--border);
}
button.active {
  background: #1f3a52;
  border-color: var(--accent);
  color: #fff;
}
button.link {
  background: none;
  border: none;
  color: var(--muted);
  padding: 2px 0;
  text-decoration: underline;
}

kbd {
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  margin-left: 6px;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.toolbar-main {
  flex: 1;
  display: flex;
  flex-wrap: wrap; /* a narrow window gets a second row rather than hidden buttons */
  align-items: center;
  gap: 8px 12px;
  white-space: nowrap;
  min-width: 0;
}
/* Always the top-right corner, however the rest wraps. */
.toolbar-account {
  flex: none;
  display: flex;
  align-items: center;
  min-height: 33px;
}
.toolbar-account[hidden] {
  display: none;
}
.brand {
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-right: 8px;
}
.doc-name {
  color: var(--muted);
  max-width: 280px;
  min-width: 40px;
  flex-shrink: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-name.dirty::after {
  content: ' •';
  color: var(--text);
}
.spacer {
  flex: 1;
}
#example {
  min-width: 110px;
  max-width: 260px;
  flex-shrink: 1;
}
.ambient {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  white-space: nowrap;
}
.ambient input {
  font: inherit;
  width: 44px;
  text-align: right;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 6px;
}
.ambient input.invalid {
  border-color: var(--red);
}
.toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  user-select: none;
}

/* Main layout */
main {
  display: grid;
  grid-template-columns: 150px 1fr 300px;
  min-height: 0;
}
.center {
  position: relative;
  display: grid;
  grid-template-rows: 1fr auto;
  min-width: 0;
  min-height: 0;
}

/* Parts palette */
.palette {
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 8px;
}
.palette .group {
  margin-bottom: 10px;
}
.palette h3 {
  margin: 4px 2px 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}
.palette button {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 6px;
  margin-bottom: 3px;
  font-size: 12px;
  text-align: left;
}
.palette .ico {
  width: 30px;
  height: 20px;
  overflow: visible;
}
.palette .ico .comp .body {
  stroke-width: 3;
}
.palette .ico .ico-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 700;
  fill: currentColor;
}
.palette button.active .ico .comp .body {
  stroke: #fff;
}
.palette kbd {
  margin-left: 0;
}
select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 6px;
}

/* Oscilloscope */
.scope {
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding: 8px 12px 10px;
}
.scope-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.scope-head h2 {
  margin: 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}
.scope-field {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.scope-field input {
  font: inherit;
  width: 70px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 6px;
}
.scope-field input.invalid {
  border-color: var(--red);
}
#scopeStatus {
  color: var(--muted);
  font-size: 12px;
}
.scope-body {
  display: grid;
  grid-template-columns: 1fr 230px;
  gap: 10px;
  margin-top: 8px;
}
.scope.off .scope-body,
.scope.off .scope-field,
.scope.off #tstart,
.scope.off #pinTrace,
.scope.off #play {
  display: none;
}
#plot {
  width: 100%;
  display: block;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
#plot .plot-bg {
  fill: #12141a;
  stroke: var(--border);
}
#plot .grid {
  stroke: #262b35;
  stroke-width: 1;
}
#plot .grid.minor {
  stroke: #20242c;
}
#plot .tick {
  fill: var(--muted);
  font-size: 10px;
}
#plot .trace {
  fill: none;
  stroke-width: 1.6;
  stroke-linejoin: round;
}
#plot .trace.ghost {
  stroke-width: 1;
  opacity: 0.22;
}
#plot .cursor {
  stroke: var(--muted);
  stroke-dasharray: 3 3;
}
#plot .cursor-t {
  fill: var(--text);
}
#traceList {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 12px;
  max-height: 190px;
  overflow-y: auto;
}
#traceList li {
  display: grid;
  grid-template-columns: 10px 1fr auto auto;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
}
#traceList li.empty {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}
#traceList .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
}
#traceList .tv {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
#traceList .remove {
  text-decoration: none;
  padding: 0 2px;
}
.canvas-wrap {
  position: relative;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}
#canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  user-select: none;
  touch-action: none;
}
.canvas-wrap.zoomed-out #gridBg {
  opacity: 0.5;
}
.canvas-wrap.panning #canvas {
  cursor: grabbing;
}
.moment-label {
  position: absolute;
  top: 8px;
  left: 12px;
  pointer-events: none;
  color: var(--muted);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12px;
}
.moment-label:empty {
  display: none;
}
.zoom-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  gap: 4px;
}
.zoom-controls button {
  min-width: 32px;
  padding: 4px 8px;
  background: color-mix(in srgb, var(--panel-2) 90%, transparent);
}
#zoomLevel {
  min-width: 56px;
  font-variant-numeric: tabular-nums;
}
#canvas.tool-select {
  cursor: default;
}
#canvas:not(.tool-select) {
  cursor: crosshair;
}

/* Sidebar */
.sidebar {
  background: var(--panel);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--muted);
}

/* Multimeter */
.lcd {
  background: #b8c7a4;
  color: #1d2418;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.lcd-mode {
  font-size: 11px;
  opacity: 0.7;
}
.lcd-value {
  font-size: 30px;
  font-weight: 600;
  text-align: right;
  white-space: nowrap;
}
.modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}
.modes button {
  font-weight: 600;
  font-size: 15px;
}
.probes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.probe {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.probe .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.probe.red .dot {
  background: var(--red);
}
.probe.black .dot {
  background: #222;
  border: 1px solid var(--black);
}
.probe small {
  color: var(--muted);
}
.hint {
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.4;
}

/* Inspector */
.field {
  display: grid;
  grid-template-columns: 80px 1fr;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.field label {
  color: var(--muted);
}
.field input,
.field select {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 5px 7px;
  width: 100%;
}
.field-hint {
  margin: -2px 0 6px 86px;
}
.pin-hint {
  margin: -4px 0 8px;
}
.field input.invalid {
  border-color: var(--red);
}
.readings {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 4px 6px;
  margin: 8px 0;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
.readings dt {
  color: var(--muted);
  font-family: inherit;
}
.readings dd {
  margin: 0;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.actions button {
  white-space: nowrap;
  padding: 5px 8px;
}
.inspector-title {
  font-weight: 600;
  margin-bottom: 8px;
}
.help {
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  line-height: 1.6;
}

/* Problems */
#messageList {
  margin: 0;
  padding-left: 16px;
  color: var(--warn);
  line-height: 1.5;
}
#messageList li.info {
  color: var(--muted);
}

/* Netlist */
summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
#netlist {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 11px;
  white-space: pre-wrap;
  margin: 8px 0 0;
  color: var(--text);
}

/* Status bar */
.statusbar {
  display: flex;
  gap: 12px;
  padding: 4px 12px;
  background: var(--panel);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
}
#statusSim.ok {
  color: var(--ok);
}
#statusSim.error {
  color: var(--red);
}

/* SVG */
.comp .body {
  fill: none;
  stroke: var(--wire);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.comp .hit {
  stroke: transparent;
  stroke-width: 14;
  stroke-linecap: round;
  fill: none;
}
.tool-select .comp {
  cursor: move;
}
.comp.selected .body {
  stroke: var(--accent);
}
.comp.selected .fill {
  fill: var(--accent);
}
.comp .fill {
  fill: var(--wire);
}
.comp .body.thin {
  stroke-width: 1.5;
}
.comp .body.dashed {
  stroke-dasharray: 3 3;
}
.scope.bode .tran-only,
.scope:not(.bode) .bode-only {
  display: none;
}
#fstart,
#fstop {
  width: 70px;
}
#traceList .ts {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 11px;
}
#traceList .ts.spread {
  color: var(--text);
}
.slider {
  display: flex;
  align-items: center;
  gap: 8px;
}
.slider input {
  flex: 1;
}
.slider output {
  min-width: 3.5em;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.comp .actuator {
  fill: transparent;
  stroke: none;
  pointer-events: all;
  cursor: pointer;
}
.comp .actuator:hover {
  fill: color-mix(in srgb, var(--accent) 14%, transparent);
}
.comp .hitbox {
  fill: transparent;
  stroke: none;
  pointer-events: all;
}
.comp circle.body {
  fill: none;
}
.label {
  fill: var(--text);
  font-size: 11px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  pointer-events: none;
}
.label.current {
  fill: var(--current);
}
.arrow {
  fill: var(--current);
}
.terminal {
  fill: var(--wire);
}
.junction {
  fill: var(--wire);
}
.handle {
  fill: var(--bg);
  stroke: var(--accent);
  stroke-width: 2;
  cursor: grab;
}
.preview {
  opacity: 0.55;
  pointer-events: none;
}
.hover-ring {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  pointer-events: none;
}
.hover-tip {
  fill: var(--accent);
  font-size: 11px;
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  pointer-events: none;
}
.probe-marker {
  cursor: grab;
}
.probe-marker line {
  stroke-width: 2;
}
.probe-marker.red line {
  stroke: var(--red);
}
.probe-marker.red circle {
  fill: var(--red);
}
.probe-marker.black line {
  stroke: var(--black);
}
.probe-marker.black circle {
  fill: #15171c;
  stroke: var(--black);
  stroke-width: 1.5;
}
.probe-marker text {
  font-size: 11px;
  font-weight: 700;
  fill: #fff;
  pointer-events: none;
}
.probe-marker .tip {
  stroke: none;
}

/* Supply in constant-current (current-limited) mode */
.label .cc {
  fill: var(--warn);
  font-weight: 700;
}
.readings .cc {
  color: var(--warn);
}

/* IC symbols */
.label.pin {
  font-size: 9px;
  fill: var(--muted);
}
.label.pin .pin-num {
  fill: #5f6675;
}
.label.chip {
  font-size: 14px;
  font-weight: 700;
  fill: var(--muted);
}
.readings .muted {
  color: var(--muted);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 11px;
}

/* Agent activity in the status bar */
#statusAgent {
  color: var(--muted);
  transition: color 0.4s;
}
#statusAgent.active {
  color: var(--accent);
}


/* ------------------------------------------------------------ breadboard view */
.breadboard-view {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.breadboard-view[hidden] {
  display: none;
}
#breadboardBtn.active,
#perfboardBtn.active,
#inventoryBtn.active {
  background: var(--accent);
  color: #0b1a26;
  border-color: var(--accent);
}
.bb-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.bb-head .spacer {
  flex: 1;
}
.bb-note {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.bb-board-wrap {
  flex: 1 1 60%;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}
.bb-board-wrap svg {
  display: block;
  margin: 0 auto;
}
.bb-sub { fill: #6b6556; font-size: 7.5px; paint-order: stroke; stroke: #f3f0e6; stroke-width: 3px; stroke-linejoin: round; }
.bb-lists {
  flex: 0 1 40%;
  min-height: 80px;
  overflow: auto;
  border-top: 1px solid var(--border);
  padding: 6px 12px 10px;
}
#bbSteps,
#pbSteps {
  margin: 0;
  padding-left: 22px;
  columns: 2 420px;
  column-gap: 28px;
}
#bbSteps li,
#pbSteps li {
  padding: 2px 4px;
  border-radius: 4px;
  break-inside: avoid;
  cursor: default;
  line-height: 1.45;
}
#bbSteps li.hl,
#bbSteps li:hover,
#pbSteps li.hl,
#pbSteps li[data-bb]:hover {
  background: var(--panel-2);
}
#pbSteps li.note {
  color: var(--muted);
}
#bbWarnings,
#pbWarnings {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--warn);
}
#bbWarnings:empty,
#pbWarnings:empty {
  display: none;
}
.bb-svg text {
  user-select: none;
  -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
.bb-board { fill: #f3f0e6; stroke: #d6d0bf; }
.bb-channel { fill: #e2ddcd; }
.bb-hole { fill: #4a463d; }
.bb-red { stroke: #d63a2f; stroke-width: 1.5; }
.bb-blue { stroke: #2b55c7; stroke-width: 1.5; }
.bb-sign-red { fill: #d63a2f; font-size: 11px; font-weight: 700; }
.bb-sign-blue { fill: #2b55c7; font-size: 11px; font-weight: 700; }
.bb-rail-label { fill: var(--muted); font-size: 10px; }
.bb-idx { fill: #9a9383; font-size: 7px; }
.bb-lead { stroke: #a9aeb5; stroke-width: 2; stroke-linecap: round; }
.bb-foot { fill: #8d939b; }
.bb-label { fill: #2b2b2b; font-size: 8.5px; font-weight: 600; paint-order: stroke; stroke: #f3f0e6; stroke-width: 3px; stroke-linejoin: round; }
.bb-plus { fill: #b0261d; font-size: 9px; font-weight: 700; paint-order: stroke; stroke: #f3f0e6; stroke-width: 2.5px; }
.bb-res { fill: #e6c993; stroke: #a8895a; stroke-width: 0.8; }
.bb-elcap { fill: #24418f; stroke: #142858; stroke-width: 0.8; }
.bb-elcap-stripe { fill: #b9c5de; }
.bb-elcap-minus { fill: #24418f; font-size: 9px; font-weight: 700; text-anchor: middle; }
.bb-cercap { fill: #e29a3b; stroke: #a8641a; stroke-width: 0.8; }
.bb-ind { fill: #4f7f45; stroke: #2f5228; stroke-width: 0.8; }
.bb-diode { fill: #1e1e1e; }
.bb-diode-glass { fill: #d8894b; stroke: #9c5b29; stroke-width: 0.6; }
.bb-switch { fill: #4b4f56; stroke: #2b2e33; }
.bb-to92 { fill: #222428; }
.bb-body-name { fill: #e8e8e8; font-size: 8px; font-weight: 700; }
.bb-tab { fill: #b9bec5; stroke: #80868e; stroke-width: 0.6; }
.bb-pot { fill: #2d5fb5; stroke: #1c3d78; }
.bb-pin { fill: #5c564a; font-size: 7.5px; font-weight: 700; }
.bb-dip { fill: #26282c; }
.bb-dip-pin { fill: #b9bec5; }
.bb-notch { fill: #f3f0e6; }
.bb-pin1 { fill: #f3f0e6; }
.bb-dip-label { fill: #e8e8e8; font-size: 9px; font-weight: 700; }
.bb-dip-pinname { fill: #c9cbd0; font-size: 5px; }
.bb-jumper { fill: none; stroke-width: 3.6; stroke-linecap: round; }
.bb-jumper-shadow { fill: none; stroke: #00000030; stroke-width: 6; stroke-linecap: round; }
.bb-wire { fill: none; stroke-width: 2.6; stroke-linecap: round; }
.bb-box { fill: var(--panel-2); stroke: var(--border); }
.bb-box-title { fill: var(--text); font-size: 10px; font-weight: 600; }
.bb-box-sub { fill: var(--muted); font-size: 9px; }
.bb-item { transition: opacity 0.12s; }
.bb-svg.has-hl .bb-item:not(.hl) { opacity: 0.25; }

/* ------------------------------------------------------------ perfboard view */
.pb-svg :is(.pb-two, .pb-dip, .pb-inline, .pb-off) { cursor: grab; }
.pb-lock-bg { fill: #1e2530; stroke: #fff; stroke-width: 1; }
.pb-lock-shackle { fill: none; stroke: #ffd166; stroke-width: 1.4; }
.pb-lock-body { fill: #ffd166; }
.pb-size { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); white-space: nowrap; }
.pb-size input { width: 56px; }
.board-error { max-width: 640px; margin: 40px auto; padding: 14px 18px; border: 1px solid var(--red); border-radius: 8px; color: var(--text); background: color-mix(in srgb, var(--red) 12%, var(--panel)); line-height: 1.5; }
#bbBoard :is(.bb-two, .bb-dip, .bb-inline) { cursor: grab; }
:is(#pbBoard, #bbBoard).dragging, :is(#pbBoard, #bbBoard).dragging * { cursor: grabbing !important; }
:is(#pbBoard, #bbBoard).dragging .bb-item { transition: none; }
:is(#bbWarnings, #pbWarnings) li.notice { font-weight: 600; }
.board-invalid { margin: 6px 12px 0; padding: 8px 12px; border: 1px solid var(--red); border-radius: 8px; color: var(--text); background: color-mix(in srgb, var(--red) 14%, var(--panel)); line-height: 1.45; }
.board-invalid strong { color: var(--red); }
.board-invalid ul { margin: 4px 0 0; padding-left: 18px; }
#pbSteps.invalid { opacity: 0.45; text-decoration: line-through; }
.pb-title { fill: var(--text); font-size: 12px; font-weight: 600; }
.pb-board-top { fill: #e6cf9e; stroke: #b99a62; }
.pb-board-bottom { fill: #d9bd86; stroke: #b99a62; }
.pb-hole { fill: #5a4426; }
.pb-pad { fill: #c98142; }
.pb-svg .bb-idx { fill: var(--muted); font-size: 8px; }
.pb-notch { fill: #e6cf9e; }
.pb-pin1 { fill: #e6cf9e; }
.pb-term { fill: #2f8f55; stroke: #1d5e37; }
.pb-term-pin { fill: #1f1f1f; font-size: 9px; font-weight: 700; paint-order: stroke; stroke: #e6cf9e; stroke-width: 2.5px; }
.pb-trace { stroke: #8f979e; stroke-width: 6; stroke-linecap: round; }
.pb-solder { fill: #e4e7ea; stroke: #6f777e; stroke-width: 1; }
.pb-lead-end { fill: #8d959c; }
.pb-ghost { fill: none; stroke: #6b5332; stroke-width: 1; stroke-dasharray: 3 2.5; opacity: 0.75; }
.pb-ghost-name { fill: #5a4426; font-size: 8px; font-weight: 600; paint-order: stroke; stroke: #d9bd86; stroke-width: 2.5px; }
.pb-ghost-link { stroke-width: 2; stroke-dasharray: 2 3; opacity: 0.7; }
.pb-pin-mark { fill: #3b2a12; font-size: 7.5px; font-weight: 700; paint-order: stroke; stroke: #d9bd86; stroke-width: 2.5px; }

/* ------------------------------------------------------------ inventory */
.inv-body { flex: 1; min-height: 0; display: flex; gap: 0; }
.inv-stock { flex: 3 1 0; min-width: 0; overflow: auto; padding: 10px 14px; }
.inv-check { flex: 2 1 0; min-width: 260px; overflow: auto; padding: 10px 14px; border-left: 1px solid var(--border); }
.inv-check-head { display: flex; align-items: center; gap: 8px; }
.inv-check-head .spacer { flex: 1; }
.inv-body h3 { margin: 14px 0 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.inv-check-head h3 { margin: 0; }
.inv-add { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.inv-fields { display: contents; }
.inv-add input:not([type=checkbox]) { width: 110px; }
.inv-add #invQty { width: 64px; }
.inv-add #invNote { width: 140px; }
.inv-kit { color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.inv-error { color: var(--warn); min-height: 1.2em; margin-top: 4px; }
.inv-table { border-collapse: collapse; width: 100%; }
.inv-table td { padding: 2px 6px 2px 0; border-bottom: 1px solid var(--border); }
.inv-table .inv-desc { width: 45%; }
.inv-table .inv-qty { width: 64px; }
.inv-table .inv-note { width: 100%; }
.inv-del { padding: 0 8px; }
.inv-empty { color: var(--muted); }
#invCheck { list-style: none; margin: 8px 0 0; padding: 0; }
#invCheck li { display: flex; align-items: baseline; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.inv-line { flex: 1; }
.inv-names, .inv-have { color: var(--muted); }
.inv-have { margin-left: 6px; }
.inv-icon { width: 14px; font-weight: 700; text-align: center; }
.inv-ok .inv-icon { color: var(--ok); }
.inv-short .inv-icon, .inv-short .inv-have { color: var(--warn); }
.inv-missing .inv-icon, .inv-missing .inv-have { color: var(--red); }

/* Save / Cancel / Don't Save prompt (web/platform.js; the desktop app uses a native dialog) */
.confirm-dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 18px 20px 14px;
  max-width: 380px;
}
.confirm-dialog::backdrop {
  background: rgb(0 0 0 / 45%);
}
.confirm-message {
  margin: 0 0 6px;
  font-weight: 600;
}
.confirm-detail {
  margin: 0 0 16px;
  color: var(--muted);
}
.confirm-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.confirm-buttons .primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1a26;
}

/* Assistant panel (ui/chat.js): takes the sidebar's column while open */
.chat {
  display: none;
}
main.chat-open .sidebar {
  display: none;
}
main.chat-open .chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-left: 1px solid var(--border);
}
.chat-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.chat-head .spacer,
.chat-actions .spacer {
  flex: 1;
}
.chat-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  line-height: 1.45;
}
.chat-entry {
  overflow-wrap: anywhere;
}
.chat-user {
  align-self: flex-end;
  max-width: 85%;
  background: #1f3a52;
  border-radius: 10px 10px 2px 10px;
  padding: 6px 10px;
}
.chat-assistant code,
.chat-note code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  background: var(--panel-2);
  padding: 0 3px;
  border-radius: 3px;
}
.chat-tool {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--muted);
}
.chat-tool::before {
  content: '⚙ ';
}
.chat-tool.failed,
.chat-tool-error {
  color: var(--warn);
}
.chat-note,
.chat-muted,
.chat-pending {
  color: var(--muted);
}
.chat-pending {
  font-style: italic;
}
.chat-error {
  color: var(--red);
}
.chat-form {
  border-top: 1px solid var(--border);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chat-form textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  resize: vertical;
}
.chat-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}
.chat-actions .primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1a26;
}
main.chat-open {
  grid-template-columns: 150px 1fr 340px;
}

/* Account (ui/account.js) and My circuits (web/cloud.js) */
.sign-in-btn {
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1a26;
  font-weight: 600;
  padding: 6px 14px;
}
.sign-in-btn:hover {
  filter: brightness(1.08);
  border-color: var(--accent);
}
.avatar,
.avatar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  padding: 0;
  border: none;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.3px;
  background: var(--avatar, #4a6fa5);
  position: relative;
}
.avatar-btn {
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 3px transparent;
  transition: box-shadow 0.12s;
}
.avatar-btn:hover,
.avatar-btn[aria-expanded='true'] {
  box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--accent);
}
.avatar-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.avatar.large {
  width: 48px;
  height: 48px;
  font-size: 18px;
}
/* The provider's mark on the avatar's corner: who the account belongs to. */
.provider-badge {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px var(--panel);
}
.provider-badge svg {
  width: 10px;
  height: 10px;
}
.avatar.large .provider-badge {
  width: 20px;
  height: 20px;
}
.avatar.large .provider-badge svg {
  width: 13px;
  height: 13px;
}

/* Account menu: drops down from the profile button */
.account-menu {
  position: fixed;
  z-index: 50;
  width: 280px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgb(0 0 0 / 45%);
  padding: 6px;
  color: var(--text);
}
.account-menu-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.account-menu-who {
  min-width: 0;
}
.account-menu-name {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu-email,
.account-menu-via {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-menu-via {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 3px;
}
.account-menu-via svg {
  width: 12px;
  height: 12px;
  flex: none;
}
.account-menu [role='menuitem'] {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}
.account-menu [role='menuitem']:hover,
.account-menu [role='menuitem']:focus-visible {
  background: var(--panel-2);
  outline: none;
}
.account-menu hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 6px 0;
}
.account-menu .danger {
  color: var(--red);
}
.account-menu .account-menu-error {
  margin: 4px 10px;
  color: var(--red);
  font-size: 12px;
}
.account-menu .account-menu-error:empty {
  display: none;
}

/* Sign-in buttons in each provider's own style, with its logo */
.provider-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 42px;
  border-radius: 21px;
  font-weight: 500;
  font-size: 14px;
  padding: 0 16px;
}
.provider-btn svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.provider-google,
.provider-microsoft {
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #747775;
}
.provider-google:hover,
.provider-microsoft:hover {
  background: #f2f2f2;
  border-color: #747775;
}
.provider-github {
  background: #24292f;
  color: #fff;
  border: 1px solid #57606a;
}
.provider-github:hover {
  background: #32383f;
  border-color: #57606a;
}
.provider-btn:disabled {
  opacity: 0.6;
}
.signin-waiting {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
}
.signin-waiting:empty {
  display: none;
}
.signin-waiting::before {
  content: '';
  width: 12px;
  height: 12px;
  border: 2px solid var(--muted);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.account-dialog,
.cloud-dialog {
  width: min(420px, calc(100vw - 32px));
  max-width: none;
}
.signin-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 12px;
}
.account-fine {
  margin: 0 0 14px;
  font-size: 11px;
  color: var(--muted);
}
.account-fine a {
  color: var(--accent);
}
.confirm-buttons .spacer {
  flex: 1;
}
.account-delete {
  color: var(--red);
}
.cloud-error {
  margin: 0 0 10px;
  color: var(--red);
}
.cloud-error:empty {
  display: none;
}
.cloud-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.cloud-list {
  list-style: none;
  margin: 8px 0 12px;
  padding: 0;
  max-height: min(50vh, 420px);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}
.cloud-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px 0 0;
  border-bottom: 1px solid var(--border);
}
.cloud-list li:last-child {
  border-bottom: none;
}
.cloud-list .cloud-empty {
  padding: 12px;
  color: var(--muted);
}
.cloud-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  background: none;
  border: none;
  border-radius: 0;
  padding: 8px 10px;
  text-align: left;
}
.cloud-open:hover {
  background: var(--panel-2);
}
.cloud-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cloud-meta {
  font-size: 11px;
  color: var(--muted);
}
.cloud-dialog form input {
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 14px;
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
}
.chat-signin button {
  margin-left: 4px;
  background: var(--accent);
  border-color: var(--accent);
  color: #0b1a26;
}

/* Sign-in result page (web/signed-in.html) and the privacy page */
.signed-in-page,
.privacy-page {
  display: block;
  height: 100%;
  overflow-y: auto;
  margin: 0;
  background: var(--bg);
  color: var(--text);
}
.signed-in-box,
.privacy-page main {
  display: block;
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 16px;
  line-height: 1.55;
}
.signed-in-box a,
.privacy-page a {
  color: var(--accent);
}
.avatar-btn[hidden],
.sign-in-btn[hidden] {
  display: none;
}
