:root {
  color-scheme: dark;
  --bg: #111418;
  --panel: #1a1f25;
  --panel-2: #202832;
  --text: #eef3f7;
  --muted: #a8b3bd;
  --line: #36424d;
  --accent: #21c78a;
  --accent-2: #f4c542;
  --danger: #ff6b6b;
  --blue: #62a8ff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Noto Sans Georgian", Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: #151a20;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

.topbar span,
.hint {
  color: var(--muted);
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 10px;
}

button {
  border: 1px solid var(--line);
  color: var(--text);
  background: var(--panel-2);
  border-radius: 8px;
  padding: 9px 14px;
  cursor: pointer;
}

button:hover {
  border-color: var(--blue);
}

button.active {
  color: #062419;
  background: var(--accent-2);
  border-color: var(--accent-2);
  font-weight: 700;
}

.component-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(33, 199, 138, 0.16);
}

button.primary {
  color: #062419;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 700;
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(620px, 1fr) 360px;
  gap: 14px;
  padding: 14px;
}

.panel,
.board-section {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 8px;
  overflow: hidden;
}

.panel {
  padding: 14px;
}

.panel-head {
  display: grid;
  gap: 10px;
}

h2 {
  font-size: 16px;
  margin-bottom: 10px;
}

input[type="search"] {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111820;
  color: var(--text);
  padding: 10px;
}

.component-list {
  margin-top: 14px;
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 160px);
  overflow: auto;
  padding-right: 4px;
}

.category-title {
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
  margin: 6px 0;
}

.component-item {
  width: 100%;
  text-align: left;
  display: grid;
  gap: 3px;
  background: #151b22;
}

.component-item strong {
  font-size: 14px;
}

.component-item span {
  color: var(--muted);
  font-size: 12px;
}

.component-item small {
  color: var(--accent-2);
  font-size: 11px;
  letter-spacing: 0;
}

.toolbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 18px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #151a20;
}

.toolbar label {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  white-space: nowrap;
}

.toolbar output {
  color: var(--text);
  min-width: 52px;
}

.toolbar [hidden] {
  display: none !important;
}

.toolbar input[type="range"] {
  width: 108px;
}

.toolbar-context {
  min-width: 220px;
  color: var(--muted);
}

.toolbar-title {
  color: var(--text);
  font-weight: 700;
}

.toolbar-empty {
  color: var(--muted);
}

.context-control {
  padding: 4px 0;
}

.param-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar-param {
  display: flex;
  align-items: center;
  gap: 7px;
}

.toolbar-param select {
  min-width: 104px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161c;
  color: var(--text);
  padding: 7px 9px;
}

.zoom-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zoom-controls button {
  min-width: 36px;
  padding: 7px 10px;
}

.zoom-controls output {
  min-width: 54px;
  text-align: center;
}

.status-pill {
  min-width: 90px;
  text-align: center;
  padding: 7px 10px;
  border-radius: 999px;
  background: #26313b;
  color: var(--muted);
}

.status-pill.running {
  color: #062419;
  background: var(--accent);
  font-weight: 700;
}

.edit-pill {
  min-width: 180px;
  color: var(--text);
}

.board {
  height: calc(100vh - 160px);
  min-height: 540px;
  padding: 12px;
}

svg {
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background-color: #0f1419;
  background-image:
    linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
  background-size: 24px 24px;
}

.editable-wire {
  fill: none;
  stroke: #81909d;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
  cursor: grab;
}

.editable-wire-hit {
  fill: none;
  stroke: rgba(255, 255, 255, 0.001);
  stroke-width: 22;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: stroke;
  cursor: grab;
}

svg:active .editable-wire,
svg:active .editable-wire-hit {
  cursor: grabbing;
}

.editable-wire.signal.active,
.editable-wire.manual.active {
  stroke: var(--accent-2);
  filter: url("#glow");
}

.editable-wire.selected {
  stroke: var(--accent-2);
  filter: url("#glow");
}

.pin-lead {
  fill: none;
  stroke: #9cabb8;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.pin-lead.active,
.pin-lead.selected {
  stroke: var(--accent-2);
  filter: url("#glow");
}

.wire-bridge-cut,
.wire-bridge-hop {
  fill: none;
  stroke-linecap: round;
  pointer-events: none;
}

.wire-bridge-cut {
  stroke: #0f1419;
  stroke-width: 13;
}

.wire-bridge-hop {
  stroke: #a8b3bd;
  stroke-width: 8;
}

.wire-draft {
  fill: var(--accent-2);
  stroke: #fff2bd;
  stroke-width: 2;
}

.junction {
  cursor: move;
}

.junction circle {
  fill: var(--accent-2);
  stroke: #fff2bd;
  stroke-width: 2;
}

.junction.selected circle {
  fill: var(--accent);
  filter: url("#glow");
}

.placed-component {
  cursor: move;
}

.placed-component rect,
.placed-component circle {
  fill: #1b2730;
  stroke: #67b8ff;
  stroke-width: 2;
}

.placed-component line {
  stroke: #a5b5c4;
  stroke-width: 4;
  stroke-linecap: round;
}

.placed-component path {
  fill: #69272e;
  stroke: #ff7a7a;
  stroke-width: 2;
}

.placed-component.on circle:not(.pin) {
  fill: #9d232b;
  stroke: #ff5f66;
  filter: url("#glow");
}

.placed-component.on path {
  fill: #ff3f49;
}

.placed-component .pin {
  fill: #0f1419;
  stroke: var(--accent-2);
  stroke-width: 2;
  cursor: crosshair;
  pointer-events: all;
}

.pin-wrap:hover .pin,
.pin-wrap.selected-pin .pin {
  fill: var(--accent-2);
  stroke: #fff2bd;
  filter: url("#glow");
}

.pin-wrap.connected-pin .pin {
  fill: var(--accent);
  stroke: #fff2bd;
  stroke-width: 3;
}

.pin-wrap.connected-pin .pin-label {
  fill: #fff2bd;
}

.connection-dot {
  pointer-events: none;
}

.connection-dot circle {
  fill: rgba(244, 197, 66, 0.25);
  stroke: #fff2bd;
  stroke-width: 2;
}

.connection-dot .connection-core {
  fill: var(--accent-2);
  stroke: none;
}

.pin-label {
  fill: var(--accent-2);
  font-size: 10px;
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: #0f1419;
  stroke-width: 3px;
}

.placed-component text {
  fill: var(--text);
  font-size: 15px;
  text-anchor: middle;
  paint-order: stroke;
  stroke: #0f1419;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.placed-component .pin-label {
  fill: var(--accent-2);
  font-size: 10px;
  stroke-width: 3px;
}

.placed-component.selected rect,
.placed-component.selected circle {
  stroke: var(--accent-2);
  filter: url("#glow");
}

.probe {
  fill: var(--text);
  font-size: 17px;
  text-anchor: middle;
}

.probe {
  fill: var(--accent-2);
  font-weight: 700;
}

.metrics {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.metrics div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid #2a343f;
  padding-bottom: 7px;
}

dt {
  color: var(--muted);
}

dd {
  margin: 0;
  font-weight: 700;
}

textarea {
  width: 100%;
  height: 210px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: #dce8ef;
  background: #10161c;
  line-height: 1.45;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
}

canvas {
  width: 100%;
  height: 120px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0c1116;
}

.feedback-box {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.feedback-box label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.feedback-box input,
.feedback-box textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  color: var(--text);
  background: #10161c;
}

.feedback-box textarea {
  min-height: 96px;
  height: 96px;
  font-family: inherit;
}

.feedback-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.debug-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.inspector-card {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #141b22;
}

.inspector-card span,
.muted-row {
  color: var(--muted);
  font-size: 12px;
}

.mini-table {
  display: grid;
  gap: 6px;
  margin: 10px 0;
}

.mini-table div {
  display: grid;
  grid-template-columns: minmax(88px, 0.8fr) minmax(0, 1.4fr);
  gap: 8px;
  align-items: start;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.mini-table dt {
  color: var(--muted);
  font-size: 12px;
}

.mini-table dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.warning-list {
  display: grid;
  gap: 8px;
}

.warning-item {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151b22;
  color: var(--text);
  font-size: 12px;
}

.warning-item.warning {
  border-color: rgba(244, 197, 66, 0.7);
}

.warning-item.danger {
  border-color: rgba(255, 107, 107, 0.8);
  color: #ffd8d8;
}

.warning-item.info {
  border-color: rgba(98, 168, 255, 0.55);
}

.netlist-panel details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111820;
  padding: 8px 10px;
}

.netlist-panel summary {
  cursor: pointer;
  color: var(--accent-2);
  font-size: 12px;
}

.debug-json {
  max-height: 280px;
  overflow: auto;
  margin: 8px 0 0;
  color: #d9e7f5;
  font-size: 11px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.context-menu {
  position: fixed;
  z-index: 20;
  width: 240px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151b22;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.context-title {
  font-weight: 700;
  margin-bottom: 10px;
}

.context-row {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 10px;
}

.context-row select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10161c;
  color: var(--text);
  padding: 8px;
}

.muted-row {
  line-height: 1.35;
}

.danger-action {
  width: 100%;
  color: #fff4f4;
  border-color: rgba(255, 107, 107, 0.5);
  background: rgba(255, 107, 107, 0.14);
}

@media (max-width: 1180px) {
  body {
    min-width: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .board {
    height: 560px;
  }
}
