/* ==========================================
   MEMORY ALBUM - 3D CSS PAGE FLIPPER ENGINE
   Inspired by NYTimes-Flipper & CSS 3D Transforms
   ========================================== */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,600;0,700;1,400;1,600&family=Great+Vibes&family=Outfit:wght@300;400;500;600;700&family=Playfair+Display:ital,wght@0,500;0,700;1,400&display=swap');

:root {
  /* Light Warm Romantic Theme */
  --bg-primary: #fdf5f5;
  --bg-secondary: #fce8eb;
  --bg-card: rgba(255, 255, 255, 0.9);
  --bg-book: #fffcf9;
  --page-left-bg: #fdf8f4;
  --page-right-bg: #fefaf6;
  
  --text-primary: #2c1a20;
  --text-secondary: #6e4b52;
  --text-accent: #c84b61;
  --text-gold: #b8860b;
  
  --border-color: rgba(200, 75, 97, 0.2);
  --border-gold: rgba(184, 134, 11, 0.4);
  --accent-rose: #d85a70;
  --shadow-color: rgba(180, 80, 100, 0.15);
  
  --font-serif: 'Cormorant Garamond', Georgia, serif;
  --font-heading: 'Playfair Display', Georgia, serif;
  --font-cursive: 'Great Vibes', cursive;
  --font-sans: 'Outfit', sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --transition-smooth: all 0.35s cubic-bezier(0.25, 1, 0.5, 1);
}

[data-theme="rose_petal_dark"], [data-theme="warm_linen"] {
  --bg-primary: #faf0ef;
  --bg-secondary: #f5dbdf;
  --bg-card: rgba(255, 255, 255, 0.92);
  --bg-book: #fffcf9;
  --page-left-bg: #fdf7f3;
  --page-right-bg: #fef9f5;
  --text-primary: #2c1a20;
  --text-secondary: #64434a;
  --text-accent: #c84b61;
  --text-gold: #b8860b;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: radial-gradient(circle at 50% 20%, #ffffff 0%, #fdeef0 50%, #f7d6dc 100%);
  background-size: 200% 200%;
  animation: ambient-shift 20s ease-in-out infinite;
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

@keyframes ambient-shift {
  0%, 100% { background-position: 50% 0%; }
  25% { background-position: 30% 50%; }
  50% { background-position: 50% 100%; }
  75% { background-position: 70% 50%; }
}

/* --- ROMANTIC HEART LIQUID PRELOADER OVERLAY --- */
.love-preloader {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 30%, #ffffff 0%, #fdeef0 60%, #f5d3d9 100%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.love-preloader.loaded {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-heart-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  margin-bottom: 1.5rem;
}

.preloader-heart-bg {
  width: 100px;
  height: 100px;
  fill: rgba(200, 75, 97, 0.12);
  stroke: var(--text-accent);
  stroke-width: 1.5px;
}

.preloader-heart-fill-container {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 0%;
  overflow: hidden;
  transition: height 0.3s ease-out;
}

.preloader-heart-fill-svg {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100px;
  height: 100px;
  fill: url(#heartGradient);
}

.preloader-title {
  font-family: var(--font-cursive);
  font-size: 3.2rem;
  color: var(--text-accent);
  margin-bottom: 0.2rem;
  line-height: 1;
}

.preloader-counter {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
}

.preloader-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* Floating Petals Canvas */
#rosePetalCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* --- Header Bar --- */
.app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 70px;
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  z-index: 1000;
  box-shadow: 0 4px 20px rgba(200, 75, 97, 0.08);
  transition: transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), opacity 0.4s ease;
}

.app-header.header-hidden {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-heading);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
}

.brand-logo .heart-icon {
  color: #e63956;
  font-size: 1.5rem;
  animation: pulse-heart 2s infinite ease-in-out;
}

@keyframes pulse-heart {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); color: #ff4d6d; }
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 1005;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-smooth);
}

.btn-icon:hover {
  background: #fce8eb;
  border-color: var(--text-accent);
  color: var(--text-accent);
  transform: translateY(-2px);
}

.btn-primary {
  background: linear-gradient(135deg, #e63956 0%, #c84b61 100%);
  color: #ffffff;
  border: none;
  font-weight: 600;
  padding: 0.65rem 1.4rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 4px 18px rgba(230, 57, 86, 0.35);
  cursor: pointer;
  transition: var(--transition-smooth);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(230, 57, 86, 0.5);
  color: #fff;
}

.btn-danger {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: #dc3545;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.main-wrapper {
  padding-top: 80px;
  min-height: calc(100vh - 70px);
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 5;
}

.viewer-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  position: relative;
}

/* ==========================================
   NYTIMES-FLIPPER 3D CSS PAGE FLIP ARCHITECTURE
   ========================================== */

.book-stage {
  margin: 1rem auto;
  position: relative;
  width: 1000px;
  height: 600px;
}

/* Container Perspective Wrapper */
.flip-book {
  position: relative;
  width: 1000px;
  height: 600px;
  margin: 0 auto;
  perspective: 2500px;
  -webkit-perspective: 2500px;
  border-radius: 12px;

  /* Premium Gilded Paper Stack Shadow */
  box-shadow: 
    0 25px 60px rgba(180, 80, 100, 0.28),
    0 8px 20px rgba(184, 134, 11, 0.12),
    -10px 8px 0px -2px #f8e5e8,
    10px 8px 0px -2px #f8e5e8,
    -16px 14px 2px -4px #f2d5da,
    16px 14px 2px -4px #f2d5da,
    -20px 18px 4px -6px #eedce0,
    20px 18px 4px -6px #eedce0,
    0 0 0 2px rgba(184, 134, 11, 0.35),
    inset 0 0 40px rgba(184, 134, 11, 0.06);

  background: var(--bg-book);
}

/* Center Spine Shadow Line with Gold Trim */
.flip-book::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: linear-gradient(to bottom, 
    rgba(184, 134, 11, 0.1) 0%,
    rgba(184, 134, 11, 0.35) 20%,
    rgba(184, 134, 11, 0.35) 80%,
    rgba(184, 134, 11, 0.1) 100%);
  pointer-events: none;
  z-index: 501;
}

.flip-book::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 24px;
  transform: translateX(-50%);
  background: linear-gradient(to right, 
    rgba(0,0,0,0.15) 0%, 
    rgba(0,0,0,0.03) 40%, 
    rgba(0,0,0,0.03) 60%, 
    rgba(0,0,0,0.15) 100%);
  pointer-events: none;
  z-index: 500;
}

/* Base Left & Right Background Covers */
.base-page-left {
  position: absolute;
  top: 0;
  left: 0;
  width: 500px;
  height: 600px;
  background: var(--page-left-bg);
  border-right: 1px solid rgba(0,0,0,0.05);
  border-radius: 12px 0 0 12px;
  overflow: hidden;
  z-index: 1;
}

.base-page-right {
  position: absolute;
  top: 0;
  left: 500px;
  width: 500px;
  height: 600px;
  background: var(--page-right-bg);
  border-radius: 0 12px 12px 0;
  overflow: hidden;
  z-index: 1;
}

/* 3D Flipping Page Sheet (.flipper) */
.flipper {
  position: absolute;
  top: 0;
  left: 500px; /* Aligned along vertical spine */
  width: 500px;
  height: 600px;
  transform-origin: left center;
  -webkit-transform-origin: left center;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.9s cubic-bezier(0.645, 0.045, 0.355, 1.000);
  cursor: pointer;
  filter: drop-shadow(0 0 0 transparent);
}

.flipper:hover:not(.flipped) {
  filter: drop-shadow(-4px 0 8px rgba(180, 80, 100, 0.12));
}

/* Flipped State -> Rotates -180deg to lie on left spread */
.flipper.flipped {
  transform: rotateY(-180deg);
  -webkit-transform: rotateY(-180deg);
}

/* Front and Back 3D Faces */
.front, .back {
  position: absolute;
  top: 0;
  left: 0;
  width: 500px;
  height: 600px;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 0 12px 12px 0;
  background: var(--bg-book);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.03);
}

.front {
  transform: rotateY(0deg);
  -webkit-transform: rotateY(0deg);
  z-index: 2;
  border-left: 1px solid rgba(0,0,0,0.06);
}

/* Back Face is pre-rotated 180deg so when .flipper flips -180deg, it faces forward! */
.back {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
  z-index: 1;
  border-right: 1px solid rgba(0,0,0,0.06);
  border-radius: 12px 0 0 12px;
}

/* Front Cover Layout */
.book-cover-front {
  background: linear-gradient(145deg, #ffffff 0%, #fdf2f4 100%);
  border-radius: 12px;
  padding: 3rem 2rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  border: 3px double var(--border-gold);
  animation: cover-entrance 1.2s cubic-bezier(0.25, 1, 0.5, 1) both;
}

@keyframes cover-entrance {
  0% { opacity: 0; transform: scale(0.92); }
  100% { opacity: 1; transform: scale(1); }
}

.book-title {
  font-family: var(--font-heading);
  font-size: 3rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  line-height: 1.2;
}

.book-subtitle {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 1.5rem;
  color: var(--text-accent);
  margin-bottom: 1.8rem;
}

.cover-photo-frame {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 4px solid var(--text-gold);
  overflow: hidden;
  box-shadow: 
    0 10px 30px rgba(200, 75, 97, 0.25),
    0 0 0 8px rgba(184, 134, 11, 0.08),
    0 0 30px rgba(184, 134, 11, 0.15);
  margin: 0 auto 1.5rem auto;
  animation: cover-frame-glow 3s ease-in-out infinite;
}

@keyframes cover-frame-glow {
  0%, 100% { box-shadow: 0 10px 30px rgba(200, 75, 97, 0.25), 0 0 0 8px rgba(184, 134, 11, 0.08), 0 0 30px rgba(184, 134, 11, 0.15); }
  50% { box-shadow: 0 10px 30px rgba(200, 75, 97, 0.35), 0 0 0 10px rgba(184, 134, 11, 0.15), 0 0 45px rgba(184, 134, 11, 0.25); }
}

.cover-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.cover-photo-frame:hover img {
  transform: scale(1.08);
}

/* Photo Frames inside Pages */
.photo-frame-fit {
  width: 100%;
  height: 100%;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 8px 25px rgba(0,0,0,0.1);
  border: 1px solid var(--border-color);
  position: relative;
}

.photo-frame-fit img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.photo-frame-fit:hover img {
  transform: scale(1.03);
}

/* Glassmorphic Overlay Caption Card */
.glass-overlay-card {
  position: absolute;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  width: 88%;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-gold);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.6rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(200, 75, 97, 0.18);
  z-index: 15;
}

/* Caption Typography */
.caption-wrapper {
  padding: 1.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
}

.cursive-decorative {
  font-family: var(--font-cursive);
  font-size: 3rem;
  color: var(--text-accent);
  line-height: 1;
  margin-bottom: 0.8rem;
}

.caption-text {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  line-height: 1.65;
  color: var(--text-primary);
  margin-bottom: 1.2rem;
  white-space: pre-wrap;
}

.caption-meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.caption-meta::before, .caption-meta::after {
  content: '✦';
  color: var(--text-gold);
}

/* Flip Control Toolbar */
.flip-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 1.5rem;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  padding: 0.65rem 2rem;
  border-radius: 50px;
  border: 1px solid rgba(184, 134, 11, 0.2);
  z-index: 100;
  box-shadow: 
    0 8px 30px rgba(200, 75, 97, 0.15),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.nav-arrow {
  background: none;
  border: none;
  color: var(--text-accent);
  font-size: 1.6rem;
  cursor: pointer;
  padding: 0.4rem 0.7rem;
  border-radius: 50%;
  transition: var(--transition-smooth);
}
.nav-arrow:hover:not(:disabled) {
  background: var(--bg-secondary);
  transform: scale(1.25);
  box-shadow: 0 0 15px rgba(200, 75, 97, 0.25);
}
.nav-arrow:active:not(:disabled) {
  transform: scale(0.92);
  box-shadow: 0 0 20px rgba(200, 75, 97, 0.4);
}
.nav-arrow:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-counter {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

/* Floating Audio Buttons */
.audio-controls-group {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 1000;
}

.audio-toggle-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(200, 75, 97, 0.3);
  color: var(--text-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 
    0 8px 25px rgba(200, 75, 97, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: var(--transition-smooth);
  animation: orb-breathe 3s ease-in-out infinite;
}

@keyframes orb-breathe {
  0%, 100% { box-shadow: 0 8px 25px rgba(200, 75, 97, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
  50% { box-shadow: 0 8px 30px rgba(200, 75, 97, 0.3), 0 0 15px rgba(200, 75, 97, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
}

.audio-toggle-btn:hover {
  transform: scale(1.12);
  box-shadow: 0 10px 30px rgba(200, 75, 97, 0.35);
  animation: none;
}
.audio-toggle-btn.playing {
  animation: spin-vinyl 4s linear infinite;
  background: linear-gradient(135deg, var(--text-accent), #e63956);
  color: #fff;
  border-color: transparent;
}

@keyframes spin-vinyl {
  100% { transform: rotate(360deg); }
}

/* --- Admin Dashboard & Editor --- */
.dashboard-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem;
  width: 100%;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2.5rem;
}

.dashboard-title {
  font-family: var(--font-heading);
  font-size: 2.2rem;
  color: var(--text-primary);
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 2rem;
}

.album-card {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition-smooth);
  box-shadow: 0 8px 30px var(--shadow-color);
  display: flex;
  flex-direction: column;
}
.album-card:hover {
  transform: translateY(-6px) scale(1.015);
  border-color: rgba(184, 134, 11, 0.4);
  box-shadow: 
    0 16px 45px rgba(200, 75, 97, 0.22),
    0 0 0 1px rgba(184, 134, 11, 0.15);
}

.album-card-cover {
  height: 200px;
  background: rgba(0,0,0,0.05);
  position: relative;
  overflow: hidden;
}
.album-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
}
.album-card:hover .album-card-cover img {
  transform: scale(1.06);
}

.album-card-body {
  padding: 1.5rem;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.album-card-title {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--text-primary);
  margin-bottom: 0.4rem;
}

.album-card-subtitle {
  font-family: var(--font-serif);
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 1.2rem;
}

.album-card-actions {
  margin-top: auto;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Editor Specific Styles */
.editor-header {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.share-link-box {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #ffffff;
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-accent);
  width: 100%;
  max-width: 500px;
}

.pages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.page-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-left: 3px solid rgba(184, 134, 11, 0.4);
  border-radius: var(--radius-md);
  padding: 1.2rem;
  position: relative;
  transition: var(--transition-smooth);
  cursor: grab;
}
.page-card:hover {
  border-left-color: var(--text-gold);
  box-shadow: 0 8px 25px rgba(200, 75, 97, 0.12);
}
.page-card:active {
  cursor: grabbing;
}
.page-card.dragging {
  opacity: 0.4;
  border-color: var(--text-accent);
}

.page-card-image {
  width: 100%;
  height: 190px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  margin-bottom: 0.8rem;
}

.form-input, .form-textarea, .form-select {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
  transition: var(--transition-smooth);
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--text-accent);
  box-shadow: 0 0 10px rgba(200, 75, 97, 0.2);
}

.dropzone {
  border: 2px dashed var(--text-accent);
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-md);
  padding: 3rem 2rem;
  text-align: center;
  cursor: pointer;
  margin-bottom: 2rem;
  transition: var(--transition-smooth);
}
.dropzone:hover, .dropzone.dragover {
  background: #fce8eb;
  border-color: var(--text-accent);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}
.toast {
  background: var(--text-accent);
  color: #fff;
  padding: 0.8rem 1.6rem;
  border-radius: 30px;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  animation: fadeInOut 3s forwards;
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateY(20px); }
  15%, 85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-20px); }
}

/* --- Print CSS (@media print) --- */
@media print {
  @page {
    size: 8in 8in;
    margin: 0;
  }
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .app-header, .flip-controls, .audio-controls-group, #rosePetalCanvas, .love-preloader, .no-print {
    display: none !important;
  }
  .print-page-break {
    page-break-after: always;
    break-after: page;
    width: 8in;
    height: 8in;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5in;
    box-sizing: border-box;
  }
  .print-photo {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
  }
}

/* ==========================================
   RESPONSIVE & MULTI-DEVICE STYLING ENGINE
   (Mobile <768px, Laptop 1024px-1919px, TV >=1920px & TV Displays)
   ========================================== */

/* Universal Focus visible ring for TV Remote (D-Pad) & Keyboard Accessibility */
:focus-visible, [data-tv-focused="true"] {
  outline: 3px solid var(--text-gold) !important;
  outline-offset: 4px !important;
  box-shadow: 0 0 20px rgba(184, 134, 11, 0.6), 0 0 40px rgba(200, 75, 97, 0.4) !important;
  transform: scale(1.05);
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}



/* ------------------------------------------
   1. MOBILE DEVICE OPTIMIZATIONS (<768px)
   ------------------------------------------ */
@media (max-width: 768px) {
  body {
    overflow-x: hidden;
  }

  .app-header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: space-between;
  }

  .brand-logo {
    font-size: 1.15rem;
  }

  .nav-actions {
    gap: 0.4rem;
  }

  .btn-icon {
    padding: 0.4rem 0.65rem;
    font-size: 0.75rem;
  }

  .main-wrapper {
    padding: 0.75rem 0.5rem;
  }

  /* Single Page Flip Book Mode for Mobile Screens */
  .book-stage {
    width: 100% !important;
    max-width: 440px !important;
    height: calc(100vh - 170px) !important;
    min-height: 440px !important;
    max-height: 640px !important;
    margin: 0 auto;
    perspective: 1500px;
  }

  .flip-book {
    width: 100% !important;
    height: 100% !important;
    margin: 0 auto;
  }

  .base-page-left, .base-page-right, .front, .back {
    width: 100% !important;
    left: 0 !important;
    border-radius: var(--radius-md) !important;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15) !important;
  }

  .base-page-left {
    display: none !important; /* Hide left page in single page view */
  }

  .base-page-right {
    width: 100% !important;
    left: 0 !important;
  }

  .page-photo-frame {
    height: 55% !important;
    margin-bottom: 0.75rem !important;
  }

  .page-caption {
    font-size: 1.15rem !important;
  }

  .page-meta {
    font-size: 0.75rem !important;
  }

  /* Mobile Floating Control Dock */
  .flip-controls {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: 92%;
    max-width: 400px;
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 900;
  }

  .nav-arrow {
    width: 42px;
    height: 42px;
    font-size: 1.1rem;
  }

  .page-counter {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
  }

  .audio-controls-group {
    bottom: 4.8rem;
    right: 1rem;
    gap: 0.4rem;
  }

  .audio-toggle-btn {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
  }

  /* Dashboard Mobile Grid */
  .dashboard-grid, .album-grid {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  .editor-layout {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
  }

  .editor-sidebar {
    order: 2;
  }

  .editor-canvas-stage {
    order: 1;
    min-height: 380px !important;
  }

  .dropzone {
    padding: 1.5rem 1rem !important;
  }
}

/* ------------------------------------------
   2. LAPTOP & TABLET OPTIMIZATIONS (769px - 1919px)
   ------------------------------------------ */
@media (min-width: 769px) and (max-width: 1919px) {
  .book-stage {
    width: 860px;
    height: 580px;
  }

  .base-page-left, .base-page-right {
    width: 430px;
    height: 100%;
  }

  .dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  }
}

/* ------------------------------------------
   3. TV & 10FT EXPERIENCE OPTIMIZATIONS (@media tv & body.tv-force-mode)
   ------------------------------------------ */
@media tv {
  :root {
    --radius-sm: 12px;
    --radius-md: 20px;
    --radius-lg: 32px;
  }

  html {
    font-size: 18px; /* Scale base font size for 10ft distance viewing */
  }

  body {
    background: radial-gradient(circle at 50% 20%, #ffffff 0%, #fae2e6 40%, #f0bdc8 100%);
  }



  .app-header {
    padding: 1.25rem 3rem;
  }

  .brand-logo {
    font-size: 1.8rem;
  }

  .btn-icon, .btn-primary {
    padding: 0.75rem 1.6rem;
    font-size: 1.1rem;
    border-width: 2px;
  }

  /* Scaled 10ft TV Book Stage */
  .book-stage {
    width: 1200px !important;
    height: 760px !important;
    margin: 2rem auto;
  }

  .base-page-left, .base-page-right, .front, .back {
    width: 600px !important;
    height: 100% !important;
  }

  .page-inner-padding {
    padding: 2.5rem !important;
  }

  .page-photo-frame {
    height: 70% !important;
    border-width: 12px !important;
  }

  .page-caption {
    font-size: 2.2rem !important;
    margin-top: 1rem !important;
  }

  .page-meta {
    font-size: 1.2rem !important;
  }

  /* TV Control Dock */
  .flip-controls {
    padding: 0.8rem 2rem;
    gap: 1.5rem;
    border: 2px solid var(--border-gold);
    box-shadow: 0 15px 40px rgba(0,0,0,0.25);
  }

  .nav-arrow {
    width: 64px;
    height: 64px;
    font-size: 1.8rem;
    border-width: 2px;
  }

  .page-counter {
    font-size: 1.25rem;
    padding: 0.6rem 1.5rem;
  }

  .audio-controls-group {
    bottom: 2.5rem;
    right: 3rem;
    gap: 1rem;
  }

  .audio-toggle-btn {
    width: 60px;
    height: 60px;
    font-size: 1.6rem;
    border-width: 2px;
  }

  /* TV Dashboard Layout */
  .dashboard-grid {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 2.5rem;
  }

  .album-card {
    border-width: 2px;
  }

  .album-card-title {
    font-size: 1.6rem;
  }

  .editor-canvas-stage {
    min-height: 600px;
  }
}

/* 4K Ultra TV screens (>=2560px) */
@media (min-width: 2560px) {
  html {
    font-size: 24px;
  }

  .book-stage {
    width: 1600px !important;
    height: 1000px !important;
  }

  .base-page-left, .base-page-right, .front, .back {
    width: 800px !important;
  }
/* Force TV Mode Toggle Override */
body.tv-force-mode {
  font-size: 18px !important;
  background: radial-gradient(circle at 50% 20%, #ffffff 0%, #fae2e6 40%, #f0bdc8 100%) !important;
}

body.tv-force-mode .book-stage {
  width: 1100px !important;
  height: 700px !important;
}
body.tv-force-mode .base-page-left,
body.tv-force-mode .base-page-right,
body.tv-force-mode .front,
body.tv-force-mode .back {
  width: 550px !important;
  height: 100% !important;
}
body.tv-force-mode .btn-icon, body.tv-force-mode .btn-primary {
  padding: 0.7rem 1.4rem !important;
  font-size: 1.05rem !important;
  border-width: 2px !important;
}

