/* Video Studio — dark-first, light theme via [data-theme] or OS setting */
:root {
  --bg: #f4f6f8; --surface: #ffffff; --surface-2: #f0f3f6; --border: #e1e6ec;
  --text: #0f172a; --muted: #5b6678; --faint: #94a0b0;
  --accent: #0e7a5f; --accent-hover: #0b6650; --accent-soft: #e3f4ee; --accent-text: #0b6650;
  --warn: #b45309; --warn-soft: #fdf3e5; --danger: #c2410c; --ok: #15803d;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0a0e13; --surface: #11171f; --surface-2: #17202a; --border: #222c38;
    --text: #e7ecf2; --muted: #8d9aab; --faint: #5d6a7b;
    --accent: #19a37f; --accent-hover: #1cb88f; --accent-soft: #0f2a23; --accent-text: #5fd6b1;
    --warn: #f59e0b; --warn-soft: #2a1f0c; --danger: #f97316; --ok: #22c55e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0a0e13; --surface: #11171f; --surface-2: #17202a; --border: #222c38;
  --text: #e7ecf2; --muted: #8d9aab; --faint: #5d6a7b;
  --accent: #19a37f; --accent-hover: #1cb88f; --accent-soft: #0f2a23; --accent-text: #5fd6b1;
  --warn: #f59e0b; --warn-soft: #2a1f0c; --danger: #f97316; --ok: #22c55e;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 32px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-text); }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); font-weight: 400; }
i[data-icon] { display: inline-flex; width: 18px; height: 18px; flex: none; }
i[data-icon] svg { width: 100%; height: 100%; }

/* ---------------------------------------------------------------- layout */
.app { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 18px;
  padding: 20px 14px; border-right: 1px solid var(--border); background: var(--surface); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.logo { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 800;
  color: #fff; background: linear-gradient(135deg, #19a37f, #0b5a46); box-shadow: 0 4px 14px rgba(25, 163, 127, .35); }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text span { color: var(--muted); font-size: .82em; }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-label { font-size: .72em; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px; color: var(--muted);
  text-decoration: none; font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--surface-2); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--accent-text); }
.budget { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px; font-size: .88em; }
.budget-row { display: flex; justify-content: space-between; gap: 8px; }
.budget-row b { font-variant-numeric: tabular-nums; }
.budget-row.muted { color: var(--muted); font-size: .9em; }
.meter { position: relative; height: 6px; border-radius: 99px; background: var(--border); margin: 8px 0 6px; overflow: hidden; display: flex; }
.meter i { display: block; height: 100%; width: 0; transition: width .4s; }
#meter-used { background: var(--accent); }
#meter-pending { background: repeating-linear-gradient(45deg, var(--warn) 0 4px, transparent 4px 7px); }
.theme-toggle { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--border);
  border-radius: 9px; padding: 7px 10px; color: var(--muted); cursor: pointer; }
.theme-toggle:hover { color: var(--text); }

.main { padding: 28px 32px 120px; min-width: 0; }
.page-head { margin-bottom: 22px; max-width: 760px; }
.page-head.row-between { max-width: none; display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.eyebrow { color: var(--accent-text); font-size: .78em; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.page-head h1 { font-size: 1.75rem; letter-spacing: -.02em; margin: 2px 0 6px; }
.page-head p { color: var(--muted); margin: 0; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.form { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 14px; font-size: 1rem; display: flex; align-items: center; gap: 8px; }
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > span { font-weight: 600; font-size: .9em; }
.field em, .toggle em { font-style: normal; font-weight: 400; color: var(--muted); font-size: .92em; margin-left: 4px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.row > * { flex: 1; min-width: 160px; }
.hint { color: var(--muted); font-size: .82em; }
input[type=text], textarea, select {
  width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { resize: vertical; min-height: 44px; }
input[type=text]:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
input[type=range] { width: 100%; accent-color: var(--accent); }
output { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .88em; }

/* ---------------------------------------------------------------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; background: var(--accent); color: #fff;
  border: none; border-radius: 10px; padding: 10px 16px; font-weight: 600; cursor: pointer; transition: background .15s, transform .05s; white-space: nowrap; }
.btn:hover { background: var(--accent-hover); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn.ghost:hover { background: var(--surface-2); }
.btn.big { width: 100%; padding: 14px; font-size: 1.02em; border-radius: 12px; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; padding: 6px; border-radius: 8px; display: inline-flex; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

/* segmented control */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px; padding: 4px; width: fit-content; max-width: 100%; }
.seg button { border: none; background: none; padding: 7px 14px; border-radius: 8px; cursor: pointer; color: var(--muted); font-weight: 500; display: inline-flex; align-items: center; gap: 7px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .15); }
.shape { display: inline-block; border: 1.6px solid currentColor; border-radius: 3px; }

/* radio cards: models, presenter modes */
.picker, .cards-radio { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.opt { text-align: left; background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 12px; padding: 12px 14px; cursor: pointer; transition: border-color .15s, background .15s; }
.opt:hover { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.opt b { display: flex; justify-content: space-between; gap: 6px; font-size: .92em; }
.opt b small { color: var(--accent-text); font-weight: 600; white-space: nowrap; }
.opt span { display: block; color: var(--muted); font-size: .82em; margin-top: 3px; line-height: 1.35; }

/* voice picker */
.voice { display: flex; gap: 8px; }
.voice select { flex: 1; }

/* toggles */
.toggle { display: flex; align-items: center; gap: 12px; cursor: pointer; padding: 6px 0; font-weight: 500; }
.toggle input { display: none; }
.toggle > span { width: 38px; height: 22px; border-radius: 99px; background: var(--border); position: relative; flex: none; transition: background .2s; }
.toggle > span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 2px rgba(0, 0, 0, .3); }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(16px); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chips button { border: 1px solid var(--border); background: var(--surface-2); border-radius: 99px; padding: 5px 12px; font-size: .82em; color: var(--muted); cursor: pointer; }
.chips button:hover { color: var(--text); border-color: var(--accent); }

/* ---------------------------------------------------------------- dropzone */
.drop { position: relative; border: 1.5px dashed var(--border); border-radius: 12px; background: var(--surface-2); min-height: 86px;
  display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; cursor: pointer; color: var(--muted);
  transition: border-color .15s, background .15s; text-align: center; font-size: .9em; overflow: hidden; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-text); }
.drop-lg { min-height: 200px; }
.drop input { display: none; }
.drop.filled { border-style: solid; padding: 0; cursor: default; }
.drop.filled img { width: 100%; max-height: 320px; object-fit: contain; display: block; background: #000; }
.drop.filled audio { width: calc(100% - 24px); margin: 22px 12px; }
.drop .x { position: absolute; top: 8px; right: 8px; background: rgba(0, 0, 0, .65); color: #fff; border: none; border-radius: 99px; width: 28px; height: 28px; cursor: pointer; display: grid; place-items: center; }
.drop .busy { position: absolute; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--surface) 70%, transparent); }

/* ---------------------------------------------------------------- caption styles */
.captions { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.cap-tile { background: none; border: 1.5px solid var(--border); border-radius: 12px; padding: 6px; cursor: pointer; text-align: center; color: var(--muted); font-size: .8em; font-weight: 600; transition: border-color .15s; }
.cap-tile.on { border-color: var(--accent); color: var(--accent-text); }
.cap-screen { height: 74px; border-radius: 8px; margin-bottom: 6px; display: flex; align-items: flex-end; justify-content: center; padding: 8px 6px;
  background: linear-gradient(160deg, #3b5d7a, #1a2a3a 60%, #0f1822); overflow: hidden; }
.cap { display: inline-block; color: #fff; font-weight: 800; font-size: 11px; line-height: 1.25; letter-spacing: .01em; }
.cap em { font-style: normal; }
.cap-clean { text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; }
.cap-karaoke { font-family: Impact, "Arial Black", sans-serif; font-weight: 400; font-size: 14px; text-transform: uppercase;
  text-shadow: -1.5px -1.5px 0 #000, 1.5px -1.5px 0 #000, -1.5px 1.5px 0 #000, 1.5px 1.5px 0 #000; }
.cap-karaoke em { color: #FFD60A; }
.cap-pill { font-family: "Arial Black", sans-serif; text-transform: uppercase; font-size: 10px; text-shadow: -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000, 1px 1px 0 #000; }
.cap-pill em { background: #0e7a5f; border-radius: 5px; padding: 1px 4px; }
.cap-boxed { background: rgba(0, 0, 0, .72); padding: 4px 7px; border-radius: 5px; font-weight: 700; }
.cap-brand { background: #0e7a5f; padding: 4px 7px; border-radius: 6px; font-family: "Arial Rounded MT Bold", "Arial Rounded Bold", sans-serif; }
.cap-brand em { color: #B8F5DC; }
.cap-minimal { font-size: 9px; font-weight: 600; text-shadow: 1px 1px 2px rgba(0, 0, 0, .8); }
.cap-none { color: rgba(255, 255, 255, .45); font-weight: 500; }

/* ---------------------------------------------------------------- summary / preview */
.summary { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 14px; }
.preview { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: grid; place-items: center; }
.screen { position: relative; width: 100%; max-width: 190px; aspect-ratio: 9 / 16; border-radius: 18px; overflow: hidden;
  background: linear-gradient(160deg, #2c4a63, #13202d 55%, #0b131b); background-size: cover; background-position: center;
  box-shadow: 0 0 0 6px #05080c, 0 18px 40px rgba(0, 0, 0, .35); transition: aspect-ratio .3s, max-width .3s; }
.screen.r-16-9 { aspect-ratio: 16 / 9; max-width: 100%; border-radius: 12px; }
.screen.r-1-1 { aspect-ratio: 1; max-width: 230px; }
.screen .shade { position: absolute; inset: 0; background: linear-gradient(transparent 45%, rgba(0, 0, 0, .45)); }
.screen .cap-line { position: absolute; left: 6%; right: 6%; bottom: 18%; text-align: center; }
.screen.r-16-9 .cap-line { bottom: 12%; }
.screen .cap { font-size: 12px; }
.screen .cap-karaoke { font-size: 16px; }
.screen .banner { position: absolute; top: 6%; left: 0; right: 0; text-align: center; color: #fff; font-weight: 700; font-size: 11px; text-shadow: 0 1px 3px #000; }
.screen .banner small { display: inline-block; background: #0e7a5f; border-radius: 99px; padding: 2px 8px; font-size: 9px; letter-spacing: .06em; margin-bottom: 3px; text-shadow: none; }
.screen .bubble { position: absolute; right: 6%; bottom: 34%; width: 30%; aspect-ratio: 1; border-radius: 50%; border: 2px solid #fff;
  background: radial-gradient(circle at 50% 38%, #e6c3a5 0 18%, transparent 19%), radial-gradient(circle at 50% 100%, #3a5f8a 0 42%, #7aa0c4 43%); background-size: cover; background-position: center; }
.screen .tag { position: absolute; top: 8px; left: 8px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; border-radius: 99px; padding: 2px 8px; }
.est-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.est-card .lbl { color: var(--muted); font-size: .85em; }
.est-card .amt { font-size: 2rem; font-weight: 750; letter-spacing: -.02em; font-variant-numeric: tabular-nums; margin: 2px 0; }
.est-card .note { color: var(--muted); font-size: .82em; min-height: 1.2em; margin-bottom: 14px; }
.est-card .facts { list-style: none; padding: 0; margin: 0 0 14px; font-size: .85em; color: var(--muted); display: grid; gap: 4px; }
.est-card .facts li { display: flex; justify-content: space-between; gap: 8px; }
.est-card .facts b { color: var(--text); font-weight: 600; text-align: right; }

/* ---------------------------------------------------------------- tutorial steps */
.steps { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 12px; }
.step { display: grid; grid-template-columns: 34px 1fr 150px; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.step-no { width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .9em; }
.step-tools { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.step-body { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.step-body input, .step-body textarea { background: var(--surface); }
.step-body .title-in { font-weight: 600; }
.step-body details summary { cursor: pointer; color: var(--muted); font-size: .82em; }
.step-body details input { margin-top: 6px; }
.step .drop { min-height: 100%; font-size: .8em; padding: 8px; background: var(--surface); }
.step .drop.filled img { max-height: 150px; height: 100%; object-fit: cover; }
.add-step { width: 100%; }
.ai-draft { background: linear-gradient(135deg, var(--accent-soft), var(--surface) 65%); }
.ai-draft .row > input { flex: 3; }
.ai-draft .row > select { flex: 0 0 70px; min-width: 70px; }
.ai-draft .row > .btn { flex: 0 0 auto; min-width: 0; }

/* ---------------------------------------------------------------- clips */
.clip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; max-height: 460px; overflow-y: auto; padding: 2px; }
.clip { text-align: left; background: var(--surface-2); border: 1.5px solid var(--border); border-radius: 12px; padding: 12px; cursor: pointer; }
.clip.on { border-color: var(--accent); background: var(--accent-soft); }
.clip b { font-size: .85em; display: block; }
.clip span { color: var(--muted); font-size: .8em; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; margin-top: 3px; }

/* ---------------------------------------------------------------- library */
.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.filters button { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 6px 14px; cursor: pointer; color: var(--muted); font-weight: 500; }
.filters button.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.media { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.media video { width: 100%; aspect-ratio: 16 / 10; background: #000; display: block; object-fit: contain; }
.media .meta { padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.media .meta b { font-size: .9em; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.media .sub { display: flex; gap: 8px; align-items: center; color: var(--muted); font-size: .8em; flex-wrap: wrap; }
.media .acts { display: flex; gap: 8px; margin-top: auto; padding-top: 4px; }
.media .acts a { font-size: .82em; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.badge { display: inline-block; font-size: .72em; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-text); text-transform: capitalize; }
.empty { color: var(--muted); text-align: center; padding: 40px 10px; }

/* ---------------------------------------------------------------- models page */
.model-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.model-cols + .card { margin-bottom: 16px; }
.mrow { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.mrow:first-child { border-top: none; padding-top: 0; }
.mrow b { font-size: .95em; }
.mrow .p { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent-text); text-align: right; }
.mrow span { grid-column: 1 / -1; color: var(--muted); font-size: .85em; }
.cost-table, .ledger { display: grid; gap: 0; font-size: .9em; }
.cost-table div, .ledger div { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 9px 0; border-top: 1px solid var(--border); }
.cost-table div:first-child, .ledger div:first-child { border-top: none; }
.cost-table b, .ledger b { font-variant-numeric: tabular-nums; }
.ledger span small { color: var(--muted); display: block; font-size: .85em; }

/* ---------------------------------------------------------------- signed-in user */
.me { display: flex; align-items: center; gap: 8px; padding: 8px 6px 0; border-top: 1px solid var(--border); }
.avatar-dot { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; font-size: .85em; flex: none; text-transform: uppercase; }
.me-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; flex: 1; }
.me-text b { font-size: .88em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-text span { color: var(--muted); font-size: .75em; }
body:not(.is-admin) .admin-only { display: none !important; }

/* team list */
.users { display: grid; margin-bottom: 14px; }
.user-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.user-row:first-child { border-top: none; }
.user-row .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-row .who b { font-size: .92em; }
.user-row .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.user-row .acts button { font-size: .8em; padding: 6px 10px; }
.user-row.off { opacity: .55; }
.add-user > input { flex: 2; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.add-user > .toggle { flex: 0 0 auto; min-width: 0; }
.add-user > .btn { flex: 0 0 auto; min-width: 0; }
input[type=color] { width: 100%; height: 42px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); padding: 4px; cursor: pointer; }
#page-settings .row > input { flex: 2; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
#page-settings .row > .btn { flex: 0 0 auto; min-width: 0; }
.modal-box input { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 16px; }

/* ---------------------------------------------------------------- connections */
.conn { padding: 14px 0; border-top: 1px solid var(--border); }
.conn:first-of-type { border-top: none; padding-top: 0; }
.conn-head { display: flex; align-items: center; gap: 10px; }
.conn .hint { margin: 4px 0 10px; display: block; }
.conn .row > input { flex: 3; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; }
.conn .row > .btn { flex: 0 0 auto; min-width: 0; }

/* voice extras (ElevenLabs) */
.voice { flex-wrap: wrap; }
.voice-extra { flex-basis: 100%; display: grid; gap: 10px; margin-top: 4px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.voice-extra .seg { background: var(--surface); }
.voice-extra .lbl { font-size: .8em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
.voice-extra .chips { margin-top: 0; }
.voice-extra .chips button { background: var(--surface); }

/* ---------------------------------------------------------------- activity drawer */
.activity-btn { position: fixed; right: 22px; bottom: 22px; z-index: 30; display: flex; align-items: center; gap: 8px; background: var(--text); color: var(--bg);
  border: none; border-radius: 99px; padding: 11px 18px; font-weight: 600; cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); }
.activity-btn .count { background: var(--accent); color: #fff; border-radius: 99px; min-width: 22px; height: 22px; display: grid; place-items: center; font-size: .8em; padding: 0 6px; }
.activity-btn.live i { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100%); background: var(--surface); border-left: 1px solid var(--border);
  z-index: 40; transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; box-shadow: -20px 0 40px rgba(0, 0, 0, .2); }
.drawer.open { transform: none; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.drawer-body { overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; flex: 1; }
.job { border: 1px solid var(--border); border-radius: 12px; padding: 14px; background: var(--surface-2); }
.job-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.job-top b { font-size: .92em; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.job .sub { color: var(--muted); font-size: .8em; margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.status { font-size: .74em; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.status.queued { background: var(--border); color: var(--muted); }
.status.running { background: var(--warn-soft); color: var(--warn); }
.status.running::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1s infinite; }
.status.done { background: var(--accent-soft); color: var(--accent-text); }
.status.failed { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger); }
.job .bar { height: 3px; border-radius: 99px; background: var(--border); margin: 10px 0 8px; overflow: hidden; }
.job .bar i { display: block; height: 100%; width: 35%; background: var(--warn); animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(300%); } }
.job pre { margin: 8px 0 0; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; word-break: break-word; color: var(--muted);
  background: var(--surface); border-radius: 8px; padding: 8px 10px; max-height: 220px; overflow-y: auto; }
.job video { width: 100%; max-height: 300px; background: #000; border-radius: 8px; margin-top: 10px; display: block; }
.job .acts { display: flex; gap: 12px; margin-top: 8px; font-size: .85em; }
.job .acts a, .job .acts button { font-weight: 600; text-decoration: none; background: none; border: none; color: var(--accent-text); cursor: pointer; padding: 0; }

/* modal & toasts */
.modal { position: fixed; inset: 0; z-index: 60; background: rgba(5, 8, 12, .55); display: grid; place-items: center; padding: 16px; backdrop-filter: blur(3px); }
.modal-box { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 22px; width: min(420px, 100%); box-shadow: var(--shadow); }
.modal-box h3 { margin: 0 0 8px; }
.modal-box p { color: var(--muted); margin: 0 0 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
.toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { pointer-events: auto; background: var(--text); color: var(--bg); padding: 11px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); display: flex; gap: 14px; align-items: center; font-weight: 500; animation: rise .25s ease; max-width: min(520px, calc(100vw - 32px)); }
.toast.err { background: var(--danger); color: #fff; }
.toast button { background: none; border: none; color: var(--accent); font-weight: 700; cursor: pointer; padding: 0; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

.keywarn { display: flex; gap: 12px; align-items: flex-start; background: var(--warn-soft); color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; }
.keywarn div { color: var(--text); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr; }
  .summary { position: static; display: grid; grid-template-columns: 200px 1fr; }
  .model-cols { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 20; height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 16px; border-right: none; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .brand-text, .nav-label, .budget, .me-text { display: none; }
  .me { border-top: none; padding: 0; }
  .nav { flex-direction: row; gap: 4px; }
  .nav a { white-space: nowrap; padding: 8px 10px; font-size: .88em; }
  .main { padding: 20px 16px 110px; }
  .summary { grid-template-columns: 1fr; }
  .step { grid-template-columns: 30px 1fr; }
  .step .drop { grid-column: 2; min-height: 80px; }
}

/* delete button in the library */
.media .acts .del { margin-left: auto; background: none; border: none; color: var(--muted); font: inherit; font-size: .82em; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 0; }
.media .acts .del:hover { color: var(--danger); }
.media .acts .del i[data-icon] { width: 15px; height: 15px; }
#modal-yes.danger { background: var(--danger); }

/* failure and warning boxes in Activity */
.job-error, .job-warn { border-radius: 10px; padding: 12px 14px; margin-top: 10px; font-size: .86em; line-height: 1.45; }
.job-error { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--danger) 35%, transparent); }
.job-error > b { display: flex; align-items: center; gap: 6px; color: var(--danger); font-size: 1.02em; }
.job-error > b i[data-icon] { width: 16px; height: 16px; }
.job-error p { margin: 6px 0; color: var(--text); }
.job-error ul { margin: 6px 0 8px; padding-left: 18px; color: var(--text); }
.job-error li { margin: 3px 0; }
.job-error small { color: var(--muted); }
.job-error.cat-busy, .job-error.cat-billing, .job-error.cat-key { background: var(--warn-soft); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.job-error.cat-busy > b, .job-error.cat-billing > b, .job-error.cat-key > b { color: var(--warn); }
.job-warn { background: var(--warn-soft); border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent); }
.job-warn b { color: var(--warn); }
.job-warn p { margin: 4px 0 0; color: var(--text); }

/* sign-in, set-password and reset pages */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); }
.login-card .logo { margin-bottom: 14px; }
.login-card h1 { font-size: 1.4rem; margin: 0 0 4px; letter-spacing: -.01em; }
.login-card > p { color: var(--muted); margin: 0 0 20px; font-size: .92em; }
.login-card input { width: 100%; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 11px 12px; }
.login-card input:focus { outline: none; border-color: var(--accent); }
.login-card input[readonly] { color: var(--muted); }
.login-card .err { color: var(--danger); font-size: .88em; min-height: 1.3em; margin: 4px 0 10px; }
.login-card .ok-msg { color: var(--accent-text); font-size: .9em; margin: 4px 0 10px; }
.link-btn { display: block; margin: 14px auto 0; background: none; border: none; color: var(--accent-text); font: inherit; font-size: .9em; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; }
.link-btn:hover { text-decoration: underline; }

/* show / hide password */
.pw-wrap { position: relative; display: block; }
.pw-wrap input { padding-right: 44px !important; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px; border: none; background: none; color: var(--muted); cursor: pointer; border-radius: 8px; display: grid; place-items: center; padding: 0; }
.pw-eye:hover { color: var(--text); background: var(--surface); }
.pw-eye svg { width: 18px; height: 18px; }

/* settings: email */
.mail-mode { margin-bottom: 14px; }
.user-row .who .em { color: var(--muted); font-size: .82em; }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.conn-head .conn-remove { margin: 0 0 0 auto; display: inline; font-size: .82em; color: var(--muted); }
.conn-head .conn-remove:hover { color: var(--danger); }
