:root {
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  color: #20364c;
  background: #edf2f7;
  font-synthesis: none;
  --blue: #215cab;
  --navy: #18365a;
  --line: #d4dfe9;
  --muted: #536a80;
  --green: #167044;
  --amber: #a75b00;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  height: 100dvh;
  min-height: 560px;
  overflow: hidden;
}
button,
input {
  font: inherit;
}
button {
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: inherit;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}
button:hover {
  background: #edf4fd;
  border-color: #a2b9d4;
}
button:active {
  background: #ddeafb;
}
button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
button:focus-visible,
input:focus-visible {
  outline: 3px solid #78a4e0;
  outline-offset: 3px;
}
button[aria-pressed="true"] {
  color: var(--blue);
  background: #e6effb;
  border-color: var(--blue);
}
svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
button svg {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  flex-shrink: 0;
}
::selection {
  background: #d3e5fb;
  color: #143764;
}
input {
  caret-color: var(--blue);
}
* {
  scrollbar-width: thin;
  scrollbar-color: #a8b9ca #f2f6fa;
}
.appbar {
  height: 76px;
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 28px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  white-space: nowrap;
}
.brand svg {
  width: 32px;
  height: 32px;
  stroke: #c5dcff;
  stroke-width: 2;
}
.project {
  min-width: 0;
}
.project button {
  color: white;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  min-height: 26px;
  max-width: 290px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project strong {
  font-size: 15px;
}
.version {
  display: block;
  font-size: 12px;
  color: #c6d8ec;
  margin-top: 3px;
}
.appbar nav {
  margin-left: auto;
  display: flex;
  gap: 8px;
}
.appbar nav button {
  color: #e4eef9;
  background: transparent;
  border-color: #59718b;
  white-space: nowrap;
}
.appbar nav button:hover {
  background: #2c4e76;
}
.appbar nav #save {
  background: #e8f0fb;
  color: #18365a;
  border-color: #e8f0fb;
}
main {
  height: calc(100dvh - 76px);
  display: flex;
  flex-direction: column;
}
.canvasbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 0 24px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
#hint {
  font-size: 13px;
  color: var(--muted);
}
.badge {
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
  padding: 6px 9px;
  border-radius: 5px;
  background: #e8f0fb;
  color: #215397;
}
.badge.running {
  background: #e7f4ec;
  color: var(--green);
}
.view-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.view-actions button {
  min-height: 34px;
  font-size: 12px;
  padding: 5px 10px;
}
#canvasWrap {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #fff;
  overflow: hidden;
}
#canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  user-select: none;
}
.component {
  cursor: grab;
  outline: none;
}
.component:active {
  cursor: grabbing;
}
.component .body {
  fill: #fff;
  stroke: #536c85;
  stroke-width: 2.3;
}
.component.selected .body {
  stroke: var(--blue);
}
.component .selection {
  fill: #e9f1fc;
  stroke: #96b9e7;
  stroke-dasharray: 5 4;
}
.component text {
  fill: #314a63;
  stroke: none;
  font-size: 14px;
  text-anchor: middle;
  pointer-events: none;
}
.component .value {
  font-size: 12px;
  fill: #566d82;
}
.component .terminal-hit {
  stroke: transparent;
  stroke-width: 30;
  fill: transparent;
  cursor: crosshair;
}
.component .terminal {
  fill: #fff;
  stroke: #607a92;
  stroke-width: 2;
  pointer-events: none;
}
.component .terminal.hot {
  stroke: #b86600;
  fill: #fff3da;
}
.component .terminal.draft {
  fill: #215cab;
  stroke: #215cab;
}
.component.lit .bulb {
  fill: #ffe58b;
  stroke: #a96a05;
}
.component.lit .filament {
  stroke: #a96a05;
}
.component.switch-on .body {
  stroke: #167044;
}
.wire-line {
  stroke: #677f96;
  stroke-width: 2.7;
  fill: none;
  pointer-events: none;
}
.wire-line.hot {
  stroke: #bd6a08;
}
.wire-line.selected {
  stroke: #215cab;
  stroke-width: 4;
}
.wire-hit {
  stroke: transparent;
  stroke-width: 18;
  fill: none;
  cursor: pointer;
}
.draft-line {
  stroke: #215cab;
  stroke-width: 2;
  stroke-dasharray: 6 5;
  fill: none;
  pointer-events: none;
}
.readout {
  position: absolute;
  bottom: 18px;
  left: 24px;
  right: 24px;
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 12px;
  pointer-events: none;
  color: #536a80;
}
.readout strong {
  font-weight: 650;
  color: #2c465e;
}
.readout b {
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: #263d54;
}
.divider {
  width: 1px;
  height: 15px;
  background: #cfdae4;
}
.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7d91a4;
}
.state-dot.ok {
  background: #188553;
}
.state-dot.error {
  background: #bf3434;
}
.toolbar {
  min-height: 80px;
  padding: 14px 24px;
  display: flex;
  gap: 22px;
  align-items: center;
  border-top: 1px solid var(--line);
  background: #f7f9fc;
  flex-shrink: 0;
}
.toolgroup {
  display: flex;
  gap: 8px;
}
.toolgroup button {
  display: flex;
  align-items: center;
  gap: 7px;
}
.toolbar .run {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 156px;
  justify-content: center;
  background: var(--green);
  border-color: var(--green);
  color: #fff;
  font-weight: 650;
}
.toolbar .run:hover {
  background: #0d5a35;
}
.toolbar .run.running {
  background: #fff;
  color: #18365a;
  border-color: #8298ad;
}
footer {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  font-size: 11px;
  color: #5b7085;
  border-top: 1px solid #e0e7ef;
  background: #edf2f7;
  flex-shrink: 0;
}
#inspector {
  position: absolute;
  right: 20px;
  top: 18px;
  width: 240px;
  padding: 16px;
  background: #fff;
  border: 1px solid #cddbe8;
  border-radius: 10px;
  max-height: calc(100% - 80px);
  overflow: auto;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.panel-head h2 {
  font-size: 17px;
  margin: 0;
  line-height: 1.4;
}
.panel-head > button {
  border: 0;
  font-size: 24px;
  min-width: 40px;
  padding: 0;
  background: transparent;
  color: #5d7187;
}
label {
  display: block;
  font-size: 12px;
  font-weight: 550;
  color: #4e657b;
  margin: 15px 0 10px;
}
input:not([type="file"]) {
  display: block;
  width: 100%;
  min-height: 42px;
  padding: 9px 10px;
  margin-top: 7px;
  background: #fbfdff;
  color: #213a51;
  border: 1px solid #c4d3e1;
  border-radius: 6px;
}
#propertyForm button {
  width: 100%;
  font-size: 12px;
  background: #edf3fc;
  border-color: #c8d9ed;
  color: #194e93;
}
dl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  margin: 17px 0;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}
dt {
  color: #5c7085;
}
dd {
  margin: 0;
  color: #233d56;
  font-weight: 600;
}
#deleteSelected {
  font-size: 12px;
  width: 100%;
}
.danger {
  color: #a93333;
}
#toggleSwitch {
  width: 100%;
  margin-bottom: 10px;
  color: #12643b;
  border-color: #afcfbc;
}
#empty {
  position: absolute;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
  text-align: center;
  max-width: 85%;
  width: 360px;
}
#empty h1 {
  font-size: 23px;
  margin: 0 0 12px;
}
#empty p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
}
.primary {
  background: #215cab;
  color: #fff;
  border-color: #215cab;
}
.primary:hover {
  background: #174b90;
  color: #fff;
}
dialog {
  border: 1px solid #cbd9e5;
  border-radius: 14px;
  padding: 24px;
  max-width: min(560px, calc(100vw - 32px));
  width: 540px;
  color: #20364c;
  background: white;
  box-shadow: 0 20px 80px #102c4a38;
}
dialog::backdrop {
  background: #0c233e66;
}
dialog p {
  font-size: 14px;
  line-height: 1.8;
  color: #536a80;
  margin: 12px 0 18px;
}
dialog small {
  font-size: 12px;
  line-height: 1.7;
  color: #536a80;
}
.component-menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.component-menu button {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 17px 12px;
  gap: 8px;
}
.component-menu svg {
  width: 80px;
  height: 46px;
  stroke-width: 2;
}
.component-menu strong {
  font-size: 14px;
}
.component-menu small {
  font-size: 11px;
}
.example-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.example-list button {
  text-align: left;
  display: flex;
  flex-direction: column;
  padding: 13px 16px;
  gap: 5px;
}
.example-list strong {
  font-size: 14px;
}
.example-list small {
  font-size: 12px;
}
.text-button {
  background: transparent;
  color: #215cab;
  border: 0;
  margin-top: 14px;
}
.wide {
  width: 100%;
  margin: 10px 0;
}
.import-label {
  border: 1px dashed #a9bdcf;
  padding: 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}
input[type="file"] {
  display: block;
  width: 100%;
  margin-top: 12px;
  font-size: 12px;
}
ol {
  padding-left: 23px;
  color: #415a71;
  font-size: 14px;
  line-height: 2;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 130px;
  transform: translate(-50%, 12px);
  background: #18365a;
  color: white;
  border-radius: 7px;
  max-width: calc(100vw - 32px);
  width: max-content;
  padding: 12px 20px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s,
    transform 0.15s;
  z-index: 8;
}
#toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
[hidden] {
  display: none !important;
}
@media (max-width: 900px) {
  .appbar {
    gap: 18px;
    padding: 0 16px;
  }
  .brand span {
    display: none;
  }
  .appbar nav {
    gap: 5px;
  }
  .appbar nav button {
    padding: 8px 10px;
    font-size: 13px;
  }
  .project button {
    max-width: 190px;
  }
  .toolbar {
    gap: 10px;
    padding: 12px 16px;
  }
  .history {
    gap: 4px;
  }
  .toolbar button {
    padding: 9px 11px;
    font-size: 13px;
  }
  .canvasbar {
    padding: 0 16px;
  }
  .readout {
    left: 16px;
    right: 16px;
  }
  #inspector {
    width: 220px;
    right: 14px;
  }
  .toolbar .run {
    min-width: 125px;
  }
}
@media (max-width: 600px) {
  body {
    min-height: 520px;
  }
  .appbar {
    height: 105px;
    flex-wrap: wrap;
    align-content: center;
    gap: 9px 12px;
    padding: 10px 14px;
  }
  .brand svg {
    width: 27px;
    height: 27px;
  }
  .project {
    flex: 1;
  }
  .project button {
    max-width: 260px;
  }
  .project strong {
    font-size: 14px;
  }
  .version {
    font-size: 10px;
  }
  .appbar nav {
    width: 100%;
    justify-content: space-between;
    gap: 5px;
  }
  .appbar nav button {
    font-size: 12px;
    min-height: 34px;
    flex: 1;
    padding: 5px 8px;
  }
  main {
    height: calc(100dvh - 105px);
  }
  .canvasbar {
    height: 47px;
    padding: 0 12px;
    gap: 8px;
  }
  #hint {
    display: none;
  }
  .view-actions button {
    min-height: 32px;
    padding: 5px 8px;
  }
  .toolbar {
    min-height: 117px;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 12px;
  }
  .toolgroup:first-child {
    width: 100%;
  }
  .toolgroup:first-child button {
    flex: 1;
    justify-content: center;
    min-height: 43px;
  }
  .toolgroup:first-child svg {
    width: 18px;
    height: 18px;
  }
  .history {
    flex: 1;
  }
  .history button {
    min-height: 40px;
    font-size: 12px;
    padding: 6px 10px;
  }
  .toolbar .run {
    min-height: 40px;
    font-size: 12px;
    min-width: 127px;
  }
  .readout {
    bottom: 14px;
    left: 12px;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
  }
  .readout .divider {
    display: none;
  }
  .readout strong {
    flex-basis: 100%;
    order: -1;
  }
  footer {
    padding: 0 12px;
    height: 30px;
    font-size: 10px;
  }
  footer span:nth-child(2) {
    display: none;
  }
  #inspector {
    top: 10px;
    right: 10px;
    width: 205px;
    padding: 12px;
    max-height: calc(100% - 70px);
  }
  dialog {
    padding: 20px;
  }
  .component-menu {
    gap: 8px;
  }
  .component-menu button {
    padding: 12px 8px;
  }
  #toast {
    bottom: 160px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
.floating-tools {
  position: absolute;
  right: 20px;
  bottom: 65px;
  display: flex;
  flex-direction: column;
  padding: 4px;
  background: #fff;
  border: 1px solid #cbd9e5;
  border-radius: 9px;
  gap: 2px;
}
.floating-tools button {
  width: 46px;
  min-height: 44px;
  padding: 5px 2px;
  font-size: 11px;
  border: 0;
  border-radius: 5px;
}
.floating-tools button:nth-last-child(2),
.floating-tools button:nth-last-child(3) {
  font-size: 20px;
}
.floating-tools > span {
  height: 1px;
  background: #d9e2eb;
  margin: 3px;
}
#inspector:not([hidden]) ~ .floating-tools {
  right: 275px;
}
@media (max-width: 900px) {
  .appbar {
    gap: 16px;
  }
  .appbar nav {
    gap: 4px;
  }
  .appbar nav button {
    padding: 8px;
    font-size: 12px;
  }
}
@media (max-width: 600px) {
  .appbar nav button {
    padding: 5px;
    font-size: 11px;
  }
  .toolbar > #remove {
    min-height: 40px;
    padding: 7px 12px;
    font-size: 12px;
  }
  .floating-tools {
    right: 10px;
    bottom: 64px;
  }
  .floating-tools button {
    width: 44px;
    min-height: 38px;
  }
  #inspector:not([hidden]) ~ .floating-tools {
    right: 10px;
    visibility: hidden;
  }
  .readout {
    right: 68px;
  }
}
#dots circle {
  stroke: none;
  fill: #dce5ed;
}
#canvasWrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px;
  grid-template-rows: minmax(0, 1fr) 54px;
}
#canvas {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  width: 100%;
  height: 100%;
}
#grid {
  cursor: grab;
}
#canvasWrap.inspecting {
  grid-template-columns: minmax(0, 1fr) 272px;
}
#inspector {
  position: static;
  grid-column: 2;
  grid-row: 1;
  align-self: start;
  justify-self: center;
  margin: 14px 8px 0;
  width: 246px;
  max-height: calc(100% - 285px);
}
.floating-tools,
#inspector:not([hidden]) ~ .floating-tools {
  position: static;
  grid-column: 2;
  grid-row: 1;
  align-self: end;
  justify-self: center;
  margin: 0 0 12px;
  visibility: visible;
}
.readout {
  left: 20px;
  right: 20px;
  bottom: 17px;
}
.component text {
  font-size: var(--label-size, 14px);
}
.component .value {
  font-size: var(--value-size, 12px);
}
.component .terminal-hit {
  stroke: none;
  fill: transparent;
}
.version,
footer {
  font-size: 11px;
}
@media (max-width: 600px) {
  #canvasWrap {
    grid-template-columns: minmax(0, 1fr) 64px;
    grid-template-rows: minmax(0, 1fr) 62px;
  }
  #canvasWrap.inspecting {
    grid-template-columns: minmax(0, 1fr) 64px;
    grid-template-rows: minmax(0, 1fr) 230px 62px;
  }
  #inspector {
    grid-column: 1/-1;
    grid-row: 2;
    width: 100%;
    max-height: 230px;
    height: 230px;
    margin: 0;
    border-width: 1px 0 0;
    border-radius: 0;
    padding: 10px 14px;
  }
  #inspector .panel-head h2 {
    font-size: 14px;
  }
  #inspector form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 80px;
    align-items: end;
    gap: 8px;
  }
  #inspector form label {
    margin: 6px 0;
  }
  #inspector form button {
    margin-bottom: 6px;
    min-height: 42px;
  }
  #inspector dl {
    margin: 9px 0;
    gap: 5px;
  }
  #inspector #deleteSelected,
  #inspector #toggleSwitch {
    width: auto;
    padding: 6px 14px;
    min-height: 36px;
    margin: 0 6px 0 0;
  }
  .floating-tools button {
    width: 46px;
    min-height: 44px;
  }
  .floating-tools,
  #inspector:not([hidden]) ~ .floating-tools {
    margin-bottom: 6px;
  }
  .version,
  footer {
    font-size: 11px;
  }
  .readout {
    left: 12px;
    right: 12px;
    bottom: 14px;
  }
}
.pan-hint{margin-left:auto;color:#536a80;font-size:12px;white-space:nowrap}
