/* EDWARD.EXE: a violet dev board, a little CRT, and a dot-matrix printer for the letter.
   Phone first (390px), then the desktop gets a wider board. */
:root {
  --crt: #0b0d10;
  --ink-1: #10131a;
  --ink-2: #161b26;
  --line: #262c3d;
  --mint: #7cf2b0;
  --mint-dim: #3ba776;
  --coral: #ff5d73;
  --coral-ink: #c9284a;
  --violet: #8b6cff;
  --violet-dim: #3b2f7a;
  --violet-deep: #2a2155;
  --cream: #f6ebd2;
  --cream-dim: #c9bfa8;
  --amber: #ffb547;
  --muted: #9d96b0;
  --pcb: #2b2066;
  --pcb-2: #33267b;
  --gold: #d9a441;
  --paper: #f7efda;
  --paper-ink: #221d33;

  --f-pixel: "Silkscreen", "VT323", ui-monospace, monospace;
  --f-term: "VT323", ui-monospace, monospace;
  --f-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --gut: clamp(12px, 3.5vw, 32px);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }
body {
  margin: 0;
  background-color: var(--crt);
  background-image: radial-gradient(rgba(124, 242, 176, 0.045) 1px, transparent 1.2px);
  background-size: 16px 16px;
  color: var(--cream);
  font-family: var(--f-mono);
  font-size: 16px;
  line-height: 1.6;
  overflow-x: hidden;
}
img, canvas, svg { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
a { color: var(--mint); }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 3px; border-radius: 2px; }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.nowrap { white-space: nowrap; }

.skip-link {
  position: fixed; left: 8px; top: -60px; z-index: 100;
  background: var(--amber); color: #000; padding: 10px 14px; font-family: var(--f-pixel); font-size: 12px; text-decoration: none;
}
.skip-link:focus { top: 8px; }

/* pixel-cornered border, used everywhere */
.pix-btn {
  --b: var(--violet-dim);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; margin: 3px;
  font-family: var(--f-pixel); font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; text-decoration: none;
  color: var(--cream); background: var(--ink-2); border: 0; cursor: pointer;
  box-shadow: 0 -3px 0 0 var(--b), 0 3px 0 0 var(--b), -3px 0 0 0 var(--b), 3px 0 0 0 var(--b), 0 6px 0 0 #000;
  transition: transform 0.06s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
}
.pix-btn:hover { background: #1d2333; }
.pix-btn:active { transform: translateY(3px); box-shadow: 0 -3px 0 0 var(--b), 0 3px 0 0 var(--b), -3px 0 0 0 var(--b), 3px 0 0 0 var(--b); }
.pix-btn.alt { --b: var(--mint-dim); }
.pix-btn[disabled] { opacity: 0.4; cursor: default; }

/* =========================================================
   TOP BAR
   ========================================================= */
.bar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 8px;
  height: 52px; padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  background: rgba(11, 13, 16, 0.88);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-bottom: 1px solid #1d2230;
}
.logo {
  display: flex; align-items: center; gap: 9px; padding: 6px 6px 6px 2px; min-height: 44px;
  background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.logo-chip {
  position: relative; width: 20px; height: 20px; flex: none;
  background: var(--violet-deep); border: 2px solid var(--mint);
  box-shadow: 0 0 10px rgba(124, 242, 176, 0.35);
}
.logo-chip::before, .logo-chip::after {
  content: ""; position: absolute; left: 2px; right: 2px; height: 3px;
  background: repeating-linear-gradient(90deg, var(--amber) 0 2px, transparent 2px 4px);
}
.logo-chip::before { top: -6px; } .logo-chip::after { bottom: -6px; }
.logo-chip i { position: absolute; inset: 4px; background: var(--mint); }
.logo.tapped .logo-chip { animation: chip-bump 0.18s; }
@keyframes chip-bump { 50% { transform: scale(1.25) rotate(-8deg); } }
.logo-txt { font-family: var(--f-pixel); font-size: 15px; color: var(--mint); letter-spacing: 0.04em; text-shadow: 0 0 8px rgba(124, 242, 176, 0.45); }
.bar-debug { display: none; font-family: var(--f-pixel); font-size: 10px; color: #000; background: var(--amber); padding: 2px 6px; }
.bar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.bar-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 10px;
  font-family: var(--f-pixel); font-size: 11px; text-transform: uppercase; text-decoration: none;
  color: var(--cream); background: var(--ink-2); border: 0; cursor: pointer;
  box-shadow: 0 -2px 0 0 var(--line), 0 2px 0 0 var(--line), -2px 0 0 0 var(--line), 2px 0 0 0 var(--line);
  -webkit-tap-highlight-color: transparent;
}
.bar-btn svg { width: 18px; height: 18px; }
#mute .x { display: none; }
#mute[aria-pressed="false"] .x { display: inline; }
#mute[aria-pressed="false"] .w1, #mute[aria-pressed="false"] .w2 { display: none; }
#mute[aria-pressed="false"] { color: var(--muted); }
.bar-letter { background: var(--coral); color: #1b0d12; box-shadow: 0 -2px 0 0 #a8304b, 0 2px 0 0 #a8304b, -2px 0 0 0 #a8304b, 2px 0 0 0 #a8304b, 0 4px 0 0 #000; }
.bar-letter:active { transform: translateY(2px); }
.bar-letter .short { display: none; }
@media (max-width: 370px) { .bar-letter .long { display: none; } .bar-letter .short { display: inline; } .logo-txt { font-size: 13px; } }

/* =========================================================
   THE RIG: a violet dev board with a little CRT on it
   ========================================================= */
.rig { padding: 8px 8px 8px; }
.board {
  position: relative; max-width: 1180px; margin: 0 auto;
  padding: 22px 10px 14px;
  border-radius: 14px;
  background-color: var(--pcb);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='120' fill='none' stroke='%23d9a441' stroke-width='1.4' opacity='.28'%3E%3Cpath d='M0 18h40l10 10h60l10-10h40M0 34h28l8 8h46M0 96h70l12-12h78M100 60h20l10 10v50M40 120V80l8-8h20'/%3E%3Ccircle cx='82' cy='42' r='3'/%3E%3Ccircle cx='68' cy='72' r='3'/%3E%3Ccircle cx='100' cy='60' r='3'/%3E%3C/g%3E%3C/svg%3E"),
    radial-gradient(120% 90% at 30% 0%, #3a2c8a 0%, transparent 60%);
  box-shadow: 0 1px 0 #4d3ca8 inset, 0 -2px 0 #1a1340 inset, 0 18px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px #140f33;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
}
.hole { position: absolute; width: 12px; height: 12px; border-radius: 50%; background: var(--crt); box-shadow: 0 0 0 3px var(--gold), 0 0 0 4px #6d4e16; }
.hole-tl { left: 8px; top: 8px; } .hole-tr { right: 8px; top: 8px; } .hole-bl { left: 8px; bottom: 8px; } .hole-br { right: 8px; bottom: 8px; }
.silk {
  font-family: var(--f-pixel); font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase;
  color: rgba(246, 235, 210, 0.78);
}
.silk-top { position: absolute; top: 6px; left: 28px; right: 28px; display: flex; gap: 12px; justify-content: space-between; }
.silk-made { display: none; }

.bezel {
  position: relative; padding: 7px; border-radius: 12px;
  background: linear-gradient(#1b1e28, #0d0f15);
  box-shadow: 0 0 0 2px #0a0812, 0 2px 0 3px #463897, 0 0 34px rgba(124, 242, 176, 0.13);
}
.screen {
  position: relative; overflow: hidden; border-radius: 9px;
  background: #050607;
  min-height: 160px;
  display: flex; justify-content: center;
}
.screen canvas {
  image-rendering: pixelated; image-rendering: crisp-edges;
  outline: none; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.board.playing .screen canvas, .board.playing .sw1 { touch-action: none; }
.screen canvas:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }
.screen.power canvas { animation: crt-on 0.5s cubic-bezier(.2, .8, .2, 1); transform-origin: 50% 50%; }
@keyframes crt-on {
  0% { transform: scale(0.03, 0.006); filter: brightness(5); }
  35% { transform: scale(1, 0.006); filter: brightness(3); }
  100% { transform: scale(1, 1); filter: brightness(1); }
}
.glass {
  position: absolute; inset: 0; pointer-events: none; border-radius: 9px;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 32%),
    radial-gradient(130% 120% at 50% 50%, transparent 58%, rgba(0, 0, 0, 0.42) 100%);
  box-shadow: inset 0 0 22px rgba(124, 242, 176, 0.08), inset 0 0 2px rgba(0, 0, 0, 0.9);
}
@media (prefers-reduced-motion: no-preference) {
  .glass::after { content: ""; position: absolute; inset: 0; background: rgba(124, 242, 176, 0.012); animation: flicker 4s steps(2) infinite; }
}
@keyframes flicker { 50% { opacity: 0; } }

/* boot / POST screen, laid over the canvas */
.boot {
  position: absolute; inset: 0; z-index: 2;
  background: #050607; color: var(--mint);
  padding: 10px 12px; overflow: hidden;
  cursor: pointer;
}
.boot pre {
  margin: 0; font-family: var(--f-term); font-size: clamp(14px, 3.9vw, 22px); line-height: 1.12; white-space: pre-wrap;
  text-shadow: 0 0 6px rgba(124, 242, 176, 0.55);
}
.boot .ok { color: var(--mint); } .boot .hl { color: var(--amber); text-shadow: 0 0 6px rgba(255, 181, 71, 0.5); } .boot .dim { color: #4c8f73; }
.boot .cur { display: inline-block; width: 0.55em; height: 0.95em; vertical-align: -0.1em; background: var(--mint); animation: blink 0.8s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.boot.done { animation: crt-off 0.28s ease-in forwards; transform-origin: 50% 50%; pointer-events: none; }
@keyframes crt-off {
  0% { transform: scale(1, 1); filter: brightness(1); }
  60% { transform: scale(1, 0.008); filter: brightness(4); opacity: 1; }
  100% { transform: scale(0, 0.008); opacity: 0; }
}

/* the register strip: live player state */
.regs {
  display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: nowrap; overflow: hidden;
  margin: 10px 2px 0; padding: 2px 8px;
  font-family: var(--f-term); font-size: 17px; line-height: 1.25; white-space: nowrap;
  background: #07080b; border: 1px solid #3b2f7a; border-radius: 4px;
  box-shadow: inset 0 0 12px rgba(124, 242, 176, 0.06);
}
.reg b { font-weight: normal; color: #8279b0; margin-right: 4px; }
.reg i { font-style: normal; color: var(--mint); }
.reg-fps, .regs .reg:first-child { display: none; }
.flags { display: flex; gap: 3px; }
.flags i { font-style: normal; padding: 0 3px; color: #3e3570; border: 1px solid #2c2558; line-height: 1.05; transition: background 0.05s; }
.flags i.on { background: var(--amber); border-color: var(--amber); color: #120d00; }
#f-coy.on { background: var(--coral); border-color: var(--coral); }
#f-gnd.on { background: var(--mint); border-color: var(--mint); }

/* controls */
.board-side {
  display: grid; grid-template-columns: 1fr auto; grid-template-areas: "leds sw1" "ctrl sw1";
  align-items: center; column-gap: 10px; row-gap: 10px; margin-top: 12px;
}
.u1, .uart { display: none; }
.leds { grid-area: leds; display: flex; gap: 12px; flex-wrap: wrap; font-family: var(--f-pixel); font-size: 9px; color: rgba(246, 235, 210, 0.8); }
.led { display: inline-flex; align-items: center; gap: 5px; }
.led i { width: 9px; height: 9px; border-radius: 50%; background: #3b1d2a; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.4); transition: background 0.25s, box-shadow 0.25s; }
.led[data-led="pwr"] i { background: #1d4436; }
.led[data-led="pwr"].on i { background: var(--mint); box-shadow: 0 0 8px 2px rgba(124, 242, 176, 0.7); }
.led[data-led="jmp"].on i { background: var(--amber); box-shadow: 0 0 8px 2px rgba(255, 181, 71, 0.8); transition: none; }
.led[data-led="mem"].on i { background: var(--violet); box-shadow: 0 0 10px 3px rgba(139, 108, 255, 0.9); transition: none; }
.led[data-led="err"].on i { background: var(--coral); box-shadow: 0 0 10px 3px rgba(255, 93, 115, 0.9); transition: none; }
.ctrl-row { grid-area: ctrl; display: flex; gap: 12px; align-items: flex-end; }
.dips { display: flex; flex-direction: column; gap: 4px; }
.dip-block { display: flex; gap: 3px; padding: 4px; background: #c23a52; border-radius: 3px; box-shadow: 0 2px 0 #7d2034, inset 0 1px 0 #e05b73; }
.dip {
  position: relative; width: 30px; height: 44px; padding: 0; border: 0; cursor: pointer;
  background: #5c1426; border-radius: 2px; -webkit-tap-highlight-color: transparent;
}
.dip::after {
  content: ""; position: absolute; left: 5px; right: 5px; height: 14px; bottom: 5px;
  background: var(--cream); border-radius: 1px; box-shadow: 0 2px 0 #b6a98b; transition: bottom 0.08s;
}
.dip span { position: absolute; top: 3px; left: 0; right: 0; font-family: var(--f-pixel); font-size: 9px; color: #f2c3cc; }
.dip.on::after { bottom: 25px; }
.dip.on span { top: auto; bottom: 4px; color: #fff; }
.tacts { display: flex; gap: 8px; }
.tact {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 0; border: 0; background: none; cursor: pointer;
  font-family: var(--f-pixel); font-size: 9px; color: rgba(246, 235, 210, 0.8); -webkit-tap-highlight-color: transparent;
}
.tact i {
  display: block; width: 34px; height: 34px; border-radius: 4px;
  background: radial-gradient(circle at 50% 50%, #1b1b22 0 9px, #2b2b33 9.5px 11px, transparent 11.5px), linear-gradient(145deg, #c9c7d6, #7c7a8c);
  box-shadow: 0 2px 0 #3a3848, 0 3px 6px rgba(0, 0, 0, 0.4);
}
.tact:active i { transform: translateY(1px); box-shadow: 0 1px 0 #3a3848; }
.sw1 {
  grid-area: sw1; display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.sw1-body {
  position: relative; display: grid; place-items: center; width: 92px; height: 92px; border-radius: 8px;
  background: linear-gradient(150deg, #dcdae6 0%, #9a98aa 55%, #6f6d80 100%);
  box-shadow: 0 4px 0 #3a3848, 0 8px 16px rgba(0, 0, 0, 0.45), inset 0 1px 0 #fff;
}
.sw1-body::before, .sw1-body::after {
  content: ""; position: absolute; width: 8px; height: 8px; border-radius: 50%; background: #55536a;
  box-shadow: 66px 0 0 #55536a, 0 66px 0 #55536a, 66px 66px 0 #55536a;
  left: 8px; top: 8px;
}
.sw1-body::after { display: none; }
.sw1-cap {
  width: 62px; height: 62px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ff9aa8 0 6px, var(--coral) 14px, #c9284a 100%);
  box-shadow: 0 5px 0 #8c1f37, 0 7px 10px rgba(0, 0, 0, 0.5), inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.05s, box-shadow 0.05s;
}
.sw1.down .sw1-cap, .sw1:active .sw1-cap { transform: translateY(4px); box-shadow: 0 1px 0 #8c1f37, 0 2px 4px rgba(0, 0, 0, 0.5); }

.rig-text { max-width: 760px; margin: 14px auto 0; padding: 0 2px; }
.hello { margin: 0 0 8px; font-size: 16px; line-height: 1.6; color: var(--cream); }
.help { margin: 0; font-family: var(--f-term); font-size: 19px; line-height: 1.5; color: var(--muted); }
.help .dot { color: #4a4562; margin: 0 2px; }
kbd {
  font-family: var(--f-pixel); font-size: 10px; color: var(--cream); background: var(--ink-2);
  padding: 1px 6px 2px; box-shadow: 0 2px 0 #000, 0 0 0 1px var(--line); border-radius: 2px; vertical-align: 2px;
}

/* =========================================================
   SECTIONS
   ========================================================= */
.sec { max-width: 1180px; margin: 0 auto; padding: 46px var(--gut) 10px; }
.sec-head {
  display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap;
  max-width: 760px; margin: 0 auto 14px; padding-bottom: 8px;
  border-bottom: 2px dashed #262c3d;
}
#memory .sec-head, #memory .sec-sub { max-width: 1100px; }
.sec-addr { font-family: var(--f-term); font-size: 22px; color: var(--amber); }
.sec-head h2 { margin: 0; font-family: var(--f-pixel); font-weight: 400; font-size: clamp(20px, 5.4vw, 30px); letter-spacing: 0.04em; color: var(--mint); text-shadow: 0 0 10px rgba(124, 242, 176, 0.35); }
.sec-meta { margin-left: auto; font-family: var(--f-term); font-size: 19px; color: var(--muted); }
.sec-sub { max-width: 760px; margin: 0 auto 20px; color: var(--cream-dim); font-size: 16px; }
.todo { display: none; max-width: 760px; margin: -4px auto 12px; font-family: var(--f-mono); font-size: 15px; color: #6f7a8f; }
.todo s { color: #8f6a3a; } .todo span { color: var(--mint-dim); }

/* =========================================================
   THE LETTER: fed out of a dot-matrix printer
   ========================================================= */
.printer { max-width: 760px; margin: 0 auto; }
.printer-top {
  position: relative; height: 40px; border-radius: 12px 12px 6px 6px; z-index: 2;
  background: linear-gradient(#2a2e3c, #171a23 70%, #0c0e13);
  box-shadow: 0 2px 0 #3b4155 inset, 0 8px 18px rgba(0, 0, 0, 0.5);
  display: flex; align-items: center; gap: 10px; padding: 0 16px 6px;
}
.printer-led { width: 8px; height: 8px; border-radius: 50%; background: #1d4436; }
.printer-led.busy { background: var(--amber); box-shadow: 0 0 8px var(--amber); animation: blink 0.25s steps(2) infinite; }
.printer-led.ok { background: var(--mint); box-shadow: 0 0 8px var(--mint); }
.printer-name { font-family: var(--f-pixel); font-size: 9px; color: #7d7896; letter-spacing: 0.08em; }
.printer-slot { position: absolute; left: 10px; right: 10px; bottom: 4px; height: 3px; border-radius: 2px; background: #000; box-shadow: 0 1px 0 #3b4155; }

.paper {
  position: relative; margin: -4px 8px 0; padding: 22px 20px 26px;
  background-color: var(--paper);
  color: var(--paper-ink);
  /* tractor-feed holes and perforations down both edges */
  background-image:
    radial-gradient(circle at 8px 12px, var(--crt) 0 3.6px, transparent 4.2px),
    radial-gradient(circle at calc(100% - 8px) 12px, var(--crt) 0 3.6px, transparent 4.2px),
    linear-gradient(90deg, transparent 15px, rgba(34, 29, 51, 0.16) 15px 16px, transparent 16px calc(100% - 16px), rgba(34, 29, 51, 0.16) calc(100% - 16px) calc(100% - 15px), transparent calc(100% - 15px));
  background-size: 100% 24px, 100% 24px, 100% 100%;
  background-repeat: repeat-y, repeat-y, no-repeat;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), 96% 100%, 92% calc(100% - 7px), 88% 100%, 84% calc(100% - 7px), 80% 100%, 76% calc(100% - 7px), 72% 100%, 68% calc(100% - 7px), 64% 100%, 60% calc(100% - 7px), 56% 100%, 52% calc(100% - 7px), 48% 100%, 44% calc(100% - 7px), 40% 100%, 36% calc(100% - 7px), 32% 100%, 28% calc(100% - 7px), 24% 100%, 20% calc(100% - 7px), 16% 100%, 12% calc(100% - 7px), 8% 100%, 4% calc(100% - 7px), 0 100%);
}
.paper-inner {
  position: relative; padding: 0 6px;
  /* green-bar listing paper */
  background-image: repeating-linear-gradient(to bottom, rgba(124, 242, 176, 0.17) 0 60px, transparent 60px 120px);
  background-position: 0 4px;
}
.po-cmd, .po-status { margin: 0; font-family: var(--f-mono); font-size: 13px; line-height: 20px; color: #6d6490; white-space: pre-wrap; }
.po-status { min-height: 20px; margin-bottom: 12px; color: #7c5a9e; }
.po-status .bar-fill { color: var(--coral-ink); }
.po-body { font-family: var(--f-mono); font-size: 16px; line-height: 30px; letter-spacing: 0; overflow-wrap: break-word; }
.po-body p { margin: 0 0 30px; }
.po-body .po-greet { font-weight: 600; margin-bottom: 30px; }
.po-body .po-signoff { margin-bottom: 0; }
.po-body .po-sig { font-family: var(--f-pixel); font-size: 22px; line-height: 40px; color: var(--coral-ink); margin-top: 2px; }
.po-body .po-sig .heart { display: inline-block; width: 14px; height: 12px; margin-left: 10px; vertical-align: -1px;
  background: var(--coral-ink); clip-path: polygon(0 17%, 17% 0, 42% 0, 50% 17%, 58% 0, 83% 0, 100% 17%, 100% 50%, 50% 100%, 0 50%); }
.po-eof { margin: 18px 0 0; font-family: var(--f-mono); font-size: 13px; color: #8a83a6; text-align: center; letter-spacing: 0.2em; }
.d-hex { color: #8b80bf; }
.d-scr { color: var(--coral-ink); font-weight: 600; }
.paper.decoding { cursor: pointer; }
.po-images { display: grid; gap: 12px; }
.po-images:empty { display: none; }
.po-images img { width: 100%; height: auto; border: 3px solid var(--paper-ink); }

/* the letter isn't ready yet */
.paper.pending .po-body p { margin-bottom: 10px; }
.pending-head { color: var(--coral-ink); font-weight: 600; }
.pending-bar { position: relative; height: 30px; margin-top: 10px; overflow: hidden; }
.pending-bar::before { content: ""; position: absolute; left: 0; right: 0; top: 14px; border-top: 2px dotted rgba(34, 29, 51, 0.35); }
.pending-head-ink { position: absolute; top: 6px; left: 0; width: 26px; height: 18px; background: var(--paper-ink); border-radius: 2px; }
@media (prefers-reduced-motion: no-preference) { .pending-head-ink { animation: carriage 2.4s ease-in-out infinite alternate; } }
@keyframes carriage { to { left: calc(100% - 26px); } }

/* =========================================================
   MEMORY CARD
   ========================================================= */
.mem-grid { list-style: none; margin: 0 auto; padding: 0; max-width: 1100px; display: grid; gap: 26px; }
.blk { margin: 0; }
.blk-btn {
  display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.blk-frame {
  position: relative; display: block; overflow: hidden; aspect-ratio: var(--ar, 1.333);
  background: #0f1118;
  box-shadow: 0 -4px 0 0 #2b2f42, 0 4px 0 0 #2b2f42, -4px 0 0 0 #2b2f42, 4px 0 0 0 #2b2f42, 0 10px 0 0 #000;
  margin: 4px;
}
.blk-frame img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s, filter 0.3s; }
.blk-btn:hover .blk-frame img { transform: scale(1.02); }
.blk-mosaic { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; opacity: 0; transition: opacity 0.35s; }
.blk-lock {
  position: absolute; inset: 0; display: none; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  font-family: var(--f-pixel); color: var(--cream);
}
.blk-lock b { font-weight: 400; font-size: 13px; background: rgba(11, 13, 16, 0.9); padding: 6px 10px; box-shadow: 0 0 0 2px var(--amber); }
.blk-lock small { font-family: var(--f-term); font-size: 19px; background: rgba(11, 13, 16, 0.85); padding: 0 8px; color: var(--amber); }
.blk.locked .blk-frame img { filter: blur(14px) saturate(0.4); }
.blk.locked .blk-mosaic, .blk.decrypting .blk-mosaic { opacity: 1; }
.blk.locked .blk-frame::after, .blk.decrypting .blk-frame::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(160deg, rgba(139, 108, 255, 0.55), rgba(124, 242, 176, 0.35)), repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0 2px, transparent 2px 4px);
  mix-blend-mode: hard-light;
}
.blk.locked .blk-lock, .blk.decrypting .blk-lock { display: flex; }
.blk.decrypting .blk-lock b { box-shadow: 0 0 0 2px var(--mint); color: var(--mint); }
.blk.unlocked .blk-mosaic { opacity: 0; }
.blk-cap { display: flex; gap: 10px; align-items: baseline; margin: 12px 4px 0; }
.blk-addr { flex: none; font-family: var(--f-term); font-size: 19px; color: var(--amber); }
.blk.fresh .blk-addr::after { content: " NEW"; color: var(--mint); animation: blink 0.9s steps(2) infinite; }
.blk-text { font-size: 15px; line-height: 1.5; color: var(--cream-dim); }
.blk.locked .blk-text { color: #9790b0; }

/* =========================================================
   SHARED LIBRARIES (classes)
   ========================================================= */
.term {
  max-width: 760px; margin: 0 auto; padding: 14px 16px 10px;
  background: #07080b; border: 1px solid #262c3d; border-radius: 8px;
  box-shadow: inset 0 0 30px rgba(124, 242, 176, 0.04);
}
.term-cmd { margin: 0 0 8px; font-family: var(--f-term); font-size: 20px; color: var(--mint); }
.cls-list { list-style: none; margin: 0; padding: 0; }
.cls {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: baseline;
  padding: 8px 0; border-top: 1px dashed #1f2433;
}
.cls:first-child { border-top: 0; }
.cls-perm { font-family: var(--f-term); font-size: 18px; color: #7a86a6; }
.cls-year { font-family: var(--f-term); font-size: 18px; color: var(--amber); text-align: right; }
.cls-name { grid-column: 1 / -1; font-size: 16px; color: var(--cream); font-weight: 500; }
.cls-teacher { grid-column: 1 / -1; font-size: 14px; color: var(--muted); }
@media (min-width: 640px) {
  .cls { grid-template-columns: 120px 1fr auto 60px; }
  .cls-name, .cls-teacher { grid-column: auto; }
  .cls-perm { grid-column: 1; grid-row: 1; } .cls-name { grid-column: 2; grid-row: 1; } .cls-teacher { grid-column: 3; grid-row: 1; text-align: right; } .cls-year { grid-column: 4; grid-row: 1; }
}

/* =========================================================
   FOOTER
   ========================================================= */
.foot { max-width: 760px; margin: 0 auto; padding: 60px var(--gut) calc(40px + env(safe-area-inset-bottom)); text-align: center; }
.foot-eof { margin: 0; font-family: var(--f-pixel); font-size: 44px; line-height: 1; color: var(--violet-dim); letter-spacing: 0.12em; }
.foot-made { margin: 16px 0 6px; font-size: 16px; color: var(--cream); }
.foot-stats { display: flex; justify-content: center; gap: 22px; margin: 0 0 18px; font-family: var(--f-term); font-size: 21px; color: var(--muted); }
.foot-stats b { font-weight: 400; color: var(--mint); }
.foot-btns { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; }
.foot-hint { margin: 22px 0 4px; font-size: 14px; color: #8f89a8; }
.foot-exit { margin: 0; font-family: var(--f-term); font-size: 18px; color: #3d4560; }

/* =========================================================
   LIGHTBOX & TOAST
   ========================================================= */
.lightbox {
  width: min(960px, 100vw - 16px); max-width: none; max-height: calc(100vh - 16px); padding: 12px; border: 0;
  background: var(--crt); color: var(--cream);
  box-shadow: 0 -4px 0 0 var(--violet-dim), 0 4px 0 0 var(--violet-dim), -4px 0 0 0 var(--violet-dim), 4px 0 0 0 var(--violet-dim);
}
.lightbox::backdrop { background: rgba(5, 6, 9, 0.86); }
.lb-top { display: flex; align-items: center; justify-content: space-between; margin: 0 0 10px; }
.lb-addr { font-family: var(--f-term); font-size: 20px; color: var(--amber); }
.lb-x { min-height: 44px; padding: 0 12px; border: 0; background: var(--ink-2); color: var(--cream); font-family: var(--f-pixel); font-size: 11px; cursor: pointer; }
.lb-fig { margin: 0; }
.lb-fig img { width: 100%; height: auto; max-height: calc(100vh - 210px); object-fit: contain; background: #000; }
.lb-fig figcaption { margin-top: 10px; font-size: 16px; color: var(--cream-dim); }
.lb-nav { display: flex; justify-content: space-between; margin-top: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 80;
  max-width: calc(100vw - 32px); padding: 10px 14px;
  font-family: var(--f-pixel); font-size: 11px; line-height: 1.5; color: var(--cream); text-align: center;
  background: #0b0d10; box-shadow: 0 -2px 0 0 var(--mint), 0 2px 0 0 var(--mint), -2px 0 0 0 var(--mint), 2px 0 0 0 var(--mint), 0 8px 24px rgba(0, 0, 0, 0.6);
  transform: translate(-50%, 160%); opacity: 0; transition: transform 0.25s cubic-bezier(.2, .9, .3, 1.3), opacity 0.2s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast b { color: var(--amber); font-weight: 400; }

/* =========================================================
   DEBUG BUILD (type "edward", or tap the logo 5x)
   ========================================================= */
.debug .bar-debug { display: inline-block; }
.debug .bar { border-bottom-color: var(--amber); }
.debug .todo { display: block; }
.debug [data-src] { position: relative; outline: 1px dashed rgba(255, 181, 71, 0.55); outline-offset: -1px; }
.debug [data-src]::before {
  content: attr(data-src); position: absolute; top: 0; right: 0; z-index: 3;
  font-family: var(--f-term); font-size: 15px; color: #120d00; background: var(--amber); padding: 0 6px;
}
.debug .reg-fps, .debug .regs .reg:first-child { display: inline; }
.debug .regs { font-size: 15px; }
.debug .blk-frame { outline: 1px solid var(--coral); }

/* =========================================================
   WIDER SCREENS
   ========================================================= */
@media (min-width: 600px) {
  .rig { padding: 18px var(--gut) 8px; }
  .board { padding: 26px 18px 20px; }
  .silk-made { display: inline; }
  .regs .reg:first-child { display: inline; }
  .paper { margin: -4px 14px 0; padding: 32px 34px 34px; background-image:
    radial-gradient(circle at 11px 12px, var(--crt) 0 4.4px, transparent 5px),
    radial-gradient(circle at calc(100% - 11px) 12px, var(--crt) 0 4.4px, transparent 5px),
    linear-gradient(90deg, transparent 22px, rgba(34, 29, 51, 0.16) 22px 23px, transparent 23px calc(100% - 23px), rgba(34, 29, 51, 0.16) calc(100% - 23px) calc(100% - 22px), transparent calc(100% - 22px)); }
  .paper-inner { padding: 0 14px; }
  .po-body { font-size: 17px; line-height: 32px; }
  .po-body p { margin-bottom: 32px; }
  .paper-inner { background-image: repeating-linear-gradient(to bottom, rgba(124, 242, 176, 0.17) 0 64px, transparent 64px 128px); }
  .mem-grid { display: flex; flex-wrap: wrap; gap: 30px 22px; }
  .blk { flex: var(--ar) 1 calc(var(--ar) * 200px); min-width: 0; }
}
@media (min-width: 960px) {
  .board { display: grid; grid-template-columns: minmax(0, 1fr) 236px; gap: 22px; padding: 30px 24px 24px; }
  .board-side {
    display: flex; flex-direction: column; align-items: stretch; gap: 18px; margin-top: 0;
    padding: 6px 0 0;
  }
  .u1 { display: flex; flex-direction: column; align-items: center; }
  .u1-pins { width: 110px; height: 7px; background: repeating-linear-gradient(90deg, #c9c7d6 0 4px, transparent 4px 9px); }
  .u1-body {
    width: 128px; height: 74px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
    background: linear-gradient(#22222a, #141419); border-radius: 3px; box-shadow: 0 3px 0 #000, inset 0 1px 0 #3a3a45;
    font-family: var(--f-pixel); color: #b9b6c8;
  }
  .u1-body b { font-weight: 400; font-size: 13px; letter-spacing: 0.08em; }
  .u1-body small { font-size: 8px; color: #6f6c80; }
  .u1-body::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #0b0b0f; margin: -6px 0 4px -96px; }
  .leds { justify-content: space-between; padding: 0 6px; }
  .ctrl-row { justify-content: space-between; }
  .uart { display: flex; flex-direction: column; gap: 4px; flex: 1; min-height: 96px; }
  .uart pre {
    flex: 1; margin: 0; padding: 6px 8px; overflow: hidden; display: flex; flex-direction: column; justify-content: flex-end;
    font-family: var(--f-term); font-size: 15px; line-height: 1.15; color: var(--mint); white-space: pre-wrap; word-break: break-all;
    background: #07080b; border: 1px solid #3b2f7a; border-radius: 4px; box-shadow: inset 0 0 14px rgba(124, 242, 176, 0.06);
    min-height: 0; max-height: 220px;
  }
  .sw1 { margin-top: auto; align-self: center; }
  .sw1-body { width: 132px; height: 132px; border-radius: 10px; }
  .sw1-body::before { box-shadow: 106px 0 0 #55536a, 0 106px 0 #55536a, 106px 106px 0 #55536a; }
  .sw1-cap { width: 90px; height: 90px; }
  .regs { font-size: 19px; }
  .reg-fps { display: inline; }
  .rig-text { margin-top: 18px; }
  .sec { padding-top: 64px; }
}

/* landscape phones: give the screen everything */
@media (max-height: 500px) and (orientation: landscape) {
  .board { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 12px; padding-top: 20px; }
  .board-side { grid-template-columns: 1fr; grid-template-areas: "sw1" "leds" "ctrl"; margin-top: 0; justify-items: center; }
  .ctrl-row { flex-direction: column; align-items: center; gap: 8px; }
  .regs { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .toast { transition: opacity 0.2s !important; }
}
