/* ==========================================================================
   overlays.css — 24fps Big CRT Monitor + Live Website Zoom-In (Resolution-Safe),
                  Custom Hardware Crosshair Cursor, Lightbox & Toast
   ========================================================================== */

/* ============ BIG CRT MONITOR & LIVE WEBSITE ZOOM-IN (24FPS) ============ */
html.crt-active,
html.crt-active body {
  overflow: hidden !important;
  background: #040706 !important;
}

/* Frame the live website (#board) inside the 64vw x 64vh CRT glass aperture.
   No will-change on .board so Chrome/Edge keeps crisp 1:1 vector text resolution! */
html.crt-active .board {
  transform-origin: 50% 50vh;
  transform: translate3d(var(--cam-x, 0vw), var(--b-y, -16px), 0) scale(var(--b-scale, 0.64));
}

.boot {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  font-family: var(--f-mono);
  overflow: hidden;
}

.boot.is-done,
html[data-motion="off"] .boot {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* The 3D Physical CRT Monitor Rig — synchronized with #board at 24fps */
.crt-rig {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  transform: translate3d(var(--cam-x, 0vw), var(--r-y, -10px), 0) scale(var(--r-scale, 1));
  transform-origin: 50% calc(50% - 6px);
  opacity: var(--r-op, 1);
}

/* Outer room mask painted with simple borders */
.crt-rig::before {
  content: "";
  position: absolute;
  inset: -45vh -45vw;
  border: 45.5vh solid #040706;
  border-inline-width: 45.5vw;
  pointer-events: none;
  z-index: 0;
}

html.era-mode .board {
  max-height: 100vh;
  overflow: hidden;
  position: relative;
  z-index: 295;
  pointer-events: none;
}

html.era-mode .boot {
  pointer-events: none !important;
}

html.era-mode .crt-rig {
  pointer-events: none !important;
}

html.era-mode .crt-rig::before {
  display: none !important;
}

html.era-mode .crt-housing {
  pointer-events: auto !important;
  cursor: pointer;
}

/* Molded Industrial Monitor Casing (Responsive across all laptop/desktop resolutions) */
.crt-housing {
  position: relative;
  z-index: 2;
  background: transparent;
  border-radius: clamp(18px, 2.2vw, 28px);
  border: 2px solid #3c4540;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.92);
}

.crt-top-vents {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: clamp(10px, 1.4vh, 16px) clamp(16px, 2vw, 26px) clamp(8px, 1vh, 12px);
  background: linear-gradient(180deg, #2b312e 0%, #222725 100%);
}

.crt-top-vents i {
  width: clamp(18px, 2vw, 28px);
  height: 4px;
  border-radius: 2px;
  background: #0a0d0c;
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.9), 0 1px 0 rgba(255, 255, 255, 0.08);
}

/* Deep Recessed Inner Bezel Lip — uses borders so center stays 100% transparent! */
.crt-bezel-lip {
  background: transparent;
  border-left: clamp(16px, 1.8vw, 26px) solid #202523;
  border-right: clamp(16px, 1.8vw, 26px) solid #202523;
  padding: 0;
}

/* Transparent Glass Aperture exactly matching scale(0.64) of #board (64vw x 64vh) */
.crt-aperture {
  position: relative;
  width: 64vw;
  height: 64vh;
  border: clamp(8px, 1vh, 12px) solid #0d100f;
  border-radius: 4px;
  overflow: hidden;
  background: transparent;
  box-shadow:
    inset 0 0 32px rgba(0, 0, 0, 0.7),
    inset 0 0 2px 1px rgba(255, 255, 255, 0.14);
}

/* 24fps Stepped Top & Bottom Phosphor Shutters */
.crt-shutter {
  position: absolute;
  left: 0;
  right: 0;
  height: 50.5%;
  background: #040907;
  z-index: 3;
  transition: transform 0.62s steps(15, end);
}

.crt-shutter-top {
  top: 0;
  transform-origin: top center;
}

.crt-shutter-bot {
  bottom: 0;
  transform-origin: bottom center;
}

.boot.stage-tube .crt-shutter-top,
.boot.stage-zoom .crt-shutter-top,
.boot.stage-tube .crt-shutter-bot,
.boot.stage-zoom .crt-shutter-bot {
  transform: scaleY(0);
}

/* Stage 1: Horizontal CRT Electron Beam Strike (24fps stepped) */
.crt-beam {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  margin-top: -1.5px;
  background: #ffffff;
  box-shadow: 0 0 12px #ffffff, 0 0 26px var(--led-ok);
  transform: scaleX(0.01);
  opacity: 1;
  z-index: 5;
  transition: transform 0.45s steps(11, end),
              opacity 0.25s steps(6, end);
}

.boot.stage-beam .crt-beam {
  transform: scaleX(1);
}

.boot.stage-tube .crt-beam,
.boot.stage-zoom .crt-beam {
  transform: scaleX(1);
  opacity: 0;
}

/* CRT Scanlines & Curved Glass Glare over the live website */
.crt-scanlines {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.28) 0px,
      rgba(0, 0, 0, 0.28) 1px,
      transparent 1px,
      transparent 3px
    );
  pointer-events: none;
  z-index: 6;
}

.crt-glare {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.07) 0%, rgba(255, 255, 255, 0.02) 22%, transparent 40%),
    radial-gradient(circle at center, transparent 64%, rgba(0, 0, 0, 0.5) 100%);
  pointer-events: none;
  z-index: 7;
}

/* Green CRT On-Screen Display (OSD) above the bottom sync bar */
.crt-osd {
  position: absolute;
  bottom: 26px;
  left: 18px;
  right: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--f-mono);
  font-size: clamp(0.65rem, 0.9vw, 0.75rem);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--led-ok);
  text-shadow: 0 0 10px rgba(91, 227, 139, 0.85), 0 1px 2px #000;
  z-index: 8;
  opacity: 0;
  transition: opacity 0.25s steps(6, end);
}

.boot.stage-tube .crt-osd {
  opacity: 1;
}

.crt-osd span {
  background: rgba(6, 16, 12, 0.84);
  border: 1px solid rgba(91, 227, 139, 0.45);
  padding: 4px 10px;
  border-radius: 3px;
}

/* CRT Bottom Phosphor Progress Bar inside Glass */
.crt-loadbar {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  height: 6px;
  background: rgba(6, 16, 12, 0.84);
  border: 1px solid rgba(91, 227, 139, 0.45);
  border-radius: 3px;
  overflow: hidden;
  z-index: 8;
  opacity: 0;
  transition: opacity 0.25s steps(6, end);
}

.boot.stage-tube .crt-loadbar {
  opacity: 1;
}

.crt-loadbar i {
  display: block;
  height: 100%;
  width: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  background: linear-gradient(90deg, var(--led-ok), var(--gold-hi));
  box-shadow: 0 0 10px var(--led-ok);
}

/* Monitor Lower Chin, Badge, Knobs & Power Button */
.crt-chin {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: clamp(10px, 1.3vh, 14px) clamp(16px, 2vw, 26px) clamp(12px, 1.6vh, 16px);
  background: linear-gradient(180deg, #1c211f 0%, #121614 100%);
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.crt-badge {
  display: flex;
  align-items: baseline;
  gap: 10px;
  white-space: nowrap;
}

.crt-badge b {
  font-family: var(--f-stencil);
  font-size: clamp(0.9rem, 1.2vw, 1.05rem);
  letter-spacing: 0.08em;
  color: var(--gold-hi);
}

.crt-badge span {
  font-size: 0.64rem;
  color: #8b9690;
  letter-spacing: 0.08em;
}

.crt-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.crt-knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #38403c, #141816);
  border: 1px solid #090b0a;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.7), inset 0 1px 1px rgba(255, 255, 255, 0.15);
  position: relative;
}

.crt-knob::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 6px;
  width: 2px;
  height: 4px;
  background: #8b9690;
}

.crt-hint-pill {
  font-size: 0.62rem;
  color: #9aa89f;
  letter-spacing: 0.08em;
  padding: 4px 10px;
  background: #101412;
  border: 1px solid #2b332f;
  border-radius: 3px;
  white-space: nowrap;
}

.crt-pwr {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  background: #141917;
  border: 1.5px solid #2f3834;
  border-radius: 4px;
  font-size: 0.66rem;
  font-weight: 500;
  color: #cfd8d3;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1), 0 2px 4px rgba(0, 0, 0, 0.6);
}

.crt-pwr i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--led-warn);
  box-shadow: 0 0 8px var(--led-warn);
}

.boot.stage-beam .crt-pwr i,
.boot.stage-tube .crt-pwr i,
.boot.stage-zoom .crt-pwr i {
  background: var(--led-ok);
  box-shadow: 0 0 12px var(--led-ok);
}

/* Monitor Pedestal Neck & Swivel Stand */
.crt-neck {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: clamp(100px, 10vw, 140px);
  height: clamp(14px, 2vh, 20px);
  background: linear-gradient(90deg, #111513, #262c29 50%, #111513);
  border-inline: 2px solid #0a0c0b;
  box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.85);
}

.crt-base {
  position: absolute;
  top: calc(100% + clamp(14px, 2vh, 20px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  width: clamp(220px, 24vw, 320px);
  height: clamp(12px, 1.8vh, 16px);
  background: linear-gradient(180deg, #282e2b 0%, #151917 100%);
  border: 1.5px solid #39423d;
  border-radius: 12px 12px 4px 4px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.9);
}

@media (max-width: 860px) {
  .crt-hint-pill,
  .crt-knob {
    display: none;
  }
  .crt-monitor {
    width: 92vw;
    height: 76vh;
  }
  .crt-bezel-lip {
    border-width: 28px 14px 48px 14px;
  }
  .crt-aperture {
    inset: 28px 14px 48px 14px;
  }
  .crt-top-plate {
    height: 28px;
    padding: 0 12px;
  }
  .crt-chin {
    height: 48px;
    padding: 0 14px;
  }
  .crt-model-tag {
    display: none;
  }
}

/* ============ DECEMBER SNOWFALL CANVAS (snow.js) ============ */
.snow-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 48;
}

.snow-canvas[hidden] {
  display: none !important;
}

/* ============ CHRISTMAS LED FAIRY LIGHTS & PCB DECOR ============ */
html.xmas-off .xmas-strand,
html.xmas-off .xmas-foot-strand,
html.xmas-off .xmas-chip-hat,
html.xmas-off .xmas-holly,
html.crt-active .xmas-strand,
html.era-mode .xmas-strand {
  display: none !important;
}

.lyr-sw-xmas {
  background: conic-gradient(#ff5964 0 90deg, #ffd166 90deg 180deg, #4ade80 180deg 270deg, #56cfe1 270deg 360deg) !important;
}

.xmas-strand {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  height: 26px;
  pointer-events: none;
  overflow-x: clip;
  overflow-y: visible;
  z-index: 4;
}

.xmas-foot-strand {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 26px;
  pointer-events: none;
  overflow: hidden;
  z-index: 4;
}

.xmas-wire {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 14px;
  display: block;
}

.xmas-bulbs {
  position: relative;
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-inline: 10px;
  height: 100%;
}

.xmas-bulb {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 3px;
  transform: rotate(var(--rot, 0deg));
  transform-origin: top center;
}

.xmas-bulb-cap {
  width: 6px;
  height: 5px;
  background: linear-gradient(180deg, #2e3834 0%, #141917 100%);
  border: 1px solid rgba(230, 194, 116, 0.4);
  border-radius: 1.5px 1.5px 0 0;
}

.xmas-bulb-glass {
  width: 8px;
  height: 12px;
  border-radius: 3px 3px 50% 50%;
  background: var(--bulb-c, #ffd166);
  box-shadow:
    0 0 8px var(--bulb-c, #ffd166),
    0 0 18px var(--bulb-g, rgba(255, 209, 102, 0.55)),
    inset 0 -2px 3px rgba(255, 255, 255, 0.55);
  animation: xmasTwinkle var(--t, 2.4s) ease-in-out var(--d, 0s) infinite;
}

.xmas-bulb.is-red {
  --bulb-c: #ff5964;
  --bulb-g: rgba(255, 89, 100, 0.65);
}

.xmas-bulb.is-gold {
  --bulb-c: #ffd166;
  --bulb-g: rgba(255, 209, 102, 0.65);
}

.xmas-bulb.is-green {
  --bulb-c: #4ade80;
  --bulb-g: rgba(74, 222, 128, 0.62);
}

.xmas-bulb.is-blue {
  --bulb-c: #56cfe1;
  --bulb-g: rgba(86, 207, 225, 0.65);
}

.xmas-bulb.is-amber {
  --bulb-c: #ff9f43;
  --bulb-g: rgba(255, 159, 67, 0.62);
}

@keyframes xmasTwinkle {
  0%, 100% {
    opacity: 1;
    filter: brightness(1.12);
    transform: scale(1);
  }
  50% {
    opacity: 0.42;
    filter: brightness(0.75);
    transform: scale(0.92);
  }
}

html[data-motion="off"] .xmas-bulb-glass {
  animation: none !important;
  opacity: 0.9;
}

@media (prefers-reduced-motion: reduce) {
  .xmas-bulb-glass {
    animation: none !important;
    opacity: 0.9;
  }
}

/* Santa Hat Perched on U1 64-LQFP Processor Chip */
.xmas-chip-hat {
  position: absolute;
  top: -26px;
  left: -10px;
  width: 78px;
  height: auto;
  z-index: 6;
  pointer-events: none;
  transform: rotate(-16deg);
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55));
}

@media (max-width: 560px) {
  .xmas-chip-hat {
    top: -20px;
    left: -6px;
    width: 60px;
  }
  .xmas-bulb-glass {
    width: 7px;
    height: 10px;
  }
}

/* Festive Holly Badge on Footer Silkscreen Tag */
.foot-silk-tag {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.xmas-holly {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  background: rgba(255, 89, 100, 0.14);
  border: 1px solid rgba(255, 89, 100, 0.45);
  border-radius: 2px;
  font-size: 0.6rem;
  color: #ffb3b8;
  letter-spacing: 0.08em;
}

.xmas-holly svg {
  width: 24px;
  height: 12px;
  display: block;
}

/* ============ CURSOR SWARM (cursor-swarm.js) OVERLAY & BLUEPRINT STATES ============ */
.swarm-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 52;
}

html.js .cs-blueprint {
  opacity: 0 !important;
  clip-path: inset(0 100% 100% 0);
  pointer-events: none;
}

html.js .cs-building {
  opacity: 0.94 !important;
  filter: contrast(1.08) brightness(1.08);
  outline: 1px dashed var(--led-ok);
  outline-offset: 2px;
}

html.js .cs-built {
  opacity: 1 !important;
  clip-path: none !important;
  filter: none;
  outline: 1px solid transparent;
  transform: none !important;
  transition: opacity 0.18s ease, filter 0.18s ease;
}

/* ============ CUSTOM HARDWARE CROSSHAIR CURSOR ============ */
.cursor {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  html.has-cursor,
  html.has-cursor body,
  html.has-cursor a,
  html.has-cursor button,
  html.has-cursor [role="button"],
  html.has-cursor input,
  html.has-cursor label {
    cursor: none !important;
  }

  html.has-cursor .cursor {
    display: block;
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 400;
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.15s ease;
  }

  html.has-cursor .cursor.is-ready {
    opacity: 1;
  }

  .cur-dot {
    position: fixed;
    top: 0;
    left: 0;
    width: 6px;
    height: 6px;
    margin-left: -3px;
    margin-top: -3px;
    border-radius: 50%;
    background: var(--gold-hi);
    box-shadow: 0 0 10px var(--gold-hi), 0 0 4px #fff;
    transform: translate3d(-200px, -200px, 0);
    will-change: transform;
  }

  .cur-ring {
    position: fixed;
    top: 0;
    left: 0;
    width: 32px;
    height: 32px;
    margin-left: -16px;
    margin-top: -16px;
    border: 1.5px solid rgba(230, 194, 116, 0.82);
    border-radius: 4px;
    transform: translate3d(-200px, -200px, 0);
    will-change: transform;
    transition: width 0.16s steps(4, end),
                height 0.16s steps(4, end),
                margin 0.16s steps(4, end),
                border-color 0.16s ease,
                border-radius 0.16s ease,
                background-color 0.16s ease;
  }

  .cur-ring::before,
  .cur-ring::after {
    content: "";
    position: absolute;
  }

  .cur-ring::before {
    left: 50%;
    top: -5px;
    bottom: -5px;
    width: 1px;
    margin-left: -0.5px;
    background: linear-gradient(
      180deg,
      var(--gold) 0 4px,
      transparent 4px calc(100% - 4px),
      var(--gold) calc(100% - 4px) 100%
    );
  }

  .cur-ring::after {
    top: 50%;
    left: -5px;
    right: -5px;
    height: 1px;
    margin-top: -0.5px;
    background: linear-gradient(
      90deg,
      var(--gold) 0 4px,
      transparent 4px calc(100% - 4px),
      var(--gold) calc(100% - 4px) 100%
    );
  }

  .cursor.is-hover .cur-dot {
    background: var(--led-ok);
    box-shadow: 0 0 12px var(--led-ok);
  }

  .cursor.is-hover .cur-ring {
    width: 42px;
    height: 42px;
    margin-left: -21px;
    margin-top: -21px;
    border-color: var(--led-ok);
    background: rgba(91, 227, 139, 0.1);
    border-radius: 50%;
  }

  .cursor.is-down .cur-ring {
    width: 22px;
    height: 22px;
    margin-left: -11px;
    margin-top: -11px;
    border-color: var(--gold-hi);
    background: rgba(230, 194, 116, 0.25);
  }
}

.click-pulse {
  position: fixed;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border: 2px solid var(--gold-hi);
  border-radius: 50%;
  pointer-events: none;
  z-index: 390;
  animation: clickPulseAnim 0.45s steps(11, end) forwards;
}

@keyframes clickPulseAnim {
  0% {
    transform: scale(0.5);
    opacity: 0.95;
  }
  100% {
    transform: scale(4.2);
    opacity: 0;
  }
}

/* ============ OPTICAL INSPECTION LIGHTBOX ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 180;
  background: rgba(6, 9, 8, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--s5);
}

.lightbox[hidden] {
  display: none !important;
}

.lb-fig {
  max-width: min(1080px, 90vw);
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--s2);
  animation: lbZoomIn 0.25s steps(6, end);
}

@keyframes lbZoomIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

#lbImg {
  max-width: 100%;
  max-height: 78vh;
  object-fit: contain;
  border: 2px solid var(--gold);
  border-radius: 3px;
  background: #0a0d0c;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
}

#lbCap {
  font-family: var(--f-mono);
  font-size: 0.78rem;
  color: var(--gold-hi);
  text-align: center;
}

.lb-x,
.lb-nav {
  position: absolute;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--ic);
  color: var(--ic-ink);
  border: 1.5px solid var(--gold);
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.lb-x:hover,
.lb-nav:hover {
  background: var(--gold);
  color: #111;
}

.lb-x svg,
.lb-nav svg {
  width: 20px;
  height: 20px;
}

.lb-x {
  top: var(--s4);
  right: var(--s4);
}

.lb-prev {
  left: var(--s4);
  top: 50%;
  transform: translateY(-50%);
}

.lb-next {
  right: var(--s4);
  top: 50%;
  transform: translateY(-50%);
}

.lb-nav[hidden] {
  display: none !important;
}

/* Status Toast */
.toast {
  position: fixed;
  bottom: var(--s4);
  right: var(--s4);
  z-index: 190;
  padding: 10px 16px;
  background: var(--ic);
  color: var(--led-ok);
  border: 1.5px solid var(--gold);
  border-radius: 3px;
  font-family: var(--f-mono);
  font-size: 0.76rem;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-on {
  opacity: 1;
  transform: translateY(0);
}

/* ============ J3 · UART0 HARDWARE SERIAL DEBUG CONSOLE (EMBEDDED UNDER EVENTS) ============ */
.uart-dock {
  margin-top: var(--s6);
}

.uart-dock-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: var(--s2);
  font-family: var(--f-mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: var(--gold);
  text-transform: uppercase;
}

.uart-dock-hint {
  color: var(--silk-dim);
  font-size: 0.65rem;
}

.uart-term {
  position: relative;
  width: 100%;
  height: 440px;
  z-index: 5;
  display: flex;
  flex-direction: column;
  background: #0a0f0d;
  border: 2px solid var(--gold);
  border-radius: 6px;
  box-shadow:
    0 18px 44px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.85),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-family: var(--f-mono);
  transition: height 0.22s ease;
  overflow: hidden;
}

.uart-term.is-max {
  height: min(640px, 78vh);
}

/* Top Hardware Bezel Header */
.uart-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(180deg, #1a211e 0%, #101513 100%);
  border-bottom: 1.5px solid #252e2a;
  flex-shrink: 0;
}

.uart-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.uart-title b {
  font-size: 0.72rem;
  color: var(--gold-hi);
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.uart-baud {
  font-size: 0.62rem;
  padding: 2px 7px;
  background: #070b09;
  color: var(--led-ok);
  border: 1px solid rgba(91, 227, 139, 0.35);
  border-radius: 3px;
  white-space: nowrap;
}

.uart-baud.is-hot {
  color: #ff6b5b;
  border-color: rgba(255, 107, 91, 0.6);
  box-shadow: 0 0 8px rgba(255, 107, 91, 0.3);
}

.uart-leds {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.6rem;
  color: var(--ic-dim);
  letter-spacing: 0.08em;
}

.uart-led-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.uart-led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #232b27;
  border: 1px solid #080b0a;
  transition: background-color 0.06s ease, box-shadow 0.06s ease;
}

.uart-led.tx.is-active {
  background: var(--gold-hi);
  box-shadow: 0 0 8px var(--gold-hi);
}

.uart-led.rx.is-active {
  background: var(--led-ok);
  box-shadow: 0 0 8px var(--led-ok);
}

.uart-ctrls {
  display: flex;
  align-items: center;
  gap: 5px;
}

.uart-ctrl-btn {
  padding: 3px 8px;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  font-weight: 600;
  color: var(--ic-ink);
  background: #141917;
  border: 1px solid #2e3834;
  border-radius: 3px;
  cursor: pointer;
  transition: border-color 0.14s ease, background-color 0.14s ease, color 0.14s ease;
}

.uart-ctrl-btn:hover {
  border-color: var(--gold);
  color: var(--gold-hi);
}

.uart-ctrl-btn.close:hover {
  background: #8e2020;
  border-color: #ff7a6b;
  color: #fff;
}

/* Quick SMD Jumper Macros Bar */
.uart-macros {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 7px 12px;
  background: #0c110f;
  border-bottom: 1px solid #1e2623;
  overflow: hidden;
  flex-shrink: 0;
}

.uart-macro-lbl {
  font-size: 0.58rem;
  color: var(--ic-dim);
  letter-spacing: 0.08em;
  margin-right: 3px;
  flex-shrink: 0;
}

.uart-chip {
  padding: 3px 8px;
  font-family: var(--f-mono);
  font-size: 0.62rem;
  color: var(--ic-ink);
  background: #151c19;
  border: 1px solid #2b3631;
  border-radius: 3px;
  white-space: nowrap;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.14s ease, color 0.14s ease, transform 0.1s ease;
}

.uart-chip:hover {
  border-color: var(--gold);
  color: var(--gold-hi);
  transform: translateY(-1px);
}

.uart-chip.is-egg {
  border-color: rgba(230, 194, 116, 0.45);
  color: var(--gold-hi);
  background: rgba(230, 194, 116, 0.08);
}

.uart-chip.is-egg:hover {
  border-color: var(--led-ok);
  color: var(--led-ok);
  background: rgba(91, 227, 139, 0.12);
}

/* Phosphor Screen Output & Input Prompt */
.uart-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background:
    repeating-linear-gradient(
      180deg,
      rgba(0, 0, 0, 0) 0px,
      rgba(0, 0, 0, 0) 2px,
      rgba(0, 0, 0, 0.24) 3px,
      rgba(0, 0, 0, 0.24) 4px
    ),
    radial-gradient(circle at 50% 30%, #091711 0%, #050a08 100%);
  padding: 10px 14px;
}

.uart-out {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.72rem;
  line-height: 1.5;
  color: #d7e6dc;
  padding-right: 6px;
  scrollbar-width: thin;
  scrollbar-color: #36473e #080e0b;
}

.uart-out::-webkit-scrollbar {
  width: 6px;
}

.uart-out::-webkit-scrollbar-track {
  background: #080e0b;
}

.uart-out::-webkit-scrollbar-thumb {
  background: #36473e;
  border-radius: 3px;
}

.uart-out::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

.uart-line {
  flex-shrink: 0;
  word-break: break-word;
}

.uart-echo {
  color: #ffffff;
  margin-top: 4px;
}

.uart-pre {
  flex-shrink: 0;
  margin: 2px 0;
  font-family: var(--f-mono);
  font-size: 0.67rem;
  line-height: 1.44;
  white-space: pre-wrap;
  overflow: visible;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.38);
  border-left: 2px solid var(--gold);
  border-radius: 2px;
}

.uart-dim {
  color: #8fa698;
  border-left-color: #35473e;
}

.u-ok {
  color: var(--led-ok);
}

.u-gold {
  color: var(--gold-hi);
}

.u-warn {
  color: #f4b942;
}

.u-err {
  color: #ff6b5b;
  border-left-color: #ff6b5b;
}

.u-prompt {
  color: var(--led-ok);
  font-weight: 600;
}

.u-cmd-inline {
  display: inline-block;
  padding: 0 6px;
  margin: 0 2px;
  font-family: var(--f-mono);
  font-size: 0.67rem;
  color: var(--gold-hi);
  background: rgba(230, 194, 116, 0.12);
  border: 1px solid rgba(230, 194, 116, 0.4);
  border-radius: 3px;
  cursor: pointer;
}

.u-cmd-inline:hover {
  background: var(--gold);
  color: #111;
}

.uart-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  margin-top: 6px;
  border-top: 1px dashed rgba(91, 227, 139, 0.25);
  flex-shrink: 0;
}

.uart-prompt {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--led-ok);
  white-space: nowrap;
}

.uart-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-family: var(--f-mono);
  font-size: 0.74rem;
  caret-color: var(--led-ok);
}

.uart-input::placeholder {
  color: rgba(154, 176, 163, 0.45);
}

/* ============ EASTER EGG STATES: OVERCLOCK (5.00V) & JTAG GLITCH ============ */
html.is-overclocked #hudV,
html.is-overclocked #hudNet {
  color: #ff6b5b !important;
  text-shadow: 0 0 10px rgba(255, 107, 91, 0.8);
}

html.is-overclocked .scope-wave {
  stroke: #ff6b5b;
  filter: drop-shadow(0 0 5px #ff6b5b);
  animation-duration: 0.55s !important;
}

html.is-overclocked .pcb-pulse,
html.is-overclocked .pcb-pulse-rev,
html.is-overclocked .fanout-pulse {
  stroke: #ff6b5b !important;
  animation-duration: 0.9s !important;
}

html.is-overclocked .brand-led,
html.is-overclocked .scope-dot {
  background: #ff6b5b !important;
  box-shadow: 0 0 10px #ff6b5b !important;
}

body.is-glitching {
  animation: jtagFaultShake 0.38s steps(4, end) infinite;
  filter: contrast(1.35) hue-rotate(35deg);
}

@keyframes jtagFaultShake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-4px, 2px); }
  50% { transform: translate(4px, -2px); }
  75% { transform: translate(-3px, -1px); }
  100% { transform: translate(0, 0); }
}

@media (max-width: 640px) {
  .uart-term {
    height: min(400px, 72vh);
  }
  .uart-baud,
  .uart-leds {
    display: none;
  }
  .uart-prompt {
    font-size: 0.65rem;
  }
  .uart-input {
    font-size: 16px; /* Prevents mobile Safari / iOS viewport zoom */
  }
}

/* ==========================================================================
   SECRET POV SCENE: PROJECT-CODE-ERA (CONTINUOUS ROOM, DESK TABLE & PAPER)
   ========================================================================== */
.era-scene {
  position: fixed;
  top: 0;
  bottom: 0;
  left: -44vw;
  width: 144vw;
  z-index: 350;
  pointer-events: auto;
  perspective: 1200px;
  transform: translate3d(var(--cam-x, 0vw), 0, 0);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.era-scene[hidden] {
  display: none !important;
}

.era-scene.is-active {
  opacity: 1;
}

/* Seamless Full-Room Wall + Warm Lamp Spotlight (Zero hard edges or seams!) */
.era-room-wall {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle 46vw at 16% 24%, rgba(255, 206, 118, 0.28) 0%, rgba(255, 168, 72, 0.1) 42%, transparent 78%),
    radial-gradient(circle 38vw at 66% 42%, rgba(91, 227, 139, 0.14) 0%, rgba(14, 77, 56, 0.08) 48%, transparent 76%),
    linear-gradient(180deg, #060908 0%, #0b110e 56%, #050706 100%);
  pointer-events: none;
}

/* Crisp Vector SVG Architect Swing-Arm Desk Lamp */
.era-lamp {
  position: absolute;
  top: 4vh;
  left: 2vw;
  width: clamp(210px, 20vw, 290px);
  z-index: 6;
  pointer-events: none;
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.85));
}

.era-lamp-svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}

/* Continuous 3D Workbench Desk — Spans under Both the Left Mat & Right CRT Monitor! */
.era-desk {
  position: absolute;
  left: -4vw;
  right: -4vw;
  bottom: -7vh;
  height: 62vh;
  transform-style: preserve-3d;
  z-index: 4;
}

.era-desk-surface {
  position: relative;
  width: 100%;
  height: 100%;
  background:
    radial-gradient(ellipse 36% 65% at 22% 42%, rgba(255, 208, 124, 0.25) 0%, rgba(255, 170, 76, 0.08) 48%, transparent 78%),
    radial-gradient(ellipse 28% 45% at 66% 28%, rgba(91, 227, 139, 0.14) 0%, transparent 70%),
    linear-gradient(180deg, #1a130d 0%, #2a1e15 45%, #1d150e 100%);
  border-top: 2px solid #4d3927;
  transform: rotateX(28deg);
  transform-origin: bottom center;
  box-shadow:
    0 -24px 60px rgba(0, 0, 0, 0.9),
    inset 0 2px 16px rgba(255, 214, 145, 0.12);
}

.era-desk-grain {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.014) 0px,
      rgba(255, 255, 255, 0.014) 2px,
      transparent 2px,
      transparent 11px
    ),
    repeating-linear-gradient(
      0deg,
      rgba(0, 0, 0, 0.18) 0px,
      rgba(0, 0, 0, 0.18) 1px,
      transparent 1px,
      transparent 30px
    );
  pointer-events: none;
}

/* Green Hardware ESD Cutting Mat on Left Half of the Desk */
.era-desk-mat {
  position: absolute;
  top: 9%;
  left: 6%;
  width: 35%;
  bottom: 14%;
  background:
    linear-gradient(0deg, rgba(230, 194, 116, 0.08) 1px, transparent 1px) 0 0 / 24px 24px,
    linear-gradient(90deg, rgba(230, 194, 116, 0.08) 1px, transparent 1px) 0 0 / 24px 24px,
    rgba(11, 29, 22, 0.88);
  border: 1.5px solid rgba(230, 194, 116, 0.38);
  border-radius: 6px;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.7);
  pointer-events: none;
}

.era-mat-marks {
  position: absolute;
  top: 8px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: space-between;
  font-family: var(--f-mono);
  font-size: 0.54rem;
  letter-spacing: 0.08em;
  color: rgba(230, 194, 116, 0.48);
}

.era-desk-edge {
  height: 24px;
  background: linear-gradient(180deg, #16100b 0%, #090604 100%);
  border-top: 1px solid #3a2b1d;
}

/* Steaming Ceramic Coffee Mug on Left of Mat */
.era-mug {
  position: absolute;
  top: 18%;
  left: 8.5%;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2c221b 10%, #140e0a 72%);
  border: 6px solid #d8cfc0;
  box-shadow:
    0 14px 24px rgba(0, 0, 0, 0.78),
    inset 0 4px 10px rgba(0, 0, 0, 0.9);
}

.era-mug::after {
  content: "";
  position: absolute;
  top: 50%;
  left: -17px;
  width: 13px;
  height: 20px;
  margin-top: -10px;
  border: 5px solid #c9bfb0;
  border-right: none;
  border-radius: 10px 0 0 10px;
}

.era-steam {
  position: absolute;
  top: -30px;
  left: 13px;
  display: flex;
  gap: 7px;
}

.era-steam i {
  width: 3px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 245, 225, 0.35);
  filter: blur(2px);
  animation: mugSteam 2.6s ease-in-out infinite;
}

.era-steam i:nth-child(2) {
  animation-delay: 0.8s;
  height: 28px;
}

.era-steam i:nth-child(3) {
  animation-delay: 1.5s;
}

@keyframes mugSteam {
  0% { transform: translateY(6px) scaleX(0.8); opacity: 0; }
  50% { transform: translateY(-6px) scaleX(1.3); opacity: 0.55; }
  100% { transform: translateY(-18px) scaleX(0.9); opacity: 0; }
}

/* Sticky Note on the Mat */
.era-sticky {
  position: absolute;
  top: 18%;
  left: 33.5%;
  width: 118px;
  padding: 9px 11px;
  background: linear-gradient(165deg, #f6df87 0%, #e5c65c 100%);
  color: #231c0d;
  font-family: var(--f-mono);
  font-size: 0.6rem;
  transform: rotate(6deg);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.55);
  border-top: 6px solid rgba(212, 174, 62, 0.65);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.era-sticky span {
  font-size: 0.52rem;
  opacity: 0.72;
  letter-spacing: 0.08em;
}

.era-sticky b {
  font-size: 0.66rem;
  color: #7d1d1d;
}

/* Brass Drafting Pen on the Mat */
.era-pen {
  position: absolute;
  bottom: 20%;
  left: 32%;
  width: 142px;
  height: 8px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f3d78b 0%, #b58d3d 14%, #1e2421 14%, #1e2421 86%, #d9b45b 86%, #fff1be 100%);
  transform: rotate(-28deg);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.7);
}

/* ==========================================================================
   THE PAPER ON THE TABLE (.era-paper) — LIFTS UP WHEN CLICKED!
   ========================================================================== */
.era-paper {
  position: absolute;
  top: 13%;
  left: 14.5%;
  width: min(380px, 28vw);
  min-height: 270px;
  padding: 20px 24px 16px 32px;
  background:
    linear-gradient(90deg, transparent 24px, rgba(204, 82, 72, 0.32) 24px, rgba(204, 82, 72, 0.32) 25px, transparent 25px),
    repeating-linear-gradient(
      180deg,
      transparent 0px,
      transparent 23px,
      rgba(72, 110, 138, 0.16) 23px,
      rgba(72, 110, 138, 0.16) 24px
    ),
    linear-gradient(165deg, #fbf7ec 0%, #f1e8d2 100%);
  color: #1e1b18;
  border-radius: 3px;
  box-shadow:
    0 14px 30px rgba(0, 0, 0, 0.75),
    0 2px 0 #d5c8ad;
  transform: rotate(-3deg) scale(0.92);
  cursor: pointer;
  transition:
    transform 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.42s ease,
    top 0.42s cubic-bezier(0.22, 1, 0.36, 1),
    left 0.42s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 20;
}

.era-paper:hover:not(.is-reading) {
  transform: rotate(-1.2deg) scale(0.96) translateY(-6px);
  box-shadow:
    0 22px 42px rgba(0, 0, 0, 0.82),
    0 0 24px rgba(255, 214, 132, 0.35);
}

/* Lifted Up State — Held in front of your eyes for clear reading */
.era-paper.is-reading {
  top: -16%;
  left: 12%;
  width: min(460px, 34vw);
  transform: rotateX(-26deg) rotate(0deg) scale(1.06);
  box-shadow:
    0 38px 90px rgba(0, 0, 0, 0.92),
    0 0 40px rgba(255, 212, 128, 0.28);
  cursor: default;
  z-index: 40;
}

.era-paper-clip {
  position: absolute;
  top: -8px;
  left: 42px;
  width: 16px;
  height: 34px;
  border: 2.5px solid #c59b3e;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.era-paper-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1.5px dashed rgba(30, 27, 24, 0.25);
  font-family: var(--f-mono);
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  color: #5c5143;
}

.era-paper-stamp {
  padding: 2px 6px;
  border: 1px solid #9e3b33;
  color: #9e3b33;
  font-weight: 600;
  border-radius: 2px;
}

.era-paper-body {
  font-family: var(--f-sans);
  font-size: 0.88rem;
  line-height: 1.65;
  color: #211d19;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.era-paper-body[contenteditable="true"] {
  outline: 2px dashed #9e3b33;
  outline-offset: 6px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 2px;
}

.era-paper-title {
  font-family: var(--f-stencil);
  font-size: 1.45rem;
  letter-spacing: 0.04em;
  color: #161310;
  margin: 0;
}

.era-paper-sign {
  margin-top: 6px;
  font-family: var(--f-mono);
  font-size: 0.8rem;
  font-weight: 600;
  color: #7c2d23;
  text-align: right;
}

.era-paper-foot {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid rgba(30, 27, 24, 0.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--f-mono);
}

.era-paper-hint {
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: #8c5a19;
}

.era-paper-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: flex-end;
}

.era-paper-actions[hidden] {
  display: none !important;
}

.era-act-btn {
  padding: 5px 10px;
  font-family: var(--f-mono);
  font-size: 0.64rem;
  font-weight: 600;
  color: #231e19;
  background: #e6dac0;
  border: 1px solid #968567;
  border-radius: 3px;
  cursor: pointer;
}

.era-act-btn:hover {
  background: #d8c7a3;
}

.era-act-btn.primary {
  background: #1d2622;
  color: var(--gold-hi);
  border-color: #1d2622;
}

/* Bottom HUD Bar for Returning to CRT Monitor */
.era-hud {
  position: absolute;
  left: 45.5vw;
  top: clamp(16px, 3vh, 28px);
  bottom: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  z-index: 50;
  font-family: var(--f-mono);
}

.era-pov-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  background: rgba(10, 14, 12, 0.88);
  border: 1px solid var(--ic-edge);
  border-radius: 4px;
  font-size: 0.66rem;
  color: var(--gold-hi);
  letter-spacing: 0.08em;
}

.era-pov-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--led-ok);
  box-shadow: 0 0 8px var(--led-ok);
}

.era-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--gold);
  color: #121514;
  border: 1.5px solid #121514;
  border-radius: 4px;
  font-family: var(--f-mono);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  box-shadow: 0 4px 0 #090b0a;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease;
}

.era-back-btn:hover {
  background: var(--gold-hi);
  transform: translateY(-1px);
}

.era-back-btn svg {
  width: 15px;
  height: 15px;
}

@media (max-width: 640px) {
  .lightbox {
    padding: 12px;
  }
  .lb-x {
    top: 10px;
    right: 10px;
    width: 38px;
    height: 38px;
  }
  .lb-prev {
    left: 8px;
    width: 38px;
    height: 38px;
  }
  .lb-next {
    right: 8px;
    width: 38px;
    height: 38px;
  }
  .toast {
    left: 12px;
    right: 12px;
    bottom: 12px;
    text-align: center;
  }
}

@media (max-width: 820px) {
  .era-scene {
    width: 144vw;
  }
  .era-hud {
    left: 46vw;
    top: 14px;
    gap: 8px;
  }
  .era-back-btn {
    font-size: 0.68rem;
    padding: 7px 11px;
  }
  .era-paper {
    left: 12%;
    width: min(340px, 78vw);
  }
  .era-paper.is-reading {
    position: fixed;
    inset: 0;
    margin: auto;
    width: min(390px, 92vw);
    max-height: 86vh;
    transform: none !important;
    z-index: 500;
  }
  .era-mug,
  .era-sticky {
    display: none;
  }
}
