/* ═══════════════════════════════════════════════════════════════
   SPACE STUDIO — Design System v2
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Cairo:wght@400;500;600;700&display=swap');

:root {
  --bg:         #080810;
  --surface:    #0f0f16;
  --card:       #141420;
  --border:     rgba(255,255,255,0.06);
  --border-h:   rgba(124,58,237,0.35);
  --purple:     #7c3aed;
  --purple-l:   #9f67ff;
  --green:      #22c55e;
  --red:        #ef4444;
  --text:       #f0eeff;
  /* Raised from 0.38 / 0.50 to meet WCAG AA (>=4.5:1 on dark bg) */
  --muted:      #8a87a0;
  --muted-l:    #b5b2c8;

  /* Unified nav height — used everywhere instead of magic numbers 52/56/60/64 */
  --nav-h: 64px;
  /* Verify-banner height — 0 when no banner; set to 42px by body class */
  --verify-banner-h: 0px;

  /* ── Backward-compat aliases (old templates) ── */
  --text-primary:   var(--text);
  --text-muted:     var(--muted);
  --border-default: var(--border);
  --bg-card:        var(--card);
  --bg-elevated:    var(--surface);
  /* Legacy purple (was misleadingly named --gold). Keep for one release. */
  --accent:         var(--purple-l);
  --accent-bg:      rgba(124,58,237,0.10);
  --accent-border:  rgba(124,58,237,0.30);
  --gold:           var(--accent);
  --gold-bg:        var(--accent-bg);
  --gold-border:    var(--accent-border);
  --purple-glow:    rgba(124,58,237,0.12);
  --purple-border:  rgba(124,58,237,0.20);
  --purple-light:   var(--purple-l);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[dir="rtl"] { font-family: 'Cairo', 'Inter', system-ui, sans-serif; }

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; font-size: inherit; }
input, textarea, select { font-family: inherit; }

/* ─── SCROLLBAR ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }

/* ─── TOP NAV ───────────────────────────────────────────────── */
.top-nav {
  height: 56px;
  position: sticky; top: 0; z-index: 200;
  background: rgba(8,8,16,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex; align-items: center;
  padding: 0 20px; gap: 0;
}

.nav-logo {
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0; margin-right: 32px;
}
.nav-logo img { height: 28px; width: auto; }
.nav-logo-text { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.nav-logo-plus { color: var(--purple-l); }

.nav-tabs {
  display: flex; align-items: center; flex: 1;
  justify-content: center; gap: 2px;
}
.nav-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 0 16px; height: 56px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  position: relative; white-space: nowrap;
}
.nav-tab svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.nav-tab:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.nav-tab.active { color: var(--text); border-bottom-color: var(--purple); }
.nav-tab-new {
  font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
  background: var(--purple); color: #fff;
  padding: 1px 5px; border-radius: 4px;
  position: absolute; top: 10px; right: 4px;
}

.nav-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }

.nav-icon-btn {
  /* 36px visual, but 44x44 tap target on mobile via padding */
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: color 0.15s, background 0.15s;
}
@media (max-width: 768px) {
  .nav-icon-btn { width: 44px; height: 44px; }
}
.nav-icon-btn:hover { color: var(--text); background: rgba(255,255,255,0.06); }
.nav-icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; }

.nav-credits {
  display: flex; align-items: center; gap: 6px;
  background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.2);
  color: var(--green); font-size: 13px; font-weight: 600;
  padding: 5px 12px; border-radius: 20px;
  transition: background 0.15s;
}
.nav-credits:hover { background: rgba(34,197,94,0.16); }
.nav-credits svg { width: 13px; height: 13px; stroke: currentColor; fill: none; stroke-width: 2; }

/* ─── ADMIN NAV BUTTON ───────────────────────────────────── */
.nav-admin-wrap { position: relative; }
.nav-admin-btn {
  display: flex; align-items: center; gap: 5px;
  background: rgba(109,40,217,0.15); border: 1px solid rgba(139,92,246,0.35);
  color: #a78bfa; font-size: 11px; font-weight: 700;
  padding: 5px 11px; border-radius: 7px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  letter-spacing: .3px; white-space: nowrap;
}
.nav-admin-btn:hover { background: rgba(109,40,217,0.28); border-color: rgba(139,92,246,0.6); color: #c4b5fd; }
.nav-admin-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 6px; min-width: 200px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  display: none; z-index: 400;
}
.nav-admin-dropdown.open { display: block; }
.nav-tab-new {
  font-size: 9px; font-weight: 700; color: #a78bfa;
  background: rgba(139,92,246,0.15); border: 1px solid rgba(139,92,246,0.3);
  padding: 1px 5px; border-radius: 4px; letter-spacing: .4px;
}

.nav-avatar-wrap { position: relative; }
.nav-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-l));
  color: #fff; font-size: 13px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.15s;
}
.nav-avatar:hover { opacity: 0.85; }

.nav-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  background: var(--surface); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 6px; min-width: 200px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.04);
  display: none; z-index: 300;
}
.nav-dropdown.open { display: block; }
.nav-dropdown-user { padding: 10px 12px 8px; }
.nav-dropdown-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.nav-dropdown-email { font-size: 11px; color: var(--muted); }
.nav-dropdown-sep { height: 1px; background: var(--border); margin: 4px 0; }
.nav-dropdown-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px;
  font-size: 13px; color: var(--muted-l);
  transition: background 0.12s, color 0.12s;
}
.nav-dropdown-item svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.nav-dropdown-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-dropdown-danger:hover { color: var(--red); }

.nav-btn-ghost {
  font-size: 13px; font-weight: 500; color: var(--muted-l);
  padding: 7px 14px; border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  transition: border-color 0.15s, color 0.15s;
}
.nav-btn-ghost:hover { border-color: rgba(255,255,255,0.58); color: var(--text); }

.nav-btn-primary {
  font-size: 13px; font-weight: 600; color: #fff;
  background: var(--purple); padding: 7px 16px; border-radius: 8px;
  transition: background 0.15s, transform 0.1s;
}
.nav-btn-primary:hover { background: var(--purple-l); }
.nav-btn-primary:active { transform: scale(0.97); }

/* ─── APP LAYOUT ────────────────────────────────────────────── */
.app-layout {
  display: flex; height: calc(100dvh - var(--nav-h)); overflow: hidden;
}

/* Left Panel */
.left-panel {
  width: 260px; min-width: 260px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto; overflow-x: hidden;
  transition: width 0.2s ease, min-width 0.2s ease;
}
.left-panel.collapsed { width: 60px; min-width: 60px; }

.panel-section { padding: 14px 14px 0; }
.panel-section + .panel-section { margin-top: 6px; }
.panel-bottom { flex: 1; }

/* Sub-tabs */
.sub-tabs {
  display: flex; background: var(--card);
  border-radius: 8px; padding: 3px; gap: 2px;
}
.sub-tab {
  flex: 1; text-align: center; padding: 6px 8px;
  border-radius: 6px; font-size: 12px; font-weight: 500;
  color: var(--muted); cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.sub-tab.active { background: rgba(124,58,237,0.2); color: var(--text); }

/* Preset card */
.preset-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px;
}
.preset-card-label { font-size: 10px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.preset-card-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.preset-card-name { font-size: 14px; font-weight: 600; color: var(--text); }
.preset-card-model { font-size: 11px; color: var(--muted); margin-top: 2px; }
.btn-change {
  font-size: 11px; font-weight: 600; color: var(--purple-l);
  background: rgba(124,58,237,0.12); padding: 4px 10px;
  border-radius: 6px; border: 1px solid rgba(124,58,237,0.2);
  transition: background 0.12s;
}
.btn-change:hover { background: rgba(124,58,237,0.2); }

/* Frame zones */
.frame-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.frame-label { font-size: 11px; font-weight: 500; color: var(--muted); display: block; margin-bottom: 6px; }
.frame-zone {
  aspect-ratio: 16/9; border: 1.5px dashed rgba(255,255,255,0.1);
  border-radius: 8px; cursor: pointer; overflow: hidden;
  position: relative; display: flex; align-items: center; justify-content: center;
  background: var(--card); transition: border-color 0.15s;
}
.frame-zone:hover { border-color: rgba(124,58,237,0.4); }
.frame-zone img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.frame-zone.has-image img { display: block; }
.frame-zone .placeholder { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.frame-zone.has-image .placeholder { display: none; }
.frame-zone .placeholder .icon { font-size: 18px; opacity: 0.4; }
.frame-zone input[type=file] { display: none; }

/* Duration chips */
.duration-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.duration-chips, .aspect-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.duration-chip, .aspect-chip {
  padding: 5px 12px; border-radius: 6px; font-size: 12px; font-weight: 500;
  color: var(--muted); background: var(--card);
  border: 1px solid var(--border); cursor: pointer;
  transition: all 0.12s;
}
.duration-chip:hover, .aspect-chip:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }
.duration-chip.active, .aspect-chip.active {
  color: #fff; background: var(--purple); border-color: var(--purple);
}

/* Toggle */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle-label { font-size: 13px; font-weight: 500; color: var(--text); }
.toggle-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; border-radius: 10px;
  background: rgba(255,255,255,0.1); cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: ''; position: absolute; height: 14px; width: 14px;
  left: 3px; top: 3px; border-radius: 50%;
  background: #fff; transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--purple); }
.toggle input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Prompt textarea */
.prompt-wrap { position: relative; }
.prompt-textarea {
  width: 100%; min-height: 90px; max-height: 180px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px; color: var(--text);
  font-size: 13px; line-height: 1.6; resize: vertical;
  transition: border-color 0.15s;
}
.prompt-textarea:focus { border-color: rgba(124,58,237,0.4); outline: none; }
.prompt-footer { display: flex; align-items: center; justify-content: flex-end; padding-top: 6px; }
.char-count { font-size: 10px; color: var(--muted); }

/* Model selector */
.model-selector-btn {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 14px; cursor: pointer;
  transition: border-color 0.15s; width: 100%;
}
.model-selector-btn:hover { border-color: rgba(124,58,237,0.3); }
.model-selector-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.model-selector-name { font-size: 14px; font-weight: 600; color: var(--text); }
.model-selector-arrow { color: var(--muted); font-size: 16px; }
.model-selector-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.model-tag {
  font-size: 9px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  background: rgba(124,58,237,0.12); color: var(--purple-l);
  border: 1px solid rgba(124,58,237,0.2); padding: 2px 7px; border-radius: 4px;
}
.model-selector-price { font-size: 12px; color: var(--muted); }

/* Generate button */
.btn-generate {
  width: 100%; padding: 13px; border-radius: 10px;
  background: linear-gradient(135deg, var(--purple), var(--purple-l));
  color: #fff; font-size: 14px; font-weight: 600;
  transition: opacity 0.15s, transform 0.1s;
  box-shadow: 0 4px 20px rgba(124,58,237,0.3);
}
.btn-generate:hover { opacity: 0.9; }
.btn-generate:active { transform: scale(0.98); }
.btn-generate:disabled { opacity: 0.5; cursor: not-allowed; }
.cost-preview { text-align: center; font-size: 11px; color: var(--muted); margin-top: 8px; }
.cost-preview .cost { color: var(--green); font-weight: 600; }

/* Main canvas */
.main-canvas {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  background: var(--bg);
}

/* Canvas tabs */
.canvas-tabs {
  display: flex; align-items: center; gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 24px; flex-shrink: 0;
  background: var(--bg);
}
.canvas-tab {
  padding: 0 16px; height: 44px; font-size: 13px; font-weight: 500;
  color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}
.canvas-tab:hover { color: var(--text); }
.canvas-tab.active { color: var(--text); border-bottom-color: var(--purple); }

/* History grid */
.history-section { padding: 24px; }
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px;
}
.history-title { font-size: 15px; font-weight: 600; color: var(--text); }
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* History card */
.history-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), border-color 0.2s, box-shadow 0.2s;
}
.history-card:hover {
  transform: translateY(-2px); border-color: var(--border-h);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.history-thumb {
  aspect-ratio: 16/9; overflow: hidden;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 28px;
}
.history-thumb video, .history-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.history-card-body { padding: 10px 12px 12px; }
.history-card-model { font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--purple-l); margin-bottom: 4px; }
.history-card-prompt { font-size: 12px; color: var(--muted-l); line-height: 1.4; margin-bottom: 8px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.history-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.history-card-cost { font-size: 11px; font-weight: 600; color: var(--green); }

/* Hero empty state */
.hero-section {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 60px 24px; text-align: center;
}
.hero-title { font-size: 36px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); margin-bottom: 12px; line-height: 1.2; }
.hero-subtitle { font-size: 15px; color: var(--muted); max-width: 400px; margin: 0 auto 40px; line-height: 1.7; }
.step-cards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.step-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px 24px; text-align: center; min-width: 100px;
}
.step-card-icon { font-size: 28px; margin-bottom: 10px; display: block; }
.step-card-title { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.4; }

/* Modals */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px); z-index: 500;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; width: 100%; max-width: 520px;
  max-height: 85vh; overflow-y: auto;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close {
  /* WCAG tap-target minimum: 44x44 on touch devices */
  width: 36px; height: 36px; border-radius: 8px;
  font-size: 22px; color: var(--muted); line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.modal-close:hover { background: rgba(255,255,255,0.08); color: var(--text); }

/* Preset grid */
.preset-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px,1fr));
  gap: 8px; padding: 16px;
}
.preset-item {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 10px; text-align: center; cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.preset-item:hover, .preset-item.active {
  border-color: rgba(124,58,237,0.4); background: rgba(124,58,237,0.08);
}
.preset-item-icon { font-size: 24px; margin-bottom: 8px; }
.preset-item-name { font-size: 12px; font-weight: 500; color: var(--text); }

/* Model list */
.model-list { padding: 8px; }
.model-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 10px; cursor: pointer;
  transition: background 0.12s;
}
.model-item:hover, .model-item.active { background: rgba(124,58,237,0.1); }
.model-item-info { flex: 1; }
.model-item-name { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.model-item-desc { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.model-item-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.model-item-price { font-size: 13px; font-weight: 600; color: var(--purple-l); flex-shrink: 0; }

/* Progress overlay */
.progress-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.8);
  backdrop-filter: blur(8px); z-index: 600;
  display: none; align-items: center; justify-content: center;
}
.progress-overlay.show { display: flex; }
.progress-card {
  background: var(--surface); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px; padding: 40px 48px; text-align: center; max-width: 360px; width: 100%;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}
.progress-spinner {
  width: 48px; height: 48px; border-radius: 50%;
  border: 3px solid rgba(124,58,237,0.2);
  border-top-color: var(--purple);
  animation: spin 0.9s linear infinite; margin: 0 auto 20px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.progress-sub { font-size: 13px; color: var(--muted); margin-bottom: 20px; }
.progress-bar-wrap { background: rgba(255,255,255,0.06); border-radius: 4px; height: 4px; overflow: hidden; margin-bottom: 12px; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--purple), var(--purple-l)); width: 0%; transition: width 0.3s ease; border-radius: 4px; }
.progress-cost { font-size: 12px; color: var(--muted); }

/* Status badges */
.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 20px;
}
.status-badge.completed { background: rgba(34,197,94,0.12); color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.status-badge.processing { background: rgba(124,58,237,0.12); color: var(--purple-l); border: 1px solid rgba(124,58,237,0.2); }
.status-badge.failed { background: rgba(239,68,68,0.12); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.status-badge.pending { background: rgba(107,104,128,0.2); color: var(--muted-l); border: 1px solid rgba(107,104,128,0.2); }
.status-dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* Toasts */
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 700; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 12px 16px;
  font-size: 13px; font-weight: 500; color: var(--text);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  animation: slideUp 0.25s ease;
  pointer-events: auto;
}
.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }
@keyframes slideUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ═══════════════════════════════════════════════════
   IMAGE CREATION PAGE — Higgsfield-style (ic-*)
   ═══════════════════════════════════════════════════ */
.ic-page {
  /* CSS vars drive the bar heights so future additions (ref thumbnails, pills)
     can't break the scroll layout. Update --ic-bar-h in JS when the bar
     grows/shrinks. */
  --ic-bar-h: 160px;
  --ic-sel-offset: 180px;

  display: flex; flex-direction: column;
  height: calc(100dvh - var(--nav-h)); overflow: hidden;
  background: var(--bg);
  /* direction: ltr kept intentionally — image grid + thumbnails read LTR
     even in RTL locale, so scrollbar lands on the expected side. */
  direction: ltr; width: 100%;
  position: relative;
}

/* ── Tabs row ── */
.ic-tabs-row {
  display: flex; align-items: center; flex-shrink: 0;
  padding: 8px 16px 0; border-bottom: 1px solid rgba(255,255,255,0.05);
  direction: rtl;
  gap: 12px;
}
.ic-tabs { display: flex; gap: 2px; flex: 1; }

/* ── Size slider ── */
.ic-size-slider-wrap {
  display: flex; align-items: center; gap: 7px;
  padding-bottom: 6px; flex-shrink: 0;
}
.ic-size-slider {
  -webkit-appearance: none; appearance: none;
  width: 90px; height: 3px;
  background: rgba(255,255,255,0.12);
  border-radius: 99px; outline: none; cursor: pointer;
}
.ic-size-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #c4b5fd;
  border: 2px solid rgba(124,58,237,0.6);
  cursor: pointer; transition: background .15s;
}
.ic-size-slider::-webkit-slider-thumb:hover { background: #fff; }
.ic-size-slider::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #c4b5fd; border: 2px solid rgba(124,58,237,0.6);
  cursor: pointer;
}
.ic-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 7px 7px 0 0;
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.58); background: none; border: none; cursor: pointer;
  transition: color .15s, background .15s;
}
.ic-tab--active { color: rgba(255,255,255,0.90); background: rgba(255,255,255,0.05); }
.ic-tab:hover:not(.ic-tab--active) { color: rgba(255,255,255,0.65); }
.ic-view-all {
  font-size: 12px; color: rgba(255,255,255,0.58);
  text-decoration: none; transition: color .15s;
}
.ic-view-all:hover { color: rgba(255,255,255,0.65); }

/* ── Masonry grid ── */
.ic-grid-scroll {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  direction: ltr; width: 100%;
  /* Reserve space for the floating bar + safe-area inset on iOS */
  padding-bottom: calc(var(--ic-bar-h, 160px) + env(safe-area-inset-bottom, 0px));
}
.ic-grid-wrap {
  padding: 6px 6px 6px;
  display: grid;
  grid-template-columns: repeat(var(--ic-cols, 5), 1fr);
  gap: 5px;
  direction: ltr;
  width: 100%;
  box-sizing: border-box;
}
.ic-grid-item {
  border-radius: 8px; overflow: hidden;
  position: relative; cursor: pointer;
  background: #0d0b1a;
  min-width: 0;
}
@media (max-width: 900px)  { .ic-grid-wrap { --ic-cols: 3; } }
@media (max-width: 600px)  { .ic-grid-wrap { --ic-cols: 2; } }
.ic-grid-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease; }
.ic-grid-item:hover img { transform: scale(1.04); }

/* Grid hover overlay */
.ic-grid-overlay {
  position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(5,3,18,0.85) 0%, rgba(5,3,18,0.3) 50%, transparent 100%);
  opacity: 0; transition: opacity .22s;
  display: flex; flex-direction: column;
  justify-content: flex-end; padding: 10px;
}
.ic-grid-item:hover .ic-grid-overlay { opacity: 1; }
.ic-grid-item:hover .ic-google-badge { opacity: 1 !important; }
.ic-grid-actions {
  display: flex; gap: 5px; justify-content: flex-end; margin-bottom: 6px;
}
.ic-grid-btn {
  width: 26px; height: 26px; border-radius: 6px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.85); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, border-color .15s;
}
.ic-grid-btn:hover { background: rgba(124,58,237,0.7); border-color: rgba(167,139,250,0.6); }
.ic-grid-btn--del:hover { background: rgba(239,68,68,0.6); border-color: rgba(252,165,165,0.5); }
.ic-grid-info {
  display: flex; align-items: center; justify-content: space-between;
}
.ic-grid-model { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: rgba(167,139,250,0.9); }
.ic-grid-cost  { font-size: 9px; color: rgba(255,255,255,0.58); }
.ic-grid-ratio-badge {
  position: absolute; top: 6px; left: 6px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 4px;
  font-size: 9px; font-weight: 700; color: rgba(255,255,255,0.70);
  padding: 2px 5px; pointer-events: none;
}

/* Pending card */
.ic-grid-item--pending {
  aspect-ratio: 3/4; display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.03); border: 1px dashed rgba(255,255,255,0.10);
}
/* ── Select mode ── */
.ic-select-mode-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 7px; font-size: 12px; font-weight: 500;
  color: rgba(255,255,255,0.5); border: 1px solid rgba(255,255,255,0.1);
  background: transparent; cursor: pointer; margin-bottom: 6px;
  transition: all .15s;
}
.ic-select-mode-btn:hover { color: #fff; border-color: rgba(255,255,255,0.58); }
.ic-select-mode-btn--active { color: #a78bfa; border-color: rgba(124,58,237,0.5); background: rgba(124,58,237,0.12); }

/* Checkbox — always square, shows on hover */
.ic-grid-check {
  position: absolute; top: 7px; right: 7px; z-index: 4;
  width: 20px; height: 20px; border-radius: 5px;
  background: rgba(0,0,0,0.45); border: 2px solid rgba(255,255,255,0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background .15s, border-color .15s;
  cursor: pointer;
}
.ic-grid-check svg { opacity: 0; transition: opacity .15s; }

/* Show checkbox on hover (always, not just select mode) */
.ic-grid-item:hover .ic-grid-check { opacity: 1; }

/* In select mode — always show checkbox */
.ic-grid--select .ic-grid-item .ic-grid-check { opacity: 1; cursor: pointer; }

/* Selected state */
.ic-grid-item--selected .ic-grid-check {
  opacity: 1 !important;
  background: #7c3aed !important;
  border-color: #7c3aed !important;
}
.ic-grid-item--selected .ic-grid-check svg { opacity: 1; }

/* Selected card overlay */
.ic-grid-item--selected::after {
  content: ''; position: absolute; inset: 0; border-radius: 8px;
  border: 2px solid #7c3aed;
  background: rgba(124,58,237,0.15);
  pointer-events: none;
}

/* In select mode: hover highlight */
.ic-grid--select .ic-grid-item:hover::after {
  content: ''; position: absolute; inset: 0; border-radius: 8px;
  border: 2px solid rgba(167,139,250,0.4);
  pointer-events: none;
}

/* ── Floating select bar ── */
.ic-sel-float {
  position: absolute; bottom: var(--ic-sel-offset, 180px); left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; align-items: center; gap: 10px;
  background: rgba(15,12,30,0.96); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 40px; padding: 8px 8px 8px 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6), 0 0 0 1px rgba(124,58,237,0.2);
  animation: floatUp .22s cubic-bezier(.22,1,.36,1);
  white-space: nowrap;
}
@keyframes floatUp { from { transform: translateX(-50%) translateY(16px); opacity:0; } to { transform: translateX(-50%) translateY(0); opacity:1; } }

.ic-sel-count {
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.75);
  padding: 0 4px;
}
.ic-sel-cancel {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.ic-sel-cancel:hover { background: rgba(255,255,255,0.13); color: #fff; }
.ic-sel-delete {
  display: flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 30px; font-size: 13px; font-weight: 700;
  background: #dc2626; border: none;
  color: #fff; cursor: pointer; transition: background .15s;
}
.ic-sel-delete:hover { background: #ef4444; }

/* Delete confirm modal */
.ic-del-overlay {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(0,0,0,0.65); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.ic-del-modal {
  background: #1c1a2e; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 16px; padding: 32px 28px 24px;
  width: 100%; max-width: 400px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.7);
  animation: scaleIn .2s ease;
}
@keyframes scaleIn { from { transform: scale(.94); opacity:0; } to { transform: none; opacity:1; } }
.ic-del-title { font-size: 18px; font-weight: 700; color: #fff; margin-bottom: 8px; text-align: right; }
.ic-del-sub   { font-size: 13px; color: rgba(255,255,255,0.45); margin-bottom: 24px; text-align: right; }
.ic-del-btns  { display: flex; gap: 10px; }
.ic-del-keep {
  flex: 1; padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 600;
  background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.8); cursor: pointer; transition: background .15s;
}
.ic-del-keep:hover { background: rgba(255,255,255,0.13); }
.ic-del-confirm {
  flex: 1; padding: 12px; border-radius: 10px; font-size: 14px; font-weight: 700;
  background: #991b1b; border: 1px solid rgba(239,68,68,0.4);
  color: #fca5a5; cursor: pointer; transition: background .15s;
}
.ic-del-confirm:hover { background: #b91c1c; }

.ic-grid-pending-inner { text-align: center; }
.ic-pending-spinner {
  width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 8px;
  border: 2px solid rgba(124,58,237,0.2); border-top-color: #7c3aed;
  animation: spin .8s linear infinite;
}
.ic-pending-label { font-size: 11px; color: rgba(255,255,255,0.58); }

/* Failed card */
.ic-failed-card {
  background: rgba(248,113,113,0.06);
  border: 1px dashed rgba(248,113,113,0.25);
  position: relative; border-radius: 8px;
  overflow: hidden; cursor: default;
}

/* New pending card (optimistic) */
.ic-pending-card {
  position: relative; overflow: hidden; border-radius: 6px;
  background: rgba(20,15,40,0.9);
  border: 1px solid rgba(124,58,237,0.20);
  display: flex; align-items: center; justify-content: center;
  min-height: 120px;
}
.ic-pending-shimmer {
  position: absolute; inset: 0;
  background: linear-gradient(105deg,
    transparent 40%, rgba(124,58,237,0.08) 50%, transparent 60%);
  background-size: 200% 100%;
  animation: icShimmer 1.6s infinite;
}
@keyframes icShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.ic-pending-body {
  position: relative; z-index: 1; text-align: center; padding: 16px;
}
.ic-pending-spinner-lg {
  width: 32px; height: 32px; border-radius: 50%; margin: 0 auto 10px;
  border: 2px solid rgba(124,58,237,0.18);
  border-top-color: #8b5cf6;
  animation: spin .9s linear infinite;
}
.ic-pending-status {
  font-size: 11px; font-weight: 600; color: rgba(167,139,250,0.8);
  letter-spacing: .3px;
}
@keyframes icFadeIn { from { opacity:0; transform:scale(1.02); } to { opacity:1; transform:scale(1); } }

/* Empty state */
.ic-empty {
  column-span: all; text-align: center; padding: 80px 24px;
}
.ic-empty-icon  { font-size: 52px; margin-bottom: 16px; opacity: .4; }
.ic-empty-title { font-size: 20px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.ic-empty-sub   { font-size: 13px; color: var(--muted); }

/* ── Bottom bar (floating) ── */
.ic-bar {
  position: absolute; bottom: 0; left: 0; right: 0;
  z-index: 50; padding: 0 12px 40px; direction: rtl;
  background: transparent; pointer-events: none;
}
.ic-bar > * { pointer-events: auto; }
.ic-bar-inner {
  max-width: 780px; margin: 0 auto;
  background: rgba(14,12,26,0.97); backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px; padding: 12px 14px 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.55), 0 2px 12px rgba(124,58,237,0.08);
}
.ic-bar-prompt-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.ic-attach-btn {
  width: 36px; height: 36px; flex-shrink: 0; border-radius: 8px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.10);
  color: rgba(255,255,255,0.50); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
}
.ic-attach-btn:hover { background: rgba(124,58,237,0.18); color: #a78bfa; border-color: rgba(124,58,237,0.35); }
.ic-prompt-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: #fff; font-size: 14px; line-height: 1.55; resize: none;
  font-family: inherit; padding: 4px 0;
  min-height: 26px; max-height: 110px;
}
.ic-prompt-input::placeholder { color: rgba(255,255,255,0.58); }
.ic-gen-btn {
  flex-shrink: 0; display: flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%);
  border: none; color: #fff; font-size: 13px; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 18px rgba(109,40,217,0.40);
  transition: opacity .15s, transform .12s;
}
.ic-gen-btn:hover { opacity: .9; transform: scale(1.02); }
.ic-gen-btn:active { transform: scale(0.97); }
.ic-gen-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.ic-gen-count {
  background: rgba(255,255,255,0.58); border-radius: 4px;
  padding: 1px 6px; font-size: 11px; font-weight: 800;
}
.ic-gen-cost {
  background: rgba(255,255,255,0.58); border-radius: 4px;
  padding: 2px 7px; font-size: 11px; font-weight: 800;
  letter-spacing: 0.3px;
}

/* Controls row */
.ic-bar-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ic-pill {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 20px;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.70); font-size: 12px; font-weight: 500;
  cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.ic-pill:hover { background: rgba(255,255,255,0.09); border-color: rgba(255,255,255,0.16); color: #fff; }
.ic-pill--model { padding-left: 7px; }
.ic-model-letter {
  width: 20px; height: 20px; border-radius: 5px; flex-shrink: 0;
  background: rgba(124,58,237,0.25); border: 1px solid rgba(124,58,237,0.40);
  font-size: 11px; font-weight: 800; color: #c4b5fd;
  display: flex; align-items: center; justify-content: center;
}
.ic-count-ctrl {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.75);
}
.ic-count-ctrl button {
  width: 24px; height: 24px; border-radius: 50%;
  background: rgba(255,255,255,0.07); border: 1px solid rgba(255,255,255,0.11);
  color: rgba(255,255,255,0.65); cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 14px;
  transition: background .15s;
}
.ic-count-ctrl button:hover { background: rgba(124,58,237,0.25); border-color: rgba(124,58,237,0.4); color: #a78bfa; }
.ic-cost-label { font-size: 12px; color: rgba(255,255,255,0.58); margin-left: auto; }

/* ── Model Dropdown (above pill) ── */
.ic-model-drop-wrap { position: relative; }
.ic-model-drop {
  position: absolute; bottom: calc(100% + 10px); left: 0;
  width: 300px; max-height: 520px;
  background: rgba(12,10,26,0.98); backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 12px;
  overflow: hidden; display: flex; flex-direction: column;
  z-index: 400;
  opacity: 0; pointer-events: none;
  transform: translateY(6px);
  transition: opacity .18s, transform .18s;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
}
.ic-model-drop--open { opacity: 1; pointer-events: all; transform: translateY(0); }
.ic-model-drop-search-wrap {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px 8px; flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ic-model-drop-search {
  flex: 1; background: none; border: none; outline: none;
  font-size: 13px; color: #fff; font-family: inherit;
}
.ic-model-drop-search::placeholder { color: rgba(255,255,255,0.58); }
.ic-model-drop-list { overflow-y: auto; padding: 6px 8px 10px; }
.ic-model-section-label {
  padding: 8px 8px 4px; font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .9px; color: rgba(255,255,255,0.58);
}
.ic-model-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 9px; cursor: pointer;
  transition: background .15s;
}
.ic-model-row:hover { background: rgba(255,255,255,0.05); }
.ic-model-row--active { background: rgba(124,58,237,0.14) !important; }
.ic-model-row-icon {
  width: 32px; height: 32px; border-radius: 7px; flex-shrink: 0;
  background: rgba(124,58,237,0.18); border: 1px solid rgba(124,58,237,0.28);
  font-size: 13px; font-weight: 800; color: #c4b5fd;
  display: flex; align-items: center; justify-content: center;
}
.ic-model-row-info { flex: 1; min-width: 0; }
.ic-model-row-name { font-size: 13px; font-weight: 600; color: #fff; }
.ic-model-row-desc { font-size: 11px; color: rgba(255,255,255,0.58); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ic-model-row-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.ic-model-row-price { font-size: 11px; color: rgba(255,255,255,0.58); }
.ic-model-row-check { color: #7c3aed; opacity: 0; }
.ic-model-row--active .ic-model-row-check { opacity: 1; }

/* ── Reference thumbnails row ── */
.ic-refs-row {
  padding-bottom: 10px; overflow-x: auto; overflow-y: hidden;
}
#icRefThumbWrap {
  display: flex; flex-direction: row; align-items: center;
  gap: 8px; flex-wrap: nowrap;
}
.ic-ref-thumb {
  position: relative; width: 52px; height: 52px;
  border-radius: 8px; overflow: hidden;
  border: 2px solid rgba(124,58,237,0.5);
  flex-shrink: 0;
}
.ic-ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ic-ref-thumb--loading {
  background: rgba(255,255,255,0.05);
  display: flex; align-items: center; justify-content: center;
  border-color: rgba(255,255,255,0.15);
}
.ic-ref-spinner {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(124,58,237,0.2); border-top-color: #7c3aed;
  animation: spin .7s linear infinite;
}
.ic-ref-remove {
  position: absolute; top: 2px; right: 2px;
  width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0,0,0,0.75); border: none;
  color: #fff; font-size: 11px; line-height: 1;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s;
}
.ic-ref-thumb:hover .ic-ref-remove { opacity: 1; }

/* ── Bar drag-over state ── */
.ic-bar--dragover .ic-bar-inner {
  border-radius: 12px;
  outline: 2px dashed rgba(124,58,237,0.6);
  background: rgba(124,58,237,0.06);
}

/* ── Grid ref button ── */
.ic-grid-btn--ref:hover { background: rgba(59,130,246,0.50); border-color: rgba(147,197,253,0.4); }

/* ── 3-dot card menu button ── */
.ic-3dot-btn {
  position: absolute; top: 7px; left: 7px; z-index: 4;
  width: 26px; height: 26px; border-radius: 6px;
  background: rgba(0,0,0,0.55); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,0.12);
  color: rgba(255,255,255,0.85); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity .15s, background .15s;
  padding: 0;
}
.ic-grid-item:hover .ic-3dot-btn { opacity: 1; }
.ic-3dot-btn:hover { background: rgba(124,58,237,0.7); border-color: rgba(167,139,250,0.6); }

/* ── Card context menu ── */
.ic-card-menu {
  position: fixed; z-index: 9999;
  background: rgba(15,12,30,0.97); backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 4px;
  min-width: 190px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.7);
  animation: icMenuFadeIn .15s cubic-bezier(.22,1,.36,1);
}
@keyframes icMenuFadeIn {
  from { opacity: 0; transform: scale(.94) translateY(-4px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}
.ic-card-menu-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 13px; border-radius: 7px;
  font-size: 13px; color: rgba(255,255,255,0.85);
  cursor: pointer; transition: background .12s;
  border: none; background: none; width: 100%;
  text-align: right; direction: rtl;
}
.ic-card-menu-item:hover { background: rgba(124,58,237,0.25); color: #fff; }
.ic-card-menu-sep { height: 1px; background: rgba(255,255,255,0.07); margin: 3px 4px; }

/* ── Pill dropdowns (aspect / resolution) ── */
.ic-pill-drop-wrap { position: relative; }
.ic-pill-drop {
  position: absolute; bottom: calc(100% + 10px); left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: rgba(12,10,26,0.98); backdrop-filter: blur(24px);
  border: 1px solid rgba(255,255,255,0.10); border-radius: 12px;
  padding: 10px; z-index: 400; min-width: 160px;
  opacity: 0; pointer-events: none;
  transition: opacity .15s, transform .15s;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.5);
}
.ic-pill-drop--open {
  opacity: 1; pointer-events: all;
  transform: translateX(-50%) translateY(0);
}
.ic-pill-drop-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .8px; color: rgba(255,255,255,0.58);
  padding: 0 4px 8px;
}
.ic-pill-drop-options {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
}
.ic-pill-drop-options--row {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.ic-pill-opt {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 8px 6px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65); font-size: 11px; font-weight: 600;
  transition: background .12s, border-color .12s, color .12s;
}
.ic-pill-opt:hover { background: rgba(255,255,255,0.08); color: #fff; }
.ic-pill-opt--active {
  background: rgba(124,58,237,0.20) !important;
  border-color: rgba(124,58,237,0.50) !important;
  color: #c4b5fd !important;
}
.ic-pill-opt--sm {
  flex-direction: row; padding: 5px 12px;
}

/* Aspect ratio mini previews (in dropdown options) */
.ic-aspect-preview {
  background: rgba(255,255,255,0.15); border-radius: 2px; flex-shrink: 0;
}
/* Aspect ratio icon in pill (border style, transitions) */
.ic-aspect-icon {
  border: 1.5px solid rgba(255,255,255,0.55); border-radius: 2px;
  flex-shrink: 0; transition: width .15s, height .15s;
}
/* shared sizes for both .ic-aspect-preview and .ic-aspect-icon */
.ic-aspect-1-1  { width: 14px; height: 14px; }
.ic-aspect-3-4  { width: 11px; height: 14px; }
.ic-aspect-4-3  { width: 14px; height: 11px; }
.ic-aspect-9-16 { width:  8px; height: 14px; }
.ic-aspect-16-9 { width: 14px; height:  8px; }

/* ══ IMAGE DETAIL MODAL (idm-*) ══════════════════════════ */
.idm-wrap {
  display: flex;
  width: 92vw; max-width: 1100px;
  height: 88vh; max-height: 820px;
  background: #0d0b1e;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.7);
  position: relative;
}

/* Left — image */
.idm-left {
  flex: 1; position: relative;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; background: #050312;
}
.idm-bg {
  position: absolute; inset: -20px;
  background-size: cover; background-position: center;
  filter: blur(28px) brightness(0.35) saturate(1.4);
  z-index: 0;
}
.idm-img {
  position: relative; z-index: 1;
  max-width: 100%; max-height: 100%;
  object-fit: contain;
  transition: opacity .3s ease;
}

/* Right — panel */
.idm-panel {
  width: 300px; flex-shrink: 0;
  display: flex; flex-direction: column;
  background: #0d0b1e;
  border-left: 1px solid rgba(255,255,255,0.06);
}

/* Header */
.idm-header {
  display: flex; align-items: center;
  justify-content: flex-end;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.idm-role     { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.idm-close {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.09);
  color: rgba(255,255,255,0.5); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.idm-close:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* Tabs */
.idm-tabs {
  display: flex; gap: 2px;
  padding: 8px 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.idm-tab {
  display: flex; align-items: center; gap: 5px;
  padding: 6px 12px; font-size: 12px; font-weight: 500;
  color: var(--text-dim); border-radius: 6px 6px 0 0;
  border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.idm-tab--active { color: var(--text-primary); border-bottom-color: #7c3aed; }

/* Scrollable body */
.idm-body {
  flex: 1; overflow-y: auto; padding: 16px;
}

/* Section label */
.idm-section-label {
  display: flex; align-items: center; gap: 5px;
  font-size: 10px; font-weight: 700; letter-spacing: .8px;
  color: var(--text-dim); text-transform: uppercase;
  margin-bottom: 8px;
}
.idm-copy-btn {
  margin-left: auto;
  font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 5px;
  background: rgba(124,58,237,0.2); border: 1px solid rgba(124,58,237,0.35);
  color: #c4b5fd; cursor: pointer; transition: background .15s;
  text-transform: none; letter-spacing: 0;
}
.idm-copy-btn:hover { background: rgba(124,58,237,0.35); }

.idm-prompt {
  font-size: 13px; line-height: 1.6;
  color: rgba(255,255,255,0.75);
  word-break: break-word;
}

/* Info grid */
.idm-info-grid { display: flex; flex-direction: column; gap: 1px; }
.idm-info-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
}
.idm-info-row span:first-child { color: var(--text-dim); }
.idm-info-row span:last-child  { color: var(--text-primary); font-weight: 600; }

/* Bottom actions */
.idm-actions {
  display: flex; gap: 8px;
  padding: 12px 16px 6px;
  border-top: 1px solid rgba(255,255,255,0.05);
  flex-shrink: 0;
}
.idm-btn-animate {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border-radius: 9px;
  background: linear-gradient(135deg,#7c3aed,#6d28d9);
  color: #fff; font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  transition: opacity .15s;
}
.idm-btn-animate:hover { opacity: .88; }
.idm-btn-ref {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px; border-radius: 9px;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.75); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: background .15s;
}
.idm-btn-ref:hover { background: rgba(255,255,255,0.1); }

.idm-actions2 {
  display: flex; gap: 6px; align-items: center;
  padding: 6px 16px 14px;
  flex-shrink: 0;
}
.idm-action-icon {
  flex: 1; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.55); cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s;
}
.idm-action-icon:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ══════════════════════════════════════════════════════════════════
   LEGACY `.image-canvas` / `.bottom-bar` block REMOVED — fully replaced
   by `.ic-page` + `.ic-bar` system. image.js falls back to the old
   class only if `.ic-page` is not on the page, so removing this CSS is
   safe.
   ══════════════════════════════════════════════════════════════════ */

/* Gallery / image history grid */
.image-history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px,1fr));
  gap: 12px; padding: 0 24px 120px;
}
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px,1fr));
  gap: 12px;
}
.gallery-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), border-color 0.2s, box-shadow 0.2s;
}
.gallery-card:hover {
  transform: translateY(-2px); border-color: var(--border-h);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.gallery-thumb {
  overflow: hidden; background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  min-height: 140px; position: relative;
}
.gallery-thumb img, .gallery-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-type-badge {
  position: absolute; bottom: 6px; right: 6px;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  color: rgba(255,255,255,0.8); font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 4px;
}
.gallery-card-body { padding: 10px 12px 12px; }
.gallery-card-model { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--purple-l); margin-bottom: 4px; }
.gallery-card-prompt { font-size: 12px; color: var(--muted-l); line-height: 1.4; margin-bottom: 8px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.gallery-card-meta { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.gallery-card-actions { display: flex; gap: 6px; padding: 0 12px 12px; flex-wrap: wrap; }

/* Buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px; border-radius: 8px; font-size: 13px; font-weight: 500; transition: all 0.15s; cursor: pointer; border: none; }
.btn-primary { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-l); }
.btn-ghost { background: transparent; border: 1px solid rgba(255,255,255,0.1); color: var(--muted-l); }
.btn-ghost:hover { border-color: rgba(255,255,255,0.58); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-download {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.2);
  color: var(--green); font-size: 12px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px;
  transition: background 0.15s;
}
.btn-download:hover { background: rgba(34,197,94,0.18); }
.btn-send-to-video {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(124,58,237,0.1); border: 1px solid rgba(124,58,237,0.2);
  color: var(--purple-l); font-size: 12px; font-weight: 600;
  padding: 7px 14px; border-radius: 8px;
  transition: background 0.15s;
}
.btn-send-to-video:hover { background: rgba(124,58,237,0.2); }
.btn-delete-gen {
  background: transparent; border: none; color: var(--muted);
  font-size: 13px; padding: 2px 6px; border-radius: 6px;
  transition: color 0.15s, background 0.15s; margin-left: auto;
}
.btn-delete-gen:hover { color: var(--red); background: rgba(239,68,68,0.12); }

/* Result card */
.result-card {
  margin: 24px; background: var(--card);
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden;
}
.result-card-footer {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  border-top: 1px solid var(--border);
}

/* Forms */
.form-input {
  width: 100%; background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px 14px; color: var(--text);
  /* 16px prevents iOS Safari from auto-zooming on focus */
  font-size: 15px;
  min-height: 44px;
  transition: border-color 0.15s; outline: none;
}
.form-input:focus { border-color: rgba(124,58,237,0.4); }
/* Explicit 16px on mobile — iOS zoom trigger is strict on < 16 */
@media (max-width: 768px) {
  .form-input, input[type="text"], input[type="email"], input[type="password"],
  input[type="tel"], input[type="number"], input[type="url"], textarea, select {
    font-size: 16px !important;
  }
}
.form-input-sm { padding: 7px 11px; font-size: 13px; min-height: 36px; }
.inline-form { display: flex; align-items: center; gap: 6px; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 10px 14px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--border);
}
.data-table td { padding: 12px 14px; font-size: 13px; color: var(--muted-l); border-bottom: 1px solid rgba(255,255,255,0.03); vertical-align: middle; }
.data-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Cards & sections */
.card-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; overflow: hidden; margin-bottom: 16px;
}
.section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 16px; }

/* Filter tabs (gallery) */
.filter-tabs { display: flex; gap: 4px; }
.filter-tab {
  padding: 6px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--muted);
  border: 1px solid var(--border); background: var(--card);
  transition: all 0.15s;
}
.filter-tab:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }
.filter-tab.active { color: #fff; background: var(--purple); border-color: var(--purple); }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.page-btn {
  padding: 6px 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500; color: var(--muted-l);
  background: var(--card); border: 1px solid var(--border);
  transition: all 0.15s;
}
.page-btn:hover { color: var(--text); border-color: rgba(255,255,255,0.15); }
.page-btn.active { color: #fff; background: var(--purple); border-color: var(--purple); }

/* Page layout */
.page-container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; flex-wrap: wrap; gap: 12px; }
.page-title { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }

/* Account */
.account-grid { display: grid; grid-template-columns: 280px 1fr; gap: 20px; }
.account-profile-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px; text-align: center;
}
.account-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  background: linear-gradient(135deg, var(--purple), var(--purple-l));
  color: #fff; font-size: 24px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; margin: 0 auto 14px;
}
.account-name { font-size: 18px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.account-email { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.account-role {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 3px 10px; border-radius: 20px;
}
.account-role.admin { background: rgba(124,58,237,0.15); color: var(--purple-l); border: 1px solid rgba(124,58,237,0.25); }
.account-role.user { background: rgba(107,104,128,0.15); color: var(--muted-l); border: 1px solid rgba(107,104,128,0.2); }
.credit-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 6px; }
.credit-balance-big { font-size: 32px; font-weight: 800; color: var(--green); letter-spacing: -0.02em; }

/* Pricing */
.pricing-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(200px,1fr)); gap: 14px; margin-bottom: 40px; }
.pricing-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 14px; padding: 24px 20px; text-align: center; position: relative;
  transition: border-color 0.2s, transform 0.2s;
}
.pricing-card.featured { border-color: rgba(124,58,237,0.4); background: linear-gradient(135deg, rgba(124,58,237,0.08), var(--card)); }
.pricing-card:hover { border-color: rgba(124,58,237,0.35); transform: translateY(-2px); }
.pricing-card-badge {
  position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
  background: var(--purple); color: #fff; font-size: 10px; font-weight: 700;
  letter-spacing: 0.08em; padding: 3px 12px; border-radius: 20px;
}
.pricing-card-name { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 12px; }
.pricing-card-amount { font-size: 36px; font-weight: 800; color: var(--text); letter-spacing: -0.03em; line-height: 1; }
.pricing-card-amount sup { font-size: 18px; font-weight: 600; vertical-align: top; margin-top: 6px; }
.pricing-card-credits { font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
.pricing-card-savings { font-size: 12px; color: var(--green); font-weight: 600; margin-bottom: 20px; }
.btn-buy {
  display: block; padding: 10px; border-radius: 10px;
  background: var(--purple); color: #fff; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, transform 0.1s;
  margin-top: 20px;
}
.btn-buy:hover { background: var(--purple-l); }
.btn-buy:active { transform: scale(0.97); }

/* User cell in admin tables */
.user-cell { display: flex; align-items: center; gap: 10px; }
.avatar-sm {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--purple), var(--purple-l));
  color: #fff; font-size: 12px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
}

/* Stats grid */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); gap: 12px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--text); letter-spacing: -0.02em; }
.stat-sub { font-size: 11px; color: var(--muted); margin-top: 4px; }

/* Empty state */
.empty-state { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 40px; margin-bottom: 14px; }
.empty-title { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty-sub { font-size: 13px; color: var(--muted); }

/* Panel overlay (mobile) */
.panel-overlay { display: none; }

@media (max-width: 768px) {
  .left-panel { position: fixed; top: var(--nav-h); left: -260px; height: calc(100dvh - var(--nav-h)); z-index: 150; transition: left 0.25s ease; box-shadow: none; }
  .left-panel.open { left: 0; box-shadow: 8px 0 32px rgba(0,0,0,0.5); }
  .panel-overlay.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 140; top: var(--nav-h); }
  .nav-tabs { display: none; }
  .history-grid { grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); }
  .account-grid { grid-template-columns: 1fr; }
}

/* RTL adjustments */
[dir="rtl"] .nav-logo { margin-right: 0; margin-left: 32px; }
[dir="rtl"] .nav-right { margin-left: 0; margin-right: auto; }
[dir="rtl"] .data-table th, [dir="rtl"] .data-table td { text-align: right; }
[dir="rtl"] .toast-container { right: auto; left: 20px; }
[dir="rtl"] .nav-dropdown { right: auto; left: 0; }
[dir="rtl"] .btn-delete-gen { margin-left: 0; margin-right: auto; }

/* ── Admin Sidebar Layout ──────────────────────────────────────────── */
.admin-layout {
  display: flex;
  height: calc(100dvh - var(--nav-h));
  overflow: hidden;
  background: var(--bg);
}
/* In RTL the sidebar appears on the right (start side) */
.admin-sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--surface);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
.admin-content {
  flex: 1;
  overflow-y: auto;
  min-width: 0;
}
.admin-content.noscroll { overflow: hidden; display: flex; flex-direction: column; }

/* Sidebar header */
.admin-sidebar-head {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.admin-sidebar-role {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.admin-sidebar-name {
  font-size: 15px;
  font-weight: 800;
  color: var(--text);
}

/* Sidebar navigation */
.admin-nav {
  flex: 1;
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.admin-nav-section {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 14px 10px 4px;
}
.admin-nav-section:first-child { padding-top: 4px; }
.admin-nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted-l);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
}
.admin-nav-item:hover { background: rgba(255,255,255,0.06); color: var(--text); }
.admin-nav-item.active { background: rgba(124,58,237,0.15); color: #a78bfa; font-weight: 600; }
.admin-nav-icon {
  width: 17px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.75;
  font-size: 13px;
}
.admin-nav-item.active .admin-nav-icon { opacity: 1; }

/* Sidebar footer */
.admin-sidebar-foot {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* Flash messages */
.flash-container {
  position: fixed; top: 64px; right: 16px; z-index: 400;
  display: flex; flex-direction: column; gap: 8px;
}

/* ─── AUTH PAGES ────────────────────────────────────────────── */
.auth-page {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.auth-card {
  width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 18px; padding: 36px 32px;
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.auth-logo {
  text-align: center; margin-bottom: 28px;
}
.auth-logo img { height: 48px; width: auto; margin-bottom: 10px; }
.auth-logo-name { font-size: 18px; font-weight: 700; color: var(--text); }
.auth-tagline { font-size: 12px; color: var(--muted); margin-top: 4px; }
.auth-title {
  font-size: 20px; font-weight: 700; color: var(--text);
  margin-bottom: 24px; text-align: center;
}
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted-l); margin-bottom: 6px; }
.auth-switch {
  text-align: center; margin-top: 20px; font-size: 13px; color: var(--muted);
}
.auth-switch a { color: var(--purple-l); }
.auth-switch a:hover { text-decoration: underline; }
.alert {
  padding: 10px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  margin-bottom: 16px;
}
.alert-error { background: rgba(239,68,68,0.1); color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.alert-success { background: rgba(34,197,94,0.1); color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
