:root {
  --bg-obsidian: #090807;
  --ink-ivory: #faf7f2;
  --ink-muted: rgba(250, 247, 242, 0.72);
  --champagne: #e6d1ae;
  --champagne-strong: #f2dfc0;
  --emerald: #6ee7b7;
  --amber: #fcd34d;
  --rose: #fda4af;
  --glass-bg: rgba(14, 12, 10, 0.56);
  --glass-border: rgba(250, 247, 242, 0.14);
  --font-serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-obsidian);
  color: var(--ink-ivory);
  font-family: var(--font-sans);
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

.camera-app {
  position: relative;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-obsidian);
}

/* Viewfinder */
.viewfinder-stage {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, #1c1917 0%, #090807 75%);
  overflow: hidden;
}

.viewfinder-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform-origin: center center;
  transition: opacity 220ms ease;
}

.viewfinder-video.is-mirrored {
  transform: scaleX(-1);
}

/* Soft top and bottom vignettes for control legibility */
.viewfinder-stage::before,
.viewfinder-stage::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 2;
}

.viewfinder-stage::before {
  top: 0;
  height: 130px;
  background: linear-gradient(to bottom, rgba(9, 8, 7, 0.72), transparent);
}

.viewfinder-stage::after {
  bottom: 0;
  height: 185px;
  background: linear-gradient(to top, rgba(9, 8, 7, 0.84), transparent);
}

/* Optional rule-of-thirds grid */
.grid-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms ease;
}

.grid-overlay.is-visible {
  opacity: 1;
}

.grid-overlay span {
  position: absolute;
  background: rgba(250, 247, 242, 0.22);
}

.grid-overlay span:nth-child(1) {
  left: 33.33%;
  top: 0;
  bottom: 0;
  width: 1px;
}

.grid-overlay span:nth-child(2) {
  left: 66.66%;
  top: 0;
  bottom: 0;
  width: 1px;
}

.grid-overlay span:nth-child(3) {
  top: 33.33%;
  left: 0;
  right: 0;
  height: 1px;
}

.grid-overlay span:nth-child(4) {
  top: 66.66%;
  left: 0;
  right: 0;
  height: 1px;
}

/* Tap-to-focus indicator */
.focus-reticle {
  position: absolute;
  width: 68px;
  height: 68px;
  margin-left: -34px;
  margin-top: -34px;
  border: 1.5px solid var(--champagne-strong);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(9, 8, 7, 0.35);
  pointer-events: none;
  z-index: 4;
  opacity: 0;
  transform: scale(1.25);
}

.focus-reticle.is-pulsing {
  animation: focusPulse 650ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes focusPulse {
  0% {
    opacity: 0;
    transform: scale(1.3);
  }
  20% {
    opacity: 0.95;
    transform: scale(0.96);
  }
  70% {
    opacity: 0.85;
    transform: scale(1);
  }
  100% {
    opacity: 0;
    transform: scale(0.92);
  }
}

/* Shutter flash */
.shutter-flash {
  position: absolute;
  inset: 0;
  background: #fffdf8;
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}

.shutter-flash.is-flashing {
  animation: shutterFlash 180ms ease-out;
}

@keyframes shutterFlash {
  0% {
    opacity: 0.85;
  }
  100% {
    opacity: 0;
  }
}

/* Top HUD — stays visible above both viewfinder and fallback overlay */
.top-hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 12px) + 12px) 16px 12px;
  pointer-events: none;
}

.event-pill,
.status-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  max-width: 55vw;
}

.event-title {
  font-family: var(--font-serif);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink-ivory);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.event-tag {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(230, 209, 174, 0.18);
  color: var(--champagne-strong);
  white-space: nowrap;
}

.status-pill {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--ink-ivory);
  white-space: nowrap;
  transition: border-color 220ms ease, background-color 220ms ease;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--champagne);
  flex-shrink: 0;
  transition: background-color 220ms ease, transform 220ms ease;
}

.status-pill.is-uploading .status-dot {
  background: var(--amber);
  animation: dotPulse 1.1s ease-in-out infinite;
}

.status-pill.is-synced .status-dot {
  background: var(--emerald);
}

.status-pill.is-warning .status-dot {
  background: var(--rose);
}

@keyframes dotPulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.4;
    transform: scale(0.75);
  }
}

/* Toast banner */
.toast-banner {
  position: absolute;
  top: calc(env(safe-area-inset-top, 12px) + 62px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 32;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(20, 17, 15, 0.84);
  border: 1px solid rgba(230, 209, 174, 0.28);
  color: var(--ink-ivory);
  font-size: 0.78rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Zoom Bar */
.zoom-bar {
  position: absolute;
  bottom: calc(env(safe-area-inset-bottom, 16px) + 124px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.zoom-chip {
  appearance: none;
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-muted);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}

.zoom-chip.is-active {
  background: rgba(230, 209, 174, 0.24);
  color: var(--champagne-strong);
}

/* Bottom Control Deck */
.bottom-deck {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 16px 24px calc(env(safe-area-inset-bottom, 16px) + 22px);
  gap: 16px;
}

.deck-slot {
  display: flex;
  align-items: center;
  gap: 12px;
}

.deck-slot-left {
  justify-content: flex-start;
}

.deck-slot-center {
  justify-content: center;
}

.deck-slot-right {
  justify-content: flex-end;
}

/* Tactile Shutter Button */
.shutter-btn {
  position: relative;
  width: 82px;
  height: 82px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  outline: none;
  touch-action: manipulation;
  transition: opacity 200ms ease, transform 120ms cubic-bezier(0.22, 1, 0.36, 1);
}

.shutter-btn:disabled {
  opacity: 0.42;
  cursor: default;
}

.shutter-btn:not(:disabled):active {
  transform: scale(0.92);
}

.shutter-ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.shutter-ring-track {
  fill: none;
  stroke: rgba(250, 247, 242, 0.85);
  stroke-width: 3.2;
}

.shutter-ring-active {
  fill: none;
  stroke: var(--champagne-strong);
  stroke-width: 3.8;
  stroke-linecap: round;
  stroke-dasharray: 264;
  stroke-dashoffset: 264;
  opacity: 0;
  transition: opacity 200ms ease;
}

.shutter-btn.is-uploading .shutter-ring-active {
  opacity: 1;
  stroke-dashoffset: 185;
  animation: shutterOrbit 1.2s linear infinite;
  transform-origin: center;
}

@keyframes shutterOrbit {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.shutter-core {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #f5efe6 100%);
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.32), inset 0 0 0 1px rgba(230, 209, 174, 0.5);
  transition: transform 120ms ease, background 120ms ease;
}

.shutter-btn:not(:disabled):active .shutter-core,
.shutter-btn.is-snapping .shutter-core {
  transform: scale(0.87);
  background: var(--champagne-strong);
}

/* Circular Glass Icon Buttons */
.icon-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  background: var(--glass-bg);
  color: var(--ink-ivory);
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  transition: transform 280ms cubic-bezier(0.22, 1, 0.36, 1);
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn.is-active {
  background: rgba(230, 209, 174, 0.24);
  border-color: rgba(230, 209, 174, 0.55);
  color: var(--champagne-strong);
}

.icon-btn.is-rotated svg {
  transform: rotate(180deg);
}

/* Ephemeral capture confirmation chip (in-memory only, fades after handoff) */
.ephemeral-thumb {
  position: relative;
  width: 46px;
  height: 58px;
  border-radius: 10px;
  overflow: hidden;
  border: 1.5px solid rgba(250, 247, 242, 0.65);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(10px) scale(0.86);
  pointer-events: none;
  transition: opacity 240ms ease, transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  display: none;
}

.ephemeral-thumb.is-visible {
  display: block;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.ephemeral-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ephemeral-badge {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: rgba(9, 8, 7, 0.78);
  border: 1px solid rgba(250, 247, 242, 0.4);
  display: grid;
  place-items: center;
  font-size: 10px;
  color: var(--emerald);
}

/* Fallback overlay (only shown on camera permission error or unsupported environment) */
.camera-fallback {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 50% 35%, rgba(28, 25, 23, 0.92), rgba(9, 8, 7, 0.98));
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

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

.fallback-card {
  width: 100%;
  max-width: 360px;
  padding: 32px 26px;
  border-radius: 24px;
  background: rgba(24, 21, 19, 0.88);
  border: 1px solid rgba(230, 209, 174, 0.22);
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.fallback-emblem {
  width: 54px;
  height: 54px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(230, 209, 174, 0.14);
  border: 1px solid rgba(230, 209, 174, 0.3);
  color: var(--champagne-strong);
  display: grid;
  place-items: center;
}

.fallback-emblem svg {
  width: 24px;
  height: 24px;
}

.fallback-title {
  margin: 0 0 10px;
  font-family: var(--font-serif);
  font-size: 1.85rem;
  font-weight: 500;
  color: var(--ink-ivory);
}

.fallback-message {
  margin: 0 0 24px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--ink-muted);
}

.fallback-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-primary,
.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 0.94rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 120ms ease, opacity 160ms ease, background-color 160ms ease;
}

.btn-primary {
  border: none;
  background: linear-gradient(135deg, #f3e2c6 0%, #dcc195 100%);
  color: #171412;
}

.btn-secondary {
  border: 1px solid rgba(250, 247, 242, 0.22);
  background: rgba(250, 247, 242, 0.06);
  color: var(--ink-ivory);
}

.btn-primary:active,
.btn-secondary:active {
  transform: scale(0.98);
}

.fallback-note {
  margin: 18px 0 0;
  font-size: 0.74rem;
  line-height: 1.45;
  color: rgba(250, 247, 242, 0.5);
}

[hidden] {
  display: none !important;
}
