/* Pulse — YouTube Automation. Mobile-first. */
:root {
  --bg: #07070b;
  --bg-elev: #0c0c12;
  --surface: #13131b;
  --surface-2: #1a1a24;
  --surface-3: #22222e;
  --line: #2b2b38;
  --line-2: #3a3a4a;
  --ink: #f7f5ff;
  --muted: #9a96ad;
  --faint: #6a667c;
  --accent: #ff3355;
  --accent-2: #ff6b81;
  --accent-soft: rgba(255, 51, 85, .14);
  --violet: #8b7cff;
  --violet-soft: rgba(139, 124, 255, .16);
  --ok: #3dd68c;
  --ok-soft: rgba(61, 214, 140, .14);
  --warn: #f5c14a;
  --warn-soft: rgba(245, 193, 74, .14);
  --crit: #ff7a70;
  --crit-soft: rgba(255, 122, 112, .14);
  --blue: #7ea6ff;
  --blue-soft: rgba(126, 166, 255, .16);
  --shimmer-a: #1a1a24;
  --shimmer-b: #2a2a38;
  --nav-h: 64px;
  --top-h: 56px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 18px 50px rgba(0, 0, 0, .45);
  --font: "Segoe UI Variable Text", "Segoe UI", -apple-system, BlinkMacSystemFont, Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink); }
html { height: 100%; }
body {
  min-height: 100%;
  font: 15px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
img, video { max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; }
.hidden { display: none !important; }

/* ── boot ── */
#boot {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  background:
    radial-gradient(80% 60% at 50% 0%, rgba(255, 51, 85, .22), transparent 55%),
    var(--bg);
  transition: opacity .4s ease;
}
#boot.gone { opacity: 0; pointer-events: none; }
.boot-mark {
  width: 72px; height: 72px; border-radius: 22px;
  background: linear-gradient(145deg, #ff3355, #ff6b81 55%, #8b7cff);
  display: grid; place-items: center;
  font-weight: 900; font-size: 28px; color: #fff;
  box-shadow: 0 16px 40px rgba(255, 51, 85, .35);
  animation: bootPulse 1.2s ease-in-out infinite;
}
.boot-name { margin: 16px 0 4px; font-size: 22px; font-weight: 800; letter-spacing: -.03em; text-align: center; }
.boot-sub { color: var(--muted); font-size: 12px; letter-spacing: .14em; text-transform: uppercase; text-align: center; }
.boot-bar { width: 160px; height: 3px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 22px auto 0; }
.boot-bar span { display: block; height: 100%; width: 30%; background: linear-gradient(90deg, var(--accent), var(--violet)); animation: bootLoad 1.1s ease-in-out infinite; }
@keyframes bootPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}
@keyframes bootLoad {
  0% { transform: translateX(-80%); }
  100% { transform: translateX(280%); }
}

/* ── app shell ── */
#app { min-height: 100dvh; }
.shell {
  min-height: 100dvh;
  padding-top: calc(var(--top-h) + var(--safe-t));
  padding-bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
}
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  height: calc(var(--top-h) + var(--safe-t));
  padding: var(--safe-t) 14px 0;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; color: inherit; }
.brand:hover { text-decoration: none; }
.logo {
  width: 32px; height: 32px; border-radius: 10px; flex: none;
  background: linear-gradient(145deg, #ff3355, #8b7cff);
  display: grid; place-items: center; font-weight: 900; color: #fff; font-size: 14px;
}
.brand-copy { min-width: 0; }
.brand-copy b { display: block; font-size: 14.5px; letter-spacing: -.02em; }
.brand-copy small { display: block; color: var(--muted); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-chip {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
  display: grid; place-items: center; color: var(--ink);
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--violet-soft); color: var(--violet);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  border: 1px solid var(--line);
}

.page { padding: 14px 14px 8px; max-width: 1120px; margin: 0 auto; }
.page-head { margin-bottom: 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.035em; line-height: 1.15; }
.page-head p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* ── bottom nav ── */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--nav-h) + var(--safe-b));
  padding: 6px 8px var(--safe-b);
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg-elev) 90%, transparent);
  backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
}
.nav-btn {
  border: 0; background: none; color: var(--faint);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 52px; border-radius: 12px; font-size: 10.5px; font-weight: 700; letter-spacing: .02em;
}
.nav-btn svg { width: 22px; height: 22px; }
.nav-btn.active { color: var(--ink); }
.nav-btn.active svg { color: var(--accent); }

/* desktop rail */
.side-nav { display: none; }

/* ── primitives ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  font-weight: 700; transition: transform .08s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.97); }
.btn.primary {
  background: linear-gradient(180deg, #ff4a67, var(--accent));
  border-color: transparent; color: #fff;
  box-shadow: 0 10px 24px rgba(255, 51, 85, .28);
}
.btn.ok { background: var(--ok); border-color: var(--ok); color: #062114; }
.btn.danger { background: transparent; border-color: var(--crit); color: var(--crit); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.spin {
  width: 14px; height: 14px; border-radius: 50%; flex: none;
  border: 2px solid currentColor; border-top-color: transparent;
  animation: rot .7s linear infinite; display: none;
}
.busy .spin { display: inline-block; }
@keyframes rot { to { transform: rotate(360deg); } }

input, textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px; color: var(--ink);
}
textarea { resize: vertical; min-height: 120px; }
.field { margin-bottom: 12px; }
.field label {
  display: block; font-size: 11px; font-weight: 800; color: var(--muted);
  text-transform: uppercase; letter-spacing: .07em; margin-bottom: 6px;
}

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  border-radius: 999px; padding: 3px 9px; font-size: 10.5px; font-weight: 800;
  letter-spacing: .05em; text-transform: uppercase; flex: none;
}
.pill.queued, .pill.generating { background: var(--blue-soft); color: var(--blue); }
.pill.generated, .pill.review { background: var(--warn-soft); color: var(--warn); }
.pill.approved, .pill.uploading { background: var(--ok-soft); color: var(--ok); }
.pill.uploaded { background: var(--ok); color: #062114; }
.pill.failed, .pill.rejected { background: var(--crit-soft); color: var(--crit); }
.pill.engine, .pill.template { background: var(--surface-3); color: var(--muted); border: 1px dashed var(--line); }

.sk { position: relative; overflow: hidden; background: var(--shimmer-a); border-radius: 8px; color: transparent !important; }
.sk::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 30%, var(--shimmer-b) 50%, transparent 70%);
  animation: shimmer 1.4s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.sk-line { height: 12px; margin: 6px 0; }
.sk-card { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface); }

.banner {
  display: none; align-items: center; gap: 10px;
  background: var(--crit-soft); border: 1px solid var(--crit); color: var(--crit);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; font-size: 13.5px;
}
.banner.show { display: flex; }
.banner.warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.empty {
  text-align: center; color: var(--muted); border: 1px dashed var(--line);
  border-radius: 16px; padding: 36px 16px;
}
.empty b { color: var(--ink); }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 14px);
  transform: translateX(-50%) translateY(8px);
  background: var(--surface-3); border: 1px solid var(--line); color: var(--ink);
  border-radius: 12px; padding: 10px 16px; font-weight: 700; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 90;
  max-width: calc(100vw - 28px);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { border-color: var(--crit); color: var(--crit); }

.fade-up { animation: fadeUp .32s cubic-bezier(.2,.7,.2,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.view-enter { animation: viewIn .3s cubic-bezier(.2,.7,.2,1) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ── auth ── */
.auth {
  min-height: 100dvh;
  padding: calc(28px + var(--safe-t)) 18px 32px;
  display: flex; flex-direction: column;
  background:
    radial-gradient(90% 50% at 50% -10%, rgba(255, 51, 85, .28), transparent 50%),
    radial-gradient(70% 40% at 80% 110%, rgba(139, 124, 255, .18), transparent 50%),
    var(--bg);
}
.crumbs { color: var(--muted); font-size: 12px; margin: 0 0 16px; }
.crumbs a { color: var(--muted); }
.auth-hero { margin: 18px 0 28px; }
.auth-hero h1 { margin: 14px 0 8px; font-size: 32px; letter-spacing: -.04em; line-height: 1.1; }
.auth-hero p { margin: 0; color: var(--muted); max-width: 42ch; }
.seo-block { margin-top: 28px; color: var(--muted); font-size: 14px; max-width: 52ch; }
.seo-block h2 { color: var(--ink); font-size: 18px; letter-spacing: -.02em; margin: 0 0 10px; }
.seo-block h3 { color: var(--ink); font-size: 15px; margin: 16px 0 6px; }
.seo-block ol { margin: 0; padding-left: 18px; }
.seo-block li { margin: 0 0 8px; }
.seo-block p { margin: 0 0 10px; }
.auth-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 20px;
  box-shadow: var(--shadow);
}
.otp-row { display: flex; gap: 8px; }
.otp-row input {
  text-align: center; letter-spacing: .4em; font-size: 22px; font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.form-error { color: var(--crit); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.form-ok { color: var(--ok); font-size: 13px; min-height: 18px; margin: 8px 0 0; }
.auth-caps { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 22px; }
.cap-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px;
}
.cap-tile b { display: block; font-size: 13px; margin-bottom: 2px; }
.cap-tile span { color: var(--muted); font-size: 12px; }

/* ── create ── */
.prompt-card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 14px;
}
.prompt-card textarea {
  min-height: 140px; border: 0; background: transparent; padding: 6px 4px 10px;
  font-size: 16px; line-height: 1.45;
}
.prompt-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--surface-2);
  color: var(--muted); border-radius: 999px; padding: 8px 13px;
  font-size: 13px; font-weight: 700; min-height: 36px;
}
.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }

.section-label {
  margin: 22px 0 10px; font-size: 12px; font-weight: 800;
  letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
}
.template-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tmpl {
  text-align: left; border: 1px solid var(--line); background: var(--surface);
  border-radius: 16px; padding: 12px; min-height: 118px;
  display: flex; flex-direction: column; gap: 6px;
}
.tmpl.active { border-color: var(--accent); background: var(--accent-soft); }
.tmpl .ico {
  width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center;
  background: var(--surface-2); font-size: 16px;
}
.tmpl b { font-size: 13.5px; letter-spacing: -.01em; }
.tmpl span { color: var(--muted); font-size: 12px; line-height: 1.35; }

.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice {
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted);
  border-radius: 12px; padding: 10px 6px; font-size: 12.5px; font-weight: 700; text-align: center;
}
.choice.active { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }
.choice small { display: block; font-weight: 600; color: var(--faint); font-size: 10px; margin-top: 2px; }

.sticky-cta {
  position: sticky; bottom: calc(var(--nav-h) + var(--safe-b) + 8px);
  margin-top: 16px; z-index: 5;
}

.recent-row { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 4px; }
.recent-card {
  flex: none; width: 132px; text-align: left; border: 0; background: none; padding: 0; color: inherit;
}
.thumb {
  width: 132px; aspect-ratio: 9/16; border-radius: 14px; overflow: hidden;
  background: #111; position: relative;
}
.thumb img, .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .ph {
  position: absolute; inset: 0;
  display: grid; place-items: center; font-weight: 900; font-size: 28px; color: #fff;
  background: linear-gradient(160deg, #2a1630, #1a1028 40%, #ff3355);
}
.thumb .badge { position: absolute; left: 8px; top: 8px; }
.recent-card .t { display: block; margin-top: 7px; font-size: 12.5px; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* ── library ── */
.search-row { display: flex; gap: 8px; margin-bottom: 12px; }
.search-row input { min-height: 44px; }
.filter-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; }
.filter-tabs .tab {
  flex: none; border: 1px solid var(--line); background: var(--surface); color: var(--muted);
  border-radius: 999px; padding: 7px 12px; font-size: 12.5px; font-weight: 700; min-height: 34px;
}
.filter-tabs .tab.active { background: var(--violet-soft); border-color: var(--violet); color: var(--ink); }
.filter-tabs .n { opacity: .7; }

.library-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.lib-card {
  border: 0; background: none; padding: 0; text-align: left; color: inherit;
}
.lib-card .thumb { width: 100%; }
.lib-card .meta-line {
  margin-top: 7px; display: flex; align-items: flex-start; gap: 6px;
}
.lib-card h3 {
  margin: 0; font-size: 13px; font-weight: 700; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-card .sub { color: var(--muted); font-size: 11.5px; margin-top: 3px; }

/* ── queue / stats ── */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.tile .k { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); }
.tile .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 2px; }
.tile .v small { font-size: 12px; color: var(--muted); font-weight: 600; }
.meter { height: 5px; border-radius: 99px; background: var(--surface-2); margin-top: 8px; overflow: hidden; }
.meter span { display: block; height: 100%; border-radius: 99px; background: var(--ok); transition: width .4s ease; }
.meter.hot span { background: var(--warn); }
.meter.full span { background: var(--crit); }

.cards { display: grid; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; }
.card .top { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card h3 { font-size: 15px; margin: 0; font-weight: 700; letter-spacing: -.015em; flex: 1; min-width: 0; }
.meta { color: var(--muted); font-size: 12px; display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.meta code { font: 11px var(--mono); background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }
.date { margin-left: auto; font: 11.5px var(--mono); color: var(--muted); }
.script {
  color: var(--muted); font-size: 13px; margin: 9px 0 0;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.script.open { display: block; -webkit-line-clamp: unset; }
.expand { background: none; border: none; color: var(--blue); font-size: 12px; padding: 4px 0; min-height: auto; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.yt-thumb { display: inline-flex; align-items: center; gap: 10px; margin-top: 10px; }
.yt-thumb img { width: 108px; border-radius: 8px; display: block; }

/* ── profile ── */
.profile-hero {
  background: linear-gradient(180deg, rgba(139,124,255,.16), var(--surface));
  border: 1px solid var(--line); border-radius: 20px; padding: 22px 16px 16px;
  text-align: center; margin-bottom: 14px;
}
.profile-hero .avatar { width: 72px; height: 72px; font-size: 26px; margin: 0 auto 10px; }
.profile-hero h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: -.02em; }
.profile-hero p { margin: 0; color: var(--muted); font-size: 13px; word-break: break-all; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat-row div { background: var(--bg-elev); border-radius: 12px; padding: 10px 6px; }
.stat-row b { display: block; font-size: 18px; }
.stat-row span { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.list-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px; margin-bottom: 8px; color: inherit; text-align: left;
}
.list-row .ico {
  width: 36px; height: 36px; border-radius: 10px; background: var(--surface-2);
  display: grid; place-items: center; flex: none;
}
.list-row b { display: block; font-size: 14px; }
.list-row span { color: var(--muted); font-size: 12.5px; }
.list-row .chev { margin-left: auto; color: var(--faint); }

/* ── video detail sheet ── */
.sheet {
  position: fixed; inset: 0; z-index: 55; display: none;
  background: rgba(4, 4, 8, .72); backdrop-filter: blur(4px);
}
.sheet.open { display: block; }
.sheet-card {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-height: min(92dvh, 860px);
  background: var(--bg-elev); border-radius: 22px 22px 0 0;
  border: 1px solid var(--line); overflow: auto;
  padding: 10px 14px calc(18px + var(--safe-b));
  animation: sheetUp .28s cubic-bezier(.2,.7,.2,1);
}
@keyframes sheetUp { from { transform: translateY(24px); } to { transform: none; } }
.grab { width: 40px; height: 4px; border-radius: 99px; background: var(--line-2); margin: 4px auto 12px; }
.detail-player {
  width: min(280px, 70vw); aspect-ratio: 9/16; margin: 0 auto 14px;
  border-radius: 16px; overflow: hidden; background: #000; position: relative;
}
.detail-player video, .detail-player img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-player iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.history { display: grid; gap: 8px; margin-top: 8px; }
.history li { list-style: none; color: var(--muted); font-size: 12.5px; padding-left: 14px; position: relative; }
.history li::before {
  content: ""; position: absolute; left: 0; top: 7px; width: 7px; height: 7px; border-radius: 50%; background: var(--violet);
}

/* ── overlays / studio (ported + tightened) ── */
.overlay {
  position: fixed; inset: 0; z-index: 60; display: none;
  background: rgba(6, 7, 12, .74); backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 12px;
  opacity: 0; transition: opacity .22s ease;
}
.overlay.open { display: flex; }
.overlay.in { opacity: 1; }
.modal {
  background: var(--surface); border: 1px solid var(--line); border-radius: 18px;
  width: 100%; max-width: 460px; max-height: calc(100dvh - 24px); overflow: auto;
  padding: 20px; transform: translateY(12px) scale(.98);
  transition: transform .22s cubic-bezier(.2,.7,.2,1);
}
.overlay.in .modal { transform: none; }
.modal h2 { margin: 0 0 4px; font-size: 17px; }
.modal .sub { margin-bottom: 14px; color: var(--muted); font-size: 12.5px; }

.gen-steps { display: grid; gap: 4px; margin: 12px 0 6px; }
.gen-step { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 10px; color: var(--muted); }
.gen-step .dot {
  width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center;
  border: 2px solid var(--line); font-size: 12px; color: transparent;
}
.gen-step.active { color: var(--ink); background: var(--surface-2); }
.gen-step.active .dot { border-color: var(--blue); border-top-color: transparent; animation: rot .7s linear infinite; }
.gen-step.done { color: var(--ink); }
.gen-step.done .dot { border-color: var(--ok); background: var(--ok); color: #062114; animation: none; }
.gen-step.done .dot::before { content: "✓"; font-weight: 900; }
.gen-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: 12px 0 4px; }
.gen-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--violet)); width: 0%; transition: width .5s ease; }
.gen-result { display: none; text-align: center; padding: 10px 0 2px; }
.gen-result.show { display: block; animation: fadeUp .3s ease both; }
.gen-result .big { font-size: 36px; }
.gen-error { display: none; color: var(--crit); background: var(--crit-soft); border: 1px solid var(--crit); border-radius: 10px; padding: 10px 12px; margin-top: 12px; font-weight: 600; }
.gen-error.show { display: block; }
.gen-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.studio { max-width: 980px; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.studio-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.studio-head h2 { font-size: 15px; margin: 0; flex: 1; min-width: 120px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.save-ind { font-size: 12px; font-weight: 700; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.save-ind.ok { color: var(--ok); }
.save-ind.err { color: var(--crit); }
.save-ind .spin { display: inline-block; width: 11px; height: 11px; }
.studio-body { display: grid; grid-template-columns: 1fr; overflow: auto; }
.stage-col { padding: 14px; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 10px; }
.stage { position: relative; width: 100%; max-width: 260px; aspect-ratio: 9/16; background: #000; border-radius: 14px; overflow: hidden; }
.stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.stage .no-video { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12.5px; text-align: center; padding: 20px; }
.layer { position: absolute; inset: 0; display: flex; justify-content: center; pointer-events: none; padding: 6%; }
.layer.pos-top { align-items: flex-start; padding-top: 14%; }
.layer.pos-middle { align-items: center; }
.layer.pos-bottom { align-items: flex-end; padding-bottom: 14%; }
.cap { font-weight: 800; text-align: center; line-height: 1.25; max-width: 94%; }
.cap:empty { display: none; }
.cap.blink { background: rgba(10,12,16,.88); color: #fff; padding: .32em .55em; border-radius: .32em; text-transform: uppercase; letter-spacing: .02em; }
.cap.karaoke { color: #ffd234; text-shadow: 0 2px 0 #000, 0 0 12px rgba(0,0,0,.6); text-transform: uppercase; }
.cap.hyper-word { background: rgba(10,12,16,.92); color: #fff; padding: .38em .6em; border-radius: 999px; text-transform: uppercase; letter-spacing: .01em; }
.cap.typewriter { color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.85); font-family: var(--mono); letter-spacing: .02em; border-bottom: 3px solid rgba(255,255,255,.55); padding-bottom: .12em; }
.cap.drop { background: rgba(10,12,16,.9); color: #fff; padding: .32em .6em; border-radius: .5em; text-transform: uppercase; }
.cap.pop { animation: capPop .16s cubic-bezier(.2,.7,.3,1.4); }
@keyframes capPop { from { transform: scale(.82); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.title-layer { position: absolute; left: 0; right: 0; display: flex; justify-content: center; pointer-events: none; padding: 0 6%; }
.title-layer.pos-top { top: 4%; }
.title-layer.pos-bottom { bottom: 4%; }
.title-chip { background: var(--accent); color: #fff; font-weight: 800; text-align: center; padding: .35em .7em; border-radius: .4em; max-width: 96%; line-height: 1.3; }
.title-chip:empty { display: none; }
.transport { width: 100%; max-width: 260px; }
.scrub-wrap { position: relative; height: 22px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.scrub-trim { position: absolute; inset: 0; border-radius: 99px; }
.scrub-wrap input[type=range] {
  position: absolute; inset: 0; width: 100%; height: 100%; margin: 0;
  -webkit-appearance: none; appearance: none; background: transparent; border: none; padding: 0; cursor: pointer;
}
.scrub-wrap input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 6px; height: 22px; border-radius: 3px; background: #fff; border: none; }
.transport .row { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.timecode { font: 11.5px var(--mono); color: var(--muted); margin-left: auto; }
.panel-col { display: flex; flex-direction: column; min-width: 0; }
.studio-tabs { display: flex; gap: 2px; padding: 10px 12px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.studio-tab {
  background: none; border: none; color: var(--muted); font-weight: 700; font-size: 13px;
  padding: 8px 12px; border-radius: 8px 8px 0 0; position: relative; min-height: 40px;
}
.studio-tab.active { color: var(--ink); }
.studio-tab.active::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--accent); }
.studio-pane { display: none; padding: 14px; overflow: auto; }
.studio-pane.active { display: block; animation: fadeUp .22s ease both; }
.cap-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.cap-rows { display: grid; gap: 6px; }
.cap-row {
  display: grid; grid-template-columns: 58px 58px 1fr auto; gap: 6px; align-items: center;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px;
}
.cap-row.live { border-color: var(--accent); background: var(--accent-soft); }
.cap-row input { padding: 6px 7px; font-size: 12.5px; background: var(--surface); border-radius: 8px; }
.cap-row input.t-num { font-variant-numeric: tabular-nums; text-align: center; }
.cap-row .mini { display: flex; gap: 3px; }
.icon-btn {
  background: var(--surface); border: 1px solid var(--line); color: var(--muted); border-radius: 8px;
  width: 28px; height: 28px; display: grid; place-items: center; font-size: 12px; padding: 0; flex: none;
}
.cap-hint { color: var(--muted); font-size: 12px; margin-top: 10px; }
.ctl { margin-bottom: 14px; }
.ctl label { display: flex; justify-content: space-between; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; }
.ctl label output { color: var(--ink); font-variant-numeric: tabular-nums; text-transform: none; }
.ctl input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 5px; border-radius: 99px; background: var(--surface-2); padding: 0; border: none; }
.ctl input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--violet); border: none; }
.ctl .pair { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.ctl .pair input[type=number] { width: 84px; text-align: center; font-variant-numeric: tabular-nums; padding: 6px 8px; }
.divider { border-top: 1px solid var(--line); margin: 16px 0; }
.studio-foot { display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: center; flex-wrap: wrap; }

.caps-grid { display: grid; gap: 8px; }
.cap-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.cap-card b { display: block; margin-bottom: 4px; }
.cap-card span { color: var(--muted); font-size: 12.5px; }

@media (min-width: 860px) {
  .bottom-nav { display: none; }
  .side-nav {
    display: flex; flex-direction: column; gap: 4px;
    position: fixed; top: 0; left: 0; bottom: 0; width: 228px;
    padding: calc(18px + var(--safe-t)) 12px 18px;
    background: var(--bg-elev); border-right: 1px solid var(--line); z-index: 45;
  }
  .side-nav .brand { padding: 4px 8px 18px; }
  .side-nav .nav-btn {
    flex-direction: row; justify-content: flex-start; gap: 10px;
    padding: 0 12px; min-height: 44px; font-size: 14px; color: var(--muted);
  }
  .side-nav .nav-btn.active { background: var(--surface-2); color: var(--ink); }
  .shell { padding: 28px 28px 40px 256px; }
  .topbar { display: none; }
  .page { padding: 0; }
  .page-head h1 { font-size: 30px; }
  .library-grid { grid-template-columns: repeat(4, 1fr); }
  .tiles { grid-template-columns: repeat(4, 1fr); }
  .template-grid { grid-template-columns: repeat(4, 1fr); }
  .choice-grid { grid-template-columns: repeat(5, 1fr); }
  .studio-body { grid-template-columns: minmax(240px, 320px) 1fr; }
  .stage-col { border-bottom: 0; border-right: 1px solid var(--line); }
  .modal.studio { max-width: 980px; height: calc(100vh - 36px); }
  .sheet-card {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -50%);
    width: min(520px, 92vw); border-radius: 20px; max-height: 90vh;
    animation: fadeUp .25s ease;
  }
  #toast { bottom: 24px; }
  .sticky-cta { position: static; }
  .auth { align-items: center; justify-content: center; }
  .auth-inner { width: min(420px, 100%); }
}

@media (prefers-reduced-motion: reduce) {
  .sk::after, .spin, .boot-mark, .boot-bar span, .gen-step.active .dot { animation: none !important; }
  .view-enter, .fade-up, .cap.pop, .studio-pane.active, .gen-result.show, .sheet-card { animation: none !important; }
  .overlay, .modal, .btn, .meter span, .gen-bar span { transition: none !important; }
}
