:root {
  --accent: #a78bfa;
  --accent-2: #60a5fa;
  --text: #f0f0f0;
  --muted: #9ca3af;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-hover: rgba(255, 255, 255, 0.08);
  --input-bg: rgba(0, 0, 0, 0.25);
  --error-bg: rgba(239, 68, 68, 0.1);
  --error-border: rgba(239, 68, 68, 0.3);
  --error-text: #fca5a5;
  --radius: 16px;
}

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 3rem 1rem 5rem;
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  background-color: #060612;
  background-image:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(124, 58, 237, 0.25) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(37, 99, 235, 0.2) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 60% 30%, rgba(167, 139, 250, 0.1) 0%, transparent 50%);
}

/* Soft glow orbs in the background */
body::before,
body::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 500px;
  height: 500px;
  background: rgba(124, 58, 237, 0.15);
  top: -100px;
  left: -100px;
}

body::after {
  width: 400px;
  height: 400px;
  background: rgba(37, 99, 235, 0.12);
  bottom: -80px;
  right: -80px;
}

header, main {
  position: relative;
  z-index: 1;
}

header {
  text-align: center;
  margin-bottom: 2.5rem;
}

header h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #fff 30%, var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

header p {
  color: var(--muted);
  font-size: 0.875rem;
  margin-top: 0.4rem;
  letter-spacing: 0.02em;
}

#sd-status {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.75rem;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: 99px;
  padding: 0.3rem 0.8rem;
  font-size: 0.78rem;
  color: var(--muted);
  backdrop-filter: blur(10px);
}

#status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.3s;
}

#status-dot.online {
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.6);
}

#status-dot.offline {
  background: #f87171;
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.6);
}

main {
  width: 100%;
  max-width: 740px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  padding: 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.07);
}

label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

textarea#prompt {
  width: 100%;
  min-height: 110px;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea#prompt::placeholder {
  color: rgba(156, 163, 175, 0.5);
}

textarea#prompt:focus {
  border-color: rgba(167, 139, 250, 0.5);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

.mode-toggle {
  display: flex;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  padding: 0.3rem;
}

.mode-btn {
  flex: 1;
  padding: 0.5rem 1rem;
  background: transparent;
  color: var(--muted);
  border: none;
  border-radius: 7px;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
}

.mode-desc {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--muted);
  margin-top: 0.1rem;
}

.mode-btn.active .mode-desc {
  color: rgba(255, 255, 255, 0.5);
}

.mode-btn:hover:not(.active) {
  background: var(--glass-hover);
  color: var(--text);
}

.mode-btn.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.5), rgba(37, 99, 235, 0.4));
  color: var(--text);
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.25), inset 0 1px 0 rgba(255,255,255,0.1);
  border: 1px solid rgba(167, 139, 250, 0.3);
}

.mode-icon {
  font-size: 0.9rem;
}

.generate-row {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}

#cancel-btn {
  display: none;
  flex-shrink: 0;
  width: 44px;
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 10px;
  font-size: 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

#cancel-btn.visible {
  display: flex;
  align-items: center;
  justify-content: center;
}

#cancel-btn:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.5);
}

#cancel-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button#generate-btn {
  width: 100%;
  padding: 0.85rem 1.5rem;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.15s, box-shadow 0.2s;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.35);
  position: relative;
  overflow: hidden;
}

button#generate-btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.12), transparent);
  pointer-events: none;
}

button#generate-btn:hover:not(:disabled):not(.loading) {
  opacity: 0.9;
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(124, 58, 237, 0.45);
}

button#generate-btn:active:not(:disabled) {
  transform: translateY(0);
}

button#generate-btn:disabled {
  cursor: not-allowed;
  transform: none;
}

#progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: rgba(255, 255, 255, 0.15);
  transition: width 0.4s ease;
  border-radius: 10px;
}

#btn-label {
  position: relative;
  z-index: 1;
}


#result {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
}

#result.visible {
  display: flex;
}

#output {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  cursor: zoom-in;
  transition: filter 0.4s ease, opacity 0.4s ease;
}

#output.preview {
  filter: blur(8px) brightness(0.75);
  opacity: 0.85;
  cursor: default;
  pointer-events: none;
}

#lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  cursor: zoom-out;
}

#lightbox.visible {
  display: flex;
}

#lightbox-img {
  max-width: 95vw;
  max-height: 88vh;
  border-radius: 10px;
  box-shadow: 0 16px 80px rgba(0, 0, 0, 0.8);
}

#lightbox-download {
  font-size: 0.85rem;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--glass-border);
  border-radius: 6px;
  padding: 0.4rem 1rem;
  background: var(--glass-bg);
  backdrop-filter: blur(10px);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

#lightbox-download:hover {
  color: var(--text);
  border-color: rgba(255,255,255,0.2);
  background: var(--glass-hover);
}


#error-msg {
  display: none;
  background: var(--error-bg);
  border: 1px solid var(--error-border);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  color: var(--error-text);
  font-size: 0.875rem;
  backdrop-filter: blur(10px);
}

#error-msg.visible {
  display: block;
}
