:root {
  color-scheme: light;
  --ink: #192d35;
  --muted: #506770;
  --line: #d6e4e5;
  --accent: #066f69;
  font: 15px/1.45 Arial, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0; background: #edf4f3; color: var(--ink);
  height: 100vh; height: 100dvh; overflow: hidden;
  display: grid; grid-template-rows: auto auto minmax(0, 1fr);
}
html:fullscreen { background: #edf4f3; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(20px, 3vw, 28px); line-height: 1.15; }
h2 { font-size: 17px; }
h3 { font-size: 13px; }
a { color: var(--accent); text-underline-offset: 3px; }
button, select, input { font: inherit; }
button, select, input[type=number], input[type=text], #open-lab {
  min-height: 42px; padding: 7px 10px; border: 1px solid #c7d8d9; border-radius: 8px;
  background: #fff; color: var(--ink);
}
button, select { cursor: pointer; }
button:hover, #open-lab:hover { background: #e7f2f1; }
button[aria-pressed=true], button[aria-selected=true], #check {
  background: var(--accent); border-color: var(--accent); color: #fff;
}
#workspace-open { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: .52; cursor: default; }
:focus-visible { outline: 3px solid #b65807; outline-offset: 2px; }
.toolbar {
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap;
  gap: 12px; background: #fff; border-bottom: 1px solid var(--line);
  padding: 14px clamp(12px, 3vw, 30px);
}
.toolbar nav, .challenge-actions, .shop { display: flex; flex-wrap: wrap; gap: 8px; }
.panel-bar {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 5px clamp(12px, 3vw, 30px); background: #f7faf9; border-bottom: 1px solid var(--line);
}
.panel-bar button { min-height: 32px; padding: 3px 9px; font-size: 13px; }
.brand { color: var(--accent); text-transform: uppercase; font-size: 10px; letter-spacing: .14em; font-weight: 700; margin-bottom: 4px; }
.workspace {
  display: grid; grid-template-columns: minmax(235px, .86fr) minmax(250px, 1.28fr) minmax(305px, 1.03fr);
  grid-template-areas: "controls stage inspector"; align-items: stretch;
  gap: 12px; width: 100%; min-height: 0; margin: 0; padding: 12px; overflow: auto;
}
.controls, .stage, .inspector { min-width: 0; border-radius: 14px; }
.controls, .inspector { background: #fff; border: 1px solid var(--line); }
.controls { grid-area: controls; padding: 16px; }
.controls > label { display: block; color: var(--muted); font-size: 13px; margin: 12px 0 4px; }
.controls select { width: 100%; }
#hex-form { margin: 0 0 12px; }
#hex-form label { font-size: 13px; font-weight: 700; display: block; margin-bottom: 4px; }
.hex-row { display: flex; gap: 6px; }
#hex-input { width: 100%; min-width: 0; font-family: monospace; }
#hex-error { font-size: 12px; color: #9c2831; margin-top: 4px; }
.channels { display: grid; gap: 10px; margin: 12px 0; }
.channel { --channel: #b22738; }
.green { --channel: #08764b; }
.blue { --channel: #2948d1; }
.channel-header { display: flex; align-items: center; gap: 8px; }
.channel-header label { color: var(--channel); font-weight: 700; }
.channel-header span { color: var(--muted); font: 12px monospace; }
.channel-header input { margin-left: auto; width: 66px; min-height: 42px; padding: 4px 6px; }
input[type=range] { display: block; width: 100%; height: 32px; margin: 0; accent-color: var(--channel); cursor: pointer; }
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; }
.presets button { font-size: 13px; display: inline-flex; gap: 6px; align-items: center; }
.presets button::before { content: ""; width: 11px; height: 11px; border-radius: 50%; border: 1px solid #29394766; background: var(--swatch); }
.stage {
  grid-area: stage; color: #f1fafb; background: #12252e;
  display: flex; flex-direction: column; padding: 16px;
}
.stage-heading, .stage-footer, .signal-heading { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.stage-heading output { font: 700 14px monospace; color: #fff; padding: 6px 8px; border: 1px solid #728a94; border-radius: 7px; }
.stage-footer p { color: #cbdfe4; font-size: 13px; }
.led-scene {
  --lamp: rgb(255 0 96); --glow: .8;
  position: relative; flex: 1; min-height: 150px; isolation: isolate;
  background: radial-gradient(circle, #35545f 1px, transparent 1px) center / 19px 19px;
  margin: 12px 0; border-radius: 9px; overflow: hidden;
}
.led-scene::before {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 50% 34%, var(--lamp) 0%, transparent 56%);
  opacity: calc(var(--glow) * .32); z-index: -1;
}
.led-assembly {
  width: 120px; height: 222px; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(var(--led-scale, 1));
}
.zoom-controls {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 6px; margin-bottom: 10px;
}
.zoom-controls button { min-width: 40px; }
#zoom-level { min-width: 52px; text-align: center; font: 700 13px monospace; }
.lens, .flange { position: absolute; z-index: 1; border: 1px solid #97acb665; }
.lens {
  inset: 1px 6px auto; height: 119px; border-radius: 60px 60px 9px 9px;
  background: radial-gradient(ellipse at 28% 24%, #fff9 0%, #fff2 22%, transparent 43%),
    linear-gradient(88deg, #101821cc, #74889930 32%, transparent 63%, #101821bb), var(--lamp);
  box-shadow: 0 0 calc(25px * var(--glow)) var(--lamp), inset 0 -18px 20px #0005;
}
.lens::after { content: ""; position: absolute; bottom: 0; left: 35%; right: 31%; height: 25px; border-inline: 6px solid #1e2d3666; border-top: 4px solid #f3f9ff39; }
.flange { top: 115px; width: 100%; height: 13px; border-radius: 4px; background: linear-gradient(#fff6, #0007), var(--lamp); }
.legs { position: absolute; top: 117px; inset-inline: 17%; display: flex; justify-content: space-between; }
.legs i { display: block; width: 5px; height: 82px; background: linear-gradient(90deg, #70868e, #e5eef0 47%, #a4b4be 70%, #566f79); }
.legs i:nth-child(2) { height: 105px; }
.legs i:nth-child(3) { height: 95px; }
.legs i:nth-child(4) { height: 89px; }
.inspector { grid-area: inspector; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 5px; padding: 9px; border-bottom: 1px solid var(--line); background: #f7faf9; border-radius: 14px 14px 0 0; }
.tabs button { flex: 1 1 auto; font-size: 13px; padding-inline: 5px; }
.tab-content { padding: 12px; flex: 1; }
.tab-content p { font-size: 13px; margin: 8px 0; }
.signal-heading select { font-size: 13px; }
#waveform { display: block; width: 100%; height: auto; margin: 8px 0; background: #f5faf9; border-radius: 8px; --trace: #2948d1; }
#waveform text { fill: #3d5662; font: 12px Arial, sans-serif; }
.gridlines { fill: none; stroke: #cbdade; }
#wave-area { fill: var(--trace); opacity: .13; }
#wave-line { fill: none; stroke: var(--trace); stroke-width: 2.5; stroke-linejoin: round; }
#playhead { stroke: #192d35; stroke-width: 2; stroke-dasharray: 3 3; }
.readouts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px; margin: 8px 0; }
.readouts div { padding: 6px 5px; border-radius: 6px; background: #eaf4f2; }
.readouts dt { font-size: 10px; color: var(--muted); }
.readouts dd { font-size: 17px; font-weight: bold; margin: 0; }
.hint { color: var(--muted); }
table { border-collapse: collapse; margin: 8px 0; width: 100%; font-size: 13px; }
th, td { padding: 5px; border-bottom: 1px solid var(--line); text-align: left; }
pre { margin: 7px 0; background: #142832; color: #dff6f4; border-radius: 8px; padding: 9px; max-height: 240px; overflow: auto; font: 12px/1.6 monospace; }
.shop { border-top: 1px solid var(--line); padding: 10px 12px; font-size: 13px; gap: 7px 14px; }
.target { display: flex; align-items: center; gap: 12px; margin: 13px 0; padding: 10px; border-radius: 8px; background: #edf5f4; }
#target-swatch { width: 56px; height: 48px; border: 1px solid #56737b; border-radius: 6px; }
#feedback { min-height: 2.5em; }
body.teaching { font-size: 17px; }
.teaching .tab-content p, .teaching .stage-footer p { font-size: 15px; }
.teaching .readouts dd { font-size: 20px; }
.teaching .shop { display: none; }
@media (min-width: 931px) {
  .workspace { grid-template-rows: minmax(360px, 1fr); }
  .controls, .inspector { overflow: auto; }
  .tabs { position: sticky; top: 0; z-index: 1; }
}
@media (max-width: 930px) {
  .workspace { grid-template-columns: minmax(235px, 1fr) minmax(250px, 1.2fr); grid-template-areas: "controls stage" "inspector inspector"; }
  #waveform { max-width: 520px; }
  .readouts { max-width: 520px; }
}
@media (max-width: 560px) {
  .toolbar { padding: 10px; gap: 7px; }
  .toolbar button { min-height: 44px; font-size: 13px; }
  .workspace { display: block; padding: 8px; }
  .stage, .controls { margin-bottom: 8px; padding: 11px; }
  .led-scene { height: 178px; margin: 5px 0; }
  .zoom-controls { justify-content: center; margin-bottom: 6px; }
  .zoom-controls button { min-height: 44px; min-width: 44px; }
  .channels { gap: 4px; margin: 7px 0; }
  .channel-header input { min-height: 44px; }
  input[type=range] { height: 36px; }
}
