:root {
  --bg: #050506;
  --bg-alt: #0c0d10;
  --surface: #111317;
  --ink: #f3f4f2;
  --green: #00fa9c;
  --pink: #ff50da;
  --accent: #ff50da;
  --muted: rgba(243, 244, 242, 0.55);
  --line: rgba(243, 244, 242, 0.14);
  --green-glow: 0 0 18px rgba(0, 250, 156, 0.55), 0 0 40px rgba(0, 250, 156, 0.25);
  --pink-glow: 0 0 18px rgba(255, 80, 218, 0.55), 0 0 44px rgba(255, 80, 218, 0.3);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  /* z-scale */
  --z-bg: 0;
  --z-base: 1;
  --z-overlay: 20;
  --z-drawer-backdrop: 40;
  --z-drawer: 50;
  --z-modal: 60;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  position: relative;
  min-height: 100vh;
  padding: clamp(1rem, 2.4vw, 2rem);
  display: flex;
  flex-direction: column;
  gap: clamp(1rem, 2vw, 1.6rem);
  background: var(--bg);
  color: var(--ink);
  font-family: "IBM Plex Mono", "Fira Code", Menlo, Monaco, monospace;
  overflow-x: hidden;
}

/* Brick (running-bond) brand texture */
.bg-honeycomb {
  position: fixed;
  inset: -10%;
  z-index: var(--z-bg);
  pointer-events: none;
  opacity: 0.1;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='80' viewBox='0 0 120 80'%3E%3Cg fill='none' stroke='%2300fa9c' stroke-width='1.4'%3E%3Cpath d='M0 0H120M0 40H120M0 0V40M60 40V80'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 120px 80px;
  -webkit-mask-image: radial-gradient(ellipse 70% 65% at 50% 42%, #000 25%, transparent 100%);
          mask-image: radial-gradient(ellipse 70% 65% at 50% 42%, #000 25%, transparent 100%);
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: var(--z-bg);
  pointer-events: none;
  background:
    radial-gradient(60% 50% at 18% 0%, rgba(255, 80, 218, 0.12), transparent 70%),
    radial-gradient(55% 50% at 92% 8%, rgba(0, 250, 156, 0.12), transparent 70%);
}

/* ─── Header ─────────────────────────────────────────────── */
.booth-header {
  position: relative;
  z-index: var(--z-base);
  display: flex;
  align-items: center;
  gap: clamp(0.8rem, 2vw, 1.4rem);
}
.header-logo {
  height: clamp(3rem, 5.5vw, 4.8rem);
  width: auto;
  flex-shrink: 0;
  animation: logo-neon 5.5s infinite steps(1, end);
}
@keyframes logo-neon {
  /* mostly lit, with quick irregular flickers like a real neon sign */
  0%, 100%   { opacity: 1; filter: drop-shadow(0 0 8px rgba(0, 250, 156, 0.55)) drop-shadow(0 0 18px rgba(0, 250, 156, 0.3)); }
  41%        { opacity: 1; filter: drop-shadow(0 0 8px rgba(0, 250, 156, 0.55)) drop-shadow(0 0 18px rgba(0, 250, 156, 0.3)); }
  42%        { opacity: 0.35; filter: drop-shadow(0 0 2px rgba(0, 250, 156, 0.2)); }
  43%        { opacity: 1; filter: drop-shadow(0 0 9px rgba(0, 250, 156, 0.6)) drop-shadow(0 0 20px rgba(0, 250, 156, 0.32)); }
  44%        { opacity: 0.4; filter: drop-shadow(0 0 2px rgba(0, 250, 156, 0.2)); }
  45%        { opacity: 1; filter: drop-shadow(0 0 9px rgba(0, 250, 156, 0.6)) drop-shadow(0 0 20px rgba(0, 250, 156, 0.32)); }
  72%        { opacity: 1; filter: drop-shadow(0 0 8px rgba(0, 250, 156, 0.55)) drop-shadow(0 0 18px rgba(0, 250, 156, 0.3)); }
  72.5%      { opacity: 0.45; filter: drop-shadow(0 0 2px rgba(0, 250, 156, 0.18)); }
  73%        { opacity: 1; filter: drop-shadow(0 0 10px rgba(0, 250, 156, 0.65)) drop-shadow(0 0 22px rgba(0, 250, 156, 0.34)); }
}
@media (prefers-reduced-motion: reduce) {
  .header-logo {
    animation: none;
    filter: drop-shadow(0 0 10px rgba(0, 250, 156, 0.35));
  }
}
.header-text {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  min-width: 0;
}
.header-pill {
  align-self: flex-start;
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--green);
  border: 1px solid rgba(0, 250, 156, 0.6);
  border-radius: 999px;
  padding: 0.28rem 0.8rem;
  box-shadow: inset 0 0 12px rgba(0, 250, 156, 0.12);
}
.booth-title {
  margin: 0;
  font-family: "Archivo", system-ui, sans-serif;
  font-weight: 900;
  font-style: italic;
  font-size: clamp(1.9rem, 5.2vw, 3.6rem);
  line-height: 0.92;
  letter-spacing: -0.03em;
  color: var(--pink);
  text-shadow: var(--pink-glow);
  text-wrap: balance;
}
.advanced-toggle {
  margin-left: auto;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms var(--ease), border-color 150ms var(--ease), transform 200ms var(--ease);
}
.advanced-toggle:hover {
  color: var(--green);
  border-color: rgba(0, 250, 156, 0.5);
  transform: rotate(35deg);
}

/* ─── Layout ─────────────────────────────────────────────── */
.layout {
  position: relative;
  z-index: var(--z-base);
  flex: 1;
  display: grid;
  gap: clamp(1rem, 2vw, 1.6rem);
  min-height: 0;
  grid-template-columns: 1fr 340px;
  grid-template-rows: minmax(0, 1fr);
}
.layout > * { min-height: 0; }

/* Drawing mode keeps the transcript visible on the right */
.layout:not(.webcam-layout) {
  grid-template-columns: 1fr 320px;
}

/* ─── Stage ──────────────────────────────────────────────── */
#stage {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #000;
  box-shadow:
    inset 0 0 0 1px rgba(0, 250, 156, 0.06),
    0 0 60px rgba(0, 0, 0, 0.6);
}
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: 14px;
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.55);
  z-index: var(--z-overlay);
}

#art-canvas,
#ascii-layer,
#typo-layer {
  position: absolute;
  inset: 0;
}

/* Canvas display size is controlled by JS (resizeCanvas) to avoid CSS/inline conflicts */

#ascii-layer {
  margin: 0;
  padding: 0.8rem;
  color: rgba(239, 239, 239, 0.5);
  font-size: clamp(0.45rem, 0.85vw, 0.72rem);
  line-height: 1;
  pointer-events: none;
  text-shadow: none;
  user-select: none;
}

#ascii-layer.shock {
  animation: ascii-shock 220ms steps(2, end);
}

@keyframes ascii-shock {
  0% {
    transform: translateX(-6px) skewX(4deg);
    opacity: 0.95;
  }
  100% {
    transform: translateX(0);
    opacity: 0.72;
  }
}

#typo-layer {
  pointer-events: none;
  overflow: hidden;
}

#draw-cursor {
  position: absolute;
  top: 0;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  pointer-events: none;
  z-index: 5;
  will-change: transform;
}

#draw-cursor::before,
#draw-cursor::after {
  content: '';
  position: absolute;
  background: var(--accent, #00f5d4);
}

#draw-cursor::before {
  left: 6px;
  top: 0;
  width: 2px;
  height: 14px;
}

#draw-cursor::after {
  top: 6px;
  left: 0;
  height: 2px;
  width: 14px;
}

#draw-cursor[hidden] {
  display: none;
}

.word-fragment {
  position: absolute;
  white-space: nowrap;
  letter-spacing: 0.12em;
  font-weight: 800;
  text-transform: uppercase;
  mix-blend-mode: screen;
  animation: drop-out var(--duration, 1200ms) ease-out forwards;
  filter: saturate(1.3);
}

@keyframes drop-out {
  0% {
    opacity: 0;
    transform: translateY(-8px) scale(1.35) rotate(var(--rot, 0deg));
  }
  20% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(20px) scale(0.8) rotate(calc(var(--rot, 0deg) * 0.6));
  }
}

#transcript-panel h2 {
  margin: 0 0 0.7rem;
  font-size: 1rem;
}

#transcript-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
  max-height: 100%;
  overflow: auto;
}

#transcript-list li {
  border-left: 1px solid rgba(239, 239, 239, 0.3);
  padding: 0.45rem 0.55rem;
  background: transparent;
}

#transcript-list li strong {
  color: var(--ink);
}

.hidden {
  display: none !important;
}

/* ─── Booth panel ────────────────────────────────────────── */
.booth-panel {
  position: relative;
  z-index: var(--z-base);
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  padding: clamp(1rem, 2vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: linear-gradient(180deg, var(--surface), var(--bg-alt));
  overflow: auto;
}

.booth-step {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
}
.step-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: var(--green-glow);
  animation: dot-pulse 1.8s ease-in-out infinite;
}
@keyframes dot-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.7); }
}
#status-label {
  font-weight: 700;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
}
#status-detail {
  width: 100%;
  font-size: 0.74rem;
  color: var(--muted);
  line-height: 1.5;
}

.block-label {
  display: block;
  margin-bottom: 0.55rem;
  font-size: 0.62rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.webcam-type-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 0.7rem;
}
.webcam-type-card {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  align-items: flex-start;
  text-align: left;
  padding: 0.85rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
  transition: border-color 160ms var(--ease), color 160ms var(--ease), box-shadow 220ms var(--ease), transform 160ms var(--ease);
}
.webcam-type-card strong {
  font-size: 1rem;
  letter-spacing: 0.04em;
}
.webcam-type-card small {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.02em;
}
.webcam-type-card:hover:not(.active) {
  border-color: rgba(243, 244, 242, 0.4);
  transform: translateY(-1px);
}
.webcam-type-card.active {
  border-color: var(--green);
  color: var(--green);
  box-shadow: var(--green-glow), inset 0 0 18px rgba(0, 250, 156, 0.08);
}
.webcam-type-card.active small { color: rgba(0, 250, 156, 0.8); }

/* Action buttons */
.booth-actions {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}
.btn-primary,
.btn-capture,
.btn-ghost {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border-radius: 12px;
  border: 1px solid transparent;
  transition: transform 160ms var(--ease), filter 160ms var(--ease), box-shadow 220ms var(--ease), border-color 160ms var(--ease), background 160ms var(--ease);
}
.btn-primary {
  width: 100%;
  padding: 1.05rem;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--green);
  color: #04130c;
  border-color: var(--green);
  box-shadow: var(--green-glow);
}
.btn-capture {
  width: 100%;
  padding: 1.05rem;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--pink);
  color: #fff;
  border-color: var(--pink);
  box-shadow: var(--pink-glow);
}
.btn-primary:hover:not(:disabled),
.btn-capture:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.08);
}
.btn-ghost {
  padding: 0.8rem;
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.76rem;
}
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); }
.result-secondary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}
button:disabled { opacity: 0.4; cursor: not-allowed; }

.booth-hint {
  margin: 0;
  font-size: 0.72rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ─── State-driven visibility ────────────────────────────── */
[data-show-state] { display: none; }
body[data-state="idle"] .stage-welcome { display: flex; }
body[data-state="idle"] .style-block,
body[data-state="live"] .style-block { display: block; }
body[data-state="idle"] #start-btn,
body[data-state="live"] #stop-btn,
body[data-state="live"] #cancel-btn,
body[data-state="result"] #share-btn { display: block; }
body[data-state="result"] .result-secondary { display: grid; }
body[data-state="live"] .booth-hint[data-show-state~="live"],
body[data-state="result"] .booth-hint[data-show-state~="result"] { display: block; }

/* Drawing (advanced) mode: simple controls, no booth chrome */
body[data-mode="drawing"] .stage-welcome,
body[data-mode="drawing"] .style-block,
body[data-mode="drawing"] .booth-hint { display: none !important; }
body[data-mode="drawing"] #start-btn,
body[data-mode="drawing"] #stop-btn { display: block; }
body[data-mode="drawing"] .result-secondary { display: grid; }

/* ─── Welcome overlay ────────────────────────────────────── */
.stage-welcome {
  display: none;
  position: absolute;
  inset: 0;
  z-index: calc(var(--z-overlay) + 2);
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: clamp(1.2rem, 3vw, 2.6rem);
  padding: clamp(1.5rem, 5vw, 4rem);
  pointer-events: none;
  background: radial-gradient(120% 90% at 30% 25%, rgba(0, 250, 156, 0.06), transparent 60%);
}
.welcome-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
}
.welcome-eyebrow {
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--green);
}
.welcome-title {
  margin: 0;
  font-family: "Archivo", system-ui, sans-serif;
  font-weight: 900;
  font-style: italic;
  font-size: clamp(2.2rem, 7vw, 4.6rem);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: var(--ink);
  text-shadow: 0 0 34px rgba(0, 250, 156, 0.22);
  text-wrap: balance;
}
.welcome-sub {
  margin: 0;
  max-width: 44ch;
  color: var(--muted);
  line-height: 1.6;
  font-size: clamp(0.85rem, 1.4vw, 1rem);
}
.welcome-steps {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
}
.welcome-steps li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.76rem;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.42rem 0.9rem;
  background: rgba(5, 5, 6, 0.5);
}
.welcome-steps li span {
  display: grid;
  place-items: center;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  background: var(--pink);
  color: #fff;
  font-weight: 700;
  font-size: 0.7rem;
}

/* ─── Photo teaser (neon camera icon) ──────────────────── */
.photo-teaser {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  animation: photo-bounce 2.4s ease-in-out infinite;
  flex-shrink: 0;
}
.photo-icon {
  width: clamp(100px, 12vw, 160px);
  height: auto;
  /* Keep original SVG yellow, add neon glow */
  filter:
    brightness(1.15)
    drop-shadow(0 0 14px rgba(252, 245, 65, 0.6))
    drop-shadow(0 0 36px rgba(252, 245, 65, 0.3));
  animation: photo-glow 2s ease-in-out infinite, photo-flicker 4s infinite;
}
.photo-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid #fcf541;
  transform: translate(-50%, -50%) scale(0.8);
  animation: photo-ring-pulse 2.4s ease-out infinite;
  pointer-events: none;
}

@keyframes photo-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}
@keyframes photo-glow {
  0%, 100% {
    filter:
      brightness(1.15)
      drop-shadow(0 0 14px rgba(252, 245, 65, 0.6))
      drop-shadow(0 0 36px rgba(252, 245, 65, 0.3));
  }
  50% {
    filter:
      brightness(1.35)
      drop-shadow(0 0 24px rgba(252, 245, 65, 0.9))
      drop-shadow(0 0 60px rgba(252, 245, 65, 0.5));
  }
}
@keyframes photo-flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: 0.25; }
}
@keyframes photo-ring-pulse {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0.7;
    box-shadow: 0 0 0 0 rgba(252, 245, 65, 0.55), 0 0 20px rgba(252, 245, 65, 0.3);
  }
  70% {
    opacity: 0;
    box-shadow: 0 0 0 28px rgba(252, 245, 65, 0), 0 0 40px rgba(252, 245, 65, 0);
  }
  100% {
    transform: translate(-50%, -50%) scale(1.4);
    opacity: 0;
    box-shadow: 0 0 0 0 rgba(252, 245, 65, 0), 0 0 0 rgba(252, 245, 65, 0);
  }
}

/* ─── Countdown (big, centered) + flash ──────────────────── */
#countdown-overlay {
  position: absolute;
  inset: 0;
  z-index: calc(var(--z-overlay) + 3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Archivo Black", sans-serif;
  font-size: clamp(6rem, 26vh, 15rem);
  line-height: 1;
  color: var(--green);
  text-shadow: var(--green-glow), 0 0 70px rgba(0, 250, 156, 0.55);
  pointer-events: none;
  user-select: none;
}
#countdown-overlay::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at center, rgba(0, 0, 0, 0.45), transparent 62%);
}
#countdown-overlay span { position: relative; animation: count-pop 1s var(--ease); }
@keyframes count-pop {
  0% { transform: scale(0.4); opacity: 0; }
  20% { transform: scale(1.15); opacity: 1; }
  40% { transform: scale(1); }
  100% { transform: scale(1); opacity: 0.85; }
}
#countdown-overlay.hidden { display: none; }

#flash-overlay {
  position: absolute;
  inset: 0;
  z-index: calc(var(--z-overlay) + 4);
  background: #fff;
  opacity: 0;
  pointer-events: none;
}
#flash-overlay.flash { animation: flash 380ms var(--ease); }
@keyframes flash {
  0% { opacity: 0; }
  12% { opacity: 0.92; }
  100% { opacity: 0; }
}

/* ─── Form controls (drawer) ─────────────────────────────── */
.controls-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.controls-row label {
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  min-width: 5.5rem;
}
.advanced-drawer select,
.advanced-drawer .controls-row.buttons button {
  flex: 1;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  cursor: pointer;
}
.advanced-drawer select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.2rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23f3f4f2' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
}
.advanced-drawer .controls-row.buttons button:hover:not(:disabled) {
  border-color: var(--ink);
}
.ascii-slider {
  flex: 1;
  appearance: none;
  -webkit-appearance: none;
  height: 2px;
  border: none;
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(243, 244, 242, 0.2), var(--green));
}
.ascii-slider::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  box-shadow: var(--green-glow);
  cursor: pointer;
}
.ascii-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--green);
  border: none;
  cursor: pointer;
}
.slider-value {
  min-width: 2.4rem;
  text-align: right;
  color: var(--green);
  font-size: 0.8rem;
}
.meter-wrap {
  display: grid;
  gap: 0.4rem;
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  color: var(--muted);
}
#energy-meter {
  width: 100%;
  height: 14px;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
}
#energy-fill {
  width: 0%;
  height: 100%;
  background: var(--green);
  box-shadow: 0 0 12px rgba(0, 250, 156, 0.6);
  transition: width 100ms linear;
}

/* ─── Advanced drawer ────────────────────────────────────── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer-backdrop);
  background: rgba(0, 0, 0, 0.62);
  -webkit-backdrop-filter: blur(2px);
          backdrop-filter: blur(2px);
}
.drawer-backdrop.hidden { display: none; }
.advanced-drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(380px, 92vw);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.4rem;
  overflow: auto;
  background: var(--bg-alt);
  border-left: 1px solid var(--line);
  box-shadow: -24px 0 70px rgba(0, 0, 0, 0.6);
  transform: translateX(100%);
  transition: transform 320ms var(--ease);
}
.advanced-drawer.open { transform: translateX(0); }
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-head h3 {
  margin: 0;
  font-size: 0.76rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--green);
}
.drawer-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.2rem;
}
.drawer-close:hover { color: var(--ink); }
.drawer-debug {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 1rem;
}
.drawer-debug h4 {
  margin: 0 0 0.6rem;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.drawer-debug ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.4rem;
}
.drawer-debug li {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.74rem;
  color: var(--muted);
}
.drawer-debug kbd {
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-family: inherit;
  font-size: 0.72rem;
  min-width: 22px;
  text-align: center;
  color: var(--ink);
}

/* ─── Transcript panel (drawing mode floating) ───────────── */
#transcript-panel {
  position: fixed;
  top: clamp(5.5rem, 12vh, 7rem);
  right: clamp(1rem, 2.4vw, 2rem);
  width: min(300px, 80vw);
  max-height: 60vh;
  z-index: var(--z-overlay);
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(12, 13, 16, 0.92);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
  overflow: auto;
}
#transcript-panel h2 {
  margin: 0 0 0.7rem;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--green);
}
#transcript-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.55rem;
}
#transcript-list li {
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 5, 6, 0.5);
  font-size: 0.78rem;
}
#transcript-list li strong { color: var(--green); }

/* ─── Modal / QR ─────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  -webkit-backdrop-filter: blur(6px);
          backdrop-filter: blur(6px);
}
.modal.hidden { display: none; }
.modal-content {
  position: relative;
  max-width: 520px;
  width: 90%;
  padding: 2.2rem 2rem;
  text-align: center;
  background: var(--bg-alt);
  border: 1px solid rgba(0, 250, 156, 0.4);
  border-radius: 16px;
  box-shadow: var(--green-glow);
}
.modal-content h3 {
  margin: 0 0 1.2rem;
  font-family: "Archivo", system-ui, sans-serif;
  font-weight: 900;
  font-style: italic;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--green);
}
.modal-content p {
  margin: 1.2rem 0 0;
  font-size: 0.8rem;
  line-height: 1.5;
  color: var(--muted);
}
.modal-grid {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 1.2rem;
  margin-top: 0.8rem;
}
.modal-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 0.6rem;
}
.modal-col p {
  margin: 0;
  text-align: center;
}
.tag-text {
  font-size: 0.75rem;
  color: var(--muted);
}
.tag-handle {
  color: var(--pink);
  font-weight: 700;
}
.modal-close {
  position: absolute;
  top: 0.7rem;
  right: 0.9rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.7rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.modal-close:hover { color: var(--pink); }
.story-preview {
  display: block;
  width: 100%;
  max-width: 240px;
  margin: 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 250, 156, 0.5);
  box-shadow: var(--green-glow);
}
.story-preview:not([src]),
.story-preview[src=""] { display: none; }
#qr-container {
  display: inline-block;
  padding: 0.8rem;
  background: #fff;
  border-radius: 10px;
  min-height: 1px;
}
#qr-container:empty {
  width: 150px;
  height: 150px;
  background: var(--surface);
  border: 1px dashed var(--line);
}
#qr-container img {
  display: block;
  margin: 0 auto;
  image-rendering: pixelated;
}

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 1000px) {
  body { padding: 1rem; }
  .layout,
  .layout.webcam-layout,
  .layout:not(.webcam-layout) {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(48vh, 1fr) auto;
  }
  .booth-actions { margin-top: 0; }
  #transcript-panel {
    position: static;
    width: auto;
    max-height: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .advanced-toggle:hover { transform: none; }
}
