  /* =========================================
     1. Design Tokens & Variables (Luxury Theme)
     ========================================= */
  :root { 
      /* Gold & Amber Palette */
      --accent: #D4AF37; 
      --accent-light: #F5D76E;
      --accent-glow: rgba(212, 175, 55, 0.4);
      --accent-gold-gradient: linear-gradient(135deg, #D4AF37 0%, #F5D76E 50%, #D4AF37 100%);
      
      /* Dark Surface Palette */
      --bg-dark: #050608;
      --surface-1: #0A0C12;
      --surface-2: #12161F;
      
      /* Glassmorphism 3.0 */
      --glass-bg: rgba(10, 12, 18, 0.75);
      --glass-border: rgba(255, 255, 255, 0.12);
      --glass-highlight: rgba(255, 255, 255, 0.05);
      
      /* Typography */
      --text-main: #FFFFFF;
      --text-secondary: rgba(238, 243, 255, 0.7);
      --text-muted: rgba(238, 243, 255, 0.45);
      
    /* Spacing & Borders */
    --radius-xl: 32px;
    --radius-lg: 20px;
    --transition-base: all 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
    
    /* Layout Tokens */
    --sidebar-w: 280px;
    --header-h: 75px;
    --mobile-nav-h: 85px; /* Increased for mobile-native feel */
}

/* =========================================
   2. Global Reset & Body
   ========================================= */
body { 
    background-color: var(--bg-dark); 
    background-image: 
        radial-gradient(circle at 0% 0%, rgba(212, 175, 55, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(0, 194, 255, 0.05) 0%, transparent 50%),
        url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.03'/%3E%3C/svg%3E");
    font-family: 'Outfit', 'IBM Plex Sans Arabic', sans-serif;
    min-height: 100vh; color: var(--text-main); margin: 0; overflow-x: hidden;
    display: flex; flex-direction: column;
    -webkit-user-select: none;
    user-select: none;
    -webkit-font-smoothing: antialiased;
}

/* Shared Mobile-First Layout Classes */
.luxury-app .app-sidebar { display: none; }
.luxury-app .app-main { 
    width: 100%; 
    margin: 0; 
    padding: 0;
    padding-bottom: calc(var(--mobile-nav-h) + 20px);
    overflow-x: hidden;
}

/* Global Mobile Navigation (Luxury) */
.luxury-app .mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    height: var(--mobile-nav-h);
    background: rgba(10, 12, 18, 0.92);
    -webkit-backdrop-filter: blur(25px);
    backdrop-filter: blur(25px);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    display: flex !important;
    align-items: center;
    justify-content: space-around;
    padding: 0 12px;
    padding-bottom: env(safe-area-inset-bottom);
}

.luxury-app .mobile-nav .nav-item {
    all: unset;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: var(--text-muted);
    font-family: inherit;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--transition-base);
    cursor: pointer;
    flex: 1;
    height: 100%;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
}

.luxury-app .mobile-nav .nav-item.active,
.luxury-app .mobile-nav .nav-item:hover {
    color: var(--accent-light);
}

.luxury-app .mobile-nav .nav-item i {
    font-size: 20px;
}

.luxury-app .mobile-nav .plus-btn {
    width: 52px;
    height: 52px;
    background: var(--accent-gold-gradient);
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #000 !important;
    font-size: 20px;
    box-shadow: 0 8px 25px var(--accent-glow);
    transform: translateY(-5px);
    margin: 0 auto;
}

@media (min-width: 1024px) {
    .luxury-app .mobile-nav { display: none !important; }
    .luxury-app { display: flex; flex-direction: row; }
    .luxury-app .app-sidebar { 
        display: flex; 
        position: fixed; 
        right: 0; top: 0; bottom: 0; 
        width: var(--sidebar-w); 
    }
    .luxury-app .app-main { 
        margin-right: var(--sidebar-w); 
        width: calc(100% - var(--sidebar-w));
        padding-bottom: 0;
    }
}

  .app-container { display: flex; flex: 1; height: 100vh; overflow: hidden; flex-direction: column; }
  
  @media (min-width: 1024px) {
      .app-container { flex-direction: row; }
  }

  /* =========================================
     3. Layout Sections
     ========================================= */
  /* Main Preview Area */
  .preview-section {
      flex: 1; display: flex; align-items: center; justify-content: center;
      position: relative; padding: 20px; overflow-y: auto;
      background: radial-gradient(circle at center, #1a1a1a 0%, #000 100%);
      background-size: cover;
      -webkit-backdrop-filter: blur(20px);
      backdrop-filter: blur(20px);
  }
  
  /* Desktop Sidebar */
  .controls-sidebar {
      width: 320px !important; 
      background: rgba(10, 10, 10, 0.85); 
      border-left: 1px solid var(--glass-border);
      padding: 30px; display: none;
      flex-direction: column; gap: 20px; z-index: 50;
      -webkit-backdrop-filter: blur(40px) saturate(180%);
      backdrop-filter: blur(40px) saturate(180%);
      box-shadow: -10px 0 40px rgba(0,0,0,0.5);
  }

  /* =========================================
     Luxury Global Styles
     ========================================= */
  .luxury-theme aside nav a {
      display: flex; align-items: center; gap: 14px;
      padding: 12px 18px; border-radius: 16px;
      color: var(--text-secondary); font-size: 14px; font-weight: 600;
      transition: var(--transition-base);
      border: 1px solid transparent;
  }
  
  .luxury-theme aside nav a:hover {
      background: rgba(255, 255, 255, 0.05);
      color: #FFF; transform: translateX(-4px);
  }
  
  .luxury-theme aside nav a.active {
      background: rgba(212, 175, 55, 0.1);
      border-color: rgba(212, 175, 55, 0.2);
      color: var(--accent-light);
      box-shadow: 0 8px 20px rgba(0,0,0,0.2);
  }
  
  .luxury-theme aside nav a.active i {
      color: var(--accent);
      filter: drop-shadow(0 0 8px var(--accent-glow));
  }

  /* Animations */
  @keyframes fadeInUp {
      from { opacity: 0; transform: translateY(20px); }
      to { opacity: 1; transform: translateY(0); }
  }
  
  .animate-fade-in {
      animation: fadeInUp 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
  }
.story-card {
    width: 100%;
    max-width: 380px;   /* 🔥 المقاس الذهبي للجوال */
    height: auto;
    max-height: 820px;  /* يمنع الطول المبالغ فيه */
    
    border-radius: 32px;
    background: rgba(0,0,0,0.55);
    -webkit-backdrop-filter: blur(22px) saturate(160%);
    backdrop-filter: blur(22px) saturate(160%);
    
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    
    box-shadow:
      0 40px 90px -20px rgba(0,0,0,0.9),
      inset 0 0 0 1px rgba(255,255,255,0.08);
}
@media (max-width: 420px) {
    .story-card {
        max-width: 340px;
        border-radius: 26px;
    }

  .img-uploader { height: 300px; }
@media (max-width: 420px) {
  .img-uploader { height: 260px; }
}


    .ratings-grid {
        padding: 16px;
    }
}
@media (min-width: 1024px) {
    .story-card {
        width: 100%;
        max-width: 100%;
        transform: none;
    }
}


  /* Dynamic Background Layers */
  .card-bg-blur { position: absolute; inset: 0; z-index: 0; }
  #bgCanvas { 
      width: 100%; height: 100%; object-fit: cover; 
      transform: scale(1.2); opacity: 0.6; filter: blur(40px) saturate(140%); 
      transition: opacity 1s ease;
  }
  .card-overlay { 
      position: absolute; inset: 0; z-index: 1;
      background: linear-gradient(to bottom, 
          rgba(0,0,0,0.2) 0%, 
          rgba(0,0,0,0.6) 40%, 
          rgba(0,0,0,0.9) 70%, 
          #000 100%);
  }

  /* =========================================
     5. Image Uploader
     ========================================= */
  .img-uploader { 
      width: 100%; height: 320px; position: relative; z-index: 2;
      cursor: pointer; overflow: hidden; 
      -webkit-mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
      mask-image: linear-gradient(to bottom, black 60%, transparent 100%);
  }
  
  #productImgDiv {
      width: 100%; height: 100%; 
      background-size: cover; background-position: center;
      transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  }
  
  .img-uploader:hover #productImgDiv { transform: scale(1.08); }
  
  /* Hover Shine Effect on Image */
  .img-uploader::after {
      content: ''; position: absolute; inset: 0;
      background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, transparent 40%);
      opacity: 0; transition: opacity 0.3s;
  }
  .img-uploader:hover::after { opacity: 1; }

  /* =========================================
     6. Content & Typography
     ========================================= */
  .card-body { 
      padding: 0 28px; z-index: 10; flex: 1; display: flex; flex-direction: column; 
      margin-top: -60px; /* Pull content up */
  }

  /* Universal Input Reset */
  input, textarea, select { 
      background: transparent; border: none; outline: none; text-align: center; width: 100%;
      font-family: inherit; color: #fff; transition: all 0.3s ease; appearance: none;
  }
  input::placeholder, textarea::placeholder { color: rgba(255,255,255,0.2); transition: color 0.3s; }
  input:focus::placeholder { color: rgba(255,255,255,0.1); }

  /* Title - Gradient Text */
  .title-input { 
      font-size: 28px; font-weight: 800; margin-bottom: 4px; 
      background: linear-gradient(180deg, #fff 0%, #e0e0e0 100%);
      -webkit-background-clip: text;
      background-clip: text;
      -webkit-text-fill-color: transparent;
      filter: drop-shadow(0 4px 12px rgba(0,0,0,0.5));
  }
  .title-input:focus { transform: scale(1.05); -webkit-text-fill-color: #fff; }

  /* Origin */
  .origin-input { 
      font-size: 15px; font-weight: 700; color: var(--accent); 
      margin-bottom: 20px; text-transform: uppercase; 
      text-shadow: 0 0 15px rgba(212, 175, 55, 0.4);
  }

  /* Meta Badges */
  .meta-badge.primary {
  border-color: var(--accent);
  color: #fff;
}
.meta-badge.secondary {
  opacity: 0.6;
}
  .meta-row { display: flex; justify-content: center; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
  
  .meta-badge { 
      font-size: 11px; 
      background: rgba(255,255,255,0.03); 
      backdrop-filter: blur(10px);
      padding: 6px 14px; 
      border-radius: 12px; 
      color: #ccc; 
      border: 1px solid rgba(255,255,255,0.06);
      display: flex; align-items: center; gap: 8px; 
      transition: 0.3s;
      box-shadow: 0 4px 10px rgba(0,0,0,0.2);
  }
  .meta-badge:hover { 
      background: rgba(255,255,255,0.08); 
      border-color: rgba(255,255,255,0.2); 
      transform: translateY(-2px);
  }
  .meta-input { width: auto; min-width: 40px; text-align: center; font-size: 11px; color: #eee; font-weight: 500; }

  /* =========================================
     7. Ratings System (New & Animated)
     ========================================= */
  .ratings-grid { 
      display: flex; flex-direction: column; gap: 10px; margin-top: 10px; 
      background: rgba(255,255,255,0.02); 
      padding: 20px; border-radius: 20px; 
      border: 1px solid rgba(255,255,255,0.04);
      box-shadow: inset 0 2px 20px rgba(0,0,0,0.2);
  }
  
  .rating-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
  .rating-label { font-size: 12px; font-weight: 600; color: var(--accent); width: 80px; text-align: right; }
  .rating-dots { display: flex; gap: 6px; }
  
  /* Animated Dots */
  .dot { 
      width: 24px; height: 10px; border-radius: 4px; 
      background: rgba(255,255,255,0.08); 
      cursor: pointer; position: relative; overflow: hidden;
      transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  
  /* Hover State */
  .dot:hover { transform: scaleY(1.5); background: rgba(255,255,255,0.2); }
  
  /* Active State with Shine Animation */
  .dot.active { 
      background: var(--accent); 
      box-shadow: 0 0 15px var(--accent-glow);
  }
  .dot.active::after {
      content: ''; position: absolute; top:0; left:-100%; width:100%; height:100%;
      background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
      animation: shine 1.5s infinite;
  }
  
  @keyframes shine { 100% { left: 100%; } }
  
  .rating-score { font-size: 11px; font-family: monospace; min-width: 20px; text-align: left; font-weight: bold; }
  .rating-score.good { color:#4ade80; text-shadow: 0 0 10px rgba(74, 222, 128, 0.4); }
  .rating-score.mid { color:#facc15; }
  .rating-score.bad { color:#f97373; }

  /* =========================================
     8. Notes Area
     ========================================= */
  .notes-area {
      margin-top: auto; margin-bottom: 0px; text-align: center;
      border-top: 1px solid rgba(255,255,255,0.06); padding-top: 20px;
  }
  .notes-input { 
      font-size: 12px; color: #ddd; resize: none; line-height: 1.6; 
      font-style: italic; opacity: 0.7; transition: opacity 0.3s;
      height: 65px;
  }
  .notes-input:focus { opacity: 1; }

  /* =========================================
     9. UI Controls (Floating Bar)
     ========================================= */
.floating-bar {
    position: relative;
    bottom: 30px;
    justify-content: center;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 15, 15, 0.8);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    backdrop-filter: blur(20px) saturate(180%);
    padding: 8px 10px;
    border-radius: 50px;
    border: 1px solid rgba(255,255,255,0.1);
    display: flex;
    gap: 10px;
    z-index: 100;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
}
  
  .icon-btn { 
      color: #aaa; font-size: 18px; transition: 0.3s; 
      background: transparent; border: none; cursor: pointer; 
      width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; 
      border-radius: 50%; position: relative;
  }
  .icon-btn:hover { color: white; background: rgba(255,255,255,0.1); transform: translateY(-3px); }
  
  /* Primary Action Button (Camera) */
  .fab-camera {
      background: linear-gradient(135deg, var(--accent) 0%, #F5D76E 100%);
      color: #000; 
      box-shadow: 0 10px 25px rgba(212, 175, 55, 0.3);
      transform: translateY(-8px); width: 56px; height: 56px; font-size: 20px;
  }
 .fab-camera:hover {
    background: #fff;
    transform: translateY(-12px) scale(1.05);
    box-shadow: 0 15px 35px rgba(255, 255, 255, 0.3);
    color: #000;
}
  /* =========================================
     10. Badges & Overlays
     ========================================= */
  .ai-badge {
      position: absolute; top: 25px; right: 25px; 
      background: rgba(0,0,0,0.6); backdrop-filter: blur(12px);
      border: 1px solid var(--accent); color: var(--accent);
      padding: 6px 12px; border-radius: 30px; font-size: 9px; font-weight: 800;
      z-index: 5; display: none; box-shadow: 0 4px 15px rgba(212, 175, 55, 0.2);
      animation: fadeIn 0.5s ease; letter-spacing: 1px;
  }

  .ai-score-chip {
      position:absolute; left:25px; top:25px; z-index:6;
      display:flex; align-items:center; gap:8px;
      background: rgba(0,0,0,0.6); backdrop-filter: blur(12px);
      border-radius: 30px; padding: 4px 12px; 
      border: 1px solid rgba(255,255,255,0.1);
      animation: fadeIn 0.5s ease;
  }
  .ai-score-value { font-family: monospace; font-weight: 800; color: #fff; }
  .ai-score-label { color: #9ca3af; font-size: 9px; font-weight: 600; text-transform: uppercase; }
  
  /* Welcome Empty State */


  /* =========================================
     11. Utilities & Animations
     ========================================= */
  #toast {
      visibility: hidden; min-width: 250px; 
      background-color: rgba(20,20,20,0.95); 
      border: 1px solid var(--glass-border);
      color: #fff; text-align: center; border-radius: 50px; padding: 14px 28px; 
      position: fixed; z-index: 200; left: 50%; bottom: 90px; 
      transform: translateX(-50%); font-size: 13px; font-weight: 600;
      backdrop-filter: blur(10px); 
      box-shadow: 0 10px 30px rgba(0,0,0,0.5); 
      opacity: 0; transition: opacity 0.3s, bottom 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  }
  #toast.show { visibility: visible; opacity: 1; bottom: 110px; }
  
  .display-only { display: none; pointer-events: none; }
  
  /* Smart Loading Overlay */
  #loadingOverlay {
      position: fixed; inset: 0; background: rgba(5,5,5,0.95); z-index: 200;
      display: none; align-items: center; justify-content: center; flex-direction: column; 
      backdrop-filter: blur(15px);
  }
  
  @keyframes fadeIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
  
  /* Responsive Adjustments */
  @media (min-width: 1024px) {
      .controls-sidebar { display: flex; width: 320px; }
      .floating-bar { display: none; }
      .story-card { transform: scale(0.95); }
      #toast.show { bottom: 50px; }
  }


.story-card {
    background: rgba(0,0,0,0.55);
    backdrop-filter: blur(22px) saturate(160%);
}

#captureCard {
    transform-style: preserve-3d;
    will-change: transform;
}
/* تنسيق الأزرار المعطلة */
.disabled-btn {
    opacity: 0.3;
    pointer-events: none; /* يمنع الضغط */
    filter: grayscale(100%); /* يحوّل اللون للرمادي */
    cursor: not-allowed;
}
@keyframes shine {
    100% { transform: translateX(100%); }
}
.group-hover\:animate-shine:hover {
    animation: shine 1.5s infinite;
}

/* تنسيق حالة الظهور للقائمة */
.dropdown-active {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(0) !important;
}
.arrow-rotate {
    transform: rotate(180deg);
}
@media (min-width: 1024px) {
  .desktop-menu .menu-item-glass {
    display: none;
  }
}
/* ===============================
   INSTAGRAM-STYLE BOTTOM NAV (RTL)
=============================== */

.insta-bottom-nav{
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    background: rgba(10,10,10,0.92);
    -webkit-backdrop-filter: blur(25px) saturate(180%);
    backdrop-filter: blur(25px) saturate(180%);
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 9999;
}

/* زر */
.insta-nav-btn{
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #e5e5e5;
    font-size: 20px;
    border-radius: 50%;
    transition: all .25s ease;
    position: relative;
}

/* Hover / Active */
.insta-nav-btn:hover{
    color: white;
    transform: translateY(-2px);
}

/* زر الإضافة (الوسط) */
.insta-nav-btn.add{
    background: linear-gradient(135deg, #D4AF37, #F5D76E);
    color: #000;
    width: 52px;
    height: 52px;
    font-size: 22px;
    box-shadow: 0 10px 30px rgba(212,175,55,.45);
    transform: translateY(-18px);
}

.insta-nav-btn.add:hover{
    transform: translateY(-22px) scale(1.05);
}

/* مؤشر الصفحة الحالية */
.insta-nav-btn.active::after{
    content:'';
    position:absolute;
    bottom:-6px;
    width:6px;
    height:6px;
    background:#D4AF37;
    border-radius:50%;
}

/* فراغ أسفل الصفحة حتى لا يغطي المحتوى */
body{
    padding-bottom: 80px;
}

/* إخفاء أي floating bar قديم */
.floating-bar,
.card-actions-desktop{
    display: none !important;
}
/* ===============================
   TOOLTIP (Bottom Nav + Icons)
=============================== */
.nav-tooltip{
  position: absolute;
  bottom: 60px;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(10px);
  color: #fff;
  font-size: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: all .2s ease;
  border: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
}

/* سهم صغير */
.nav-tooltip::after{
  content:'';
  position:absolute;
  top:100%;
  left:50%;
  transform:translateX(-50%);
  border:6px solid transparent;
  border-top-color: rgba(0,0,0,0.85);
}

/* Hover */
.group:hover .nav-tooltip{
  opacity: 1;
  transform: translateY(0);
}
/* زر معطّل – محفوظ المكان */
.insta-nav-btn.disabled-btn{
  opacity: 0.35;
  filter: grayscale(100%);
  pointer-events: none;
}

/* Tooltip حتى لو معطل */
.insta-nav-btn.disabled-btn .nav-tooltip{
  opacity: 0;
}

/* Hover للزر المفعّل فقط */
.insta-nav-btn:not(.disabled-btn):hover{
  color: #fff;
  transform: translateY(-2px);
}
/* ===============================
   TOOLTIP – FINAL (RTL Friendly)
=============================== */
.insta-nav-btn{
  position: relative; /* مهم جداً */
}

/* Tooltip */
.nav-tooltip{
  position: absolute;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(12px);
  color: #fff;
  font-size: 10px;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: all .2s ease;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 10px 25px rgba(0,0,0,0.6);
  z-index: 9999;
}

/* سهم */
.nav-tooltip::after{
  content:'';
  position:absolute;
  top:100%;
  left:50%;
  transform:translateX(-50%);
  border:6px solid transparent;
  border-top-color: rgba(0,0,0,0.85);
}

/* Hover */
.insta-nav-btn:hover .nav-tooltip{
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#roastInput {
  cursor: default;
  opacity: 0.8;
}

@keyframes pulseIntro {
                0% { transform:scale(1); box-shadow:0 0 25px rgba(212,175,55,0.3); }
                50% { transform:scale(1.1); box-shadow:0 0 60px rgba(212,175,55,0.6); }
                100% { transform:scale(1); box-shadow:0 0 25px rgba(212,175,55,0.3); }
            }
            @keyframes moveSpotlight {
                0%   { transform:translate(-150px, -150px); }
                50%  { transform:translate(150px, 100px); }
                100% { transform:translate(-150px, -150px); }
            }
            @keyframes pulseGlow {
                0% {transform:scale(1); box-shadow:0 0 25px rgba(212,175,55,0.25);}
                50% {transform:scale(1.08); box-shadow:0 0 55px rgba(212,175,55,0.55);}
                100% {transform:scale(1); box-shadow:0 0 25px rgba(212,175,55,0.25);}
            }

@keyframes fade-in-up {
        from { opacity: 0; transform: translateY(20px); }
        to { opacity: 1; transform: translateY(0); }
    }
    .animate-fade-in-up {
        animation: fade-in-up 0.8s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    }


/* ===== UI V2 Refresh (app.php only) ===== */
body.ui-v2 {
  --accent: #d4af37;
  --ink: #f6f1e1;
  --bg-0: #07080d;
  --bg-1: #0d111a;
  --bg-2: #1a2230;
  background:
    radial-gradient(1200px 600px at 15% 15%, rgba(212,175,55,.12), transparent 60%),
    radial-gradient(1000px 500px at 85% 90%, rgba(0,168,255,.08), transparent 60%),
    linear-gradient(150deg, var(--bg-0), var(--bg-1) 45%, var(--bg-2));
  color: var(--ink);
}

.ui-v2 .preview-section {
  background: transparent;
  padding: clamp(16px, 4vw, 36px);
}

.ui-v2 .story-card {
  max-width: 430px;
  border-radius: 36px;
  border: 1px solid rgba(212,175,55,.22);
  background: linear-gradient(180deg, rgba(10,12,18,.86), rgba(8,10,14,.95));
  box-shadow:
    0 30px 90px rgba(0, 0, 0, .62),
    0 0 0 1px rgba(255,255,255,.03) inset,
    0 0 120px rgba(212,175,55,.08);
}

.ui-v2 .story-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(520px 220px at 50% -10%, rgba(212,175,55,.20), transparent 70%),
    linear-gradient(120deg, transparent 20%, rgba(255,255,255,.03) 45%, transparent 75%);
}

.ui-v2 .img-uploader {
  height: 340px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  mask-image: linear-gradient(to bottom, black 66%, transparent 100%);
  -webkit-mask-image: linear-gradient(to bottom, black 66%, transparent 100%);
}

.ui-v2 .card-body {
  margin-top: -48px;
  padding: 0 24px 18px;
}

.ui-v2 .title-input {
  font-size: clamp(26px, 5vw, 33px);
  letter-spacing: .2px;
  text-shadow: 0 8px 20px rgba(0,0,0,.55);
}

.ui-v2 .origin-input {
  font-size: 13px;
  letter-spacing: 2px;
  opacity: .95;
}

.ui-v2 .meta-row {
  gap: 10px;
  margin-bottom: 16px;
}

.ui-v2 .meta-badge {
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.1);
  background: linear-gradient(170deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  box-shadow: 0 10px 22px rgba(0,0,0,.24);
}

.ui-v2 .meta-badge:focus-within,
.ui-v2 .meta-badge:hover {
  border-color: rgba(212,175,55,.45);
  transform: translateY(-1px);
}

.ui-v2 #recipeCard,
.ui-v2 #brewExplanation {
  border-color: rgba(212,175,55,.22) !important;
  background: linear-gradient(170deg, rgba(212,175,55,.08), rgba(255,255,255,.03)) !important;
  border-radius: 16px;
}

.ui-v2 .notes-area {
  border-top: 1px solid rgba(255,255,255,.1);
  padding-top: 14px;
}

.ui-v2 .notes-input {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding: 10px 14px;
  min-height: 72px;
}

.ui-v2 .ratings-grid {
  margin-top: 14px;
  gap: 12px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,.08);
  background: linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.015));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 10px 26px rgba(0,0,0,.25);
}

.ui-v2 .rating-label {
  width: 92px;
  font-size: 12px;
  font-weight: 700;
  color: #f4dd8a;
}

.ui-v2 .dot {
  width: 28px;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.09);
}

.ui-v2 .dot.active {
  background: linear-gradient(90deg, #f0cd5f, #d4af37);
  box-shadow: 0 0 12px rgba(212,175,55,.45);
}

.ui-v2 .desktop-menu {
  right: 20px !important;
  gap: 12px !important;
}

.ui-v2 .desktop-menu .menu-item-glass,
.ui-v2 .desktop-menu button[onclick*="toggleUserMenu"] {
  border: 1px solid rgba(255,255,255,.12) !important;
  background: linear-gradient(160deg, rgba(255,255,255,.08), rgba(255,255,255,.03)) !important;
  border-radius: 16px !important;
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.ui-v2 .desktop-menu .menu-item-glass span {
  opacity: 1 !important;
  font-size: 12px;
  color: rgba(255,255,255,.92);
}

.ui-v2 .card-actions-desktop .group {
  border: 1px solid rgba(212,175,55,.28) !important;
  background: linear-gradient(160deg, rgba(0,0,0,.72), rgba(20,20,20,.55)) !important;
  box-shadow: 0 14px 40px rgba(0,0,0,.36), 0 0 32px rgba(212,175,55,.12);
}

.ui-v2 .insta-bottom-nav {
  height: calc(72px + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid rgba(212,175,55,.22);
  background: linear-gradient(180deg, rgba(8,10,14,.92), rgba(7,8,13,.98));
}

.ui-v2 .insta-nav-btn {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(255,255,255,.03);
  border: 1px solid transparent;
}

.ui-v2 .insta-nav-btn.active {
  border-color: rgba(212,175,55,.45);
  color: #f6dc81;
  background: rgba(212,175,55,.10);
}

.ui-v2 .insta-nav-btn.add {
  border-radius: 16px;
  width: 56px;
  height: 56px;
  transform: translateY(-20px);
}

.ui-v2 .insta-nav-btn.add:hover {
  transform: translateY(-22px) scale(1.04);
}

@media (max-width: 768px) {
  .ui-v2 .preview-section {
    padding-top: 8px;
  }

  .ui-v2 .story-card {
    max-width: 100%;
    border-radius: 24px;
  }

  .ui-v2 .img-uploader {
    height: 280px;
  }

  .ui-v2 .card-body {
    padding: 0 14px 14px;
    margin-top: -32px;
  }
}
/* ===== Desktop UX Refinement (Large Screens) ===== */
@media (min-width: 1024px) {
  .ui-v2 .app-container {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 0;
    min-height: 100vh;
  }

  .ui-v2 .desktop-menu {
    display: flex !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
    z-index: 20;
    width: 300px;
    height: 100vh;
    padding: 28px 18px;
    margin: 0;
    border-left: 1px solid rgba(255,255,255,.08);
    background: linear-gradient(180deg, rgba(10,12,18,.92), rgba(8,10,15,.98));
    backdrop-filter: blur(16px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
    justify-content: flex-start;
    overflow-y: auto;
  }

  .ui-v2 .desktop-menu .group,
  .ui-v2 .desktop-menu .menu-item-glass {
    width: 100%;
  }

  .ui-v2 .desktop-menu .menu-item-glass {
    justify-content: space-between !important;
    padding: 12px 14px !important;
    border-radius: 14px !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    background: rgba(255,255,255,.03) !important;
  }

  .ui-v2 .desktop-menu .menu-item-glass span {
    opacity: 1 !important;
    order: 1;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .1px;
  }

  .ui-v2 .desktop-menu .menu-item-glass > div {
    order: 2;
  }

  .ui-v2 .desktop-menu #userDropdown {
    position: static !important;
    width: 100% !important;
    margin-top: 10px !important;
    transform: none !important;
    border-radius: 12px;
  }

  .ui-v2 .desktop-menu #userDropdown a {
    font-size: 12px;
  }

  .ui-v2 .preview-section {
    padding: 28px 32px;
    align-items: center;
    justify-content: center;
  }

  .ui-v2 .story-card {
    max-width: 500px;
    width: min(92vw, 500px);
    max-height: 92vh;
    border-radius: 34px;
  }

  .ui-v2 .card-actions-desktop {
    margin-top: 16px;
    transform: none;
  }

  .ui-v2 .card-actions-desktop .group {
    border-radius: 18px !important;
    padding: 10px 14px !important;
  }
}
/* ===== UI V3: Full Redesign (Desktop + Mobile) ===== */
body.ui-v3 {
  --accent: #f0c861;
  --accent-2: #00c2ff;
  --bg-900: #070b12;
  --bg-800: #0d1522;
  --bg-700: #151f2f;
  --card-bg: rgba(10, 14, 22, 0.82);
  --card-border: rgba(255, 255, 255, 0.12);
  --text: #eef3ff;
  --muted: rgba(233, 238, 255, 0.62);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(240,200,97,.22), transparent 60%),
    radial-gradient(900px 600px at 95% 110%, rgba(0,194,255,.16), transparent 65%),
    linear-gradient(150deg, var(--bg-900), var(--bg-800) 45%, var(--bg-700));
  min-height: 100vh;
}

.ui-v3 .app-container {
  min-height: calc(100vh - 100px);
  height: auto;
  overflow: visible;
}

.ui-v3 .preview-section {
  background: transparent;
  padding: clamp(12px, 2.6vw, 34px);
  overflow: visible;
}

.ui-v3 #ambientGlow {
  opacity: .75 !important;
  filter: blur(120px);
}

.ui-v3 .story-card {
  width: min(100%, 420px);
  max-width: 420px;
  max-height: 88vh;
  border-radius: 30px;
  border: 1px solid var(--card-border);
  background: linear-gradient(180deg, rgba(15,20,30,.92), rgba(8,11,18,.96));
  box-shadow:
    0 35px 90px rgba(0, 0, 0, .58),
    0 0 0 1px rgba(255,255,255,.04) inset,
    0 0 80px rgba(0,194,255,.08),
    0 0 70px rgba(240,200,97,.08);
}

.ui-v3 .story-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    radial-gradient(420px 140px at 50% -10%, rgba(240,200,97,.26), transparent 75%),
    linear-gradient(130deg, transparent 20%, rgba(255,255,255,.05) 50%, transparent 78%);
}

.ui-v3 .img-uploader {
  height: 300px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.ui-v3 .card-body {
  margin-top: -34px;
  padding: 0 16px 16px;
  position: relative;
  z-index: 9;
}

.ui-v3 #recipePresetTabs {
  scrollbar-width: thin;
}

.ui-v3 #recipePresetTabs::-webkit-scrollbar {
  height: 6px;
}

.ui-v3 #recipePresetTabs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}

.ui-v3 .recipe-tab {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.04);
  color: rgba(238, 243, 255, 0.88);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 11px;
  line-height: 1;
  transition: all .2s ease;
}

.ui-v3 .recipe-tab.active {
  border-color: rgba(240, 200, 97, 0.5);
  background: rgba(240, 200, 97, 0.16);
  color: #f7deb4;
}

.ui-v3 .recipe-tab:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ui-v3 .title-input {
  font-size: clamp(26px, 4.2vw, 34px);
  color: #fff;
  -webkit-text-fill-color: #fff;
  text-shadow: 0 12px 18px rgba(0,0,0,.45);
}

.ui-v3 .origin-input {
  font-size: 12px;
  letter-spacing: 2px;
  color: #f4d476;
  margin-bottom: 14px;
}

.ui-v3 .meta-row {
  gap: 8px;
  margin-bottom: 12px;
}

.ui-v3 .meta-badge {
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.11);
  background: linear-gradient(165deg, rgba(255,255,255,.08), rgba(255,255,255,.02));
  box-shadow: 0 10px 20px rgba(0,0,0,.22);
}

.ui-v3 .meta-input,
.ui-v3 #methodInput,
.ui-v3 #roasterySearch,
.ui-v3 #productLinkInput {
  color: #f3f7ff !important;
}

.ui-v3 #roasterySearch,
.ui-v3 #productLinkInput,
.ui-v3 .notes-input {
  background: rgba(255,255,255,.04) !important;
  border: 1px solid rgba(255,255,255,.1) !important;
  border-radius: 12px;
}

.ui-v3 #roasteryResults {
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 14px 35px rgba(0,0,0,.45);
}

.ui-v3 #brewExplanation,
.ui-v3 #recipeCard {
  border: 1px solid rgba(240,200,97,.26) !important;
  background: linear-gradient(160deg, rgba(240,200,97,.10), rgba(255,255,255,.02)) !important;
  border-radius: 14px;
}

.ui-v3 .notes-area {
  border-top: 1px solid rgba(255,255,255,.1);
  margin-top: 12px;
  padding-top: 12px;
}

.ui-v3 .notes-input {
  min-height: 76px;
  padding: 10px 12px;
}

.ui-v3 .ratings-grid {
  margin-top: 12px;
  padding: 14px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.1);
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.015));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05), 0 16px 30px rgba(0,0,0,.28);
}

.ui-v3 .rating-label {
  color: #f6db87;
  font-size: 11px;
  width: 84px;
}

.ui-v3 .dot {
  width: 22px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
}

.ui-v3 .dot.active {
  background: linear-gradient(90deg, #f4d46c, #d8aa33);
  box-shadow: 0 0 10px rgba(240,200,97,.55);
}

.ui-v3 #toast {
  border: 1px solid rgba(255,255,255,.15);
  background: rgba(7, 10, 16, .9);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.ui-v3     .mobile-nav {
        display: flex !important;
        position: fixed;
        left: 15px; right: 15px; bottom: 15px;
        height: var(--mobile-nav-h); 
        border-radius: 28px;
        background: var(--glass-bg);
        -webkit-backdrop-filter: blur(40px) saturate(180%);
        backdrop-filter: blur(40px) saturate(180%);
        border: 1px solid var(--glass-border);
        box-shadow: 0 25px 60px rgba(0,0,0,0.6);
        justify-content: space-around; align-items: center;
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 1000;
    }

.ui-v3 #loadingOverlay {
  background: linear-gradient(180deg, rgba(7,11,18,.95), rgba(3,5,8,.98));
}

.ui-v3 .floating-bar { display: none !important; }

  /* ========== LUXURY BOTTOM NAV (Mobile Only) ========== */
  @media (max-width: 1023px) {
    .mobile-nav {
        display: flex !important;
        position: fixed;
        left: 20px; right: 20px; bottom: 20px;
        height: 72px; border-radius: 24px;
        background: var(--glass-bg);
        -webkit-backdrop-filter: blur(30px) saturate(160%);
        backdrop-filter: blur(30px) saturate(160%);
        border: 1px solid var(--glass-border);
        box-shadow: 0 20px 50px rgba(0,0,0,0.5);
        justify-content: space-around; align-items: center;
        padding-bottom: env(safe-area-inset-bottom);
        z-index: 1000;
    }
    
    .nav-item {
        display: flex; flex-direction: column; align-items: center; gap: 6px;
        color: var(--text-muted); font-size: 11px; font-weight: 800;
        transition: var(--transition-base);
        flex: 1;
    }
    
    .nav-item.active { color: var(--accent); }
    .nav-item i { font-size: 24px; transition: var(--transition-base); }
    .nav-item.active i { transform: translateY(-3px); filter: drop-shadow(0 0 15px var(--accent-glow)); }

    .plus-btn {
        width: 64px; height: 64px; border-radius: 22px;
        background: var(--accent-gold-gradient);
        display: flex; align-items: center; justify-content: center;
        color: #000; font-size: 28px;
        transform: translateY(-22px);
        box-shadow: 0 18px 40px rgba(212, 175, 55, 0.5);
        transition: var(--transition-base);
    }
    .plus-btn:active { transform: translateY(-22px) scale(0.85); }
  }

.ui-v3 .desktop-menu {
  display: none !important;
}

.ui-v3 .card-actions-desktop {
  display: none !important;
}

@media (min-width: 1024px) {
  body.ui-v3 { padding-bottom: 0; }

  .ui-v3 .app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    min-height: 100vh;
    height: 100vh;
  }

  .ui-v3 .desktop-menu {
    display: flex !important;
    position: relative !important;
    top: auto !important;
    right: auto !important;
    transform: none !important;
    z-index: 25;
    width: 320px;
    height: 100vh;
    margin: 0;
    padding: 24px 16px;
    gap: 10px !important;
    border-left: 1px solid rgba(255,255,255,.08);
    background:
      radial-gradient(500px 260px at 20% -10%, rgba(240,200,97,.14), transparent 70%),
      linear-gradient(180deg, rgba(9,12,19,.9), rgba(7,10,16,.98));
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    overflow-y: auto;
  }

  .ui-v3 .desktop-menu .group,
  .ui-v3 .desktop-menu .menu-item-glass {
    display: flex !important;
    width: 100%;
  }

  .ui-v3 .desktop-menu .menu-item-glass {
    justify-content: space-between !important;
    align-items: center;
    border-radius: 14px !important;
    border: 1px solid rgba(255,255,255,.1) !important;
    background: linear-gradient(170deg, rgba(255,255,255,.08), rgba(255,255,255,.025)) !important;
    padding: 12px 14px !important;
  }

  .ui-v3 .desktop-menu .menu-item-glass span {
    opacity: 1 !important;
    font-size: 13px;
    font-weight: 700;
    color: #f7fbff;
  }

  .ui-v3 .desktop-menu #userDropdown {
    position: static !important;
    width: 100% !important;
    margin-top: 8px !important;
    transform: none !important;
    border: 1px solid rgba(255,255,255,.1);
    background: rgba(6,9,14,.95);
    border-radius: 12px;
  }

  .ui-v3 .desktop-menu #userDropdown a {
    font-size: 12px;
  }

  .ui-v3 .preview-section {
    align-items: center;
    justify-content: center;
    padding: 26px;
  }

  .ui-v3 .story-card {
    width: min(95%, 720px);
    max-width: 720px;
    max-height: 88vh;
    border-radius: 40px;
    margin-right: 20px;
  }

  .ui-v3 .img-uploader {
    height: 340px;
  }

  .ui-v3 .card-body {
    margin-top: -42px;
    padding: 0 20px 16px;
  }

  .ui-v3 .insta-bottom-nav {
    display: none !important;
  }

  .ui-v3 .card-actions-desktop {
    display: flex !important;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px;
    z-index: 30;
    margin: 0;
  }

  .ui-v3 .card-actions-desktop > .group {
    border-radius: 18px !important;
    border: 1px solid rgba(240,200,97,.28) !important;
    background: linear-gradient(160deg, rgba(9,12,19,.88), rgba(8,11,18,.95)) !important;
    box-shadow: 0 16px 36px rgba(0,0,0,.38), 0 0 30px rgba(240,200,97,.10);
  }
}

/* =========================================
   14. NATIVE MOBILE APP OVERRIDES (PWA)
   ========================================= */
body {
    -webkit-tap-highlight-color: transparent !important;
    overscroll-behavior-y: none !important; /* يمنع السحب العشوائي للصفحة في الايفون */
    touch-action: pan-y;
}

/* دعم شريط القوائم السفلي في الآيفون (Safe Area) */
.insta-bottom-nav,
.ui-v2 .insta-bottom-nav {
    height: calc(64px + env(safe-area-inset-bottom, 0px)) !important;
    padding-bottom: env(safe-area-inset-bottom, 0px) !important;
}

/* دعم الفراغ السفلي الكلي (Safety Padding) */
body {
    padding-bottom: calc(120px + env(safe-area-inset-bottom, 0px)) !important;
}

@media (min-width: 1024px) {
    body { padding-bottom: 0 !important; }
}

/* ===============================
   15. LUXURY COMPONENT STYLES
   =============================== */
.luxury-app .story-card {
    border: 1px solid rgba(255,255,255,0.11);
    border-radius: 34px;
    box-shadow: 0 34px 96px -24px rgba(0,0,0,0.8), 0 0 0 1px rgba(255,255,255,0.03) inset, 0 0 70px rgba(212,175,55,0.08);
}
.luxury-app .panel-card {
    border: 1px solid rgba(255,255,255,0.1);
    background: linear-gradient(170deg, rgba(14,18,28,0.9), rgba(10,14,22,0.95));
    border-radius: 22px;
    padding: 22px;
}
.luxury-app .split-grid {
    display: grid;
    grid-template-columns: minmax(410px, 520px) 1fr;
    max-width: 1320px;
    gap: clamp(14px, 2vw, 28px);
}
/* --- Story Export Special State --- */
.story-card.is-exporting {
    width: 1080px !important;
    height: 1920px !important;
    max-width: none !important;
    max-height: none !important;
    border-radius: 0 !important;
    margin: 0 !important;
    transform: none !important;
    position: fixed !important;
    top: 0; left: -9999px; /* Hide from screen but render in DOM */
    z-index: 9999;
    background: #000 !important;
}
.story-card.is-exporting .card-inner {
    padding: 60px !important;
}
.story-card.is-exporting .title-input {
    font-size: 84px !important;
}
.story-card.is-exporting .ai-score-chip {
    top: 60px; left: 60px;
    padding: 20px 40px;
    border-radius: 40px;
}
.story-card.is-exporting .ai-score-value {
    font-size: 80px;
}

@media (max-width: 1023px) {
    .luxury-app .split-grid { display: block; width: 100%; }
    .luxury-app .story-card { 
        border-radius: 0; /* Full bleed on mobile */
        width: 100%;
        max-width: none;
        box-shadow: none;
        border: none;
    }
}

.recipe-tab {
    padding: 6px 14px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.04);
    color: #9ca3af;
    font-size: 11px;
    font-weight: 600;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
}
.recipe-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}
.recipe-tab.active {
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.15), rgba(212, 175, 55, 0.05));
    border-color: rgba(212, 175, 55, 0.4);
    color: #D4AF37;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.1);
}
