:root {
  --bg: #070709;
  --surface-1: #101015;
  --surface-2: #16161d;
  --surface-3: #1c1c26;
  --ink: #f4f1ea;
  --ink-2: #c9c4b8;
  --muted: #8f8a80;
  --gold: #d4b978;
  --gold-bright: #ead39c;
  --gold-soft: rgba(212, 185, 120, 0.12);
  --hairline: rgba(255, 255, 255, 0.085);
  --hairline-strong: rgba(212, 185, 120, 0.35);
  --ok: #34d399;
  --err: #fca5a5;
  --font-display: "Space Grotesk", system-ui, sans-serif;
  --font-sans: "Inter", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

[hidden] { display: none !important; }
* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(ellipse 75% 42% at 80% 0%, rgba(212, 185, 120, 0.09), transparent 65%),
    radial-gradient(ellipse 50% 35% at 10% 88%, rgba(212, 185, 120, 0.04), transparent 70%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
}

.mono { font-family: var(--font-mono); }
.muted-note { font-size: 12px; color: var(--muted); }

.shell {
  max-width: 1440px;
  margin: 0 auto;
  padding: 16px clamp(16px, 3vw, 32px) 36px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 16px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--hairline);
}

.brand-wrap { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: var(--font-display); font-weight: 700; letter-spacing: 0.06em; font-size: 16px; }
.brand img { width: 28px; height: 28px; }

.badge-pill, .user-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--gold);
  background: var(--gold-soft);
  border: 1px solid var(--hairline-strong);
  padding: 4px 10px;
  border-radius: 999px;
}

.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ghost-link, .btn-ghost {
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 8px;
  padding: 7px 12px;
  text-decoration: none;
  cursor: pointer;
}
.ghost-link:hover, .btn-ghost:hover { border-color: var(--hairline-strong); color: var(--gold); }

.auth-stage { display: flex; justify-content: center; padding: 24px 0 48px; }
.auth-card {
  width: 100%;
  max-width: 540px;
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 28px;
}
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; color: var(--gold); margin-bottom: 8px; }
.auth-card h1 { font-family: var(--font-display); font-size: 24px; line-height: 1.2; margin: 0 0 10px; }
.auth-sub { color: var(--ink-2); font-size: 13.5px; margin: 0 0 20px; }

.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 18px; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.auth-tab {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  padding: 9px;
  border-radius: 7px;
  cursor: pointer;
}
.auth-tab.is-active { background: var(--surface-3); color: var(--gold); }

.auth-form, .gen-form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--ink-2); font-weight: 500; }
.field input, .field textarea, .field select, .mini-select, .chat-form textarea {
  width: 100%;
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  padding: 10px 12px;
  font: inherit;
}
.field input:focus, .field textarea:focus, .chat-form textarea:focus { outline: 1px solid var(--gold); border-color: var(--gold); }

.btn-primary {
  background: linear-gradient(135deg, var(--gold), #b99953);
  color: #070709;
  font-family: var(--font-display);
  font-weight: 700;
  border: 0;
  border-radius: 9px;
  padding: 11px 18px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:disabled { opacity: 0.55; cursor: wait; }
.btn-primary.small, .btn-ghost.small { padding: 7px 12px; font-size: 12px; }

.banner-error {
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(248, 113, 113, 0.45);
  color: var(--err);
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12.5px;
}

.feature-strip {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.feature-strip div { display: flex; flex-direction: column; gap: 2px; }
.feature-strip b { font-size: 12px; color: var(--gold); }
.feature-strip span { font-size: 11.5px; color: var(--muted); }

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(340px, 0.95fr);
  gap: 18px;
  align-items: start;
}
@media (max-width: 1020px) {
  .studio-grid { grid-template-columns: 1fr; }
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  padding: 20px;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-head h2 { font-family: var(--font-display); font-size: 19px; margin: 0; }

.mode-switch { display: inline-flex; background: var(--surface-2); padding: 4px; border-radius: 10px; gap: 4px; }
.mode-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
}
.mode-btn.is-active { background: var(--gold); color: #070709; }

.controls-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.gen-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.stage-card {
  margin-top: 18px;
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  overflow: hidden;
}
.stage-empty { padding: 36px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.stage-media-wrap { background: #040406; display: flex; justify-content: center; align-items: center; max-height: 460px; }
.stage-media-wrap img, .stage-media-wrap video { max-width: 100%; max-height: 460px; display: block; object-fit: contain; }
.stage-meta { padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 12px; border-top: 1px solid var(--hairline); flex-wrap: wrap; }
.stage-prompt { font-size: 12px; color: var(--ink-2); flex: 1; min-width: 180px; }

.library-head { display: flex; justify-content: space-between; align-items: center; margin: 20px 0 10px; }
.library-head h3 { font-family: var(--font-display); font-size: 15px; margin: 0; }
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)); gap: 12px; }
.lib-card {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.lib-thumb { height: 128px; background: #040406; display: flex; align-items: center; justify-content: center; overflow: hidden; cursor: pointer; }
.lib-thumb img, .lib-thumb video { width: 100%; height: 100%; object-fit: cover; }
.lib-body { padding: 9px 10px; display: flex; flex-direction: column; gap: 6px; }
.lib-title { font-size: 11.5px; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }

.chat-panel { display: flex; flex-direction: column; gap: 12px; }
.mini-select { width: auto; padding: 6px 10px; font-size: 12px; }
.quick-ideas { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  background: var(--surface-2);
  color: var(--ink-2);
  border: 1px solid var(--hairline);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11.5px;
  cursor: pointer;
}
.chip:hover { border-color: var(--hairline-strong); color: var(--gold); }

.chat-messages {
  max-height: 520px;
  min-height: 280px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}
.chat-msg {
  background: var(--surface-2);
  border: 1px solid var(--hairline);
  border-radius: 12px;
  padding: 11px 13px;
}
.chat-msg.user { border-color: var(--hairline-strong); background: rgba(212, 185, 120, 0.06); }
.chat-role { font-family: var(--font-mono); font-size: 10.5px; color: var(--gold); margin-bottom: 4px; text-transform: uppercase; }
.chat-text { font-size: 13px; color: var(--ink); white-space: pre-wrap; }

.prompt-box {
  margin-top: 10px;
  background: var(--surface-3);
  border: 1px solid var(--hairline);
  border-radius: 9px;
  padding: 9px 10px;
}
.prompt-box-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; }
.prompt-box-label { font-family: var(--font-mono); font-size: 10.5px; color: var(--gold); }
.prompt-box-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.prompt-box-body { font-size: 12px; color: var(--ink-2); user-select: all; }

.chat-form { display: flex; flex-direction: column; gap: 8px; padding-top: 8px; border-top: 1px solid var(--hairline); }
.chat-submit-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }

.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--surface-3);
  color: var(--gold-bright);
  border: 1px solid var(--hairline-strong);
  padding: 10px 15px;
  border-radius: 10px;
  font-size: 12.5px;
  z-index: 99;
}
