/* ============================================
   AINN Image — Dark Luxury 暗黑奢华主题
   配色：深黑紫背景 + 紫罗兰强调 + 玻璃拟态
   ============================================ */

/* ---- CSS Variables ---- */
:root {
  /* 背景层次 */
  --bg-root: #08080E;
  --bg-surface: #0E0E18;
  --bg-elevated: #14141F;
  --bg-glass: rgba(20, 20, 31, 0.65);
  --bg-glass-hover: rgba(26, 26, 40, 0.78);

  /* 边框 */
  --border-subtle: rgba(124, 58, 237, 0.08);
  --border-glass: rgba(124, 58, 237, 0.13);
  --border-active: rgba(124, 58, 237, 0.35);
  --border-input: rgba(255, 255, 255, 0.06);

  /* 强调色 */
  --accent: #7C3AED;
  --accent-soft: #8B5CF6;
  --accent-glow: rgba(124, 58, 237, 0.25);
  --accent-subtle: rgba(124, 58, 237, 0.08);

  /* 辅助色 */
  --cyan: #06B6D4;
  --cyan-glow: rgba(6, 182, 212, 0.2);
  --emerald: #10B981;
  --amber: #F59E0B;
  --red: #EF4444;

  /* 渐变 */
  --gradient-primary: linear-gradient(135deg, #7C3AED, #3B82F6);
  --gradient-cyan: linear-gradient(135deg, #06B6D4, #10B981);
  --gradient-hero: linear-gradient(135deg, #7C3AED 0%, #3B82F6 50%, #06B6D4 100%);

  /* 文字 */
  --text-primary: #F1F1F6;
  --text-secondary: #9898B0;
  --text-tertiary: #5C5C72;
  --text-placeholder: #4A4A60;

  /* 圆角 */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-2xl: 32px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-glow: 0 0 40px rgba(124, 58, 237, 0.18);
  --shadow-cyan: 0 0 30px rgba(6, 182, 212, 0.12);

  /* 动画 */
  --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);

  /* 尺寸 */
  --topbar-h: 56px;
  --sidebar-w: 220px;
  --panel-w: 280px;
  --gallery-h: 200px;

  /* 字体 */
  --font-sans: 'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'SF Mono', monospace;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100dvh;
  user-select: none;
}

a { color: var(--accent-soft); text-decoration: none; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; border: none; outline: none; }
input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  outline: none;
  border: none;
  background: transparent;
  color: inherit;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(124, 58, 237, 0.2); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(124, 58, 237, 0.4); }

/* ============================================
   Layout — 三栏布局
   ============================================ */
.app-container {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr var(--panel-w);
  grid-template-rows: var(--topbar-h) 1fr;
  height: 100dvh;
  overflow: hidden;
}

/* ---- Top Bar ---- */
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(14, 14, 24, 0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--border-glass);
  z-index: 100;
  gap: 16px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.topbar-logo .logo-icon {
  width: 32px;
  height: 32px;
  background: var(--gradient-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  box-shadow: var(--shadow-glow);
}

.topbar-logo .logo-dot {
  color: var(--cyan);
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 500;
  transition: all 0.2s var(--ease-smooth);
  white-space: nowrap;
}

.topbar-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border-color: var(--border-glass);
}

.topbar-btn.active {
  background: var(--accent-subtle);
  border-color: var(--border-active);
  color: var(--accent-soft);
}

.topbar-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---- Sidebar (模型列表) ---- */
.sidebar {
  grid-row: 2;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  transition: border-color 0.2s;
}

.sidebar-search:focus-within {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.sidebar-search input {
  flex: 1;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.sidebar-search input::placeholder { color: var(--text-placeholder); }

.sidebar-search svg {
  width: 15px;
  height: 15px;
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.model-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.model-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s var(--ease-smooth);
  margin-bottom: 2px;
  position: relative;
}

.model-item:hover {
  background: var(--bg-glass);
}

.model-item.active {
  background: var(--accent-subtle);
  border: 1px solid var(--border-active);
}

.model-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  background: var(--accent);
  border-radius: 0 3px 3px 0;
}

.model-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-glass);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-soft);
}

.model-item.active .model-icon {
  background: var(--accent);
  color: #fff;
}

.model-info {
  flex: 1;
  min-width: 0;
}

.model-name {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-tag {
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.model-badge {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--emerald);
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---- Main Content (生图区) ---- */
.main-content {
  grid-row: 2;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, rgba(124, 58, 237, 0.05) 0%, transparent 70%);
}

.generate-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 48px;
  overflow-y: auto;
  gap: 20px;
}

.prompt-container {
  width: 100%;
  max-width: 800px;
  background: var(--bg-glass);
  backdrop-filter: blur(30px) saturate(180%);
  -webkit-backdrop-filter: blur(30px) saturate(180%);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-xl);
  padding: 20px;
  transition: all 0.3s var(--ease-smooth);
  box-shadow: var(--shadow-md);
}

.prompt-container:focus-within {
  border-color: var(--border-active);
  box-shadow: var(--shadow-md), var(--shadow-glow);
}

.prompt-input {
  width: 100%;
  resize: none;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.7;
  min-height: 80px;
  max-height: 200px;
}

.prompt-input::placeholder {
  color: var(--text-placeholder);
}

.prompt-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  gap: 10px;
  flex-wrap: wrap;
}

.prompt-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.prompt-actions-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s;
  cursor: pointer;
  white-space: nowrap;
}

.action-chip:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-primary);
  border-color: var(--border-glass);
}

.action-chip svg {
  width: 14px;
  height: 14px;
}

/* ---- Generate Button ---- */
.btn-generate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 28px;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: var(--radius-md);
  transition: all 0.25s var(--ease-spring);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
  border: none;
}

.btn-generate::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.15), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}

.btn-generate:hover {
  transform: translateY(-1px) scale(1.02);
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.5);
}

.btn-generate:hover::before { opacity: 1; }

.btn-generate:active {
  transform: scale(0.97);
}

.btn-generate.loading {
  pointer-events: none;
  opacity: 0.8;
}

.btn-generate svg { width: 18px; height: 18px; }

/* ---- Reference Image Area ---- */
.ref-images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.ref-image-item {
  width: 60px;
  height: 60px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-glass);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  background: var(--bg-elevated);
}

.ref-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ref-image-add {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--border-glass);
  color: var(--text-tertiary);
  transition: all 0.2s;
}

.ref-image-add:hover {
  border-color: var(--border-active);
  color: var(--accent-soft);
  background: var(--accent-subtle);
}

.ref-image-add svg {
  width: 20px;
  height: 20px;
}

.ref-image-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.ref-image-item:hover .ref-image-remove { opacity: 1; }

/* ---- Results Area ---- */
.results-area {
  width: 100%;
  max-width: 800px;
  min-height: 200px;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
}

.result-card {
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  position: relative;
  border: 1px solid var(--border-glass);
  background: var(--bg-elevated);
  transition: all 0.3s var(--ease-smooth);
}

.result-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-glow);
  border-color: var(--border-active);
}

.result-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-card-actions {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 8px;
  background: linear-gradient(transparent, rgba(0,0,0,0.8));
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.3s;
}

.result-card:hover .result-card-actions { opacity: 1; }

.result-card-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 0.75rem;
  transition: background 0.2s;
  border: none;
}

.result-card-btn:hover {
  background: rgba(255,255,255,0.3);
}

.results-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  text-align: center;
  gap: 12px;
}

.results-empty svg {
  width: 48px;
  height: 48px;
  opacity: 0.4;
}

/* ---- Right Panel (参数面板) ---- */
.panel {
  grid-row: 2;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
  gap: 20px;
}

.panel-section {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.panel-section:last-child { border-bottom: none; }

.panel-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.panel-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.ratio-option {
  width: 48px;
  height: 36px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}

.ratio-option:hover {
  border-color: var(--border-glass);
  color: var(--text-primary);
}

.ratio-option.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-soft);
}

.count-option {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  background: transparent;
}

.count-option:hover {
  border-color: var(--border-glass);
  color: var(--text-primary);
}

.count-option.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-soft);
}

.select-input {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.85rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239898B0' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.select-input:focus {
  border-color: var(--border-active);
}

/* ---- Gallery (底部抽屉) ---- */
.gallery-drawer {
  border-top: 1px solid var(--border-glass);
  background: rgba(14, 14, 24, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  height: var(--gallery-h);
  transition: height 0.3s var(--ease-smooth);
  overflow: hidden;
}

.gallery-drawer.collapsed {
  height: 40px;
}

.gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  height: 40px;
  cursor: pointer;
  user-select: none;
}

.gallery-header:hover {
  background: rgba(255,255,255,0.02);
}

.gallery-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.gallery-title svg { width: 14px; height: 14px; }

.gallery-scroll {
  display: flex;
  gap: 10px;
  padding: 0 20px 12px;
  overflow-x: auto;
  height: calc(var(--gallery-h) - 40px);
  align-items: center;
}

.gallery-thumb {
  width: 120px;
  height: 120px;
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: all 0.2s;
  background: var(--bg-elevated);
}

.gallery-thumb:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.gallery-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  color: var(--text-tertiary);
  font-size: 0.85rem;
}

/* ---- Modal / Overlay ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s var(--ease-smooth);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-2xl);
  max-width: 900px;
  width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: slideUp 0.3s var(--ease-spring);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  z-index: 1;
}

.modal-header h2 {
  font-size: 1.2rem;
  font-weight: 700;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  border: none;
}

.modal-close:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

/* ---- Template Grid in Modal ---- */
.template-categories {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.template-cat-btn {
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border-subtle);
  transition: all 0.2s;
  cursor: pointer;
}

.template-cat-btn:hover {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

.template-cat-btn.active {
  background: var(--accent-subtle);
  border-color: var(--accent);
  color: var(--accent-soft);
}

.template-search {
  margin-bottom: 20px;
}

.template-search input {
  width: 100%;
  padding: 10px 16px;
  background: var(--bg-glass);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: border-color 0.2s;
}

.template-search input:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.template-search input::placeholder { color: var(--text-placeholder); }

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
}

.template-card {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  cursor: pointer;
  transition: all 0.3s var(--ease-smooth);
}

.template-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--border-active);
}

.template-card-thumb {
  aspect-ratio: 1;
  background: var(--bg-elevated);
  overflow: hidden;
  position: relative;
}

.template-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-card-info {
  padding: 12px 14px;
}

.template-card-title {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.template-card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-tertiary);
}

.template-card-category {
  color: var(--accent-soft);
  font-weight: 500;
}

.template-card-btn {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent-soft);
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border-active);
  transition: all 0.2s;
  cursor: pointer;
}

.template-card-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ---- Image Lightbox ---- */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s;
}

.lightbox-image {
  max-width: 90vw;
  max-height: 90vh;
  border-radius: var(--radius-lg);
  object-fit: contain;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  border: none;
  transition: background 0.2s;
}

.lightbox-close:hover { background: rgba(255,255,255,0.2); }

/* ---- Auth Pages ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--bg-root);
  background-image: radial-gradient(ellipse at 50% 0%, rgba(124, 58, 237, 0.1) 0%, transparent 60%);
}

.auth-card {
  width: 400px;
  padding: 40px;
  background: var(--bg-glass);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.auth-card h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.auth-card .subtitle {
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-align: center;
  margin-bottom: 28px;
}

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.form-input:focus {
  border-color: var(--border-active);
  box-shadow: 0 0 0 3px var(--accent-subtle);
}

.form-input::placeholder { color: var(--text-placeholder); }

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--gradient-primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.95rem;
  border-radius: var(--radius-md);
  transition: all 0.25s var(--ease-spring);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.3);
  cursor: pointer;
  border: none;
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.5);
  transform: translateY(-1px);
}

.auth-link {
  text-align: center;
  margin-top: 16px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.auth-link a {
  color: var(--accent-soft);
  font-weight: 500;
}

.auth-error {
  padding: 8px 12px;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: var(--radius-sm);
  color: var(--red);
  font-size: 0.8rem;
  margin-bottom: 16px;
  display: none;
}

.auth-error.show { display: block; }

/* ---- Notifications / Toasts ---- */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-md);
  font-size: 0.85rem;
  animation: slideInRight 0.3s var(--ease-spring);
  max-width: 400px;
}

.toast.success { border-color: var(--emerald); color: var(--emerald); }
.toast.error { border-color: var(--red); color: var(--red); }

@keyframes slideInRight {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---- Loading Spinner ---- */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Skeleton Loading ---- */
.skeleton {
  background: linear-gradient(90deg, var(--bg-glass) 25%, var(--bg-elevated) 50%, var(--bg-glass) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* ---- Responsive ---- */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: 1fr;
    grid-template-rows: var(--topbar-h) 1fr;
  }
  .sidebar, .panel { display: none; }
  .sidebar.mobile-open {
    display: flex;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 150;
  }
  .panel.mobile-open {
    display: flex;
    position: fixed;
    top: var(--topbar-h);
    right: 0;
    bottom: 0;
    width: var(--panel-w);
    z-index: 150;
  }
  .generate-area { padding: 20px; }
  .template-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .gallery-thumb { width: 90px; height: 90px; }
  .auth-card { width: 90vw; max-width: 400px; padding: 30px; }
}
