:root {
  color-scheme: dark;
  --ink: #e7eadf;
  --muted: #a7afa1;
  --accent: #d3ec9a;
  --line: #394138;
  font: 16px/1.55 system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: #141914; color: var(--ink); }
a { color: inherit; }
button, a { touch-action: manipulation; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
header {
  position: fixed; z-index: 3; inset: 0 0 auto; height: 64px;
  padding: 0 clamp(16px,5vw,72px); display: flex; align-items: center;
  justify-content: space-between; gap: 12px; background: #141914;
  border-bottom: 1px solid var(--line); font-size: .85rem;
}
.brand { text-decoration: none; font-weight: 600; }
kbd { border: 1px solid #6b7961; border-radius: 4px; padding: 3px 6px; margin-right: 4px; color: var(--accent); }
main { height: 395svh; }
.stage {
  position: sticky; top: 0; height: 100svh; padding: 76px clamp(16px,5vw,72px) 60px;
  display: grid; grid-template-columns: minmax(0, .85fr) minmax(0, 1fr);
  align-items: center; gap: clamp(20px,4vw,60px); overflow: clip;
}
.copy { z-index: 1; }
.label { color: var(--accent); font: .78rem ui-monospace, monospace; }
h1,h2 { font-size: clamp(2.6rem,6.6vw,7.2rem); line-height: .96; letter-spacing: -.065em; margin: 16px 0 24px; font-weight: 550; }
article > p:last-child { color: var(--muted); max-width: 39ch; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
#download,.quiet { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; background: transparent; color: var(--ink); }
#download { background: var(--accent); color: #172010; border-color: transparent; font-weight: 600; }
button:hover { filter: brightness(1.13); }
#download-status { color: var(--muted); font-size: .75rem; }
.view { border: 1px solid var(--line); border-radius: 20px; overflow: hidden; background: #20271f; }
.camera { height: clamp(170px,45vh,500px); position: relative; perspective: 700px; overflow: hidden; background: radial-gradient(ellipse at 50% 50%, #3b4931, #20271f 76%); }
.board,.inside { position: absolute; inset: 0; display: flex; justify-content: center; align-items: center; }
.board { gap: 3%; transform: translateX(var(--x,0%)) scale(var(--zoom,1)) rotateX(var(--tilt,22deg)) rotateZ(-8deg); opacity: var(--shell,1); }
.key {
  width: 23%; aspect-ratio: 1; display: grid; place-content: center; text-align: center;
  border-radius: 15%; color: #29341e; background: #b7c4a4;
  border: 5px solid #d5dec7; box-shadow: 0 12px #788569, 0 22px #4e5e43, 0 30px 24px #10170e99;
}
.key:nth-child(2) { background: #d3ec9a; border-color: #e0f3b7; }
.key span { font: 600 clamp(1.4rem,5vw,5rem) ui-monospace, monospace; }
.key small { font-size: clamp(.52rem,1vw,.8rem); }
.inside { opacity: var(--core,0); transform: scale(var(--depth,.55)) rotate(var(--angle,0deg)); }
.socket,.plate,.trace { position: absolute; width: 57%; aspect-ratio: 1; border: 2px solid #6b805c; border-radius: var(--radius,18%); transform: rotate(45deg); }
.socket { background: #263822; box-shadow: 0 0 0 16px #2c4229, 0 0 0 17px #597452; }
.plate { width: 40%; background: #93aa6a; border: 6px double #cde59a; box-shadow: inset 0 0 0 8px #546a43; }
.trace { width: 24%; background: #d3ec9a; border: 4px solid #e8f4c9; box-shadow: 0 8px #50673c; }
.readout { min-height: 112px; padding: 14px 18px; border-top: 1px solid var(--line); font: .78rem/1.45 ui-monospace, monospace; }
#signal { color: var(--accent); }
output { display: block; min-height: 2em; margin-top: 5px; overflow-wrap: anywhere; }
#replay { font-size: .72rem; padding: 3px 7px; }
.stage nav { position: absolute; inset: auto clamp(16px,5vw,72px) 12px; display: flex; justify-content: space-between; border-top: 1px solid var(--line); }
nav button { padding: 8px 4px; color: var(--muted); background: transparent; border: 0; border-top: 2px solid transparent; font-size: .82rem; }
nav button[aria-current] { color: var(--accent); border-color: currentColor; }
@media(max-width:700px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: auto auto; align-content: center; gap: 12px; }
  h1,h2 { font-size: clamp(2.1rem,9vw,4rem); margin: 6px 0 12px; }
  h1 br { display: none; }
  article p { margin: 6px 0; font-size: .9rem; }
  .actions { margin-top: 12px; }
  .camera { height: clamp(95px,23svh,240px); }
  .readout { min-height: 80px; padding: 8px 12px; }
}
@media(max-height:520px) {
  main { height: auto; }
  .stage { position: relative; min-height: 620px; height: auto; }
}
@media(prefers-reduced-motion:reduce) {
  main { height: auto; }
  .stage { position: relative; min-height: 100svh; height: auto; }
}

/* The interface and the keyboard share one perspective. */
.stage { --scene: 0; --scene-turn: 0deg; perspective: 1100px; isolation: isolate; }
.stage::before {
  content: ""; position: absolute; z-index: -1;
  inset: 14% -48% -125%; pointer-events: none;
  background:
    repeating-linear-gradient(90deg, transparent 0 94px, #83946c30 94px 96px),
    repeating-linear-gradient(0deg, transparent 0 94px, #83946c30 94px 96px);
  transform-origin: center top;
  transform: translateY(calc(var(--scene) * -34px)) rotateX(67deg) rotateZ(var(--scene-turn));
  mask-image: linear-gradient(transparent, black 23%, black 70%, transparent);
}
.stage::after {
  content: ""; position: absolute; z-index: -2; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 63% 65%, #3a4930, #141914 75%);
}
.copy {
  padding: clamp(16px,3vw,40px); border: 1px solid #53634d;
  border-radius: 20px; background: #1b241b;
  box-shadow: -7px 9px 0 #111911, -8px 10px 0 #42533d, 0 24px 72px #0e140ead;
  transform: translate3d(calc(var(--scene) * 1.5vw), calc(var(--scene) * -9px), calc(27px + var(--scene) * 18px))
    rotateY(calc(10deg + var(--scene-turn))) rotateX(4deg);
}
.view {
  transform: translate3d(calc(var(--scene) * -1vw), calc(var(--scene) * 8px), calc(-34px + var(--scene) * 17px))
    rotateY(calc(-12deg + var(--scene-turn))) rotateX(-4deg);
  box-shadow: 9px 12px 0 #151e14, 10px 13px 0 #52664b, 0 32px 64px #0b130d99;
}
.stage nav {
  padding: 0 16px; background: #1b241b;
  border: 1px solid #53634d; border-radius: 8px;
  transform: translateZ(30px) rotateX(-10deg);
  box-shadow: 0 5px #0f170f;
}
header { background: #1b241b; border-color: #53634d; box-shadow: 0 4px #0f170f; }
@media(max-width:700px) {
  .copy { padding: 12px; transform: translateY(calc(var(--scene) * -2px)) rotateY(calc(4deg + var(--scene-turn) * .32)); }
  .view { transform: translateY(calc(var(--scene) * 2px)) rotateY(calc(-6deg + var(--scene-turn) * .32)); }
}
@media(max-height:700px) and (max-width:700px) {
  .copy { padding: 8px 12px; }
  .copy h1,.copy h2 { font-size: clamp(1.7rem,7.5vw,2.4rem); }
  .copy .actions { margin-top: 6px; }
  .copy #download-status { margin: 4px 0 0; }
}
@media(prefers-reduced-motion:reduce) {
  .copy,.view,.stage nav { transform: none; }
}

/* Warm molded plastic, black legends, and one orange switch stem. */
:root { color-scheme: light; --ink:#24221e; --muted:#575349; --accent:#a33416; --line:#bab3a4; }
body { background:#e6e1d5; }
header { background:#e6e1d5; border-color:#a9a092; box-shadow:none; }
kbd { border-color:#7c7568; color:var(--ink); background:#f7f3e8; }
.stage::before { display:none; }
.stage::after { background:radial-gradient(ellipse at 70% 22%, #f5f0e5, #d5ccba 86%); }
.copy { border:0; border-radius:0; background:transparent; box-shadow:none; }
h1,h2 { letter-spacing:-.075em; font-weight:600; }
.view { border-color:#756e62; border-radius:12px; background:#282720; box-shadow:7px 10px #8f8779, 8px 11px #736b5e; }
.camera { background:radial-gradient(ellipse at 42% 32%, #ece6d8, #bdb29d); }
.key { background:#d8d0bc; border-color:#eee7d6; color:#26231e; box-shadow:0 12px #9f937c,0 22px #6c6252,0 32px 22px #40352666; }
.key:nth-child(2) { background:#e05b2f; border-color:#ef7447; color:#24150f; }
.board { transform:translateX(var(--x,0%)) scale(var(--zoom,1)) rotateX(var(--tilt,22deg)) rotateZ(-8deg); }
.inside { transform:scale(var(--depth,.55)) rotateZ(-15deg); }
.socket,.plate,.trace {
  border-radius:8%; transform:rotateX(42deg) rotateZ(35deg);
  transition:background-color .2s ease-out;
}
.socket { width:48%; top:34%; background:#4d493e; border:6px solid #6f6859; box-shadow:0 14px #2b2924,0 26px 18px #3d332951; }
.plate { width:40%; top:calc(30% - var(--scene) * 5%); background:#bdb39e; border:8px double #f1e7d2; box-shadow:0 8px #766d5e; }
.trace { width:18%; top:calc(32% - var(--scene) * 8%); background:#e05b2f; border:4px solid #f47e50; box-shadow:0 12px #913813; }
.trace::before,.trace::after { content:""; position:absolute; inset:42% 12%; background:#913813; border-radius:2px; }
.trace::after { transform:rotate(90deg); }
.readout { color:#f1ebde; border-color:#514c40; }
#signal { color:#f6b398; }
#replay { color:#f1ebde; border-color:#8f8572; }
#download { background:#22201c; color:#fff9ed; }
.stage nav { background:#e9e3d6; border-color:#a9a092; box-shadow:0 4px #b4aa97; }
@media(prefers-reduced-motion:reduce) { .socket,.plate,.trace { transition:none; } }

.install { border-color: #9c3e23; color: #842e16; background: #fae8da; font-weight: 600; }
header .quiet { padding: 4px 8px; }
#setup-guide {
  width: min(94vw, 630px); max-height: 88svh; border: 1px solid #827767;
  border-radius: 12px; padding: clamp(16px,4vw,32px); background: #fbf5e9; color: #25211c;
  box-shadow: 0 16px 48px #22190c55;
}
#setup-guide::backdrop { background: #241d15aa; }
#setup-guide h2 { font-size: clamp(1.7rem,5vw,2.7rem); margin: 12px 0; letter-spacing: -.045em; }
#setup-guide form { display: flex; justify-content: flex-end; }
#setup-guide ol { padding-inline-start: 24px; }
#setup-guide li + li { margin-top: 12px; }
#setup-guide .actions a { text-decoration: none; }
.script-link { padding: 8px 12px; border: 1px solid #842e16; border-radius: 8px; background: #842e16; color: #fff9ed; }
@media(max-width:700px) { .actions { gap: 6px; } .actions button { font-size: .83rem; } }
