/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #FFF8E7;
  font-family: -apple-system, 'PingFang SC', 'Microsoft YaHei', sans-serif;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.hidden { display: none !important; }

/* === Permission Screen === */
.permission-screen {
  position: fixed; inset: 0; z-index: 100;
  background: #FFF8E7;
  display: flex; align-items: center; justify-content: center;
  text-align: center; color: #2d2a4a; padding: 32px;
}
.permission-content { max-width: 320px; }
.permission-icon { margin-bottom: 16px; font-size: 48px; }
.permission-content h2 { font-size: 22px; margin-bottom: 12px; color: #2d2a4a; font-weight: 800; }
.permission-content p { font-size: 14px; line-height: 1.6; color: #5a5570; margin-bottom: 24px; }
.retry-btn {
  background: #C5A3FF; color: #2d2a4a;
  border: none; border-radius: 16px;
  padding: 12px 32px; font-size: 16px; font-weight: 800; cursor: pointer;
}
.retry-btn:active { opacity: 0.8; }

/* === Camera UI Layout === */
.camera-ui {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  background: #000;
}

/* === Top Bar (floats over viewfinder) === */
.top-bar {
  position: absolute; top: 0; left: 0; right: 0; z-index: 32;
  display: flex; justify-content: space-between; align-items: center;
  padding: 48px 16px 8px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.4), transparent);
}
.top-icon {
  width: 36px; height: 36px;
  background: rgba(255,255,255,0.15);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
}
.top-icon:active { opacity: 0.7; }
.top-icon svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.top-icon.active svg { stroke: #FFD96B; fill: #FFD96B; }
.top-title {
  font-size: 15px; font-weight: 900; color: #fff;
  letter-spacing: 1px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  background: rgba(255,255,255,0.12);
  padding: 3px 10px; border-radius: 8px;
}

/* === Viewfinder Frame (full screen, other elements float over it) === */
.viewfinder-frame {
  position: absolute; inset: 0;
  overflow: hidden;
  background: #000;
}
#video {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0; pointer-events: none;
}
#viewfinder {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* === AI Speech Bubble (top-right, semi-transparent) === */
.ai-bubble {
  position: absolute; top: 100px; right: 8px;
  max-width: 220px;
  background: rgba(255,255,255,0.65);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 14px;
  padding: 8px 10px 9px;
  z-index: 31;
  cursor: pointer;
  animation: bubbleIn 0.25s ease;
}
.ai-bubble::after {
  display: none;
}
.ai-bubble-header {
  display: flex; align-items: center; gap: 5px; margin-bottom: 4px;
}
.voice-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #FF6B8A;
}
.voice-dot.pulsing { animation: pulse 1.2s infinite; }
@keyframes pulse { 0%,100% { transform: scale(0.9); } 50% { transform: scale(1.3); } }
.ai-label {
  font-size: 10px; color: #2d2a4a; font-weight: 800;
  background: #FFD96B; padding: 2px 7px; border-radius: 8px;
}
.ai-mode {
  margin-left: auto; font-size: 9px; color: #2d2a4a; font-weight: 700;
  background: #D9EFDE; padding: 2px 6px; border-radius: 8px;
}
.ai-bubble-text {
  font-size: 11px; color: #2d2a4a; line-height: 1.5; font-weight: 500;
}
.ai-bubble-text .hint {
  color: #2d2a4a; font-weight: 800;
  background: #FFE3A3; padding: 0 3px; border-radius: 3px;
}
.ai-bubble.fade-out { animation: bubbleOut 0.4s ease forwards; }
.ai-bubble.mood-encouraging .ai-label { background: #D9EFDE; }
.ai-bubble.mood-adjusting .ai-label { background: #FFD96B; }

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes bubbleOut {
  from { opacity: 1; }
  to { opacity: 0; transform: translateY(6px); }
}

/* === Mini Preview Card (F4, top-right below AI bubble) === */
.mini-preview {
  position: absolute; top: 100px; right: 8px;
  width: 78px;
  background: rgba(255,248,231,0.6);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 10px 6px 6px;
  z-index: 30;
  animation: bubbleIn 0.3s ease;
}
.mini-preview-label {
  position: absolute; top: -7px; left: 50%; transform: translateX(-50%);
  background: #FFD96B; color: #2d2a4a;
  font-size: 8px; font-weight: 800; letter-spacing: 0.8px;
  padding: 1px 8px; border-radius: 6px;
  white-space: nowrap;
}
.mini-frame {
  position: relative;
  background: #2d2a4a;
  border-radius: 6px;
  overflow: visible;
  margin: 2px auto 6px;
  width: 54px; height: 70px;
}
.mini-frame.closeup { width: 68px; height: 54px; }
.mini-frame.halfbody { width: 56px; height: 70px; }
.mini-frame.fullbody { width: 54px; height: 70px; }
.mini-frame::before, .mini-frame::after {
  content: ''; position: absolute; width: 8px; height: 8px;
  border: 1.5px solid #FFD96B;
}
.mini-frame::before { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.mini-frame::after  { bottom: -1px; right: -1px; border-left: none; border-top: none; }
.mini-frame svg { width: 100%; height: 100%; display: block; }
.mini-caption {
  text-align: center; font-size: 9px; font-weight: 800;
  color: #2d2a4a; background: #FF9FB1; border-radius: 6px; padding: 2px 4px;
}
.mini-sub {
  text-align: center; font-size: 8px; color: #5a5570;
  margin-top: 2px; font-weight: 600;
}
.mini-preview.fade-out { animation: bubbleOut 0.8s ease forwards; }

/* === Celebration (inside viewfinder) === */
.celebration {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.confetti-canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}
.celebration-text {
  position: relative; z-index: 41;
  font-size: 36px; font-weight: 900;
  color: #fff;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  padding: 12px 32px; border-radius: 20px;
  animation: celebPop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
@keyframes celebPop {
  0% { transform: scale(0) rotate(-8deg); opacity: 0; }
  50% { transform: scale(1.3) rotate(3deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg); }
}

/* === Action Row (floats over viewfinder) === */
.action-bar {
  position: absolute; bottom: 150px; left: 0; right: 0; z-index: 15;
  display: flex; align-items: center; justify-content: center;
  gap: 12px;
  padding: 8px 16px;
}
/* AI main button (replaces shutter) */
.ai-btn-main {
  width: 66px; height: 66px; border-radius: 50%;
  background: #C5A3FF;
  border: none;
  box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 6px #C5A3FF;
  cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.ai-btn-main:active { transform: scale(0.92); }
.ai-btn-main .ai-btn-icon {
  font-size: 16px; font-weight: 900; color: #2d2a4a;
  letter-spacing: 1px;
}
.ai-btn-main.loading .ai-btn-icon { display: none; }
.ai-btn-main.loading .ai-btn-loading { display: flex !important; }
.ai-btn-main.loading {
  animation: aiPulse 1.2s ease infinite;
}
@keyframes aiPulse {
  0%,100% { box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 6px #C5A3FF, 0 0 0 0 rgba(197,163,255,0.4); }
  50% { box-shadow: inset 0 0 0 4px #fff, inset 0 0 0 6px #C5A3FF, 0 0 0 10px rgba(197,163,255,0); }
}
.spinner {
  width: 22px; height: 22px;
  border: 2.5px solid rgba(45,42,74,0.15);
  border-top-color: #2d2a4a;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ready-btn {
  background: #FFD96B;
  border: none; border-radius: 16px;
  padding: 9px 20px;
  cursor: pointer;
  animation: readyBounce 0.3s ease;
}
.ready-btn:active { transform: scale(0.93); opacity: 0.8; }
.ready-text {
  font-size: 14px; font-weight: 800; color: #2d2a4a;
}
@keyframes readyBounce {
  0% { opacity: 0; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1); }
}

/* === Bottom Panel (floats over viewfinder) === */
.bottom-panel {
  position: absolute; bottom: 0; left: 0; right: 0; z-index: 15;
  background: linear-gradient(to top, rgba(0,0,0,0.5), transparent);
  padding: 8px 16px 32px;
}
.slide-selector {
  display: flex; justify-content: center; align-items: center; gap: 6px;
  margin-bottom: 12px;
  width: 100%; text-align: center;
}
.slide-option {
  flex: 1; text-align: center;
  font-size: 12px; font-weight: 800;
  color: rgba(255,255,255,0.5); padding: 5px 0; border-radius: 14px;
  background: transparent; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s;
}
.slide-option.active {
  color: #fff; background: rgba(255,255,255,0.15);
}
.slide-option.active[data-style="thunder"] {
  color: #FFD96B; background: rgba(255,217,107,0.15);
}
.phone-controls {
  display: flex; justify-content: space-evenly; align-items: center;
  padding: 0 12px;
}
.ctrl-btn {
  width: 48px; height: 48px; border-radius: 16px;
  background: rgba(255,255,255,0.12);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 14px;
  border: none;
  cursor: pointer; font-weight: 700;
}
.ctrl-btn:active { opacity: 0.7; }
.ctrl-btn svg { width: 20px; height: 20px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.flip-btn { background: rgba(255,255,255,0.12); }
/* (shutter removed — AI button is the main action) */

/* === Flash Overlay === */
.flash {
  position: fixed; inset: 0; z-index: 50;
  background: #fff;
  animation: flashAnim 0.15s ease-out forwards;
}
@keyframes flashAnim {
  0% { opacity: 0.9; }
  100% { opacity: 0; }
}

/* === Toast === */
.toast {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 40;
  background: #7FD8A8;
  color: #2d2a4a; font-size: 13px; font-weight: 800;
  padding: 8px 20px; border-radius: 14px;
  animation: toastIn 0.3s ease;
}
.toast.fade-out { animation: bubbleOut 0.3s ease forwards; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}
