:root {
  color-scheme: dark;
  --bg: #0b0c0f;
  --bg-alt: #14161c;
  --panel: rgba(255,255,255,0.04);
  --line: rgba(255,255,255,0.08);
  --text: #f5f5f7;
  --muted: rgba(245,245,247,0.55);
  --accent: #8fd2ff;
  --accent-dim: rgba(143,210,255,0.12);
  --green: #34d399;
  --red: #f87171;
  --radius: 16px;
  --radius-sm: 10px;
}

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

body {
  font-family: 'Manrope', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── topbar ─────────────────────────────────── */
.topbar {
  padding: 16px 28px;
  border-bottom: 1px solid var(--line);
}
.logo {
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ── layout ─────────────────────────────────── */
.page { padding-bottom: 64px; }

.composer {
  display: grid;
  grid-template-columns: 380px minmax(0, 1fr);
  gap: 0;
  max-width: 1340px;
  margin: 0 auto;
  min-height: calc(100vh - 53px);
}

.panel { padding: 28px; }

.form-panel {
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.results-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: var(--bg-alt);
}

.form-title {
  font-size: 18px;
  font-weight: 700;
}

/* ── fields ─────────────────────────────────── */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.field span {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}
.field em {
  font-weight: 400;
  font-style: normal;
  opacity: 0.6;
}

input, textarea {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}
input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}
textarea { resize: vertical; min-height: 56px; }

/* ── chips ──────────────────────────────────── */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.chip:hover {
  border-color: var(--accent);
  color: var(--text);
}
.chip.active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

/* ── seo panel ──────────────────────────────── */
.seo-panel { margin-top: 4px; }
summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
  padding: 4px 0;
}
.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}
.toggle span { font-size: 13px; color: var(--muted); }
.toggle.small span { font-size: 12px; }
.toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

/* ── actions ────────────────────────────────── */
.actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 22px;
  height: 42px;
  border-radius: 999px;
  border: none;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent), #5eb8f5);
  color: #0b0c0f;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn.outline {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
}
.btn.outline:hover { border-color: var(--accent); }
.btn.small { height: 34px; padding: 0 16px; font-size: 13px; }

/* ── status ─────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-top: auto;
  padding-top: 8px;
}
.status-bar .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.status-bar.busy .dot {
  background: var(--accent);
  animation: pulse 1.2s infinite;
}
.status-bar.error .dot { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── results ────────────────────────────────── */
.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.result-header h2 { font-size: 18px; font-weight: 700; }

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.result-card { margin: 0; }
.result-card figcaption {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.img-wrap {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  overflow: hidden;
  background: rgba(255,255,255,0.02);
}
.img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: none;
}
.img-wrap img[src] { display: block; }
.img-wrap.placeholder .placeholder-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--muted);
  opacity: 0.5;
}
.img-wrap.has-image .placeholder-text { display: none; }

/* ── meta chips ─────────────────────────────── */
.auto-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.meta-chip {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.02);
  font-size: 12px;
  color: var(--muted);
}
.logo-thumb {
  height: 40px;
  width: auto;
  max-width: 120px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 4px;
}

/* ── prompt preview ─────────────────────────── */
.prompt-details { margin-top: 4px; }
.prompt-preview {
  white-space: pre-wrap;
  word-break: break-word;
  font: 12px/1.6 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: rgba(245,245,247,0.7);
  background: rgba(255,255,255,0.02);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 8px 0 0;
  min-height: 60px;
}

.hidden { display: none !important; }

.history-panel {
  margin: 0 28px 2rem;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.history-card figcaption {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.35;
}
.history-card small { opacity: 0.7; }

/* ── responsive ─────────────────────────────── */
@media (max-width: 860px) {
  .composer { grid-template-columns: 1fr; }
  .form-panel { border-right: none; border-bottom: 1px solid var(--line); }
  .results-grid { grid-template-columns: 1fr; }
  .history-panel { margin: 0 16px 2rem; }
}
