/* =========================================================================
 * Theremin / XY pad. One big rectangular surface, scale-line grid in the
 * background, fingers leave glowing crosshair touch markers. The first
 * finger drives pitch (X) + volume (Y); a second finger overlays vibrato
 * (X = rate, Y = depth).
 * ========================================================================= */

/* ── play/theremin — scoped palette ──────────────────────────────────
 * Indigo + pink stage lights (inherited from --play-*); the rest is
 * theremin-specific:
 *   - deep navy backdrop for the pad / modal glass
 *   - pink crisp-dot tone for the vibrato touch
 *   - mic-status pill palette (lime live / red blocked)
 *   - rec-pulse rose so it reads as "we are RECORDING right now"
 */
:root {
  --theremin-bg-deep: #0b1224;
  --theremin-modal-scrim: #020617;
  --theremin-touch-dot-pink: #fcd3e6;
  --theremin-mic-blocked: #f43f5e;
  --theremin-mic-blocked-bg: #7f1d1d;
  --theremin-mic-live: #84cc16;
  --theremin-mic-live-text: #bef264;
  --theremin-mic-live-bg: #14532d;
  --theremin-mic-off-text: #fca5a5;
  --theremin-rec-strong: #dc2663;
}

.theremin-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px 24px;
  width: 100%;
}

.theremin-pad {
  position: relative;
  width: min(100%, 1080px);
  height: clamp(320px, 60vh, 580px);
  border-radius: 18px;
  background: radial-gradient(
      120% 80% at 50% 100%,
      color-mix(in srgb, var(--play-pink, #f472b6) 18%, transparent),
      transparent 60%
    ),
    radial-gradient(
      120% 80% at 50% 0%,
      color-mix(in srgb, var(--play-indigo, #818cf8) 18%, transparent),
      transparent 60%
    ),
    linear-gradient(180deg, var(--surface-1), var(--theremin-bg-deep, #0b1224));
  border: 1px solid var(--border);
  box-shadow: 0 24px 40px -20px color-mix(in srgb, var(--pure-black) 60%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--pure-white) 4%, transparent),
    inset 0 0 0 1px color-mix(in srgb, var(--play-indigo, #818cf8) 8%, transparent);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  cursor: crosshair;
}

/* SVG-style grid drawn in CSS: vertical lines = pitch divisions, horizontal
 * lines = volume contours. The vertical lines are positioned by JS via CSS
 * variables for the active scale; horizontal lines are fixed thirds. */
.theremin-grid {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.theremin-grid-line {
  position: absolute;
  background: color-mix(in srgb, var(--play-slate-300, #94a3b8) 8%, transparent);
  pointer-events: none;
}

.theremin-grid-line.vertical {
  top: 0;
  bottom: 0;
  width: 1px;
}

.theremin-grid-line.vertical.is-c {
  background: color-mix(in srgb, var(--play-indigo, #818cf8) 32%, transparent);
  width: 1.5px;
}

.theremin-grid-line.vertical.is-root {
  background: color-mix(in srgb, var(--play-pink, #f472b6) 40%, transparent);
  width: 1.5px;
}

.theremin-grid-line.horizontal {
  left: 0;
  right: 0;
  height: 1px;
}

/* Note labels along the bottom edge for each octave's C (or root). */
.theremin-grid-label {
  position: absolute;
  bottom: 6px;
  transform: translateX(-50%);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: color-mix(in srgb, var(--play-slate-100, #e2e8f0) 45%, transparent);
  pointer-events: none;
  text-shadow: 0 1px 2px color-mix(in srgb, var(--pure-black) 60%, transparent);
}

.theremin-grid-label.is-root {
  color: color-mix(in srgb, var(--play-pink, #f472b6) 85%, transparent);
}

.theremin-grid-label.is-edge-left {
  transform: translateX(4px);
}

.theremin-grid-label.is-edge-right {
  transform: translateX(-100%) translateX(-4px);
}

/* Volume gradient overlay — subtle vertical fade so it reads "louder up". */
.theremin-pad::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--play-indigo, #818cf8) 12%, transparent),
    transparent 50%,
    color-mix(in srgb, var(--pure-black) 18%, transparent)
  );
  pointer-events: none;
}

.theremin-axis-label {
  position: absolute;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: color-mix(in srgb, var(--play-slate-300, #94a3b8) 55%, transparent);
  pointer-events: none;
  text-transform: uppercase;
}

.theremin-axis-x {
  bottom: 6px;
  right: 12px;
}

.theremin-axis-y {
  top: 12px;
  left: 12px;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}

.theremin-hint {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: color-mix(in srgb, var(--play-slate-100, #e2e8f0) 35%, transparent);
  font-size: 14px;
  letter-spacing: 0.04em;
  text-align: center;
  pointer-events: none;
  transition: opacity 240ms ease;
}

.theremin-pad.is-active .theremin-hint {
  opacity: 0;
}

/* Touch markers — one per active pointer. Position is set live via
 * --tx / --ty (in px). Two flavours: primary (pitch+volume) and
 * vibrato (secondary fingers).
 *
 * z-index bumped so they stay above the paint trail canvas (z=1) and
 * the hand-skeleton overlay (z=2) — the cursor feedback is the most
 * important "where am I touching" signal. */
.theremin-touch {
  position: absolute;
  left: var(--tx, 0);
  top: var(--ty, 0);
  width: 96px;
  height: 96px;
  margin-left: -48px;
  margin-top: -48px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 3;
  background: radial-gradient(
    circle at 50% 50%,
    color-mix(in srgb, var(--play-indigo, #818cf8) 55%, transparent),
    color-mix(in srgb, var(--play-indigo, #818cf8) 8%, transparent) 50%,
    transparent 70%
  );
  filter: blur(0.5px);
  will-change: left, top;
}

.theremin-touch::after {
  /* Inner crisp dot. */
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--play-slate-100, #e2e8f0) 95%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--play-indigo, #818cf8) 50%, transparent),
    0 0 18px color-mix(in srgb, var(--play-indigo, #818cf8) 60%, transparent);
}

.theremin-touch.vibrato {
  background: radial-gradient(
    circle at 50% 50%,
    color-mix(in srgb, var(--play-pink, #f472b6) 55%, transparent),
    color-mix(in srgb, var(--play-pink, #f472b6) 8%, transparent) 50%,
    transparent 70%
  );
}

.theremin-touch.vibrato::after {
  background: color-mix(in srgb, var(--theremin-touch-dot-pink, #fcd3e6) 95%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--play-pink, #f472b6) 55%, transparent),
    0 0 18px color-mix(in srgb, var(--play-pink, #f472b6) 60%, transparent);
}

/* Crosshair lines through the primary touch — a long horizontal pitch
 * axis and a long vertical volume axis so the player can read off the
 * note from the labels at the bottom. Stacks alongside touch markers. */
.theremin-crosshair {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.theremin-crosshair-line {
  position: absolute;
  background: color-mix(in srgb, var(--play-indigo, #818cf8) 35%, transparent);
  pointer-events: none;
}

.theremin-crosshair-line.vertical {
  top: 0;
  bottom: 0;
  width: 1.5px;
  left: var(--cx, -10px);
  margin-left: -0.75px;
  box-shadow: 0 0 12px color-mix(in srgb, var(--play-indigo, #818cf8) 50%, transparent);
}

.theremin-crosshair-line.horizontal {
  left: 0;
  right: 0;
  height: 1.5px;
  top: var(--cy, -10px);
  margin-top: -0.75px;
  box-shadow: 0 0 12px color-mix(in srgb, var(--play-indigo, #818cf8) 50%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .theremin-touch {
    filter: none;
  }
}

/* ---------- Air mode ---------- *
 * The same pad doubles as a camera-feed display with hand-landmark
 * overlay. Switching modes flips a class on the pad: in touch mode the
 * video and canvas are display:none, in air mode they fill the pad and
 * the touch markers + crosshair are hidden. The grid overlay stays
 * visible in both so the player can read off the note from the labels.
 */

.theremin-video,
.theremin-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: none;
  pointer-events: none;
}

.theremin-video {
  object-fit: cover;
  /* Mirror so left-handed motion in the real world goes left in the
   * frame — the natural "mirror" feel for selfie cameras. */
  transform: scaleX(-1);
  opacity: 0.45;
  background: var(--pure-black);
}

.theremin-overlay {
  /* The canvas already paints its own background-transparent landmark
   * skeleton; we just need it on top of the video. */
  z-index: 2;
}

.theremin-pad.is-air-mode {
  cursor: default;
}

.theremin-pad.is-air-mode .theremin-video,
.theremin-pad.is-air-mode .theremin-overlay {
  display: block;
}

.theremin-pad.is-air-mode .theremin-touch,
.theremin-pad.is-air-mode .theremin-crosshair {
  display: none;
}

.theremin-pad.is-air-mode .theremin-hint {
  display: none;
}

/* Permission / status card centred over the pad while air mode is
 * loading, awaiting permission, or recovering from an error. */
.theremin-air-card {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 32px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--play-slate-900, #0f172a) 92%, transparent);
  border: 1px solid var(--border);
  box-shadow: 0 24px 60px -20px color-mix(in srgb, var(--pure-black) 70%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--pure-white) 6%, transparent);
  max-width: min(90%, 380px);
  text-align: center;
  backdrop-filter: blur(8px);
}

.theremin-air-card[hidden] {
  display: none;
}

.theremin-air-card-icon {
  font-size: 36px;
  line-height: 1;
  filter: drop-shadow(0 4px 14px color-mix(in srgb, var(--play-indigo, #818cf8) 50%, transparent));
}

.theremin-air-card-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.theremin-air-card-message {
  margin: 0;
  color: var(--fg-dim);
  font-size: 13px;
  line-height: 1.5;
}

.theremin-air-card-button {
  margin-top: 4px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--pure-white) 12%, transparent);
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--play-indigo, #818cf8) 95%, transparent),
    color-mix(in srgb, var(--play-pink, #f472b6) 95%, transparent)
  );
  color: var(--pure-white);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--play-indigo, #818cf8) 35%, transparent);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.theremin-air-card-button:hover,
.theremin-air-card-button:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--play-pink, #f472b6) 45%, transparent);
  outline: none;
  filter: brightness(1.05);
}

.theremin-air-card-button[disabled] {
  cursor: progress;
  filter: grayscale(0.4);
  transform: none;
  box-shadow: none;
}

.theremin-air-card-button[hidden] {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  .theremin-air-card-button {
    transition: none;
  }
}

@media (max-width: 640px) {
  .theremin-pad {
    height: clamp(300px, 64vh, 520px);
  }
  .theremin-hint {
    font-size: 12px;
    padding: 0 24px;
  }
  .theremin-axis-label {
    font-size: 9px;
  }
  .theremin-air-card {
    padding: 22px 24px;
    gap: 10px;
  }
  .theremin-air-card-message {
    font-size: 12px;
  }
}

/* ---------- Paint trail ---------- *
 * Fingertip-driven rainbow trail canvas. Sits between the webcam
 * video (z-index 0) and the hand-skeleton overlay (z-index 2) so
 * the skeleton + touch markers (z-index 3) stay readable on top.
 * pointer-events: none so it never steals input from the pad below.
 */

.theremin-paint {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* ---- Paint toggle styled like the existing controls ---- *
 * The other controls use <select>/<input range>; this one's a
 * checkbox that we re-skin into a small pill toggle so it doesn't
 * jar against the rest of the row.
 */

.control-paint .paint-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--pure-white) 12%, transparent);
  background: color-mix(in srgb, var(--play-slate-900, #0f172a) 60%, transparent);
  color: var(--fg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 160ms ease, border-color 160ms ease;
}

.control-paint .paint-toggle:hover {
  background: color-mix(in srgb, var(--play-slate-800, #1e293b) 80%, transparent);
  border-color: color-mix(in srgb, var(--play-pink, #f472b6) 45%, transparent);
}

.control-paint .paint-toggle input {
  /* Hide the native checkbox in favour of the swatch+label below. */
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.control-paint .paint-swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: conic-gradient(
    hsl(0, 92%, 65%),
    hsl(60, 92%, 65%),
    hsl(120, 92%, 65%),
    hsl(180, 92%, 65%),
    hsl(240, 92%, 65%),
    hsl(300, 92%, 65%),
    hsl(360, 92%, 65%)
  );
  box-shadow: 0 0 6px color-mix(in srgb, var(--play-pink, #f472b6) 0%, transparent);
  transition: box-shadow 160ms ease;
  flex-shrink: 0;
}

.control-paint .paint-toggle input:checked ~ .paint-swatch {
  box-shadow: 0 0 10px color-mix(in srgb, var(--play-pink, #f472b6) 70%, transparent);
}

.control-paint .paint-toggle input:checked ~ .paint-label::after {
  content: ' on';
  color: color-mix(in srgb, var(--play-pink, #f472b6) 95%, transparent);
}

.control-paint .paint-toggle:focus-within {
  outline: 2px solid color-mix(in srgb, var(--play-indigo, #818cf8) 60%, transparent);
  outline-offset: 2px;
}

/* ---------- Record control + preview modal ---------- *
 * Record buttons live alongside the rest of the controls; the preview
 * modal is a centred fixed overlay that appears once a recording
 * finishes (auto-stop or user-stop).
 */

/* Mic toggle — small pill above the Rec buttons. Two visually
 * distinct states so it's obvious at a glance whether voice will be
 * captured in the next recording:
 *
 *   UNMUTED: green-tinted pill, bright mic emoji, text "Unmuted"
 *   MUTED:   red-tinted pill, mic emoji with a red slash through it,
 *            text "Muted"
 *
 * Native checkbox is hidden; the emoji + state-text + pill background
 * are the affordance. Modifiers:
 *
 *   .is-blocked: appears after a denied mic permission. Adds a
 *                "(blocked)" hint to the muted text so the user can
 *                tell "I unticked it" from "the browser blocked me".
 *   .is-locked:  set during an active recording so the toggle can't
 *                be flipped mid-clip (where it would have no effect
 *                anyway).
 */

.control-record .record-mic-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--theremin-mic-blocked, #f43f5e) 45%, transparent);
  background: color-mix(in srgb, var(--theremin-mic-blocked-bg, #7f1d1d) 28%, transparent);
  color: var(--fg);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease,
    box-shadow 160ms ease;
}

.control-record .record-mic-toggle:hover {
  filter: brightness(1.1);
}

/* Live (checked) state — mic will be recorded. */
.control-record .record-mic-toggle:has(input:checked) {
  background: color-mix(in srgb, var(--theremin-mic-live-bg, #14532d) 32%, transparent);
  border-color: color-mix(in srgb, var(--theremin-mic-live, #84cc16) 55%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--theremin-mic-live, #84cc16) 18%, transparent);
}

.control-record .record-mic-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Mic emoji + slash overlay. The ::after element draws a thin red
 * line corner-to-corner over the icon when the toggle is off — the
 * universal "no audio" symbol. We anchor it to the icon span (which
 * is positioned relative) and rotate -30deg to roughly match how
 * native iOS / Android mic-mute icons strike through the body. */
.control-record .record-mic-icon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  font-size: 14px;
  line-height: 1;
  filter: grayscale(0.7) brightness(0.9);
  transition: filter 160ms ease;
}

.control-record .record-mic-toggle:has(input:checked) .record-mic-icon {
  filter: none;
}

.control-record .record-mic-icon::after {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  top: 50%;
  height: 2px;
  margin-top: -1px;
  background: color-mix(in srgb, var(--theremin-mic-blocked, #f43f5e) 95%, transparent);
  border-radius: 1px;
  transform: rotate(-30deg);
  box-shadow: 0 0 4px color-mix(in srgb, var(--theremin-mic-blocked, #f43f5e) 55%, transparent);
  pointer-events: none;
  transition: opacity 160ms ease;
}

.control-record .record-mic-toggle:has(input:checked) .record-mic-icon::after {
  opacity: 0;
}

/* Two text spans — only the one matching the current state is
 * visible. Cleaner than swapping ::after content because the visible
 * text stays in the DOM (better screen-reader experience: SR reads
 * either "Unmuted, checkbox, checked" or "Muted, checkbox, not
 * checked" depending on state). */
.control-record .record-mic-text {
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: 11px;
}

.control-record .record-mic-text-on {
  display: none;
  color: color-mix(in srgb, var(--theremin-mic-live-text, #bef264) 98%, transparent);
}

.control-record .record-mic-text-off {
  display: inline;
  color: color-mix(in srgb, var(--theremin-mic-off-text, #fca5a5) 98%, transparent);
}

.control-record .record-mic-toggle:has(input:checked) .record-mic-text-on {
  display: inline;
}

.control-record .record-mic-toggle:has(input:checked) .record-mic-text-off {
  display: none;
}

.control-record .record-mic-toggle:focus-within {
  outline: 2px solid color-mix(in srgb, var(--play-indigo, #818cf8) 60%, transparent);
  outline-offset: 2px;
}

/* Permission-denied: keep the muted styling but call out that it's
 * not just "user turned it off" — the browser is blocking. */
.control-record .record-mic-toggle.is-blocked .record-mic-text-off::after {
  content: ' (blocked)';
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  margin-left: 4px;
  color: color-mix(in srgb, var(--theremin-mic-blocked, #f43f5e) 90%, transparent);
}

.control-record .record-mic-toggle.is-locked {
  pointer-events: none;
  opacity: 0.55;
}

.control-record .record-buttons {
  display: flex;
  gap: 6px;
}

.record-btn {
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--pure-white) 12%, transparent);
  background: color-mix(in srgb, var(--play-slate-900, #0f172a) 60%, transparent);
  color: var(--fg);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 120ms ease;
  font-family: inherit;
}

.record-btn:hover,
.record-btn:focus-visible {
  background: color-mix(in srgb, var(--play-slate-800, #1e293b) 80%, transparent);
  border-color: color-mix(in srgb, var(--play-pink, #f472b6) 45%, transparent);
  outline: none;
}

.record-btn:active {
  transform: translateY(1px);
}

.record-btn.is-recording {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--play-pink, #f472b6) 95%, transparent),
    color-mix(in srgb, var(--theremin-rec-strong, #dc2663) 95%, transparent)
  );
  border-color: transparent;
  color: var(--pure-white);
  box-shadow: 0 0 12px color-mix(in srgb, var(--play-pink, #f472b6) 50%, transparent);
  /* Pulsing glow signals "we are actively recording right now". */
  animation: theremin-record-pulse 1.2s ease-in-out infinite;
}

.record-btn.is-disabled,
.record-btn[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

@keyframes theremin-record-pulse {
  0%,
  100% {
    box-shadow: 0 0 10px color-mix(in srgb, var(--play-pink, #f472b6) 40%, transparent);
  }
  50% {
    box-shadow: 0 0 22px color-mix(in srgb, var(--play-pink, #f472b6) 85%, transparent);
  }
}

@media (prefers-reduced-motion: reduce) {
  .record-btn.is-recording {
    animation: none;
  }
}

/* ---- Preview modal ---- */

.theremin-record-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.theremin-record-modal[hidden] {
  display: none;
}

.theremin-record-modal-backdrop {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--theremin-modal-scrim, #020617) 70%, transparent);
  backdrop-filter: blur(4px);
  cursor: pointer;
}

.theremin-record-modal-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  padding: 22px 24px 24px;
  border-radius: 18px;
  background: linear-gradient(180deg, var(--surface-1), var(--theremin-bg-deep, #0b1224));
  border: 1px solid var(--border);
  box-shadow: 0 32px 70px -20px color-mix(in srgb, var(--pure-black) 70%, transparent),
    inset 0 1px 0 color-mix(in srgb, var(--pure-white) 6%, transparent);
  width: min(460px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.theremin-record-modal-title {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
  color: var(--fg);
}

.theremin-record-modal-message {
  margin: 0;
  color: var(--fg-dim);
  font-size: 13px;
  line-height: 1.5;
}

.theremin-record-modal-video {
  width: 100%;
  border-radius: 12px;
  background: var(--pure-black);
  /* Square aspect — matches the recording canvas. */
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.theremin-record-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.theremin-record-btn {
  flex: 1 1 100px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--pure-white) 12%, transparent);
  background: color-mix(in srgb, var(--play-slate-900, #0f172a) 60%, transparent);
  color: var(--fg);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  font-family: inherit;
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease, background 160ms ease;
}

.theremin-record-btn:hover,
.theremin-record-btn:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--play-slate-800, #1e293b) 85%, transparent);
  transform: translateY(-1px);
}

.theremin-record-btn.primary {
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--play-indigo, #818cf8) 95%, transparent),
    color-mix(in srgb, var(--play-pink, #f472b6) 95%, transparent)
  );
  border-color: transparent;
  color: var(--pure-white);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--play-indigo, #818cf8) 35%, transparent);
}

.theremin-record-btn.primary:hover,
.theremin-record-btn.primary:focus-visible {
  filter: brightness(1.05);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--play-pink, #f472b6) 45%, transparent);
}

.theremin-record-btn.ghost {
  background: transparent;
  border-color: color-mix(in srgb, var(--play-slate-300, #94a3b8) 25%, transparent);
  color: var(--fg-dim);
}

.theremin-record-btn[hidden] {
  display: none;
}

/* Inline status line below the action buttons. Used to surface
 * "share unavailable here, downloading instead" / "share failed" so
 * users actually understand why a click on Share might end up doing
 * the same thing as a click on Download. */
.theremin-record-modal-status {
  margin: 0;
  font-size: 12px;
  line-height: 1.4;
  color: var(--fg-dim);
  text-align: center;
  min-height: 1.4em;
}

.theremin-record-modal-status[hidden] {
  display: none;
}

.theremin-record-modal-status.is-error {
  color: color-mix(in srgb, var(--play-pink, #f472b6) 95%, transparent);
}

@media (max-width: 640px) {
  .theremin-record-modal-card {
    padding: 18px 18px 20px;
  }
  .theremin-record-modal-actions {
    flex-direction: column;
  }
  .theremin-record-btn {
    flex: 1 1 auto;
  }
}
