:root {
  --ink: #f5f1e6;
  --bg: #0d0d0f;
  --surface: #16171b;
  --surface-2: #1c1e22;
  --border: rgba(245, 241, 230, 0.08);
  --border-hover: rgba(222, 161, 46, 0.4);
  --accent: #dea12e;
  --accent-dim: rgba(222, 161, 46, 0.15);
  --text: #f5f1e6;
  --text-secondary: rgba(245, 241, 230, 0.6);
  --text-tertiary: rgba(245, 241, 230, 0.4);
  --serif: 'DM Serif Display', 'Times New Roman', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--text); font-family: var(--sans); min-height: 100vh; }
body { display: flex; flex-direction: column; }

a { color: inherit; text-decoration: none; }
em { font-style: italic; font-family: var(--serif); color: var(--accent); }

/* ── topbar ──────────────────────────────────────────────────────────── */
.topbar {
  height: 56px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; border-bottom: 1px solid var(--border);
  background: rgba(13, 13, 15, 0.85); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px; border: 2px solid var(--accent); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--serif); font-size: 16px; color: var(--accent);
}
.brand-name { font-family: var(--serif); font-size: 18px; letter-spacing: 0.4px; }
.who { font-size: 13px; color: var(--text-secondary); }

/* ── layout ──────────────────────────────────────────────────────────── */
.layout {
  flex: 1;
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  min-height: 0;
}
.composer, .gallery {
  padding: 32px 40px; overflow-y: auto;
}
.composer { border-right: 1px solid var(--border); display: flex; flex-direction: column; }
.gallery { background: linear-gradient(180deg, transparent, rgba(222, 161, 46, 0.02)); }

/* ── composer ────────────────────────────────────────────────────────── */
.kicker {
  font-size: 11px; letter-spacing: 0.32em; color: var(--accent);
  opacity: 0.85; text-transform: uppercase; margin-bottom: 14px;
}
.hero {
  font-family: var(--serif); font-size: 44px; line-height: 1.05;
  color: var(--accent); margin-bottom: 12px; letter-spacing: -0.01em;
}
.sub { color: var(--text-secondary); margin-bottom: 28px; font-size: 14px; }

.mode-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.mode-tab {
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-secondary); padding: 8px 16px; border-radius: 8px;
  font-family: inherit; font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.mode-tab:hover { color: var(--text); border-color: var(--border-hover); }
.mode-tab.active {
  background: var(--accent-dim); border-color: var(--accent); color: var(--accent);
}

.picker-row {
  display: flex; align-items: center; gap: 10px; margin-bottom: 16px;
}
.picker-label { font-size: 12px; color: var(--text-secondary); width: 32px; }
select {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  padding: 8px 12px; border-radius: 8px; font-family: inherit; font-size: 13px;
  flex: 1; cursor: pointer;
}
select:focus, select:hover { border-color: var(--border-hover); outline: none; }

.ref-row { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.ref-preview {
  width: 88px; height: 88px; border-radius: 10px; border: 1px dashed var(--border);
  background: var(--surface); cursor: pointer; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: var(--text-tertiary); text-align: center;
  transition: border-color 0.2s;
}
.ref-preview:hover { border-color: var(--accent); }
.ref-preview.has-img { border-style: solid; }
.ref-preview img { width: 100%; height: 100%; object-fit: cover; }
.ref-empty-hint { padding: 8px; line-height: 1.4; }

.ghost-btn {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 6px 12px; border-radius: 6px; font-family: inherit; font-size: 12px; cursor: pointer;
}
.ghost-btn:hover { border-color: var(--border-hover); color: var(--text); }

textarea {
  width: 100%; min-height: 130px; max-height: 280px; resize: vertical;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px 18px; font-family: inherit; font-size: 14px;
  line-height: 1.6; transition: border-color 0.2s, box-shadow 0.2s;
}
textarea:focus { outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-dim);
}
textarea::placeholder { color: var(--text-tertiary); }

.composer-actions { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; }
.advanced { display: flex; flex-direction: column; }
.adv-label { font-size: 12px; color: var(--text-tertiary); cursor: pointer; user-select: none; }
.adv-label:hover { color: var(--text-secondary); }
.adv-panel {
  margin-top: 10px; padding: 12px; background: var(--surface-2); border-radius: 8px;
  display: flex; flex-direction: column; gap: 8px;
}
.adv-row { display: flex; align-items: center; gap: 10px; }
.adv-row label { font-size: 12px; color: var(--text-secondary); width: 60px; }
.adv-row select { flex: 1; }

.primary-btn {
  background: var(--accent); color: #1a1a1a; border: none; padding: 12px 24px;
  border-radius: 10px; font-family: inherit; font-weight: 500; font-size: 14px;
  cursor: pointer; transition: all 0.2s; letter-spacing: 0.03em;
}
.primary-btn:hover { background: #e9b34a; transform: translateY(-1px); }
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.status { margin-top: 12px; font-size: 13px; color: var(--text-secondary); min-height: 18px; }
.status.error { color: #f87171; }

/* ── gallery ─────────────────────────────────────────────────────────── */
.gallery-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.gallery-title { font-family: var(--serif); font-size: 20px; }
.filter-tabs { display: flex; gap: 4px; }
.filter-tab {
  background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
  padding: 5px 12px; border-radius: 999px; font-family: inherit; font-size: 12px;
  cursor: pointer; transition: all 0.2s;
}
.filter-tab.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.filter-tab:hover:not(.active) { color: var(--text); border-color: var(--border-hover); }

.gen-list { display: flex; flex-direction: column; gap: 16px; }
.gen-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  overflow: hidden; transition: all 0.2s; cursor: pointer;
}
.gen-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.gen-media {
  width: 100%; aspect-ratio: 1; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
}
.gen-media img, .gen-media video { width: 100%; height: 100%; object-fit: cover; }
.gen-media.video-aspect { aspect-ratio: 16/9; }
.gen-meta { padding: 12px 14px; }
.gen-prompt {
  font-size: 13px; line-height: 1.5; color: var(--text); margin-bottom: 8px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.gen-foot { display: flex; align-items: center; justify-content: space-between; }
.gen-tag { font-size: 11px; color: var(--text-tertiary); }
.gen-actions { display: flex; gap: 4px; }
.gen-action {
  background: transparent; border: none; color: var(--text-tertiary);
  padding: 4px 6px; border-radius: 4px; cursor: pointer; font-size: 14px;
  transition: color 0.2s;
}
.gen-action:hover { color: var(--accent); background: var(--accent-dim); }
.gen-action.favorited { color: var(--accent); }

.gen-status-running, .gen-status-queued {
  width: 100%; aspect-ratio: 1; background: var(--surface-2);
  display: flex; align-items: center; justify-content: center;
  color: var(--accent); font-size: 13px; gap: 8px;
}
.gen-status-failed {
  width: 100%; padding: 24px; background: rgba(248, 113, 113, 0.06);
  color: #f87171; font-size: 12px; text-align: center;
}

.gen-empty {
  text-align: center; color: var(--text-tertiary); padding: 60px 0; font-size: 14px;
}

/* ── modal ──────────────────────────────────────────────────────────── */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
}
.modal[hidden] { display: none; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(0,0,0,0.7); backdrop-filter: blur(4px);
}
.modal-body {
  position: relative; max-width: 90vw; max-height: 90vh; background: var(--surface);
  border-radius: 16px; padding: 24px; overflow-y: auto; border: 1px solid var(--border);
}
.modal-close {
  position: absolute; top: 10px; right: 14px;
  background: transparent; border: none; color: var(--text-secondary);
  font-size: 24px; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: var(--text); }
.modal-content img, .modal-content video {
  max-width: 100%; max-height: 70vh; border-radius: 10px; display: block;
  margin: 0 auto 18px;
}
.modal-prompt { font-size: 14px; color: var(--text); line-height: 1.7; }
.modal-meta { font-size: 12px; color: var(--text-secondary); margin-top: 12px; }

/* ── spinner ─────────────────────────────────────────────────────────── */
@keyframes spin { to { transform: rotate(360deg); } }
.spin {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--accent-dim); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; vertical-align: middle;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .composer { border-right: none; border-bottom: 1px solid var(--border); }
}
