:root {
  --bg: #09090b;
  --bg-raise: #111114;
  --panel: #131317;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.14);
  --text: #f2eee5;
  --muted: #a39e93;
  --faint: #6d6960;
  --gold: #e3c48b;
  --gold-soft: rgba(227, 196, 139, 0.08);
  --gold-edge: rgba(227, 196, 139, 0.5);
  --gold-grad: linear-gradient(135deg, #f7e6bb 0%, #e2bd7a 40%, #b88b4e 75%, #e8cd93 100%);
  --ink: #1a140b;
  --ok: #86d99b;
  --err: #ff8b7b;
  --radius-lg: 22px;
  --radius: 14px;
  --radius-sm: 10px;
  --serif: "Instrument Serif", "Cormorant Garamond", Georgia, serif;
  --sans: "Geist", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --ease: cubic-bezier(.2, .8, .2, 1);
  --row: 250px;
  --top: 64px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.lb-open { overflow: hidden; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
button:focus-visible, a:focus-visible, .tile:focus-visible { outline: 2px solid var(--gold-edge); outline-offset: 2px; }
::selection { background: rgba(227, 196, 139, 0.3); }

.aura {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 600px at 6% -12%, rgba(227, 196, 139, 0.10), transparent 60%),
    radial-gradient(800px 700px at 110% 115%, rgba(120, 98, 180, 0.08), transparent 60%),
    radial-gradient(600px 380px at 62% -6%, rgba(255, 255, 255, 0.035), transparent 70%);
}
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 90; opacity: .055;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ── Gate ─────────────────────────────────────────────────────────────── */
.gate { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 24px; overflow: hidden; }
.gate.leaving { animation: fade .45s ease reverse both; }
.gate-orb {
  position: absolute; width: min(760px, 130vw); aspect-ratio: 1; border-radius: 50%;
  background: conic-gradient(from 0deg, #f7e6bb, #b88b4e, #3b2b5c, #0b0b0e, #e2bd7a, #f7e6bb);
  filter: blur(100px); opacity: .26; animation: spin 28s linear infinite;
}
.gate-inner { position: relative; text-align: center; width: min(420px, 100%); animation: rise 1s var(--ease) both; }
.eyebrow { font-size: 11px; letter-spacing: .34em; text-transform: uppercase; color: var(--gold); margin: 0 0 14px; }
.wordmark {
  font: italic 400 clamp(72px, 16vw, 120px)/.92 var(--serif); letter-spacing: -.02em; margin: 0; padding: 0 .08em;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.gate-sub { color: var(--muted); margin: 16px 0 36px; font-size: 15px; }
.gate-card {
  display: flex; flex-direction: column; gap: 16px; padding: 24px; text-align: left;
  border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: rgba(10, 10, 12, .62);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); box-shadow: 0 30px 80px -30px rgba(0, 0, 0, .8);
}
.gate-card.shake { animation: shake .45s; }
.gate-submit { height: 50px; margin-top: 4px; font-size: 14px; }
.gate-submit:disabled { opacity: .6; }
.gate-note { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.gate-msg.ok { color: var(--muted); }
.link-btn { align-self: center; padding: 4px 6px; font-size: 13px; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(255, 255, 255, .2); transition: color .2s; }
.link-btn:hover { color: var(--gold); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
.gate-msg { min-height: 20px; margin: 14px 0 0; color: var(--err); font-size: 13px; }
.gate-foot {
  position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: 0; right: 0; margin: 0;
  text-align: center; color: var(--faint); font-size: 10.5px; letter-spacing: .3em; text-transform: uppercase;
}

/* ── Shell ────────────────────────────────────────────────────────────── */
.app { position: relative; z-index: 1; min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--top);
  display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
  background: rgba(9, 9, 11, .74); backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.brand-name {
  font: italic 400 31px/1 var(--serif); padding-right: .06em;
  background: var(--gold-grad); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.brand-tag { font-size: 10.5px; letter-spacing: .3em; text-transform: uppercase; color: var(--faint); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.icon-btn {
  width: 34px; height: 34px; flex: none; border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--line); color: var(--muted); transition: color .2s, border-color .2s, background .2s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: rgba(255, 255, 255, .04); }

.layout { display: grid; grid-template-columns: 420px minmax(0, 1fr); min-height: calc(100vh - var(--top)); }

/* ── Composer ─────────────────────────────────────────────────────────── */
.composer {
  position: sticky; top: var(--top); height: calc(100vh - var(--top)); overflow-y: auto;
  display: flex; flex-direction: column; gap: 22px; padding: 22px 22px 0;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, .015), transparent 40%);
  scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, .1) transparent;
}
.composer > * { animation: rise .7s var(--ease) both; }
.composer > :nth-child(2) { animation-delay: .05s; }
.composer > :nth-child(3) { animation-delay: .1s; }
.composer > :nth-child(4) { animation-delay: .15s; }
.composer > :nth-child(5) { animation-delay: .2s; }
.composer > :nth-child(n+6) { animation-delay: .25s; }

.medium {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; flex: none;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255, 255, 255, .02);
}
.medium button {
  position: relative; z-index: 1; height: 42px; border-radius: 999px;
  font-size: 12px; letter-spacing: .2em; text-transform: uppercase; color: var(--muted); transition: color .35s;
}
.medium button.active { color: var(--ink); font-weight: 600; }
.medium-glider {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 999px;
  background: var(--gold-grad); box-shadow: 0 8px 26px -8px rgba(227, 196, 139, .55);
  transition: transform .5s var(--ease);
}
.medium[data-kind="video"] .medium-glider { transform: translateX(100%); }

.field { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.label { font-size: 10.5px; letter-spacing: .26em; text-transform: uppercase; color: var(--faint); }
.hint { font-size: 11.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 22px 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 36px; padding: 0 15px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--muted); font-size: 13px; white-space: nowrap; transition: color .25s, border-color .25s, background .25s;
}
.chip:hover:not(:disabled):not(.active) { color: var(--text); border-color: var(--line-strong); }
.chip.active { color: var(--gold); border-color: var(--gold-edge); background: var(--gold-soft); }
.chip:disabled { opacity: .32; cursor: not-allowed; }
.chips.small .chip { height: 32px; padding: 0 13px; font-size: 12.5px; }

.refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); gap: 10px; }
.refs.slots { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.refs.drag .ref.empty { border-color: var(--gold-edge); color: var(--gold); background: var(--gold-soft); }
/* Padding sets the shape: aspect-ratio on grid-item buttons sizes the row from the wrong axis. */
.ref {
  position: relative; display: block; width: 100%; min-width: 0; height: 0; padding: 0 0 100%;
  border-radius: var(--radius-sm); overflow: hidden; border: 1px dashed var(--line-strong); color: var(--faint);
  transition: border-color .25s, color .25s, background .25s;
}
.refs.slots .ref { padding-bottom: 75%; }
.ref.empty:hover { border-color: var(--gold-edge); color: var(--gold); background: var(--gold-soft); }
.ref-in {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 5px; font-size: 11px; padding: 6px; text-align: center;
}
.ref.filled { border: 1px solid var(--line); }
.ref img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ref .tag {
  position: absolute; left: 6px; bottom: 6px; font-size: 9.5px; letter-spacing: .14em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 6px; background: rgba(0, 0, 0, .6); color: var(--text);
}
.ref .x {
  position: absolute; top: 6px; right: 6px; width: 24px; height: 24px; border-radius: 50%;
  background: rgba(0, 0, 0, .62); color: #fff; display: grid; place-items: center; opacity: 0; transition: opacity .2s;
}
.ref:hover .x, .ref .x:focus-visible { opacity: 1; }
.ref-veil { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .5); }
.spin {
  width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .2);
  border-top-color: var(--gold); animation: spin .8s linear infinite;
}

textarea {
  width: 100%; resize: vertical; min-height: 150px; max-height: 420px; padding: 16px 18px;
  border-radius: var(--radius); border: 1px solid var(--line); background: rgba(0, 0, 0, .28); color: var(--text);
  font: 400 15px/1.62 var(--sans); outline: 0; transition: border-color .25s, box-shadow .25s;
}
textarea:focus { border-color: rgba(227, 196, 139, .45); box-shadow: 0 0 0 5px rgba(227, 196, 139, .06); }
textarea::placeholder { color: var(--faint); font: italic 400 18px/1.45 var(--serif); }
textarea.nudge { animation: shake .4s; border-color: rgba(255, 139, 123, .5); }

.aspects { display: flex; flex-wrap: wrap; gap: 8px; }
.aspect {
  width: 64px; height: 64px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px;
  color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; transition: color .25s, border-color .25s, background .25s;
}
.aspect i { display: block; border: 1.5px solid currentColor; border-radius: 3px; }
.aspect.active { color: var(--gold); border-color: var(--gold-edge); background: var(--gold-soft); }
.aspect:hover:not(.active) { color: var(--text); border-color: var(--line-strong); }

.composer-foot {
  position: sticky; bottom: 0; margin: auto -22px 0; padding: 18px 22px 22px; flex: none;
  background: linear-gradient(180deg, rgba(9, 9, 11, 0), var(--bg) 38%);
}
.generate {
  position: relative; width: 100%; height: 58px; border-radius: 999px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; gap: 11px;
  background: var(--gold-grad); color: var(--ink); font-weight: 600; font-size: 15px; letter-spacing: .04em;
  box-shadow: 0 16px 42px -16px rgba(227, 196, 139, .65), inset 0 1px 0 rgba(255, 255, 255, .5);
  transition: transform .3s var(--ease), box-shadow .3s, opacity .2s;
}
.generate::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
  transform: translateX(-100%); transition: transform 1s var(--ease);
}
.generate:hover::before { transform: translateX(100%); }
.generate:hover { transform: translateY(-1px); box-shadow: 0 20px 52px -16px rgba(227, 196, 139, .8), inset 0 1px 0 rgba(255, 255, 255, .5); }
.generate:active { transform: scale(.99); }
.generate kbd {
  font: 500 10.5px var(--sans); padding: 3px 7px; border-radius: 6px;
  background: rgba(26, 20, 11, .12); color: rgba(26, 20, 11, .66);
}
.generate.busy { pointer-events: none; opacity: .85; }
.generate.busy .gen-icon svg { animation: spin 1.2s linear infinite; }
.gen-icon { display: grid; place-items: center; }

/* ── Studio ───────────────────────────────────────────────────────────── */
.studio { padding: 30px 28px 80px; min-width: 0; }
.studio-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.studio-title { font: 400 46px/1 var(--serif); margin: 0; letter-spacing: -.01em; }
.studio-title em { color: var(--gold); }
.studio-sub { margin: 9px 0 0; color: var(--faint); font-size: 12.5px; letter-spacing: .03em; }
.filter { display: flex; gap: 2px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; }
.filter button { height: 32px; padding: 0 15px; border-radius: 999px; font-size: 12.5px; color: var(--muted); transition: color .25s, background .25s; }
.filter button:hover:not(.active) { color: var(--text); }
.filter button.active { background: rgba(255, 255, 255, .08); color: var(--text); }

/* Justified rows: each tile grows in proportion to its aspect ratio. */
.grid { display: flex; flex-wrap: wrap; gap: 12px; }
.grid::after { content: ""; flex-grow: 999999; }
.tile {
  --ar: 1;
  position: relative; min-width: 0; max-width: 100%;
  flex: calc(var(--ar) * 100) 1 calc(var(--ar) * var(--row));
  border-radius: var(--radius); overflow: hidden; background: var(--bg-raise); border: 1px solid var(--line);
  animation: tileIn .6s var(--ease) both; isolation: isolate;
}
@keyframes tileIn { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }
.tile .box { position: relative; width: 100%; aspect-ratio: var(--ar); overflow: hidden; }
.tile.result { cursor: zoom-in; }
.tile.result .box { background: linear-gradient(120deg, #111114 0%, #19181d 45%, #111114 85%); background-size: 300% 100%; animation: sheen 2.4s linear infinite; }
.tile.result.ready .box { animation: none; }
.tile img, .tile video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  opacity: 0; transition: opacity .6s ease, transform .9s var(--ease);
}
.tile.ready img, .tile.ready video { opacity: 1; }
.tile.result:hover img, .tile.result:hover video { transform: scale(1.035); }
.veil {
  position: absolute; inset: 0; opacity: 0; transition: opacity .35s; pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, .35) 0%, transparent 26%, transparent 52%, rgba(0, 0, 0, .8) 100%);
}
.tile:hover .veil, .tile:focus-visible .veil { opacity: 1; }
.cap {
  position: absolute; left: 14px; right: 14px; bottom: 12px; margin: 0; font-size: 12.5px; line-height: 1.45;
  color: rgba(255, 255, 255, .9); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  opacity: 0; transform: translateY(6px); transition: opacity .35s, transform .35s var(--ease); pointer-events: none;
}
.tile:hover .cap, .tile:focus-visible .cap { opacity: 1; transform: none; }
.badges { position: absolute; top: 10px; left: 10px; display: flex; gap: 6px; pointer-events: none; }
.badge {
  display: inline-block; font-size: 9.5px; letter-spacing: .18em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px;
  background: rgba(0, 0, 0, .5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  color: var(--text); border: 1px solid rgba(255, 255, 255, .08);
}
.badge.gold { color: var(--gold); }
.play {
  position: absolute; right: 10px; top: 10px; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, .5); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #fff; pointer-events: none;
  transition: opacity .3s;
}
.tile.playing .play { opacity: 0; }

.tile.pending .box { background: linear-gradient(120deg, #111114 0%, #1c1a1f 42%, #111114 84%); background-size: 300% 100%; animation: sheen 2.6s linear infinite; }
@keyframes sheen { from { background-position: 100% 0; } to { background-position: -200% 0; } }
.pending-in { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 16px; text-align: center; }
.orbit { position: relative; width: 74px; height: 74px; display: grid; place-items: center; }
.orbit::before, .orbit::after { content: ""; position: absolute; inset: 0; border-radius: 50%; }
.orbit::before { border: 1px solid rgba(227, 196, 139, .16); }
.orbit::after { border: 1.5px solid transparent; border-top-color: var(--gold); animation: spin 1.6s linear infinite; }
.elapsed { font: italic 400 24px/1 var(--serif); color: var(--gold); font-variant-numeric: tabular-nums; }
.pmsg { font-size: 11.5px; color: var(--muted); max-width: 92%; letter-spacing: .02em; }
.pbar { position: absolute; left: 0; bottom: 0; height: 2px; width: 3%; background: var(--gold-grad); transition: width .9s var(--ease); }
.tile-btn {
  position: absolute; top: 10px; right: 10px; height: 26px; padding: 0 11px; border-radius: 999px; font-size: 11px;
  border: 1px solid var(--line-strong); color: var(--muted); background: rgba(0, 0, 0, .45); transition: color .2s, border-color .2s;
}
.tile-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, .3); }

.tile.failed .box, .tile.expired .box { display: grid; place-items: center; }
.tile.failed .box { background: repeating-linear-gradient(135deg, rgba(255, 139, 123, .035) 0 12px, transparent 12px 24px); }
.tile.expired .box { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .025) 0 12px, transparent 12px 24px); }
.note-in { padding: 44px 18px 18px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.5; max-width: 300px; }
.note-in b { display: block; font: italic 400 22px/1.2 var(--serif); margin-bottom: 6px; }
.tile.failed .note-in b { color: var(--err); }
.tile.expired .note-in b { color: var(--text); }

.studio-empty { text-align: center; padding: 14vh 20px; }
.studio-empty h3 { font: italic 400 42px/1.1 var(--serif); margin: 0 0 10px; }
.studio-empty p { color: var(--faint); margin: 0; }

/* ── Lightbox ─────────────────────────────────────────────────────────── */
.lightbox { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.lb-backdrop { position: absolute; inset: 0; background: rgba(5, 5, 7, .86); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); animation: fade .3s both; }
.lb-panel {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 360px;
  width: min(1440px, 100%); height: min(88vh, 940px);
  border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--panel);
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, .85); animation: pop .45s var(--ease) both;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.lb-media { position: relative; display: grid; place-items: center; background: #050506; min-height: 0; min-width: 0; }
.lb-media img, .lb-media video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; animation: fade .5s both; }
.lb-info { display: flex; flex-direction: column; gap: 14px; padding: 22px; border-left: 1px solid var(--line); min-height: 0; }
.lb-top { display: flex; justify-content: space-between; align-items: center; }
.lb-meta { color: var(--faint); font-size: 12px; margin: 0; letter-spacing: .03em; }
.lb-prompt { flex: 1; min-height: 60px; overflow-y: auto; font: 400 19px/1.5 var(--serif); padding-right: 6px; white-space: pre-wrap; scrollbar-width: thin; }
.lb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  height: 42px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 13px; color: var(--text); text-decoration: none; transition: color .25s, border-color .25s, filter .25s;
}
.btn:hover { border-color: var(--gold-edge); color: var(--gold); }
.btn.gold { grid-column: 1 / -1; border: 0; background: var(--gold-grad); color: var(--ink); font-weight: 600; }
.btn.gold:hover { color: var(--ink); filter: brightness(1.06); }
.btn.ghost { border-color: var(--line); color: var(--muted); }
.lb-nav {
  position: absolute; top: 50%; translate: 0 -50%; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; font-size: 24px; line-height: 1; color: var(--text);
  background: rgba(0, 0, 0, .5); border: 1px solid var(--line); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: border-color .2s;
}
.lb-nav:hover { border-color: var(--gold-edge); }
.lb-nav.prev { left: 14px; }
.lb-nav.next { right: 374px; }

/* ── Toasts ───────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; left: 50%; bottom: 26px; translate: -50% 0; z-index: 80; width: max-content; max-width: calc(100vw - 32px);
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-radius: 999px; font-size: 13px;
  background: rgba(22, 22, 27, .94); border: 1px solid var(--line-strong); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .7);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); animation: rise .4s var(--ease) both;
}
.toast::before { content: ""; width: 6px; height: 6px; flex: none; border-radius: 50%; background: var(--gold); }
.toast.ok::before { background: var(--ok); }
.toast.err::before { background: var(--err); }
.toast.out { animation: fade .3s ease reverse both; }

.tabbar { display: none; }

/* ── Forms ────────────────────────────────────────────────────────────── */
.form { display: flex; flex-direction: column; gap: 16px; }
.fld { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.fld > span:first-child { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--faint); }
.fld input {
  width: 100%; height: 46px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: rgba(0, 0, 0, .3); color: var(--text); font: 400 15px var(--sans); outline: 0;
  transition: border-color .25s, box-shadow .25s;
}
.fld input:focus { border-color: rgba(227, 196, 139, .45); box-shadow: 0 0 0 4px rgba(227, 196, 139, .07); }
.fld-row { display: flex; gap: 8px; align-items: center; }
.fld-row input { flex: 1; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; letter-spacing: .04em; }
.form-msg { min-height: 18px; margin: -4px 0 0; color: var(--err); font-size: 13px; }
.form-msg:empty { display: none; }
.fld-hint { color: var(--faint); font-size: 12px; line-height: 1.5; }
.check { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--muted); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--gold-deep); }
.modal-split { display: flex; flex-direction: column; gap: 8px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn.gold-outline { border-color: var(--gold-edge); color: var(--gold); }
.btn.gold-outline:hover { background: var(--gold-soft); }
.btn.danger { border-color: rgba(255, 139, 123, .5); color: var(--err); }
.btn.danger:hover { background: rgba(255, 139, 123, .08); color: var(--err); border-color: var(--err); }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ── Account ──────────────────────────────────────────────────────────── */
.quota-pill {
  display: flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--gold-edge); background: var(--gold-soft); color: var(--gold); font-size: 12.5px; font-weight: 500;
  font-variant-numeric: tabular-nums; transition: background .2s;
}
.quota-pill:hover { background: rgba(227, 196, 139, .14); }
.quota-pill.low { border-color: rgba(255, 139, 123, .5); background: rgba(255, 139, 123, .08); color: var(--err); }
.account { position: relative; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--gold-grad); color: var(--ink); font: italic 400 18px/1 var(--serif);
}
.avatar.sm { width: 32px; height: 32px; font-size: 16px; }
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 40; min-width: 240px; padding: 6px;
  border: 1px solid var(--line-strong); border-radius: var(--radius); background: rgba(20, 20, 24, .97);
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, .8); animation: rise .25s var(--ease) both;
}
.menu-head { display: flex; flex-direction: column; padding: 10px 12px 12px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-head b { font-weight: 500; }
.menu-head span { color: var(--faint); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.menu button { display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; color: var(--muted); }
.menu button:hover { background: rgba(255, 255, 255, .05); color: var(--text); }
#menuAdmin { color: var(--gold); }

.gen-cost {
  padding: 3px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: rgba(26, 20, 11, .14); color: rgba(26, 20, 11, .78);
}
.generate.short { filter: saturate(.35) brightness(.8); }

/* ── Modal ────────────────────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal-card {
  position: relative; width: min(460px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  padding: 22px; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--panel);
  box-shadow: 0 40px 120px -20px rgba(0, 0, 0, .85); animation: pop .4s var(--ease) both;
}
.modal-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-top h3 { margin: 0; font: italic 400 28px/1.1 var(--serif); }
.modal-body { display: flex; flex-direction: column; gap: 14px; }
.modal-note { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.55; }
.modal-loading, .admin-loading { display: grid; place-items: center; padding: 40px 0; }
.balance { display: flex; align-items: baseline; gap: 12px; }
.balance-num { font: italic 400 54px/1 var(--serif); color: var(--gold); font-variant-numeric: tabular-nums; }
.balance-label { color: var(--muted); font-size: 13px; }
.creds {
  margin: 0; padding: 14px 16px; border-radius: var(--radius-sm); background: rgba(0, 0, 0, .35); border: 1px solid var(--line);
  font: 13px/1.7 ui-monospace, "Cascadia Mono", Consolas, monospace; white-space: pre-wrap; word-break: break-all;
}
.meter { display: flex; flex-direction: column; gap: 8px; }
.meter-top { display: flex; align-items: baseline; gap: 12px; }
.meter-num { font: italic 400 50px/1 var(--serif); color: var(--gold); font-variant-numeric: tabular-nums; }
.meter-label { color: var(--text); font-size: 14px; }
.meter-label small { display: block; color: var(--faint); font-size: 12px; margin-top: 2px; }
.meter-bar { height: 4px; border-radius: 999px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: var(--gold-grad); border-radius: inherit; transition: width .6s var(--ease); }
.ledger { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.ledger li { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.lg-reason { display: flex; flex-direction: column; min-width: 0; }
.lg-reason small { color: var(--faint); font-size: 11.5px; margin-top: 2px; }
.lg-delta { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.lg-delta.plus { color: var(--ok); }
.lg-delta.minus { color: var(--muted); }

/* ── Admin ────────────────────────────────────────────────────────────── */
body.view-admin .layout, body.view-admin .tabbar { display: none !important; }
.admin { position: relative; padding: 30px 28px 80px; max-width: 1240px; margin: 0 auto; animation: rise .5s var(--ease) both; }
.admin-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.admin-head .eyebrow { margin-bottom: 8px; }
.admin-head-right { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat {
  display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-radius: var(--radius);
  border: 1px solid var(--line); background: linear-gradient(160deg, rgba(255, 255, 255, .035), rgba(255, 255, 255, .01));
}
.stat-num { font: italic 400 38px/1 var(--serif); color: var(--text); font-variant-numeric: tabular-nums; }
.stat-label { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.admin-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; }
.admin-bar .btn.gold { grid-column: auto; padding: 0 22px; }
.search {
  flex: 1; min-width: 0; height: 42px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(0, 0, 0, .25); color: var(--text); font: 400 14px var(--sans); outline: 0;
}
.search:focus { border-color: rgba(227, 196, 139, .45); }
.table { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.tr {
  display: grid; grid-template-columns: minmax(200px, 2fr) minmax(70px, .6fr) minmax(110px, 1fr) minmax(150px, 1.1fr) 280px;
  gap: 14px; align-items: center;
  padding: 14px 18px; border-bottom: 1px solid var(--line); font-size: 13.5px;
}
.tr:last-child { border-bottom: 0; }
.tr.th { padding: 11px 18px; font-size: 10.5px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); background: rgba(255, 255, 255, .02); }
.tr:not(.th):hover { background: rgba(255, 255, 255, .02); }
.tr.off { opacity: .55; }
.who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.who-text { display: flex; flex-direction: column; min-width: 0; }
.who-text b { font-weight: 500; }
.who-text small, .cell small { color: var(--faint); font-size: 12px; display: block; overflow: hidden; text-overflow: ellipsis; }
.cell { color: var(--muted); font-variant-numeric: tabular-nums; }
.cell .big { color: var(--text); font-size: 15px; font-weight: 500; }
.cell .big .of { color: var(--faint); font-weight: 400; font-size: 13px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; }
.admin-empty { color: var(--faint); padding: 26px 18px; margin: 0; text-align: center; }
.admin-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.admin-h { margin: 0 0 12px; font-size: 10.5px; letter-spacing: .24em; text-transform: uppercase; color: var(--faint); font-weight: 500; }
.admin-h small { letter-spacing: .04em; text-transform: none; margin-left: 6px; }
.feed { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.feed-row { display: flex; gap: 14px; padding: 12px; border-bottom: 1px solid var(--line); }
.feed-row:last-child { border-bottom: 0; }
.thumb { flex: none; width: 76px; height: 76px; border-radius: var(--radius-sm); overflow: hidden; background: var(--bg-raise); display: block; }
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.none { background: repeating-linear-gradient(135deg, rgba(255, 255, 255, .03) 0 8px, transparent 8px 16px); }
.feed-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.feed-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.feed-top b { font-weight: 500; font-size: 13.5px; }
.feed-prompt { margin: 0; color: var(--muted); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feed-main small { color: var(--faint); font-size: 11.5px; }
.pill { font-size: 10.5px; letter-spacing: .08em; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line-strong); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: rgba(134, 217, 155, .35); }
.pill.err { color: var(--err); border-color: rgba(255, 139, 123, .35); }
.pill.gold { color: var(--gold); border-color: var(--gold-edge); }
.settings { max-width: 640px; gap: 26px; }
.settings .btn.gold { align-self: flex-start; padding: 0 28px; }
.set-group { display: flex; flex-direction: column; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }

/* ── Responsive ───────────────────────────────────────────────────────── */
@media (max-width: 1180px) {
  .layout { grid-template-columns: 380px minmax(0, 1fr); }
}
@media (max-width: 900px) {
  :root { --row: 150px; --top: 58px; }
  .topbar { padding: 0 16px; }
  .brand-tag { display: none; }
  .layout { display: block; }
  .composer { position: static; height: auto; overflow: visible; border-right: 0; padding: 18px 16px 0; gap: 20px; }
  .composer-foot { bottom: calc(76px + env(safe-area-inset-bottom)); margin: 4px -16px 0; padding: 14px 16px 16px; }
  .generate kbd { display: none; }
  .studio { padding: 22px 16px 120px; }
  .studio-title { font-size: 38px; }
  .grid { gap: 8px; }
  body.view-create .studio, body.view-studio .composer { display: none; }
  .veil { opacity: 1; background: linear-gradient(180deg, rgba(0, 0, 0, .35), transparent 34%); }
  .cap { display: none; }
  .tabbar {
    display: flex; gap: 4px; padding: 5px; position: fixed; left: 50%; translate: -50% 0; z-index: 30;
    bottom: calc(14px + env(safe-area-inset-bottom)); border-radius: 999px;
    background: rgba(18, 18, 22, .88); border: 1px solid var(--line-strong); box-shadow: 0 16px 40px -10px rgba(0, 0, 0, .8);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  }
  .tabbar button { height: 44px; padding: 0 24px; border-radius: 999px; font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 8px; transition: color .25s; }
  .tabbar button.active { background: var(--gold-grad); color: var(--ink); font-weight: 600; }
  .tabbar .count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; font-size: 10.5px; display: grid; place-items: center; background: var(--gold); color: var(--ink); font-weight: 600; }
  .tabbar button.active .count { background: var(--ink); color: var(--gold); }
  .lightbox { padding: 10px; }
  .lb-panel { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; height: 100%; border-radius: 18px; }
  .lb-info { border-left: 0; border-top: 1px solid var(--line); max-height: 48vh; padding: 16px; }
  .lb-prompt { font-size: 16px; }
  .lb-nav { display: none; }
  .toasts { bottom: calc(92px + env(safe-area-inset-bottom)); }
  .topbar-right { gap: 8px; }
  .quota-pill { padding: 0 11px; }
  .admin { padding: 22px 16px 60px; }
  .admin-head-right { width: 100%; justify-content: space-between; }
  .stat-num { font-size: 30px; }
  .admin-cols { grid-template-columns: 1fr; }
  .tr.th { display: none; }
  .tr { grid-template-columns: 1fr 1fr 1fr; gap: 10px 12px; padding: 16px; }
  .tr .who, .tr .row-actions { grid-column: 1 / -1; }
  .tr .row-actions { justify-content: flex-start; }
  .cell::before { content: attr(data-label); display: block; font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); margin-bottom: 2px; }
  .admin-bar { flex-wrap: wrap; }
}
@media (hover: none) { .ref .x { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
