:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #637083;
  --line: #d8dee8;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --accent: #1f7a6d;
  --accent-strong: #155f55;
  --warn: #c06917;
  --danger: #b4232b;
  --wire: #2f4b7c;
  --node: #1f7a6d;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  border-color: #aab4c4;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-strong);
}

.ghost {
  background: transparent;
}

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

.topbar {
  align-items: center;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 20px;
  justify-content: space-between;
  padding: 18px 22px;
}

.topbar h1 {
  font-size: 24px;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0 0 6px;
}

.topbar p {
  color: var(--muted);
  margin: 0;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.workspace {
  display: grid;
  flex: 1;
  gap: 14px;
  grid-template-columns: 260px minmax(460px, 1fr) 310px;
  min-height: 0;
  padding: 14px;
}

.panel,
.bench {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 0;
}

.panel {
  display: flex;
  flex-direction: column;
  overflow: auto;
  padding: 16px;
}

.panel h2,
.bench h2 {
  font-size: 18px;
  line-height: 1.2;
  margin: 0;
}

.component-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.part {
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: grab;
  display: grid;
  gap: 10px;
  grid-template-columns: 54px 1fr;
  min-height: 74px;
  padding: 10px;
  user-select: none;
}

.part:hover {
  border-color: var(--accent);
}

.part:active {
  cursor: grabbing;
}

.symbol {
  align-items: center;
  background: #eef6f5;
  border-radius: 8px;
  display: flex;
  height: 48px;
  justify-content: center;
}

.part-name {
  display: block;
  font-size: 15px;
  margin-bottom: 3px;
}

.part-desc {
  color: var(--muted);
  display: block;
  font-size: 12px;
  line-height: 1.35;
}

.hint,
.lesson {
  background: #f3f6fa;
  border: 1px solid #e2e7ef;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  padding: 12px;
}

.hint p,
.summary p {
  margin: 6px 0 0;
}

.bench {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.bench-head {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  padding: 14px 16px;
}

.bench-tools {
  align-items: center;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 13px;
  gap: 12px;
  justify-content: flex-end;
}

.canvas-wrap {
  flex: 1;
  min-height: 520px;
  position: relative;
}

.canvas {
  background-color: #fbfcfe;
  background-image:
    linear-gradient(#e8edf4 1px, transparent 1px),
    linear-gradient(90deg, #e8edf4 1px, transparent 1px);
  background-size: 24px 24px;
  height: 100%;
  overflow: hidden;
  position: relative;
}

.wire-layer {
  height: 100%;
  inset: 0;
  pointer-events: none;
  position: absolute;
  width: 100%;
  z-index: 3;
}

.wire {
  stroke: var(--wire);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
  fill: none;
}

.wire-preview {
  opacity: 0.65;
  stroke-dasharray: 10 8;
}

.wire-current {
  animation: current-flow 0.75s linear infinite;
  fill: none;
  pointer-events: none;
  stroke: #f6b73c;
  stroke-dasharray: 2 16;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 7;
}

@keyframes current-flow {
  from {
    stroke-dashoffset: 0;
  }

  to {
    stroke-dashoffset: -18;
  }
}

.circuit-item {
  background: #fff;
  border: 1px solid #c9d2df;
  border-radius: 8px;
  box-shadow: 0 8px 18px rgba(24, 33, 47, 0.08);
  height: 84px;
  position: absolute;
  width: 132px;
  z-index: 2;
}

.circuit-item.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 109, 0.17), 0 8px 18px rgba(24, 33, 47, 0.08);
}

.component-label {
  color: var(--muted);
  font-size: 12px;
  left: 10px;
  max-width: 112px;
  overflow: hidden;
  position: absolute;
  right: 10px;
  text-align: center;
  text-overflow: ellipsis;
  top: 58px;
  white-space: nowrap;
}

.switch-toggle {
  background: #f7f9fc;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  color: var(--ink);
  font-size: 12px;
  height: 26px;
  min-height: 0;
  padding: 0 10px;
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 5;
}

.switch-toggle:hover {
  border-color: var(--accent);
}

.terminal {
  background: #fff;
  border: 3px solid var(--node);
  border-radius: 999px;
  cursor: crosshair;
  height: 18px;
  position: absolute;
  top: 33px;
  width: 18px;
  z-index: 4;
}

.terminal:hover {
  box-shadow: 0 0 0 5px rgba(31, 122, 109, 0.14);
}

.terminal.active {
  background: var(--node);
  box-shadow: 0 0 0 5px rgba(31, 122, 109, 0.18);
}

.component-svg {
  height: 48px;
  left: 16px;
  position: absolute;
  top: 13px;
  transform-origin: center;
  transition: transform 0.12s ease;
  width: 100px;
}

.bulb-glow {
  background: rgba(248, 189, 72, var(--glow, 0));
  border-radius: 999px;
  filter: blur(14px);
  height: 70px;
  left: 31px;
  pointer-events: none;
  position: absolute;
  top: 5px;
  width: 70px;
}

.inspector-content {
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
  min-height: 126px;
  padding-bottom: 14px;
}

.empty {
  color: var(--muted);
  line-height: 1.6;
  margin: 0;
}

.field {
  display: grid;
  gap: 7px;
  margin: 12px 0;
}

.field label {
  color: var(--muted);
  font-size: 13px;
}

.field input {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 38px;
  padding: 8px 10px;
  width: 100%;
}

.toggle-row {
  align-items: center;
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.toggle-row input {
  height: 18px;
  width: 18px;
}

.results h3,
.lesson h3 {
  font-size: 15px;
  margin: 0 0 10px;
}

.summary {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

.summary strong {
  color: var(--ink);
}

.result-list {
  display: grid;
  gap: 8px;
  margin: 0;
}

.result-line {
  background: #f7f9fc;
  border: 1px solid #e4e9f1;
  border-radius: 8px;
  padding: 9px;
}

.alert {
  border-left: 4px solid var(--warn);
  color: #70400c;
  padding-left: 10px;
}

.danger {
  border-left-color: var(--danger);
  color: var(--danger);
}

.lesson {
  margin-top: 16px;
}

.lesson ul {
  margin: 0;
  padding-left: 18px;
}

@media (max-width: 1080px) {
  .workspace {
    grid-template-columns: 220px minmax(400px, 1fr);
  }

  .inspector {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-start;
  }

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

  .canvas-wrap {
    min-height: 460px;
  }
}
