:root {
  --bg: #F4F5F7;
  --panel: #FFFFFF;
  --ink: #111827;
  --muted: #4B5563;
  --line: #E5E7EB;
  --line-2: #D1D5DB;
  --accent: #2F5BEA;
  --accent-ink: #1E3FB0;
  --warn: #F59E0B;
  --ok-bg: #D1FAE5;
  --ok-ink: #065F46;
  --err-bg: #FEE2E2;
  --err-ink: #991B1B;
  --radius: 14px;
  --head: 'Space Grotesk', Inter, system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
h1, h2, h3 { font-family: var(--head); margin: 0; line-height: 1.2; }
h1 { font-size: 30px; }
h2 { font-size: 20px; font-weight: 600; }
code { background: #F3F4F6; padding: 1px 6px; border-radius: 4px; font-size: 13px; }
.muted { color: var(--muted); margin: 0; }
.small { font-size: 13px; }
.skip { position: absolute; left: -999px; top: 8px; background: #fff; padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
:focus-visible { outline: 3px solid #93C5FD; outline-offset: 2px; }

/* Shell */
.shell { min-height: 100vh; display: flex; flex-wrap: wrap; }
.side { flex: 1 1 232px; max-width: 100%; background: var(--ink); color: #E5E7EB; padding: 24px 16px; display: flex; flex-direction: column; gap: 28px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-family: var(--head); font-size: 17px; color: #fff; }
.brand small { font-size: 12px; color: #9CA3AF; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 8px; color: #D1D5DB; text-decoration: none; font-size: 14px; min-height: 44px; }
.nav a:hover { background: #1F2937; color: #fff; }
.nav a.is-active { background: #1F2937; color: #fff; font-weight: 600; }
.plan-card { margin-top: auto; background: #1F2937; border-radius: 12px; padding: 16px; display: flex; flex-direction: column; gap: 10px; font-size: 13px; color: #D1D5DB; }
.plan-card strong { font-size: 15px; color: #fff; }
.eyebrow { font-size: 12px; color: #9CA3AF; letter-spacing: .04em; text-transform: uppercase; }
.plan-card .linklike { color: #9CA3AF; }
.main { flex: 999 1 560px; min-width: 0; padding: 32px 40px 56px; display: flex; flex-direction: column; gap: 24px; }
@media (max-width: 700px) { .main { padding: 20px 16px 40px; } .side { gap: 16px; } .plan-card { margin-top: 0; } }

/* Common pieces */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
.page-head p { margin-top: 4px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.card-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; }
.split { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.grow-2 { flex: 2 1 520px; min-width: 0; }
.grow-1 { flex: 1 1 300px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row-end { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #374151; }
.field small { font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  font: inherit; font-size: 15px; color: var(--ink); background: #FAFAFB; border: 1px solid var(--line-2); border-radius: 10px; padding: 0 14px; min-height: 46px; width: 100%;
}
textarea { padding: 12px 14px; min-height: 120px; resize: vertical; line-height: 1.45; }
input::placeholder, textarea::placeholder { color: #6B7280; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 44px; }
.check input { width: 20px; height: 20px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; color: var(--ink); font: inherit; font-size: 14px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #F9FAFB; color: var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-ink); color: #fff; }
.btn-outline { border-color: var(--accent); color: var(--accent); }
.btn-warn { background: var(--warn); border-color: var(--warn); color: var(--ink); font-weight: 700; }
.btn-warn:hover { background: #FBBF24; }
.btn-locked { border-style: dashed; background: #F9FAFB; color: #92400E; font-weight: 700; }
.btn-lg { min-height: 50px; padding: 0 24px; font-size: 15px; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 13px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; min-height: 32px; }
.linklike.danger { color: #B91C1C; }

.flash { padding: 12px 16px; border-radius: 10px; background: var(--ok-bg); color: var(--ok-ink); font-size: 14px; font-weight: 500; }
.flash-error { background: var(--err-bg); color: var(--err-ink); }
.chip { align-self: flex-start; display: inline-block; font-size: 12px; font-weight: 600; color: #374151; background: #E5E7EB; padding: 3px 9px; border-radius: 999px; }
.chip-ok { color: var(--ok-ink); background: var(--ok-bg); }
.badge-pro { font-size: 11px; font-weight: 700; color: #92400E; background: #FEF3C7; padding: 2px 6px; border-radius: 4px; }

/* Genre pills */
.pills { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pills legend { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 8px; padding: 0; }
.pill { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border: 1px solid var(--line-2); border-radius: 999px; background: #fff; font-size: 14px; cursor: pointer; color: var(--ink); text-decoration: none; }
.pill input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pill:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.pill:has(input:focus-visible) { outline: 3px solid #93C5FD; outline-offset: 2px; }
.pill-locked { border-style: dashed; background: #F9FAFB; color: #6B7280; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; }
.stat span, .stat small { font-size: 13px; color: var(--muted); }
.stat strong { font-family: var(--head); font-size: 30px; }

/* Video cards and thumbnails */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 18px; }
.video-grid-lg { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.video-card { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.video-card:hover .thumb { transform: translateY(-2px); }
.video-link { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.video-title { font-weight: 600; font-size: 14px; line-height: 1.35; }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.thumb { position: relative; aspect-ratio: 9 / 16; border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 14px 10px 0; transition: transform .15s; }
.thumb svg { width: 74%; display: block; }
.thumb-hook { font-family: var(--head); font-weight: 700; font-size: 15px; line-height: 1.2; text-align: center; color: #fff; text-shadow: 0 0 2px #000, 0 2px 0 #000, 0 -1px 0 #000, 1px 0 0 #000, -1px 0 0 #000; }

/* Idea list */
.idea-list { list-style: none; margin: 0; padding: 0; }
.idea-list li { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid #F0F1F3; }
.idea-list li:first-child { border-top: 0; }
.idea-list li > div { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.idea-list strong { font-size: 14px; }

/* Filter tabs */
.filter { display: flex; flex-wrap: wrap; gap: 8px; }
.filter a { padding: 8px 14px; border-radius: 999px; background: #fff; border: 1px solid var(--line); color: var(--ink); text-decoration: none; font-size: 14px; min-height: 40px; display: inline-flex; align-items: center; }
.filter a.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* Tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 12px 10px; border-top: 1px solid var(--line); vertical-align: top; }
.table thead th { border-top: 0; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tier-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tier { font: inherit; font-size: 12px; padding: 6px 10px; border-radius: 999px; border: 1px dashed var(--line-2); background: #fff; color: var(--muted); cursor: pointer; min-height: 32px; }
.tier-on { border-style: solid; border-color: var(--accent); background: #EEF2FF; color: var(--accent-ink); font-weight: 600; }

/* Guest pages */
.guest-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; padding: 24px 16px; }
.guest-brand { display: flex; align-items: center; gap: 10px; font-family: var(--head); font-size: 22px; }
.guest-card { width: 100%; max-width: 440px; }
.guest-card h1 { font-size: 26px; }
.error-card { max-width: 560px; }

/* Studio */
.studio-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.studio-head .title-input { flex: 1 1 320px; font-family: var(--head); font-size: 22px; font-weight: 600; background: transparent; border-color: transparent; padding: 0 8px; }
.studio-head .title-input:hover, .studio-head .title-input:focus { border-color: var(--line-2); background: #fff; }
.save-status { font-size: 13px; color: var(--muted); min-width: 90px; }
.studio { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.studio-script { flex: 3 1 560px; min-width: 0; }
.studio-stage { flex: 1 1 340px; min-width: 0; position: sticky; top: 16px; }
.stage-wrap { background: #0B0F1A; border-radius: 14px; padding: 12px; display: flex; justify-content: center; }
#stage { width: 100%; max-width: 330px; aspect-ratio: 9 / 16; height: auto; border-radius: 8px; background: #222; display: block; }
.stage-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stage-buttons .btn { width: 100%; }
.stage-buttons .wide { grid-column: 1 / -1; }
.status-box { font-size: 13px; color: var(--muted); min-height: 20px; }
progress { width: 100%; height: 8px; }
.lines { display: flex; flex-direction: column; gap: 10px; }
.line-row { display: grid; grid-template-columns: 28px repeat(3, minmax(0, 1fr)) auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.line-row .line-text { grid-column: 2 / -1; grid-row: 2; }
.line-row .line-tools { grid-column: 5; grid-row: 1; }
.line-row.is-current { border-color: var(--accent); box-shadow: 0 0 0 2px #C7D2FE; }
.line-row select, .line-row input { min-height: 44px; font-size: 14px; padding: 0 10px; }
.line-num { font-size: 12px; font-weight: 700; color: var(--muted); text-align: center; }
.line-tools { display: flex; gap: 4px; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 8px; background: #fff; cursor: pointer; color: var(--muted); }
.icon-btn:hover { color: var(--ink); background: #F9FAFB; }
@media (max-width: 640px) {
  .line-row { grid-template-columns: 28px 1fr 1fr 1fr; }
  .line-row .line-text { grid-column: 2 / -1; grid-row: 2; }
  .line-row .line-tools { grid-column: 2 / -1; grid-row: 3; justify-content: flex-end; }
}
.title-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.title-list li { display: flex; gap: 8px; align-items: center; }
.title-list input { flex: 1 1 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.hint { background: #EEF2FF; color: #1E3A8A; border-radius: 10px; padding: 12px 14px; font-size: 13px; }

/* Cast panel and sound settings */
.cast-list { display: flex; flex-direction: column; gap: 10px; }
.cast-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; }
.cast-row strong { flex: 0 0 96px; }
.cast-row select { flex: 1 1 150px; width: auto; }
.cast-row strong { font-size: 14px; }
.cast-row input[type=color] { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; cursor: pointer; }
.cast-row select { min-height: 44px; font-size: 13px; padding: 0 8px; }
.sound-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.sound-box legend { font-size: 13px; font-weight: 600; color: #374151; padding: 0 4px; }
.sound-box input[type=range] { width: 100%; min-height: 32px; }

/* Batch render queue */
.queue-bar { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-color: #C7D2FE; background: #EEF2FF; }
.queue-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Wide 16:9 preview */
#stage.wide { aspect-ratio: 16 / 9; max-width: 100%; }
.studio.is-wide .studio-stage { flex: 2 1 520px; }
.studio.is-wide .studio-script { flex: 3 1 480px; }

/* Script rows adapt to the width of the script column, not the window */
.lines { container-type: inline-size; }
@container (max-width: 620px) {
  .line-row { grid-template-columns: 28px repeat(3, minmax(0, 1fr)); }
  .line-row .line-text { grid-column: 2 / -1; grid-row: 2; }
  .line-row .line-tools { grid-column: 2 / -1; grid-row: 3; justify-content: flex-end; }
}

.cast-row .voice-select { flex: 2 1 220px; }

/* Thumbnail designer */
.thumb-designer { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.thumb-preview { flex: 1 1 220px; max-width: 300px; }
.studio.is-wide .thumb-preview { max-width: 460px; flex-basis: 320px; }
#thumb-canvas { width: 100%; height: auto; border-radius: 10px; background: #111827; display: block; box-shadow: 0 10px 24px rgba(17,24,39,0.18); }
.thumb-controls { flex: 1 1 260px; min-width: 0; }
.thumb-row { display: flex; flex-wrap: wrap; gap: 12px; }
.thumb-row .field { flex: 1 1 140px; }

/* Channels */
.channel-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.channel-list li { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.channel-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; flex: 1 1 420px; }
.channel-form .field { flex: 1 1 220px; }

.trend-card { border-color: #FDE68A; background: linear-gradient(180deg, #FFFBEB, #FFFFFF 60%); }

/* Script library */
.library-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.library-card { display: flex; gap: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.library-card .thumb { flex: 0 0 86px; width: 86px; padding: 8px 6px 0; }
.library-card .thumb-hook { font-size: 9px; }
.library-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; align-items: flex-start; }
.library-body strong { font-size: 15px; line-height: 1.3; }

.pack-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 8px 10px; border: 1px dashed #FDE68A; border-radius: 12px; background: #FFFBEB; }
.pack-row select { flex: 1 1 240px; min-height: 44px; }

/* Admin */
.admin-tabs { margin: -4px 0 0; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 24px; align-items: start; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px 20px; }
.form-grid .field small { font-size: 12px; }
.chip-bad { color: var(--err-ink); background: var(--err-bg); }
.card-danger { border-color: #FCA5A5; }
.btn-danger { background: #B91C1C; border-color: #B91C1C; color: #fff; font-weight: 600; }
.btn-danger:hover { background: #991B1B; color: #fff; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.inline-form .check { min-height: 32px; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.field-legend { font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; padding: 0; }
.check-box { border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: #fff; }
.narrow { max-width: 640px; }
.setup-steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 12px; }
.copy-row { margin: 6px 0; }
.copy-row code, code.secret { font-size: 14px; user-select: all; }
.stat strong.stat-sm { font-size: 20px; }
.table th[scope="row"] { font-weight: 600; }
details summary { cursor: pointer; min-height: 32px; }
/* forms that sit directly in a card keep their natural height */
.card > .channel-form, .card > form > .channel-form { flex: 0 0 auto; }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; }
.product-table input { width: 100%; min-width: 140px; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line-2); border-radius: 8px; font: inherit; }
.product-table .input-price { min-width: 80px; max-width: 100px; }
.copy-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Upgrades in the sidebar */
.nav-title { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #9CA3AF; padding: 0 12px 4px; }
.nav-upgrades a.is-locked { color: #9CA3AF; }
.nav-upgrades a.is-locked:hover { color: #fff; }
.nav a .lock { margin-left: auto; color: #F59E0B; flex: none; }
dialog.upsell { border: 0; border-radius: 18px; padding: 28px; max-width: 520px; width: calc(100% - 32px); box-shadow: 0 30px 80px rgba(17,24,39,.35); color: var(--ink); }
dialog.upsell::backdrop { background: rgba(17,24,39,.6); }
dialog.upsell h2 { font-size: 24px; margin: 6px 0 8px; }
dialog.upsell .eyebrow { color: #B45309; font-weight: 700; font-size: 13px; }
.upsell-close { position: absolute; top: 12px; right: 12px; }
.upsell-close .icon-btn { font-size: 24px; line-height: 1; width: 40px; height: 40px; border-radius: 10px; border: 0; background: #F3F4F6; cursor: pointer; }
.upsell-list { margin: 16px 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.upsell-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 12px; }

/* Studio: the script does not follow the idea */
.idea-banner { border: 1px solid #FCD34D; background: #FFFBEB; border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.idea-banner strong { color: #92400E; }
.idea-banner p { margin: 0; color: #78350F; }
.idea-steps { margin: 0; padding-left: 20px; color: #78350F; display: flex; flex-direction: column; gap: 2px; }
.idea-banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.idea-banner[hidden] { display: none; }
.voice-hint { margin: -6px 0 0; min-height: 18px; }
/* Idea vault */
.teaser-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.teaser-list li { background: #fff; border: 1px dashed #FCD34D; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.locked-ideas summary { cursor: pointer; min-height: 32px; }
.locked-ideas[open] summary { margin-bottom: 12px; }
