:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #51606d;
  --line: #c7d2dc;
  --paper: #f6f8f8;
  --panel: #ffffff;
  --green: #1f8a70;
  --teal: #0f7892;
  --red: #c3423f;
  --gold: #e7b930;
  --yellow: #ffe37a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app {
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(16px, 4vw, 48px) 14px;
  background: #ffffff;
  border-bottom: 1px solid var(--line);
}

.topbar h1,
.side-panel h2,
.concept h2,
.assessment-card h2 {
  margin: 0;
  line-height: 1.08;
}

.topbar h1 {
  font-size: clamp(2rem, 4vw, 4rem);
}

.summary {
  max-width: 580px;
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.tabbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px clamp(16px, 4vw, 48px) 0;
}

.tab,
.btn,
.part,
.slot {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
}

.tab {
  min-width: 118px;
  padding: 10px 18px;
  font-weight: 800;
}

.tab.active {
  background: var(--ink);
  color: #ffffff;
  border-color: var(--ink);
}

.tab[aria-disabled="true"] {
  color: #8c98a3;
  cursor: not-allowed;
}

.unlock-status {
  min-height: 24px;
  margin: 8px clamp(16px, 4vw, 48px) 14px;
  color: var(--muted);
}

.panel {
  padding: 0 clamp(16px, 4vw, 48px) 36px;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.concept,
.vocab-strip article,
.side-panel,
.assessment-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.concept {
  padding: 18px;
  min-height: 240px;
  position: relative;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.concept p {
  color: var(--muted);
  line-height: 1.42;
}

.concept.intro-active {
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(231, 185, 48, 0.28), 0 0 22px rgba(231, 185, 48, 0.34);
  transform: translateY(-2px);
}

.concept.intro-complete {
  border-color: var(--green);
  box-shadow: inset 0 0 0 2px rgba(31, 138, 112, 0.16);
}

.concept.intro-locked-box {
  opacity: 0.5;
  cursor: not-allowed;
}

.concept:focus-visible {
  outline: 3px solid var(--teal);
  outline-offset: 3px;
}

.intro-check {
  margin: 0 0 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.intro-check h2 {
  margin: 0 0 8px;
}

.intro-check p {
  max-width: 780px;
  line-height: 1.42;
}

.intro-check[hidden] {
  display: none;
}

.learn-stage.intro-locked {
  opacity: 0.48;
  pointer-events: none;
  filter: grayscale(0.2);
}

.vocab-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 16px;
}

.vocab-strip article {
  padding: 18px;
}

.vocab-strip h2 {
  margin: 0;
}

.vocab-strip p {
  color: var(--muted);
  line-height: 1.42;
}

.icon {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  font-weight: 900;
}

.icon.source {
  background: #fff4ba;
}

.icon.path {
  border-radius: 0;
  border-top: 5px solid var(--green);
  border-right: 5px solid var(--green);
  border-bottom: 5px solid transparent;
  border-left: 5px solid transparent;
}

.icon.load {
  border-radius: 50%;
  background: var(--yellow);
  box-shadow: 0 0 18px rgba(231, 185, 48, 0.75);
}

.icon.switch {
  position: relative;
}

.icon.switch::after {
  content: "";
  position: absolute;
  width: 34px;
  height: 4px;
  background: var(--red);
  transform: rotate(-28deg);
}

.learn-stage,
.sim-layout,
.assessment-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  align-items: start;
}

.assessment-layout {
  grid-template-columns: minmax(320px, 420px) minmax(0, 1fr);
  min-width: 0;
}

.circuit-shell {
  min-height: 420px;
  background:
    linear-gradient(#e7ecef 1px, transparent 1px),
    linear-gradient(90deg, #e7ecef 1px, transparent 1px),
    #ffffff;
  background-size: 40px 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.circuit-shell svg {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 420px;
}

.assessment-shell {
  min-height: 0;
  height: min(520px, calc(100vh - 260px));
  min-width: 0;
}

.assessment-shell svg {
  min-height: 0;
  height: 100%;
  max-height: 520px;
}

.side-panel,
.assessment-card {
  padding: 18px;
}

.side-panel p,
.assessment-card p {
  line-height: 1.45;
}

.task {
  padding: 12px;
  background: #eef8f4;
  border-left: 5px solid var(--green);
  border-radius: 8px;
  color: #21443a;
  font-weight: 700;
}

.check-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.check-block h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.25;
}

.check-answers {
  display: grid;
  gap: 8px;
}

.mini-diagram-shell {
  margin: 14px 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfb;
}

.mini-diagram-shell svg {
  display: block;
  width: 100%;
  min-height: 160px;
}

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

.mini-part {
  fill: #ffffff;
  stroke: var(--ink);
  stroke-width: 4;
}

.feedback,
.hint {
  min-height: 42px;
  color: var(--muted);
}

.feedback.good {
  color: var(--green);
  font-weight: 800;
}

.feedback.warn {
  color: var(--red);
  font-weight: 800;
}

.btn,
.part {
  padding: 10px 14px;
  font-weight: 800;
}

.btn.primary,
.btn:hover,
.part.selected {
  background: var(--green);
  border-color: var(--green);
  color: #ffffff;
}

.button-row,
.control-stack,
.build-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 14px 0;
}

.lab-concept-question {
  flex-basis: 100%;
  margin: 0;
  font-weight: 800;
  line-height: 1.35;
}

.control {
  display: grid;
  gap: 8px;
  margin: 14px 0;
  font-weight: 800;
}

.control select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #ffffff;
}

.build-layout {
  grid-template-columns: minmax(0, 1fr) 390px;
}

.build-board {
  position: relative;
  min-height: 560px;
}

.build-board svg {
  min-height: 560px;
}

.drop-layer {
  position: absolute;
  inset: 0;
}

.slot {
  position: absolute;
  width: 108px;
  min-height: 52px;
  transform: translate(-50%, -50%);
  background: rgba(255, 255, 255, 0.9);
  border: 2px dashed #94a3ad;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 800;
}

.slot.filled {
  border-style: solid;
  color: #ffffff;
}

.slot[data-part="battery"] {
  background: #31475c;
}

.slot[data-part="bulb"] {
  background: #d8a900;
  color: #1c1a11;
}

.slot[data-part="switch"] {
  background: #0f7892;
}

.slot[data-part="wire"] {
  background: #1f8a70;
}

.answers {
  display: grid;
  gap: 10px;
}

.answer {
  width: 100%;
  padding: 12px;
  text-align: left;
}

.answer.correct {
  border-color: var(--green);
  background: #e4f6ef;
}

.answer.incorrect {
  border-color: var(--red);
  background: #ffe9e8;
}

.wire {
  fill: none;
  stroke: #1f8a70;
  stroke-width: 14;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wire.off {
  stroke: #a9b4bd;
  stroke-dasharray: 10 12;
}

.wire-hot {
  stroke: #c3423f;
  filter: drop-shadow(0 0 8px rgba(195, 66, 63, 0.85));
  animation: heatPulse 0.7s ease-in-out infinite alternate;
}

.short-wire {
  stroke: var(--red);
}

.battery-body {
  fill: #31475c;
}

.bulb-glass {
  stroke: #263442;
  stroke-width: 5;
}

.bulb-halo {
  fill: var(--yellow);
  filter: blur(10px);
}

.switch-bar {
  stroke: #263442;
  stroke-width: 10;
  stroke-linecap: round;
}

.current-dot {
  fill: var(--gold);
  stroke: #4a3a05;
  stroke-width: 2;
}

.current-dot--high {
  fill: #ffe37a;
  stroke: #5c4704;
  filter: drop-shadow(0 0 6px rgba(231, 185, 48, 0.85));
}

.current-dot--mid {
  fill: #d7c86d;
  stroke: #5f5a2c;
  filter: drop-shadow(0 0 3px rgba(215, 200, 109, 0.55));
}

.current-dot--low {
  fill: #aeb8bf;
  stroke: #45515a;
}

.current-dot--short {
  fill: #ff4d3d;
  stroke: #741d17;
  filter: drop-shadow(0 0 7px rgba(255, 77, 61, 0.95));
}

.current-dot-label {
  fill: #17212b;
  font: 800 9px Arial, Helvetica, sans-serif;
  text-anchor: middle;
  pointer-events: none;
}

@keyframes heatPulse {
  from {
    stroke-width: 14;
  }

  to {
    stroke-width: 19;
  }
}

.label {
  fill: var(--ink);
  font: 800 18px Arial, Helvetica, sans-serif;
}

.small-label {
  fill: var(--muted);
  font: 700 14px Arial, Helvetica, sans-serif;
}

.warning-label {
  fill: var(--red);
  font: 800 16px Arial, Helvetica, sans-serif;
}

.lab-component {
  cursor: grab;
  user-select: none;
}

.lab-component:active {
  cursor: grabbing;
}

.terminal {
  fill: #ffffff;
  stroke: #17212b;
  stroke-width: 4;
  cursor: crosshair;
}

.wire-start {
  fill: none;
  stroke: var(--gold);
  stroke-width: 4;
}

.contact-hint {
  fill: rgba(231, 185, 48, 0.28);
  stroke: var(--gold);
  stroke-width: 3;
  pointer-events: none;
}

.lab-wire {
  cursor: pointer;
}

#labPanel,
#labSvg,
#labControls {
  user-select: none;
}

.wire-draft {
  opacity: 0.7;
  stroke-dasharray: 12 8;
}

.btn.primary {
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
}

.callout-line {
  stroke: #c3423f;
  stroke-width: 3;
  stroke-dasharray: 7 7;
}

.voltage-band {
  fill: rgba(15, 120, 146, 0.14);
  stroke: #0f7892;
  stroke-width: 3;
}

.electron {
  fill: #246bfe;
  stroke: #0b2f73;
  stroke-width: 2;
}

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

  .vocab-strip {
    grid-template-columns: 1fr;
  }

  .learn-stage,
  .sim-layout,
  .assessment-layout,
  .build-layout {
    grid-template-columns: 1fr;
  }

  .assessment-layout .assessment-card {
    order: 2;
  }

  .assessment-shell {
    height: min(420px, 46vh);
  }
}

@media (max-width: 640px) {
  .topbar {
    display: block;
  }

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

  .tab {
    flex: 1 1 130px;
  }

  .circuit-shell,
  .circuit-shell svg {
    min-height: 340px;
  }

  .assessment-shell {
    min-height: 0;
    height: 260px;
  }

  .assessment-shell svg {
    min-height: 0;
  }
}
