:root {
  --bg: #0c0f14;
  --surface: #141a24;
  --surface-2: #1c2433;
  --border: #2a3548;
  --text: #e8edf5;
  --muted: #8b9bb5;
  --accent: #5b8def;
  --accent-hover: #7aa3f5;
  --success: #34d399;
  --error: #f87171;
  --radius: 12px;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "DM Sans", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.bg-glow {
  position: fixed;
  inset: -20% 0 auto;
  height: 60vh;
  background: radial-gradient(
    ellipse 80% 50% at 50% -10%,
    rgba(91, 141, 239, 0.18),
    transparent 70%
  );
  pointer-events: none;
  z-index: 0;
}

.header,
.layout,
.footer {
  position: relative;
  z-index: 1;
}

.header {
  text-align: center;
  padding: 2.5rem 1.5rem 1rem;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.5rem;
  letter-spacing: -0.02em;
}

.logo-icon {
  color: var(--accent);
  font-size: 1.25rem;
}

.tagline {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.layout {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 1.25rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.prompt-input {
  width: 100%;
  resize: vertical;
  min-height: 140px;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  line-height: 1.55;
}

.prompt-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.image-upload {
  margin-top: 1rem;
}

.image-hint {
  margin: 0 0 0.65rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.image-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.image-input {
  flex: 1;
  min-width: 200px;
  font-size: 0.85rem;
  color: var(--muted);
}

.image-input::file-selector-button {
  margin-right: 0.75rem;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

.image-preview-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.image-preview-list[hidden] {
  display: none;
}

.image-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
  aspect-ratio: 1;
}

.image-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.image-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  border: none;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}

.image-thumb-remove:hover {
  background: rgba(220, 38, 38, 0.9);
}

.image-thumb-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0.25rem 0.35rem;
  font-size: 0.65rem;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 1rem;
}

.btn {
  font: inherit;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 0.65rem 1.1rem;
  font-weight: 600;
  transition: background 0.15s, opacity 0.15s, transform 0.1s;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:not(:disabled):hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--muted);
}

.btn-small {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

.btn-small:not(:disabled):hover {
  background: var(--border);
}

.btn.is-loading .btn-label::after {
  content: "…";
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.4;
  }
}

.status {
  min-height: 1.4em;
  margin: 0.85rem 0 0;
  font-size: 0.88rem;
  color: var(--muted);
}

.status.is-error {
  color: var(--error);
}

.status.is-success {
  color: var(--success);
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.preview-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.preview-actions {
  display: flex;
  gap: 0.5rem;
}

.preview-frame-wrap {
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #fff;
  min-height: 420px;
}

#preview {
  width: 100%;
  height: min(70vh, 560px);
  border: 0;
  display: block;
  background: #fff;
}

.footer {
  text-align: center;
  padding: 1rem 1.5rem 2rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.footer code {
  background: var(--surface);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.8em;
}
