:root {
  color-scheme: dark;
  --bg: #101616;
  --panel: #171e1e;
  --edge: #34403d;
  --text: #f0f3ea;
  --dim: #acb7b2;
  --acid: #d1f88a;
  font:
    16px/1.45 "Segoe UI",
    Arial,
    sans-serif;
  color: var(--text);
  background: var(--bg);
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}
button,
input,
select {
  font: inherit;
}
button,
a {
  touch-action: manipulation;
}
button {
  color: inherit;
  cursor: pointer;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}
button:disabled {
  opacity: 0.52;
  cursor: wait;
}
header,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(16px, 3.4vw, 64px);
  background: #111717;
  gap: 16px;
}
header {
  height: 74px;
  border-bottom: 1px solid var(--edge);
}
.brand {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-size: 1.45rem;
  font-weight: 650;
  letter-spacing: -0.055em;
}
.brand img {
  width: 35px;
}
.brand b {
  color: var(--acid);
  font-weight: 500;
}
.head-label,
.foot-hint,
.hint,
.view-mode {
  font-size: 0.83rem;
  color: var(--dim);
}
.head-label {
  margin-right: auto;
  padding-left: 21px;
  border-left: 1px solid var(--edge);
  margin-left: 7px;
}
.quiet,
.tools button {
  border: 1px solid var(--edge);
  background: #1b2423;
  border-radius: 7px;
  padding: 7px 11px;
}
.quiet:hover,
.tools button:hover,
.tab:hover {
  background: #303b36;
}
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(300px, 29vw, 440px);
  flex: 1;
  min-height: 540px;
}
#stage {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 500px;
  background: radial-gradient(
    ellipse at 47% 48%,
    #35423d 0%,
    #222e2c 35%,
    #162120 78%
  );
}
#stage:before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: radial-gradient(#82958c55 0.9px, transparent 0.9px);
  background-size: 20px 20px;
  pointer-events: none;
  opacity: 0.58;
}
#viewport,
#labels {
  position: absolute;
  inset: 0;
}
#viewport canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}
#labels {
  pointer-events: none;
}
.tag {
  position: absolute;
  transform: translate(-50%, 0);
  color: #dfefdb;
  background: #17211ff2;
  border: 1px solid #657a68;
  border-radius: 4px;
  font:
    600 0.72rem/1.3 "Segoe UI",
    sans-serif;
  padding: 2px 6px;
  white-space: nowrap;
}
.stage-top,
.stage-bottom {
  position: absolute;
  left: clamp(14px, 2.5vw, 40px);
  right: clamp(14px, 2.5vw, 40px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 1;
  pointer-events: none;
}
.stage-top {
  top: 24px;
}
.stage-bottom {
  bottom: 20px;
  gap: 8px;
}
.kicker,
.eyebrow,
.micro,
.tab small,
.mono {
  font:
    600 0.73rem/1.4 Consolas,
    monospace;
  letter-spacing: 0.11em;
}
.kicker {
  color: #dfeddf;
  display: flex;
  gap: 9px;
  align-items: center;
}
.kicker i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--acid);
}
.tools {
  pointer-events: auto;
  display: flex;
  gap: 4px;
}
.tools button {
  min-width: 35px;
  padding: 2px 6px;
  font-size: 1.25rem;
}
.view-mode {
  font-family: Consolas, monospace;
}
.hint {
  color: #c3cfc9;
}
.unavailable {
  position: absolute;
  inset: 25%;
  display: grid;
  place-content: center;
  text-align: center;
}
aside {
  padding: clamp(24px, 3.3vw, 58px);
  background: var(--panel);
  border-left: 1px solid var(--edge);
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.eyebrow,
.micro {
  color: var(--acid);
}
h1 {
  font-size: clamp(2.4rem, 4.1vw, 4.5rem);
  letter-spacing: -0.065em;
  line-height: 0.99;
  margin: 17px 0 16px;
  font-weight: 620;
}
h1 span {
  color: var(--acid);
}
.intro,
dialog p {
  color: #bdc9c2;
  line-height: 1.55;
}
.intro {
  margin: 0 0 26px;
}
.card {
  border-top: 1px solid var(--edge);
  padding: 15px 0 3px;
}
.micro {
  margin: 0 0 8px;
  color: #a9bcad;
}
.line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 6px 0;
  color: var(--dim);
  font-size: 0.88rem;
}
.line strong {
  color: var(--text);
  font-size: 0.88rem;
  text-align: right;
  font-weight: 550;
}
.primary {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: var(--acid);
  color: #172216;
  font-weight: 700;
  padding: 13px 16px;
  margin-top: 14px;
}
.primary:hover {
  background: #dfffac;
}
.notice {
  font-size: 0.85rem;
  color: #ccd7ce;
  min-height: 1.2em;
  margin: 10px 0 0;
}
.notice a {
  color: var(--acid);
}
.parts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.parts button,
.step {
  background: transparent;
  border: 1px solid var(--edge);
  border-radius: 5px;
  padding: 7px;
  text-align: left;
  color: #bcc6c0;
  font-size: 0.86rem;
}
.parts button[aria-pressed="true"],
.step[aria-pressed="true"] {
  border-color: #a8c57a;
  color: var(--acid);
  background: #222f23;
}
.steps {
  display: grid;
  gap: 5px;
}
.step span {
  color: #a4ba95;
  font-family: monospace;
  margin-right: 12px;
}
.detail {
  margin: 12px 0 0;
  font-size: 0.9rem;
  color: #ced9d0;
  min-height: 3em;
}
footer {
  min-height: 77px;
  border-top: 1px solid var(--edge);
}
nav {
  display: flex;
  gap: 7px;
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  padding: 10px 16px;
  border-radius: 6px;
  color: #bdc7c0;
  font-weight: 550;
}
.tab small {
  margin-right: 7px;
  color: #91a39a;
}
.tab.active {
  border-color: #53654a;
  background: #252f23;
  color: var(--acid);
}
.tab.active small {
  color: var(--acid);
}
kbd {
  border: 1px solid #405049;
  border-radius: 4px;
  padding: 1px 5px;
}
.foot-hint kbd:last-child {
  margin-right: 5px;
}
dialog {
  width: min(92vw, 410px);
  background: var(--panel);
  color: var(--text);
  border: 1px solid #526151;
  border-radius: 14px;
  padding: 24px;
}
dialog::backdrop {
  background: #070c0bd9;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
h2 {
  letter-spacing: -0.04em;
  margin: 0;
}
dialog label {
  display: block;
  margin: 15px 0 5px;
  color: #d1d9cd;
}
select,
input {
  width: 100%;
  border: 1px solid var(--edge);
  border-radius: 6px;
  padding: 9px;
  background: #101615;
  color: var(--text);
}
@media (min-width: 1500px) {
  main {
    min-height: 660px;
  }
}
@media (max-width: 780px) {
  header {
    height: 60px;
  }
  .head-label,
  .foot-hint {
    display: none;
  }
  main {
    display: flex;
    flex-direction: column;
    min-height: 0;
  }
  #stage {
    height: 56svh;
    min-height: 340px;
  }
  aside {
    border-left: 0;
    border-top: 1px solid var(--edge);
    padding: 22px;
  }
  h1 {
    font-size: 2.6rem;
    margin: 7px 0;
  }
  h1 br {
    display: none;
  }
  h1 br:after {
    content: " ";
  }
  .intro {
    margin: 4px 0 13px;
  }
  .stage-top {
    top: 12px;
  }
  .stage-bottom {
    bottom: 12px;
  }
  .hint {
    font-size: 0.73rem;
  }
  .card {
    padding-top: 12px;
  }
  footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    min-height: 60px;
    padding: 6px 10px;
    justify-content: center;
  }
  .tab {
    padding: 8px 9px;
  }
  .parts {
    grid-template-columns: repeat(3, 1fr);
  }
  .tag {
    font-size: 0.64rem;
  }
  .view-mode {
    font-size: 0.75rem;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto;
  }
}
#sample {
  background: #222e27;
  border: 1px solid #495d48;
  border-radius: 9px;
  padding: 13px;
  margin-top: 10px;
  font-size: 0.88rem;
}
#sample p {
  margin: 4px 0;
}
#sample a {
  color: var(--acid);
}
.circuit-view main {
  grid-template-columns: minmax(0, 1fr) clamp(375px, 39vw, 620px);
}
.circuit-view aside {
  padding: 18px clamp(16px, 2.2vw, 34px);
  justify-content: flex-start;
  overflow-y: auto;
  max-height: calc(100svh - 151px);
  min-height: 540px;
}
.circuit-view h1 {
  font-size: clamp(2rem, 3.3vw, 3.2rem);
  margin: 6px 0;
}
.circuit-view .intro {
  font-size: 0.94rem;
  margin: 4px 0 13px;
}
.scheme-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--edge);
  padding-top: 12px;
  gap: 12px;
}
.scheme-head h2 {
  font-size: 1.15rem;
}
.wire-label {
  display: block;
  margin: 10px 0 4px;
  color: var(--dim);
  font-size: 0.85rem;
}
.wire-detail {
  font-size: 0.84rem;
  color: var(--text);
  margin: 8px 0;
}
.sheet-wrap,
.inner-diagram {
  background: #101b1a;
  border: 1px solid #3f534b;
  border-radius: 8px;
}
.sheet,
.inner-diagram {
  width: 100%;
  display: block;
}
.sheet text {
  font:
    11px "Segoe UI",
    sans-serif;
  fill: #e1e8dd;
}
.sheet text.sheet-section {
  fill: var(--acid);
  font:
    600 10px Consolas,
    monospace;
  letter-spacing: 1px;
}
.sheet .hit {
  fill: transparent;
}
.sheet .net {
  cursor: pointer;
}
.sheet .net:hover .hit,
.sheet .net.chosen .hit {
  fill: #344938;
}
.sheet .net.chosen path {
  stroke-width: 4;
}
.inside {
  margin-top: 9px;
  font-size: 0.86rem;
}
.inside summary {
  cursor: pointer;
  color: var(--dim);
}
.inner-diagram {
  margin-top: 7px;
  color: #d8e4d7;
}
.schema-modal {
  width: min(92vw, 650px);
  max-height: 91svh;
  overflow: auto;
}
.schema-modal .sheet-wrap {
  margin-top: 10px;
}
@media (max-width: 780px) {
  .circuit-view aside {
    min-height: 0;
    max-height: none;
  }
  footer nav {
    width: 100%;
    justify-content: space-around;
    gap: 2px;
  }
  footer .tab {
    padding: 8px 4px;
    font-size: 0.87rem;
  }
  footer .tab small {
    margin-right: 2px;
  }
}
/* Light falls behind the object and onto a shallow grid below the inspection area. */
#stage {
  background: radial-gradient(
    ellipse at 43% 29%,
    #3c5049 0%,
    #263731 31%,
    #15221f 71%,
    #111b19 100%
  );
}
#stage:before {
  background-image: radial-gradient(#a1b7a65c 0.8px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(120deg, #0008, transparent 65%);
}
#stage:after {
  content: "";
  position: absolute;
  bottom: -13%;
  left: -15%;
  width: 130%;
  height: 34%;
  z-index: -1;
  pointer-events: none;
  transform: perspective(250px) rotateX(54deg);
  background-image:
    linear-gradient(#92ad961c 1px, transparent 1px),
    linear-gradient(90deg, #92ad961c 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: radial-gradient(ellipse at 50% 60%, black, transparent 68%);
}
body[data-scene="assembled"] #viewport:before,
body[data-scene="signal"] #viewport:before {
  content: "";
  position: absolute;
  pointer-events: none;
  left: 24%;
  bottom: 8%;
  width: 50%;
  height: 8%;
  background: radial-gradient(ellipse, #08100f89, transparent 67%);
}
#viewport canvas {
  position: relative;
}
aside {
  background: linear-gradient(136deg, #1c2824, #151e1c 57%);
}
.stage-top .view-mode {
  color: #d2dbd1;
  padding: 4px 9px;
  border: 1px solid #657c6a63;
  border-radius: 20px;
  background: #121d198c;
}
.tab.active {
  box-shadow: inset 0 -2px #a1be6b;
}
.terminal-tag {
  display: block;
  position: absolute;
  transform: translate(9px, calc(-100% - 8px));
  padding: 4px 8px;
  border: 1px solid var(--wire-color);
  border-left-width: 3px;
  background: #101915ed;
  color: #f5f7ed;
  border-radius: 4px;
  white-space: nowrap;
  font:
    600 0.76rem/1.3 Consolas,
    monospace;
  box-shadow: 0 4px 16px #0006;
}
.terminal-tag[hidden] {
  display: none;
}
.terminal-tag.below {
  transform: translate(9px, 9px);
}
.terminal-tag.flip {
  transform: translate(calc(-100% - 9px), calc(-100% - 8px));
}
.terminal-tag.below.flip {
  transform: translate(calc(-100% - 9px), 9px);
}
.wiring-drawing {
  background-image: radial-gradient(#8caa901f 0.7px, transparent 0.8px);
  background-size: 12px 12px;
}
.wiring-drawing .chosen text {
  fill: #edffbe;
  font-weight: 700;
}
.wiring-drawing .net:hover text {
  text-decoration: underline;
}
.schema-modal .wiring-drawing {
  max-height: 69svh;
}
.pairing {
  border-top: 1px solid var(--edge);
  margin-top: 19px;
  padding-top: 12px;
}
.pairing h3 {
  margin: 0;
  font-size: 1rem;
}
.pairing p {
  font-size: 0.87rem;
}
.pair-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
#pairLinkBox img {
  display: block;
  background: white;
  border-radius: 6px;
  margin: 12px auto;
}
#pairLinkBox a {
  display: block;
  text-align: center;
  color: var(--acid);
  padding: 9px;
}
#pairStatus:empty {
  display: none;
}
#config {
  max-height: 90svh;
  overflow: auto;
}
