:root {
  /* Typography */
  --font-family-base: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --font-family-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  --font-size-label: 0.9rem;
  --font-size-status: 1rem;

  /* Color tokens */
  --color-bg-app: #f5f5f5;
  --color-text-primary: #1f1f1f;
  --color-text-muted: #444444;
  --color-accent-primary: #ff3355;
  --color-accent-photo: #ffffff;
  --color-danger: #bb0000;
  --color-surface-panel: #ffffff;
  /* Note: overlay colors moved to dark theme selector (body.capture-body, .viewer-body) */
  --color-progress-active: rgba(255, 255, 255, 0.95);
  --color-progress-inactive: rgba(255, 255, 255, 0.45);
  --color-banner-success: rgba(21, 157, 96, 0.92);
  --color-banner-text: #ffffff;

  /* Spacing & sizing */
  --space-xs: 0.5rem;
  --space-sm: 0.75rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2rem;
  --corner-soft: 12px;
  --corner-pill: 999px;
  --tap-target: 64px;
  --tap-target-large: 96px;

  /* Animation durations */
  --anim-duration-fast: 120ms;
  --anim-duration-mid: 180ms;
  --anim-duration-slow: 300ms;

  /* Timings */
  --photo-segment-duration: 2000ms;

  font-family: var(--font-family-base);
  background-color: var(--color-bg-app);
  color: var(--color-text-primary);
}

body {
  margin: 0;
  padding: var(--space-xl);
  font-family: var(--font-family-base);
  background: var(--color-bg-app);
  color: var(--color-text-primary);
  min-height: 100vh;
  touch-action: manipulation;
}

body.capture-body {
  --color-bg-app: #000000;
  padding: 0;
  color: #ffffff;
}

/* Shared dark theme tokens for capture and viewer experiences */
body.capture-body,
.viewer-body {
  /* Background and text */
  --color-bg-app: #000000;
  --color-text-primary: #ffffff;

  /* Overlay darkness scale - semantic levels for different UI contexts */
  --overlay-subtle: rgba(0, 0, 0, 0.40);   /* status panels, toggles */
  --overlay-medium: rgba(0, 0, 0, 0.55);   /* buttons, timer */
  --overlay-heavy: rgba(0, 0, 0, 0.70);    /* scrims, replay overlay, hover states */
  --overlay-modal: rgba(0, 0, 0, 0.80);    /* modal backdrops, blocking overlays */

  /* Borders and outlines */
  --color-border-subtle: rgba(255, 255, 255, 0.22);
  --color-focus-ring: rgba(255, 255, 255, 0.85);
}

/* ==========================================================================
   SHARED PRIMITIVES
   Reusable patterns for capture and viewer experiences
   ========================================================================== */

/* Media Stage - Full-viewport container for video/image display
   Note: position is NOT included - capture uses relative, viewer uses absolute */
.media-stage {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  overflow: hidden;
  background: #000;
}

/* Media Stage Container - Aspect ratio framing for media elements */
.media-stage__container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Portrait framing: 9:16 aspect ratio */
.media-stage__container--portrait {
  inset: unset;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: 100%;
  aspect-ratio: 9 / 16;
}

/* Landscape framing: 16:9 with min() constraints for robust scaling */
.media-stage__container--landscape {
  inset: unset;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  width: min(100%, calc(100vh * 16 / 9));
  height: min(100%, calc(100vw * 9 / 16));
  aspect-ratio: 16 / 9;
}

/* Media Stage Element - Base styles for video/image elements */
.media-stage__element {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.media-stage__element--cover {
  object-fit: cover;
  object-position: center;
}

.media-stage__element--mirror {
  transform: scaleX(-1);
}

/* Icon Button - Circular interactive button for media controls
   Base class provides common layout, focus, active, and disabled states */
.icon-button {
  appearance: none;
  border: none;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform var(--anim-duration-fast) ease,
              background var(--anim-duration-fast) ease;
  -webkit-tap-highlight-color: transparent;
}

.icon-button:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.icon-button:active {
  transform: scale(0.95);
}

.icon-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Icon Button Sizes */
.icon-button--md {
  width: 56px;
  height: 56px;
}

.icon-button--lg {
  width: var(--tap-target);  /* 64px */
  height: var(--tap-target);
}

.icon-button--xl {
  width: var(--tap-target-large);  /* 96px */
  height: var(--tap-target-large);
}

/* Icon Button Appearances */
.icon-button--glass {
  background: var(--overlay-medium);
  border: 1px solid var(--color-border-subtle);
  color: var(--color-text-primary);
}

.icon-button--glass:hover {
  background: var(--overlay-heavy);
}

.icon-button--frosted {
  background: var(--overlay-subtle);
  border: 2px solid rgba(255, 255, 255, 0.25);
  color: var(--color-text-primary);
  backdrop-filter: blur(12px);
}

.icon-button--frosted:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   END SHARED PRIMITIVES
   ========================================================================== */

.capture-app {
  /* Capture-specific variable (overlay gap) - overlay colors now in shared dark theme */
  --capture-overlay-gap: var(--space-md);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  background: #000000;
  color: var(--color-text-primary);
}

header h1 {
  margin-top: 0;
}

main {
  max-width: 800px;
}

/* Capture experience */

.capture-stage {
  position: relative;
  flex: 1;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  overflow: hidden;
  background: #000;
  user-select: none;
  isolation: isolate;
  --preview-top: 0px;
  --preview-left: 0px;
  --preview-width: 100%;
  --preview-height: 100%;
  --bar-top: 0px;
  --bar-right: 0px;
  --bar-bottom: 0px;
  --bar-left: 0px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --capture-shutter-size: var(--tap-target-large);
  --capture-flip-size: 56px;
  --capture-controls-bottom: calc(var(--safe-bottom) + var(--space-xl) + var(--space-lg));
  --capture-flip-center-offset: calc((var(--capture-shutter-size) - var(--capture-flip-size)) / 2);
}

/* Video container for aspect-fit preview bounds */
.capture-stage__video-container {
  position: absolute;
  inset: auto;
  top: var(--preview-top);
  left: var(--preview-left);
  width: var(--preview-width);
  height: var(--preview-height);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  transition: top 180ms ease, left 180ms ease, width 180ms ease, height 180ms ease;
}

/* Bar regions positioned around the preview via CSS variables */
.capture-bars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
}

.capture-bar {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: width 180ms ease, height 180ms ease;
}

.capture-bar > * {
  pointer-events: auto;
}

.capture-bar--top {
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar-top);
  padding: calc(var(--space-lg) + var(--safe-top)) var(--space-lg) var(--space-lg);
}

.capture-bar--bottom {
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bar-bottom);
  padding: var(--space-lg) var(--space-lg) calc(var(--space-lg) + var(--safe-bottom));
}

.capture-bar--left {
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--bar-left);
  padding: var(--space-lg) var(--space-lg) var(--space-lg) calc(var(--space-lg) + var(--safe-left));
}

.capture-bar--right {
  top: 0;
  bottom: 0;
  right: 0;
  width: var(--bar-right);
  padding: var(--space-lg) calc(var(--space-lg) + var(--safe-right)) var(--space-lg) var(--space-lg);
}

.capture-stage__video,
.capture-stage__photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  transform-origin: center;
}

.capture-stage__video {
  z-index: 1;
}

.capture-stage__video--mirrored {
  transform: scaleX(-1);
}

.capture-stage__review--mirrored {
  transform: scaleX(-1);
  transform-origin: center;
}

/* Orientation fix: reverse Safari's landscape squish for the raw blob preview.
   The raw 640x480 blob contains portrait sensor data horizontally compressed into
   landscape dimensions. object-fit: fill stretches the content to fill the portrait-
   shaped element, reversing the distortion — the CSS equivalent of the server-side
   scale=480:640,setsar=1 reshape. */
.capture-stage__video--orientation-fix {
  object-fit: fill;
}

/* Orientation fix combined with front-camera mirror */
.capture-stage__video--orientation-fix-mirrored {
  object-fit: fill;
  transform: scaleX(-1);
  transform-origin: center;
}

.capture-stage__video--playback,
.capture-stage__photo {
  z-index: 2;
}

/* Legacy class kept but now uses contain to prevent cropping */
.capture-stage__video--cropped {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
}

/* Photo review image - uses object-fit for aspect-fit framing (canvas can't do object-fit) */
.capture-stage__photo-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #000;
  z-index: 3;
}

.capture-stage__freeze-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  background: #000;
  z-index: 2;
  pointer-events: none;
}

.capture-stage__freeze-frame--mirrored {
  transform: scaleX(-1);
}

/* Countdown overlay (3-2-1 before recording) */
.capture-stage__countdown {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  pointer-events: none;
  background: rgba(0, 0, 0, 1);
  transition: background 0.4s ease;
}

.capture-stage__countdown.has-stream {
  background: rgba(0, 0, 0, 0.5);
}

.capture-stage__countdown[hidden] {
  display: none;
}

.capture-stage__countdown-number {
  font-size: 5rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
  animation: countdownPop 1s ease-out forwards;
}

@keyframes countdownPop {
  0% {
    opacity: 0;
    transform: scale(1.8);
  }
  20% {
    opacity: 1;
    transform: scale(1);
  }
  75% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.8);
  }
}

.capture-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  padding: var(--space-lg);
  z-index: 3;
}

.capture-overlay--top {
  align-items: flex-start;
  justify-content: center;
  padding-top: calc(var(--space-xl) + var(--safe-top));
}

.capture-overlay--controls {
  align-items: center;
  justify-content: flex-end;
  padding-bottom: var(--capture-controls-bottom);
  gap: var(--space-sm);
  flex-direction: column;
}

/* Right-side button stack (flip camera + gallery) - matches viewer page layout */
.capture-button-stack {
  position: absolute;
  bottom: calc(var(--capture-controls-bottom) + var(--capture-flip-center-offset));
  right: calc(var(--safe-right) + var(--space-lg));
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.capture-button-stack [hidden] {
  display: none;
}

.capture-button-stack__btn {
  pointer-events: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: background 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
}

.capture-button-stack__btn:hover {
  background: rgba(0, 0, 0, 0.65);
  transform: scale(1.05);
}

.capture-button-stack__btn:active {
  transform: scale(0.95);
}

.capture-button-stack__btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

.capture-button-stack__btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.capture-button-stack__btn svg {
  width: 24px;
  height: 24px;
}

/* Close button (top-right X) */
.capture-close-btn {
  position: absolute;
  top: calc(var(--space-lg) + var(--safe-top));
  right: calc(var(--safe-right) + var(--space-lg));
  z-index: 4;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: background 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
}

.capture-close-btn:hover {
  background: rgba(0, 0, 0, 0.65);
  transform: scale(1.05);
}

.capture-close-btn:active {
  transform: scale(0.95);
}

.capture-close-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

.capture-close-btn[hidden] {
  display: none;
}

/* Bar-first control placement */
.capture-app[data-bar-layout="vertical"] .capture-overlay {
  inset: auto;
  padding: 0;
}

.capture-app[data-bar-layout="vertical"] .capture-overlay--top {
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar-top);
  align-items: center;
  justify-content: center;
  padding: calc(var(--space-lg) + var(--safe-top)) var(--space-lg) var(--space-lg);
}

.capture-app[data-bar-layout="vertical"] .capture-overlay--controls {
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bar-bottom);
  align-items: center;
  justify-content: center;
  padding: var(--space-lg) var(--space-lg) calc(var(--space-lg) + var(--safe-bottom));
}

.capture-app[data-bar-layout="horizontal"] .capture-overlay {
  inset: auto;
  padding: 0;
}

.capture-app[data-bar-layout="horizontal"] .capture-overlay--top {
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--bar-left);
  height: auto;
  align-items: flex-start;
  justify-content: center;
  padding: var(--space-lg) var(--space-lg) var(--space-lg) calc(var(--space-lg) + var(--safe-left));
}

.capture-app[data-bar-layout="horizontal"] .capture-overlay--controls {
  top: 0;
  bottom: 0;
  right: 0;
  width: var(--bar-right);
  height: auto;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg) calc(var(--space-lg) + var(--safe-right)) var(--space-lg) var(--space-lg);
}

/* Restore button stack positioning in bar layouts */
.capture-app[data-bar-layout="vertical"] .capture-button-stack,
.capture-app[data-bar-layout="horizontal"] .capture-button-stack {
  bottom: calc(var(--capture-controls-bottom) + var(--capture-flip-center-offset));
  right: calc(var(--safe-right) + var(--space-lg));
}


.capture-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  width: min(340px, 100%);
}

.capture-status-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  width: 100%;
  background: var(--overlay-subtle);
  padding: 0.75rem 1rem;
  border-radius: var(--corner-soft);
  pointer-events: auto;
  text-align: center;
}

.capture-status-stack--top {
  align-items: center;
}

.capture-status {
  margin: 0;
  font-size: var(--font-size-status);
  line-height: 1.35;
}

.capture-status--error {
  color: #ff8fa3;
}

.capture-status--success {
  color: #9ff2c3;
}

.capture-status--saved {
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.75);
}

.upload-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.upload-overlay[hidden] {
  display: none;
}

.upload-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
}

.upload-overlay__card {
  position: relative;
  background: rgba(30, 30, 30, 0.95);
  backdrop-filter: blur(16px);
  border-radius: var(--corner-soft);
  padding: 1.5rem 2rem;
  min-width: 260px;
  max-width: 90%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.upload-overlay__status {
  margin: 0 0 1rem;
  font-size: 1.1rem;
  color: #fff;
}

.upload-overlay__cancel {
  margin-top: 1rem;
  padding: 0.5rem 1.25rem;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--corner-pill);
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.95rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.upload-overlay__cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
}

.upload-progress {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  overflow: hidden;
}

.upload-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--color-progress-active);
  border-radius: 3px;
  transition: width 0.15s ease-out;
}

.upload-progress--indeterminate .upload-progress__bar {
  width: 100%;
  background: linear-gradient(
    90deg,
    var(--color-progress-active) 0%,
    rgba(255, 255, 255, 0.4) 50%,
    var(--color-progress-active) 100%
  );
  background-size: 200% 100%;
  animation: indeterminate-progress 1.2s ease-in-out infinite;
}

@keyframes indeterminate-progress {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.capture-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  background: var(--overlay-subtle);
  backdrop-filter: blur(16px);
  border-radius: var(--corner-pill);
  border: 1px solid rgba(255, 255, 255, 0.18);
  padding: 0.4rem;
  pointer-events: auto;
}

.capture-mode-toggle__button {
  position: relative;
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: var(--font-size-label);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.85rem;
  border-radius: var(--corner-pill);
  min-width: 110px;
  min-height: 54px;
  cursor: pointer;
  transition: color var(--anim-duration-fast) ease;
}

.capture-mode-toggle__button::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: var(--corner-pill);
  background: rgba(255, 255, 255, 0.12);
  opacity: 0;
  transform: scaleX(0.92);
  transition: opacity var(--anim-duration-fast) ease, transform var(--anim-duration-fast) ease;
  z-index: -1;
}

.capture-mode-toggle__button.is-active {
  color: #ffffff;
}

.capture-mode-toggle__button.is-active::after {
  opacity: 1;
  transform: scaleX(1);
}

.capture-mode-toggle__icon svg {
  display: block;
  stroke: currentColor;
}

.capture-timer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  pointer-events: none;
}

.capture-timer[hidden] {
  display: none;
}

.capture-timer__label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.6);
  transition: color var(--anim-duration-fast) ease;
}

.capture-timer--warning .capture-timer__label {
  color: #ff6b6b;
}

.capture-timer__value {
  font-family: var(--font-family-mono);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  color: #ffebeb;
  animation: captureTimerPulse 2.4s ease-in-out infinite;
}

@keyframes captureTimerPulse {
  0% { opacity: 0.85; }
  50% { opacity: 1; }
  100% { opacity: 0.85; }
}

.capture-timer--warning .capture-timer__value {
  color: #ff6b6b;
  animation: captureTimerWarningPulse 0.8s ease-in-out infinite;
}

@keyframes captureTimerWarningPulse {
  0% { opacity: 0.8; }
  50% { opacity: 1; }
  100% { opacity: 0.8; }
}

.capture-replay-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--anim-duration-mid) ease;
}

.capture-replay-info[hidden] {
  display: none;
}

.capture-replay-info.is-visible {
  opacity: 1;
}

.capture-replay-info__label {
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: rgba(255, 255, 255, 0.6);
}

.capture-replay-info__timer {
  font-family: var(--font-family-mono);
  font-size: 1.1rem;
  letter-spacing: 0.08em;
  color: #ffebeb;
  animation: captureTimerPulse 2.4s ease-in-out infinite;
}

.capture-secondary {
  display: flex;
  align-items: flex-end;
  min-height: var(--capture-shutter-size);
  gap: var(--space-md);
  pointer-events: auto;
  visibility: hidden;
  opacity: 0;
  transition:
    opacity var(--anim-duration-mid) ease,
    visibility 0s linear var(--anim-duration-mid);
}

.capture-secondary[hidden] {
  display: none;
}

.capture-secondary.is-visible {
  visibility: visible;
  opacity: 1;
  transition:
    opacity var(--anim-duration-mid) ease,
    visibility 0s;
}

.capture-secondary__button {
  background: none;
  border: none;
  color: #ffffff;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  transition: transform var(--anim-duration-fast) ease, opacity var(--anim-duration-fast) ease;
}

.capture-secondary__icon {
  width: var(--tap-target);
  height: var(--tap-target);
  border-radius: 50%;
  border: 1px solid var(--color-border-subtle);
  background: var(--overlay-medium);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.capture-secondary__label {
  font-size: 0.85rem;
  line-height: 1;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

#nextButton .capture-secondary__icon {
  background: rgba(72, 199, 142, 0.15);
  border-color: rgba(72, 199, 142, 0.5);
  box-shadow: 0 0 10px rgba(72, 199, 142, 0.3), inset 0 0 14px rgba(72, 199, 142, 0.25);
}

#retakeButton .capture-secondary__icon {
  background: rgba(255, 100, 100, 0.15);
  border-color: rgba(255, 100, 100, 0.5);
  box-shadow: 0 0 10px rgba(255, 100, 100, 0.3), inset 0 0 14px rgba(255, 100, 100, 0.25);
}

.capture-secondary__button:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.capture-secondary__button:active {
  transform: scale(0.95);
}

.capture-secondary__button[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.capture-shutter {
  width: var(--tap-target-large);
  height: var(--tap-target-large);
  flex: 0 0 auto;
  border-radius: 50%;
  background: transparent;
  border: none;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  pointer-events: auto;
  margin-top: 0;
}

.capture-shutter__ring,
.capture-shutter__core {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transition: transform var(--anim-duration-mid) ease, background-color var(--anim-duration-mid) ease, border var(--anim-duration-mid) ease;
}

.capture-shutter__ring {
  border: 4px solid #ffffff;
}

.capture-shutter__core {
  inset: 12px;
  background: var(--color-accent-primary);
  transform: scale(0.94);
}

.capture-shutter.is-photo .capture-shutter__core {
  background: var(--color-accent-photo);
  box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.3);
}

.capture-shutter.is-recording .capture-shutter__core {
  border-radius: 18%;
  transform: scale(0.8);
}

.capture-shutter:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 6px;
}

.capture-banner {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0) + var(--space-lg));
  left: 50%;
  transform: translate(-50%, -16px);
  background: var(--color-banner-success);
  color: var(--color-banner-text);
  border-radius: var(--corner-pill);
  padding: 0.6rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--anim-duration-slow) ease, transform var(--anim-duration-slow) ease;
  z-index: 4;
}

.capture-banner.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

.capture-banner__content {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
}

.capture-banner__dismiss {
  appearance: none;
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.capture-banner__dismiss:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 3px;
  border-radius: 50%;
}

.capture-recipient-sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
}

.capture-recipient-sheet.is-open {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  pointer-events: auto;
}

.capture-recipient-sheet__scrim {
  position: absolute;
  inset: 0;
  background: var(--overlay-heavy);
  opacity: 0;
  transition: opacity var(--anim-duration-mid) ease;
}

.capture-recipient-sheet.is-open .capture-recipient-sheet__scrim {
  opacity: 1;
}

.capture-recipient-sheet__panel {
  position: relative;
  width: min(480px, 100%);
  margin: 0;
  border-top-left-radius: 24px;
  border-top-right-radius: 24px;
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + var(--space-lg));
  background: rgba(23, 23, 23, 0.95);
  color: #ffffff;
  transform: translateY(32px);
  opacity: 0;
  transition: transform var(--anim-duration-mid) ease, opacity var(--anim-duration-mid) ease;
  pointer-events: auto;
  box-shadow: 0 -12px 24px rgba(0, 0, 0, 0.4);
}

.capture-recipient-sheet.is-open .capture-recipient-sheet__panel {
  transform: translateY(0);
  opacity: 1;
}

.capture-recipient-sheet__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) var(--space-lg) var(--space-sm);
}

.capture-recipient-sheet__header h2 {
  margin: 0;
  font-size: 1.2rem;
}

.capture-recipient-sheet__body {
  padding: 0 var(--space-lg) var(--space-lg);
}

.capture-recipient-summary {
  margin: 0 0 var(--space-md);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.95rem;
}

.capture-recipient-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: min(420px, 50vh);
  overflow-y: auto;
  padding-bottom: var(--space-sm);
}

.capture-send-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  margin-top: var(--space-md);
  padding: 0.85rem;
  border: none;
  border-radius: var(--corner-soft);
  background: #1f6bff;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  pointer-events: auto;
  transition: transform var(--anim-duration-fast) ease, background var(--anim-duration-fast) ease, opacity var(--anim-duration-fast) ease;
}

.capture-send-primary:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 3px;
}

.capture-send-primary:active {
  transform: scale(0.97);
}

.capture-send-primary[disabled] {
  opacity: 0.6;
  cursor: not-allowed;
}

.capture-send-primary svg {
  display: block;
}

.capture-app[data-view="review"] .capture-mode-toggle,
.capture-app[data-view="review"] #shutterButton {
  display: none;
}

.capture-recipient-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  padding: 0.5rem var(--space-md);
  min-height: 56px;
  border-radius: var(--corner-soft);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.capture-recipient-item__info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.capture-recipient-item__name {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.capture-recipient-item__meta {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
  margin: 0;
}

.capture-recipient-item__toggle {
  appearance: none;
  border: none;
  width: 48px;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.24);
  position: relative;
  flex: 0 0 auto;
  transition: background var(--anim-duration-fast) ease;
  cursor: pointer;
}

.capture-recipient-item__toggle:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

.capture-recipient-item__toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform var(--anim-duration-fast) ease;
}

.capture-recipient-item.is-selected {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.28);
}

.capture-recipient-item.is-selected .capture-recipient-item__toggle {
  background: var(--color-accent-primary);
}

.capture-recipient-item.is-selected .capture-recipient-item__toggle::after {
  transform: translateX(20px);
}

@media (min-width: 768px) {
  .capture-stage {
    width: 100%;
    height: 100vh;
  }

  .capture-overlay {
    padding-left: max(var(--space-xl), calc((100vw - 428px) / 2));
    padding-right: max(var(--space-xl), calc((100vw - 428px) / 2));
  }

  .capture-button-stack {
    right: calc(var(--safe-right) + var(--space-lg));
  }
}

.page-footer {
  margin-top: 3rem;
}

.subtitle {
  margin-top: -0.5rem;
  color: #555;
}

.shares-layout {
  display: grid;
  gap: 1.5rem;
}

.recipient-list {
  list-style: none;
  margin: 0.5rem 0 0;
  padding: 0;
  display: grid;
  gap: 0.5rem;
}

.recipient-list__item {
  display: flex;
}

.recipient-checkbox {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  width: 100%;
  cursor: pointer;
}

.recipient-checkbox input {
  width: 1rem;
  height: 1rem;
}

.recipient-checkbox span {
  display: inline-block;
  line-height: 1.25;
}

.recipient-checkbox.is-self {
  background: rgba(21, 157, 96, 0.08);
  border: 1px solid rgba(21, 157, 96, 0.2);
  border-radius: var(--corner-soft);
  padding: 0.75rem;
}

.recipient-checkbox.is-self span {
  color: #159d60;
  font-weight: 600;
}

.recipient-checkbox.is-self::before {
  content: '👤';
  margin-right: 0.5rem;
  font-size: 1.1rem;
}

.panel {
  background: #ffffff;
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.inline-button {
  background: transparent;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.4rem 0.75rem;
  cursor: pointer;
}

.captures-list {
  display: grid;
  gap: 1rem;
}

.capture-card {
  border: 1px solid #ebebeb;
  border-radius: 8px;
  padding: 1rem;
  background: #fafafa;
}

.capture-card__header {
  margin-bottom: 0.5rem;
}

.meta-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  color: #555;
  font-size: 0.9rem;
}

.meta-list li + li {
  margin-top: 0.25rem;
}

.card-actions {
  display: flex;
  justify-content: flex-end;
}

.secondary {
  background: transparent;
  border: 1px solid #005bbb;
  color: #005bbb;
  padding: 0.5rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
}

.secondary:hover {
  background: rgba(0, 91, 187, 0.08);
}

.share-result .badge {
  display: inline-block;
  background: #e6f0ff;
  color: #084aa0;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

.share-links {
  list-style: none;
  padding: 0;
  margin: 1rem 0 0;
  display: grid;
  gap: 0.8rem;
}

.share-links li {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  border: 1px solid #ebebeb;
  border-radius: 6px;
  padding: 0.75rem;
  background: #fff;
}

.share-link__info {
  max-width: 70%;
  word-break: break-word;
}

.share-link__info code {
  font-size: 0.85rem;
}

.empty-state {
  color: #666;
}

.error-panel {
  border: 1px solid #d93025;
  background: #ffeceb;
}

.error-panel h2 {
  color: #a1120e;
}

.viewer-body {
  /* Layout - variables now in shared dark theme selector */
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  background: var(--color-bg-app);
  color: var(--color-text-primary);
  font-family: var(--font-family-base);
  overflow: hidden;
}

.viewer-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
  margin: 0;
  padding: 0;
}

.viewer-stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 0;
}

/* Base styles for viewer media elements (class-based for consistent specificity) */
.viewer-stage__video,
.viewer-stage__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  margin: 0;
  padding: 0;
  transition: opacity var(--anim-duration-slow) ease-in-out;
}

/* Transition classes now applied to container, not media elements */
.viewer-stage__media-container.transitioning-out {
  opacity: 0;
  pointer-events: none;
}

.viewer-stage__media-container.transitioning-in {
  opacity: 0;
}

/* Viewer media container for aspect ratio cropping */
.viewer-stage__media-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity var(--anim-duration-slow) ease-in-out;
}

/* Portrait framing: 9:16 aspect ratio */
.viewer-stage__media-container--portrait {
  /* Override inset to allow aspect-ratio to control dimensions */
  inset: unset;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: 100%;
  aspect-ratio: 9 / 16;
}

/* Landscape framing: 16:9 aspect ratio */
.viewer-stage__media-container--landscape {
  /* Override inset to allow aspect-ratio to control dimensions */
  inset: unset;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* Media fills container, cropping as needed (must come after base to override) */
.viewer-stage__video--cropped,
.viewer-stage__image--cropped {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

/* Legacy media displays at native aspect ratio (no cropping) */
.viewer-stage__video--native,
.viewer-stage__image--native {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* Buffering spinner */
.viewer-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 10;
  display: none;
  pointer-events: none;
}

.viewer-spinner.is-visible {
  display: block;
}

.viewer-spinner__ring {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  animation: viewer-spinner-rotate 0.8s linear infinite;
}

.viewer-spinner__text {
  display: block;
  margin-top: 12px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  text-align: center;
}

@keyframes viewer-spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

.viewer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 60px; /* Leave space for video controls */
  display: flex;
}

.viewer-overlay[hidden] {
  display: none;
}

.viewer-zone {
  flex: 0 0 25%;
  background: transparent;
  border: none;
  cursor: pointer;
}

.viewer-zone--center {
  flex: 1;
  cursor: pointer;
}

.viewer-zone--right {
  flex: 0 0 25%;
}

.viewer-zone:focus-visible {
  outline: 2px solid #fff;
}

.viewer-zone:disabled {
  cursor: not-allowed;
  opacity: 0.3;
}

/* Tap zones: 25% left (prev), 50% middle (pause/play toggle), 25% right (next) */

/* Flash indicator for pause/play */
.viewer-flash {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.5rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(0, 0, 0, 0.6);
  padding: 12px 28px;
  border-radius: 8px;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  user-select: none;
}

.viewer-flash.is-visible {
  animation: flash-indicator 0.5s ease-out forwards;
}

@keyframes flash-indicator {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  80% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
  }
}

.viewer-status {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--overlay-modal);
  color: #ffffff;
  padding: 12px 24px;
  border-radius: 6px;
  font-size: 0.9rem;
  z-index: 20;
  display: none;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  text-align: center;
  white-space: pre-line;
  max-width: 85vw;
  width: max-content;
  transition: background var(--anim-duration-fast) ease;
}

.viewer-status:hover {
  background: rgba(0, 0, 0, 0.9);
}

.viewer-status--error {
  background: rgba(176, 0, 32, 0.8);
}

.viewer-status--info {
  background: var(--overlay-modal);
}

.viewer-stage .expired-message {
  color: #f2f2f2;
  font-size: 1.2rem;
  text-align: center;
  padding: 1.5rem;
}

/* Viewer Progress Bar */
.viewer-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100vw;
  max-width: none;
  z-index: 10;
  padding: var(--space-sm) var(--space-md);
  padding-top: calc(var(--space-sm) + env(safe-area-inset-top, 0));
  box-sizing: border-box;
}

.viewer-progress__track {
  display: flex;
  gap: 2px;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
}

.viewer-progress__segment {
  flex: 1;
  background: transparent;
  border-radius: 3px;
  position: relative;
  overflow: visible;
  padding: 8px 0; /* Add vertical padding for larger tap area */
  margin: -8px 0; /* Negative margin to maintain visual position */
}

.viewer-progress__segment:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: 2px;
}

/* Add the background bar as a separate element */
.viewer-progress__segment::before {
  content: '';
  position: absolute;
  top: 8px; /* Offset by padding amount */
  left: 0;
  right: 0;
  height: 5px;
  background: var(--color-progress-inactive);
  border-radius: 3px;
  z-index: 1;
}

.viewer-progress__segment-fill {
  position: absolute;
  top: 8px; /* Offset by padding amount */
  left: 0;
  height: 5px; /* Fixed height to maintain visual appearance */
  background: var(--color-progress-active);
  border-radius: 3px;
  width: 0%;
  transition: width var(--anim-duration-fast) ease-out;
  z-index: 2; /* Above the background */
}

.viewer-progress__segment.is-completed .viewer-progress__segment-fill {
  width: 100%;
}

.viewer-progress__segment.is-active .viewer-progress__segment-fill {
  transition: none;
}

.viewer-progress__timestamp-wrapper {
  text-align: center;
  margin-top: var(--space-xs);
}

.viewer-progress__timestamp {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.95);
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.viewer-progress__timestamp.is-visible {
  opacity: 1;
}

.viewer-progress__timestamp:empty {
  display: none;
}

.viewer-progress__sender {
  display: block;
  margin-top: 1px;
  font-size: 0.7rem;
  opacity: 0.75;
}

/* Viewer Replay Overlay */
.viewer-replay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-heavy);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--anim-duration-mid) ease, visibility 0s linear var(--anim-duration-mid);
  z-index: 15;
  pointer-events: none; /* Let taps pass through to nav zones beneath */
}

.viewer-replay.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity var(--anim-duration-mid) ease, visibility 0s;
}

.viewer-replay__content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  pointer-events: auto; /* Re-enable interaction for replay button */
}

.viewer-replay__button {
  appearance: none;
  border: none;
  background: rgba(255, 255, 255, 0.15);
  color: var(--color-text-primary);
  border-radius: 50%;
  width: 96px;
  height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(12px);
  border: 2px solid rgba(255, 255, 255, 0.25);
  transition: transform var(--anim-duration-fast) ease, background var(--anim-duration-fast) ease;
  animation: replayPulse 3s ease-in-out infinite;
}

.viewer-replay__button:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.05);
}

.viewer-replay__button:active {
  transform: scale(0.95);
}

.viewer-replay__button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.75);
  outline-offset: 4px;
}

.viewer-replay__button svg {
  display: block;
  stroke: currentColor;
}

.viewer-replay__label {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  text-align: center;
  opacity: 0.9;
}

@keyframes replayPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.08);
    opacity: 1;
  }
}

/* Viewer Button Stack - vertical column of action buttons on the right */
.viewer-button-stack {
  position: absolute;
  bottom: 12%;
  right: 5%;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  pointer-events: none;
}

.viewer-button-stack [hidden] {
  display: none;
}

.viewer-button-stack__btn {
  pointer-events: auto;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: white;
  transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: none;
}

.viewer-button-stack__btn:hover {
  background: rgba(0, 0, 0, 0.65);
  transform: scale(1.05);
}

.viewer-button-stack__btn:active {
  transform: scale(0.95);
}

.viewer-button-stack__btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.viewer-button-stack__btn svg {
  width: 24px;
  height: 24px;
}

/* Mute toggle icon state */
.viewer-mute-toggle__muted {
  display: none;
}

.viewer-mute-toggle.is-muted .viewer-mute-toggle__unmuted {
  display: none;
}

.viewer-mute-toggle.is-muted .viewer-mute-toggle__muted {
  display: block;
}

/* Wrapper to position hint relative to mute button */
.viewer-mute-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 56px;
  min-width: 56px;
}

/* Unmute hint text - positioned to the left of the mute button */
.viewer-unmute-hint {
  position: absolute;
  right: calc(100% + 14px);
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: rgba(255, 220, 220, 0.8);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.viewer-unmute-hint.is-visible {
  opacity: 1;
  animation: unmuteHintGlowScale 2s ease-in-out infinite;
}

@keyframes unmuteHintGlowScale {
  0%, 100% {
    transform: scale(1);
    text-shadow: 0 0 0 transparent;
  }
  50% {
    transform: scale(1.05);
    text-shadow: 0 0 8px rgba(220, 50, 50, 0.5), 0 0 16px rgba(220, 50, 50, 0.25);
  }
}

/* Wrapper to position reply hint relative to reply button */
.viewer-reply-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 56px;
  min-width: 56px;
}

/* Reply hint text - positioned to the left of the reply button */
.viewer-reply-hint {
  position: absolute;
  right: calc(100% + 14px);
  white-space: nowrap;
  font-size: 0.8rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: rgba(255, 255, 255, 0.9);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.viewer-reply-hint.is-visible {
  opacity: 1;
  animation: replyHintGlowScale 2s ease-in-out infinite;
}

@keyframes replyHintGlowScale {
  0%, 100% {
    transform: scale(1);
    text-shadow: 0 0 0 transparent;
  }
  50% {
    transform: scale(1.05);
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.5), 0 0 16px rgba(255, 255, 255, 0.25);
  }
}

/* Reply button gentle glow when hint is active */
.viewer-button-stack__btn.is-reply-pulsing {
  animation: replyButtonPulse 2s ease-in-out infinite;
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
}

@keyframes replyButtonPulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 18px rgba(255, 255, 255, 0.4), 0 0 6px rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.7);
  }
}

.viewer-mute-toggle.is-muted {
  animation: mutePulse 2s ease-in-out infinite;
  border-color: rgba(220, 50, 50, 0.4);
  background: rgba(255, 220, 220, 0.8);
  color: #333;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

@keyframes mutePulse {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  }
  50% {
    transform: scale(1.08);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  }
}

/* Viewer Camera Prompt - full-screen overlay for reply confirmation */
.viewer-camera-prompt {
  position: absolute;
  inset: 0;
  z-index: 20; /* Above reply bar and tap zones */
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--overlay-modal);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.viewer-camera-prompt[hidden] {
  display: none;
}

.viewer-camera-prompt__content {
  text-align: center;
  max-width: 320px;
  padding: var(--space-xl);
  color: white;
  font-family: 'DM Sans', var(--font-family-base);
}

.viewer-camera-prompt__icon {
  margin-bottom: var(--space-lg);
  opacity: 0.8;
}

.viewer-camera-prompt__title {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 var(--space-sm);
}

.viewer-camera-prompt__text {
  font-size: 0.95rem;
  opacity: 0.8;
  margin: 0 0 var(--space-xl);
  line-height: 1.4;
}

.viewer-camera-prompt__okay {
  display: block;
  width: 100%;
  padding: 0.85rem;
  background: white;
  color: #000;
  border: none;
  border-radius: var(--corner-soft);
  font-size: 1rem;
  font-weight: 600;
  font-family: 'DM Sans', var(--font-family-base);
  cursor: pointer;
  margin-bottom: var(--space-sm);
  transition: opacity 0.2s;
}

.viewer-camera-prompt__okay:active {
  opacity: 0.8;
}

.viewer-camera-prompt__cancel {
  display: block;
  width: 100%;
  padding: 0.75rem;
  background: transparent;
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--corner-soft);
  font-size: 0.95rem;
  font-family: 'DM Sans', var(--font-family-base);
  cursor: pointer;
  transition: opacity 0.2s;
}

.viewer-camera-prompt__cancel:active {
  opacity: 0.7;
}

/* Viewer Success Banner - shown after returning from reply capture flow */
.viewer-success-banner {
  position: fixed;
  top: calc(1rem + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  z-index: 30;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.viewer-success-banner[hidden] {
  display: none;
}

.viewer-success-banner.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.viewer-success-banner__message {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  background: var(--color-banner-success);
  color: var(--color-banner-text);
  border-radius: var(--corner-pill);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: 'DM Sans', var(--font-family-base);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

/* Viewer Empty State */
.viewer-empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 60vh;
  color: var(--color-text-primary);
}

.viewer-empty-state__content {
  text-align: center;
  max-width: 320px;
  padding: var(--space-xl);
}

.viewer-empty-state__title {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 var(--space-xs);
  color: var(--color-text-primary);
}

.viewer-empty-state__icon {
  margin: 0 auto var(--space-lg);
  opacity: 0.7;
  animation: emptyStateFloat 4s ease-in-out infinite;
}

.viewer-empty-state__icon svg {
  display: block;
  stroke: currentColor;
}

.viewer-empty-state__subtitle {
  font-size: 1rem;
  margin: 0 0 var(--space-xl);
  opacity: 0.8;
  color: var(--color-text-primary);
}

.viewer-empty-state__cta {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: 1px solid var(--color-border-subtle);
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--color-text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--anim-duration-fast) ease,
              transform var(--anim-duration-fast) ease;
  -webkit-tap-highlight-color: transparent;
}

.viewer-empty-state__cta svg {
  flex-shrink: 0;
  stroke: currentColor;
}

.viewer-empty-state__cta:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.03);
}

.viewer-empty-state__cta:active {
  transform: scale(0.97);
}

.viewer-empty-state__cta:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 3px;
}

@keyframes emptyStateFloat {
  0%, 100% {
    transform: translateY(0);
    opacity: 0.7;
  }
  50% {
    transform: translateY(-8px);
    opacity: 0.9;
  }
}

/* Send to me checkbox styling */
.capture-send-to-me {
  display: flex;
  align-items: center;
}
.capture-send-to-me__label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
  margin: 0;
}
.capture-send-to-me__checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.1);
  position: relative;
  cursor: pointer;
  transition: all var(--anim-duration-fast) ease;
}
.capture-send-to-me__checkbox:checked {
  background: var(--color-accent-primary);
  border-color: var(--color-accent-primary);
}
.capture-send-to-me__checkbox:checked::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #ffffff;
  font-size: 14px;
  font-weight: bold;
}
.capture-send-to-me__checkbox:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}
.capture-send-to-me__text {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 500;
}

/* =============================================================
   Invite Flow UI Mockup
   ============================================================= */

.invite-root {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  z-index: 1;
}

/* State-driven visibility */
[data-state="idle"] .invite-review,
[data-state="recording"] .invite-review { display: none; }
[data-state="review"] .invite-controls { display: none; }
[data-state="review"] .invite-video-stage .invite-video:not(.invite-video--playback) { display: none; }
[data-state="idle"] .invite-video--playback,
[data-state="recording"] .invite-video--playback { display: none; }

/* Video stage — fullscreen behind controls */
.invite-video-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: #000;
}
.invite-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.invite-video--mirrored {
  transform: scaleX(-1);
}
.invite-video--playback {
  position: absolute;
  inset: 0;
}

/* Recording timer pill — above shutter */
.invite-timer {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--space-xl) + var(--space-lg) + 80px + var(--space-md));
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--corner-pill);
  padding: 0.35rem 0.9rem;
  z-index: 6;
  pointer-events: none;
}
.invite-timer__value {
  color: #fff;
  font-size: 0.9rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

/* "Link copied" overlay — transparent scrim, tap anywhere or OK to dismiss */
.invite-copied-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  align-items: center;
  justify-content: center;
  animation: inviteCopiedFadeIn var(--anim-duration-fast) ease both;
}
.invite-copied-overlay[hidden] { display: none; }
.invite-copied-overlay:not([hidden]) { display: flex; }
@keyframes inviteCopiedFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.invite-copied-overlay__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-xl);
  border-radius: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  text-align: center;
}
.invite-copied-overlay__card svg {
  opacity: 0.9;
}
.invite-copied-overlay__title {
  font-size: 1.15rem;
  font-weight: 600;
}
.invite-copied-overlay__subtitle {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}
.invite-copied-overlay__ok {
  margin-top: var(--space-xs);
  padding: 0.45rem 1.6rem;
  border-radius: var(--corner-pill);
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease;
}
.invite-copied-overlay__ok:hover {
  background: rgba(255, 255, 255, 0.25);
}
.invite-copied-overlay__ok:active {
  transform: scale(0.96);
}

/* Back button — top-left, always visible */
.invite-back {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + var(--space-md));
  left: calc(env(safe-area-inset-left, 0px) + var(--space-md));
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, transform 0.2s ease;
}
.invite-back:hover {
  background: rgba(0, 0, 0, 0.65);
  transform: scale(1.05);
}
.invite-back:active {
  transform: scale(0.95);
}
.invite-back:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

/* Close button — top-right, matches capture-close-btn */
.invite-close {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + var(--space-md));
  right: calc(env(safe-area-inset-right, 0px) + var(--space-md));
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  -webkit-tap-highlight-color: transparent;
  pointer-events: auto;
  transition: background 0.2s ease, transform 0.2s ease;
}
.invite-close:hover {
  background: rgba(0, 0, 0, 0.65);
  transform: scale(1.05);
}
.invite-close:active {
  transform: scale(0.95);
}
.invite-close:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

/* Instruction pill */
.invite-pill {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + var(--space-lg));
  left: 50%;
  transform: translate(-50%, 0);
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--corner-pill);
  padding: 0.5rem 1rem;
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-align: center;
  line-height: 1.4;
  pointer-events: none;
  z-index: 5;
}

/* Shutter button container — centered at bottom */
.invite-controls {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--space-xl) + var(--space-lg));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Review state layout */
.invite-review {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  animation: inviteFadeIn var(--anim-duration-mid) ease;
}

@keyframes inviteFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Retake button wrapper — positioned above actions */
.invite-retake-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: calc(var(--space-xl) * 2);
}

.invite-retake {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.65rem 1.25rem;
  border-radius: var(--corner-pill);
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--anim-duration-fast) ease, color var(--anim-duration-fast) ease;
}
.invite-retake:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}
.invite-retake:active {
  opacity: 0.8;
}
.invite-retake:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.75);
  outline-offset: 4px;
}

/* Actions bar — bottom sheet panel */
.invite-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-lg) var(--space-lg) calc(env(safe-area-inset-bottom, 0px) + var(--space-xl));
  background: rgba(23, 23, 23, 0.95);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -12px 24px rgba(0, 0, 0, 0.4);
  animation: inviteSheetUp var(--anim-duration-mid) ease both;
}

@keyframes inviteSheetUp {
  from {
    transform: translateY(32px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Copy link row */
.invite-copy-row {
  display: flex;
  width: 100%;
  max-width: 360px;
  gap: var(--space-xs);
}

.invite-link-field {
  flex: 1;
  min-width: 0;
  padding: 0.6rem 0.8rem;
  border-radius: var(--corner-soft);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.85rem;
  font-family: var(--font-family-base);
  outline: none;
}
.invite-link-field:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 1px;
}

.invite-copy-btn {
  padding: 0.6rem 1rem;
  border-radius: var(--corner-soft);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, transform 0.2s ease;
}
.invite-copy-btn:hover {
  background: rgba(0, 0, 0, 0.65);
  transform: scale(1.05);
}
.invite-copy-btn:active {
  transform: scale(0.95);
}
.invite-copy-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}

/* Share button — matches capture-send-primary */
.invite-share-btn {
  width: 100%;
  max-width: 360px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.5rem;
  border-radius: 2rem;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--anim-duration-fast) ease, transform var(--anim-duration-fast) ease;
}
.invite-share-btn:hover {
  background: rgba(255, 255, 255, 0.22);
  transform: scale(1.03);
}
.invite-share-btn:active {
  transform: scale(0.97);
}
.invite-share-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 3px;
}


