/* --- Design Tokens & Core Variables --- */
:root {
  --color-bg-dark: #0a0a0c;
  --color-bg-panel: rgba(18, 18, 22, 0.75);
  --color-border-glass: rgba(255, 255, 255, 0.08);
  --color-border-active: rgba(255, 255, 255, 0.2);
  
  /* Neon Accents */
  --color-accent-primary: #00f0ff; /* Neon Cyan */
  --color-accent-secondary: #ff007f; /* Neon Magenta/Rose */
  --color-accent-purple: #8a2be2; /* Neon Purple */
  --color-accent-gold: #ffd700; /* Gold */
  
  /* Telemetry Accents */
  --color-level-ok: #39ff14; /* Neon Green */
  --color-level-warn: #ffaa00; /* Neon Amber */
  --color-level-error: #ff3b30; /* Neon Red */
  
  /* Typography Colors */
  --color-text-main: #ffffff;
  --color-text-sub: #a0a0ab;
  --color-text-dim: #71717a;
  
  /* Glassmorphism Styling */
  --glass-blur: blur(24px);
  --glass-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
  
  /* Fonts */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  /* Safe Area Heights for Modern Devices */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* --- Global Reset & Scrollbars --- */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  background-color: #030304;
  color: var(--color-text-main);
  font-family: var(--font-sans);
  overflow: hidden;
  position: fixed;
}

/* Custom subtle scrollbar for preset selector */
::-webkit-scrollbar {
  height: 4px;
  width: 4px;
}
::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent-primary);
}

/* --- Desktop Layout Simulator (The Smartphone chassis frame) --- */
.app-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg-dark);
  position: relative;
  overflow: hidden;
}

@media (min-width: 500px) {
  /* Desktop / Tablet simulator frame */
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top left, #1c1030 0%, #050508 100%);
  }

  body::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(138, 43, 226, 0.12) 0%, rgba(0, 0, 0, 0) 70%);
    top: 10%;
    left: 20%;
    z-index: 0;
    pointer-events: none;
  }
  
  body::after {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(0, 240, 255, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
    bottom: 10%;
    right: 20%;
    z-index: 0;
    pointer-events: none;
  }

  .app-container {
    width: 420px;
    height: 840px;
    border-radius: 48px;
    border: 12px solid #232329;
    box-shadow: 0 25px 60px -10px rgba(0, 0, 0, 0.9), 
                0 0 0 1px rgba(255,255,255,0.05),
                inset 0 0 20px rgba(0,0,0,0.8);
    overflow: hidden;
    z-index: 1;
  }
}

/* --- Glassmorphism Panels --- */
.glass-panel {
  background: var(--color-bg-panel);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--color-border-glass);
  box-shadow: var(--glass-shadow);
}

/* --- Top Header Navigation --- */
.app-header {
  padding: calc(12px + var(--safe-top)) 20px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 10;
  border-bottom: 1px solid var(--color-border-glass);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-accent-primary), var(--color-accent-secondary));
  box-shadow: 0 0 8px var(--color-accent-primary);
  animation: logoPulse 3s infinite ease-in-out;
}

.header-logo h1 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(to right, #fff, #a0a0ab);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.logo-sub {
  font-size: 9px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--color-accent-primary);
  border: 1px solid rgba(0, 240, 255, 0.3);
  padding: 1px 4px;
  border-radius: 3px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Header Buttons styling */
.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border-glass);
  color: var(--color-text-sub);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-text-main);
  border-color: var(--color-border-active);
}

.icon-btn.active {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(138, 43, 226, 0.15));
  border-color: var(--color-accent-primary);
  color: var(--color-accent-primary);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.2);
}

.icon-btn .icon {
  width: 18px;
  height: 18px;
  transition: transform 0.3s ease;
}

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

.grid-badge {
  position: absolute;
  bottom: -4px;
  right: -4px;
  font-size: 7px;
  font-weight: 700;
  font-family: var(--font-mono);
  background: #27272a;
  color: #fff;
  padding: 1px 4px;
  border-radius: 4px;
  border: 1px solid var(--color-border-glass);
  pointer-events: none;
}

.icon-btn.active .grid-badge {
  background: var(--color-accent-primary);
  color: #000;
  border-color: var(--color-accent-primary);
}

/* --- Camera Viewport --- */
.viewport-area {
  flex: 1;
  position: relative;
  overflow: hidden;
  background-color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}

#camera-stream {
  display: none; /* Stream drawn inside canvas */
}

.canvas-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#camera-canvas {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.3s ease; /* Smooth visual style switching */
}

/* --- Camera Flash Overlay --- */
.flash-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  opacity: 0;
  pointer-events: none;
  z-index: 99;
}

.flash-active {
  animation: shutterFlashAnim 0.3s ease-out;
}

/* --- Composition Grids Overlay --- */
.grid-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.grid-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
  transition: all 0.3s ease;
}

/* Grid display toggles */
.grid-none .grid-thirds-lines,
.grid-none .grid-triangle-lines,
.grid-none .grid-cinematic-mask,
.grid-none .grid-center-crosshair {
  display: none;
}

.grid-thirds .grid-thirds-lines { display: block; }
.grid-thirds .grid-triangle-lines,
.grid-thirds .grid-cinematic-mask,
.grid-thirds .grid-center-crosshair { display: none; }

.grid-triangle .grid-triangle-lines { display: block; }
.grid-triangle .grid-thirds-lines,
.grid-triangle .grid-cinematic-mask,
.grid-triangle .grid-center-crosshair { display: none; }

.grid-cinematic .grid-cinematic-mask { display: flex; }
.grid-cinematic .grid-thirds-lines,
.grid-cinematic .grid-triangle-lines,
.grid-cinematic .grid-center-crosshair { display: none; }

.grid-center .grid-center-crosshair { display: flex; }
.grid-center .grid-thirds-lines,
.grid-center .grid-triangle-lines,
.grid-center .grid-cinematic-mask { display: none; }

/* Rule of Thirds Lines */
.grid-thirds-lines {
  position: absolute;
  width: 100%;
  height: 100%;
}

.grid-thirds-lines .v-line {
  position: absolute;
  width: 1px;
  height: 100%;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.grid-thirds-lines .v-line.l1 { left: 33.33%; }
.grid-thirds-lines .v-line.l2 { left: 66.66%; }

.grid-thirds-lines .h-line {
  position: absolute;
  height: 1px;
  width: 100%;
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.grid-thirds-lines .h-line.t1 { top: 33.33%; }
.grid-thirds-lines .h-line.t2 { top: 66.66%; }

/* Grid intersection intersection nodes */
.third-node {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid rgba(0, 0, 0, 0.3);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px rgba(255,255,255,0.4);
}
.third-node.n1 { left: 33.33%; top: 33.33%; }
.third-node.n2 { left: 66.66%; top: 33.33%; }
.third-node.n3 { left: 33.33%; top: 66.66%; }
.third-node.n4 { left: 66.66%; top: 66.66%; }

/* Golden Triangle svg overlay */
.grid-triangle-lines {
  position: absolute;
  width: 100%;
  height: 100%;
}
.grid-triangle-lines svg {
  width: 100%;
  height: 100%;
  opacity: 0.8;
  filter: drop-shadow(0 0 1px rgba(0,0,0,0.5));
}

/* Cinematic Letterboxes */
.grid-cinematic-mask {
  position: absolute;
  width: 100%;
  height: 100%;
  flex-direction: column;
  justify-content: space-between;
}
.grid-cinematic-mask .letterbox {
  background: #000;
  height: 12%; /* Generates 2.39:1 crop out of 16:9 stream */
  width: 100%;
  opacity: 0.95;
  transition: height 0.3s ease;
}

/* Center / Minimalist Crosshair */
.grid-center-crosshair {
  position: absolute;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;
}
.circle-focus {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 1px dashed rgba(255,255,255,0.4);
  box-shadow: 0 0 0 2px rgba(0,0,0,0.2), inset 0 0 0 1px rgba(0,0,0,0.2);
  animation: focalSpin 20s linear infinite;
}
.cross {
  position: absolute;
  background: rgba(255, 255, 255, 0.45);
  box-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.cross.x { width: 16px; height: 1px; }
.cross.y { width: 1px; height: 16px; }


/* --- Virtual Horizon leveler HUD --- */
.horizon-leveler-ui {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 140px;
  height: 140px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 6;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.1s ease;
}

.horizon-leveler-ui.visible {
  opacity: 0.75;
}

.horizon-ring {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.horizon-ring::before, .horizon-ring::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 1px;
  background: rgba(255, 255, 255, 0.4);
}
.horizon-ring::before { left: 0; }
.horizon-ring::after { right: 0; }

.horizon-bar {
  position: absolute;
  width: 80px;
  height: 1px;
  background: rgba(255, 255, 255, 0.6);
  top: 50%;
  left: calc(50% - 40px);
  transform-origin: center center;
  transition: transform 0.05s linear, background-color 0.2s ease, filter 0.2s ease;
}

/* Calibration dot */
.horizon-target {
  position: absolute;
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  top: calc(50% - 4px);
  left: calc(50% - 4px);
  transition: transform 0.05s linear;
}

/* Leveled State (Perfect horizon alignment) */
.horizon-leveler-ui.leveled .horizon-bar {
  background-color: var(--color-level-ok);
  filter: drop-shadow(0 0 6px var(--color-level-ok));
  height: 2px;
}
.horizon-leveler-ui.leveled .horizon-target {
  background-color: var(--color-level-ok);
  filter: drop-shadow(0 0 6px var(--color-level-ok));
  transform: translate(0, 0) scale(1.3) !important;
}
.horizon-leveler-ui.leveled .horizon-ring {
  border-color: rgba(57, 255, 20, 0.3);
}


/* --- Real-Time Technical HUD Overlay --- */
.hud-metrics {
  position: absolute;
  top: 15px;
  left: 15px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 8;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  text-shadow: 0 2px 4px rgba(0,0,0,0.8);
  pointer-events: none;
  background: rgba(0,0,0,0.4);
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255,255,255,0.05);
}

.hud-item {
  display: flex;
  gap: 6px;
}

.hud-label {
  color: var(--color-text-dim);
}

.hud-val {
  color: var(--color-accent-primary);
}


/* --- Live AI Assistant Panel --- */
.live-assistant-card {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  border-radius: 20px;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  z-index: 8;
  pointer-events: auto;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(0);
}

.live-assistant-card.hidden {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

.assistant-icon-container {
  flex-shrink: 0;
  margin-top: 2px;
}

.assistant-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.15), rgba(255, 0, 127, 0.15));
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--color-accent-primary);
  transition: all 0.3s ease;
}

/* Changing colors of assistant icon based on message status */
.assistant-icon.warn {
  color: var(--color-level-warn);
  border-color: rgba(255, 170, 0, 0.4);
  background: rgba(255, 170, 0, 0.1);
}

.assistant-icon.ok {
  color: var(--color-level-ok);
  border-color: rgba(57, 255, 20, 0.4);
  background: rgba(57, 255, 20, 0.1);
}

.assistant-icon.info {
  color: var(--color-accent-gold);
  border-color: rgba(255, 215, 0, 0.4);
  background: rgba(255, 215, 0, 0.1);
}

.assistant-icon svg {
  width: 18px;
  height: 18px;
}

.assistant-content {
  flex: 1;
}

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.assistant-header h4 {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--color-text-main);
  opacity: 0.9;
}

.assistant-badge {
  font-family: var(--font-mono);
  font-size: 8px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(0, 240, 255, 0.15);
  color: var(--color-accent-primary);
  border: 1px solid rgba(0, 240, 255, 0.2);
}

.assistant-icon.warn ~ .assistant-content .assistant-badge {
  background: rgba(255, 170, 0, 0.15);
  color: var(--color-level-warn);
  border-color: rgba(255, 170, 0, 0.2);
}

.assistant-icon.ok ~ .assistant-content .assistant-badge {
  background: rgba(57, 255, 20, 0.15);
  color: var(--color-level-ok);
  border-color: rgba(57, 255, 20, 0.2);
}

.assistant-icon.info ~ .assistant-content .assistant-badge {
  background: rgba(255, 215, 0, 0.15);
  color: var(--color-accent-gold);
  border-color: rgba(255, 215, 0, 0.2);
}

#assistant-tip {
  font-size: 13px;
  line-height: 1.4;
  font-weight: 400;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  transition: opacity 0.2s ease;
}


/* --- Bottom Controls Area --- */
.app-controls {
  padding: 16px 20px calc(20px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
  z-index: 10;
  border-top: 1px solid var(--color-border-glass);
  border-radius: 24px 24px 0 0;
}

/* Exposure slider */
.exposure-slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
}

.exp-icon {
  width: 16px;
  height: 16px;
  color: var(--color-text-sub);
}

.exposure-slider {
  flex: 1;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.1);
  height: 4px;
  border-radius: 2px;
  outline: none;
}

.exposure-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.exposure-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  background: var(--color-accent-primary);
}

.exposure-value {
  font-family: var(--font-mono);
  font-size: 11px;
  width: 32px;
  text-align: right;
  color: var(--color-accent-primary);
}

/* Preset carousel */
.preset-carousel-wrapper {
  overflow-x: auto;
  margin: 0 -20px;
  padding: 4px 20px;
}

.preset-carousel {
  display: flex;
  gap: 10px;
  width: max-content;
}

.preset-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--color-border-glass);
  padding: 8px 14px;
  border-radius: 12px;
  color: var(--color-text-sub);
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
}

.preset-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--color-border-active);
  color: #fff;
}

.preset-btn.active {
  background: #fff;
  color: #000;
  border-color: #fff;
  box-shadow: 0 4px 15px rgba(255, 255, 255, 0.15);
  font-weight: 600;
}

.preset-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  background: #e4e4e7;
}

/* Individual Preset Indicator colors */
.preset-dot.natural { background: #fff; }
.preset-dot.sunset { background: linear-gradient(135deg, #ff8c00, #ff007f); }
.preset-dot.noir { background: linear-gradient(135deg, #3f3f46, #09090b); border: 1px solid #71717a; }
.preset-dot.cyberpunk { background: linear-gradient(135deg, #00ffff, #ff007f); }
.preset-dot.minimalist { background: linear-gradient(135deg, #e4e4e7, #a1a1aa); }
.preset-dot.foodie { background: linear-gradient(135deg, #ffd700, #ff4500); }

/* Capture bar */
.capture-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 10px;
}

/* Gallery button preview */
.gallery-preview-btn {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border-glass);
  padding: 2px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-preview-btn:hover {
  transform: scale(1.08);
  border-color: var(--color-accent-primary);
}

.thumbnail-wrapper {
  width: 100%;
  height: 100%;
  border-radius: 9px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #18181b;
}

.thumbnail-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-placeholder-icon {
  width: 20px;
  height: 20px;
  color: var(--color-text-dim);
}

/* Glorious Shutter Button */
.shutter-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: none;
  border: 4px solid #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  padding: 0;
  box-shadow: 0 0 12px rgba(255, 255, 255, 0.15);
}

.shutter-inner {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: #ffffff;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.shutter-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 0 20px rgba(0, 240, 255, 0.3);
  border-color: var(--color-accent-primary);
}

.shutter-btn:hover .shutter-inner {
  background: var(--color-accent-primary);
  transform: scale(0.9);
}

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

.shutter-btn:active .shutter-inner {
  transform: scale(0.75);
}

/* Help button */
.help-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--color-border-glass);
  color: var(--color-text-sub);
  font-family: var(--font-sans);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.help-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: var(--color-border-active);
}


/* --- Modal General System --- */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(3, 3, 4, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 100%;
  max-height: 80%;
  border-radius: 28px 28px 0 0;
  border-bottom: none;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.open .modal-container {
  transform: translateY(0);
}

.modal-header {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border-glass);
}

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.close-btn {
  background: none;
  border: none;
  color: var(--color-text-sub);
  font-size: 28px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: color 0.2s ease;
}

.close-btn:hover {
  color: #fff;
}

.modal-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px calc(24px + var(--safe-bottom));
}

/* --- Gallery Grid Layout --- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.gallery-item {
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--color-border-glass);
  cursor: pointer;
  background: #141416;
  transform: scale(1);
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.gallery-item:hover {
  transform: scale(0.98);
  border-color: var(--color-accent-primary);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.item-badge {
  position: absolute;
  bottom: 4px;
  left: 4px;
  font-size: 8px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.6);
  padding: 1px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  color: var(--color-accent-primary);
  font-family: var(--font-mono);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--color-text-sub);
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--color-text-dim);
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

.empty-state span {
  font-size: 12px;
  color: var(--color-text-dim);
  max-width: 200px;
  line-height: 1.4;
}

/* --- Help / Guide Styles --- */
.help-content section {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.help-content h4 {
  font-size: 15px;
  color: #fff;
}

.help-content p {
  font-size: 13px;
  color: var(--color-text-sub);
  line-height: 1.5;
}

.help-item {
  display: flex;
  gap: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.03);
  padding: 14px;
  border-radius: 16px;
}

.help-emoji {
  font-size: 24px;
  flex-shrink: 0;
  margin-top: 2px;
}

.help-item h5 {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
  color: #fff;
}

.help-item p {
  margin-bottom: 6px;
}

.help-item ul {
  padding-left: 16px;
  font-size: 12px;
  color: var(--color-text-sub);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.text-green {
  color: var(--color-level-ok);
}

.ready-btn {
  width: 100%;
  padding: 14px;
  background: #fff;
  border: none;
  border-radius: 14px;
  color: #000;
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 14px;
  margin-top: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.ready-btn:hover {
  background: var(--color-accent-primary);
  box-shadow: 0 4px 15px rgba(0, 240, 255, 0.3);
}

/* --- Photo Viewer Overlay (LightBox) --- */
.photo-viewer-overlay {
  background: rgba(0, 0, 0, 0.98);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.viewer-container {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  position: relative;
}

.viewer-close-btn {
  position: absolute;
  top: -40px;
  right: 0;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
}

#viewer-img {
  width: 100%;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.05);
}

.viewer-meta {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--color-text-dim);
  text-transform: uppercase;
}

.viewer-actions {
  display: flex;
  width: 100%;
  gap: 12px;
}

.action-btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.action-btn.download {
  background: var(--color-accent-primary);
  color: #000;
}
.action-btn.download:hover {
  background: #fff;
  box-shadow: 0 0 15px rgba(0, 240, 255, 0.4);
}

.action-btn.delete {
  background: rgba(255, 59, 48, 0.1);
  color: #ff3b30;
  border: 1px solid rgba(255, 59, 48, 0.2);
}
.action-btn.delete:hover {
  background: #ff3b30;
  color: #fff;
}

.btn-icon {
  width: 16px;
  height: 16px;
}


/* --- CSS Keyframes for Animations --- */
@keyframes logoPulse {
  0%, 100% {
    transform: scale(1);
    opacity: 0.9;
  }
  50% {
    transform: scale(1.15);
    opacity: 1;
    box-shadow: 0 0 14px var(--color-accent-primary), 0 0 4px var(--color-accent-secondary);
  }
}

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

@keyframes shutterFlashAnim {
  0% { opacity: 0; }
  25% { opacity: 1; }
  100% { opacity: 0; }
}

/* Pulsing warning indicator */
.pulse {
  animation: heartPulse 2s infinite ease-in-out;
}

@keyframes heartPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
