:root {
  --bg: #f6f6f3; --panel: #fff; --ink: #1d1d1f; --muted: #6b6b70; --line: #e4e3de; --accent: #4f46e5; --accent-ink: #fff;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --chip: #efeee9;
  --st-idea: #a1a1aa; --st-generating: #8b5cf6; --st-pending_approval: #f59e0b; --st-scheduled: #3b82f6;
  --st-publishing: #06b6d4; --st-published: #16a34a; --st-failed: #dc2626; --st-rejected: #71717a;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121214; --panel: #1c1c1f; --ink: #ececee; --muted: #9b9ba3; --line: #2c2c31; --chip: #26262b; --accent: #818cf8; --accent-ink: #0b0b10; color-scheme: dark; }
}
* { box-sizing: border-box; }
/* Rules like .modal { display: flex } would otherwise beat the browser's own [hidden] { display: none }. */
[hidden] { display: none !important; }
body { margin: 0; font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji"; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.top { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; letter-spacing: -0.01em; }
.status { display: flex; gap: 6px; flex-wrap: wrap; flex: 1; }
.pill { padding: 2px 9px; border-radius: 999px; background: var(--chip); font-size: 12px; white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.pill.bad { background: color-mix(in srgb, var(--bad) 18%, transparent); color: var(--bad); }
.top-actions { display: flex; gap: 8px; }

.tabs { display: flex; gap: 2px; padding: 0 20px; background: var(--panel); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.view { padding: 20px; max-width: 1400px; margin: 0 auto; }
.banner { padding: 10px 20px; background: color-mix(in srgb, var(--warn) 16%, var(--panel)); color: var(--ink); border-bottom: 1px solid var(--line); }

.btn { border: 1px solid var(--line); background: var(--panel); padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--bad); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.tile b { display: block; font-size: 22px; font-variant-numeric: tabular-nums; }
.empty { padding: 40px; text-align: center; color: var(--muted); }
.error-box { background: color-mix(in srgb, var(--bad) 10%, transparent); color: var(--bad); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin: 8px 0; overflow-wrap: anywhere; }

/* Status dots and badges */
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--chip); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--dot, var(--muted)); }
[data-status="idea"] { --dot: var(--st-idea); } [data-status="generating"] { --dot: var(--st-generating); }
[data-status="pending_approval"] { --dot: var(--st-pending_approval); } [data-status="scheduled"] { --dot: var(--st-scheduled); }
[data-status="publishing"] { --dot: var(--st-publishing); } [data-status="published"] { --dot: var(--st-published); }
[data-status="failed"] { --dot: var(--st-failed); } [data-status="rejected"] { --dot: var(--st-rejected); }

/* Schedule timeline */
.timeline { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.tl-inner { position: relative; }
.tl-head, .tl-lane { display: flex; }
.tl-label { position: sticky; left: 0; z-index: 2; width: 160px; flex: none; padding: 10px 12px; background: var(--panel); border-right: 1px solid var(--line); }
.tl-track { position: relative; flex: none; border-bottom: 1px solid var(--line); }
.tl-head .tl-track { height: 30px; }
.tl-lane .tl-track { height: 106px; }
/* A paused account's lane: greyed and striped, labelled, so its overdue reels read as waiting, not stuck. */
.tl-lane.paused .tl-track { background: repeating-linear-gradient(135deg, transparent 0 10px, color-mix(in srgb, var(--muted) 10%, transparent) 10px 20px); }
.tl-lane.paused .frame, .tl-lane.paused .frame-time { opacity: .5; filter: grayscale(.7); }
.tl-lane.paused .tl-label { background: color-mix(in srgb, var(--muted) 8%, var(--panel)); }
.tl-paused-row { display: flex; align-items: center; gap: 8px; margin: 2px 0; }
.tl-paused-row .link-btn { margin: 0; font-size: 12px; }
.tl-paused-tag { position: absolute; left: 8px; bottom: 6px; padding: 2px 8px; border-radius: 99px; font-size: 12px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); z-index: 1; }
/* The posting time under each reel's box, so times read at a glance. */
.frame-time { position: absolute; top: 82px; transform: translateX(-50%); z-index: 1; padding: 0 3px; border-radius: 3px; background: var(--panel); font-size: 11px; font-variant-numeric: tabular-nums; color: var(--muted); white-space: nowrap; pointer-events: none; }
/* Small platform glyphs (account rows, analytics). */
.pf-row { display: flex; gap: 6px; margin-top: 6px; }
.pf-icon { display: inline-flex; width: 16px; height: 16px; vertical-align: -3px; }
.pf-icon svg { width: 100%; height: 100%; }
.tl-day { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--line); padding: 6px 8px; font-size: 12px; color: var(--muted); }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--bad); z-index: 1; }
.frame { position: absolute; top: 10px; width: 38px; height: 68px; padding: 0; border-radius: 6px; background: var(--dot); border: 3px solid var(--dot); cursor: pointer; transform: translateX(-19px); overflow: hidden; }
.frame:hover { outline: 2px solid var(--ink); z-index: 2; }
/* With a cover: the image fills the box, the status shows as the border plus a dot in the corner. */
.frame.has-cover { background: #000; }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame-dot { position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 50%; background: var(--dot); box-shadow: 0 0 0 1.5px #fff; }
.frame:not(.has-cover) .frame-dot { display: none; }
.legend { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }

/* Review cards */
.reel { display: grid; grid-template-columns: 170px 1fr; gap: 14px; }
.reel video, .reel .novideo { width: 170px; aspect-ratio: 9 / 16; border-radius: 10px; background: #000; object-fit: cover; }
.reel .novideo { display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 12px; text-align: center; padding: 8px; }
.reel textarea, .reel input, .field input, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--bg); }
.reel textarea { min-height: 80px; resize: vertical; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.cover-row { display: flex; gap: 10px; align-items: flex-start; }
.cover-thumb { width: 64px; aspect-ratio: 9 / 16; object-fit: cover; border-radius: 6px; display: block; background: #000; }
.cover-thumb.empty { display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 10px; text-align: center; padding: 4px; }
.script { font-size: 13px; padding-left: 18px; margin: 6px 0; }
.script li { margin-bottom: 4px; }
@media (max-width: 560px) { .reel { grid-template-columns: 1fr; } .reel video, .reel .novideo { width: 100%; max-width: 260px; } }

/* Forms and suggestions */
.form { display: grid; gap: 14px; }
.field label, .field .label { display: block; font-weight: 600; margin-bottom: 4px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.two { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 640px) { .two { grid-template-columns: 1fr; } }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.chip { border: 1px dashed var(--line); background: var(--chip); padding: 3px 10px; border-radius: 999px; cursor: pointer; font-size: 12px; }
.chip:hover { border-color: var(--accent); }
.choices { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.choice { position: relative; border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; background: var(--bg); text-align: left; }
.choice.selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.choice b { display: block; margin-bottom: 2px; }
.choice .desc { font-size: 12px; color: var(--muted); }
.choice .play { margin-top: 6px; font-size: 12px; padding: 2px 8px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 400 !important; }
.check input { width: auto; }

/* Subtitle previews: frames rendered by the server in each style (empty until it can draw them) */
.sub-preview { aspect-ratio: 540 / 200; margin-bottom: 8px; border-radius: 8px; overflow: hidden; background: linear-gradient(135deg, #3b5d50, #8a6b4a); }
.sub-preview img { display: block; width: 100%; height: 100%; object-fit: cover; }

/* Admin → Models */
.cap-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 4px 0 12px; background: var(--bg); }
.cap-card p { margin: 8px 0; }
.meter { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 8px; }
.meter span { display: block; height: 100%; background: var(--accent); }
.meter.full span { background: #c0392b; }
.cap-form { align-items: center; gap: 10px; }
.money-input { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--ink); padding-left: 10px; }
.money-input input { border: 0; width: 90px; padding: 7px 8px; background: transparent; }
.money-input input:focus { outline: none; }

.model-jobs { display: grid; gap: 14px; }
.model-job h3 { margin: 0; }
.model-job .btn.ghost { padding: 2px 8px; }
.nowrap { white-space: nowrap; }

/* Tables and charts */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.chart { width: 100%; height: 180px; }
.chart rect { fill: var(--accent); }
.chart text { fill: var(--muted); font-size: 10px; }
.learnings { white-space: pre-wrap; font-size: 13px; }
.log-row td:first-child { white-space: nowrap; color: var(--muted); }
.lvl-error { color: var(--bad); } .lvl-warn { color: var(--warn); }

/* Modal and toasts */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal-card { position: relative; background: var(--panel); border-radius: 14px; padding: 22px; width: min(760px, 100%); }
.modal-card.wide { width: min(1120px, 100%); }

/* Account form: a section menu on the left, one section at a time on the right, actions pinned below. */
.acct-form { display: grid; grid-template-columns: 180px 1fr; grid-template-rows: 1fr auto; gap: 0 22px; }
.acct-nav { display: flex; flex-direction: column; gap: 2px; border-right: 1px solid var(--line); padding-right: 12px; }
.acct-nav button { text-align: left; border: 0; background: none; padding: 9px 12px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.acct-nav button.active { background: var(--chip); color: var(--ink); font-weight: 600; }
.acct-body { min-height: 60vh; max-height: 70vh; overflow-y: auto; padding-right: 6px; }
.acct-body h3 { font-size: 16px; margin-bottom: 4px; }
.acct-actions { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.platform { border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.platform-head { display: flex; align-items: baseline; gap: 10px; }
.platform-head b { font-size: 15px; }
.link-btn { margin-left: auto; border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font-size: 13px; text-decoration: underline; }
@media (max-width: 760px) {
  .acct-form { grid-template-columns: 1fr; }
  .acct-nav { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0 0 8px; margin-bottom: 12px; }
  .acct-body { max-height: none; }
}

/* Setup guide: a side panel above everything, so a half-filled form underneath stays as it is. */
.guide { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%); background: var(--panel); border-left: 1px solid var(--line); box-shadow: -10px 0 30px rgba(0,0,0,.25); z-index: 55; display: flex; flex-direction: column; }
.guide-head { display: flex; align-items: center; gap: 8px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.guide-head .modal-close { position: static; margin-left: auto; }
.guide-tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.guide-tabs button { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 12px; cursor: pointer; }
.guide-tabs button.active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.guide-body { padding: 18px 22px 28px; overflow-y: auto; line-height: 1.55; }
.guide-body h4 { margin: 18px 0 6px; }
.guide-body ol { padding-left: 20px; }
.guide-body li { margin-bottom: 6px; }
.guide-body code { background: var(--chip); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.modal-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.toasts { position: fixed; bottom: 16px; right: 16px; display: grid; gap: 8px; z-index: 60; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: 0 6px 20px rgba(0,0,0,.2); overflow-wrap: anywhere; }
.toast.bad { background: var(--bad); color: #fff; }
.confirm-bar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 8px 10px; border-radius: 8px; background: color-mix(in srgb, var(--bad) 10%, transparent); margin-top: 8px; font-size: 13px; }

/* Accounts and login */
.auth { max-width: 380px; margin: 40px auto; }
.auth .btn.primary { justify-self: start; }
.auth-links { margin-top: 12px; }
.auth-footer { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); }
.social-row { display: grid; gap: 8px; margin: 6px 0 4px; }
.btn.social { display: flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.or { display: flex; align-items: center; gap: 8px; margin: 10px 0; }
.or::before, .or::after { content: ''; flex: 1; border-top: 1px solid var(--line); }
.pill-btn { cursor: pointer; border: 0; font-size: 12px; font-family: inherit; color: inherit; }
.credits { display: grid; gap: 14px; }
.credits-title h2 { margin: 0; }
.credit-tiles { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); margin-bottom: 0; }
.credit-balance { font-size: 1.8rem; }
.credit-buy { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.credits h3 { margin-top: 0; }
.nowrap { white-space: nowrap; }
.credit-form { flex-basis: 100%; margin-top: 6px; }
.user-menu { position: relative; }
.user-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; display: grid; gap: 2px; padding: 6px; min-width: 180px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgb(0 0 0 / 0.12); }
.user-pop .btn { text-align: left; }
.notice { background: color-mix(in srgb, var(--warn) 14%, transparent); padding: 8px 10px; border-radius: 8px; font-size: 13px; margin-top: 8px; }
.choice:disabled { opacity: 0.55; cursor: not-allowed; }

/* Plan */
.plan-grid { align-items: start; }
.plan-list { padding-left: 18px; margin: 8px 0 14px; }
.checkout { margin-top: 14px; display: grid; gap: 6px; justify-items: start; }
tr.total td { border-top: 2px solid var(--line); }
.platform select { min-width: 220px; }

/* Avatar menu */
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; font-size: 15px; }
.avatar:hover, .avatar[aria-expanded="true"] { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.user-pop-email { padding: 6px 10px 8px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); margin-bottom: 4px; overflow-wrap: anywhere; }

/* Assistant */
.chat { max-width: 760px; margin: 0 auto; display: grid; gap: 12px; }
.chat-log { display: grid; gap: 10px; max-height: calc(100vh - 300px); overflow-y: auto; padding: 4px; }
.msg { display: flex; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: 80%; padding: 9px 13px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); line-height: 1.45; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chat-input { display: grid; gap: 8px; }
.chat-input textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--panel); resize: vertical; }
.draft { border-color: var(--accent); }

/* Assistant: chats on the left, the open chat on the right */
.chat-app { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.chat-side { position: sticky; top: 12px; display: grid; gap: 8px; }
.chat-list { display: grid; gap: 2px; max-height: calc(100vh - 220px); overflow-y: auto; }
.chat-item { display: flex; align-items: center; gap: 6px; padding: 7px 9px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.chat-item:hover { background: var(--chip); color: var(--ink); }
.chat-item.active { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.chat-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.chat-actions { display: none; gap: 6px; }
.chat-item:hover .chat-actions, .chat-item.active .chat-actions { display: inline-flex; }
.chat-actions .link-btn { margin: 0; text-decoration: none; }
.chat-rename { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; background: var(--panel); }
.chat-app .chat { max-width: none; margin: 0; }
.card-lines { margin: 6px 0 0; padding-left: 18px; font-size: 13px; }
.lvl-ok { color: var(--ok); }
.remake { margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line); }
@media (max-width: 760px) { .chat-app { grid-template-columns: 1fr; } .chat-side { position: static; } }

/* Things that need the user: counters, filters, the Review tab and timeline reels */
.tile-link { text-align: left; font: inherit; color: inherit; cursor: pointer; }
.tile-link:hover { border-color: var(--muted); }
.tile.action { border-color: var(--warn); box-shadow: 0 0 0 1px var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }
.action-tag { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 10px; font-weight: 600; letter-spacing: 0.02em; }
.btn .count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: 999px; background: var(--chip); color: var(--ink); font-size: 11px; text-align: center; }
.btn.primary .count { background: color-mix(in srgb, #fff 25%, transparent); color: inherit; }
.btn.action:not(.primary) { border-color: var(--warn); color: var(--warn); }
.btn.action .count { background: var(--warn); color: #fff; }
.tab-count { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 999px; background: var(--warn); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
.frame.needs-action { box-shadow: 0 0 0 2px var(--panel), 0 0 0 4px var(--warn); }
.frame-alert { position: absolute; left: 3px; top: 2px; width: 13px; height: 13px; border-radius: 50%; background: var(--warn); color: #fff; font-size: 10px; font-weight: 800; line-height: 13px; text-align: center; }
.badge.needs-legend { --dot: var(--warn); box-shadow: inset 0 0 0 1.5px var(--warn); }
.tl-day.today { color: var(--ink); font-weight: 600; }
/* Without a cover: a dark shade of the status colour, a film mark, and the same corner dot as covered reels. */
.frame:not(.has-cover) { background: linear-gradient(160deg, color-mix(in srgb, var(--dot) 45%, #0b0b0f), color-mix(in srgb, var(--dot) 18%, #0b0b0f)); }
.frame:not(.has-cover) .frame-dot { display: block; }
.frame-icon { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: color-mix(in srgb, var(--dot) 70%, #fff); opacity: 0.75; }
.frame-icon svg { width: 18px; height: 18px; }

/* Review: cards never overlap; on narrow screens the video sits above the text */
.reel-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(520px, 100%), 1fr)); }
.reel > div { min-width: 0; }
.reel .row { flex-wrap: wrap; }
@media (max-width: 900px) { .reel { grid-template-columns: 1fr; } .reel video, .reel .novideo { width: 100%; max-width: 280px; justify-self: center; } }
.banner.bad { background: color-mix(in srgb, var(--bad) 16%, var(--panel)); }
.banner.bad div + div { margin-top: 4px; }

/* Reel: what goes out on top, actions at the bottom */
.reel { display: grid; grid-template-columns: 1fr; gap: 12px; }
.reel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.reel-main { display: grid; grid-template-columns: 220px 1fr; gap: 18px; align-items: start; }
.reel-main video, .reel-main .novideo { width: 220px; aspect-ratio: 9 / 16; border-radius: 10px; background: #000; object-fit: cover; }
.reel-details { display: grid; gap: 10px; min-width: 0; }
.reel-field .label, .quick .label { display: block; font-weight: 600; font-size: 12px; margin-bottom: 3px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.reel-field p { margin: 0; }
.quick { display: grid; gap: 8px; }
.quick input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--bg); }
.reel-script { border-top: 1px solid var(--line); padding-top: 8px; }
.reel-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 12px; border-top: 1px solid var(--line); }
.reel-actions .spacer { flex: 1; }
.modal-card.reel-modal { width: min(1040px, 96vw); max-width: min(1040px, 96vw); }
.modal-card.reel-modal .reel { border: 0; padding: 0; background: none; }
.modal-card.reel-modal .reel-main { grid-template-columns: 280px 1fr; }
.modal-card.reel-modal .reel-main video, .modal-card.reel-modal .reel-main .novideo { width: 280px; }
@media (max-width: 900px) {
  .reel-main, .modal-card.reel-modal .reel-main { grid-template-columns: 1fr; }
  .reel-main video, .reel-main .novideo, .modal-card.reel-modal .reel-main video, .modal-card.reel-modal .reel-main .novideo { width: 100%; max-width: 280px; justify-self: center; }
}

/* Assistant: the message box stays at the bottom; only the messages scroll. --chat-h is the space left below the
   header and any banners (set by fitChat in app.js), so Send never needs a scroll to reach. */
.chat-app .chat { display: flex; flex-direction: column; height: var(--chat-h, calc(100vh - 210px)); min-height: 320px; gap: 10px; }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; }
.chat-compose textarea { flex: 1; min-width: 0; }
.chat-compose .btn { flex: none; height: 42px; }
.chat-app .chat-log { flex: 1; max-height: none; min-height: 0; }
.chat-app .chat-input { flex: none; }
.chat-hello { text-align: center; padding: 18px 0 4px; }
.chat-hello h2 { font-size: 26px; margin: 0 0 4px; }
[data-rotate] { display: inline-block; transition: opacity 0.15s; }
[data-rotate].fade { opacity: 0; }
/* Rename and delete appear on hover only, as small icons */
.chat-actions { display: inline-flex; gap: 2px; opacity: 0; transition: opacity 0.12s; }
.chat-item:hover .chat-actions, .chat-item:focus-within .chat-actions { opacity: 1; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); cursor: pointer; padding: 0; }
.icon-btn svg { width: 15px; height: 15px; }
.icon-btn:hover { background: var(--chip); color: var(--ink); }
.icon-btn.danger:hover { color: var(--bad); }
/* The reel a chat is about */
.chat-reel { display: flex; gap: 12px; align-items: flex-start; max-width: 560px; }
.chat-reel video, .chat-reel .novideo { width: 150px; aspect-ratio: 9 / 16; border-radius: 10px; background: #000; object-fit: cover; flex: none; }
.chat-reel .novideo { display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 12px; }
.chat-reel .cover-thumb { width: 70px; flex: none; }
.info { cursor: help; border-bottom: 1px dotted var(--muted); }
/* Messages stack at their natural height; only the log scrolls. */
.chat-app .chat-log { display: flex; flex-direction: column; gap: 10px; }
.chat-app .chat-log > * { flex: none; }
.modal-card.reel-modal .reel-head { padding-right: 34px; }

/* Every dropdown looks the same: bordered, padded, a custom arrow, a clear focus ring */
select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 30px 6px 10px; min-height: 32px;
  background-color: var(--bg); color: var(--ink); font: inherit; cursor: pointer; max-width: 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23888' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 11px 8px;
}
select:hover { border-color: var(--muted); }
select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
select:disabled { opacity: 0.55; cursor: not-allowed; }
select option { background: var(--panel); color: var(--ink); }

.icon-btn.big { width: 32px; height: 32px; border: 1px solid var(--line); }
.icon-btn.big svg { width: 17px; height: 17px; }
.icon-btn.spinning svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.plan-note { margin-bottom: 12px; }
/* A new account's reels in the chat */
.live-reels { display: grid; gap: 6px; margin: 8px 0; }
.live-reel { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; text-align: left; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--bg); color: inherit; font: inherit; cursor: pointer; }
.live-reel:hover { border-color: var(--muted); }
.live-reel img, .live-reel .live-ph { width: 34px; height: 60px; border-radius: 5px; object-fit: cover; display: flex; align-items: center; justify-content: center; }
.live-reel .live-ph { background: linear-gradient(160deg, color-mix(in srgb, var(--dot) 45%, #0b0b0f), color-mix(in srgb, var(--dot) 18%, #0b0b0f)); color: color-mix(in srgb, var(--dot) 70%, #fff); }
.live-reel .live-ph svg { width: 16px; height: 16px; }
.live-reel span b { display: block; }

.field select { width: 100%; }
.prices-doc ul { padding-left: 18px; margin: 6px 0 0; display: grid; gap: 6px; }
.price-field { display: grid; grid-template-columns: 240px 1fr; gap: 14px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
@media (max-width: 760px) { .price-field { grid-template-columns: 1fr; } }

/* Review: compact cards, 1 to 4 columns, never wider than the page. */
.review-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(max(200px, calc((100% - 3 * 14px) / 4)), 1fr)); }
.review-card { display: grid; grid-template-rows: auto 1fr; gap: 10px; padding: 10px; min-width: 0; }
.review-thumb { padding: 0; border: 0; background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 3 / 4; width: 100%; cursor: pointer; }
.review-thumb img, .review-thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.review-thumb .novideo { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: #aaa; font-size: 12px; }
.review-body { display: grid; gap: 4px; align-content: start; min-width: 0; }
.review-title { overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.review-error { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.stats-tiles { margin-bottom: 10px; }
.views-chart { width: 100%; height: auto; max-width: 560px; display: block; }

/* Characters */
.character-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); }
.character-card { display: grid; gap: 6px; align-content: start; min-width: 0; }
.character-photos { display: flex; gap: 6px; flex-wrap: wrap; }
.character-photo { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: var(--chip); }
.character-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-remove { position: absolute; top: 2px; right: 2px; border: 0; border-radius: 999px; width: 22px; height: 22px; background: rgb(0 0 0 / .6); color: #fff; cursor: pointer; line-height: 1; }
.add-photo { display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--muted); cursor: pointer; border: 1px dashed var(--line); }
.character-choice img { width: 48px; height: 48px; object-fit: cover; border-radius: 8px; display: block; margin-bottom: 4px; }
.price-tag { display: table; max-width: 100%; margin: 3px 0 4px; font-size: 11px; padding: 1px 7px; border-radius: 999px; background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); white-space: normal; }
.price-tag.paid { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }

/* The cost on the left, the form's buttons on the right (above them when there is no room). */
.acct-actions { align-items: center; }
.cost-summary { flex: 1 1 260px; min-width: 0; padding: 8px 12px; border-radius: 10px; background: var(--chip); }
.acct-buttons { margin-left: auto; flex-wrap: nowrap; }
.cost-summary:empty { display: none; }

/* Formatting in the Assistant's replies. */
.bubble ul, .bubble ol { margin: 4px 0; padding-left: 20px; }
.bubble code { font-family: ui-monospace, Menlo, monospace; font-size: .92em; padding: 0 4px; border-radius: 4px; background: rgb(127 127 127 / .15); }

/* Profile */
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-bottom: 14px; }
.profile-grid .panel, .profile-grid + .panel { margin: 0; }
.profile-grid + .panel { margin-bottom: 14px; }
.kv { display: flex; gap: 10px; align-items: baseline; margin: 4px 0; }
.kv > span:first-child { min-width: 52px; }
.pause-list { margin: 8px 0 0; padding-left: 20px; }

/* Account cards: a clear header with the ⋯ menu, the settings as a small grid, and the counts as stats. */
.acct-card { display: flex; flex-direction: column; gap: 10px; }
.acct-card.paused { border-style: dashed; }
.acct-head { display: flex; align-items: center; gap: 8px; }
.acct-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.acct-title b { font-size: 16px; }
.acct-title .pf-row { margin: 0; }
.acct-topic { margin: 0; color: var(--ink); }
.acct-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px 14px; }
.acct-fact { display: flex; flex-direction: column; font-size: 13px; min-width: 0; }
.acct-fact span { color: var(--muted); font-size: 12px; }
.acct-fact b { font-weight: 500; overflow-wrap: anywhere; }
.acct-stats { display: flex; gap: 8px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; }
.acct-stat { display: flex; align-items: baseline; gap: 4px; font-size: 13px; color: var(--muted); padding: 2px 8px; border-radius: 99px; background: var(--bg); }
.acct-stat b { color: var(--ink); }
.acct-stat.warn b { color: var(--warn); }
.acct-menu { position: relative; }
.menu-btn { font-size: 20px; line-height: 1; padding: 2px 10px; }
.acct-pop { position: absolute; right: 0; top: calc(100% + 4px); z-index: 20; min-width: 190px; display: grid; gap: 2px; padding: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); }
.acct-pop .btn { justify-content: flex-start; text-align: left; width: 100%; }
.acct-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
.danger-text { color: var(--bad); }
.confirm-body p { margin: 0 0 8px; }

/* Something needs an admin's attention: a count on the Admin tab and the System button (red: stopped, amber: covered) */
.tab-alert { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; font-size: 11px; font-weight: 700; color: #fff; background: var(--bad); vertical-align: 1px; }
.tab-alert.amber { background: var(--warn); color: #1d1d1f; }

/* Admin → System: what needs attention, then one line per service */
.system-page { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; align-items: start; }
.system-page > section:first-child { grid-column: 1 / -1; }
.system-page h3 { margin: 0 0 8px; }
.alert-card { border-left: 4px solid var(--bad); background: color-mix(in srgb, var(--bad) 8%, var(--panel)); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; }
.alert-card.amber { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn) 10%, var(--panel)); }
.alert-card p { margin: 6px 0; }
.all-good { color: var(--ok); font-weight: 600; }
.svc-row { display: flex; align-items: baseline; gap: 10px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 14px; }
.svc-row:first-of-type { border-top: 0; }
.svc-dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: var(--ok); transform: translateY(-1px); }
.svc-dot.amber { background: var(--warn); }
.svc-dot.red { background: var(--bad); }
.svc-dot.off { background: var(--line); }
.svc-name { flex: none; width: 170px; font-weight: 600; }
.svc-status { flex: 1; min-width: 0; color: var(--muted); overflow-wrap: anywhere; }
.svc-row .link-btn { margin: 0; }
.inline-details { display: inline; }
.inline-details summary { cursor: pointer; display: inline; }
.inline-details[open] > *:not(summary) { display: block; margin-top: 4px; }

/* The video window */
.modal-close { top: 14px; right: 14px; width: 32px; height: 32px; padding: 0; border-radius: 8px; display: grid; place-items: center; line-height: 1; }
.modal-close:hover, .modal-close:focus-visible { background: var(--chip); color: var(--ink); }
.modal-card.reel-modal .reel { gap: 18px; }
.modal-card.reel-modal .reel-head { padding-right: 44px; align-items: center; }
.reel .reel-details { gap: 14px; }
.reel .hint { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.4; }
.reel textarea, .reel input:not([type="checkbox"]):not([type="radio"]) {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--bg);
  font-size: 14px; line-height: 1.45; transition: border-color .15s, box-shadow .15s;
}
.reel textarea:hover, .reel input:not(:disabled):hover { border-color: var(--muted); }
.reel textarea:focus, .reel input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.reel input:disabled { opacity: .6; cursor: not-allowed; }
.reel textarea[data-field="caption"] { min-height: 96px; }
.cover-row { gap: 12px; }
.cover-row .cover-thumb { width: 72px; flex: none; }
.cover-field { flex: 1; min-width: 0; }
.cover-field .btn { justify-self: start; margin-top: 6px; }
.when-input { cursor: pointer; min-height: 38px; font-variant-numeric: tabular-nums; }
.when-input::-webkit-calendar-picker-indicator { cursor: pointer; opacity: .55; padding: 4px; border-radius: 6px; }
.when-input::-webkit-calendar-picker-indicator:hover { opacity: 1; background-color: var(--chip); }
.script li { margin-bottom: 12px; }
/* A block text box, so the scene number lines up with its first line rather than its bottom */
.script textarea { display: block; min-height: 60px; margin-bottom: 4px; }
.badge { white-space: nowrap; }

/* Video cards: the whole card opens the video; the status sits on the cover */
.review-card { cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; }
.review-card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.review-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.review-thumb { position: relative; }
.review-thumb .badge { position: absolute; top: 8px; left: 8px; background: rgba(255,255,255,.92); color: #1d1d1f; box-shadow: 0 1px 4px rgba(0,0,0,.25); }

/* What can be remade, as a quiet list rather than buttons */
.quick .label { margin-bottom: 0; }
.quick-list { list-style: none; margin: 0; padding: 0; display: grid; border-top: 1px solid var(--line); }
.quick-list li { border-bottom: 1px solid var(--line); }
.quick-opt { width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 4px; border: 0; background: none; text-align: left; cursor: pointer; border-radius: 6px; }
.quick-opt:hover, .quick-opt:focus-visible { background: var(--chip); }
.quick-opt:disabled { opacity: .6; cursor: wait; }
.q-text { flex: 1; min-width: 0; display: grid; }
.q-name { font-size: 14px; color: var(--accent); }
.q-desc { font-size: 12px; color: var(--muted); }
.q-cost { font-size: 12px; font-weight: 600; white-space: nowrap; }
.q-cost.free { font-weight: 400; color: var(--muted); }
.saved-tick { margin-left: 6px; color: var(--ok); text-transform: none; letter-spacing: 0; font-weight: 600; }
.saved-tick::before { content: "✓ "; }

/* A question over the open window */
.confirm-layer { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,.35); display: grid; place-items: center; padding: 16px; }
.confirm-card { background: var(--panel); border-radius: 14px; padding: 20px 22px; width: min(440px, 100%); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.confirm-card h3 { margin: 0 0 8px; }
.confirm-card p { margin: 0 0 10px; }
.confirm-cost { padding: 8px 10px; border-radius: 8px; background: var(--chip); }
.confirm-card .row { margin-top: 14px; }
/* A published video's caption folds open: show the arrow so it reads as clickable */
.reel-field > summary.label { display: list-item; cursor: pointer; }
/* Where Connect would be, without enough credit */
.connect-credit { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: var(--chip); }
