/* Prompt to Video — dark creator-tool theme, no frameworks. */
:root {
  --bg: #0b0d12;
  --panel: #141824;
  --panel-2: #1a2030;
  --border: #2a3248;
  --text: #eef1f8;
  --muted: #9aa3bd;
  --accent: #7c6cff;
  --accent-2: #00d4ff;
  --danger: #ff5d6c;
  --ok: #3ddc84;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.bg-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(700px 340px at 12% -5%, rgba(124,108,255,.30), transparent 60%),
    radial-gradient(640px 320px at 88% 0%, rgba(0,212,255,.20), transparent 60%),
    radial-gradient(900px 480px at 50% 115%, rgba(255,122,89,.12), transparent 60%),
    radial-gradient(500px 400px at 100% 60%, rgba(124,108,255,.10), transparent 60%);
}
.view { position: relative; z-index: 1; }
.hidden { display: none !important; }

/* ---------- auth ---------- */
#auth-view { display: flex; justify-content: center; align-items: center; min-height: 100vh; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 16px; padding: 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.logo img { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto; }
.auth-card h1 { margin: 8px 0 4px; font-size: 26px; }
.subtitle { color: var(--muted); margin: 0 0 20px; font-size: 14px; }
.tabs { display: flex; gap: 8px; margin-bottom: 20px; }
.tab {
  flex: 1; padding: 10px; background: transparent; color: var(--muted);
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 14px;
}
.tab.active { background: var(--panel-2); color: var(--text); border-color: var(--accent); }

/* ---------- app layout ---------- */
#app-view { max-width: 1024px; margin: 0 auto; padding: 20px 20px 64px; }
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 4px 20px;
}
.brand { font-size: 20px; font-weight: 700; }
.userbox { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 14px; }
.credit-badge {
  font-weight: 700; font-size: 14px; color: #fbbf24;
  background: rgba(251, 191, 36, 0.12); border: 1px solid rgba(251, 191, 36, 0.35);
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; margin-bottom: 16px;
}
.panel h2 { margin: 0 0 16px; font-size: 18px; }
.count { color: var(--muted); font-weight: 400; font-size: 14px; }

/* ---------- forms ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 14px; }
.optional { color: var(--muted); font-weight: 400; }
input[type="email"], input[type="password"], input[type="text"], select, textarea, input[type="file"] {
  width: 100%; margin-top: 6px; padding: 12px; font-size: 15px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); font-family: inherit;
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
input[type="file"] { cursor: pointer; }
select { cursor: pointer; appearance: auto; }

/* signup-only fields + password visibility toggle */
.name-row { display: flex; gap: 12px; }
.name-row label { flex: 1; min-width: 0; }
.password-wrap { position: relative; display: block; }
.password-wrap input { padding-right: 44px; }
.eye-btn {
  position: absolute; right: 6px; top: 6px; bottom: 0;
  width: 36px; background: transparent; border: none; cursor: pointer;
  font-size: 18px; line-height: 1; opacity: .7;
}
.eye-btn:hover { opacity: 1; }

/* password strength meter (signup + reset forms) */
.strength-meter { display: flex; align-items: center; gap: 10px; margin: -4px 0 14px; }
.strength-track { flex: 1; height: 6px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--border); overflow: hidden; }
.strength-fill { height: 100%; width: 0; border-radius: 999px; transition: width .2s; }
.strength-label { font-size: 13px; font-weight: 600; min-width: 58px; text-align: right; }
.strength-meter[data-level="weak"] .strength-fill { background: var(--danger); }
.strength-meter[data-level="weak"] .strength-label { color: var(--danger); }
.strength-meter[data-level="medium"] .strength-fill { background: #f59e0b; }
.strength-meter[data-level="medium"] .strength-label { color: #f59e0b; }
.strength-meter[data-level="strong"] .strength-fill { background: var(--ok); }
.strength-meter[data-level="strong"] .strength-label { color: var(--ok); }

.btn {
  display: inline-block; padding: 12px 22px; font-size: 15px; font-weight: 600;
  border-radius: 10px; border: 1px solid var(--border); cursor: pointer;
  background: var(--panel-2); color: var(--text); transition: transform .05s;
}
.btn:active { transform: scale(.98); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; color: #fff; width: 100%;
}
.btn.ghost { padding: 8px 14px; font-size: 13px; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); padding: 8px 14px; font-size: 13px; }
.btn.small { padding: 8px 14px; font-size: 13px; }
.error { color: var(--danger); font-size: 14px; }

/* ---------- format picker ---------- */
.format-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.format-card {
  margin: 0; padding: 8px 6px; text-align: center; cursor: pointer;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.format-card input { display: none; }
.format-card:has(input:checked) { border-color: var(--accent); background: rgba(124,108,255,.12); }
.format-glyph { display: block; border: 2px solid var(--muted); border-radius: 3px; }
.format-glyph.tall { width: 13px; height: 24px; }
.format-glyph.square { width: 19px; height: 19px; }
.format-glyph.wide { width: 26px; height: 15px; }
.format-name { font-size: 12px; }
.format-use { font-size: 10px; color: var(--muted); font-weight: 400; }

/* ---------- jobs ---------- */
.job-list { display: flex; flex-direction: column; gap: 14px; }
.empty { color: var(--muted); font-size: 14px; margin: 0; }

/* ---------- clip folders ---------- */
#folder-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.folder-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.folder-chip {
  font-size: 13px; font-weight: 600; padding: 6px 12px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  cursor: pointer;
}
.folder-chip:hover { border-color: var(--accent-2); color: var(--text); }
.folder-chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.folder-chip .count { font-weight: 400; opacity: .8; }
.folder-actions { display: flex; gap: 8px; margin-bottom: 10px; }

/* ---------- compact gallery grid ---------- */
#gallery-list.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 12px;
}
.gallery-grid .job { padding: 10px; }
.gallery-grid .job-top { margin-bottom: 6px; }
.gallery-grid .job-prompt {
  font-size: 12px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.gallery-grid .job-meta { font-size: 11px; margin: 4px 0; }
.gallery-grid .job video { max-height: 200px; margin-top: 6px; }
.gallery-grid .job-actions { gap: 6px; margin-top: 8px; }
.gallery-grid .job-actions .btn { padding: 4px 8px; font-size: 12px; }
.gallery-grid .folder-move {
  width: 100%; margin-top: 8px; font-size: 12px;
  background: var(--panel); color: var(--muted);
  border: 1px solid var(--border); border-radius: 8px; padding: 5px 6px;
}
/* (retired: per-card folder dropdown replaced by select + cut/copy/paste) */

/* ---------- card ⋮ menus ---------- */
.card-menu { position: relative; margin-left: auto; flex: none; }
.menu-dots {
  border: none; background: transparent; cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 8px;
  color: var(--muted);
}
.menu-dots:hover { background: var(--panel); color: var(--text); }
.menu-pop {
  position: absolute; top: 100%; right: 0; z-index: 30;
  min-width: 190px; padding: 6px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.menu-item {
  display: block; width: 100%; text-align: left;
  border: none; background: transparent; cursor: pointer;
  padding: 8px 10px; border-radius: 8px; font-size: 13px; color: var(--text);
}
.menu-item:hover { background: var(--panel); }
.menu-item.danger { color: #c0392b; }
.menu-item.sub { padding-left: 22px; }
.menu-sub { border-top: 1px dashed var(--border); margin-top: 2px; padding-top: 2px; max-height: 180px; overflow-y: auto; }
.menu-empty { padding: 8px 10px; font-size: 12px; color: var(--muted); }

/* ---------- compact project grid ---------- */
#assemblies-list.asm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.asm-grid .job { padding: 10px; }
.asm-grid .job-prompt {
  font-size: 12px; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.asm-grid .job-meta { font-size: 11px; margin: 4px 0; }
.asm-grid .job video { max-height: 200px; margin-top: 6px; }
.asm-grid .job-actions { gap: 6px; margin-top: 8px; }
.asm-grid .job-actions .btn { padding: 4px 8px; font-size: 12px; }
@media (max-width: 560px) {
  #assemblies-list.asm-grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
}
@media (max-width: 560px) {
  #gallery-list.gallery-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
}
.job {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 16px;
}
.job-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 8px; }
.job-prompt { font-size: 14px; }
.badge {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}
.badge.uploaded {
  background: linear-gradient(135deg, #16a34a, #4ade80);
  border: none; color: #fff;
}
/* External video upload row (Studio step 2). */
.upload-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.upload-status { font-size: 13px; color: var(--muted); }
.upload-progress {
  height: 6px; border-radius: 3px; background: var(--panel);
  border: 1px solid var(--border); overflow: hidden; margin-bottom: 12px;
}
.upload-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.2s ease;
}
.status { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.status.pending { background: rgba(255,193,7,.15); color: #ffc107; }
.status.processing { background: rgba(0,212,255,.15); color: var(--accent-2); }
.status.done { background: rgba(61,220,132,.15); color: var(--ok); }
.status.failed { background: rgba(255,93,108,.15); color: var(--danger); }
.status.draft { background: rgba(167,139,250,.15); color: #a78bfa; }

/* ---------- voiceover ---------- */
.voiceover { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--border); }
.voiceover h3 { margin: 0 0 6px; font-size: 16px; }
.vo-optional { font-size: 12px; font-weight: 400; color: var(--muted); }
#vo-script { width: 100%; min-height: 88px; }
.vo-row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; margin-top: 10px; }
.vo-voice-label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
#vo-estimate { margin: 8px 0 0; }
#vo-error { margin: 8px 0 0; }
#vo-preview { margin-top: 12px; }
#vo-audio { width: 100%; }
#vo-meta { margin: 6px 0 0; }
.vo-warn { color: #ffc107; font-size: 14px; margin: 6px 0 0; }
.vo-disclosure { color: var(--muted); font-size: 12px; margin: 10px 0 0; }
.spinner {
  display: inline-block; width: 12px; height: 12px; margin-right: 6px;
  border: 2px solid rgba(0,212,255,.3); border-top-color: var(--accent-2);
  border-radius: 50%; animation: spin 1s linear infinite; vertical-align: -1px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.job-meta { color: var(--muted); font-size: 12px; margin: 6px 0; }
.job-error { color: var(--danger); font-size: 13px; margin: 6px 0; }
.job-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.job video {
  display: block;
  width: auto;            /* let the box hug the video's real shape… */
  max-width: 100%;
  max-height: 420px;
  margin: 8px auto 0;     /* …and center it in the card */
  border-radius: 10px;
  background: #000;
  aspect-ratio: 16 / 9;
}
/* Reserve each video's box before its metadata loads so the layout never shifts. */
.job video.ar-916 { aspect-ratio: 9 / 16; }
.job video.ar-11 { aspect-ratio: 1 / 1; }
.job video.ar-169 { aspect-ratio: 16 / 9; }

@media (max-width: 560px) {
  .format-use { display: none; }
  .format-name { font-size: 11px; }
  .panel { padding: 18px; }
}

/* ---------- email verification / password reset ---------- */
.auth-alt { text-align: center; margin: 14px 0 0; font-size: 14px; }
.link-btn {
  background: none; border: none; padding: 0; cursor: pointer;
  color: var(--accent-2); font-size: inherit; font-family: inherit; text-decoration: underline;
}
.link-btn:hover { color: var(--accent); }
.success { color: var(--ok); font-size: 14px; }
.verify-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 auto 16px; max-width: 860px; padding: 12px 16px;
  background: rgba(255,193,7,.08); border: 1px solid rgba(255,193,7,.35);
  border-radius: 12px; font-size: 14px; color: #ffd97a;
}
.verify-banner.hidden { display: none; }
.storage-banner { border-color: rgba(255,107,107,.4); background: rgba(255,107,107,.07); color: #ffb3b3; }

/* ---------- upgrade ---------- */
#upgrade-btn { width: auto; white-space: nowrap; }
.modal { position: fixed; inset: 0; background: rgba(4,6,12,.7); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal.hidden { display: none; }
.modal-card { background: var(--panel); border: 1px solid var(--border); border-radius: 18px;
  max-width: 560px; width: 100%; padding: 32px; position: relative; text-align: center; }
.modal-x { position: absolute; top: 12px; right: 14px; background: none; border: none;
  color: var(--muted); font-size: 18px; cursor: pointer; }
.modal-sub { color: var(--muted); margin: 8px 0 24px; }
.plan-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.plan-card { border: 1px solid var(--border); border-radius: 14px; padding: 20px 16px; }
.plan-card.featured { border-color: var(--accent); box-shadow: 0 0 24px rgba(109,92,255,.25); }
.plan-name { font-weight: 700; font-size: 16px; }
.plan-price { font-size: 30px; font-weight: 800; margin: 8px 0 4px; }
.plan-price span { font-size: 14px; font-weight: 400; color: var(--muted); }
.plan-credits { font-weight: 600; }
.plan-hint { color: var(--muted); font-size: 13px; margin: 4px 0 14px; }
.plan-card .btn-block { width: 100%; }
.modal-fine { color: var(--muted); font-size: 12px; margin: 0 0 8px; }
@media (max-width: 520px) { .plan-grid { grid-template-columns: 1fr; } }

/* ---------- billing: card setup + auto-recharge ---------- */
.billing-check { display: flex; gap: 10px; align-items: flex-start; text-align: left; font-size: 14px;
  color: var(--muted); margin: 4px 0 16px; cursor: pointer; }
.billing-check input[type="checkbox"] { margin-top: 3px; flex-shrink: 0; }
.billing-check strong { color: var(--text); }
.billing-settings { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 16px; text-align: left; }
.billing-row { display: flex; justify-content: space-between; align-items: center; font-size: 14px; margin-bottom: 10px; }
.link-btn { background: none; border: none; color: var(--accent); font-size: 14px; cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- stitch studio ---------- */
.hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.hint strong { color: var(--text); }
.btn.stitching { border-color: var(--accent); color: var(--accent-2); background: rgba(124,108,255,.12); }
.stitch-item {
  background: var(--panel-2); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 16px;
}
.stitch-item-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.stitch-num {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(124,108,255,.18); border: 1px solid var(--accent);
  color: var(--accent-2); font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.stitch-prompt { flex: 1; font-size: 14px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stitch-order { display: flex; gap: 6px; }
.stitch-order .btn { padding: 6px 10px; font-size: 13px; }
.stitch-order .btn:disabled { opacity: .35; cursor: default; }
.trim-row { display: flex; gap: 10px; align-items: flex-end; margin-top: 8px; flex-wrap: wrap; }
.trim-row label { margin: 0; font-size: 12px; color: var(--muted); font-weight: 600; }
.trim-row input {
  width: 84px; margin-top: 4px; padding: 8px 10px; font-size: 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; color: var(--text);
}
.trim-row input:focus { outline: none; border-color: var(--accent); }
.trim-hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stitch-controls { margin-top: 16px; }
.stitch-title-label { max-width: 320px; }
#stitch-btn:disabled { opacity: .45; cursor: default; }
#stitch-btn:not(:disabled) { width: auto; padding: 12px 28px; }
.dur { color: var(--accent-2); font-weight: 600; }

/* ---------- unified studio: accordion steps ---------- */
.studio-panel > .hint { margin-top: -4px; }
.studio-panel .step-body label { margin-bottom: 10px; }
#clips-panel, #projects-panel { scroll-margin-top: 76px; }
.studio-step {
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 4px 14px;
  margin-top: 10px;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(135deg, rgba(124,108,255,.55), rgba(0,212,255,.22), rgba(255,122,89,.30)) border-box;
}
.studio-step.open { padding-bottom: 12px; }
.step-head {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: none; border: none; cursor: pointer; text-align: left;
  padding: 10px 0; color: var(--text); font-family: inherit;
}
.step-head:hover .step-title { color: var(--accent-2); }
.step-title { font-size: 16px; font-weight: 700; }
.step-status { margin-left: auto; font-size: 13px; color: var(--muted); font-weight: 400; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step-chev { color: var(--muted); font-size: 14px; transition: transform .2s; flex: none; }
.studio-step.open .step-chev { transform: rotate(180deg); }
.step-body { display: none; }
.studio-step.open .step-body { display: block; }
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(124,108,255,.5);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}
.studio-step .voiceover { margin-top: 0; padding-top: 0; border-top: none; }
.tray-heading { margin: 12px 0 8px; font-size: 14px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tray-viewall { font-size: 13px; font-weight: 600; color: var(--accent-2); text-decoration: none; white-space: nowrap; }
.tray-viewall:hover { text-decoration: underline; }
.hint-inline { font-weight: 400; color: var(--muted); font-size: 12px; }
.tray {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}
.tray-item { position: relative; flex: 0 0 120px; width: 120px; }
.tray-item video {
  width: 120px;
  height: 160px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #000;
  display: block;
}
.tray-dur {
  position: absolute;
  left: 6px;
  bottom: 6px;
  font-size: 10px;
  background: rgba(0,0,0,.65);
  color: #fff;
  padding: 2px 6px;
  border-radius: 6px;
  pointer-events: none;
}
.tray-add {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(0,0,0,.65);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.tray-add.on { background: var(--accent); }

/* ---------- dialogue (multi-speaker voiceover) ---------- */
.vo-tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.vo-tab {
  padding: 8px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: transparent; color: var(--muted); cursor: pointer; font-size: 14px;
}
.vo-tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#vo-dialogue-script { width: 100%; min-height: 120px; margin-top: 10px; }
#dlg-cast { display: flex; flex-direction: column; gap: 8px; margin: 10px 0; }
.dlg-speaker-row { display: flex; gap: 8px; align-items: center; }
.dlg-speaker-row input[type="text"] { flex: 1; min-width: 0; text-transform: uppercase; }
.dlg-speaker-row select { flex: 1; min-width: 0; }
#vo-dialogue-estimate, #vo-dialogue-error { margin: 8px 0 0; }
#vo-dialogue-generate { margin-top: 10px; }

/* ---------- background music picker ---------- */
.music-picker { margin: 4px 0 16px; padding: 12px; border: 1px solid var(--border); border-radius: 10px; }
.music-picker h4 { margin: 0 0 4px; font-size: 15px; }
.music-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.music-track {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
}
.music-track:has(input:checked) { border-color: var(--accent); background: rgba(0,212,255,.06); }
.music-name { font-weight: 600; font-size: 14px; }
.music-desc { color: var(--muted); font-size: 13px; flex: 1; }
.music-preview {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-size: 12px; flex-shrink: 0;
}
.music-preview:hover { border-color: var(--accent); }
.music-track.generated { border-style: dashed; }
.music-section-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin: 8px 2px 2px; }
.track-status { font-size: 12px; color: var(--accent); }
.track-status.err { color: #f87171; }
.music-del {
  border: 1px solid var(--border); background: transparent; color: var(--muted);
  border-radius: 50%; width: 30px; height: 30px; cursor: pointer; font-size: 12px; flex-shrink: 0;
}
.music-del:hover { border-color: #f87171; color: #f87171; }
.music-gen { margin-top: 10px; }
.music-gen-form { margin-top: 10px; padding: 4px 2px; display: flex; flex-direction: column; gap: 10px; }
.music-gen-form.hidden { display: none; }
.music-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.music-preset {
  border: 1px solid var(--border); background: transparent; color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.music-preset:hover { border-color: var(--accent); }
.music-gen-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; }
.music-gen-form input[type="text"], .music-gen-form textarea {
  font-weight: 400; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--bg); color: var(--text); font-size: 14px;
}
.music-gen-form input[type="range"] { width: 100%; }
.music-lyrics-row { flex-direction: row !important; align-items: center; gap: 8px !important; font-weight: 400 !important; }
#music-lyrics-wrap.hidden { display: none; }
.music-gen-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- sticky studio step nav ---------- */
.studio-nav {
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: 2px;
  background: var(--bg); padding: 8px 0 6px; margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.studio-nav button {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 5px 2px; border: none; border-radius: 8px;
  background: none; color: var(--muted); cursor: pointer; font-size: 12.5px; font-weight: 600;
  min-width: 0; font-family: inherit;
}
.studio-nav button:hover .nav-label { color: var(--text); }
.studio-nav button.active { color: var(--text); }
.studio-nav button.active .nav-label { color: var(--accent-2); }
.studio-nav .step-num {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted); font-size: 11px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: none; transition: background .2s, color .2s, border-color .2s;
}
.studio-nav button.has-content .step-num {
  background: rgba(124,108,255,.18); border-color: rgba(124,108,255,.55); color: var(--text);
}
.studio-nav button.active .step-num {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff;
  box-shadow: 0 0 10px rgba(124,108,255,.45);
}
.nav-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-status { font-size: 11px; color: var(--accent-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) {
  .nav-label { display: none; }
  .nav-status { display: none; }
}

/* ---------- kids: clip + tune side by side ---------- */
#create-grid.kids { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
#create-grid.kids #tune-slot.hidden { display: none; }
#tune-slot .music-gen { margin-top: 0; }
#tune-slot .music-gen-form { display: flex; }
#tune-slot .music-gen-form.hidden { display: none; }
@media (max-width: 760px) {
  #create-grid.kids { grid-template-columns: 1fr; }
}

/* ---------- cast (recurring characters) ---------- */
.cast-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; margin: 12px 0; }
.cast-card { position: relative; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.cast-card img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.cast-name { padding: 6px 8px; font-size: 13px; font-weight: 600; }
.cast-del {
  position: absolute; top: 6px; right: 6px; width: 26px; height: 26px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.6); color: #fff; cursor: pointer; font-size: 12px;
}
.cast-add { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-top: 8px; }
.cast-add input[type="text"] { flex: 1; min-width: 180px; }
#character-note { margin: 6px 0 0; }

/* ---------- first-run guide ---------- */
.how-it-works {
  position: relative;
  display: flex; gap: 18px; flex-wrap: wrap;
  margin: 4px 0 6px; padding: 16px 44px 16px 18px;
  border-radius: 12px;
  background:
    linear-gradient(rgba(20,24,36,.92), rgba(20,24,36,.92)) padding-box,
    linear-gradient(135deg, rgba(124,108,255,.6), rgba(0,212,255,.35)) border-box;
  border: 1px solid transparent;
}
.howto-step { display: flex; gap: 10px; align-items: flex-start; flex: 1; min-width: 180px; }
.howto-step div { display: flex; flex-direction: column; gap: 2px; }
.howto-step b { font-size: 14px; }
.howto-step span span { font-size: 13px; color: var(--muted); }
.howto-num {
  flex: none; width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff; font-size: 13px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.howto-x {
  position: absolute; top: 8px; right: 10px;
  background: none; border: none; color: var(--muted);
  cursor: pointer; font-size: 14px; padding: 4px;
}
.howto-x:hover { color: var(--text); }

/* ---------- starting image (upload or cast) ---------- */
.start-image-group {
  background: var(--panel-2); border-radius: 12px;
  padding: 4px 12px; margin-bottom: 12px;
}
.start-image-toggle {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; background: none; border: none; cursor: pointer; text-align: left;
  padding: 9px 0; color: var(--text); font-family: inherit; font-size: 14px; font-weight: 600;
}
.start-image-toggle .optional { font-weight: 400; color: var(--muted); font-size: 12px; }
.start-image-toggle .step-chev { transition: transform .2s; }
.start-image-toggle[aria-expanded="true"] .step-chev { transform: rotate(180deg); }
.start-image-body { padding: 2px 0 10px; }
.start-image-body.hidden { display: none; }
.start-image-group label { margin-bottom: 0; }
.or-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 10px 0; color: var(--muted); font-size: 12px; font-weight: 600;
}
.or-divider::before, .or-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}
.or-divider span { padding: 0 2px; }

/* ---------- examples ---------- */
.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.example-card { margin: 0; }
.example-card video {
  width: 100%; max-height: 340px; border-radius: 12px; background: #000;
  border: 1px solid var(--border); display: block; object-fit: cover;
}
.example-card figcaption { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.example-card figcaption b { font-size: 14px; }
.example-card figcaption span { font-size: 13px; color: var(--muted); }
#examples-panel.compact .examples-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
#examples-panel.compact .example-card video { max-height: 170px; }
#examples-panel.compact .example-card figcaption b { font-size: 13px; }
#examples-panel.compact .example-card figcaption span { font-size: 12px; }

/* ---------- voiceover alt link ---------- */
.vo-alt { margin: 12px 0 0; }

/* ============================================================
   Kids mode — 2026-10-01
   A separate creation mode for making videos FOR young audiences.
   ============================================================ */
.mode-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.mode-pill {
  flex: 1;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.mode-pill.active {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, #6366f1, #a855f7, #ec4899);
  box-shadow: 0 6px 18px rgba(168, 85, 247, .35);
}
#mode-kids.active {
  background: linear-gradient(135deg, #f59e0b, #ec4899, #8b5cf6);
  box-shadow: 0 6px 18px rgba(236, 72, 153, .35);
}
.kids-panel {
  border: 1px dashed #f0abfc;
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 14px;
  background: linear-gradient(180deg, rgba(240, 171, 252, .10), rgba(147, 197, 253, .10));
}
.kids-intro {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.kids-templates {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.kids-template {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease;
}
.kids-template:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(236, 72, 153, .25);
  border-color: #f0abfc;
}
.tpl-icon { font-size: 26px; line-height: 1; }
.tpl-name { font-size: 12px; font-weight: 700; color: var(--text); text-align: center; }
.badge.kids {
  background: linear-gradient(135deg, #f59e0b, #ec4899);
  color: #fff;
  border: none;
}
/* Cheerful frame around the whole Studio while Kids mode is on */
.studio-panel.kids-mode {
  border-radius: 20px;
  border: 2px solid transparent;
  background:
    linear-gradient(var(--panel), var(--panel)) padding-box,
    linear-gradient(135deg, #f59e0b, #ec4899, #8b5cf6, #3b82f6) border-box;
}
@media (max-width: 560px) {
  .kids-templates { grid-template-columns: repeat(2, 1fr); }
}

/* Match-a-reference (music-ref.js) */
.music-ref { margin-top: 10px; }
.music-ref-form, #music-ref-form { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
#music-ref-form.hidden { display: none; }
#music-ref-file { font-size: 13px; }
#music-ref-result { min-height: 18px; }
.music-lock, .music-dl { border: none; background: none; cursor: pointer; font-size: 15px; padding: 2px 4px; }
.music-lock:hover, .music-dl:hover { transform: scale(1.15); }
.lock-panel {
  position: fixed; right: 16px; bottom: 16px; z-index: 1000;
  width: 320px; max-width: calc(100vw - 32px);
  background: #1b2230; color: #eef2f7; border: 1px solid #3a4a63;
  border-radius: 12px; padding: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.45);
}
.lock-panel-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.lock-panel .hint { color: #aeb9cc; font-size: 12px; }
.lock-row { display: flex; gap: 10px; align-items: center; margin: 10px 0; flex-wrap: wrap; }
.lock-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; }
.lock-row input[type="number"] { width: 80px; padding: 4px 6px; border-radius: 6px; border: 1px solid #3a4a63; background: #0f1520; color: #eef2f7; }
.lock-row select { padding: 4px 6px; border-radius: 6px; border: 1px solid #3a4a63; background: #0f1520; color: #eef2f7; }
