:root {
  --bg: #0b0b0d;
  --surface: #141417;
  --surface-2: #1c1c21;
  --line: #2a2a31;
  --line-2: #3a3a44;
  --text: #f2f0ec;
  --muted: #9a98a3;
  --accent: #ff5a36;
  --accent-2: #ffb199;
  --accent-ink: #140603;
  --ok: #4fd18b;
  --danger: #ff4d6a;
  --radius: 14px;
  --font-d: 'Space Grotesk', system-ui, sans-serif;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { flex: none; }
.ic { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.center { display: flex; justify-content: center; margin-top: 18px; }
.link { color: var(--accent-2); font-size: 13px; }
.link:hover { text-decoration: underline; }

#app { display: grid; grid-template-columns: 88px 1fr; min-height: 100vh; }

/* ---------- Nav ---------- */
.nav { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 14px 8px; border-right: 1px solid var(--line); background: var(--bg); z-index: 20; overflow-y: auto; }
.brand { display: flex; flex-direction: column; align-items: center; gap: 4px; font: 700 12px var(--font-d); letter-spacing: .02em; }
.nav nav { display: flex; flex-direction: column; gap: 2px; width: 100%; }
.nav nav a, .nav nav button { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 9px 4px; border-radius: 12px; color: var(--muted); font-size: 11px; font-weight: 500; background: none; border: 0; width: 100%; transition: background .15s, color .15s; }
.nav nav .ic { width: 21px; height: 21px; }
.nav nav a:hover, .nav nav button:hover { color: var(--text); background: var(--surface); }
.nav nav a.active { color: var(--text); background: var(--surface-2); }
.nav nav a.active .ic { stroke: var(--accent); }
.nav .m-only { display: none !important; }
.nav-foot { margin-top: auto; width: 100%; display: flex; justify-content: center; }
.credits-pill { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--line); font-size: 12px; }
.credits-pill .ic { width: 15px; height: 15px; stroke: var(--accent); }
.credits-pill:hover { border-color: var(--line-2); }
.topbar { display: none; }

main { min-width: 0; }

/* ---------- Generic page ---------- */
.page { padding: 28px clamp(16px, 4vw, 48px) 70px; max-width: 1500px; }
.page.narrow { max-width: 860px; }
.page-head { margin-bottom: 22px; }
.page-head h1, .h1 { font: 700 clamp(26px, 3.2vw, 38px)/1.05 var(--font-d); letter-spacing: -0.02em; margin: 0 0 6px; }
.page-head p { color: var(--muted); margin: 0; max-width: 70ch; }
.group-title { font: 600 15px var(--font-d); margin: 28px 0 12px; color: var(--text); }

/* ---------- Explore ---------- */
.explore { padding: 24px clamp(16px, 4vw, 48px) 70px; max-width: 1500px; }
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; align-items: end; padding: 24px 0 26px; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.hero h1 { font: 700 clamp(34px, 5vw, 64px)/0.98 var(--font-d); letter-spacing: -0.03em; margin: 0; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero p { color: var(--muted); font-size: 15px; margin: 0 0 16px; max-width: 52ch; }
.hero-cta { display: flex; gap: 10px; flex-wrap: wrap; }
.quick { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; margin-bottom: 26px; }
.quick-card { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); transition: border-color .15s, transform .15s; }
.quick-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.quick-card b { font: 600 13.5px var(--font-d); line-height: 1.25; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 18px; }
.tab { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-weight: 500; }
.tab.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }

/* ---------- Tools ---------- */
.tool-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 90, 54, .12); color: var(--accent); }
.tool-ic .ic { width: 19px; height: 19px; }
.tool-ic.sm { width: 30px; height: 30px; display: inline-grid; vertical-align: -7px; margin-right: 10px; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.tool-card { display: flex; flex-direction: column; gap: 8px; padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); transition: border-color .15s, transform .15s; }
.tool-card:hover { border-color: var(--line-2); transform: translateY(-1px); }
.tool-card b { font: 600 15px var(--font-d); }
.tool-card span:not(.tool-ic) { color: var(--muted); font-size: 13px; }
.tool-hero { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 18px; background: linear-gradient(120deg, rgba(255, 90, 54, .18), rgba(255, 90, 54, .04) 60%), var(--surface); border: 1px solid rgba(255, 90, 54, .35); margin-bottom: 8px; }
.tool-hero > .ic { width: 34px; height: 34px; color: var(--accent); }
.tool-hero div { flex: 1; display: flex; flex-direction: column; }
.tool-hero b { font: 700 18px var(--font-d); }
.tool-hero span { color: var(--muted); }
.tool-hero .go { color: var(--accent-2); font-weight: 600; white-space: nowrap; }
.back { color: var(--muted); font-size: 13px; }
.back:hover { color: var(--text); }

/* ---------- Preset card + motion preview ---------- */
.pcard { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface); border: 1px solid var(--line); text-align: left; padding: 0; transition: transform .2s, border-color .2s; }
.pcard:hover { transform: translateY(-2px); border-color: var(--line-2); }
.pcard.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.pv { position: relative; aspect-ratio: 4/3; overflow: hidden; perspective: 400px; background: hsl(var(--h) 30% 10%); }
.scene { position: absolute; inset: -10%; transform-style: preserve-3d; }
.scene .sky { position: absolute; inset: 0; background: radial-gradient(120% 80% at 50% 0%, hsl(var(--h) 80% 55% / .55), transparent 60%), linear-gradient(180deg, hsl(var(--h) 45% 18%), hsl(var(--h) 35% 8%)); }
.scene .floor { position: absolute; left: -20%; right: -20%; bottom: 0; height: 42%; background: repeating-linear-gradient(90deg, hsl(var(--h) 60% 60% / .18) 0 1px, transparent 1px 34px), linear-gradient(180deg, hsl(var(--h) 40% 14%), hsl(var(--h) 30% 6%)); transform: rotateX(62deg); transform-origin: top; }
.scene .subj { position: absolute; left: 50%; bottom: 30%; width: 26%; aspect-ratio: 1/1.35; transform: translateX(-50%); border-radius: 40% 40% 18% 18%; background: linear-gradient(160deg, hsl(var(--h) 90% 75%), hsl(calc(var(--h) + 30) 80% 45%)); box-shadow: 0 12px 30px hsl(var(--h) 90% 50% / .45); }
.scene .subj::after { content: ''; position: absolute; left: 50%; top: -38%; width: 58%; aspect-ratio: 1; transform: translateX(-50%); border-radius: 50%; background: inherit; }
.pcard .meta { padding: 10px 12px 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pcard .meta b { font: 600 14px var(--font-d); }
.pcard .meta span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }

.a-zoomin .scene { animation: zoomin 3.2s ease-in-out infinite alternate; }
.a-zoomout .scene { animation: zoomin 3.2s ease-in-out infinite alternate-reverse; }
.a-crash .scene { animation: crash 2.4s cubic-bezier(.7,0,.2,1) infinite; }
.a-orbit .scene { animation: orbit 5s linear infinite; }
.a-orbit-slow .scene { animation: orbit 9s linear infinite; }
.a-rise .scene { animation: rise 3.6s ease-in-out infinite alternate; }
.a-fpv .scene { animation: fpv 3s ease-in-out infinite; }
.a-whip .scene { animation: whip 2.6s cubic-bezier(.8,0,.2,1) infinite; }
.a-shake .scene { animation: shake 1.6s ease-in-out infinite; }
.a-tilt .scene { animation: tilt 3.4s ease-in-out infinite alternate; }
.a-through .scene { animation: through 2.8s ease-in infinite; }
.e-dust .subj { animation: dust 3s ease-in infinite; }
.e-float .subj { animation: float 2.6s ease-in-out infinite alternate; }
.e-fire .scene { animation: fire 1.2s ease-in-out infinite alternate; }
.e-ice .scene { animation: ice 3s ease-in-out infinite alternate; }
.e-glitch .scene { animation: glitch 1.4s steps(2) infinite; }
.e-morph .subj { animation: morph 3s ease-in-out infinite alternate; }
.e-slow .subj { animation: float 6s ease-in-out infinite alternate; }
.e-lapse .sky { animation: lapse 2s linear infinite; }
.e-rain .scene { animation: rain 1.5s linear infinite; }
.e-burst .subj { animation: burst 2s ease-out infinite; }
@keyframes zoomin { from { transform: scale(1); } to { transform: scale(1.45); } }
@keyframes crash { 0%,40% { transform: scale(1); } 55%,85% { transform: scale(1.9); } 100% { transform: scale(1); } }
@keyframes orbit { from { transform: rotateY(0deg) scale(1.15); } to { transform: rotateY(360deg) scale(1.15); } }
@keyframes rise { from { transform: translateY(12%) scale(1.1); } to { transform: translateY(-10%) rotateX(18deg) scale(1.25); } }
@keyframes fpv { 0% { transform: translateX(-12%) rotate(-6deg) scale(1.2); } 50% { transform: translateX(10%) rotate(5deg) scale(1.5); } 100% { transform: translateX(-12%) rotate(-6deg) scale(1.2); } }
@keyframes whip { 0%,35% { transform: translateX(0); filter: none; } 50% { transform: translateX(-22%); filter: blur(6px); } 65%,100% { transform: translateX(0); filter: none; } }
@keyframes shake { 0%,100% { transform: translate(0,0) rotate(0); } 20% { transform: translate(1.5%,-1%) rotate(.6deg); } 45% { transform: translate(-1%,1%) rotate(-.5deg); } 70% { transform: translate(1%,.5%) rotate(.3deg); } }
@keyframes tilt { from { transform: translateY(-14%) rotateX(-14deg) scale(1.2); } to { transform: translateY(6%) rotateX(4deg) scale(1.2); } }
@keyframes through { from { transform: scale(1); opacity: 1; } 85% { opacity: 1; } to { transform: scale(3.2); opacity: 0; } }
@keyframes dust { 0% { filter: blur(0); opacity: 1; transform: translateX(-50%); } 100% { filter: blur(10px); opacity: 0; transform: translateX(-10%) translateY(-30%) scale(1.3); } }
@keyframes float { from { transform: translateX(-50%) translateY(0); } to { transform: translateX(-50%) translateY(-28%); } }
@keyframes fire { from { filter: hue-rotate(0) saturate(1.2) brightness(1); } to { filter: hue-rotate(-20deg) saturate(1.8) brightness(1.3); } }
@keyframes ice { from { filter: none; } to { filter: saturate(.3) brightness(1.4) hue-rotate(160deg); } }
@keyframes glitch { 0% { transform: translate(0); filter: none; } 25% { transform: translate(-3%, 1%); filter: hue-rotate(90deg); } 50% { transform: translate(2%, -1%); filter: invert(.15); } 75% { transform: translate(-1%, 0); filter: hue-rotate(-90deg) saturate(2); } }
@keyframes morph { from { border-radius: 40% 40% 18% 18%; transform: translateX(-50%) rotate(0); } to { border-radius: 50%; transform: translateX(-50%) rotate(180deg) scale(1.15); } }
@keyframes lapse { from { filter: hue-rotate(0); } to { filter: hue-rotate(360deg); } }
@keyframes rain { from { filter: brightness(1); } 50% { filter: brightness(1.35) hue-rotate(20deg); } to { filter: brightness(1); } }
@keyframes burst { 0% { box-shadow: 0 0 0 0 hsl(var(--h) 90% 60% / .9); } 100% { box-shadow: 0 0 0 60px hsl(var(--h) 90% 60% / 0); } }
@media (prefers-reduced-motion: reduce) { .pv * { animation: none !important; } }

/* ---------- Studio layout ---------- */
.studio { display: grid; grid-template-columns: 390px 1fr; min-height: 100vh; }
.panel { border-right: 1px solid var(--line); padding: 20px 20px 0; display: flex; flex-direction: column; gap: 15px; position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--bg); }
.panel h2 { font: 700 22px var(--font-d); margin: 0; letter-spacing: -0.01em; display: flex; align-items: center; }
.panel > p.muted { margin: -6px 0 0; font-size: 13px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.label { font-size: 12px; color: var(--muted); font-weight: 500; display: flex; align-items: center; gap: 8px; }
.label span { margin-left: auto; font-weight: 400; opacity: .8; }
.label span + span { margin-left: 8px; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { border: 0; background: none; padding: 8px 6px; border-radius: 9px; color: var(--muted); font-weight: 500; font-size: 13px; white-space: nowrap; }
.seg button.on { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
textarea, .input { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; line-height: 1.5; outline: none; }
textarea { resize: vertical; min-height: 84px; }
.input.xs { width: 74px; padding: 6px 8px; border-radius: 8px; font-size: 13px; }
textarea:focus, select:focus, .input:focus { border-color: #4a4a55; }
select { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 10px 34px 10px 12px; outline: none; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239a98a3' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.enhance { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; border: 1px solid rgba(255, 90, 54, .4); background: rgba(255, 90, 54, .08); color: var(--accent-2); font-size: 11.5px; font-weight: 600; }
.enhance .ic { width: 12px; height: 12px; }
.enhance:hover { background: rgba(255, 90, 54, .16); }
.enhance:disabled { opacity: .6; }
.tip { font-size: 12.5px; color: var(--muted); background: var(--surface); border: 1px dashed var(--line); border-radius: 12px; padding: 10px 12px; }

.drop-wrap { display: flex; flex-direction: column; gap: 6px; }
.drop { position: relative; border: 1.5px dashed var(--line); border-radius: 12px; background: var(--surface); min-height: 104px; display: grid; place-items: center; text-align: center; color: var(--muted); font-size: 13px; padding: 12px; cursor: pointer; transition: border-color .15s; overflow: hidden; }
.drop .ic { width: 22px; height: 22px; margin-bottom: 4px; }
.drop:hover, .drop.over { border-color: var(--accent); }
.drop:not(.has) { width: 100%; font: inherit; }
.drop.has { cursor: default; border-style: solid; padding: 8px; }
.drop img, .drop video { max-height: 180px; max-width: 100%; border-radius: 8px; display: block; }
.drop .x { position: absolute; top: 6px; right: 6px; z-index: 2; }
.busy { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 6px; background: rgba(11,11,13,.65); color: var(--text); font-size: 12px; z-index: 1; }
.audio-prev { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; color: var(--accent); }
.audio-prev audio { flex: 1; min-width: 0; height: 36px; }
.lib-btn { align-self: flex-start; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-size: 12px; }
.lib-btn:hover { color: var(--text); border-color: var(--line-2); }
.lib-btn .ic { width: 14px; height: 14px; }
.refs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.ref { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.ref img { width: 100%; height: 100%; object-fit: cover; }
.ref .x { position: absolute; top: 4px; right: 4px; }
.ref.add { display: grid; place-items: center; color: var(--muted); border-style: dashed; cursor: pointer; }
.ref.add:hover, .ref.add.over { border-color: var(--accent); color: var(--text); }
.ref.add { padding: 0; }
.ref.add .ic { width: 22px; height: 22px; }

.preset-pick, .model-pick { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); width: 100%; text-align: left; }
.model-pick { padding: 10px 12px; }
.preset-pick:hover, .model-pick:hover { border-color: var(--line-2); }
.preset-pick .mini { width: 54px; height: 40px; border-radius: 8px; overflow: hidden; flex: none; }
.preset-pick .mini .pv { aspect-ratio: auto; height: 100%; }
.preset-pick b, .model-pick b { display: block; font-weight: 600; }
.preset-pick small, .model-pick small { color: var(--muted); font-size: 12px; }
.grow { flex: 1; min-width: 0; }
.chev { color: var(--muted); }
.badge { font-style: normal; font-size: 10px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 6px; border-radius: 6px; background: rgba(255, 90, 54, .16); color: var(--accent-2); vertical-align: 2px; }
.model-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.model-card { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.model-card:hover { border-color: var(--line-2); }
.model-card.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.model-card b { font: 600 15px var(--font-d); }
.model-card span { color: #cfcdc8; font-size: 13px; }
.model-card small { color: var(--muted); font-size: 11.5px; }

.char-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.char-chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); font-size: 13px; font-weight: 500; color: #d7d5d0; }
.char-chip img, .char-chip .none { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: grid; place-items: center; background: var(--surface-2); }
.char-chip .none .ic { width: 14px; height: 14px; }
.char-chip.on { border-color: var(--accent); color: var(--text); background: rgba(255, 90, 54, .1); }
.char-chip.add { padding: 8px 12px; color: var(--muted); }
.char-chip.add .ic { width: 14px; height: 14px; }
.empty.small { display: flex; gap: 10px; align-items: center; padding: 14px; text-align: left; font-size: 13px; }
.empty.small .ic { width: 22px; height: 22px; color: var(--accent); }
.empty.small b { display: inline; font-size: 13px; font-family: var(--font); color: var(--accent-2); margin: 0; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 7px 11px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 500; }
.chip:hover { color: var(--text); }
.chip.on { color: var(--text); border-color: var(--accent); background: rgba(255,90,54,.1); }

.switch { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.toggle { width: 40px; height: 24px; border-radius: 99px; background: var(--line); border: 0; position: relative; transition: background .2s; flex: none; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.toggle.on { background: var(--accent); }
.toggle.on::after { transform: translateX(16px); }

.btn-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 18px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 15px; transition: filter .15s, transform .1s; }
.btn-primary .ic { width: 16px; height: 16px; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn-ghost { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; background: transparent; font-weight: 500; }
.btn-ghost:hover { background: var(--surface); }
.btn-ghost .ic { width: 16px; height: 16px; }
.gen-btn { width: 100%; }
.gen-btn .cost { display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; padding: 2px 8px; border-radius: 99px; background: rgba(20, 6, 3, .16); font-size: 13px; }
.gen-btn .cost .ic { width: 14px; height: 14px; }
.panel-foot { position: sticky; bottom: 0; margin: auto -20px 0; padding: 14px 20px 18px; background: linear-gradient(180deg, transparent, var(--bg) 26%); }
.quote-hint { color: var(--muted); font-size: 12px; text-align: center; min-height: 0; margin-top: 6px; }
.quote-hint:empty { display: none; }
.icon-btn { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; border: 0; background: rgba(11,11,13,.78); color: var(--text); flex: none; }
.icon-btn .ic { width: 15px; height: 15px; stroke-width: 2; }

/* ---------- Feed & cards ---------- */
.feed { padding: 20px clamp(16px, 3vw, 32px) 70px; min-width: 0; }
.feed-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.feed-head h3 { font: 600 16px var(--font-d); margin: 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.media { position: relative; background: #000; aspect-ratio: 16/10; display: grid; place-items: center; overflow: hidden; }
.media video, .media img { width: 100%; height: 100%; object-fit: contain; display: block; }
.media img { cursor: zoom-in; }
.media.multi { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.media.multi img { object-fit: cover; }
.checker { background-color: #111; background-image: linear-gradient(45deg, #1b1b1f 25%, transparent 25%), linear-gradient(-45deg, #1b1b1f 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #1b1b1f 75%), linear-gradient(-45deg, transparent 75%, #1b1b1f 75%); background-size: 18px 18px; background-position: 0 0, 0 9px, 9px -9px, -9px 0; }
.media.audio { display: flex; flex-direction: column; justify-content: center; gap: 14px; padding: 16px; background: radial-gradient(80% 90% at 50% 100%, rgba(255, 90, 54, .18), transparent 70%), #0f0f12; }
.media.audio audio { width: 100%; height: 38px; }
.wave { display: flex; align-items: center; justify-content: center; gap: 3px; height: 56px; }
.wave i { width: 4px; border-radius: 4px; height: calc(10% + var(--k) * 90%); background: linear-gradient(180deg, var(--accent-2), var(--accent)); opacity: .85; }
.pending { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; text-align: center; padding: 16px; }
.pending .bar { width: 140px; height: 3px; border-radius: 9px; background: var(--line); overflow: hidden; }
.pending .bar::after { content: ''; display: block; width: 40%; height: 100%; background: var(--accent); animation: load 1.3s ease-in-out infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
.shimmer { position: absolute; inset: 0; background: linear-gradient(110deg, transparent 30%, rgba(255,255,255,.04) 50%, transparent 70%); background-size: 200% 100%; animation: shim 1.8s linear infinite; }
@keyframes shim { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.failed { color: var(--danger); padding: 18px; font-size: 13px; text-align: center; }
.failed .ok { color: var(--ok); }
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.card-body p { margin: 0; font-size: 13px; color: #d7d5d0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.tags span { padding: 2px 8px; border-radius: 99px; background: var(--surface-2); }
.tags .price { margin-left: auto; background: none; }
.tags .by { background: none; color: var(--accent-2); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: auto; }
.act { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: transparent; font-size: 12px; font-weight: 500; color: #d7d5d0; }
.act:hover { background: var(--surface-2); color: var(--text); }
.act .ic { width: 14px; height: 14px; stroke-width: 2; }
.act.on { border-color: rgba(79, 209, 139, .5); color: var(--ok); }
.act.danger:hover, .act.armed { color: var(--danger); border-color: var(--danger); }
.empty { border: 1px dashed var(--line); border-radius: var(--radius); padding: 44px 20px; text-align: center; color: var(--muted); display: grid; justify-items: center; gap: 6px; }
.empty b { display: block; color: var(--text); font: 600 18px var(--font-d); }
.warn { padding: 10px 12px; border-radius: 12px; background: rgba(255,177,153,.08); border: 1px solid rgba(255,177,153,.25); color: var(--accent-2); font-size: 12.5px; }

/* ---------- Characters ---------- */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.char-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.char-photos { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr 1fr; gap: 2px; aspect-ratio: 4/3; background: #000; }
.char-photos img { width: 100%; height: 100%; object-fit: cover; }
.char-photos img:first-child { grid-row: 1 / 4; }
.char-photos img:only-child { grid-column: 1 / 3; }
.char-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; }
.char-body b { font: 600 16px var(--font-d); }
.char-body small { color: var(--muted); }

/* ---------- Library picker / use-in ---------- */
.lib-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.lib-item { display: flex; flex-direction: column; gap: 6px; padding: 6px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-align: left; }
.lib-item:hover { border-color: var(--accent); }
.lib-item img, .lib-item video, .lib-item .aud { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: 8px; background: #000; display: grid; place-items: center; color: var(--accent); }
.lib-item small { color: var(--muted); font-size: 11.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.use-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; }
.use-item { display: flex; align-items: center; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); text-align: left; font-weight: 500; }
.use-item .ic { color: var(--accent); }
.use-item:hover { border-color: var(--line-2); }

/* ---------- Account ---------- */
.balance { padding: 22px; border-radius: 18px; background: radial-gradient(90% 120% at 100% 0%, rgba(255, 90, 54, .22), transparent 60%), var(--surface); border: 1px solid var(--line); }
.balance div { display: flex; flex-direction: column; gap: 4px; }
.balance b { font: 700 48px/1 var(--font-d); letter-spacing: -0.02em; }
.packs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.pack { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-align: left; }
.pack:hover:not(:disabled) { border-color: var(--accent); }
.pack:disabled { opacity: .5; cursor: not-allowed; }
.pack b { font: 700 24px var(--font-d); }
.pack span { color: var(--muted); font-size: 12px; }
.pack strong { margin-top: 10px; font-size: 16px; color: var(--accent-2); }
.pack .badge { position: absolute; top: 12px; right: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.table th { color: var(--muted); font-weight: 500; font-size: 12px; background: var(--surface); }
.table tr:last-child td { border-bottom: 0; }
.table .r { text-align: right; white-space: nowrap; }
.table .pos { color: var(--ok); }
.table .neg { color: #d7d5d0; }
.table .clip { display: inline-block; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.inline-form .input { flex: 1; min-width: 180px; }
.code { font: 600 22px ui-monospace, monospace; letter-spacing: .08em; padding: 12px; border-radius: 10px; background: var(--surface); text-align: center; user-select: all; }

/* ---------- Admin ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.stat { padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.stat span { color: var(--muted); font-size: 12px; }
.stat b { font: 700 26px var(--font-d); }
.stat small { color: var(--muted); font-size: 11.5px; }
.cfg { display: grid; gap: 8px; }
.cfg-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.cfg-row div { flex: 1; display: flex; flex-direction: column; }
.cfg-row small { color: var(--muted); }
.cfg-row .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-2); flex: none; }
.cfg-row.ok .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(79, 209, 139, .15); }
.cfg-row .st { font-size: 12px; color: var(--muted); }
.cfg-row.has-form { align-items: flex-start; }
.cfg-row.has-form .dot { margin-top: 6px; }
.cfg-form { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.cfg-form .input { flex: 1; min-width: 200px; padding: 9px 12px; }
.cfg-form .btn-ghost { padding: 9px 14px; }
.cfg-form small { flex-basis: 100%; }
@media (max-width: 700px) { .cfg-row { position: relative; } .cfg-row.has-form .st { position: absolute; top: 13px; right: 14px; } .cfg-row.has-form b { display: block; padding-right: 96px; } .cfg-form .btn-ghost { flex: none; } }
.cfg-row.ok .st { color: var(--ok); }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.status { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); }
.status.done { color: var(--ok); }
.status.failed { color: var(--danger); }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); backdrop-filter: blur(6px); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-box { width: min(620px, 100%); max-height: 88vh; overflow: auto; background: var(--bg); border: 1px solid var(--line); border-radius: 18px; padding: 20px; }
.modal-box.wide { width: min(1000px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; }
.modal-head h3 { font: 700 20px var(--font-d); margin: 0; }
.lightbox { max-width: 100%; max-height: 76vh; border-radius: 12px; display: block; margin: 0 auto; }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; overflow-y: auto; background: radial-gradient(60% 50% at 50% 0%, rgba(255,90,54,.18), transparent 70%), var(--bg); }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; align-items: stretch; gap: 12px; padding: 30px 24px; border-radius: 20px; border: 1px solid var(--line); background: var(--surface); text-align: center; }
.login-card > svg { align-self: center; }
.login-card h1 { font: 700 28px var(--font-d); margin: 4px 0 0; }
.login-card p { margin: 0 0 6px; color: var(--muted); }
.login-card .input { background: var(--bg); font-size: 15px; }
.err { color: var(--danger); min-height: 1em; }

.toasts { position: fixed; bottom: 18px; right: 18px; z-index: 70; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 32px); }
.toast { background: var(--surface-2); border: 1px solid var(--line); border-left: 3px solid var(--accent); padding: 10px 14px; border-radius: 10px; font-size: 13px; max-width: 380px; box-shadow: 0 10px 30px rgba(0,0,0,.4); }
.toast.err { border-left-color: var(--danger); }
.spin { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.2); border-top-color: var(--accent); animation: sp 0.8s linear infinite; }
.spin.sm { width: 12px; height: 12px; border-width: 2px; }
.btn-primary .spin { border-color: rgba(20,6,3,.25); border-top-color: var(--accent-ink); width: 18px; height: 18px; }
@keyframes sp { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .quick { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 1000px) {
  .studio { grid-template-columns: 1fr; }
  .panel { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
  .panel-foot { position: sticky; bottom: 0; }
  .hero { grid-template-columns: 1fr; }
  .packs { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  #app { grid-template-columns: 1fr; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
  .topbar { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 30; padding: 10px 16px; background: rgba(11, 11, 13, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
  .brand-m { display: flex; align-items: center; gap: 8px; font: 700 16px var(--font-d); }
  .nav { position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); overflow: visible; background: rgba(11, 11, 13, .96); backdrop-filter: blur(10px); }
  .brand, .nav-foot { display: none; }
  .nav nav { flex-direction: row; }
  .nav nav a, .nav nav button { padding: 6px 2px; }
  .nav nav .m-more { display: none; }
  .nav .m-only { display: flex !important; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .quick { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .quick-card { padding: 12px; }
  .cards { grid-template-columns: 1fr; }
  .panel { padding: 16px 16px 0; }
  .panel-foot { margin: auto -16px 0; padding: 12px 16px 14px; bottom: calc(62px + env(safe-area-inset-bottom)); }
  .explore, .page { padding-top: 14px; }
  .toasts { bottom: calc(80px + env(safe-area-inset-bottom)); right: 16px; left: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .tool-hero { flex-wrap: wrap; }
  .modal { align-items: end; padding: 0; }
  .modal-box, .modal-box.wide { width: 100%; max-height: 86vh; border-radius: 18px 18px 0 0; }
  .balance b { font-size: 40px; }
}
