:root {
  --bg: #1e1f22;
  --panel: #2b2d30;
  --panel-2: #242629;
  --panel-3: #303338;
  --line: #3c3f44;
  --line-soft: #34373c;
  --text: #ced0d6;
  --muted: #858a96;
  --accent: #4c8dff;
  --accent-2: #6fbf73;
  --danger: #d85f5f;
  --warning: #d9a441;
  --shadow: 0 16px 42px rgb(0 0 0 / 0.38);
  --mono: "JetBrains Mono", "Cascadia Code", "Fira Code", monospace;
  --sans: "Segoe UI", "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background:
    radial-gradient(circle at 24% 20%, rgb(76 141 255 / 0.12), transparent 28%),
    linear-gradient(135deg, #191a1d, #24262b 52%, #17181b);
  color: var(--text);
  font-family: var(--sans);
}

button,
textarea,
input {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(#34373b, #292b2f);
  color: var(--text);
  cursor: pointer;
}

button:hover {
  border-color: #555b66;
  background: linear-gradient(#3d4147, #303338);
}

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

button.active {
  border-color: #f2b84b;
  color: #fff2bf;
  background: linear-gradient(#4a3519, #262018);
  box-shadow: 0 0 14px rgb(242 184 75 / 0.18);
}

.ide-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: 54px 1fr;
}

.topbar {
  display: grid;
  grid-template-columns: 270px 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 0 14px;
  background: linear-gradient(#303338, #25272b);
  border-bottom: 1px solid #17181b;
  box-shadow: 0 1px 0 rgb(255 255 255 / 0.04) inset;
}

.product-mark {
  display: flex;
  align-items: center;
  gap: 11px;
}

.product-mark strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0.2px;
}

.product-mark small {
  color: var(--muted);
  font-size: 11px;
}

.mark-grid {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background:
    linear-gradient(135deg, #ff7a45 0 50%, transparent 51%),
    linear-gradient(45deg, #4c8dff 0 48%, #6fbf73 49%);
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.16) inset;
}

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

.menu button,
.run-controls button {
  height: 31px;
  padding: 0 12px;
  font-size: 12px;
}

.language-picker {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 31px;
  padding: 0 9px;
  color: var(--muted);
  font-size: 11px;
  border: 1px solid rgb(255 255 255 / 0.08);
  border-radius: 8px;
  background: rgb(255 255 255 / 0.04);
}

.language-picker select {
  height: 23px;
  color: var(--text);
  border: 1px solid rgb(255 255 255 / 0.14);
  border-radius: 6px;
  background: #1f2226;
  font-size: 12px;
}

.run-controls {
  display: flex;
  gap: 7px;
}

.examples-dialog {
  width: min(900px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #2b2d33;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.42);
}

.examples-dialog::backdrop {
  background: rgb(0 0 0 / 0.56);
}

.simulation-notice-dialog {
  width: min(620px, calc(100vw - 32px));
  padding: 0;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #2b2d33;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.42);
}

.simulation-notice-dialog::backdrop {
  background: rgb(0 0 0 / 0.56);
}

.simulation-notice-modal {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  padding: 14px;
}

.simulation-notice-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  color: #fff2bf;
  border: 1px solid rgb(242 184 75 / 0.42);
  border-radius: 999px;
  background: linear-gradient(#4a3519, #262018);
  box-shadow: 0 0 14px rgb(242 184 75 / 0.14);
  font-size: 16px;
  font-weight: 800;
}

.simulation-notice-modal strong {
  display: block;
  margin-bottom: 6px;
  color: #d7dbe5;
  font-size: 14px;
}

.simulation-notice-modal p {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.42;
}

.simulation-notice-modal ul {
  display: grid;
  gap: 6px;
  margin: 0;
  padding-left: 16px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.38;
}

.simulation-notice-confirm {
  grid-column: 1 / -1;
  justify-self: center;
  min-width: 140px;
  height: 31px;
  padding: 0 12px;
  font-size: 12px;
}

.examples-modal {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.example-search {
  width: min(260px, 34vw);
  height: 30px;
  padding: 0 10px;
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #202226;
  font-size: 12px;
}

.modal-header strong,
.modal-header span {
  display: block;
}

.modal-header span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.examples-list {
  display: grid;
  gap: 14px;
  max-height: min(420px, 60vh);
  overflow-y: auto;
}

.example-board-group {
  display: grid;
  gap: 8px;
}

.example-board-title {
  color: #d7dbe5;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.example-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

@media (max-width: 760px) {
  .example-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .example-grid {
    grid-template-columns: 1fr;
  }

  .modal-header-actions {
    align-items: flex-end;
    flex-direction: column-reverse;
  }

  .example-search {
    width: 100%;
  }
}

.example-card {
  display: grid;
  gap: 4px;
  width: 100%;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #24262c;
}

.example-card:hover {
  border-color: rgb(76 141 255 / 0.65);
  background: #2e323b;
}

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

.example-detail {
  display: grid;
  gap: 14px;
}

.example-detail h3 {
  margin: 0;
  font-size: 18px;
}

.example-detail p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 13px;
}

.example-component-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  margin-top: 10px;
}

.example-component-list li {
  padding: 5px 8px;
  color: #d7dbe5;
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: #24262c;
  font-size: 12px;
}

.example-detail-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.example-detail-actions button {
  height: 31px;
  padding: 0 12px;
  font-size: 12px;
}

.modal-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.modal-field input,
.modal-field textarea {
  width: 100%;
  color: var(--text);
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #202226;
  font: inherit;
}

.modal-field input {
  height: 34px;
  padding: 0 10px;
}

.modal-field textarea {
  min-height: 92px;
  padding: 9px 10px;
  resize: vertical;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions button {
  height: 31px;
  padding: 0 12px;
  font-size: 12px;
}

button.primary,
.run-controls .primary {
  border-color: #3c7f45;
  background: linear-gradient(#397c43, #24612e);
  color: #eef8f0;
}

button.primary:hover,
.run-controls .primary:hover {
  border-color: #4f985a;
  background: linear-gradient(#438d4d, #2c7137);
}

button.is-compiling {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

button.is-compiling::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 2px solid rgb(255 255 255 / 0.25);
  border-top-color: #eef8f0;
  border-radius: 999px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.workspace-grid {
  --bottom-panel-height: 290px;
  min-height: 0;
  display: grid;
  grid-template-columns: 230px minmax(440px, 1fr) 290px;
  grid-template-rows: minmax(180px, 1fr) var(--bottom-panel-height);
  gap: 1px;
  background: #151619;
}

.tool-window,
.board-panel,
.bottom-panel {
  min-height: 0;
  background: var(--panel);
}

.tool-window {
  padding: 10px;
}

.tool-title,
.board-toolbar,
.editor-header {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #adb2bf;
  font-size: 12px;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.palette {
  min-height: 0;
  display: grid;
  grid-template-rows: 30px 1fr;
  gap: 6px;
}

.palette-scroll {
  min-height: 0;
  overflow-y: auto;
  padding-right: 2px;
}

.palette-group {
  display: grid;
  gap: 5px;
  margin-bottom: 10px;
}

.palette-group-title,
.palette-subgroup-title {
  color: #aeb4c1;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.palette-group-title {
  padding: 7px 2px 2px;
  border-top: 1px solid var(--line-soft);
}

.palette-group:first-child .palette-group-title {
  padding-top: 2px;
  border-top: 0;
}

.palette-subgroup-title {
  margin-top: 4px;
  color: #858b98;
}

.palette-item {
  min-height: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  text-align: left;
  font-size: 11px;
  border-radius: 6px;
}

.component-icon {
  width: 17px;
  height: 17px;
  border-radius: 5px;
  display: inline-block;
  flex: 0 0 auto;
  background: var(--accent);
}

.component-default-icon {
  background: linear-gradient(135deg, #68717f, #3c424c);
}

.board-icon {
  background: linear-gradient(135deg, #308d6b, #1f5f7a);
}

.arduino-nano-icon {
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0.22) 0 10%, transparent 11% 89%, rgb(255 255 255 / 0.22) 90%),
    linear-gradient(135deg, #2d8b7c, #1e4562);
}

.sensor-icon {
  background: linear-gradient(135deg, #d79a2b, #8b6225);
}

.resistor-icon {
  background: repeating-linear-gradient(90deg, #d6b66d 0 4px, #5a3d21 4px 7px);
}

.capacitor-icon {
  background: linear-gradient(90deg, #4c8dff 0 35%, #d8e4ff 36% 43%, #26354f 44% 56%, #d8e4ff 57% 64%, #4c8dff 65%);
}

.led-icon {
  background: radial-gradient(circle at 45% 35%, #ffb1a3, #d63f3f 60%, #5d1f1f);
}

.led-green-icon {
  background: radial-gradient(circle at 45% 35%, #c7ffd2, #35b96a 60%, #174d2c);
}

.led-blue-icon {
  background: radial-gradient(circle at 45% 35%, #c7ddff, #3578d6 60%, #18345f);
}

.led-yellow-icon {
  background: radial-gradient(circle at 45% 35%, #fff6b8, #e0b51f 60%, #5f4610);
}

.led-rgb-icon {
  background: conic-gradient(#f44747, #ffd447, #50e07d, #5c9dff, #f44747);
}

.shift-register-icon {
  background:
    repeating-linear-gradient(90deg, transparent 0 9%, #d8e4ff 10% 13%, transparent 14% 19%),
    linear-gradient(135deg, #273443, #111820);
}

.distance-icon {
  background: linear-gradient(135deg, #6272a4, #3f8f8c);
}

.rain-icon {
  background:
    radial-gradient(ellipse at 50% 18%, #7894b8 0 30%, transparent 31%),
    radial-gradient(circle at 32% 78%, #61c9ff 0 12%, transparent 13%),
    radial-gradient(circle at 55% 82%, #61c9ff 0 10%, transparent 11%),
    linear-gradient(135deg, #24384f, #182536);
}

.rain-sensor-icon {
  background:
    repeating-linear-gradient(90deg, rgb(86 196 255 / 0.75) 0 2px, transparent 2px 5px),
    linear-gradient(135deg, #c0a05a, #5f4722);
}

.light-icon {
  background:
    radial-gradient(circle at 50% 38%, #fff6b0 0 22%, rgb(255 200 84 / 0.7) 23% 42%, transparent 43%),
    linear-gradient(135deg, #5b4520, #1f2731);
}

.ldr-icon {
  background:
    repeating-linear-gradient(135deg, #d9b15e 0 5px, #47351e 5px 9px),
    radial-gradient(circle at 50% 50%, #ffe68a, #936a21);
}

.climate-icon {
  background:
    radial-gradient(circle at 34% 34%, #ffcf70 0 14%, transparent 15%),
    radial-gradient(ellipse at 62% 60%, #d9e7ff 0 28%, transparent 29%),
    linear-gradient(135deg, #31465e, #202a35);
}

.analog-source-icon {
  background:
    linear-gradient(90deg, transparent 0 18%, #ffb454 19% 24%, transparent 25% 75%, #ffb454 76% 81%, transparent 82%),
    radial-gradient(circle at 50% 52%, #ffd280, #8b5b20);
}

.mcp3008-icon {
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0.18) 0 8%, transparent 9% 91%, rgb(255 255 255 / 0.18) 92%),
    repeating-linear-gradient(90deg, transparent 0 10px, rgb(255 180 84 / 0.35) 10px 13px),
    linear-gradient(135deg, #5d4b27, #252b34);
}

.esp32-icon {
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0.18) 0 12%, transparent 13% 87%, rgb(255 255 255 / 0.18) 88%),
    linear-gradient(135deg, #204f62, #1c8576);
}

.palette-hint {
  margin-top: 10px;
  padding: 8px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  background: rgb(0 0 0 / 0.15);
}

.palette-empty {
  margin: 0;
  padding: 5px 8px;
  border: 1px dashed var(--line-soft);
  border-radius: 6px;
  color: #686e79;
  font-size: 11px;
}

.board-panel {
  display: grid;
  grid-template-rows: 40px 1fr;
}

.board-toolbar {
  height: 36px;
  padding: 0 12px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--panel-2);
}

.board-toolbar > div {
  padding: 3px 0;
}

.board-title {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.current-project-title {
  min-width: 0;
  max-width: 42vw;
  overflow: hidden;
  color: var(--text);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.board-toolbar button {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

.board {
  position: relative;
  overflow: hidden;
  touch-action: none;
  background:
    linear-gradient(rgb(255 255 255 / 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgb(255 255 255 / 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 45%, rgb(76 141 255 / 0.1), transparent 42%),
    #202226;
  background-size: 20px 20px, 20px 20px, auto, auto;
}

.board.space-panning {
  cursor: grab;
}

.board.panning {
  cursor: grabbing;
}

.board.locked .component {
  cursor: default;
}

.board-viewport {
  position: absolute;
  left: 0;
  top: 0;
  width: 4000px;
  height: 2400px;
  transform-origin: 0 0;
  will-change: transform;
}

.component-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.board-watermark {
  position: absolute;
  right: 24px;
  bottom: 18px;
  z-index: 1;
  color: rgb(255 255 255 / 0.08);
  font: 700 20px var(--mono);
  pointer-events: none;
}

.wire-layer {
  position: absolute;
  inset: 0;
  width: 4000px;
  height: 2400px;
  pointer-events: auto;
  z-index: 4;
}

.component {
  position: absolute;
  pointer-events: auto;
  z-index: 5;
  min-width: 118px;
  border: 1px solid #4a4e57;
  border-radius: 11px;
  background: linear-gradient(145deg, #343840, #24272d);
  box-shadow: var(--shadow);
  user-select: none;
}

.delete-component {
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 12;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  padding: 0;
  border-color: #7d3838;
  border-radius: 50%;
  background: linear-gradient(#a84646, #743131);
  color: #fff;
  font: 700 16px/1 var(--sans);
  opacity: 0;
  transform: scale(0.82);
  transition: opacity 120ms ease, transform 120ms ease;
}

.component:hover .delete-component,
.component.selected .delete-component {
  opacity: 1;
  transform: scale(1);
}

.component.selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.component-header {
  padding: 8px 10px;
  border-bottom: 1px solid rgb(255 255 255 / 0.08);
  font-size: 12px;
  font-weight: 700;
}

.component-body {
  position: relative;
  min-height: 74px;
  padding: 10px;
  color: var(--muted);
  font-size: 12px;
}

.arduino {
  width: 205px;
  background: linear-gradient(145deg, #234f5d, #1e333b);
}

.arduino .component-visual {
  height: 58px;
}

.esp32-devkit {
  width: 310px;
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0.05) 0 9px, transparent 10px calc(100% - 10px), rgb(255 255 255 / 0.05) calc(100% - 9px)),
    linear-gradient(145deg, #1f5866, #1d343d 58%, #20272e);
}

.esp32-devkit .component-visual {
  height: 92px;
  margin: 70px 38px 0;
  border: 1px solid rgb(255 255 255 / 0.12);
  background:
    radial-gradient(circle at 70% 35%, rgb(111 191 115 / 0.28), transparent 20%),
    linear-gradient(135deg, #263641, #151d24);
}

.hcsr04 {
  width: 160px;
  background: linear-gradient(145deg, #5a4625, #30271c);
}

.resistor {
  width: 134px;
}

.capacitor {
  width: 134px;
}

.led {
  width: 118px;
}

.distance {
  width: 190px;
}

.rain-toggle {
  width: 180px;
  background: linear-gradient(145deg, #273d55, #1d2634);
}

.fc37-rain-sensor {
  width: 170px;
  background: linear-gradient(145deg, #5a4826, #2d271d);
}

.light-level {
  width: 180px;
  background: linear-gradient(145deg, #554224, #242832);
}

.ldr-light-sensor {
  width: 134px;
  background: linear-gradient(145deg, #5a4826, #2b271d);
}

.climate-environment {
  width: 210px;
  background: linear-gradient(145deg, #31465e, #202a35);
}

.analog-voltage-source {
  width: 180px;
  background: linear-gradient(145deg, #5a4826, #252b34);
}

.shift-register-74hc595 {
  background: linear-gradient(145deg, #2b3442, #151b23);
}

.arduino-nano {
  background:
    linear-gradient(90deg, rgb(255 255 255 / 0.08) 0 7%, transparent 8% 92%, rgb(255 255 255 / 0.08) 93%),
    linear-gradient(145deg, #236a6d, #173244);
}

.terminal {
  appearance: none;
  position: absolute;
  width: 12px;
  height: 12px;
  min-width: 12px;
  min-height: 12px;
  padding: 0;
  display: block;
  aspect-ratio: 1;
  border: 2px solid #1c1e22;
  border-radius: 50%;
  background: #9aa0aa;
  line-height: 0;
  box-shadow: 0 0 0 1px rgb(255 255 255 / 0.22);
  cursor: pointer;
  z-index: 8;
}

.terminal:hover,
.terminal.pending {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgb(76 141 255 / 0.2);
}

.terminal-label {
  position: absolute;
  color: #bbc0cc;
  font: 10px var(--mono);
  pointer-events: none;
}

.terminal.left {
  left: -7px;
}

.terminal.right {
  right: -7px;
}

.terminal.top {
  top: -7px;
}

.terminal.bottom {
  bottom: -7px;
}

.terminal.power {
  background: #d9822b;
}

.terminal.ground {
  background: #9da3ad;
}

.terminal.signal {
  background: #4c8dff;
}

.terminal.environment {
  background: #64b7ad;
}

.component-visual {
  height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  gap: 7px;
  color: #dce0e8;
  background: rgb(0 0 0 / 0.18);
  font: 700 12px var(--mono);
}

.built-in-leds {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
}

.built-in-led {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 5px;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 999px;
  color: #828895;
  font: 700 9px var(--mono);
  background: rgb(0 0 0 / 0.16);
}

.built-in-led-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #424852;
}

.built-in-led.on .built-in-led-dot {
  background: #ffb454;
  box-shadow: 0 0 10px rgb(255 180 84 / 0.78);
}

.built-in-led.green.on .built-in-led-dot {
  background: #6fbf73;
  box-shadow: 0 0 10px rgb(111 191 115 / 0.78);
}

.built-in-led.blue.on .built-in-led-dot {
  background: #5c9dff;
  box-shadow: 0 0 10px rgb(92 157 255 / 0.78);
}

.built-in-led.on {
  color: #dce0e8;
}

.component-select-row {
  height: 36px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 7px;
  color: #dce0e8;
  font: 700 11px var(--mono);
}

.component-select-row select,
.editable-property select,
.editable-property input:not([type="checkbox"]):not([type="radio"]) {
  min-width: 0;
  height: 24px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1e1f22;
  color: var(--text);
  font: 11px var(--mono);
}

.component-select-row select,
.editable-property select {
  padding: 0 5px;
}

.editable-property input:not([type="checkbox"]):not([type="radio"]) {
  width: 130px;
  accent-color: var(--accent);
}

.editable-property input[type="checkbox"],
.editable-property input[type="radio"] {
  width: 13px;
  height: 13px;
  accent-color: var(--accent-2);
}

.led-glow {
  width: 38px;
  height: 38px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd0c7, #8a2d2d 55%, #321515);
  opacity: 0.28;
  transition: opacity 180ms ease, box-shadow 180ms ease;
}

.led-green .led-glow {
  background: radial-gradient(circle at 35% 30%, #b5d9bd, #245338 55%, #102218);
}

.led-blue .led-glow {
  background: radial-gradient(circle at 35% 30%, #b8c8e6, #263d68 55%, #101827);
}

.led-yellow .led-glow {
  background: radial-gradient(circle at 35% 30%, #efe8ad, #6c5b20 55%, #261f0c);
}

.led-rgb {
  --rgb-led-color: #000000;
  --rgb-led-brightness: 0;
}

.led-rgb .rgb-led-glow {
  background:
    radial-gradient(circle at 35% 30%, rgb(255 255 255 / 0.75), var(--rgb-led-color) 52%, #111827 76%);
  opacity: max(0.24, calc(0.24 + var(--rgb-led-brightness) * 0.76));
  box-shadow: none;
}

.led.on .led-glow {
  opacity: 1;
  box-shadow: 0 0 24px #f44747, 0 0 52px rgb(244 71 71 / 0.5);
}

.led-green.on .led-glow {
  background: radial-gradient(circle at 35% 30%, #cbffd6, #1f8f4e 55%, #12351f);
  box-shadow: 0 0 24px #50e07d, 0 0 52px rgb(80 224 125 / 0.5);
}

.led-blue.on .led-glow {
  background: radial-gradient(circle at 35% 30%, #c8dcff, #2857aa 55%, #111e3b);
  box-shadow: 0 0 24px #5c9dff, 0 0 52px rgb(92 157 255 / 0.5);
}

.led-yellow.on .led-glow {
  background: radial-gradient(circle at 35% 30%, #fff8b8, #d8a91e 55%, #44320f);
  box-shadow: 0 0 24px #ffd447, 0 0 52px rgb(255 212 71 / 0.5);
}

.led-rgb.on .rgb-led-glow {
  box-shadow:
    0 0 calc(14px + var(--rgb-led-brightness) * 24px) var(--rgb-led-color),
    0 0 calc(28px + var(--rgb-led-brightness) * 46px) color-mix(in srgb, var(--rgb-led-color) 55%, transparent);
}

.rgb-led-readout {
  font: 700 10px var(--mono);
  color: #cbd3e2;
  background: rgb(0 0 0 / 0.18);
  border-radius: 999px;
  padding: 3px 8px;
}

.distance-readout {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font: 12px var(--mono);
}

.wifi-readout,
.rain-readout,
.rain-sensor-readout,
.light-readout,
.light-sensor-readout,
.climate-readout,
.bmp280-readout,
.analog-readout,
.adc-readout,
.button-readout,
.buzzer-readout,
.lcd-readout,
.shift-register-readout,
.dht-readout,
.servo-readout,
.pump-readout,
.relay-readout,
.reservoir-readout {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  font: 12px var(--mono);
}

.button-pulse-control {
  width: 100%;
  height: 34px;
  border-color: #3d566f;
  border-radius: 9px;
  background: linear-gradient(#26394c, #172331);
  color: #dceaff;
  font: 700 12px var(--mono);
}

.button-pulse-control:active,
.pull-up-button.is-pressed .button-pulse-control {
  border-color: #65a9ff;
  background: linear-gradient(#2f5f95, #1b3c65);
  box-shadow: 0 0 18px rgb(92 157 255 / 0.35);
}

.wifi-checkbox-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  color: #dce0e8;
  font: 11px var(--mono);
}

.wifi-checkbox-row input {
  width: 13px;
  height: 13px;
  accent-color: var(--accent-2);
}

.distance input,
.rain-toggle input[type="range"],
.light-level input[type="range"],
.climate-environment input[type="range"],
.analog-voltage-source input[type="range"],
.water-pump input[type="range"],
.water-reservoir input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

.shift-register-outputs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.shift-output {
  display: grid;
  place-items: center;
  min-height: 22px;
  border: 1px solid #3a4654;
  border-radius: 6px;
  background: #161d25;
  color: #7f8b99;
  font: 800 10px var(--mono);
}

.shift-register-74hc595.outputs-enabled .shift-output.is-on {
  border-color: #45d6c4;
  color: #d7fff9;
  background: linear-gradient(135deg, #1e5a58, #152d34);
  box-shadow: 0 0 12px rgb(69 214 196 / 0.32);
}

.nano-chip {
  display: grid;
  place-items: center;
  min-height: 190px;
  margin: 18px 34px;
  border: 1px solid #3c8a86;
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 18%, #d8e4ff 0 5%, transparent 6%),
    linear-gradient(145deg, #174854, #101c27);
  color: #c8fff8;
  font: 900 18px var(--mono);
  letter-spacing: 0.18em;
}

.water-pump .pump-impeller,
.solid-state-relay-1ch .relay-channel,
.water-reservoir .reservoir-waterline {
  display: grid;
  place-items: center;
  min-height: 34px;
  border: 1px solid #34485e;
  border-radius: 10px;
  background: linear-gradient(135deg, #172331, #101922);
  color: #9fb2c8;
  font: 800 11px var(--mono);
  letter-spacing: 0.08em;
}

.water-pump.is-running .pump-impeller {
  border-color: #45d6c4;
  color: #b7fff5;
  box-shadow: inset 0 0 18px rgb(69 214 196 / 0.25), 0 0 18px rgb(69 214 196 / 0.22);
}

.solid-state-relay-1ch.is-active .relay-channel {
  border-color: #ffb454;
  color: #ffe3ad;
  background: linear-gradient(135deg, #443019, #1d211c);
  box-shadow: inset 0 0 18px rgb(255 180 84 / 0.25), 0 0 18px rgb(255 180 84 / 0.2);
}

.water-reservoir .reservoir-waterline {
  border-color: #315d86;
  background: linear-gradient(0deg, rgb(55 146 210 / 0.42), rgb(23 35 49 / 0.88));
  color: #d6efff;
}

.water-reservoir.is-overflowing .reservoir-waterline {
  border-color: #72d7ff;
  box-shadow: 0 0 20px rgb(114 215 255 / 0.38);
}

.compact-slider-row {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  color: #dce0e8;
  font: 10px var(--mono);
}

.rain-sensor-plate {
  height: 44px;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 8px;
  background:
    repeating-linear-gradient(90deg, transparent 0 8px, rgb(214 172 92 / 0.55) 8px 11px),
    linear-gradient(135deg, #40301d, #171512);
  transition: box-shadow 180ms ease, background 180ms ease;
}

.fc37-rain-sensor.wet .rain-sensor-plate {
  background:
    repeating-linear-gradient(90deg, transparent 0 8px, rgb(97 201 255 / 0.58) 8px 11px),
    radial-gradient(circle at 35% 35%, rgb(97 201 255 / 0.36), transparent 42%),
    linear-gradient(135deg, #21364f, #141b24);
  box-shadow: 0 0 22px rgb(97 201 255 / 0.32);
}

.ldr-photoresistor {
  height: 44px;
  border: 1px solid rgb(255 255 255 / 0.12);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 0 14%, #d8b25f 15% 19%, transparent 20% 80%, #d8b25f 81% 85%, transparent 86%),
    repeating-linear-gradient(135deg, transparent 0 8px, rgb(216 178 95 / 0.62) 8px 11px),
    radial-gradient(circle at 50% 50%, rgb(255 180 84 / 0.14), transparent 45%),
    linear-gradient(135deg, #352a1d, #151512);
  transition: box-shadow 180ms ease, background 180ms ease, opacity 180ms ease;
}

.ldr-light-sensor.dark .ldr-photoresistor {
  opacity: 0.62;
}

.ldr-light-sensor.dim .ldr-photoresistor {
  box-shadow: 0 0 14px rgb(255 180 84 / 0.18);
}

.ldr-light-sensor.bright .ldr-photoresistor {
  background:
    linear-gradient(90deg, transparent 0 14%, #ffe59a 15% 19%, transparent 20% 80%, #ffe59a 81% 85%, transparent 86%),
    repeating-linear-gradient(135deg, transparent 0 8px, rgb(255 229 154 / 0.72) 8px 11px),
    radial-gradient(circle at 50% 50%, rgb(255 230 138 / 0.38), transparent 48%),
    linear-gradient(135deg, #47361f, #1b1710);
  box-shadow: 0 0 24px rgb(255 210 92 / 0.32);
}

.inspector {
  min-height: 0;
  overflow-y: auto;
}

.inspector-content {
  padding-top: 8px;
}

.inspector-signals {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
}

.property-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
}

.property-row span:first-child {
  color: var(--muted);
}

.property-row code {
  color: #c6d5ff;
  font-family: var(--mono);
}

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

.bottom-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-rows: 7px 34px 1fr;
  border-top: 1px solid #151619;
}

.bottom-resize-handle {
  height: 7px;
  cursor: ns-resize;
  background:
    linear-gradient(90deg, transparent, rgb(76 141 255 / 0.35), transparent),
    #1b1d20;
  border-top: 1px solid #111215;
  border-bottom: 1px solid #34373c;
}

.bottom-resize-handle:hover {
  background:
    linear-gradient(90deg, transparent, rgb(76 141 255 / 0.65), transparent),
    #20242a;
}

.resizing-bottom-panel {
  cursor: ns-resize;
  user-select: none;
}

.tabs {
  display: flex;
  align-items: end;
  gap: 3px;
  padding: 0 8px;
  background: var(--panel-2);
}

.tabs button {
  height: 28px;
  padding: 0 14px;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  font-size: 12px;
}

.tabs .active {
  background: var(--panel);
  border-bottom-color: var(--panel);
}

.bottom-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) 430px;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: #151619;
}

.bottom-view,
.runtime-panel {
  min-height: 0;
  background: var(--panel);
}

.editor-header {
  padding: 0 12px;
  background: #25272b;
  border-bottom: 1px solid var(--line-soft);
  text-transform: none;
}

.firmware-target {
  max-width: 240px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1e1f22;
  color: var(--text);
  font: 11px var(--mono);
}

.code-editor {
  width: 100%;
  height: calc(100% - 30px);
  background: #1e1f22;
  overflow: hidden;
}

.cm-editor {
  outline: none;
}

.cm-focused {
  outline: none !important;
}

.runtime-panel {
  display: contents;
}

.panel-card {
  position: relative;
  min-height: 0;
  padding: 10px;
  overflow: auto;
  background: var(--panel);
}

.bottom-view {
  grid-column: 2;
}

.bottom-view.active {
  grid-column: 1;
  grid-row: 1 / -1;
}

.panel-card[data-bottom-panel="serial"] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-card strong {
  display: block;
  margin-bottom: 8px;
  color: #adb2bf;
  font-size: 12px;
}

pre {
  margin: 0;
  color: #b6bac5;
  font: 12px/1.45 var(--mono);
  white-space: pre-wrap;
}

.signal-monitor {
  display: grid;
  gap: 8px;
}

.serial-monitor {
  display: grid;
  flex: 1;
  gap: 6px;
  min-height: 0;
  overflow-y: auto;
  font: 11px var(--mono);
}

.serial-actions {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--line-soft);
  background: var(--panel);
}

.serial-clear-button,
.serial-autoscroll-toggle {
  height: 24px;
  padding: 0 9px;
  font-size: 11px;
  box-shadow: 0 8px 18px rgb(0 0 0 / 0.32);
}

.serial-clear-button {
  border-color: #5a3b35;
  background: linear-gradient(#3e3734, #2b2827);
  color: #d9b8ad;
}

.serial-clear-button:hover {
  border-color: #8d574a;
  background: linear-gradient(#50413d, #342d2b);
}

.serial-controls {
  display: grid;
  grid-template-columns: minmax(112px, 0.85fr) 88px minmax(0, 1fr) auto;
  flex: 0 0 auto;
  gap: 6px;
  margin-bottom: 8px;
}

.serial-controls input,
.serial-controls select {
  min-width: 0;
  height: 24px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #1e1f22;
  color: var(--text);
  font: 11px var(--mono);
}

.serial-controls input::placeholder {
  color: #656b76;
  font-size: 11px;
}

.serial-controls button {
  height: 24px;
  padding: 0 8px;
  font-size: 11px;
}

.serial-autoscroll-toggle {
  min-width: 58px;
  border-color: #414750;
  color: #7f8794;
  font: 700 11px/1 var(--mono);
}

.serial-autoscroll-toggle.active {
  border-color: rgb(76 141 255 / 0.72);
  background: linear-gradient(#30425c, #25344a);
  color: #c8d9ff;
  box-shadow: 0 0 0 1px rgb(76 141 255 / 0.18) inset;
}

.serial-row {
  display: grid;
  grid-template-columns: 42px 74px 1fr;
  align-items: start;
  gap: 8px;
  padding: 6px 7px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: rgb(0 0 0 / 0.14);
}

.serial-direction {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  padding: 2px 5px;
  border-radius: 5px;
  color: #101317;
  font-weight: 800;
}

.serial-direction.tx {
  background: #6fbf73;
}

.serial-direction.rx {
  background: #d9a441;
}

.serial-meta {
  color: var(--muted);
}

.serial-data {
  white-space: pre-wrap;
  word-break: break-word;
}

.signal-row {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  align-items: center;
  gap: 8px;
  font: 11px var(--mono);
}

.signal-card {
  display: grid;
  gap: 7px;
  padding: 9px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: rgb(0 0 0 / 0.14);
}

.signal-card-title {
  color: #adb2bf;
  font: 700 11px var(--mono);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.signal-track {
  height: 18px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #191b1f;
  overflow: hidden;
}

.signal-fill {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 180ms ease;
}

.signal-value {
  color: #c6d5ff;
}

.problem-list {
  margin: 0;
  padding-left: 18px;
  color: #c5c9d3;
  font-size: 12px;
}

.problem-list li {
  margin-bottom: 6px;
}

.wire {
  fill: none;
  stroke: var(--wire-color, #8ab4ff);
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.wire-group.selected .wire {
  stroke: #ffd166;
  stroke-width: 4;
}

.wire-hit {
  fill: none;
  stroke: #000;
  stroke-width: 18;
  stroke-linecap: round;
  opacity: 0;
  pointer-events: stroke;
}

.delete-wire {
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
}

.wire-group:hover .delete-wire {
  opacity: 1;
  pointer-events: all;
}

.delete-wire circle {
  fill: #8d3636;
  stroke: #e28b8b;
  stroke-width: 1;
}

.delete-wire text {
  fill: #fff;
  font: 700 16px var(--sans);
  transform: translateY(-1px);
  user-select: none;
}

#signalMonitor > p.muted, #inspectorContent > p.muted, .palette-scroll > p.muted {
  font-size: 12px;
  line-height: 15px;
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }

  .ide-shell {
    height: auto;
    min-height: 100vh;
  }

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

  .workspace-grid {
    grid-template-rows: auto 480px auto 520px;
  }

  .bottom-panel {
    grid-column: auto;
  }
}
