/* =============================================================
   WriteRap AI — World-Class AI Image Generator Styles
   Inspired by Midjourney + Leonardo + ChatGPT + Canva
============================================================= */

/* ---- Theme Variables ---- */
:root {
  --aig-bg: #080814;
  --aig-surface: #0d0d1f;
  --aig-card: #111128;
  --aig-card2: #14142e;
  --aig-border: rgba(255,255,255,0.07);
  --aig-border2: rgba(255,255,255,0.12);
  --aig-text: #f1f1ff;
  --aig-muted: #6b7280;
  --aig-muted2: #9ca3af;
  --aig-accent: #6366f1;
  --aig-accent2: #8b5cf6;
  --aig-accent3: #ec4899;
  --aig-success: #10b981;
  --aig-warning: #f59e0b;
  --aig-danger: #ef4444;
  --aig-grad: linear-gradient(135deg, #6366f1, #8b5cf6, #ec4899);
  --aig-grad2: linear-gradient(135deg, #6366f1, #8b5cf6);
  --aig-glow: 0 0 40px rgba(99,102,241,0.3);
  --aig-radius: 14px;
  --aig-radius-sm: 8px;
  --aig-radius-lg: 20px;
  --aig-shadow: 0 20px 60px rgba(0,0,0,0.5);
  --left-w: 310px;
  --right-w: 280px;
  --header-h: 62px;
  --prompt-h: 120px;
}

/* Light Mode */
.light-mode {
  --aig-bg: #f0f0f8;
  --aig-surface: #f8f8ff;
  --aig-card: #ffffff;
  --aig-card2: #f3f3ff;
  --aig-border: rgba(0,0,0,0.08);
  --aig-border2: rgba(0,0,0,0.14);
  --aig-text: #0f0f2e;
  --aig-muted: #6b7280;
  --aig-muted2: #4b5563;
  --aig-shadow: 0 8px 30px rgba(0,0,0,0.1);
}

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

body.aig-body-root {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--aig-bg);
  color: var(--aig-text);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

/* ===== HEADER ===== */
.aig-header {
  height: var(--header-h);
  background: rgba(8,8,20,0.95);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--aig-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
}

.light-mode .aig-header {
  background: rgba(248,248,255,0.95);
  border-bottom-color: var(--aig-border);
}

.aig-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--aig-text);
  font-weight: 800;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.aig-logo-icon {
  width: 34px; height: 34px;
  background: var(--aig-grad2);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

/* Mode Tabs */
.aig-tabs {
  display: flex;
  gap: 3px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--aig-border);
  border-radius: 12px;
  padding: 4px;
  flex: 1;
  max-width: 680px;
  overflow-x: auto;
  scrollbar-width: none;
}
.aig-tabs::-webkit-scrollbar { display: none; }
.aig-tab {
  flex: 1;
  min-width: 90px;
  padding: 7px 12px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--aig-muted);
  transition: all 0.25s;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.aig-tab.active {
  background: var(--aig-grad2);
  color: #fff;
  box-shadow: 0 4px 14px rgba(99,102,241,0.4);
}
.aig-tab:hover:not(.active) {
  background: rgba(255,255,255,0.07);
  color: var(--aig-text);
}

/* Header Actions */
.aig-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
.aig-hdr-btn {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--aig-border);
  color: var(--aig-muted2);
  font-size: 0.9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.aig-hdr-btn:hover { background: rgba(99,102,241,0.2); color: #a5b4fc; }

.aig-credits-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(99,102,241,0.15);
  border: 1px solid rgba(99,102,241,0.3);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 0.8rem;
  font-weight: 700;
  color: #a5b4fc;
  cursor: pointer;
}
.aig-credits-badge:hover { background: rgba(99,102,241,0.25); }

/* ===== LAYOUT ===== */
.aig-layout {
  display: flex;
  height: 100vh;
  padding-top: var(--header-h);
}

/* ===== LEFT PANEL ===== */
.aig-left {
  width: var(--left-w);
  flex-shrink: 0;
  background: var(--aig-surface);
  border-right: 1px solid var(--aig-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.aig-left-scroll {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(99,102,241,0.3) transparent;
}
.aig-left-scroll::-webkit-scrollbar { width: 4px; }
.aig-left-scroll::-webkit-scrollbar-track { background: transparent; }
.aig-left-scroll::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 2px; }

.aig-section {
  padding: 16px;
  border-bottom: 1px solid var(--aig-border);
}
.aig-section:last-child { border-bottom: none; }

.aig-sec-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--aig-muted);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.aig-sec-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--aig-border);
}

/* Model Grid */
.model-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.model-item {
  padding: 10px 8px;
  border-radius: 10px;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: all 0.22s;
  text-align: center;
}
.model-item:hover {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.4);
}
.model-item.active {
  background: rgba(99,102,241,0.15);
  border-color: #6366f1;
  box-shadow: inset 0 0 0 1px rgba(99,102,241,0.3);
}
.model-icon { font-size: 1.3rem; margin-bottom: 4px; }
.model-name { font-size: 0.72rem; font-weight: 700; color: var(--aig-text); display: block; }
.model-speed {
  font-size: 0.65rem;
  color: var(--aig-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-top: 2px;
}
.model-speed.fast { color: var(--aig-success); }
.model-speed.ultra { color: var(--aig-warning); }

/* Style Pills */
.style-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.style-pill {
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.03);
  color: var(--aig-muted2);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 4px;
}
.style-pill:hover {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.4);
  color: var(--aig-text);
}
.style-pill.active {
  background: var(--aig-grad2);
  border-color: transparent;
  color: #fff;
}

/* Aspect Ratio Grid */
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.ratio-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-radius: 10px;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--aig-muted2);
}
.ratio-btn:hover {
  background: rgba(99,102,241,0.1);
  border-color: rgba(99,102,241,0.4);
  color: var(--aig-text);
}
.ratio-btn.active {
  background: rgba(99,102,241,0.15);
  border-color: #6366f1;
  color: #a5b4fc;
}
.ratio-icon {
  border: 2px solid currentColor;
  border-radius: 3px;
}
.ratio-label { font-size: 0.65rem; font-weight: 700; }

/* Resolution Toggle */
.res-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.res-btn {
  padding: 7px 4px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  cursor: pointer;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.02);
  color: var(--aig-muted2);
  transition: all 0.2s;
}
.res-btn:hover { border-color: rgba(99,102,241,0.4); color: var(--aig-text); }
.res-btn.active { background: var(--aig-grad2); border-color: transparent; color: #fff; }

/* Batch Slider */
.batch-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.batch-slider {
  flex: 1;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #6366f1 var(--val, 12.5%), var(--aig-border) var(--val, 12.5%));
  outline: none;
  cursor: pointer;
}
.batch-slider::-webkit-slider-thumb {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #6366f1;
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,0.5);
  cursor: pointer;
}
.batch-val {
  min-width: 28px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #a5b4fc;
  background: rgba(99,102,241,0.15);
  border-radius: 6px;
  padding: 2px 6px;
}

/* Advanced Controls */
.adv-control {
  margin-bottom: 12px;
}
.adv-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--aig-muted2);
  margin-bottom: 6px;
}
.adv-val {
  font-size: 0.75rem;
  font-weight: 800;
  color: #a5b4fc;
}
.adv-slider {
  width: 100%;
  appearance: none;
  height: 3px;
  border-radius: 2px;
  background: linear-gradient(to right, #8b5cf6 var(--val, 50%), var(--aig-border) var(--val, 50%));
  outline: none;
  cursor: pointer;
}
.adv-slider::-webkit-slider-thumb {
  appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #8b5cf6;
  border: 2px solid #fff;
  cursor: pointer;
}
.adv-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--aig-border);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--aig-text);
  font-size: 0.8rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  resize: none;
}
.adv-input:focus { border-color: #6366f1; }
.adv-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  cursor: pointer;
  color: var(--aig-muted2);
  font-size: 0.8rem;
  font-weight: 600;
  border: none;
  background: none;
}
.adv-toggle-icon {
  width: 32px; height: 18px;
  border-radius: 9px;
  background: var(--aig-border2);
  position: relative;
  transition: background 0.25s;
}
.adv-toggle-icon::after {
  content: '';
  position: absolute;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #fff;
  top: 2px; left: 2px;
  transition: left 0.25s;
}
.adv-toggle.on .adv-toggle-icon { background: #6366f1; }
.adv-toggle.on .adv-toggle-icon::after { left: 16px; }

.adv-section { display: none; }
.adv-section.open { display: block; }

/* ===== MAIN CANVAS AREA ===== */
.aig-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--aig-bg);
}

/* Gallery toolbar */
.gallery-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--aig-border);
  background: var(--aig-surface);
  flex-shrink: 0;
}
.gallery-toolbar-left { display: flex; align-items: center; gap: 8px; flex: 1; }
.gallery-toolbar-right { display: flex; align-items: center; gap: 6px; }

.gtb-stat {
  font-size: 0.78rem;
  color: var(--aig-muted);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--aig-border);
  border-radius: 8px;
  padding: 4px 10px;
}
.gtb-tab {
  padding: 5px 12px;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  background: none;
  color: var(--aig-muted);
  transition: all 0.2s;
}
.gtb-tab.active { background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.4); color: #a5b4fc; }
.gtb-tab:hover:not(.active) { color: var(--aig-text); }

.gtb-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--aig-border);
  color: var(--aig-muted2);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.gtb-btn:hover { background: rgba(99,102,241,0.15); color: #a5b4fc; border-color: rgba(99,102,241,0.4); }

/* Gallery grid */
.aig-gallery {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  scrollbar-width: thin;
  scrollbar-color: rgba(99,102,241,0.3) transparent;
}
.aig-gallery::-webkit-scrollbar { width: 6px; }
.aig-gallery::-webkit-scrollbar-track { background: transparent; }
.aig-gallery::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 3px; }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.gallery-grid.grid-1 { grid-template-columns: repeat(1, minmax(0,1fr)); max-width: 600px; margin: 0 auto; }
.gallery-grid.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.gallery-grid.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.gallery-grid.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }

.aig-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - var(--header-h) - 240px);
  text-align: center;
  gap: 16px;
  padding: 40px;
}
.aig-empty-orb {
  width: 120px; height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(99,102,241,0.4), rgba(139,92,246,0.2), transparent);
  border: 2px solid rgba(99,102,241,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  animation: pulse-orb 3s ease-in-out infinite;
  box-shadow: 0 0 60px rgba(99,102,241,0.2);
}
@keyframes pulse-orb {
  0%,100% { transform: scale(1); box-shadow: 0 0 60px rgba(99,102,241,0.2); }
  50% { transform: scale(1.08); box-shadow: 0 0 80px rgba(99,102,241,0.4); }
}
.aig-empty-title { font-size: 1.4rem; font-weight: 800; color: var(--aig-text); }
.aig-empty-sub { font-size: 0.9rem; color: var(--aig-muted); max-width: 400px; line-height: 1.6; }

/* Image Card */
.img-card {
  border-radius: 14px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--aig-card);
  border: 1px solid var(--aig-border);
  transition: all 0.3s;
  group: true;
}
.img-card:hover {
  transform: translateY(-4px);
  border-color: rgba(99,102,241,0.5);
  box-shadow: 0 16px 50px rgba(0,0,0,0.5);
}
.img-card canvas,
.img-card img { width: 100%; height: 100%; display: block; object-fit: cover; }
.img-card-actions {
  position: absolute;
  inset: 0;
  background: linear-gradient(0deg, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0.3) 40%, transparent 70%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 10px;
  opacity: 0;
  transition: opacity 0.25s;
}
.img-card:hover .img-card-actions { opacity: 1; }
.img-card-prompt {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.8);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.img-card-btns { display: flex; gap: 5px; flex-wrap: wrap; }
.img-card-btn {
  flex: 1;
  min-width: 0;
  padding: 5px 4px;
  border-radius: 7px;
  font-size: 0.67rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(0,0,0,0.5);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background 0.2s;
  backdrop-filter: blur(10px);
}
.img-card-btn:hover { background: rgba(99,102,241,0.6); border-color: #6366f1; }
.img-card-btn.fav.active { background: rgba(236,72,153,0.5); border-color: #ec4899; }

/* Favorite heart */
.img-fav-float {
  position: absolute;
  top: 10px; right: 10px;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  cursor: pointer;
  backdrop-filter: blur(10px);
  transition: all 0.2s;
  opacity: 0;
}
.img-card:hover .img-fav-float { opacity: 1; }
.img-fav-float:hover, .img-fav-float.active { background: rgba(236,72,153,0.4); color: #f9a8d4; }

/* Model tag */
.img-model-tag {
  position: absolute;
  top: 10px; left: 10px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  background: rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
  backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.25s;
}
.img-card:hover .img-model-tag { opacity: 1; }

/* ===== PROMPT AREA ===== */
.aig-prompt-bar {
  border-top: 1px solid var(--aig-border);
  background: var(--aig-surface);
  padding: 14px 16px;
  flex-shrink: 0;
}
.prompt-box {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--aig-border2);
  border-radius: 16px;
  padding: 12px 14px;
  transition: border-color 0.3s, box-shadow 0.3s;
}
.prompt-box:focus-within {
  border-color: #6366f1;
  box-shadow: 0 0 0 3px rgba(99,102,241,0.15);
}
.prompt-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.prompt-main textarea {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--aig-text);
  font-size: 0.92rem;
  font-family: inherit;
  resize: none;
  line-height: 1.6;
  min-height: 46px;
  max-height: 130px;
  padding: 0;
}
.prompt-main textarea::placeholder { color: var(--aig-muted); }

.gen-btn-main {
  width: 46px; height: 46px;
  border-radius: 12px;
  background: var(--aig-grad2);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  color: #fff;
  flex-shrink: 0;
  transition: all 0.3s;
  position: relative;
  overflow: hidden;
}
.gen-btn-main::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #8b5cf6, #ec4899);
  opacity: 0;
  transition: opacity 0.3s;
}
.gen-btn-main:hover::before { opacity: 1; }
.gen-btn-main:hover { transform: scale(1.05); box-shadow: 0 6px 24px rgba(99,102,241,0.5); }
.gen-btn-main:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.gen-btn-main i { position: relative; z-index: 1; }

.prompt-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.pf-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--aig-border);
  color: var(--aig-muted2);
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.pf-chip:hover { background: rgba(99,102,241,0.15); border-color: rgba(99,102,241,0.4); color: #a5b4fc; }
.pf-chip.active { background: rgba(99,102,241,0.2); border-color: #6366f1; color: #a5b4fc; }
.prompt-footer-spacer { flex: 1; }
.pf-action-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: 9px;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.04);
  color: var(--aig-muted2);
  transition: all 0.2s;
}
.pf-action-btn:hover { background: rgba(99,102,241,0.15); color: #a5b4fc; border-color: rgba(99,102,241,0.4); }
.pf-action-btn.enhance { background: rgba(99,102,241,0.12); border-color: rgba(99,102,241,0.3); color: #a5b4fc; }
.pf-action-btn.enhance:hover { background: rgba(99,102,241,0.25); }

/* ===== RIGHT SIDEBAR ===== */
.aig-right {
  width: var(--right-w);
  flex-shrink: 0;
  background: var(--aig-surface);
  border-left: 1px solid var(--aig-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.aig-right-tabs {
  display: flex;
  border-bottom: 1px solid var(--aig-border);
  flex-shrink: 0;
}
.aig-rt-tab {
  flex: 1;
  padding: 12px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  background: none;
  color: var(--aig-muted);
  transition: all 0.2s;
  border-bottom: 2px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.aig-rt-tab.active { color: #a5b4fc; border-bottom-color: #6366f1; }
.aig-rt-tab:hover:not(.active) { color: var(--aig-text); }

.aig-rt-content { flex: 1; overflow-y: auto; padding: 14px; scrollbar-width: thin; scrollbar-color: rgba(99,102,241,0.3) transparent; }
.aig-rt-content::-webkit-scrollbar { width: 4px; }
.aig-rt-content::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.3); border-radius: 2px; }

.rt-panel { display: none; }
.rt-panel.active { display: block; }

/* History item */
.history-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.02);
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.history-item:hover { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.3); }
.history-thumb {
  width: 54px; height: 54px;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--aig-card);
}
.history-thumb canvas { width: 100%; height: 100%; }
.history-info { flex: 1; min-width: 0; }
.history-prompt { font-size: 0.76rem; color: var(--aig-text); line-height: 1.4; margin-bottom: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.history-meta { font-size: 0.68rem; color: var(--aig-muted); }

/* Preset prompts */
.preset-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.02);
  margin-bottom: 6px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.78rem;
  color: var(--aig-muted2);
  line-height: 1.4;
}
.preset-card:hover { background: rgba(99,102,241,0.08); border-color: rgba(99,102,241,0.3); color: var(--aig-text); }
.preset-card strong { display: block; font-size: 0.7rem; color: var(--aig-accent); margin-bottom: 2px; text-transform: uppercase; letter-spacing: 0.06em; }

/* Saved prompts */
.saved-prompt-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.02);
  margin-bottom: 6px;
  transition: all 0.2s;
}
.saved-prompt-item:hover { border-color: rgba(99,102,241,0.3); }
.spi-text { flex: 1; font-size: 0.76rem; color: var(--aig-muted2); line-height: 1.4; cursor: pointer; }
.spi-text:hover { color: var(--aig-text); }
.spi-del { width: 24px; height: 24px; border-radius: 6px; border: none; background: rgba(239,68,68,0.1); color: #ef4444; cursor: pointer; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; flex-shrink: 0; transition: background 0.2s; }
.spi-del:hover { background: rgba(239,68,68,0.2); }

/* ===== GENERATION OVERLAY ===== */
.gen-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
}
.gen-overlay.active { opacity: 1; pointer-events: all; }

.gen-modal {
  background: var(--aig-card);
  border: 1px solid var(--aig-border2);
  border-radius: 24px;
  padding: 40px;
  max-width: 440px;
  width: 90%;
  text-align: center;
  box-shadow: 0 40px 100px rgba(0,0,0,0.6), 0 0 0 1px rgba(99,102,241,0.2);
  animation: gen-modal-in 0.4s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes gen-modal-in {
  from { transform: scale(0.8) translateY(40px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

.gen-ring-wrap {
  width: 100px; height: 100px;
  margin: 0 auto 24px;
  position: relative;
}
.gen-ring {
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 4px solid rgba(99,102,241,0.15);
  border-top-color: #6366f1;
  border-right-color: #8b5cf6;
  animation: gen-spin 0.8s linear infinite;
  position: absolute;
  top: 0; left: 0;
}
.gen-ring-inner {
  width: 70px; height: 70px;
  top: 15px; left: 15px;
  border: 3px solid rgba(139,92,246,0.15);
  border-top-color: #8b5cf6;
  border-left-color: #ec4899;
  animation: gen-spin 1.2s linear infinite reverse;
}
@keyframes gen-spin { to { transform: rotate(360deg); } }
.gen-ring-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.6rem;
}

.gen-modal h3 { font-size: 1.2rem; font-weight: 800; margin-bottom: 6px; }
.gen-modal p { font-size: 0.85rem; color: var(--aig-muted); margin-bottom: 24px; line-height: 1.5; }

.gen-status {
  font-size: 0.8rem;
  color: #a5b4fc;
  font-weight: 600;
  margin-bottom: 16px;
  min-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.gen-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: #6366f1;
  margin: 0 2px;
  animation: gen-dot 1.2s infinite;
}
.gen-dots span:nth-child(2) { animation-delay: 0.2s; }
.gen-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes gen-dot { 0%,80%,100%{transform:scale(0.6);opacity:.4} 40%{transform:scale(1);opacity:1} }

.gen-progress-bar {
  height: 4px;
  background: var(--aig-border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 12px;
}
.gen-progress-fill {
  height: 100%;
  background: var(--aig-grad);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s;
}
.gen-percent { font-size: 0.78rem; color: var(--aig-muted); text-align: right; margin-bottom: 16px; }

.gen-cancel-btn {
  padding: 8px 24px;
  border-radius: 10px;
  border: 1px solid var(--aig-border2);
  background: rgba(255,255,255,0.05);
  color: var(--aig-muted2);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.gen-cancel-btn:hover { background: rgba(239,68,68,0.15); color: #ef4444; border-color: rgba(239,68,68,0.3); }

/* ===== SHARE MODAL ===== */
.share-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.share-overlay.active { opacity: 1; pointer-events: all; }
.share-modal {
  background: var(--aig-card);
  border: 1px solid var(--aig-border2);
  border-radius: 22px;
  padding: 28px;
  max-width: 400px;
  width: 90%;
  box-shadow: var(--aig-shadow);
}
.share-modal h4 { font-size: 1.1rem; font-weight: 800; margin-bottom: 6px; }
.share-modal p { font-size: 0.82rem; color: var(--aig-muted); margin-bottom: 20px; }
.share-platforms {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.share-platform-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 8px;
  border-radius: 12px;
  border: 1px solid var(--aig-border);
  background: rgba(255,255,255,0.02);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--aig-muted2);
  font-size: 0.72rem;
  font-weight: 600;
}
.share-platform-btn i { font-size: 1.4rem; }
.share-platform-btn:hover { transform: translateY(-2px); }
.share-platform-btn.fb:hover { background: rgba(24,119,242,0.15); border-color: #1877f2; color: #1877f2; }
.share-platform-btn.ig:hover { background: rgba(225,48,108,0.15); border-color: #e1306c; color: #e1306c; }
.share-platform-btn.tw:hover { background: rgba(0,0,0,0.3); border-color: #000; color: #fff; }
.share-platform-btn.wa:hover { background: rgba(37,211,102,0.15); border-color: #25d366; color: #25d366; }
.share-platform-btn.pi:hover { background: rgba(230,0,35,0.15); border-color: #e60023; color: #e60023; }
.share-platform-btn.li:hover { background: rgba(0,119,181,0.15); border-color: #0077b5; color: #0077b5; }

.share-link-row {
  display: flex;
  gap: 8px;
}
.share-link-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--aig-border);
  border-radius: 9px;
  padding: 8px 12px;
  color: var(--aig-muted2);
  font-size: 0.78rem;
  outline: none;
}
.share-copy-btn {
  padding: 8px 16px;
  border-radius: 9px;
  border: none;
  background: var(--aig-grad2);
  color: #fff;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
}
.share-close-btn {
  width: 28px; height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.07);
  color: var(--aig-muted2);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  float: right;
  font-size: 0.8rem;
  transition: background 0.2s;
}
.share-close-btn:hover { background: rgba(239,68,68,0.2); color: #ef4444; }

/* ===== IMAGE VIEWER ===== */
.img-viewer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 10001;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.img-viewer-overlay.active { opacity: 1; pointer-events: all; }
.img-viewer-box {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.img-viewer-box canvas,
.img-viewer-box img {
  max-width: 90vw;
  max-height: 75vh;
  border-radius: 16px;
  object-fit: contain;
}
.img-viewer-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}
.ivb {
  padding: 8px 18px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.2s;
}
.ivb:hover { background: rgba(99,102,241,0.4); border-color: #6366f1; }
.ivb.close { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.3); }
.ivb.close:hover { background: rgba(239,68,68,0.3); }

/* Export format selector */
.export-formats {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.ef-btn {
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.6);
  cursor: pointer;
  transition: all 0.2s;
}
.ef-btn.active, .ef-btn:hover { background: rgba(99,102,241,0.3); border-color: #6366f1; color: #fff; }

/* ===== TOAST ===== */
.aig-toast-wrap {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  align-items: center;
}
.aig-toast {
  background: var(--aig-card);
  border: 1px solid var(--aig-border2);
  border-radius: 12px;
  padding: 10px 20px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--aig-text);
  box-shadow: var(--aig-shadow);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in 0.3s, toast-out 0.3s 2.5s forwards;
  white-space: nowrap;
  pointer-events: none;
}
.aig-toast.success { border-color: rgba(16,185,129,0.4); }
.aig-toast.error { border-color: rgba(239,68,68,0.4); }
.aig-toast i.success { color: #10b981; }
.aig-toast i.error { color: #ef4444; }
@keyframes toast-in { from { opacity:0; transform:translateY(20px) scale(0.9); } to { opacity:1; transform:translateY(0) scale(1); } }
@keyframes toast-out { from { opacity:1; } to { opacity:0; pointer-events:none; } }

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 2px dashed var(--aig-border2);
  border-radius: 14px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: all 0.25s;
  background: rgba(255,255,255,0.02);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: #6366f1;
  background: rgba(99,102,241,0.08);
}
.upload-zone i { font-size: 2rem; color: var(--aig-muted); margin-bottom: 8px; display: block; }
.upload-zone p { font-size: 0.82rem; color: var(--aig-muted); margin-bottom: 4px; }
.upload-zone span { font-size: 0.72rem; color: var(--aig-muted); }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 1200px) {
  :root { --right-w: 240px; }
}
@media (max-width: 1024px) {
  .aig-right { display: none; }
}
@media (max-width: 768px) {
  :root { --left-w: 260px; }
  .aig-left {
    position: fixed;
    top: var(--header-h);
    bottom: 0;
    left: -100%;
    z-index: 100;
    transition: left 0.3s;
    box-shadow: 4px 0 40px rgba(0,0,0,0.5);
  }
  .aig-left.open { left: 0; }
  .aig-tabs { max-width: 100%; }
  .aig-logo span { display: none; }
  .aig-credits-badge span { display: none; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .aig-gallery { padding: 12px; }
}
@media (max-width: 480px) {
  :root { --left-w: 100vw; }
  .gallery-grid { grid-template-columns: 1fr; }
  .aig-tab { padding: 6px 8px; font-size: 0.7rem; }
  .gen-modal { padding: 28px 20px; }
}

/* Scrollbar */
* { scrollbar-width: thin; scrollbar-color: rgba(99,102,241,0.2) transparent; }
*::-webkit-scrollbar { width: 4px; height: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: rgba(99,102,241,0.25); border-radius: 4px; }

/* Animations */
@keyframes fade-in { from { opacity:0; } to { opacity:1; } }
@keyframes slide-up { from { opacity:0; transform:translateY(30px); } to { opacity:1; transform:translateY(0); } }
.fade-in { animation: fade-in 0.4s ease-out forwards; }
.slide-up { animation: slide-up 0.4s cubic-bezier(0.2,0,0,1) forwards; }

/* Gradient text utility */
.grad-text {
  background: var(--aig-grad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Notification badge */
.notif-badge {
  position: absolute;
  top: -4px; right: -4px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--aig-danger);
  font-size: 0.6rem;
  font-weight: 800;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--aig-surface);
}

/* Mobile overlay backdrop */
.left-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  display: none;
}
.left-backdrop.active { display: block; }
