*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: 'Inter', 'Segoe UI', sans-serif;
  background: #0d0d1a;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

.blob {
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}
.blob1 { width: 550px; height: 550px; background: radial-gradient(circle, #818cf8, transparent); top: -160px; right: -120px; }
.blob2 { width: 420px; height: 420px; background: radial-gradient(circle, #6366f1, transparent); bottom: -120px; left: -90px; }

.container {
  position: relative;
  z-index: 1;
  max-width: 820px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 2rem;
  flex-wrap: wrap;
}
h1 {
  font-size: 2.4rem;
  font-weight: 600;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.25rem;
}
.accent { -webkit-text-fill-color: #818cf8; }
.subtitle { color: rgba(255,255,255,0.35); font-size: 0.875rem; }

/* Connect button */
.connect-btn {
  background: linear-gradient(135deg, #818cf8, #6366f1);
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  padding: 0.55rem 1.1rem;
  border-radius: 10px;
  cursor: pointer;
  transition: opacity 0.2s;
  white-space: nowrap;
}
.connect-btn:hover { opacity: 0.85; }
.connect-btn.large { font-size: 1rem; padding: 0.75rem 1.75rem; border-radius: 12px; }

.disconnect-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.5);
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}
.disconnect-btn:hover { border-color: #f87171; color: #f87171; }

/* Auth wall */
.auth-wall {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 55vh;
}
.auth-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  padding: 2.5rem 2rem;
  max-width: 420px;
}
.auth-icon { font-size: 3rem; }
.auth-card h2 { font-size: 1.3rem; font-weight: 600; color: #f1f1f1; }
.auth-card p { font-size: 0.85rem; color: rgba(255,255,255,0.4); line-height: 1.6; }
.auth-note { font-size: 0.7rem; color: rgba(255,255,255,0.2); }

/* Sections */
.section { margin-bottom: 1.25rem; }
.section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #818cf8;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.optional { color: rgba(255,255,255,0.2); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 0.7rem; }

/* Presets */
.presets { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.preset {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
  font-family: inherit;
  font-size: 0.78rem;
  padding: 0.35rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}
.preset:hover { border-color: #818cf8; color: #818cf8; }
.preset.active { background: rgba(129,140,248,0.15); border-color: #818cf8; color: #818cf8; }

/* Textarea / inputs */
textarea, input[type="text"], input[type="number"] {
  width: 100%;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  color: #e0e0e0;
  font-family: inherit;
  font-size: 0.875rem;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s;
}
textarea { padding: 0.75rem 1rem; resize: vertical; }
input[type="text"] { padding: 0.6rem 1rem; }
textarea:focus, input[type="text"]:focus, input[type="number"]:focus { border-color: #818cf8; }
textarea::placeholder, input::placeholder { color: rgba(255,255,255,0.2); }

/* Chips */
.chips-section { display: flex; flex-direction: column; gap: 0.65rem; }
.chips-group { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.chips-label { font-size: 0.72rem; color: rgba(255,255,255,0.3); width: 52px; flex-shrink: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 0.35rem; }
.chip {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.45);
  font-family: inherit;
  font-size: 0.73rem;
  padding: 0.25rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { border-color: #818cf8; color: #818cf8; }
.chip.active { background: rgba(129,140,248,0.15); border-color: #818cf8; color: #818cf8; }

/* Settings row */
.settings-row { display: flex; flex-wrap: wrap; gap: 1rem 1.5rem; align-items: flex-end; }
.setting-group { display: flex; flex-direction: column; gap: 0.4rem; }
.setting-label { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: #818cf8; }

.model-tabs { display: flex; gap: 0.3rem; }
.model-tab {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.4);
  font-family: inherit;
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.model-tab:hover { border-color: #818cf8; color: #818cf8; }
.model-tab.active { background: rgba(129,140,248,0.15); border-color: #818cf8; color: #818cf8; }

.seed-wrap { display: flex; gap: 0.4rem; align-items: center; }
.seed-wrap input { width: 110px; padding: 0.3rem 0.65rem; border-radius: 7px; }
#randomSeedBtn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  width: 32px; height: 32px;
  border-radius: 7px;
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex; align-items: center; justify-content: center;
}
#randomSeedBtn:hover { border-color: #818cf8; }

/* Toggle */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.5);
  user-select: none;
  align-self: flex-end;
  padding-bottom: 2px;
}
.toggle-label input { display: none; }
.toggle-track {
  width: 34px; height: 18px;
  background: rgba(255,255,255,0.1);
  border-radius: 9px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-label input:checked ~ .toggle-track { background: #6366f1; }
.toggle-label input:checked ~ .toggle-track .toggle-thumb { transform: translateX(16px); }

/* Negative prompt */
.neg-section input { font-size: 0.82rem; }

/* Generate button */
.generate-btn {
  width: 100%;
  background: linear-gradient(135deg, #818cf8, #6366f1);
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  padding: 0.8rem;
  border-radius: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
  margin-bottom: 1.5rem;
}
.generate-btn:hover { opacity: 0.88; }
.generate-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Loader */
.loader {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(255,255,255,0.4);
  font-size: 0.9rem;
  padding: 2rem 0;
}
.spinner {
  width: 22px; height: 22px;
  border: 2px solid rgba(255,255,255,0.1);
  border-top-color: #818cf8;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error {
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.2);
  color: #f87171;
  padding: 0.85rem 1rem;
  border-radius: 10px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}

/* Result */
.result-area {
  margin-bottom: 2rem;
}
.result-image-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}
.result-image-wrap img {
  max-width: 100%;
  max-height: 600px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  display: block;
}
.result-actions { display: flex; gap: 0.75rem; }
.action-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.6);
  font-family: inherit;
  font-size: 0.85rem;
  padding: 0.5rem 1.1rem;
  border-radius: 9px;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s;
}
.action-btn:hover { border-color: #818cf8; color: #818cf8; }
.action-btn.secondary { background: transparent; }

/* History */
.history-section { margin-top: 1rem; }
.history-grid {
  display: flex;
  gap: 0.6rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.history-thumb {
  width: 80px;
  height: 80px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255,255,255,0.07);
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
}
.history-thumb:hover { border-color: #818cf8; transform: scale(1.05); }
