:root {
  --bg: #0a0a0d;
  --bg-2: #111116;
  --surface: #16161d;
  --surface-2: #1d1d26;
  --surface-3: #262632;
  --line: #2a2a36;
  --line-2: #3a3a4a;
  --text: #f4f4f7;
  --text-2: #b4b4c2;
  --text-3: #7a7a8c;
  --accent: #d6ff3d;
  --accent-ink: #0a0a0d;
  --pink: #ff3d6e;
  --violet: #7b2cff;
  --danger: #ff5a5a;
  --ok: #4ade80;
  --radius: 14px;
  --radius-sm: 10px;
  --panel-w: 420px;
  --topbar-h: 60px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; }
svg { width: 1em; height: 1em; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- Mock banner ---------- */
.mock-banner {
  background: repeating-linear-gradient(-45deg, #2b2400, #2b2400 10px, #332a00 10px, #332a00 20px);
  color: #ffd84d;
  font-size: 12.5px;
  text-align: center;
  padding: 6px 16px;
  border-bottom: 1px solid #4a3d00;
}

/* ---------- Top bar ---------- */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(10, 10, 13, 0.85);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 16px; letter-spacing: -0.01em; color: var(--text); text-decoration: none; }
.brand-dim { color: var(--text-3); font-weight: 600; margin-left: 4px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--pink), var(--violet)); font-size: 14px;
  box-shadow: 0 4px 18px rgba(255, 61, 110, 0.35);
}
.count { background: var(--surface-3); color: var(--text-2); font-size: 11px; border-radius: 999px; padding: 1px 7px; }
.topbar-right { margin-left: auto; }
.pill-note {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--accent);
  border: 1px solid rgba(214, 255, 61, 0.25); background: rgba(214, 255, 61, 0.06); padding: 6px 12px; border-radius: 999px;
}

/* ---------- Layout ---------- */
.studio {
  display: grid;
  grid-template-columns: var(--panel-w) 1fr;
  height: calc(100vh - var(--topbar-h));
  height: calc(100dvh - var(--topbar-h));
}
body:has(.mock-banner:not([hidden])) .studio { height: calc(100dvh - var(--topbar-h) - 31px); }

/* ---------- Panel ---------- */
.panel {
  display: flex; flex-direction: column; min-height: 0;
  border-right: 1px solid var(--line); background: var(--bg-2);
}
.panel-scroll { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.block { margin-bottom: 22px; }
.block-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.block-head h2 { font-size: 13px; font-weight: 600; margin: 0; letter-spacing: 0.01em; }
.optional { color: var(--text-3); font-weight: 400; margin-left: 4px; }
.step {
  width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center;
  font-size: 11px; color: var(--text-3); border: 1px solid var(--line-2);
}

/* Segmented mode tabs */
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button {
  border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; font-weight: 600; color: var(--text-2);
  display: flex; align-items: center; justify-content: center; gap: 8px; transition: background .15s, color .15s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-selected="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 rgba(255,255,255,.06) inset; }
.mode-desc { color: var(--text-3); font-size: 12.5px; margin: 8px 2px 0; }

/* Panel footer */
.panel-foot { padding: 12px 18px 16px; border-top: 1px solid var(--line); background: var(--bg-2); }
.generate {
  position: relative; width: 100%; height: 50px; border: 0; border-radius: 12px; font-weight: 700; font-size: 15px;
  background: var(--accent); color: var(--accent-ink); display: flex; align-items: center; justify-content: center; gap: 10px;
  box-shadow: 0 8px 28px rgba(214, 255, 61, 0.22); transition: transform .1s, box-shadow .15s, background .15s, opacity .15s;
}
.generate:not(:disabled):hover { transform: translateY(-1px); box-shadow: 0 10px 32px rgba(214, 255, 61, 0.32); }
.generate:not(:disabled):active { transform: translateY(0); }
.generate:disabled { background: var(--surface-3); color: var(--text-3); box-shadow: none; }
.generate .spinner { display: none; }
.generate.loading .spinner { display: block; }
.generate.loading .generate-label { opacity: .7; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.foot-note { display: flex; align-items: center; justify-content: center; gap: 6px; color: var(--text-3); font-size: 11.5px; margin: 10px 0 0; text-align: center; }

/* ---------- Workspace ---------- */
.workspace { overflow-y: auto; padding: 14px 24px 40px; min-width: 0; }
.workspace-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.workspace-head h1 { font-size: 20px; margin: 0; letter-spacing: -0.01em; }
.filter { display: flex; gap: 4px; }
.filter button { border: 1px solid var(--line); background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; }
.filter button.active { background: var(--text); color: var(--bg); border-color: var(--text); }

.how { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; text-align: left; }
.how li { display: flex; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; color: var(--text-2); }
.how li span { width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; background: var(--surface-3); color: var(--text); font-weight: 700; font-size: 12px; flex: none; }
.how strong { color: var(--text); margin-right: 6px; }

.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.card {
  position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line);
  cursor: pointer; transition: transform .15s, border-color .15s; animation: pop .25s ease-out;
}
.card:hover { transform: translateY(-2px); border-color: var(--line-2); }
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.card-media { position: relative; aspect-ratio: 9 / 16; background: #000; overflow: hidden; }
.card-media.ar-1x1 { aspect-ratio: 1 / 1; }
.card-media.ar-16x9 { aspect-ratio: 16 / 9; }
.card-media img, .card-media video { width: 100%; height: 100%; object-fit: cover; display: block; }
.card.processing .card-media > video, .card.queued .card-media > video { filter: blur(6px) brightness(.45) saturate(1.2); transform: scale(1.1); }
.card.failed .card-media > video { filter: grayscale(1) brightness(.35); }
.card-overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 16px; }
.ring { width: 64px; height: 64px; position: relative; }
.ring svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.ring .track { stroke: rgba(255,255,255,.15); }
.ring .bar { stroke: var(--accent); stroke-linecap: round; transition: stroke-dashoffset .6s; }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; }
.overlay-label { font-size: 12.5px; color: var(--text-2); }
.shimmer::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.08) 50%, transparent 70%); background-size: 200% 100%; animation: shimmer 1.6s linear infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.card-status {
  position: absolute; top: 10px; left: 10px; z-index: 2; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px;
  background: rgba(0,0,0,.6); backdrop-filter: blur(6px); display: inline-flex; align-items: center; gap: 5px;
}
.card-status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.card.completed .card-status::before { background: var(--ok); }
.card.failed .card-status::before { background: var(--danger); }
.card-play {
  position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity .15s; pointer-events: none;
}
.card-play span { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: rgba(0,0,0,.55); backdrop-filter: blur(6px); font-size: 18px; }
.card.completed:hover .card-play { opacity: 1; }
.card.completed.playing .card-play { opacity: 0; }
.card-body { padding: 10px 12px 12px; }
.card-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 600; font-size: 13px; }
.card-title small { color: var(--text-3); font-weight: 500; font-size: 11.5px; white-space: nowrap; }
.card-prompt { color: var(--text-3); font-size: 12px; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-actions { position: absolute; right: 10px; top: 10px; z-index: 2; display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.card:hover .card-actions, .card:focus-within .card-actions { opacity: 1; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.75); backdrop-filter: blur(6px); animation: fade .2s; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 320px; max-width: 1080px; width: 100%; max-height: calc(100dvh - 48px);
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; overflow: hidden; animation: pop .2s ease-out;
}
.modal-close { position: absolute; top: 12px; right: 12px; z-index: 2; }
.modal-media { background: #000; display: grid; place-items: center; min-height: 360px; }
.modal-media video, .modal-media img { max-width: 100%; max-height: calc(100dvh - 48px); display: block; }
.modal-info { padding: 22px 20px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-info h3 { margin: 0; font-size: 18px; padding-right: 36px; }
.modal-prompt { margin: 0; color: var(--text-2); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font-size: 13px; }
.modal-prompt:empty { display: none; }
.meta { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; font-size: 13px; }
.meta dt { color: var(--text-3); }
.meta dd { margin: 0; text-align: right; }
.modal-actions { display: grid; gap: 8px; margin-top: auto; }
.btn {
  height: 42px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--surface-2); font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text);
}
.btn:hover { background: var(--surface-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }

/* ---------- Toasts ---------- */
.toasts { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 60; }
.toast {
  background: var(--surface-2); border: 1px solid var(--line-2); border-left: 3px solid var(--accent); padding: 11px 14px; border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.45); max-width: 360px; animation: pop .2s ease-out; font-size: 13px;
}
.toast.error { border-left-color: var(--danger); }
.toast.ok { border-left-color: var(--ok); }

/* ---------- Genjutsu panel ---------- */
.model-hero { position: relative; height: 104px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); flex: none; }
.model-hero-art {
  position: absolute; inset: 0; background: linear-gradient(120deg, #1b1030, #4a1a5c 30%, #0d2b3a 60%, #2b0f1f); background-size: 300% 300%;
  animation: drift 8s ease-in-out infinite alternate;
}
.model-hero-art::before {
  content: ""; position: absolute; inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 18px, rgba(255,255,255,.05) 18px 20px), radial-gradient(circle at 75% 30%, rgba(214,255,61,.25), transparent 45%);
}
.model-hero-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(to top, rgba(0,0,0,.8), transparent 70%); }
.model-hero-text { position: absolute; left: 12px; bottom: 10px; display: flex; flex-direction: column; }
.model-hero-text strong { font-family: Anton, Impact, sans-serif; font-weight: 400; font-size: 21px; letter-spacing: .01em; color: var(--accent); line-height: 1.1; text-transform: uppercase; }
.model-hero-text span { color: var(--text-2); font-size: 12px; }

.seg { flex: none; }
.slot {
  position: relative; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  min-height: 132px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 4px; padding: 16px; cursor: pointer; transition: border-color .15s, background .15s; flex: none;
}
.slot:hover { background: var(--surface-2); border-color: var(--line-2); }
.slot.dragover { border-color: var(--accent); background: rgba(214,255,61,.06); }
.slot input[type=file] { display: none; }
.slot-icons { display: flex; margin-bottom: 8px; }
.slot-icons span {
  width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-size: 14px; color: var(--text);
  background: var(--surface-3); border: 2px solid var(--surface); margin-left: -6px;
}
.slot-icons span:first-child { margin-left: 0; }
.slot:hover .slot-icons span { border-color: var(--surface-2); }
.slot-title { font-weight: 600; font-size: 13.5px; line-height: 1.3; }
.slot-hint { color: var(--text-3); font-size: 11.5px; margin-top: 2px; }
.slot.error { border-color: rgba(255,90,90,.6); }

.slot.video-filled { padding: 0; cursor: default; min-height: 0; overflow: hidden; background: #000; }
.slot.video-filled video { width: 100%; max-height: 260px; display: block; object-fit: contain; background: #000; }
.slot .drop-badge { position: absolute; left: 8px; top: 8px; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.6); backdrop-filter: blur(6px); }
.slot .drop-actions { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; }
.slot .drop-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.1); }
.slot .drop-progress i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .15s; }

.slot.images-filled { cursor: default; align-items: stretch; justify-content: flex-start; text-align: left; padding: 10px; }
.thumbs-head { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; color: var(--text-2); margin-bottom: 8px; padding: 0 2px; }
.thumbs-head b { color: var(--text); font-weight: 600; }
.link-btn { border: 0; background: none; color: var(--text-3); font-size: 12px; padding: 0; }
.link-btn:hover { color: var(--text); }
.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.thumb { position: relative; aspect-ratio: 1; border-radius: 9px; overflow: hidden; background: var(--surface-3); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.uploading img { filter: brightness(.5); }
.thumb .tag { position: absolute; left: 4px; bottom: 4px; font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 5px; background: rgba(0,0,0,.65); }
.thumb .rm {
  position: absolute; right: 4px; top: 4px; width: 20px; height: 20px; border-radius: 6px; border: 0; padding: 0; display: grid; place-items: center;
  background: rgba(0,0,0,.65); color: #fff; font-size: 11px; opacity: 0; transition: opacity .15s;
}
.thumb:hover .rm, .thumb .rm:focus-visible { opacity: 1; }
.thumb .bar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: rgba(255,255,255,.15); }
.thumb .bar i { display: block; height: 100%; background: var(--accent); }
.thumb.add {
  border: 1.5px dashed var(--line-2); background: transparent; display: grid; place-items: center; color: var(--text-3); font-size: 20px; cursor: pointer;
}
.thumb.add:hover { color: var(--text); border-color: var(--text-3); }

.row-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; flex: none; }
.row-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; font-weight: 600; font-size: 13.5px; cursor: pointer; }
.switch { position: relative; width: 34px; height: 20px; }
.switch input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.switch i { position: absolute; inset: 0; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-2); transition: background .15s; pointer-events: none; }
.switch i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: var(--text-2); transition: transform .15s, background .15s; }
.switch input:checked + i { background: var(--accent); border-color: var(--accent); }
.switch input:checked + i::after { transform: translateX(14px); background: var(--accent-ink); }
.switch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.prompt-body { padding: 0 10px 10px; }
.prompt-body textarea {
  width: 100%; resize: vertical; min-height: 110px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg-2);
  color: var(--text); font: inherit; font-size: 13px; padding: 10px 11px;
}
.prompt-body textarea::placeholder { color: var(--text-3); }
.prompt-body textarea:focus { outline: none; border-color: var(--text-3); }
.mentions { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.mentions:empty { display: none; }
.mention { border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text-2); border-radius: 7px; padding: 2px 7px; font-size: 11.5px; display: inline-flex; align-items: center; gap: 5px; }
.mention img { width: 14px; height: 14px; border-radius: 3px; object-fit: cover; }
.mention:hover { color: var(--text); border-color: var(--text-3); }

.row-kv { display: grid; grid-template-columns: 1fr auto; align-items: center; padding: 9px 14px; text-align: left; width: 100%; }
.row-kv small { grid-column: 1; color: var(--text-3); font-size: 11.5px; }
.row-kv > span { grid-column: 1; font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.row-kv .chev { grid-column: 2; grid-row: 1 / span 2; color: var(--text-3); font-size: 15px; transition: transform .15s; }
.row-btn { border: 0; background: transparent; border-radius: 12px; }
.row-btn:hover { background: var(--surface-2); }
.row-btn[aria-expanded="true"] .chev { transform: rotate(90deg); }
.new { font-style: normal; font-size: 10.5px; font-weight: 600; color: var(--accent); background: rgba(214,255,61,.12); padding: 1px 6px; border-radius: 5px; }
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 6px); margin: 0; padding: 5px; list-style: none; z-index: 5;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.5); animation: pop .15s ease-out;
}
.menu li button { width: 100%; border: 0; background: transparent; text-align: left; padding: 9px 10px; border-radius: 8px; display: flex; justify-content: space-between; align-items: center; font-weight: 500; }
.menu li button:hover { background: var(--surface-3); }
.menu li button small { color: var(--text-3); font-weight: 400; }

.price-line { display: flex; justify-content: space-between; align-items: baseline; color: var(--text-3); font-size: 12.5px; margin-bottom: 9px; min-height: 18px; }
.price-line strong { color: var(--text); font-size: 15px; }

/* ---------- Workspace tabs / hero ---------- */
.ws-tabs { display: flex; gap: 4px; margin-bottom: 18px; position: sticky; top: -14px; padding: 4px 0; background: var(--bg); z-index: 3; }
.ws-tabs button {
  border: 0; background: transparent; color: var(--text-2); padding: 7px 11px; border-radius: 9px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
}
.ws-tabs button:hover { color: var(--text); background: var(--surface); }
.ws-tabs button.active { color: var(--text); background: var(--surface-2); }
.display { font-family: Anton, Impact, sans-serif; font-weight: 400; text-transform: uppercase; font-size: 48px; line-height: 1; letter-spacing: .005em; margin: 0 0 14px; }
.display.small { font-size: 32px; margin-bottom: 18px; }
.hero { max-width: 640px; margin: 4vh auto 34px; }
.hero-sub { color: var(--text-2); font-size: 15px; margin: 0; max-width: 520px; }
.hero-explainer {
  display: grid; grid-template-columns: 180px 1fr; gap: 0; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line);
  background: var(--surface); margin-bottom: 28px; max-width: 460px;
}
.hero-explainer .art { min-height: 120px; background-size: 200% 200%; animation: drift 6s ease-in-out infinite alternate; }
.hero-explainer .txt { padding: 16px; display: flex; flex-direction: column; justify-content: center; }
.hero-explainer strong { font-size: 15px; margin-bottom: 4px; }
.hero-explainer span { color: var(--text-3); font-size: 12.5px; }
.how-modes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; margin-bottom: 20px; }
.how-modes .hero-explainer { margin: 0; max-width: none; grid-template-columns: 1fr; }
.how { max-width: 680px; }
.how div strong { display: block; margin-bottom: 2px; }
.pane-sub { color: var(--text-3); margin: 0 0 14px; }
.modal-refs { display: flex; flex-wrap: wrap; gap: 6px; }
.modal-refs:empty { display: none; }
.modal-refs img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; border: 1px solid var(--line); }

/* ---------- Templates ---------- */
.tpl-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.tpl-head .display { margin-bottom: 6px; }
.tpl-head .pane-sub { margin: 0; }
.filter { display: flex; gap: 4px; flex-wrap: wrap; }
.filter button { border: 1px solid var(--line); background: transparent; color: var(--text-2); padding: 6px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 500; }
.filter button:hover { color: var(--text); border-color: var(--line-2); }
.filter button.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.templates { columns: 4 200px; column-gap: 12px; }
.tpl {
  position: relative; display: block; width: 100%; break-inside: avoid; margin: 0 0 12px; padding: 0; border: 0; border-radius: var(--radius);
  overflow: hidden; background: #000; text-align: left; outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .15s, transform .15s;
  animation: pop .25s ease-out;
}
.tpl:hover { transform: translateY(-2px); }
.tpl.selected { outline-color: var(--accent); }
.tpl video { width: 100%; display: block; min-height: 140px; object-fit: cover; }
.tpl-meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 30px 12px 10px; background: linear-gradient(to top, rgba(0,0,0,.85), transparent); }
.tpl-title { font-weight: 700; font-size: 13.5px; }
.tpl-sub { color: var(--text-2); font-size: 11.5px; margin-top: 1px; }
.tpl-badges { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; gap: 6px; }
.tpl-badges span { font-size: 10.5px; font-weight: 600; padding: 3px 7px; border-radius: 999px; background: rgba(0,0,0,.6); backdrop-filter: blur(6px); }
.tpl-use {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.95); opacity: 0; transition: opacity .15s, transform .15s;
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 13px; padding: 9px 16px; border-radius: 999px; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); pointer-events: none;
}
.tpl:hover .tpl-use, .tpl:focus-visible .tpl-use { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tpl.selected .tpl-use { opacity: 1; transform: translate(-50%, -50%); background: rgba(0,0,0,.65); color: var(--accent); backdrop-filter: blur(6px); }
.slot.highlight { animation: nudge 1.4s ease-out 2; border-color: var(--accent); }
@keyframes nudge { 0% { box-shadow: 0 0 0 0 rgba(214,255,61,.55); } 100% { box-shadow: 0 0 0 14px rgba(214,255,61,0); } }
.slot-hint.tpl-hint { color: var(--accent); }
.tpl-link { margin-top: 8px; border: 1px solid var(--line-2); background: var(--surface-2); color: var(--text); border-radius: 999px; padding: 5px 12px; font-size: 12px; font-weight: 600; }
.tpl-link:hover { border-color: var(--accent); color: var(--accent); }
.tpl-chip {
  position: absolute; left: 8px; bottom: 8px; max-width: calc(100% - 16px); font-size: 11.5px; font-weight: 600; padding: 4px 9px; border-radius: 999px;
  background: rgba(0,0,0,.65); backdrop-filter: blur(6px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--accent);
}

/* ---------- Accounts ---------- */
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; padding: 4px 6px 4px 4px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.user-chip .avatar { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 800; color: #fff; background: linear-gradient(135deg, var(--pink), var(--violet)); }
.user-chip .link-btn { padding: 0 6px; }
.auth { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; padding: 16px; background: var(--bg); overflow-y: auto; }
.auth-art {
  position: absolute; inset: 0; opacity: .55;
  background: radial-gradient(circle at 20% 20%, rgba(255,61,110,.35), transparent 40%), radial-gradient(circle at 80% 70%, rgba(123,44,255,.35), transparent 45%), radial-gradient(circle at 60% 20%, rgba(214,255,61,.12), transparent 35%);
  animation: drift 10s ease-in-out infinite alternate; background-size: 150% 150%;
}
.auth-card { position: relative; width: 100%; max-width: 400px; background: rgba(17,17,22,.92); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 20px; padding: 26px 22px 20px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 30px 80px rgba(0,0,0,.5); }
.auth-brand { margin-bottom: 6px; }
.auth-card .display { margin: 0; }
.auth-sub { margin: -4px 0 4px; color: var(--text-2); font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field input { height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 15px; padding: 0 12px; }
.field input:focus { outline: none; border-color: var(--text-3); }
.auth-error { margin: 0; min-height: 18px; color: var(--danger); font-size: 13px; }
.auth-foot { margin: 2px 0 0; text-align: center; color: var(--text-3); font-size: 12px; }

/* ---------- History tools / reference picker ---------- */
.history-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; color: var(--text-3); font-size: 13px; }
.btn.small-btn { height: 34px; padding: 0 12px; font-size: 13px; }
.btn.danger { background: rgba(255,90,90,.1); border-color: rgba(255,90,90,.45); color: #ff8a8a; }
.btn.danger:hover { background: rgba(255,90,90,.2); }
.icon-btn.danger:hover { background: rgba(255,60,60,.85); }
.slot-links { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; }
.picker-card { position: relative; width: 100%; max-width: 860px; max-height: calc(100dvh - 48px); overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 18px 20px 22px; animation: pop .2s ease-out; }
.picker-head { display: flex; justify-content: space-between; align-items: center; }
.picker-head h3 { margin: 0; font-size: 18px; }
.picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pick { position: relative; padding: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #000; aspect-ratio: 9 / 14; text-align: left; }
.pick:hover { border-color: var(--accent); }
.pick video { width: 100%; height: 100%; object-fit: cover; display: block; }
.pick span { position: absolute; left: 0; right: 0; bottom: 0; padding: 22px 9px 8px; font-size: 12px; font-weight: 600; background: linear-gradient(to top, rgba(0,0,0,.85), transparent); }
.pick small { display: block; color: var(--text-2); font-weight: 500; }

/* ---------- Top nav (all studio pages) ---------- */
.topnav { display: flex; gap: 4px; }
.topnav a { color: var(--text-2); text-decoration: none; padding: 7px 12px; border-radius: 999px; font-weight: 500; }
.topnav a:hover { color: var(--text); background: var(--surface); }
.topnav a.active { color: var(--text); background: var(--surface-2); }

/* ---------- Model hub ---------- */
body.hub { min-height: 100vh; }
.hub-main { max-width: 1240px; margin: 0 auto; padding: 28px 24px 60px; }
.hub-hero { padding: 26px 0 22px; }
.hub-hero .display { font-size: 56px; margin: 6px 0 12px; }
.hub-sub { color: var(--text-2); font-size: 16px; max-width: 680px; margin: 0 0 20px; line-height: 1.55; }
.hub-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.hub-search { flex: 1; min-width: 260px; max-width: 520px; display: flex; align-items: center; gap: 10px; height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); }
.hub-search:focus-within { border-color: var(--text-3); }
.hub-search input { flex: 1; border: 0; background: transparent; color: var(--text); font: inherit; font-size: 15px; outline: none; }
.hub-search-icon { color: var(--text-3); display: grid; font-size: 18px; }
.models-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; margin-top: 8px; }
.model-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--surface); text-decoration: none; color: var(--text); transition: transform .15s, border-color .15s, box-shadow .15s; animation: pop .25s ease-out; }
.model-card:hover { transform: translateY(-3px); border-color: var(--line-2); box-shadow: 0 18px 40px rgba(0,0,0,.35); }
.model-card.soon { opacity: .78; }
.model-art { position: relative; height: 120px; background: linear-gradient(130deg, var(--a), #120c1e 55%, var(--b)); background-size: 180% 180%; animation: drift 7s ease-in-out infinite alternate; }
.model-art::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, transparent 0 16px, rgba(255,255,255,.05) 16px 18px), linear-gradient(to top, rgba(0,0,0,.55), transparent 70%); }
.model-type { position: absolute; left: 12px; top: 12px; z-index: 1; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(0,0,0,.45); backdrop-filter: blur(6px); font-size: 17px; }
.model-new { position: absolute; right: 12px; top: 12px; z-index: 1; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 800; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.model-new.inline { position: static; }
.model-provider { position: absolute; left: 12px; bottom: 10px; z-index: 1; font-size: 12px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: rgba(255,255,255,.88); }
.model-body { padding: 14px 16px 14px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.model-body h3 { margin: 0; font-size: 17px; letter-spacing: -.01em; }
.model-body p { margin: 0; color: var(--text-3); font-size: 13px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.model-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.model-tags span { font-size: 11px; color: var(--text-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; }
.model-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 6px; }
.model-foot .price { font-weight: 700; font-size: 13px; color: var(--accent); }
.model-foot .price.soon { color: var(--text-3); font-weight: 600; }
.model-foot .go { color: var(--text-3); font-size: 18px; display: grid; }
.model-card:hover .go { color: var(--text); }
.hub-history { margin-top: 48px; padding-top: 30px; border-top: 1px solid var(--line); }
.feed-empty { grid-column: 1 / -1; color: var(--text-3); padding: 18px 0; }

/* ---------- Model page ---------- */
.wf-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 4px; flex: none; }
.wf-tabs.many { display: flex; flex-wrap: wrap; }
.wf-tabs button { border: 0; background: transparent; color: var(--text-2); padding: 8px 10px; border-radius: 9px; font-weight: 600; font-size: 12.5px; white-space: nowrap; }
.wf-tabs.many button { flex: 1 1 auto; }
.wf-tabs button:hover { color: var(--text); }
.wf-tabs button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }
.wf-tabs button.dim:not([aria-selected="true"]) { opacity: .55; }
.notice { border: 1px solid rgba(255,216,77,.35); background: rgba(255,216,77,.07); color: #ffd84d; border-radius: 12px; padding: 10px 12px; font-size: 13px; flex: none; }
.slot .optional, .row-head .optional, .setting .optional { color: var(--text-3); font-weight: 400; font-size: 12px; }
.slot .req, .setting .req, .row-head .req { color: var(--pink); }
.slot.media-filled { padding: 0; cursor: default; min-height: 0; overflow: hidden; background: #000; }
.slot.media-filled video, .slot.media-filled img.preview { position: static; width: 100%; max-height: 260px; display: block; object-fit: contain; background: #000; }
.audio-big { display: flex; align-items: center; gap: 10px; padding: 46px 14px 18px; width: 100%; font-size: 22px; }
.audio-big audio { flex: 1; }
.audio-thumb { width: 100%; height: 100%; display: grid; place-items: center; font-size: 22px; color: var(--text-2); }
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.row-card.settings, .row-card.more { padding: 4px 14px; }
.row-card.more > summary { cursor: pointer; padding: 11px 0; font-weight: 600; font-size: 13.5px; list-style: none; display: flex; justify-content: space-between; }
.row-card.more > summary::-webkit-details-marker { display: none; }
.row-card.more > summary::after { content: "+"; color: var(--text-3); font-weight: 400; }
.row-card.more[open] > summary::after { content: "–"; }
.row-card .setting { padding: 10px 0; }
.setting.stacked { flex-direction: column; align-items: stretch; gap: 6px; }
.static-head { cursor: default; }
.prompt-body .prompt-wrap { position: relative; }
.prompt-body .char-count { position: absolute; right: 10px; bottom: 9px; font-size: 11px; color: var(--text-3); pointer-events: none; }
.field-hint { color: var(--text-3); font-size: 11.5px; margin: 7px 2px 0; }
.select, .text-in { height: 36px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: inherit; font-size: 13px; padding: 0 10px; max-width: 220px; }
textarea.text-in { height: auto; min-height: 70px; max-width: none; padding: 8px 10px; resize: vertical; }
.setting.stacked .text-in { max-width: none; }
.range { display: flex; align-items: center; gap: 10px; flex: 1; max-width: 230px; }
.range input[type=range] { flex: 1; accent-color: var(--accent); }
.range-val { min-width: 38px; text-align: right; font-weight: 700; font-size: 13px; }
.back-link { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); text-decoration: none; font-size: 13px; font-weight: 600; margin-bottom: 14px; }
.back-link:hover { color: var(--text); }
.back-icon { display: grid; font-size: 16px; }
.model-about { border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px; margin-bottom: 26px; background: linear-gradient(120deg, color-mix(in srgb, var(--model-a, #ff3d6e) 14%, transparent), transparent 55%), var(--surface); }
.about-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.about-head .display { margin: 4px 0 8px; }
.about-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-top: 16px; }
.about-item { background: rgba(0,0,0,.22); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 3px; }
.about-item small { color: var(--text-3); font-size: 11.5px; }
.about-item b { font-size: 13.5px; }
.tips { margin-top: 14px; }
.tips summary { cursor: pointer; color: var(--text-2); font-weight: 600; font-size: 13px; }
.tips ul { margin: 8px 0 0; padding-left: 18px; color: var(--text-3); font-size: 12.5px; line-height: 1.55; }
.multi-badge { position: absolute; right: 10px; bottom: 10px; z-index: 2; font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.6); }
.card-placeholder { position: absolute; inset: 0; display: grid; place-items: center; font-size: 34px; color: var(--text-3); background: linear-gradient(130deg, #1b1030, #0d2b3a); }
.card-media img { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-media.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; overflow-y: auto; align-content: start; }
.modal-media.gallery img { width: 100%; height: auto; max-height: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .panel-scroll { overflow: visible; }
  :root { --panel-w: 100%; }
  .studio { display: block; height: auto; }
  body:has(.mock-banner:not([hidden])) .studio { height: auto; }
  .panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .panel-scroll { overflow: visible; padding: 16px; }
  .panel-foot { position: sticky; bottom: 0; z-index: 10; padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); box-shadow: 0 -10px 30px rgba(0,0,0,.4); }
  .foot-note { display: none; }
  .workspace { overflow: visible; padding: 20px 16px 40px; }
  .feed { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .hub-main { padding: 18px 16px 40px; }
  .hub-hero .display { font-size: 38px; }
  .models-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .model-art { height: 90px; }
  .model-body p, .model-tags { display: none; }
  .topnav { display: none; }
  .templates { columns: 2; column-gap: 10px; }
  .display { font-size: 34px; }
  .topbar { gap: 12px; padding: 0 16px; }
  .topbar-right .pill-note { display: none; }
  .modal { padding: 0; }
  .modal-card { grid-template-columns: 1fr; max-height: 100dvh; height: 100dvh; border-radius: 0; overflow-y: auto; }
  .modal-media { min-height: 0; }
  .modal-media video, .modal-media img { max-height: 60dvh; }
  .card-actions { opacity: 1; }
}
@media (max-width: 420px) {
  .brand-dim { display: none; }
  .thumbs { grid-template-columns: repeat(4, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.auth-foot a { color: var(--text-2); }
