:root {
  --left-w: 44%;
  --bg: #171717;
  --panel: #1b1b1b;
  --card: #1f1f1f;
  --card2: #252525;
  --field: #262626;
  --line: #2c2c2c;
  --line2: #383838;
  --text: #ececec;
  --muted: #a3a3a3;
  --dim: #8f8f8f;  /* (17/11) was #737373: 3.2-3.8:1 on the cards, now 4.7-5.5:1 (WCAG AA), still a step under --muted */
  --brand: #8b5cf6;
  --brand2: #ec4899;
  --ok: #6ee7b7;
  --err: #f87171;
  --warn: #fbbf24;
  --radius: 12px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 13px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: #c4b5fd; }
svg { flex: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }
.hidden { display: none !important; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }  /* dvh: the height Safari really shows */
html { touch-action: manipulation; }  /* no zoom on a double tap (a pinch still zooms) */

/* ---------- buttons & fields ---------- */
.btn {
  height: 30px; padding: 0 12px; border: 1px solid var(--line2); background: #212121; color: var(--text);
  border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: 12.5px;
  white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #2a2a2a; border-color: #444; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: #262626; }
.btn.sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn.icon { width: 30px; padding: 0; justify-content: center; }
.btn.sm.icon { width: 26px; }
.btn.primary { background: #f2f2f2; color: #111; border-color: #f2f2f2; }
.btn.primary:hover { background: #fff; }
.btn.brand { background: linear-gradient(135deg, #7f56f2, #7c3aed); border-color: transparent; color: #fff; }  /* white reads 4.6:1 from the first stop (var(--brand) gave 4.2) */
.btn.brand:hover { filter: brightness(1.1); }
.btn.danger { color: #fca5a5; border-color: rgba(248,113,113,.35); background: rgba(248,113,113,.06); }
.btn.danger:hover { background: rgba(248,113,113,.14); }
.btn.on { background: #333; border-color: #4a4a4a; }

.ctl {
  height: 30px; background: var(--field); border: 1px solid #333; border-radius: 7px; padding: 0 9px;
  font-size: 12.5px; outline: none; min-width: 0; color: var(--text);
}
.ctl:focus, textarea.ctl:focus { border-color: var(--brand); }
/* (17/11) where the keyboard is: a violet ring on whatever Tab reaches (a mouse click shows none); fields show their
   violet border instead */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.ctl:focus-visible, .composer textarea:focus-visible { outline: none; }
select.ctl { padding-right: 24px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='3'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 8px center; }
textarea.ctl { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.ctl.num { width: 72px; }
.ctl.num.count { width: 136px; }.ctl.full { width: 100%; }
/* a file picker: its button and the chosen file's name centred in the box */
input[type="file"].ctl { height: auto; padding: 7px 10px; line-height: 28px; cursor: pointer; color: var(--muted); }
input[type="file"].ctl::file-selector-button { height: 28px; margin: 0 12px 0 0; padding: 0 14px; border: 1px solid var(--line2); border-radius: 6px; background: var(--card2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; vertical-align: middle; }
input[type="file"].ctl::file-selector-button:hover { border-color: #5b5b5b; }

.seg { display: inline-flex; background: #232323; border: 1px solid var(--line); border-radius: 8px; padding: 3px; gap: 2px; }
.seg.wide { display: flex; }
.seg button { background: none; border: 0; color: var(--muted); padding: 4px 11px; border-radius: 6px; font-weight: 600; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg button:hover { color: var(--text); }
.seg button.on { background: #3a3a3a; color: #fff; }

.switch { position: relative; width: 36px; height: 20px; border-radius: 20px; background: #3a3a3a; border: 0; padding: 0; transition: background .15s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--brand); }
.switch.on::after { transform: translateX(16px); }

.chip { border: 1px solid var(--line2); background: #222; color: var(--muted); border-radius: 999px; padding: 3px 10px; font-size: 12px; font-weight: 500; }
.chip:hover { color: var(--text); border-color: #4a4a4a; }
.chip.on { color: #fff; border-color: var(--brand); background: rgba(139,92,246,.18); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.badge { font-size: 11px; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line2); color: var(--muted); white-space: nowrap; font-weight: 600; }
.badge.ok { color: var(--ok); border-color: rgba(110,231,183,.35); background: rgba(110,231,183,.06); }
.badge.brand { color: #c4b5fd; border-color: rgba(139,92,246,.45); background: rgba(139,92,246,.1); }

.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid #555; border-top-color: #c4b5fd; animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- top bar ---------- */
.topbar { height: 48px; display: flex; border-bottom: 1px solid var(--line); background: #151515; flex: none; }
.tb-left { width: var(--left-w); min-width: 380px; display: flex; align-items: center; gap: 10px; padding: 0 12px; }
.tb-right { flex: 1; display: flex; align-items: center; justify-content: flex-start; gap: 12px; padding: 0 12px; min-width: 0; }
.tb-right > .btn { flex: none; margin-left: auto; }
.proj-name { background: none; border: 0; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 8px; max-width: 260px; }
.proj-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.proj-name:hover { background: #232323; }
.tabs { display: flex; gap: 2px; height: 100%; flex: 0 1 auto; min-width: 0; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { background: none; border: 0; color: var(--muted); font-weight: 600; font-size: 13px; padding: 0 10px; flex: none; display: flex; align-items: center; gap: 7px; position: relative; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab .dot { width: 6px; height: 6px; border-radius: 50%; border: 1.5px solid currentColor; opacity: .7; }
.tab .count { font-size: 11px; color: var(--dim); font-weight: 600; }
.tab.on { color: #fff; }
.tab.on::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: #fff; border-radius: 2px; }
.tab.on .dot { background: currentColor; }

/* ---------- workspace ---------- */
.workspace { flex: 1; display: flex; min-height: 0; }
.left { width: var(--left-w); min-width: 380px; display: flex; flex-direction: column; background: var(--panel); position: relative; }
.resizer { width: 5px; margin: 0 -2px; cursor: col-resize; z-index: 5; position: relative; }
.resizer::after { content: ""; position: absolute; left: 2px; top: 0; bottom: 0; width: 1px; background: var(--line); }
.resizer:hover::after, .resizer.drag::after { background: var(--brand); width: 2px; }
.right { flex: 1; display: flex; flex-direction: column; min-width: 0; background: #191919; }

.pane-head { height: 48px; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--line); flex: none; }
.pane-head .ttl { font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.pane-head .ttl .sub { color: var(--dim); font-weight: 500; font-size: 12px; }
.cost { color: var(--dim); font-size: 11.5px; font-weight: 600; display: flex; align-items: center; gap: 4px; font-variant-numeric: tabular-nums; }

/* ---------- setup card ---------- */
.chat-scroll { flex: 1; overflow-y: auto; padding: 16px 12px 8px; scroll-behavior: auto; }
.setup { border: 1px solid var(--line); border-radius: 14px; background: #1e1e1e; padding: 16px; }
.setup h3 { display: flex; gap: 9px; align-items: center; font-size: 15px; margin: 0 0 12px; }
.label { font-size: 12px; color: var(--muted); font-weight: 600; margin: 14px 0 7px; }
.label:first-of-type { margin-top: 0; }

.basic { display: flex; flex-wrap: wrap; gap: 12px 12px; align-items: flex-end; }
.fld { display: flex; flex-direction: column; gap: 5px; }
.fld > span { font-size: 11px; color: var(--dim); font-weight: 600; white-space: nowrap; }
.fld .unit { display: flex; align-items: center; gap: 6px; color: var(--dim); font-size: 11.5px; }
.opt-row { display: flex; align-items: center; gap: 16px; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; margin-top: 14px; background: #1b1b1b; }
.opt-row b { display: block; font-size: 13px; }
.opt-row p { margin: 2px 0 0; font-size: 12px; color: var(--dim); line-height: 1.4; }
.more-row { width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: 0; padding: 14px 0 4px; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.more-row:hover { color: var(--text); }
.more-row svg { transition: transform .15s; }
.more-row.open svg { transform: rotate(90deg); }
.pos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 8px 0 4px; }
.pos .full { grid-column: 1 / -1; }
.btn-lg { width: 100%; height: 42px; margin-top: 14px; background: #f0f0f0; color: #111; border: 0; border-radius: 10px; font-weight: 600; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; }
.btn-lg:hover { background: #fff; }
.setup-summary { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; padding: 8px 8px 8px 12px; background: #1e1e1e; }
.setup-summary .sw { width: 30px; height: 30px; border-radius: 7px; flex: none; display: grid; place-items: center; font-size: 16px; }
.setup-summary .txt { flex: 1; min-width: 0; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.setup-summary .txt b { color: var(--text); }

/* ---------- chat ---------- */
.msg { margin: 16px 0; display: flex; gap: 10px; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble { background: #2b2b2b; border-radius: 14px 14px 4px 14px; padding: 8px 13px; max-width: 86%; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .atts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.ai-av { width: 26px; height: 26px; border-radius: 8px; flex: none; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; margin-top: 1px; }
.msg .body { flex: 1; min-width: 0; }
.part-text { word-wrap: break-word; }
.part-text > :first-child { margin-top: 0; }
.part-text > :last-child { margin-bottom: 0; }
.part-text p { margin: 0 0 8px; }
.part-text ul, .part-text ol { margin: 4px 0 8px; padding-left: 20px; }
.part-text li { margin: 2px 0; }
.part-text h4, .part-text h5 { margin: 12px 0 6px; font-size: 13.5px; }
.part-text code { background: #2a2a2a; border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.part-text pre { background: #141414; border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow: auto; }
.part-text pre code { background: none; padding: 0; }
.part-text blockquote { margin: 6px 0; padding: 2px 10px; border-left: 3px solid #444; color: var(--muted); }
.part-think { margin: 4px 0 8px; }
.part-think summary { list-style: none; cursor: pointer; color: var(--dim); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; user-select: none; }
.part-think summary::-webkit-details-marker { display: none; }
.part-think summary:hover { color: var(--muted); }
.part-think .tt { border-left: 2px solid #333; margin: 6px 0 0 5px; padding: 2px 10px; color: var(--dim); font-size: 12px; white-space: pre-wrap; max-height: 260px; overflow: auto; }
.part-tool { display: flex; align-items: center; gap: 9px; background: #202020; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; margin: 6px 0; font-size: 12px; }
.part-tool .ic { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; background: #2a2a2a; color: #c4b5fd; flex: none; }
.part-tool .nm { font-weight: 600; white-space: nowrap; }
.part-tool .sm { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.part-tool.done .ic { color: var(--ok); }
.part-tool.error .ic { color: var(--err); }
.part-status { display: flex; align-items: center; gap: 8px; color: var(--dim); font-size: 12px; margin: 10px 0; }
.part-status::before, .part-status::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.part-error { color: #fecaca; background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.3); border-radius: 9px; padding: 8px 11px; margin: 6px 0; font-size: 12.5px; }
.typing { display: inline-flex; gap: 4px; padding: 6px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: #666; animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; } .typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-intro { color: var(--dim); font-size: 12px; text-align: center; margin: 22px 0 6px; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 10px; }

.composer { margin: 10px 12px 12px; border: 1px solid var(--line); border-radius: 12px; background: #1f1f1f; padding: 10px 12px 8px; flex: none; transition: border-color .15s; }
.composer:focus-within { border-color: var(--brand); }
.composer.drag { border-color: var(--brand); background: rgba(139,92,246,.06); }
.composer textarea { width: 100%; background: none; border: 0; outline: none; resize: none; min-height: 40px; max-height: 220px; line-height: 1.5; }
.composer textarea::placeholder { color: #6b6b6b; }
.comp-row { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.send { width: 34px; height: 34px; border-radius: 9px; border: 0; background: #4a4a4a; color: #ddd; display: grid; place-items: center; }
.send.ready { background: #f0f0f0; color: #111; }
.send.stop { background: #f0f0f0; color: #111; }
.att-list { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.att { display: inline-flex; align-items: center; gap: 6px; background: #2a2a2a; border: 1px solid var(--line2); border-radius: 7px; padding: 3px 4px 3px 8px; font-size: 11.5px; max-width: 240px; }
.att span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att button { background: none; border: 0; color: var(--dim); padding: 0 3px; }
.att-thumb { width: 26px; height: 26px; object-fit: cover; border-radius: 4px; margin: -1px 0 -1px -5px; flex: none; }
.att button:hover { color: var(--text); }

/* ---------- right panel ---------- */
.r-head { min-height: 48px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 7px 16px; border-bottom: 1px solid var(--line); flex: none; }
.r-head .ttl { font-weight: 700; font-size: 14px; display: flex; align-items: baseline; gap: 10px; white-space: nowrap; }
.r-head .ttl small { color: var(--dim); font-weight: 500; font-size: 12px; }
.r-body { flex: 1; overflow-y: auto; padding: 16px; }
.r-inner { max-width: 980px; margin: 0 auto; }
/* Phân cảnh (its table), Prompt video (its cards), Storyboard (a scene's frames), Ảnh tham chiếu (the cards) and
   (6/11) Ảnh & Video use the whole panel, 4 a row when there is room (a 9:16 storyboard's narrow frames keep
   filling the row) */
.r-inner.wide { max-width: 1680px; container-type: inline-size; container-name: rinner; }
@container rinner (min-width: 1040px) {
  .r-inner.wide .sdc-grid, .r-inner.wide .acards, .r-inner.wide .sbf-grid:not(.tall),
  .r-inner.wide .mgrid, .r-inner.wide .shc-grid:not(.side) { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .r-inner.wide .shc-grid.side { grid-template-columns: repeat(3, minmax(0, 1fr)); }  /* (6/11) Phân cảnh's cards */
}
.empty { height: 100%; min-height: 360px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 4px; }
.empty .ic { color: #555; margin-bottom: 10px; }
.empty h4 { margin: 0; color: #cfcfcf; font-weight: 500; font-size: 14px; }
.empty p { margin: 6px 0 16px; max-width: 250px; font-size: 12px; color: var(--dim); line-height: 1.5; }

.bible { border: 1px solid var(--line); border-radius: var(--radius); background: linear-gradient(135deg, rgba(139,92,246,.08), rgba(236,72,153,.04) 60%, transparent), var(--card); padding: 16px 18px; margin-bottom: 14px; }
.bible h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; }
.bible .log { color: #d4d4d4; margin: 6px 0 0; font-size: 13px; }
.bible .syn { color: var(--muted); font-size: 12.5px; margin-top: 10px; white-space: pre-wrap; }
.bible .syn.clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.bible .row { display: flex; gap: 8px; align-items: flex-start; }
.bible .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.bible .tags .badge { white-space: normal; max-width: 100%; overflow-wrap: anywhere; line-height: 1.45; border-radius: 10px; padding: 3px 9px; font-size: 11px; }

.ep { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); margin-bottom: 10px; transition: border-color .15s; }
.ep:hover { border-color: #3a3a3a; }
/* the open episode: a purple frame so it stands out among the others */
.ep.open, .ep.open:hover { border-color: var(--brand); box-shadow: 0 0 0 1px rgba(139,92,246,.45), 0 6px 22px rgba(139,92,246,.12); }
.ep.open .ep-head { background: rgba(139,92,246,.07); border-radius: var(--radius) var(--radius) 0 0; }
.ep.open .ep-num { background: #7c3aed; color: #fff; }  /* (17/11) white on var(--brand) was 4.2:1, on #7c3aed 5.7 */
.ep.open .ep-body { border-top-color: rgba(139,92,246,.35); }
.ep.flash { animation: flash 1.2s ease-out; }
@keyframes flash { from { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(139,92,246,.2); } }
.ep-head { display: flex; align-items: center; gap: 10px; row-gap: 6px; flex-wrap: wrap; padding: 11px 12px 11px 14px; cursor: pointer; }
.ep-num { font: 700 11px/1 ui-monospace, Consolas, monospace; background: #2d2d2d; border-radius: 6px; padding: 5px 7px; color: #ddd; flex: none; }
.ep-main { flex: 1 1 140px; min-width: 0; }  /* a narrow panel: the meta and buttons wrap under the title */
.ep-title { font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-log { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ep-meta { color: var(--dim); font-size: 12px; white-space: nowrap; display: flex; gap: 8px; align-items: center; }
.ep-actions { display: flex; gap: 2px; opacity: .5; transition: opacity .15s; }
.ep:hover .ep-actions { opacity: 1; }
.ep-head .chev { color: var(--dim); transition: transform .15s; }
.ep.open .ep-head .chev { transform: rotate(180deg); }
.ep-body { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.ep-tabs { display: flex; gap: 2px; margin: 10px 0 12px; }
.hooks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hook { background: #252525; border-radius: 9px; padding: 8px 11px; font-size: 12.5px; }
.hook b, .kv b { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); margin-bottom: 2px; }
.hook.cl { background: linear-gradient(135deg, rgba(236,72,153,.1), #252525); }
.hook.op { background: linear-gradient(135deg, rgba(139,92,246,.12), #252525); }
.hook.em { background: linear-gradient(135deg, rgba(251,146,60,.13), #252525); margin-bottom: 8px; white-space: pre-wrap; }
.hook.em b { display: flex; align-items: center; gap: 4px; color: #fdba74; }
.scene-emo { display: flex; align-items: center; gap: 5px; margin-top: 4px; font-size: 12px; color: #fdba74; font-style: italic; }
.ep-sum { color: #cfcfcf; font-size: 12.5px; margin: 10px 0 4px; white-space: pre-wrap; }
.scenes { margin-top: 8px; }
.scene { display: grid; grid-template-columns: 26px 1fr; gap: 8px; padding: 9px 0; border-top: 1px dashed #2f2f2f; }
.scene .n { font: 700 11px ui-monospace, Consolas, monospace; color: var(--dim); padding-top: 2px; }
.scene .loc { font-weight: 700; font-size: 12px; line-height: 1.4; letter-spacing: .02em; }
.scene .who { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.scene p { margin: 2px 0 0; font-size: 12.5px; color: #cfcfcf; }

/* reading script in the app font: heading, action, centered name, parenthetical, dialogue column */
.script { background: #141414; border: 1px solid var(--line); border-radius: 10px; padding: 30px 36px; font-size: 14px; line-height: 1.65; color: #e8e8e8; max-width: 760px; margin: 0 auto; }
.script .ttl { text-align: center; font-weight: 700; letter-spacing: .06em; margin: 0 0 22px; }
.script .sh { font-weight: 700; margin: 28px 0 14px; padding: 5px 10px; text-transform: uppercase; background: #1e1e1e; border-left: 3px solid var(--brand); border-radius: 4px; }
.script > .sh:first-child, .script > .sblk:first-child > .sh:first-child { margin-top: 0; }
.script .act { margin: 0 0 14px; white-space: pre-wrap; }
/* a scene's own label over its heading (CẢNH 05 – THƯ VIỆN, kept from an imported script) */
.script .sn { font-weight: 700; font-size: 12.5px; letter-spacing: .03em; color: var(--brand); margin: 28px 0 -20px; padding-left: 13px; }
.script .dlg { margin: 16px 0; }
.script .cue { text-align: center; text-transform: uppercase; font-weight: 700; color: #fff; }
.script .par { text-align: center; color: #a8a8a8; font-style: italic; }
.script .dia { margin: 2px auto 0; max-width: 64%; white-space: pre-wrap; }
.script .tl { margin: 1px auto 6px; max-width: 64%; white-space: pre-wrap; font-style: italic; font-size: 12.5px; line-height: 1.5; color: #9ca3af; }
.script .tr { text-align: right; margin: 18px 0; text-transform: uppercase; font-weight: 700; color: #c4b5fd; }
.script-notes { max-width: 760px; margin: 12px auto 0; font-size: 12.5px; color: #cfcfcf; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #181818; }
.script-notes summary { cursor: pointer; font-weight: 600; color: var(--muted); }
.script-notes div { margin-top: 8px; white-space: pre-wrap; line-height: 1.55; }
/* "## NHỊP 01: ..." beat headings (Fountain section lines): set like the outline's beat titles, a rule above each */
.script .sec { font-weight: 800; font-size: 13.5px; letter-spacing: .02em; text-transform: uppercase; color: var(--text); margin: 34px 0 6px; padding-top: 12px; border-top: 1px solid var(--line2); }
.script > .sec:first-child, .script > .sblk:first-child .sec { margin-top: 4px; padding-top: 0; border-top: 0; }
.script .syn, .script .note { color: var(--dim); font-style: italic; margin: 0 0 8px; }
.script hr { border: 0; border-top: 1px dashed #333; margin: 18px 0; }
.script-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; align-items: center; }
.script-tools > .dim { flex: 1 1 220px; min-width: 0; }
.script-tools > .spacer { display: none; }
.script-tools > .btn { flex: none; }
/* Prompt video: its tools + Khớp phân cảnh stay at the top of .r-body while the scene cards scroll */
.sd-pin { position: sticky; top: -16px; z-index: 5; margin: 0 -16px 12px; padding: 10px 16px 2px; background: #191919; border-bottom: 1px solid var(--line); }
.ep-body > .sd-pin:first-child, .ep-body > [data-match]:empty:first-child + [data-labels]:empty + .sd-pin { margin-top: -16px; }  /* right under the tab's head, no gap, like a third bar of it */
.sd-pin > .script-tools { margin-bottom: 8px; }
.no-script { border: 1px dashed #3a3a3a; border-radius: 10px; padding: 22px; text-align: center; color: var(--dim); }
.no-script .btns { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }
.no-script-tip { max-width: 460px; margin: 14px auto 0; font-size: 12px; line-height: 1.5; color: var(--dim); }

.chain { position: relative; padding-left: 38px; }
.chain::before { content: ""; position: absolute; left: 14px; top: 14px; bottom: 14px; width: 2px; background: linear-gradient(var(--brand), var(--brand2)); opacity: .6; }
.chain-ep { position: relative; margin-bottom: 16px; }
.chain-ep .node { position: absolute; left: -38px; top: 0; width: 30px; height: 30px; border-radius: 50%; background: #1d1d1d; border: 2px solid var(--brand); display: grid; place-items: center; font: 700 11px ui-monospace, monospace; }
.chain-ep h5 { margin: 0 0 6px; font-size: 13px; padding-top: 5px; display: flex; gap: 8px; align-items: center; }
.chain-link { color: var(--dim); font-size: 11px; margin: -8px 0 8px 0; display: flex; align-items: center; gap: 6px; }
.chain-warn { color: var(--warn); }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.card { border: 1px solid var(--line); background: var(--card); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s; }
.card:hover { border-color: #3a3a3a; }
.card.variant { border-left: 3px solid rgba(139,92,246,.5); }
.card-top { display: flex; gap: 12px; padding: 14px 14px 10px; align-items: flex-start; }
.avatar { width: 50px; height: 50px; border-radius: 12px; display: grid; place-items: center; font-weight: 700; font-size: 18px; flex: none; color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
.card-id { flex: 1; min-width: 0; }
.card-top h4 { margin: 0; font-size: 14.5px; line-height: 1.3; overflow-wrap: anywhere; }
.card-top .sub { color: var(--muted); font-size: 12px; line-height: 1.4; margin-top: 5px; }
.card-top .meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.card-top .meta span { font-size: 11px; line-height: 18px; padding: 0 7px; border-radius: 999px; background: #262626; border: 1px solid var(--line); color: var(--muted); }
.variant-of { font-size: 12px; color: var(--dim); margin-top: 4px; }
.variant-of b { font-weight: 500; color: #a78bfa; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 11px; }
.card-acts { display: flex; align-items: center; gap: 2px; padding: 3px 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: #1b1b1b; opacity: .7; transition: opacity .15s; }
.card:hover .card-acts { opacity: 1; }
.card-acts .grow { flex: 1; }
.card-acts .flow-btn { padding: 4px 7px; gap: 4px; font-size: 11.5px; }
.kv { padding: 2px 14px 6px; font-size: 12.5px; color: #d0d0d0; }
.kv > div { margin-top: 8px; }
.kv .clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.prompt-box { margin: 8px 14px 14px; background: #181818; border: 1px dashed #353535; border-radius: 9px; padding: 8px 10px; font-size: 12px; color: #a8a8a8; position: relative; margin-top: auto; }
.prompt-box b { display: flex; justify-content: space-between; align-items: center; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); margin-bottom: 3px; }
.prompt-box .clamp { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.card-spacer { margin-top: auto; }


/* ---------- modal, menus, toasts ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.62); display: grid; place-items: center; z-index: 60; animation: fade .12s; padding: 20px;
  grid-template-columns: minmax(0, 1fr); }  /* one column the screen's width: a dialog's 100% never grows with its text */
@keyframes fade { from { opacity: 0; } }
.modal { width: min(640px, 100%); max-height: 90vh; max-height: min(90dvh, calc(100dvh - 40px - var(--kb, 0px))); display: flex; flex-direction: column; background: #1f1f1f; border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; padding: 14px 16px 10px; gap: 10px; }
.modal-head h3 { margin: 0; font-size: 15px; flex: 1; }
.modal-body { padding: 4px 16px 12px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form .full { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.scene-rows { display: flex; flex-direction: column; gap: 8px; }
.scene-row { display: grid; gap: 6px; align-items: start; padding-bottom: 8px; border-bottom: 1px dashed var(--line);
  grid-template-columns: 1.4fr .55fr 1.4fr .7fr 28px; grid-template-areas: "title act loc time rm" "goal goal shift emo who"; }
.scene-row textarea { min-height: 30px; height: 30px; }

.menu { position: fixed; z-index: 70; background: #232323; border: 1px solid var(--line2); border-radius: 10px; padding: 4px; min-width: 210px; box-shadow: 0 14px 40px rgba(0,0,0,.5); animation: fade .1s; }
.menu button { display: flex; gap: 9px; align-items: center; width: 100%; text-align: left; background: none; border: 0; padding: 7px 10px; border-radius: 7px; font-size: 12.5px; }
.menu button:hover { background: #2e2e2e; }
.menu button.danger { color: #fca5a5; }
.menu button .d { display: block; color: var(--dim); font-size: 12px; font-weight: 400; }
.menu button.sel { background: #2b2b2b; }
.menu button:disabled { opacity: .45; cursor: not-allowed; }
.menu button:disabled:hover { background: none; }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }

#toasts { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: #2b2b2b; border: 1px solid #3d3d3d; padding: 8px 14px; border-radius: 9px; box-shadow: 0 10px 30px rgba(0,0,0,.4); font-size: 12.5px; animation: fade .15s; }
.toast.err { border-color: rgba(248,113,113,.5); color: #fecaca; }


/* ---------- board ---------- */
.board { position: fixed; inset: 0; z-index: 55; background: #141414; display: flex; flex-direction: column; animation: fade .15s; }
.board-head { height: 56px; display: flex; align-items: center; gap: 10px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.board-head h2 { margin: 0; font-size: 16px; flex: 1; }
.board-body { flex: 1; overflow: auto; padding: 22px; }
.board-inner { max-width: 1280px; margin: 0 auto; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0 18px; }
.stat { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; }
.stat b { font-size: 22px; display: block; letter-spacing: -.02em; }
.stat span { color: var(--dim); font-size: 11.5px; font-weight: 600; }
.progress { height: 6px; background: #2a2a2a; border-radius: 6px; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand2)); }
.board-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.board-col { border: 1px solid var(--line); background: #181818; border-radius: 12px; padding: 12px; min-height: 120px; }
.board-col h4 { margin: 0 0 10px; font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; text-transform: uppercase; letter-spacing: .06em; }
.bcard { background: var(--card2); border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; margin-bottom: 8px; cursor: pointer; }
.bcard:hover { border-color: #444; }
.bcard .t { font-weight: 600; font-size: 12.5px; }
.bcard .l { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.cast { display: flex; flex-wrap: wrap; gap: 10px; }
.cast .p { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px; }
.cast .avatar { width: 28px; height: 28px; font-size: 12px; border-radius: 50%; }
.sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); margin: 22px 0 10px; font-weight: 700; }

/* ---------- home ---------- */
.home { flex: 1; overflow: auto; }
.home-head { height: 60px; display: flex; align-items: center; padding: 0 28px; border-bottom: 1px solid var(--line); gap: 12px; position: sticky; top: 0; background: rgba(23,23,23,.9); backdrop-filter: blur(8px); z-index: 2; }
.logo { display: flex; align-items: center; flex: none; }
/* the product's logo (app.js LOGO): the dark theme's picture here, light-extra.css swaps in the light theme's */
.logo-img { height: 44px; width: auto; display: block; }
.logo-img.for-light { display: none; }
.home main { max-width: 1880px; margin: 0 auto; padding: 28px; }  /* (17/11) was 1180: a 1920 px screen showed 4 cards a row between wide empty sides, now 6 */
.home h1 { font-size: 26px; margin: 10px 0 4px; letter-spacing: -.02em; }
.home .lead { color: var(--muted); margin: 0 0 24px; }
.proj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.pcard { border: 1px solid var(--line); background: var(--card); border-radius: 14px; overflow: hidden; cursor: pointer; transition: transform .15s, border-color .15s; position: relative; }
.pcard:hover { border-color: #444; transform: translateY(-2px); }
.pcard .thumb { height: 120px; position: relative; display: grid; place-items: center; font-size: 42px; }
.pcard .info { padding: 12px 14px; }
.pcard .info b { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcard .info p { margin: 4px 0 8px; color: var(--muted); font-size: 12px; height: 36px; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pcard .info .m { display: flex; flex-wrap: wrap; gap: 2px 10px; color: var(--dim); font-size: 12px; white-space: nowrap; }  /* a narrow card: the time goes under, never cut */
.pcard .info .m > span:not(.spacer):not(.fit) { flex: none; }
.pcard .info .m > span.fit { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pcard .more { position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.45); border-color: transparent; }
.pnew { border: 1px dashed #444; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 230px; color: var(--muted); background: none; font-weight: 600; }
.pnew:hover { border-color: var(--brand); color: #fff; background: rgba(139,92,246,.05); }
.pnew .plus { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: #242424; }
/* (17/11) home sections folded to their first rows (util.js applyFolds); "Xem tất cả (N)" at the title line's end */
.fold-hide { display: none !important; }
.home-title { display: flex; align-items: center; gap: 10px; margin: 10px 0 4px; }
.home .home-title h1 { margin: 0; }
.fold-btn { margin-left: auto; letter-spacing: 0; }
.home-title, .conn-head h2:has(> .fold-btn) { flex-wrap: wrap; }
.doc-box { border: 1px solid rgba(139,92,246,.45); background: rgba(139,92,246,.06); border-radius: 12px; padding: 10px 14px; }
.doc-box > summary { cursor: pointer; font-weight: 600; font-size: 13px; color: #c4b5fd; display: flex; align-items: center; gap: 6px; }
.doc-in { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.doc-in .seg { align-self: flex-start; }
.doc-in label { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.doc-go { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.doc-go .dim { font-size: 12px; flex: 1; min-width: 200px; }
.doc-or { display: flex; align-items: center; gap: 10px; color: var(--dim); font-size: 11.5px; }
.doc-or::before, .doc-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.fg-st.bad { color: var(--err); max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 980px) {
  .tabs .tab { padding: 0 7px; }
  .tab .dot { display: none; }
  .hooks, .board-cols, .pos, .form { grid-template-columns: 1fr; }
}

/* ---------- model connections (home) ---------- */
.conn { margin-top: 40px; padding-top: 28px; border-top: 1px solid var(--line); scroll-margin-top: 70px; }
.conn-head h2 { font-size: 20px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.conn-head .lead { margin-bottom: 16px; }
.defaults { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 12px; margin-bottom: 16px; }
.def { display: flex; gap: 12px; align-items: center; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 12px 14px; }
.def b { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.def > div:last-child { flex: 1; min-width: 0; }
.def select { width: 100%; }
.def-ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: #262626; color: #c4b5fd; flex: none; }
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 12px; }
.conn-card { display: flex; gap: 12px; align-items: flex-start; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px; }
.conn-card.on { border-color: rgba(110,231,183,.35); }
.conn-card .cg { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-size: 19px; flex: none; color: #fff; font-weight: 700; }
.conn-card .cg.cg-logo { background: #fff; box-shadow: inset 0 0 0 1px var(--line); }  /* a provider's own logo (connections.js provMark) */
.conn-card .cg-logo img { width: 26px; height: 26px; display: block; }
.conn-card .cg.cg-full { background: none; box-shadow: none; }  /* a logo that is a whole tile itself (Claude) */
.conn-card .cg-full img { width: 40px; height: 40px; border-radius: 10px; }
.conn-card .ci { flex: 1; min-width: 0; }
.conn-card .ci b { font-size: 13.5px; }
.conn-card .ci p { margin: 3px 0 8px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.conn-card .kinds { display: flex; flex-wrap: wrap; gap: 5px; }
.conn-card .cs { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex: none; }
.conn-card .st { font-size: 12px; color: var(--dim); white-space: nowrap; }
.conn-card .st.on { color: var(--ok); }
/* what the other accounts see the provider as (connections.js channelModal, server/sources.py) */
.conn-chan { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.conn-chan b { color: var(--text); }
.test { border-radius: 9px; padding: 8px 11px; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.test.ok { color: var(--ok); background: rgba(110,231,183,.08); border: 1px solid rgba(110,231,183,.3); }
.test.bad { color: #fecaca; background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.3); }

/* ---------- media ---------- */
.ref-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.ref-thumb { width: 64px; height: 64px; border-radius: 9px; border: 2px solid transparent; background: #262626; padding: 0; overflow: hidden; color: var(--dim); font-size: 11px; }
.ref-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ref-thumb.sel { border-color: var(--brand); }
.ref-named { position: relative; }
.ref-named b { position: absolute; left: 3px; top: 3px; background: rgba(0,0,0,.65); color: #fff; font-size: 11px; padding: 0 4px; border-radius: 4px; }
[data-refs-box].off .ref-pick { opacity: .35; }
.mgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.mcard { border: 1px solid var(--line); background: var(--card); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.mc-prev { position: relative; aspect-ratio: 4 / 3; background: #121212; display: grid; place-items: center; }
.mc-prev img, .mc-prev video { width: 100%; height: 100%; object-fit: contain; display: block; background: #0d0d0d; }
.mc-prev img { cursor: zoom-in; }
.mc-kind { position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center; background: rgba(0,0,0,.6); color: #fff; pointer-events: none; }
.mc-state { display: flex; flex-direction: column; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; padding: 16px; text-align: center; }
.mc-state.bad { color: #fca5a5; font-size: 12px; overflow: auto; max-height: 100%; }
.mc-info { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.mc-t { display: flex; justify-content: space-between; gap: 8px; font-size: 12.5px; }
.mc-t b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-t span { font-size: 11px; white-space: nowrap; }
.mc-m { font-size: 12px; }
.mc-note { color: var(--warn); line-height: 1.4; }
.mc-p { font-size: 12px; color: #bdbdbd; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mc-a { display: flex; gap: 4px; margin-top: auto; padding-top: 8px; align-items: center; }
/* background music: the mark and the "Tách nhạc" button (media.js musicHTML) */
.badge.warn { color: var(--warn); border-color: rgba(251,191,36,.4); background: rgba(251,191,36,.08); }
.mu-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11.5px; min-height: 22px; }
.mu-row .btn { padding: 2px 8px; }
.mu-wait { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.mu-wait .spin { width: 11px; height: 11px; }
.mu-note { color: var(--muted); }
.mu-err { color: #fca5a5; cursor: help; }
.sdc-music { padding: 6px 12px 0; }
.sdc-pos { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; padding: 6px 12px 0; font-size: 12px; line-height: 1.4; }
.sdc-pos.sdc-pos-ok { color: #86efac; }
.acard-err.sdc-pos { margin: 6px 12px 0; padding: 6px 10px; }
.sdc-err { max-width: none; margin: 8px 12px 0; text-align: left; overflow-wrap: anywhere; }
/* a card's line written before its shot-list scene changed: Cập nhật prompt cảnh này / Bỏ qua */
.acard-err.sdc-sync { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.4); color: var(--warn); }
.sdc-sync-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.sdc-sync .btn { padding: 3px 8px; font-size: 11.5px; }
/* (19/11) Một cú máy liền: a card's line written the other way than the switch is now */
.sdc-take { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; padding: 5px 10px; border: 1px dashed var(--line); border-radius: 8px; }
.sdc-take .btn { padding: 3px 8px; font-size: 11.5px; }
.seg.sd-take button { padding: 3px 9px; }
/* (4/11) a card's Sửa lỗi (panels.js sdFixHTML): a row, so its spinner has its size; being fixed is not an error */
.acard-err.sdc-fix { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 8px; }
.acard-err.sdc-fixed { background: rgba(34,197,94,.12); border-color: rgba(34,197,94,.4); color: #86efac; }
.acard-err.sdc-fixing { flex-wrap: nowrap; text-align: left; background: rgba(139,92,246,.12); border-color: rgba(139,92,246,.4); color: #c4b5fd; }
/* the shot dialog: the scene's seconds as the shot's length changes, and "change the scene's length" */
.shot-count { margin: -4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.45; }
.shot-count.warn { color: var(--warn); }
label.shot-fit { display: flex; flex-direction: row; align-items: center; gap: 6px; font-size: 12.5px; }
label.shot-fit.hidden { display: none; }
/* (4/11) a row whose own words pull against its size (panels.js shotClash): in the dialog, and before a draw */
.shot-clash { display: flex; flex-direction: column; gap: 6px; padding: 8px 10px; border-radius: 8px; font-size: 12px; line-height: 1.45;
  color: var(--warn); background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.35); }
.shot-clash-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.shot-clash-row .dim { font-size: 12px; }
.shot-clash-ask { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.5; max-height: 50vh; overflow: auto; }
.shot-clash-ask > li + li { margin-top: 8px; }
.shot-clash-ask ul { margin: 2px 0; padding-left: 16px; color: var(--warn); }
.shot-table .shs-clash { color: var(--warn); font-weight: 700; cursor: help; }
.scene-vid + .mu-row { margin-top: 6px; }
.card-cover { position: relative; aspect-ratio: 16 / 10; background: #121212; overflow: hidden; }
.card-cover.characters { aspect-ratio: 4 / 3; }
.card-cover img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.cover-busy { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; background: rgba(0,0,0,.55); font-size: 12px; color: #ddd; }
.scene-top { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.scene-top .btn { opacity: .55; }
.scene:hover .scene-top .btn { opacity: 1; }

/* beat-sheet outline */
.beats { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.act-head { margin: 10px 0 0; font-size: 11.5px; font-weight: 700; letter-spacing: .08em; color: #c4b5fd; text-transform: uppercase; }
.act-head:first-child { margin-top: 0; }
.beat { position: relative; border-left: 2px solid #3a3a3a; padding: 6px 0 6px 12px; border-radius: 0 6px 6px 0; }
.beat:hover > .sblk-tools { display: flex; }
.beat:hover { background: rgba(139,92,246,.05); }
.beat.on { border-left-color: var(--brand); background: rgba(139,92,246,.08); }
.beat:hover { border-left-color: var(--brand); }
.beat-head { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.beat-title { font-size: 13px; line-height: 1.4; }
.beat-title b { letter-spacing: .02em; }
.beat-where { color: var(--muted); font-size: 12px; }
.beat-line { display: grid; grid-template-columns: 92px 1fr; gap: 8px; margin-top: 3px; font-size: 12.5px; line-height: 1.5; color: #d4d4d4; }
.beat-line > span { color: var(--dim); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; padding-top: 2px; }
.shift { font-weight: 700; }
.shift.up { color: var(--ok); }
.shift.down { color: #f87171; }
.emo { font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 11px; padding: 1px 5px; border-radius: 4px; background: #2a2a2a; color: #e5e5e5; }
.emo-1 { background: rgba(56,189,248,.18); color: #7dd3fc; }
.emo-2 { background: rgba(251,146,60,.18); color: #fdba74; }
.emo-3 { background: rgba(74,222,128,.16); color: #86efac; }
.emo-4 { background: rgba(96,165,250,.16); color: #93c5fd; }
.emo-5 { background: rgba(248,113,113,.18); color: #fca5a5; }
.emo-6 { background: rgba(250,204,21,.18); color: #fde047; }
.emo-7 { background: rgba(192,132,252,.18); color: #d8b4fe; }
.ep-core { font-size: 12.5px; line-height: 1.75; color: #d4d4d4; background: linear-gradient(135deg, rgba(251,146,60,.1), #232323); border-radius: 9px; padding: 9px 12px; white-space: pre-wrap; }
.ep-idea { font-size: 12.5px; line-height: 1.65; color: #d4d4d4; background: linear-gradient(135deg, rgba(139,92,246,.12), #232323); border-radius: 9px; padding: 9px 12px; margin-bottom: 8px; white-space: pre-wrap; }
.ep-idea b { color: #c4b5fd; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; }
.check-row { flex-direction: row !important; align-items: center; gap: 8px !important; align-self: end; font-weight: 500 !important; color: var(--text) !important; }
.check-row input { accent-color: var(--brand); }
/* Xoá kịch bản: what goes, and the two ticks of Xoá toàn bộ (cards, world) */
.clr-list { margin: 0; padding-left: 20px; display: grid; gap: 3px; font-size: 13px; }
.check-row.clr-opt { display: flex; align-items: flex-start; margin: 6px 0; font-size: 13px; cursor: pointer; }
.check-row.clr-opt input { margin-top: 3px; flex: none; }
/* Tạo tất cả ảnh: the cards (or Vẽ theo bộ: the characters with their looks) to make, ticked one by one */
.gen-pick-head { display: flex; gap: 6px; align-items: center; }
.gen-pick-head .ctl { flex: 1; min-width: 0; }
.gen-pick-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--line); border-radius: 9px; padding: 2px 10px; }
.gen-pick { display: flex !important; align-self: stretch !important; width: 100%; padding: 5px 0; font-size: 12.5px; }
.gen-pick + .gen-pick { border-top: 1px solid var(--line); }
.gen-pick-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.gen-pick-state { flex: none; font-size: 12px; }
.gen-pick.gen-hide { display: none !important; }
.ep-core b { color: #fdba74; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; display: inline-flex; align-items: center; gap: 4px; margin-right: 4px; }
.legacy-note { margin-top: 8px; display: flex; align-items: center; gap: 10px; justify-content: space-between; font-size: 12px; color: var(--warn); background: rgba(250,204,21,.07); border: 1px solid rgba(250,204,21,.25); border-radius: 9px; padding: 7px 10px; }

/* asset labels and Seedance scenes */
.label-tag { display: inline-block; margin-top: 4px; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 11px; line-height: 1.5; letter-spacing: .04em; padding: 1px 6px; border-radius: 5px; background: rgba(139,92,246,.16); color: #c4b5fd; }
.label-tag[data-act] { cursor: copy; transition: background .15s; }
.label-tag[data-act]:hover { background: rgba(139,92,246,.3); }
.label-tag.missing { background: #2a2a2a; color: var(--dim); }
.sd-list { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.sdc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; margin-top: 10px; }
/* Phân cảnh: one block per scene, its shots in a table (panels.js shotsHTML) */
.shs { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.shs-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
/* (4/11) a warned scene's Sửa lỗi (panels.js shotFixHTML): being fixed, put right, what stopped it */
.shs-head .btn.shs-fix { padding: 2px 8px; font-size: 11.5px; }
.shs-fixing { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #c4b5fd; white-space: nowrap; }
.shs-fixed { font-size: 12px; font-weight: 600; color: var(--ok); white-space: nowrap; }
.shs-fix-err { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #fca5a5; cursor: help; }
.shs-loc { font-size: 11.5px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
/* (5/11) the location card picker of a scene whose location tells no card: small, beside the location */
.shs-place { width: auto; max-width: 260px; height: 28px; padding: 2px 8px; font-size: 12px; flex: 0 1 auto; }
/* "+ Thêm cảnh sau cảnh 003" in its own row under a scene, clear of the frames above and below (a scene added
   there is 003.1) */
.shs-plus { margin: 8px auto -4px; width: fit-content; max-width: 100%; height: 26px; padding: 0 12px; gap: 6px;
  border-radius: 999px; border: 1.5px dashed var(--line2); background: var(--bg); color: var(--muted); display: flex; align-items: center;
  font: inherit; font-size: 12.5px; line-height: 1; white-space: nowrap; cursor: pointer; opacity: .65; transition: opacity .15s, border-color .15s, color .15s; }
.shs-wrap:hover .shs-plus, .shs-plus:focus-visible { opacity: 1; }
.shs-plus:hover { border-style: solid; border-color: var(--brand); color: var(--brand); }
@media (hover: none) { .shs-plus { opacity: 1; } }
.shs-locks { padding: 8px 12px 0; font-size: 12px; line-height: 1.5; display: grid; gap: 2px; }
.shs-table { overflow-x: auto; }
.shot-table { width: 100%; border-collapse: collapse; font-size: 12px; line-height: 1.45; min-width: 820px; }
.shot-table th { text-align: left; font-weight: 600; color: var(--dim); font-size: 11px; padding: 7px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.shot-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--muted); }
.shot-table td.n { white-space: nowrap; color: var(--text); font-weight: 600; }
.shot-table tbody tr { cursor: pointer; }
.shot-table tbody tr:hover td { background: rgba(139,92,246,.06); color: var(--text); }
.shot-table tbody tr:last-child td { border-bottom: 0; }
/* each shot's spot in the scene's location, and its people (panels.js shotSceneHTML) */
.shot-table td.shs-spot { min-width: 110px; }
.shot-table td.shs-comp { min-width: 130px; }
/* the shot dialog's quick lists beside a field (panels.js shotModal, SHOT_TERMS) */
.shot-pick-row { display: flex; gap: 6px; align-items: stretch; }
.shot-pick-row > input.ctl { flex: 1; min-width: 0; }
.shot-pick-row > select.shot-pick { flex: 0 0 auto; width: 118px; font-size: 12px; cursor: pointer; }
.form label > span[data-vi] { min-height: 1.5em; }  /* the Vietnamese reading keeps its line: the fields beside stay level */
.shot-table td.shs-who { min-width: 110px; font-size: 12px; }
.shot-table td.shs-who div + div { margin-top: 2px; }
.shot-table .shs-nocard { color: var(--warn); }
/* (4/11) the shot's storyboard frame at the end of its row (panels.js shotFrameCell) */
.shot-table td.shs-frm { width: 112px; min-width: 112px; }
/* the frame column stays at the right edge while a narrow panel scrolls the table sideways */
.shot-table th.shs-frm-h, .shot-table td.shs-frm { position: sticky; right: 0; background: var(--card); box-shadow: -1px 0 0 var(--line); }
.shot-table tbody tr:hover td.shs-frm { background: var(--card); }
.shs-th { display: flex; align-items: center; justify-content: center; gap: 4px; width: 96px; aspect-ratio: 16 / 9; box-sizing: border-box; border-radius: 6px; border: 1px solid var(--line2); background: #171717; object-fit: cover; cursor: zoom-in; font-size: 11.5px; color: var(--muted); }
.btn.shs-th.shs-th-none { cursor: pointer; border: 1px dashed var(--line2); padding: 0; }
.shs-th.shs-th-none:hover { border-color: var(--brand); color: var(--brand); }
.shs-th.shs-th-busy { border-style: dashed; cursor: default; }
.shs-th.shs-th-err { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.35); color: #fca5a5; cursor: help; }
.shs-th.shs-th-old { border: 2px solid rgba(251,191,36,.75); }
.shs-tall .shs-th { width: 54px; aspect-ratio: 9 / 16; }
.shs-th-t { font-size: 11px; margin-top: 3px; }
.shot-table .shs-th-btn { margin-top: 3px; padding: 2px 6px; font-size: 11px; }
.shot-table .shs-th-old-t { color: var(--warn); }
/* a line's Vietnamese meaning under it (shot list, storyboard card, printable sheet): for reading only */
.dlg-vi { display: block; margin-top: 3px; font-style: italic; color: var(--dim); }
.dlg-vi::before { content: "↳ "; font-style: normal; opacity: .7; }
/* (6/11) Phân cảnh as cards (panels.js shotSceneHTML, "Thẻ | Bảng"): each shot a card as the Storyboard tab's, its
   frame on top (a vertical film's beside its text: side), the camera as chips, then who, what happens, the line and
   where in the frame, the rest under "xem thêm"; a click edits it. bare: frames hidden (Ẩn khung) */
.shc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 10px; padding: 10px 12px 12px; }
.shc-grid.side { grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); }
.shc { display: flex; flex-direction: column; min-width: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--card2); overflow: hidden; cursor: pointer; }
.shc:hover { border-color: var(--line2); }
.shc-grid.side .shc { flex-direction: row; align-items: flex-start; }
.shc-grid.side .shc-media { width: 92px; flex: none; margin: 8px 0 8px 8px; border-radius: 6px; }
.shc-media .sbf-tools .btn { padding: 3px 7px; font-size: 11px; }
.shc:hover .sbf-tools, .shc:focus-within .sbf-tools, .sbf-tools.on { opacity: 1; }
.shc-grid.side .sbf-tools { top: auto; bottom: 4px; right: 4px; left: 4px; justify-content: center; }
.shc-old { position: absolute; left: 6px; bottom: 6px; padding: 1px 6px; border-radius: 5px; font-size: 11px; font-weight: 600; color: var(--warn); background: var(--card); border: 1px solid var(--warn); }
.shc-err { color: var(--err); text-align: center; padding: 0 6px; }
.shc-body { display: grid; align-content: start; gap: 5px; padding: 8px 10px 10px; min-width: 0; flex: 1; font-size: 12px; line-height: 1.5; color: var(--muted); }
.shc-cam { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.shc-chip { padding: 0 7px; border: 1px solid var(--line2); border-radius: 999px; font-size: 11.5px; color: var(--muted); white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.shc-chip.main { color: var(--text); border-color: var(--brand); font-weight: 600; }
.shc-n { min-width: 20px; padding: 0 6px; border-radius: 5px; background: var(--line2); color: var(--text); font-weight: 600; font-size: 11.5px; text-align: center; }
.shc .shs-clash { color: var(--warn); font-weight: 700; cursor: help; }
.shc-f { min-width: 0; overflow-wrap: anywhere; }
.shc-f > b { display: block; font-size: 11px; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.shc-body > .shc-f { color: var(--text); }
.shc .shs-nocard { color: var(--warn); }
.shc-more { display: grid; gap: 5px; }
.shc-more-t { justify-self: start; display: inline-flex; align-items: center; gap: 4px; max-width: 100%; padding: 0; border: 0; background: none; color: var(--dim); font-size: 11.5px; text-align: left; }
.shc-more-t:hover { color: var(--brand); }
.shc-more.open .shc-more-t svg { transform: rotate(180deg); }
.shc-more .shc-f { color: var(--muted); }
.shc-add { align-self: start; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 90px; border: 1px dashed var(--line2); border-radius: 10px; background: none; color: var(--dim); font-size: 12px; }
.shc-add:hover { border-color: var(--brand); color: var(--brand); }
/* Storyboard: one card per scene, its frames (one picture per shot, in the film's frame) in a grid, each caption under
   its frame (panels.js storyboardHTML) */
.sbc-list { display: grid; gap: 12px; margin-top: 10px; }
.sbc { border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; }
.sbc-head { padding: 10px 12px 0; flex-wrap: wrap; }
.sbc-head > b, .sbc-head > .badge { white-space: nowrap; }
.sbc-meta { display: grid; gap: 1px; margin-top: 2px; font-size: 12px; color: var(--dim); }
.sbc-meta b { color: var(--text); font-weight: 600; }
.sbc-old { display: flex; gap: 10px; align-items: center; margin: 8px 12px 0; padding: 8px; border: 1px dashed var(--line); border-radius: 10px; font-size: 12px; }
.sbc-old img { width: 120px; border-radius: 6px; cursor: zoom-in; flex: none; }
.sbc-old .dim { flex: 1; }
/* Nháp 3D (KDO Phim Trường; 6/11 Prompt video's Nháp 3D tab, panels.js sdDraftCardHTML / sdDraftMarkHTML): a scene card
   as the Seedance tab's, the draft video on top; who is which mannequin, what Phim Trường said of it, its switch */
.sbd-people { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; color: var(--muted); font-size: 12px; }
.sbd-who { display: inline-flex; align-items: center; gap: 5px; }
.sbd-who i { width: 10px; height: 10px; border-radius: 3px; border: 1px solid rgba(0,0,0,.25); flex: none; }
.sdd-state { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 8px 12px 0; font-size: 12px; }
.sdd-state .spin { width: 12px; height: 12px; }
.sdd-body { cursor: default; }
.sdd-note { margin-top: 6px; font-size: 12px; line-height: 1.45; color: var(--muted); }
.sdd-note b { color: var(--text); font-weight: 600; }
.sdd-ok { color: var(--ok, #2ca02c); }
.sdd-story { white-space: pre-wrap; font-size: 13px; line-height: 1.55; max-height: 55vh; overflow-y: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.sdd-list { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; line-height: 1.5; }
/* (6/11) 3D Shot Composer: each shot's 3D picture on the scene's card, its seconds and "Vị trí trong khung" under it */
.sdd-shots { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; padding: 10px 12px 0; }
.sdd-cap { font-size: 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sdd-cap > b { display: block; }
/* (7/11) Khớp phân cảnh: what a shot's 3D picture does against its card, the badge of a scene matching 100% */
.sdd-miss { font-size: 12px; line-height: 1.4; color: var(--warn); }
.sdd-match { background: rgba(44,160,44,.16); color: var(--ok, #2ca02c); }
/* (7/11, stage 3) what in a card holds a shot back, and Sửa thẻ's proposal on the scene's card */
.sdd-tied { margin-top: 2px; color: var(--muted); }
.sdd-fix { display: grid; gap: 6px; margin: 8px 12px 0; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 12px; }
.sdd-fix .sdd-state { padding: 0; }
.sdd-fix-ask { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; }
.sdd-fix-ask .sdc-err { flex: 1 1 100%; margin: 0; }
.sdd-fix-t { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.sdd-fix-why { line-height: 1.45; }
.sdd-fix-rows { display: grid; gap: 6px; }
.sdd-fix-row { display: grid; gap: 2px; line-height: 1.4; }
.sdd-fix-was { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(127,127,127,.5); overflow-wrap: anywhere; }
.sdd-fix-now { color: var(--text); overflow-wrap: anywhere; }
.sdd-fix-note { line-height: 1.4; }
.sdd-fix-btns { display: flex; flex-wrap: wrap; gap: 6px; }
/* (7/11, KDO 3D Shot Composer stage 2) Sa bàn 3D on a place's card: each view's picture beside its render */
.s3d { display: grid; gap: 8px; }
.s3d-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 12px; }
.s3d-busy { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.s3d-view { display: grid; gap: 4px; }
.s3d-view-t { font-size: 12px; }
.s3d-view .sdd-shots { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; }
.s3d-acts { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.s3d-acts .ctl { flex: 1 1 220px; min-width: 0; }
/* (7/11, Phim Trường 1.15) Bối cảnh theo ảnh: the place picture sent beside the room laid out from it */
.sdd-place, .sdd-cuts { display: grid; gap: 6px; padding: 10px 12px 0; }
.sdd-place-t { font-size: 12px; }
.sdd-place .sdd-shots { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0; }
/* (7/11, no 3D video on the card any more) each shot's picture, where each person is: bigger */
.sdd-cuts .sdd-shots { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); padding: 0; }
.sdc-draft { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; padding: 8px 12px 0; font-size: 12px; }
.sdc-draft .check-row { align-self: center; }
.sdc-draft .dim { font-size: 12px; line-height: 1.4; }
.sbf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr)); gap: 12px; padding: 10px 12px 12px; }
.sbf-grid.tall { grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr)); }
.sbf { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.sbf-media { position: relative; background: #111; border-radius: 8px; overflow: hidden; display: grid; place-items: center; }
.sbf-media img { width: 100%; height: 100%; object-fit: contain; display: block; cursor: zoom-in; }  /* never stretched */
.sbf-empty { display: grid; justify-items: center; gap: 4px; color: var(--dim); font-size: 12px; }
.sbf-num { position: absolute; top: 6px; left: 6px; min-width: 20px; text-align: center; padding: 1px 6px; border-radius: 5px;
  background: rgba(0,0,0,.7); color: #fff; font-size: 11px; font-weight: 700; }
.sbf-tools { position: absolute; top: 5px; right: 5px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.sbf:hover .sbf-tools, .sbf:focus-within .sbf-tools { opacity: 1; }
@media (hover: none) { .sbf-tools { opacity: 1; } }
.sbf-tools .btn { background: rgba(17,17,17,.8); border-color: transparent; color: #fff; }
.sbf-cap { font-size: 12px; line-height: 1.45; color: var(--muted); }
.sbf-cap > b { color: var(--text); font-weight: 600; }
.sbf-warn { font-size: 12px; line-height: 1.4; color: #fbbf24; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.3);
  border-radius: 7px; padding: 4px 7px; }
.sbf-warn[hidden] { display: none; }
.sbf-stale { font-size: 12px; line-height: 1.4; color: var(--muted); background: rgba(139,92,246,.08); border: 1px solid rgba(139,92,246,.3);
  border-radius: 7px; padding: 4px 7px; }
/* Storyboard → Sửa khung: the frame beside what to change */
.sbe { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.sbe.tall { grid-template-columns: minmax(0, .7fr) minmax(0, 1fr); }
@media (max-width: 720px) { .sbe, .sbe.tall { grid-template-columns: minmax(0, 1fr); } }
.sbe-img { background: #111; border-radius: 10px; overflow: hidden; display: grid; place-items: center; max-height: 62vh; }
.sbe-img img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sbe-side { display: grid; gap: 10px; }
.sbe-cap { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--muted); }
.sbe-label { display: grid; gap: 6px; font-size: 13px; }
.sbe-label textarea { width: 100%; resize: vertical; }
.sbe-tip { margin: 0; font-size: 12px; line-height: 1.5; }
/* Storyboard → viết lại (1/11): the ✎ dialog's ways (Sửa ảnh, Nhờ AI viết lại cú máy, Tự sửa prompt vẽ), one shown
   at a time, and a rewrite's "Viết xong: tự vẽ lại" choice (panels.js sbEditModal, sbRedrawHTML) */
.sbe-ways { flex-wrap: wrap; }
.sbe-ways button { flex: 1 1 auto; justify-content: center; }
.sbe-pane { display: grid; gap: 10px; }
.sbe-prompt { min-height: 220px; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 12px; }
.sbe-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; }
.sbe-warn { color: var(--warn); }
.sbe-img .sbf-empty { padding: 24px 0; }
@media (max-width: 720px) { .sbe:not([data-way="image"]) .sbe-img { max-height: 26vh; } }
.sbre-pick { gap: 6px; }
.sbre-pick .len-opt { padding: 8px 10px; }
.form .sbre-pick .len-opt { flex-direction: row; gap: 10px; font-size: 13px; color: var(--text); font-weight: 400; }  /* not .form label's stacked field look */
.len-opt b .costtag { color: var(--warn); font-size: 11px; }
.sbre-note { margin: 0; font-size: 12px; line-height: 1.5; }
.sbre-group { border: 1px solid var(--line2); border-radius: 10px; padding: 10px 12px; gap: 10px; }  /* Làm lại cảnh: what "Nhờ Trợ lý viết lại" uses */
.sbre-head { margin: 0; font-size: 12.5px; line-height: 1.5; }
.sbe-more { display: grid; gap: 4px; }
.sbe-more code { display: block; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 11px; line-height: 1.45; padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card2); color: var(--muted); }
.shs.flash { animation: flash 1.2s ease-out; }
/* Storyboard → In / lưu PDF: the episode's frames with their captions over the page; printing shows only them */
.sb-print { position: fixed; inset: 0; z-index: 1000; overflow: auto; background: #f4f4f4; color: #111; }
.sb-print-bar { position: sticky; top: 0; display: flex; gap: 8px; align-items: center; padding: 10px 16px; background: #fff;
  border-bottom: 1px solid #ddd; font-size: 13px; }
.sb-print-bar .btn { background: #fff; color: #111; border-color: #ccc; }  /* white paper in both themes */
.sb-print-bar .btn:hover { background: #f0f0f0; }
.sb-print-bar .btn.primary { background: #18181b; color: #fff; border-color: #18181b; }
.sb-print-bar .btn.primary:hover { background: #3f3f46; }
.sb-print-page { max-width: 1000px; margin: 16px auto; padding: 24px; background: #fff; font: 14px/1.5 "Segoe UI", Arial, sans-serif; }
.sb-print-page h1 { font-size: 18px; margin: 0 0 16px; }
.sb-print-page h2 { font-size: 14px; margin: 0 0 8px; }
.sb-print-page section { margin: 0 0 28px; }
.sbp-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.sb-print.tall .sbp-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sbp-grid figure { margin: 0; break-inside: avoid; page-break-inside: avoid; }
.sbp-frame { position: relative; background: #e9e9e9; display: grid; place-items: center; overflow: hidden; color: #888; font-size: 12px; }
.sbp-frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.sbp-frame b { position: absolute; top: 6px; left: 6px; padding: 1px 6px; border-radius: 4px; background: rgba(0,0,0,.7); color: #fff; font-size: 11px; }
.sbp-grid figcaption { margin-top: 6px; font-size: 12.5px; line-height: 1.45; }
.sb-print-page .talk { color: #555; font-size: 12px; margin-left: 12px; }
.sb-print-page .talk.dlg-vi { color: #777; margin-top: 0; }
@media print {
  html, body { height: auto !important; overflow: visible !important; background: #fff !important; }
  body > *:not(.sb-print) { display: none !important; }
  .sb-print { position: static; overflow: visible; background: #fff; }
  .sb-print-bar { display: none; }
  .sb-print-page { max-width: none; margin: 0; padding: 0; }
}/* the scenes in a frame per outline beat (panels.js sdBeatsHTML) */
.sd-beat { margin-top: 14px; padding: 12px; border: 1px solid var(--line2); border-radius: 14px; }
.sd-beat-head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.sd-beat-head b { font-size: 13.5px; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; color: var(--text); }
.sd-beat-head .dim { font-size: 12px; }
.sdc { border: 1px solid var(--line); border-radius: 12px; background: var(--card); overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.sdc:hover, .acard:hover { border-color: var(--brand); box-shadow: 0 0 0 1px rgba(139,92,246,.45), 0 6px 22px rgba(139,92,246,.12); }
.sdc-media { position: relative; aspect-ratio: 16 / 9; background: #141414; display: grid; border-bottom: 1px solid var(--line); }
.sdc-empty { place-self: center; display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--dim); font-size: 12px; }
.sdc-refrow { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 12px 0; cursor: pointer; }
.sdc-refrow .sdc-th { width: 36px; height: 36px; border-color: var(--line2); color: var(--muted); }
.sdc-th.k-environments { background-size: cover; background-position: center; }
.sdc-media video { width: 100%; height: 100%; object-fit: cover; background: #000; cursor: auto; }
.sdc-media .mc-state { place-self: center; }
.sdc-th { width: 40px; height: 40px; border-radius: 8px; overflow: hidden; border: 1.5px solid rgba(255,255,255,.75); background: #2a2a2a no-repeat center / cover; display: grid; place-items: center; color: #fff; font-size: 13px; font-weight: 700; flex: none; }
.sdc-th.k-characters { background-size: auto 230%; background-position: 7% 29%; }  /* the sheet's big portrait: the face */
.sdc-th.k-props { background-size: auto 140%; background-position: 12% 50%; }  /* the sheet's hero shot, on the left */
.sdc-th.more { font-size: 11px; }
.sdc-body { padding: 10px 12px 4px; cursor: pointer; flex: 1; }
.sdc-title { display: flex; align-items: center; gap: 7px; font-size: 13px; }
.sdc-title .dim { font-size: 12px; }
.sdc-refs { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sdc-foot { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 4px; padding: 4px 8px 8px 12px; font-size: 11px; }
.sdc-foot .btn { padding: 3px 7px; }
/* Prompt video → "+" after each scene card (a scene added there is 001.1), in a lane of its own to the card's right
   (under it when the cards stand one a row), so it never sits on a frame: the lane is the gap between the cards */
.sdc-wrap { position: relative; display: flex; min-width: 0; padding-right: 38px; }
.sdc-wrap > .sdc { flex: 1; min-width: 0; }
.sdc-plus { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); z-index: 3; width: 26px; height: 26px; padding: 0;
  border-radius: 50%; border: 1.5px dashed var(--line2); background: var(--bg); color: var(--muted); display: grid; place-items: center;
  cursor: pointer; opacity: .65; transition: opacity .15s, border-color .15s, color .15s; }
.sdc-wrap:hover .sdc-plus, .sdc-plus:focus-visible { opacity: 1; }
.sdc-plus:hover { border-style: solid; border-color: var(--brand); color: var(--brand); }
@media (hover: none) { .sdc-plus { opacity: 1; } }
.sdc-grid { container-type: inline-size; column-gap: 0; }
@container (max-width: 559px) {  /* one card a row (two need 2 × 280px): the "+" sits in a lane under the card */
  .sdc-wrap { padding-right: 0; padding-bottom: 32px; margin-bottom: -6px; }
  .sdc-plus { top: auto; bottom: 0; right: 50%; transform: translateX(50%); }
}
.sdc-added { font-size: 11px; padding: 1px 7px; border-radius: 999px; background: rgba(139,92,246,.16); color: #c4b5fd; white-space: nowrap; }
.sdi-kinds { display: grid; gap: 6px; }
.sdm-edit { width: 100%; min-height: 220px; font: 12.5px/1.55 ui-monospace, Consolas, monospace; resize: vertical; }
.sdm-refs { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-bottom: 12px; }
.sdm-ref { display: flex; flex-direction: column; gap: 3px; font-size: 12px; }
.sdm-ref img, .sdm-noimg { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #222; display: grid; place-items: center; color: var(--dim); }
.sdm-ref .dim { font-size: 12px; }
/* a scene's pictures picked by hand (22/10): ✕ Bỏ, ⇄ Đổi, + Thêm ảnh, and the cards' chosen pictures to pick from */
.sdm-refs-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12.5px; }
.sdm-refs-head .dim { font-size: 12px; }
.sdm-ref.on img, .sdm-ref.on .sdm-noimg { outline: 2px solid var(--brand); outline-offset: 1px; }
.sdm-ref-acts { display: flex; gap: 4px; margin-top: 2px; }
.sdm-ref-acts .btn { padding: 2px 8px; height: auto; font-size: 11.5px; }
.sdm-add { align-items: center; justify-content: center; min-height: 96px; border: 1px dashed var(--line); border-radius: 8px;
  background: transparent; color: var(--dim); cursor: pointer; font: inherit; }
.sdm-add:hover, .sdm-add.on { border-color: var(--brand); color: var(--text); }
.sdm-ref-warn { margin: 0 0 10px; font-size: 12px; color: #fbbf24; }
.sdm-ref-note { margin: 0 0 10px; font-size: 12px; line-height: 1.45; }
.sdm-picker { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; max-height: 340px; overflow: auto; }
.sdm-pick-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.sdm-pick-top .dim { font-size: 12px; }
.sdm-pick-h { margin: 10px 0 6px; font-size: 11.5px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; }
.sdm-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.sdm-pick-i { display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px;
  background: transparent; color: inherit; font: inherit; font-size: 11.5px; text-align: left; cursor: pointer; }
.sdm-pick-i:hover { border-color: var(--brand); }
.sdm-pick-i img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: #222; }
.sdm-pick-i span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sdm-text { max-height: 46vh; overflow: auto; cursor: auto; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #181818; }
.sd { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #1d1d1d; }
.sd-top { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.sd-top .btn { padding: 3px 7px; }
.sd-text { margin-top: 8px; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.55; color: #cfcfcf; white-space: pre-wrap; word-break: break-word; cursor: pointer; }
.sd-text.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.sd-warns { margin-top: 6px; font-size: 12px; color: var(--warn); display: flex; flex-direction: column; gap: 2px; }
.sd-flag { color: var(--warn); }
/* (12/11) "N cảnh có cảnh báo:" with its scenes, each a button to its card (panels.js warnListHTML / warnGo) */
.warn-list { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 12px; min-width: 0; }
.warn-go { padding: 1px 7px; border: 1px solid var(--warn); border-radius: 999px; background: none; color: var(--warn); font-size: 11.5px; line-height: 1.5; cursor: pointer; }
.warn-go:hover { background: rgba(245,158,11,.12); }
.warn-go.more { border-style: dashed; }
.sdc.flash, .sd.flash { animation: flash 1.2s ease-out; }

/* Google Flow hand-off */
.flow-steps { margin: 0 0 14px; padding-left: 20px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.flow-steps b { color: var(--text); }
.flow-btns { display: flex; gap: 8px; margin: 10px 0 4px; }
.flow-btns a.btn { text-decoration: none; }
.flow-refs { display: flex; flex-wrap: wrap; gap: 10px; }
.flow-ref { width: 92px; text-decoration: none; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; gap: 4px; }
.flow-ref img { width: 92px; height: 92px; object-fit: cover; border-radius: 9px; border: 1px solid var(--line); display: block; }
.flow-ref span { display: flex; align-items: center; gap: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-ref:hover { color: var(--text); }
.flow-drop { margin-top: 16px; width: 100%; border: 1.5px dashed #4a4a4a; border-radius: 12px; background: #1b1b1b; color: var(--muted); padding: 22px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12px; }
.flow-drop b { color: var(--text); font-size: 13.5px; }
.flow-drop:hover, .flow-drop.over { border-color: var(--brand); color: var(--text); background: #202020; }
.scene-vid { margin-top: 8px; max-width: 220px; border-radius: 9px; overflow: hidden; background: #121212; }
.scene-vid video { width: 100%; display: block; max-height: 320px; }
.scene-vid .mc-state { padding: 12px; }
.notice { margin-top: 8px; font-size: 12px; color: var(--warn); line-height: 1.4; }
.ref-thumb.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border: 1px dashed #4a4a4a; color: var(--muted); }
.ref-thumb.add:hover { border-color: var(--brand); color: #fff; }
.conn-sub { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin: 22px 0 10px; }
.conn-head + .conn-sub { margin-top: 4px; }

/* ---------- genre DNA ---------- */
.dna-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.dna-new { min-height: 170px; }
.dna-card { border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 14px; cursor: pointer; display: flex; flex-direction: column; gap: 6px; transition: border-color .15s, transform .15s; }
.dna-card:hover { border-color: #444; transform: translateY(-2px); }
.dna-card.busy { border-color: rgba(139,92,246,.45); }
.dna-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.dna-top b { font-size: 14px; }
.dna-card p { margin: 0; color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.dna-prog { font-size: 12px; }
.dna-meta { display: flex; gap: 10px; color: var(--dim); font-size: 12px; margin-top: auto; padding-top: 6px; }
.badge.bad { color: #fca5a5; border-color: rgba(248,113,113,.4); }
.dna-pick { display: flex; gap: 8px; align-items: center; }
.dna-pick select { flex: 1; min-width: 0; }
.dna-sum { margin: 6px 0 0; font-size: 12px; line-height: 1.45; }
.dna-ic { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }
.dna-body { flex: 1; display: flex; min-height: 0; }
.dna-side { width: 270px; flex: none; border-right: 1px solid var(--line); overflow-y: auto; padding: 12px 10px; }
.dna-group { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); margin: 14px 8px 6px; }
.dna-nav { width: 100%; display: flex; align-items: center; gap: 8px; background: none; border: 0; border-radius: 8px; padding: 7px 8px; text-align: left; font-size: 12.5px; color: var(--muted); }
.dna-nav:hover { background: #222; color: var(--text); }
.dna-nav.on { background: #2a2a2a; color: #fff; }
.dna-nav .id { font: 700 10.5px ui-monospace, Consolas, monospace; color: var(--dim); width: 28px; flex: none; display: flex; }
.dna-nav .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dna-nav .n { font-size: 11px; color: var(--dim); }
.dna-nav .n.empty { color: var(--warn); }
.dna-main { flex: 1; overflow-y: auto; padding: 22px 28px; }
.dna-block { max-width: 900px; }
.dna-block.locked { opacity: .45; pointer-events: none; }
.dna-block h3 { margin: 0; font-size: 17px; }
.dna-lbl { display: flex; flex-direction: column; gap: 5px; font-size: 11.5px; color: var(--muted); font-weight: 600; }
.dna-busy { display: flex; align-items: center; gap: 12px; border: 1px solid rgba(139,92,246,.4); background: rgba(139,92,246,.08); border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.dna-busy > div:nth-child(2) { flex: 1; }
.rules { display: flex; flex-direction: column; gap: 10px; }
.rule { display: grid; grid-template-columns: 30px 1fr 28px; gap: 8px; border: 1px solid var(--line); background: #1b1b1b; border-radius: 10px; padding: 10px; }
.rule-n { font: 700 11px ui-monospace, Consolas, monospace; color: var(--dim); padding-top: 4px; }
.rule-f { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 8px; }
.rule-f label { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: var(--dim); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.rule-f textarea { font-size: 12.5px; text-transform: none; letter-spacing: 0; }
@media (max-width: 980px) { .rule-f { grid-template-columns: 1fr; } .dna-side { width: 200px; } }
.ref-video { border: 1px solid var(--line); border-radius: 9px; background: #1b1b1b; margin-bottom: 8px; }
.ref-video summary { cursor: pointer; padding: 8px 11px; display: flex; align-items: center; gap: 8px; font-size: 12.5px; list-style: none; }
.ref-video summary::-webkit-details-marker { display: none; }
.ref-video summary a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ref-body { padding: 4px 12px 12px; font-size: 12.5px; color: #cfcfcf; white-space: pre-wrap; max-height: 420px; overflow: auto; }
.link-status { font-size: 12px; font-weight: 600; }
.link-ok { color: var(--ok); }
.link-bad { color: #fca5a5; }
.brief-opt summary { cursor: pointer; color: var(--muted); font-size: 12px; font-weight: 600; margin-bottom: 6px; }
.brief-opt summary:hover { color: var(--text); }
.brief-opt textarea { width: 100%; }
.cc-row { display: flex; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); font-size: 12.5px; }
.cc-row b { width: 110px; flex: none; color: var(--muted); font-weight: 600; }
.cc-login { margin-top: 10px; border: 1px solid rgba(251,191,36,.35); background: rgba(251,191,36,.06); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; display: flex; flex-direction: column; gap: 8px; }
.cc-cmd { margin: 0; background: #121212; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 11.5px; white-space: pre-wrap; word-break: break-all; }
.cc-toggle { flex-direction: row !important; align-items: center; justify-content: space-between; gap: 10px; align-self: end; }
.key-ok { color: var(--ok); font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.dna-sw { background: linear-gradient(135deg, var(--brand), var(--brand2)); color: #fff; }
.pcard .thumb { color: rgba(255,255,255,.85); }
.pcard .pdna { position: absolute; left: 10px; bottom: 10px; background: rgba(0,0,0,.55); border-color: transparent; color: #fff; display: inline-flex; gap: 4px; align-items: center; }

/* delivery check */
.audit-status { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 10px 12px; border-radius: 10px; }
.audit-status span { font-weight: 400; font-size: 12.5px; color: var(--muted); }
.audit-status.pass { color: var(--ok); background: rgba(110,231,183,.08); border: 1px solid rgba(110,231,183,.3); }
.audit-status.fail { color: var(--err); background: rgba(248,113,113,.08); border: 1px solid rgba(248,113,113,.3); }
.audit-sub { margin: 14px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); }
.audit-list { margin: 0; padding-left: 18px; font-size: 12.5px; line-height: 1.5; display: flex; flex-direction: column; gap: 4px; }
.audit-list.err li { color: #fca5a5; }
.audit-list.rev li { color: #d6d6d6; }
.audit-tl { width: 100%; border-collapse: collapse; font-size: 12px; }
.audit-tl td { padding: 4px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.audit-tl td:first-child { white-space: nowrap; color: #c4b5fd; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 11px; }
.sd-vers { margin-bottom: 8px; width: fit-content; }
.omni-refs { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.omni-refs .label-tag { margin-top: 0; cursor: copy; }

/* film genres & character worlds */
.pcard .pshared { position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.6); border-color: transparent; color: #fde68a; }
.signin { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--bg); }
.signin-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 12px; padding: 28px; border: 1px solid var(--line2); border-radius: 14px; background: #1c1c1c; box-shadow: 0 20px 60px rgba(0,0,0,.45); }
.signin-card .logo { margin-bottom: 6px; }
.signin-card .logo-img { height: 60px; }
.signin-card h2 { margin: 0; font-size: 19px; }
.signin-card p { margin: 0; font-size: 13px; }
.signin-card label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; color: var(--muted); }
.signin-card .btn { justify-content: center; height: 38px; margin-top: 4px; }
.signin-err { color: #fca5a5; font-size: 12.5px; }
.signin-ok { color: #6ee7b7; font-size: 13px; line-height: 1.5; }
.signin-alt { text-align: center; color: var(--dim); }
.signin-alt a { color: var(--text); }
.user-btn { position: relative; }
.user-dot { position: absolute; left: 20px; top: 0; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.users-wait { border: 1px solid rgba(245,158,11,.4); background: rgba(245,158,11,.08); border-radius: 10px; padding: 10px 12px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.uw-row { display: flex; align-items: center; gap: 8px; }
.user-btn { gap: 7px; padding-left: 5px; flex: none; }
.user-av { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12px; font-weight: 700; }
.user-nm { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.users-top { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 12px; }
.users-top p { margin: 0; flex: 1; font-size: 12.5px; }
table.users { width: 100%; border-collapse: collapse; font-size: 13px; }
table.users th { text-align: left; font-weight: 600; color: var(--dim); font-size: 11.5px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
table.users td { padding: 8px; border-bottom: 1px solid var(--line); }
table.users tr.off td { opacity: .55; }
.u-use { display: flex; flex-direction: column; gap: 2px; font-size: 12px; }
.user-dot.warn { background: #f59e0b; color: #1b1b1b; }
.conn-foot { margin: 12px 0 0; font-size: 12px; line-height: 1.5; }
/* Kết nối của tôi in its dialog (account menu): the dialog's title says it */
.myconn-box .conn { margin-top: 0; padding-top: 0; border-top: 0; }
.myconn-box .conn-head h2 { display: none; }
.myconn-box .conn-head .lead { font-size: 13px; }
.del-list { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.6; }
/* account groups (groups.js) */
.grp-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 7px; vertical-align: 0; flex: none; }
table.users tr.u-grp td { background: rgba(255,255,255,.03); padding-top: 10px; font-size: 12.5px; border-bottom: 1px solid var(--line2); }
table.users .u-sel { width: 28px; padding-right: 0; }
.users-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 0 0 10px; }
.users-tools input.ctl { width: min(260px, 100%); }
.users-tools select.ctl { width: auto; min-width: 160px; }
.grp-colors { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 4px; }
.grp-color { display: inline-flex; align-items: center; gap: 2px; font-size: 12.5px; font-weight: 400; cursor: pointer; }
.grp-color input { margin: 0 4px 0 0; }
.acc-tabs { margin: 0 0 12px; }
/* Sổ kinh nghiệm (Tài khoản tab, admins) */
.lb-head { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; font-size: 12.5px; }
.lb-head .opt-row { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.lb-head .opt-row p { margin: 2px 0 0; color: var(--dim); font-size: 12px; }
table.lb-users tr.lb-sel td { background: rgba(124,77,255,.08); }
table.lb-users .lb-acts { text-align: right; }
.lb-book { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 8px; }
.lb-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.lb-sec { font-size: 11.5px; font-weight: 600; color: var(--dim); text-transform: uppercase; letter-spacing: .04em; margin-top: 4px; }
.lb-entry { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.lb-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; }
.lb-txt b { overflow-wrap: anywhere; }
.lb-txt .dim { font-size: 12px; }
.lb-txt summary { cursor: pointer; color: var(--muted); font-size: 11.5px; }
.lb-ex { font-family: ui-monospace, Consolas, monospace; font-size: 12px; color: var(--muted); background: rgba(255,255,255,.03); border-radius: 6px; padding: 5px 7px; margin-top: 4px; overflow-wrap: anywhere; }
.lb-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.lb-more summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 4px 0; }
.lb-more > .lb-entry { margin-top: 6px; }
.lb-scroll { overflow-x: auto; }
table.lb-rates td, table.lb-rates th { white-space: nowrap; font-size: 12px; }
.lb-pre { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 55vh; overflow: auto; margin: 0; padding: 10px 12px;
  font-family: ui-monospace, Consolas, monospace; font-size: 12px; line-height: 1.5; color: var(--muted);
  background: rgba(255,255,255,.03); border: 1px solid var(--line); border-radius: 8px; }
@media (max-width: 640px) {
  .lb-entry { flex-wrap: wrap; }
  .lb-btns { flex-basis: 100%; justify-content: flex-start; }
  table.lb-users th:nth-child(4), table.lb-users td:nth-child(4), table.lb-users th:nth-child(5), table.lb-users td:nth-child(5) { display: none; }
  table.lb-users th:nth-child(2), table.lb-users td:nth-child(2) { display: none; }  /* room for "Trợ lý dùng sổ" */
  table.lb-users th, table.lb-users td { padding-left: 6px; padding-right: 6px; }
  .acc-tabs { display: flex; max-width: 100%; overflow-x: auto; }  /* four tabs are wider than a phone */
}
.modal.xwide { width: min(1120px, 100%); }
/* the Chi tiêu tab (spend.js) */
.spd { display: flex; flex-direction: column; gap: 12px; font-size: 13px; }
.spd-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spd-bar select.ctl { width: auto; min-width: 150px; }
.spd-bar a.btn { text-decoration: none; }
.spd-alert { border: 1px solid rgba(245,158,11,.45); background: rgba(245,158,11,.08); border-radius: 10px; padding: 8px 12px; display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; }
.spd-warn { margin: 0; color: var(--warn); font-size: 12.5px; }
.spd-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(140px, 100%), 1fr)); gap: 10px; }
.spd-kpis > div { background: var(--card2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.spd-kpis span { color: var(--muted); font-size: 12px; }
.spd-kpis b { font-size: 20px; font-variant-numeric: tabular-nums; }
.spd-kpis small { color: var(--dim); font-size: 11.5px; }
.spd-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.spd-legend span { display: inline-flex; align-items: center; gap: 5px; }
.spd-legend i, .spd-sq { width: 10px; height: 10px; border-radius: 2px; display: inline-block; flex: none; }
.spd-sq { margin-right: 6px; vertical-align: -1px; }
.spd-chart { position: relative; display: flex; align-items: stretch; gap: 3px; height: 150px; padding-top: 18px; border-bottom: 1px solid var(--line2); }
.spd-axis { position: absolute; left: 0; top: 0; font-size: 11px; color: var(--dim); }
.spd-col { flex: 1; min-width: 0; display: flex; flex-direction: column-reverse; align-items: center; border-radius: 3px 3px 0 0; }
.spd-col:hover { background: rgba(255,255,255,.05); }
.spd-col i { display: block; width: min(100%, 40px); min-height: 1px; flex: none; }
.spd-col i + i { border-bottom: 1px solid #1f1f1f; }
.spd-col i:last-child { border-radius: 3px 3px 0 0; }
.spd-days { display: flex; gap: 3px; font-size: 11px; color: var(--dim); margin-top: 3px; }
.spd-days span { flex: 1; min-width: 0; text-align: center; }
.spd-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 12px; }
.spd-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.spd-card h4 { margin: 0 0 6px; font-size: 13px; }
table.spd-t { width: 100%; border-collapse: collapse; }
table.spd-t td { padding: 5px 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.spd-t tr:last-child td { border-bottom: 0; }
table.spd-t td.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.spd-t td.num.warn { color: var(--warn); }
table.spd-t td.num.ok { color: var(--ok); }
table.spd-t tr.free td { color: var(--dim); }
.spd-meter-td { width: 38%; }
.spd-meter { height: 6px; border-radius: 3px; background: var(--card2); overflow: hidden; }
.spd-meter i { display: block; height: 100%; background: #2a78d6; border-radius: 3px; }
.spd-foot { margin: 6px 0 0; font-size: 12px; }
table.spd-t tr.spd-link { cursor: pointer; }
table.spd-t tr.spd-link:hover td { background: rgba(255,255,255,.04); }
.spd-more { color: var(--dim); display: inline-flex; vertical-align: -1px; }
.spd-scroll { max-height: 380px; overflow: auto; }
table.spd-lines th { text-align: left; font-weight: 600; color: var(--dim); font-size: 11.5px; padding: 4px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #1f1f1f; }
table.spd-lines th.num { text-align: right; }
table.spd-lines td { font-size: 12px; }
.spd-nowrap { white-space: nowrap; }
.spd-none { margin: 0; }
.spp { display: flex; flex-direction: column; gap: 10px; }
.spp-row { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.spp-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr)); gap: 8px; margin-top: 6px; }
.spp-fields label { display: flex; flex-direction: column; justify-content: space-between; gap: 4px; font-size: 11.5px; color: var(--muted); }  /* inputs in line, whatever the labels' lines */
.pcard .pworld { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.55); border-color: transparent; color: #fff; display: inline-flex; gap: 4px; align-items: center; max-width: 60%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fg-modal { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.fg-modal .form { grid-template-columns: 1fr; }
.fg-guide { border: 1px solid var(--line); background: #181818; border-radius: 10px; padding: 10px 14px; font-size: 12.5px; line-height: 1.55; color: #d0d0d0; max-height: 64vh; overflow: auto; }
.fg-guide summary { cursor: pointer; font-weight: 600; color: #c4b5fd; display: flex; align-items: center; gap: 6px; }
.fg-guide h5 { margin: 12px 0 4px; font-size: 12.5px; color: #fff; }
.fg-guide ol, .fg-guide ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 2px; }
.fg-guide p { margin: 8px 0; }
.fg-example { border-left: 3px solid rgba(139,92,246,.5); padding: 2px 0 2px 10px; margin: 6px 0 10px; color: #bdbdbd; }
.fg-example p { margin: 4px 0; }
.fg-example .fg-grp { margin: 10px 0 3px; font-weight: 700; color: #c4b5fd; font-size: 12px; letter-spacing: .03em; }
/* Film genre: the six story blocks under the brief */
.fg-blocks { border-top: 1px solid var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.fg-bhead { display: flex; align-items: center; gap: 10px; font-size: 14px; }
.fg-bhead b { display: inline-flex; align-items: center; gap: 6px; color: #c4b5fd; }
.fg-bnote { margin: 0; font-size: 12.5px; line-height: 1.5; }
.fg-bacts { display: flex; gap: 8px; align-items: center; }
.fg-bacts .ctl { flex: 1; height: 34px; }
.fg-st { font-size: 11.5px; color: var(--dim); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
.fg-st.ok { color: #86efac; border-color: rgba(134,239,172,.35); }
.fg-st.busy { color: #c4b5fd; border-color: rgba(139,92,246,.45); }
.fg-block { border: 1px solid var(--line); border-radius: 10px; background: #1a1a1a; padding: 8px 12px; }
.fg-block summary { cursor: pointer; display: flex; align-items: center; gap: 6px; font-size: 13.5px; list-style: none; }
.fg-block summary::-webkit-details-marker { display: none; }
.fg-block[open] summary { margin-bottom: 8px; }
.fg-block .fld { margin-top: 6px; }
.fg-fb { display: flex; gap: 8px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px dashed #333; }
.fg-fb .ctl { flex: 1; height: 34px; }
.modal.xl .fg-modal .fg-block textarea.ctl { min-height: 0; font-size: 13.5px; }

/* the project's World tab */
.world-tab .form { grid-template-columns: 1fr; }
.world-note { font-size: 12.5px; margin: 0 0 12px; line-height: 1.5; }
.world-save { display: flex; align-items: center; gap: 10px; margin-top: 12px; }
.world-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; color: #c4b5fd; background: rgba(139,92,246,.14); border-radius: 999px; padding: 2px 9px; white-space: nowrap; min-width: 0; max-width: 260px; }
.world-chip span { overflow: hidden; text-overflow: ellipsis; }

/* Claude Code card: the long-lived token */
.cc-token { border: 1px solid rgba(139,92,246,.45); background: rgba(139,92,246,.07); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 12.5px; line-height: 1.5; }
.cc-token.ok { border-color: rgba(110,231,183,.35); background: rgba(110,231,183,.05); }
.cc-token b { display: inline-flex; align-items: center; gap: 6px; }
.cc-steps { margin: 0 0 10px; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.cc-steps .cc-cmd { margin: 6px 0; }

/* Characters / Environments / Props: one big card per family */
.acards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr)); gap: 14px; align-items: start; }
.acard { border: 1px solid var(--line); background: var(--card); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; transition: border-color .15s, box-shadow .15s; }
.acard-cover { aspect-ratio: 16 / 9; background: #f4f4f4; position: relative; display: grid; place-items: center; overflow: hidden; }
.acard-cover img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; display: block; }
.acard-empty { color: #8a8a8a; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 12.5px; }
/* a card with no picture: where to make one (its two buttons are under the looks, 31/10: once, not twice) */
.acard-empty-hint { font-size: 12px; color: var(--dim); text-align: center; padding: 0 12px; }
.acard-err { max-width: 92%; margin-top: 4px; padding: 6px 10px; border-radius: 8px; background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.35); color: #fca5a5; font-size: 12px; line-height: 1.45; text-align: center; }
.acard-cover:has(.acard-empty) { background: #171717; }
.acard-looks, .acard-acts, .acard-thumbs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); align-items: center; }
.acard-thumbs { flex-wrap: nowrap; overflow-x: auto; }
.acard-acts .grow { flex: 1; }
.look { display: inline-flex; align-items: center; gap: 7px; border: 1px solid var(--line2); background: #1d1d1d; border-radius: 9px; padding: 3px 10px 3px 3px; font-size: 12px; font-weight: 600; color: var(--muted); max-width: 100%; cursor: pointer; }
.look span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.look img, .look .look-dot { width: 26px; height: 26px; border-radius: 6px; object-fit: cover; flex: none; background: #2a2a2a; }
.look.on { color: #fff; background: #2b2b2b; border-color: #4a4a4a; }
.look.add { border-style: dashed; padding: 6px 12px; }
/* (6/11) a place's views (panels.js viewsRowHTML): tiles like the looks', the one shown picked, × on hover */
.acard-looks.acard-views { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
.acard-views .look.add { grid-column: 1 / -1; justify-content: center; }
.acard-views .view-board { grid-column: 1 / -1; }  /* (8/11) the 4-angle picture's tile, a row of its own */
.view-wrap { position: relative; display: flex; min-width: 0; }
.view-wrap .look.view { width: 100%; min-width: 0; }
.look.view .spin { width: 26px; height: 26px; flex: none; }
.view-del { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; padding: 0; border-radius: 50%; border: 0; display: none; place-items: center; background: var(--line2); color: var(--text); cursor: pointer; }
.view-wrap:hover .view-del, .view-del:focus-visible { display: grid; }
.view-del:hover { background: var(--err); color: #fff; }
@media (hover: none) { .view-del { display: grid; } }
.acard-imgacts { display: contents; }
.look:hover { color: #fff; }
.vthumb { width: 58px; height: 44px; border-radius: 7px; overflow: hidden; border: 2px solid transparent; padding: 0; background: #222; flex: none; cursor: pointer; }
.vthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vthumb.on { border-color: var(--brand); }
/* the × on a card's version picture (panels.js del-version): on hover, always on a touch screen */
.vthumb-wrap { position: relative; flex: none; display: flex; }
.vthumb-del { position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 0; display: none; place-items: center; background: rgba(0,0,0,.72); color: #fff; cursor: pointer; }
.vthumb-wrap:hover .vthumb-del, .vthumb-del:focus-visible { display: grid; }
.vthumb-del:hover { background: #dc2626; }
@media (hover: none) { .vthumb-del { display: grid; } }
@media (pointer: coarse) { .vthumb-del { width: 24px; height: 24px; top: 2px; right: 2px; } }
/* a character card's Ảnh mẫu (panels.js samplesHTML, char_samples.py) */
.acard-samples { display: flex; flex-direction: column; gap: 7px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
.acard-samples.smp-empty { flex-direction: row; align-items: center; flex-wrap: wrap; gap: 8px; }
.acard-samples.smp-empty .dim { flex: 1; min-width: 120px; }
.smp-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.smp-t { font-weight: 700; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; }
.smp-mode { margin-left: auto; }
.smp-mode button { padding: 3px 9px; font-size: 11.5px; }
.smp-row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.vthumb.smp { cursor: zoom-in; }
.smp-add { border: 1px dashed var(--line2); background: none; color: var(--muted); border-radius: 8px; padding: 6px 10px; font-size: 12px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.smp-add:hover { color: var(--text); border-color: var(--muted); }
.smp-acts { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.smp-acts .dim { flex: 1; min-width: 160px; font-size: 12px; }
.smp-warn { color: var(--warn); font-size: 12px; line-height: 1.45; }
.smp-old summary { cursor: pointer; color: var(--dim); font-size: 11.5px; font-weight: 400; margin-top: 4px; }
.smp-old div { font-weight: 400; color: var(--dim); font-size: 12px; white-space: pre-wrap; margin-top: 4px; }
.acard-info { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.acard-name { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.acard-name h4 { margin: 0; font-size: 16px; }
.acard-name .role { color: var(--muted); font-size: 12.5px; }
.acard-label { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; margin-top: -4px; }
.acard-label .label-tag { margin-top: 0; }
/* (6/11) a look's label for the outfit now written on it (look_sync.py label_hint), put in on a click */
.acard-hint { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 6px 10px; border-radius: 8px; background: rgba(251,191,36,.08); border: 1px solid rgba(251,191,36,.4); color: var(--warn); font-size: 12px; line-height: 1.45; }
.acard-hint code { color: var(--text); word-break: break-word; }
.acard-hint .btn { padding: 3px 8px; font-size: 11.5px; }
.acard-hint.acard-err-line { margin: 8px 12px 0; }
.acard-sec .sec-t { display: block; font-size: 11px; letter-spacing: .07em; text-transform: uppercase; color: var(--dim); margin-bottom: 4px; font-weight: 700; }
.acard-sec .txt { font-size: 12.5px; line-height: 1.65; color: #d4d4d4; }
.acard-sec .txt b { color: #e5e5e5; font-weight: 600; }
/* Nhân vật: a frame a character (panels.js framesHTML, 31/10). 2/11: its head holds what the looks share (the face,
   gender · age · role, the summary, Ảnh khuôn mặt chung, Vẽ biến thể chưa có ảnh, Thêm biến thể), the looks are tiles,
   the one picked shows beside them (a phone: on the whole screen, below) */
.cfam { border: 1px solid var(--line2); border-radius: 16px; padding: 12px; margin-bottom: 16px; scroll-margin-top: 64px; }
.cfam-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.cfam-head h3 { margin: 0; font-size: 17px; line-height: 1.25; }
.cfam-fold svg { transition: transform .15s; }
.cfam.closed .cfam-fold svg { transform: rotate(-90deg); }
.cfam .acard { scroll-margin-top: 64px; }
.cfam-face { flex: none; width: 40px; height: 40px; padding: 0; border-radius: 50%; overflow: hidden; border: 1px solid var(--line2); background: var(--card2); display: grid; place-items: center; cursor: pointer; }
.cfam-face img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cfam-face.none { border-style: dashed; }
.cfam-face.square { width: 56px; border-radius: 8px; }  /* (6/11) a place's, a prop's picture: not a face */
.cfam-face:hover { border-color: var(--muted); }
.cfam-initials { font-size: 13px; font-weight: 700; color: var(--muted); }
.cfam-ttl { display: flex; flex-direction: column; min-width: 0; }
.cfam-ttl .dim { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52ch; }
.cfam-sum { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 2px 6px; padding: 2px 10px; border: 1px solid var(--line2); border-radius: 999px; font-size: 12px; color: var(--muted); }
.cfam-sum i { font-style: normal; color: var(--dim); }
.cfam-sum .bad { color: var(--err); font-weight: 600; }
.cfam-sum .busy { color: var(--brand); font-weight: 600; }
.cfam-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.cfam-acts .btn .dim { font-weight: 500; }
/* Ảnh khuôn mặt chung: the base card's face pictures, under the head */
.cfam-face-panel { margin-top: 10px; border: 1px solid var(--line2); border-radius: 12px; background: var(--card); overflow: hidden; }
.cfp-head { display: flex; align-items: center; gap: 8px; padding: 8px 8px 0 12px; }
.cfp-head .dim { font-size: 12px; }
.cfp-note { margin: 4px 12px 0; font-size: 12px; line-height: 1.5; }
.cfam-face-panel .acard-samples { border-bottom: 0; }
/* the looks as tiles, the picked one's card beside them when the frame has the room (a container query) */
.cfam-body { margin-top: 12px; }
.cfam-split { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; align-items: start; }
.cfam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 8px; align-content: start; }
.ltile { min-width: 0; display: flex; flex-direction: column; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--muted); font: inherit; font-size: 11.5px; text-align: center; cursor: pointer; scroll-margin: 8px 0; }
.ltile:hover { border-color: var(--line2); color: var(--text); }
.ltile.on { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); color: var(--text); }
.ltile-pic { position: relative; aspect-ratio: 4 / 3; border-radius: 7px; overflow: hidden; background: var(--bg); display: grid; place-items: center; }
.ltile-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ltile.none .ltile-pic { border: 1px dashed var(--line2); }
.ltile-none { color: var(--dim); display: grid; place-items: center; }
.ltile-code { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ltile-marks { position: absolute; top: 3px; left: 3px; display: flex; gap: 3px; }
.ltile-marks i { min-width: 18px; height: 18px; padding: 0 3px; border-radius: 9px; display: grid; place-items: center; font-style: normal; font-size: 11px; line-height: 1; background: var(--card); border: 1px solid var(--line2); }
.lt-base { color: var(--warn); }
.lt-err { color: var(--err); }
.ltile-marks .lt-busy { color: var(--brand); }
.cfam-detail { min-width: 0; scroll-margin-top: 8px; }
.cfam-detail .acard { border-color: var(--line2); }
.cfam-sheet-bar { display: none; }
@media (min-width: 641px) { .cfam-body { container-type: inline-size; } }
@container (min-width: 480px) {  /* a narrow frame (a tablet, the assistant open on a small window): the look beside 2-3 tiles */
  .cfam-split { grid-template-columns: minmax(0, 1fr) clamp(260px, 55%, 440px); }
}
@container (min-width: 600px) {
  .cfam-split { grid-template-columns: minmax(0, 1fr) clamp(300px, 40%, 440px); }  /* 5 tiles a row beside the assistant at 1366 px, 7 at 1920 */
}
/* Ảnh khuôn mặt chung's other parts (panels.js facePanelHTML, 2/11): the base without pictures; the switch of the looks
   without their own; the looks with their own, a line each, its own block under it on a tap */
.cfp-none { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 9px 12px; font-size: 12px; }
.cfp-none .dim { flex: 1; min-width: 160px; }
.cfp-sec { border-top: 1px solid var(--line); padding: 9px 12px; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.cfp-sec-t { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.cfp-sec-t .smp-mode { margin-left: auto; }
.cfp-looks-st { font-size: 12px; line-height: 1.45; }
.cfp-looks-st.mixed { color: var(--warn); }
.cfp-own { display: flex; flex-direction: column; gap: 4px; }
.cfp-own-item { border: 1px solid var(--line); border-radius: 9px; }
.cfp-own-row { width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; padding: 5px 8px; border: 0; background: none; color: inherit; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.cfp-own-row svg { color: var(--dim); transition: transform .15s; }
.cfp-own-item.open .cfp-own-row svg { transform: rotate(180deg); }
.cfp-own-pics { display: flex; gap: 4px; }
.cfp-own-pics .vthumb.mini { cursor: pointer; }
.cfp-same { font-size: 11px; color: var(--ok); border: 1px solid var(--line2); border-radius: 999px; padding: 0 7px; }
.cfp-own-body { display: none; border-top: 1px solid var(--line); }
.cfp-own-item.open .cfp-own-body { display: block; }
.vthumb.mini { width: 34px; height: 26px; border-width: 1px; cursor: zoom-in; }
.acard-err.acard-err-line { max-width: none; margin: 8px 12px 0; text-align: left; }
/* (8/11) a place whose views were drawn one by one: Vẽ lại thành 1 ảnh 4 góc (panels.js drawnApart) */
.acard-err.view-apart { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; background: rgba(251,191,36,.08); border-color: rgba(251,191,36,.4); color: var(--warn); }
.btn.warn-btn { color: var(--warn); border-color: rgba(251,191,36,.45); }
/* a long explanation behind a "?" (panels.js qhintHTML): its tooltip, and its text on a tap */
.qhint { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; min-width: 0; }
.qhint-b { flex: none; width: 18px; height: 18px; padding: 0; border-radius: 50%; border: 1px solid var(--line2); background: none; color: var(--muted); font: inherit; font-size: 11px; font-weight: 700; line-height: 1; display: inline-grid; place-items: center; cursor: pointer; }
.qhint-b:hover, .qhint.open .qhint-b { color: var(--text); border-color: var(--muted); }
.qhint-t { display: none; font-size: 12px; line-height: 1.45; color: var(--dim); }
.qhint.open { flex-basis: 100%; }
.qhint.open .qhint-t { display: block; flex: 1; min-width: 0; }
@media (pointer: coarse) { .qhint-b { width: 26px; height: 26px; font-size: 12px; } }
.cfam-strip { display: flex; gap: 8px; overflow-x: auto; margin-top: 10px; padding-bottom: 2px; }
.cfam-thumb { flex: none; width: 92px; display: flex; flex-direction: column; gap: 4px; padding: 0; border: 0; background: none; color: var(--muted); font: inherit; font-size: 11.5px; cursor: pointer; text-align: center; }
.cfam-thumb img, .cfam-pic { width: 92px; height: 69px; border-radius: 8px; object-fit: cover; display: grid; place-items: center; border: 1px solid var(--line); background: var(--bg); }
.cfam-thumb.none .cfam-pic { border-style: dashed; color: var(--dim); }
.cfam-tn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cfam-thumb:hover { color: var(--text); }
/* a long text on a card in a frame: its first lines, then "Xem thêm" */
.cfam .acard-sec.long:not(.open) > .txt, .cfam .acard-sec.long:not(.open) > .cos-row { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.sec-more { display: inline-block; margin-top: 2px; padding: 0; border: 0; background: none; color: var(--brand); font: inherit; font-size: 12px; cursor: pointer; }
/* a frame's card: its descriptions and prompt behind "Mô tả và prompt" (panels.js moreHTML) */
.acard-more-t { display: flex; align-items: center; gap: 6px; width: 100%; padding: 6px 0 0; border: 0; border-top: 1px solid var(--line); background: none; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; cursor: pointer; text-align: left; }
.acard-more-t:hover { color: var(--text); }
.acard-more-t svg { transition: transform .15s; }
.acard-more.open .acard-more-t svg { transform: rotate(180deg); }
.acard-more-b { display: none; }
.acard-more.open .acard-more-b { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
/* a look's outfit in its frame, folded to one line (2/11) */
.cos-t { flex: none; white-space: nowrap; }
.cos-peek { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; color: var(--muted); }
.cos-fold.open .cos-peek { display: none; }
.cos-fold > .cos-check { margin-top: 6px; }
/* Trang phục on a character card (costume.py): its fields, Gemini's check of the picture, the editor */
.cos-row { font-size: 12.5px; line-height: 1.55; color: var(--text); white-space: pre-line; max-height: 12em; overflow-y: auto; }
.cos-row .dim { margin-right: 3px; }
.cos-check { margin-top: 6px; font-size: 12px; line-height: 1.45; display: flex; align-items: flex-start; gap: 6px; }
.cos-check.ok { color: var(--ok); }
.cos-check.bad { color: var(--warn); }
.cos-check .spin { width: 11px; height: 11px; margin-top: 2px; }
.cos-acts { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.cos-text { width: 100%; line-height: 1.5; }
.cos-status { margin-top: 10px; font-size: 12.5px; display: flex; align-items: center; gap: 8px; min-height: 18px; }
.ptags { display: flex; flex-wrap: wrap; gap: 6px; }
.ptag { font-size: 11.5px; padding: 3px 10px; border-radius: 999px; background: #262626; border: 1px solid var(--line2); color: #d4d4d4; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; max-height: 60vh; overflow: auto; }
.pick { display: flex; flex-direction: column; gap: 4px; padding: 6px; border: 1px solid var(--line); border-radius: 10px; background: #1b1b1b; cursor: pointer; text-align: left; color: var(--text); }
.pick:hover { border-color: var(--brand); }
.pick img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: #222; }
.pick span { font-size: 11.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick small { font-size: 11px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* setup: a project that still uses a Genre DNA */
.dna-note { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12.5px; border: 1px solid var(--line); border-radius: 9px; padding: 7px 10px; margin: 10px 0 2px; background: #1b1b1b; }

/* the project's progress bar */
.pgbar { flex: none; border-bottom: 1px solid var(--line); background: #171717; padding: 8px 14px 9px; display: flex; flex-direction: column; gap: 7px; }
.pg-steps { display: flex; align-items: center; gap: 4px; overflow-x: auto; }
.pg-sep { flex: 1 1 8px; min-width: 6px; height: 1px; background: var(--line2); }
.pg-step { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px 3px 3px; border-radius: 999px; border: 1px solid transparent; background: none; color: var(--dim); font-size: 12px; font-weight: 600; white-space: nowrap; cursor: pointer; flex: none; }
.pg-step:hover { color: var(--text); background: #222; }
.pg-n { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; background: #2a2a2a; color: var(--muted); flex: none; }
.pg-step.done { color: #a7f3d0; }
.pg-step.done .pg-n { background: rgba(110,231,183,.18); color: #6ee7b7; }
.pg-step.on { color: #fff; border-color: rgba(139,92,246,.6); background: rgba(139,92,246,.12); }
.pg-step.on .pg-n { background: #7c3aed; color: #fff; }
.pg-step.view { color: #fff; box-shadow: inset 0 -2px 0 #fff; border-radius: 6px 6px 3px 3px; }
.pg-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pg-msg { flex: 1 1 240px; min-width: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.pg-ep { height: 28px; width: auto; }
/* a narrower panel (17/11: the full names ran off the bar from 1536 to 1680 px, at 1366 the steps were bare numbers):
   the other steps by short names (panels.js STEP_SHORT); then closer together, the two marked ones short too; then the
   other steps by their number only (name in the tooltip) */
.pgbar { container-type: inline-size; }
.pg-s { display: none; }
@container (max-width: 1000px) { .pg-step:not(.on):not(.view) .pg-t { display: none; } .pg-step:not(.on):not(.view) .pg-s { display: inline; } }
@container (max-width: 860px) {
  .pg-steps { gap: 2px; } .pg-step { gap: 4px; padding-right: 6px; } .pg-sep { flex-basis: 4px; min-width: 4px; }
  .pg-step .pg-t { display: none; } .pg-step .pg-s { display: inline; }
}
@container (max-width: 700px) { .pg-step:not(.on):not(.view) .pg-s { display: none; } .pg-step:not(.on):not(.view) { padding: 3px; } }

/* the home page's "Bắt đầu" checklist */
.start { border: 1px solid rgba(139,92,246,.45); background: linear-gradient(135deg, rgba(139,92,246,.1), rgba(236,72,153,.04) 60%, transparent), var(--card); border-radius: 14px; padding: 14px 16px; margin-bottom: 22px; }
.start-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.start-head h2 { margin: 0; font-size: 17px; display: inline-flex; align-items: center; gap: 8px; }
.start-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 10px; }
.start-step { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; background: #1b1b1b; }
.start-step.done { opacity: .7; }
.start-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #7c3aed; color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.start-step.done .start-n { background: rgba(110,231,183,.2); color: #6ee7b7; }
.start-txt { flex: 1; display: flex; flex-direction: column; gap: 3px; font-size: 12.5px; line-height: 1.45; min-width: 0; }
.start-txt span { color: var(--muted); }
.start-txt .btn { align-self: flex-start; margin-top: 5px; }
.start-ok { color: #6ee7b7; font-size: 12px; font-weight: 600; flex: none; }

/* Seedance scene length picker */
.len-pick { display: flex; flex-direction: column; gap: 8px; }
.len-opt { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.len-opt:hover { border-color: #444; }
.len-opt:has(input:checked) { border-color: var(--brand); background: rgba(139,92,246,.08); }
.len-opt input { margin-top: 3px; accent-color: var(--brand); }
.len-opt b { display: block; font-size: 13.5px; }
.len-opt span { color: var(--muted); font-size: 12px; }

/* Duyệt kịch bản → Đồng bộ dàn ý: what the outline will lose, rename, gain */
.sync-plan { font-size: 13px; line-height: 1.5; }
.sync-plan p { margin: 0 0 8px; }
.sync-sum b { color: var(--text); }
.sync-part { margin: 0 0 10px; }
.sync-head { font-weight: 600; font-size: 12.5px; margin-bottom: 3px; }
.sync-part ul { margin: 0; padding-left: 18px; max-height: 168px; overflow-y: auto; }
.sync-part li { font-size: 12.5px; color: var(--muted); }
.sync-part li b { color: var(--text); font-weight: 600; }
.sync-line { font-size: 12.5px; color: var(--muted); }
.sync-ai { display: flex; gap: 8px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  margin: 8px 0 0; cursor: pointer; font-size: 12.5px; }
.sync-ai:has(input:checked) { border-color: var(--brand); background: rgba(139,92,246,.08); }
.sync-ai input { margin-top: 3px; accent-color: var(--brand); flex: none; }
.sync-plan > .dim.sync-line { margin-top: 10px; }

/* Large dialog for the genre and world forms: form on the left, guide on the right, both filling the height */
.modal.xl { width: min(1320px, 100%); height: min(92vh, 1040px); max-height: 92vh;
  height: min(92dvh, 1040px, calc(100dvh - 40px - var(--kb, 0px))); max-height: min(92dvh, calc(100dvh - 40px - var(--kb, 0px))); }
.modal.xl .modal-head { padding: 18px 24px 12px; }
.modal.xl .modal-head h3 { font-size: 18px; }
.modal.xl .modal-body { flex: 1; min-height: 0; display: flex; overflow: hidden; padding: 4px 24px 16px; }
.modal.xl .modal-foot { padding: 14px 24px; }
.modal.xl .fg-modal { flex: 1; min-height: 0; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 22px; align-items: stretch; }
.modal.xl .fg-modal .form { display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow: auto; padding-right: 2px; }
.modal.xl .fg-modal .fld > span { font-size: 13px; }
.fg-films { margin: 0; font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.modal.xl .fg-modal .ctl { font-size: 15px; }
.modal.xl .fg-modal input.ctl { height: 42px; padding: 0 12px; }
.modal.xl .fg-modal input[type="file"].ctl { padding: 6px 12px; }  /* 42px tall: the 28px button sits in the middle */
.modal.xl .fg-modal textarea.ctl { padding: 10px 12px; line-height: 1.6; min-height: 150px; }
.modal.xl .fg-modal .fld:last-child { flex: 1; min-height: 240px; }
.modal.xl .fg-modal .fld:last-child textarea.ctl { flex: 1; resize: none; }
.modal.xl .fg-guide { max-height: none; min-height: 0; font-size: 13.5px; line-height: 1.6; padding: 12px 16px; }
.modal.xl .fg-guide[open] { height: 100%; }
.modal.xl .fg-guide:not([open]) { align-self: start; }
.modal.xl .fg-guide summary { font-size: 14px; }
.modal.xl .fg-guide h5 { font-size: 13.5px; margin: 14px 0 5px; }
.modal.xl .fg-guide ol, .modal.xl .fg-guide ul { gap: 4px; padding-left: 20px; }
@media (max-width: 760px) {
  .fg-modal { grid-template-columns: 1fr; }
  .modal.xl { height: auto; }
  .modal.xl .modal-body { display: block; overflow: auto; padding: 4px 16px 12px; }
  .modal.xl .fg-modal { grid-template-columns: 1fr; }
  .modal.xl .fg-modal .form { overflow: visible; }
  .modal.xl .fg-guide[open] { height: auto; }
}

/* cost tags: Claude usage or a paid image/video API call */
.costtag { display: inline-flex; align-items: center; margin-left: 6px; padding: 0 5px; height: 17px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; line-height: 1; vertical-align: middle; flex: none; }
.costtag-claude { background: rgba(217,119,87,.18); color: #f0a37f; }
.costtag-api { background: rgba(251,191,36,.16); color: #fbbf24; }
.btn.brand .costtag, .btn.primary .costtag { background: rgba(0,0,0,.28); color: #fff; }
.menu button .costtag { margin-left: 7px; }

/* chat replies: the next steps stand out, the technical part folds away */
.part-text h5.md-next { color: #c4b5fd; border-left: 3px solid var(--brand); padding-left: 8px; }
.part-text details.md-more { margin-top: 10px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; background: #1a1a1a; }
.part-text details.md-more > summary { cursor: pointer; color: var(--dim); font-size: 12px; font-weight: 600; }
.part-text details.md-more[open] > summary { margin-bottom: 6px; }

/* setup: "Nâng cao" */
.adv-sum { font-weight: 400; font-size: 11.5px; }
.adv-box { border-left: 2px solid var(--line2); padding: 4px 0 2px 12px; margin-top: 4px; }

/* home: Genre DNA under "Nâng cao" */
.home-adv { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 14px; }
.home-adv > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; color: var(--muted); }
.home-adv > summary::-webkit-details-marker { display: none; }
.home-adv > summary svg { transition: transform .15s; flex: none; }
.home-adv[open] > summary svg { transform: rotate(90deg); }
.home-adv > summary .dim { font-weight: 400; font-size: 12.5px; }

/* an episode's "Ảnh cần" list */
.needs { display: flex; flex-direction: column; gap: 6px; }
.need { display: flex; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 10px; padding: 7px 9px; background: #1b1b1b; }
.need.miss { border-color: rgba(251,191,36,.35); }
.need-th { width: 46px; height: 46px; border-radius: 8px; overflow: hidden; flex: none; display: grid; place-items: center; background: #242424; color: var(--dim); font-weight: 700; }
.need-th svg { width: 20px; height: 20px; }
.need-th img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.need-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; font-size: 12.5px; }
.need-txt b { overflow-wrap: anywhere; }
.need-txt span { color: var(--dim); font-size: 12px; }
.need-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.need-ok { color: var(--ok); font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.need-busy { color: var(--muted); font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.need-busy .spin { width: 12px; height: 12px; }
.need-miss-n { color: #fbbf24; }
/* cards no episode uses (Thẻ không dùng), under the needed ones */
.unused { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); display: flex; flex-direction: column; gap: 8px; }
.unused .bd-note { margin-bottom: 0; }
.unused-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12.5px; }
.unused-head .dim { flex-basis: 100%; font-size: 12px; line-height: 1.45; }
.need.unused-row { border-style: dashed; }
.unused-kept summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 2px 0; }
.unused-kept .needs { margin-top: 6px; }
.refs-spare { color: var(--muted); }
@media (max-width: 640px) {
  .need.unused-row { flex-wrap: wrap; }
  .need.unused-row .need-txt { flex-basis: calc(100% - 60px); }
  .need.unused-row .need-acts { flex-basis: 100%; }
}

/* script: one passage at a time */
.script-hint { max-width: 760px; margin: 0 auto 6px; font-size: 12px; }
.script.editable .sblk { position: relative; margin: 0 -10px; padding: 1px 10px; border-radius: 6px; }
.script.editable .sblk:hover { background: rgba(139,92,246,.06); box-shadow: inset 0 0 0 1px rgba(139,92,246,.3); }
.script.editable .sblk.on { background: rgba(139,92,246,.09); box-shadow: inset 0 0 0 1px rgba(139,92,246,.55); }
.sblk-tools { position: absolute; bottom: 100%; margin-bottom: -4px; right: 8px; z-index: 3; display: none; gap: 1px; padding: 2px; background: #232323; border: 1px solid var(--line2); border-radius: 8px; box-shadow: 0 6px 18px rgba(0,0,0,.45); }
.script.editable .sblk:hover > .sblk-tools { display: flex; }
.sblk-tools .btn { height: 24px; padding: 0 7px; font-size: 11.5px; gap: 4px; font-style: normal; text-transform: none; letter-spacing: 0; color: var(--muted); }
.sblk-tools .btn:hover { color: var(--text); }
/* a beat heading: the whole-beat tools on a row above the passage's own (fits a narrow iPad column) */
.sblk-tools.rows { flex-direction: column; align-items: flex-end; }
.sblk-grp { display: flex; gap: inherit; }
/* the rest of a beat the assistant is asked to rewrite (panels.js, AI sửa cả nhịp): one band, no hover */
.script.editable .sblk.in-beat, .script.editable .sblk.in-beat:hover { background: rgba(139,92,246,.06); box-shadow: inset 2px 0 0 rgba(139,92,246,.55); border-radius: 0; }
.sblk-editor { margin: 6px -10px 14px; padding: 8px; border: 1px solid rgba(139,92,246,.55); border-radius: 8px; background: #1b1b1b; }
.sblk-editor textarea { width: 100%; font: inherit; font-size: 13.5px; line-height: 1.6; resize: vertical; }
.sblk-edit-acts { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 11.5px; }

/* outline: one beat at a time */
.beats-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; font-size: 11.5px; }
.beats-tools .dim { flex: 1 1 220px; }
.beat-editor { padding: 8px 10px; border: 1px solid rgba(139,92,246,.55); border-radius: 8px; background: #1b1b1b; }
.beat-editor > textarea { width: 100%; font: inherit; font-size: 13px; line-height: 1.55; resize: vertical; }
.beat-form { display: flex; flex-wrap: wrap; gap: 8px 10px; }
.beat-form label { flex: 1 1 140px; display: flex; flex-direction: column; gap: 3px; font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--dim); min-width: 0; }
.beat-form label.w2 { flex: 2 1 240px; }
.beat-form label.full { flex-basis: 100%; }
.beat-form .ctl { font-size: 13px; text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text); }
.beat-form textarea { resize: vertical; line-height: 1.5; }

/* asset cards: one field at a time */
.acard-sec[data-field], .prompt-box[data-field] { position: relative; }
.acard-sec[data-field] { margin: 0 -6px; padding: 2px 6px; border-radius: 6px; }
.acard-sec[data-field]:hover, .prompt-box[data-field]:hover { background: rgba(139,92,246,.06); }
.acard-sec[data-field]:hover > .sblk-tools, .prompt-box[data-field]:hover > .sblk-tools { display: flex; }
.acard-sec.on, .prompt-box.on { background: rgba(139,92,246,.08); box-shadow: inset 0 0 0 1px rgba(139,92,246,.45); }
.acard .sblk-editor, .items-ai .sblk-editor { margin: 6px 0 2px; }
.prompt-box .sblk-editor textarea { font-size: 12px; }
.acard-add { display: flex; flex-wrap: wrap; align-items: center; gap: 5px; font-size: 11.5px; }
.chip-add { display: inline-flex; align-items: center; gap: 3px; background: none; border: 1px dashed var(--line2); border-radius: 999px; padding: 2px 9px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.chip-add:hover { color: var(--text); border-color: var(--brand); }
.items-ai { margin-bottom: 12px; }
.empty .items-ai { width: min(520px, 100%); margin: 12px auto 0; text-align: left; }
/* (12/11) Soát mặt giống nhau: the look-alike groups on top of the characters tab, each name a button to its frame */
.face-check { border: 1px solid var(--warn); border-radius: 12px; padding: 10px 12px; margin-bottom: 14px; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.face-check.ok { border-color: var(--line2); color: var(--muted); }
.face-check > .spin { display: inline-block; vertical-align: middle; margin-right: 6px; }
.face-check-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.face-check-row .warn-list { flex: 1 1 260px; }
.face-group { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 3px; padding: 2px 4px; border-radius: 999px; background: rgba(245,158,11,.08); }
.face-group i { font-style: normal; color: var(--warn); font-size: 11px; }
.face-why { margin: 0; padding-left: 18px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.face-why b { color: var(--text); font-weight: 600; }
.face-check-note { font-size: 12px; }
.cfam.flash { animation: flash 1.2s ease-out; }

/* world tab: one line at a time */
.wsec { margin-top: 16px; }
.wsec-h { font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: #c4b5fd; margin-bottom: 6px; }
.wsec-h .dim { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 11.5px; }
.wlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.witem { position: relative; padding: 5px 8px; border-radius: 6px; font-size: 13px; line-height: 1.55; color: #d4d4d4; }
.wlist .witem { padding-left: 18px; }
.wlist .witem::before { content: ''; position: absolute; left: 7px; top: 13px; width: 4px; height: 4px; border-radius: 50%; background: #555; }
.wlist .witem.on::before { display: none; }
/* an item's details: the indented lines under it (a character's look, ways, motives…) */
.wsub { list-style: none; margin: 4px 0 2px; padding: 0 0 0 12px; border-left: 2px solid var(--line); display: flex; flex-direction: column; gap: 3px; }
.wsub li { font-size: 12.5px; line-height: 1.55; }
.witem:hover { background: rgba(139,92,246,.06); }
.witem:hover > .sblk-tools { display: flex; }
.witem.on { background: rgba(139,92,246,.08); box-shadow: inset 0 0 0 1px rgba(139,92,246,.45); }
.witem .badge { font-size: 11px; margin-right: 2px; }
.wtext.wname { font-size: 15px; font-weight: 700; color: var(--text); }
.witem .sblk-editor, .witem-new .sblk-editor, .wsec > .witem-new .sblk-editor { margin: 4px 0; }
.witem-new { list-style: none; }
.wsec-add { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.wempty { margin: 0; font-size: 12.5px; }

/* film genre: signature traits ("Dấu ấn riêng") */
.fg-traits { border: 1px solid rgba(139,92,246,.4); border-radius: 12px; padding: 12px 14px; background: rgba(139,92,246,.04); }
.tr-list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.tr { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: #1b1b1b; }
.tr-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.tr-head .btn { opacity: .45; }
.tr:hover .tr-head .btn { opacity: 1; }
.badge.tr-must { background: rgba(139,92,246,.22); color: #ddd6fe; }
.tr-rule { font-size: 12.5px; line-height: 1.55; color: #d4d4d4; margin-top: 4px; white-space: pre-wrap; }
.tr-ex { font-size: 12px; line-height: 1.5; color: var(--muted); font-style: italic; margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--line2); white-space: pre-wrap; }
.tr-form { display: flex; flex-direction: column; gap: 6px; border-color: rgba(139,92,246,.55); }
.tr-form-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tr-form-row input { flex: 1 1 200px; }
.tr-form-row select { flex: 0 0 auto; width: auto; }
.tr-form textarea, .tr-ai textarea { width: 100%; resize: vertical; font: inherit; font-size: 12.5px; line-height: 1.5; }
.tr-form-acts { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 11.5px; }
.tr-ai { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.tr-busy { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; }
.tr-acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

/* Genre DNA editor: a centered window with tabs */
.dna-back { position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.62); display: grid; place-items: center; padding: 20px; animation: fade .12s; }
.dna-win { width: min(1040px, 100%); height: min(88vh, 920px); display: flex; flex-direction: column; background: #1b1b1b; border: 1px solid var(--line2); border-radius: 14px; box-shadow: 0 24px 60px rgba(0,0,0,.55); overflow: hidden; }
.dna-win-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.dna-win-head h2 { margin: 0; font-size: 15px; flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
.dna-win-head .dna-ic { width: 30px; height: 30px; border-radius: 8px; }
.dna-tabs { display: flex; gap: 4px; padding: 10px 16px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.dna-tab { background: none; border: 0; border-bottom: 2px solid transparent; padding: 7px 12px 9px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer; }
.dna-tab:hover { color: var(--text); }
.dna-tab.on { color: #fff; border-bottom-color: var(--brand); }
.dna-tab .dim { font-weight: 500; font-size: 12px; margin-left: 3px; }
.dna-subtabs { display: flex; gap: 5px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--line); background: #181818; }
.dna-sub { display: inline-flex; align-items: center; gap: 5px; max-width: 220px; background: #232323; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 12px; color: var(--muted); cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dna-sub:hover { color: var(--text); border-color: #444; }
.dna-sub.on { background: rgba(139,92,246,.18); border-color: rgba(139,92,246,.6); color: #fff; }
.dna-sub.empty .id { color: var(--warn); }
.dna-sub .id { font: 700 10.5px ui-monospace, Consolas, monospace; color: var(--dim); }
.dna-win .dna-main { flex: 1; min-height: 0; overflow-y: auto; padding: 18px 22px; }
.dna-win .dna-block { max-width: none; }
.dna-win-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 12px 16px; border-top: 1px solid var(--line); }

/* new genre DNA: what to make once it is written */
.dna-make { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; background: #1b1b1b; display: flex; flex-direction: column; gap: 4px; }
.dna-make-h { font-size: 12px; font-weight: 700; color: var(--muted); }
.dna-make .check-row { align-self: stretch; margin: 0; width: 100%; display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 7px; font-size: 13px; text-align: left; color: var(--text); font-weight: 500; }
.dna-make .check-row input { width: auto; flex: none; margin: 0; }
.dna-make .check-row .dim { font-size: 12px; }
.dna-made { margin-top: 8px; font-size: 12.5px; color: var(--muted); }

/* characters tab: reference layout picker */
.r-head .ref-layout { width: auto; height: 30px; font-size: 12px; padding: 0 8px; }
.r-head .ref-i2i { display: inline-flex; align-items: center; align-self: center; gap: 8px; font-size: 12px; white-space: nowrap; cursor: pointer; margin: 0 4px; user-select: none; color: var(--text); }
.r-head .ref-i2i .switch { display: inline-block; }

/* Kho visual */
.pcard .thumb .vk-cover { width: 100%; height: 100%; object-fit: cover; }
.pcard .thumb { overflow: hidden; }
.pcard .thumb.lib { height: 170px; }
.pcard .thumb.lib .vk-cover { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 28%; }  /* square portraits: keep the face */
.thumb-btn { position: absolute; top: 8px; right: 8px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 8px; background: rgba(0,0,0,.45); color: #fff; cursor: pointer; opacity: 0; transition: opacity .15s; }
.pcard:hover .thumb-btn { opacity: 1; }
.thumb-busy { position: absolute; left: 8px; bottom: 8px; display: inline-flex; gap: 6px; align-items: center; padding: 3px 8px; border-radius: 999px; background: rgba(0,0,0,.55); color: #fff; font-size: 11px; }
.vk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.vk-thumb { position: relative; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; background: #1b1b1b; aspect-ratio: 4 / 3; }
.vk-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vk-thumb .badge { position: absolute; left: 6px; bottom: 6px; font-size: 11px; }
.vk-thumb [data-vk-del] { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); opacity: 0; }
.vk-thumb:hover [data-vk-del] { opacity: 1; }
.vk-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; aspect-ratio: 4 / 3; border: 1px dashed var(--line2); border-radius: 9px; color: var(--muted); font-size: 12px; cursor: pointer; }
.vk-add:hover { color: var(--text); border-color: var(--brand); }
/* Kho diễn viên (actors.js): the home cards, the actor dialog, the picker, and the line on a character card */
.pcard .thumb.lib.actor-thumb .vk-cover { object-position: center 22%; }
.act-modal .fld { min-width: 0; }
.modal.xl .act-modal { flex: 1; min-height: 0; overflow: auto; padding-right: 4px; align-content: start; }
.act-slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.act-slot { display: flex; flex-direction: column; gap: 4px; font-size: 12px; min-width: 0; }
.act-slot .dim { font-size: 12px; line-height: 1.35; }
.act-pic { position: relative; aspect-ratio: 2 / 3; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--card2, #1b1b1b); display: grid; place-items: center; }
.act-pic img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.act-slot.body .act-pic img { object-fit: contain; }  /* the 9:16 full body in the same box: the three slots stay level */
.act-pic .act-del { position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,.55); color: #fff; }
.act-slot > .dim { min-height: 2.7em; }  /* two lines kept: the buttons below stay level */
.act-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.act-btns label.btn { cursor: pointer; flex-direction: row; gap: 6px; color: var(--text); }  /* not .form label's stacked field look */
.act-dna { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 8px 12px; }
.act-dna textarea { resize: vertical; }
.act-acting { flex-basis: 100%; font-size: 12px; line-height: 1.45; color: var(--muted); }
.act-acting b { color: var(--text); margin-right: 4px; }
/* Nhập kịch bản có sẵn (script_import.js): the episodes found, how to bring them in, the import running */
.modal.xl .si-preview { flex: 1; min-height: 0; overflow: auto; padding-right: 4px; align-content: start; }
/* Phim tài liệu (documentary.js): the xl body does not scroll, its one child does (long fact sheets, 85 narration rows) */
.modal.xl .doc-modal { flex: 1; min-width: 0; min-height: 0; overflow: auto; padding-right: 4px; }
.si-eps { display: grid; gap: 2px; border: 1px solid var(--line); border-radius: 10px; padding: 4px 10px; max-height: 340px; overflow: auto; }
.si-all { display: flex; gap: 6px; justify-content: flex-end; padding: 2px 0; }
.form label.si-ep { display: grid; grid-template-columns: 20px minmax(0, 1fr) auto 56px; gap: 8px; align-items: center; flex-direction: row;
  padding: 7px 0; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text); font-weight: 500; cursor: pointer; }
.form label.si-ep:first-of-type { border-top: 0; }
.si-ep-main { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.si-open { font-weight: 400; font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-num { display: inline-flex; align-items: center; gap: 6px; }
.si-num input { width: 64px; height: 26px; padding: 0 6px; }
.si-warn { color: var(--warn); font-size: 12px; font-weight: 500; }
.si-modes { display: grid; gap: 8px; }
.form label.si-mode { display: flex; flex-direction: row; gap: 8px; align-items: flex-start; font-size: 12.5px; color: var(--text); font-weight: 400; cursor: pointer; }
.si-mode > span { display: flex; flex-direction: column; gap: 2px; }
.si-mode .dim { font-size: 12px; }
.si-results { display: grid; gap: 4px; margin-top: 10px; font-size: 12.5px; max-height: 320px; overflow: auto; }
.si-next { display: grid; gap: 8px; justify-items: start; margin-top: 12px; }
.si-orig { white-space: pre-wrap; font: 12.5px/1.55 var(--mono, ui-monospace, monospace); max-height: 60vh; overflow: auto;
  background: var(--card2, #1b1b1b); border: 1px solid var(--line); border-radius: 10px; padding: 12px; margin: 0; }
.act-make summary, .act-text summary { cursor: pointer; font-weight: 600; font-size: 13px; margin: 4px 0 8px; }
.act-make textarea { width: 100%; margin-bottom: 8px; }
.act-go { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.act-go .dim { flex: 1; min-width: 200px; font-size: 12px; }
.act-roles { display: grid; gap: 3px; font-size: 12px; }
.act-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.act-pick-one { display: flex; flex-direction: column; gap: 3px; text-align: left; padding: 6px; border: 1px solid var(--line); border-radius: 11px; background: none; color: var(--text); cursor: pointer; font-size: 12px; min-width: 0; }
.act-pick-one:hover:not(:disabled) { border-color: var(--brand); }
.act-pick-one:disabled { opacity: .5; cursor: not-allowed; }
.act-pick-one .dim { font-size: 12px; }
.act-pick-pic { aspect-ratio: 2 / 3; border-radius: 8px; overflow: hidden; display: grid; place-items: center; color: rgba(255,255,255,.85); margin-bottom: 3px; }
.act-pick-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.acard-actor { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 12px; }
/* a card with no actor: one line like Ảnh khuôn mặt's, its buttons under it once tapped (panels.js actorHTML) */
.acard-actor.act-none { display: block; padding: 0; }
.act-toggle { width: 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; padding: 9px 12px; border: 0; background: none; color: inherit; font: inherit; font-size: 12px; text-align: left; cursor: pointer; }
.act-toggle .dim { flex: 1; min-width: 120px; }
.act-toggle:hover .smp-t { color: var(--text); }
.act-toggle svg { color: var(--dim); transition: transform .15s; }
.act-none.open .act-toggle svg { transform: rotate(180deg); }
.act-none-btns { display: none; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.act-none.open .act-none-btns { display: flex; }
.acard-actor .spin { width: 12px; height: 12px; }
.acard-actor .bd-err { color: var(--warn); }
.act-tag { display: inline-flex; align-items: center; gap: 5px; }
.act-hint { flex-basis: 100%; font-size: 12px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px 6px; }
.vk-videos { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.vk-videos a { color: var(--muted); }
.vk-learn { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tr-heavy { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 6px 0 10px; }
.bd-note { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 8px 10px; margin-bottom: 8px; border: 1px dashed var(--line); border-radius: 10px; }
.bd-note .bd-err { color: var(--warn); }
/* Phân cảnh → Nhãn sai (3/11, panels.js labelsHTML / labelPick): one row a wrong label, the cards to pick from */
.lab-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; width: 100%; }
.lab-row b { color: var(--warn); }
.lab-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 8px; max-height: 60vh; overflow: auto; }
.lab-card { display: flex; align-items: center; gap: 8px; justify-content: flex-start; text-align: left; white-space: normal; min-height: 40px; }
.lab-card .vthumb { width: 34px; height: 34px; cursor: pointer; }
/* Storyboard → Tạo tất cả: the run's bar (panels.js sbRunHTML), the frames it left out under it */
.sbr .sbr-skip { flex-basis: 100%; }
.sbr .sbr-skip summary { cursor: pointer; color: var(--warn); }
.sbr .sbr-skip ul { margin: 6px 0 0; padding-left: 18px; display: grid; gap: 3px; max-height: 220px; overflow: auto; }
/* (8/11, the admin: "khóa giao diện đi em… cảm giác như bị nháy nháy") Prompt video's line of figures stays one line as
   scenes are written (its whole text in its title) */
.sd-sum { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1 1 260px; }
.stale-note { border-color: rgba(245, 158, 11, .45); color: var(--text); }
.pg-check { display: block; margin-top: 2px; font-size: 12px; color: var(--dim); }
.refs-bar { display: flex; flex-direction: column; gap: 10px; padding: 12px 16px 4px; border-bottom: 1px solid var(--line); }
.refs-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.refs-row .ttl { font-weight: 700; display: inline-flex; align-items: center; gap: 6px; }
.refs-count { font-size: 12.5px; color: var(--muted); }
.refs-needs { max-height: 46vh; overflow: auto; }
.ref-kinds { align-self: flex-start; margin-bottom: 8px; }
.ref-kinds .count { font-size: 11px; color: var(--dim); margin-left: 4px; }
.tab.on .count, .ref-kinds .on .count { color: var(--muted); }  /* (17/11) on the lighter chosen chip --dim was 2.4:1 */
.ep.ep-solo, .ep.ep-solo:hover { border: 0; background: none; box-shadow: none; }  /* no frame around a whole tab */
.ep.ep-solo > .ep-body { padding: 0; border: 0; }
.ep-pick { max-width: 62%; overflow-x: auto; flex-wrap: nowrap; }
.ep-pick button { white-space: nowrap; }
.badge.ep-go { cursor: pointer; border: 0; font: inherit; }
.vk-report { display: flex; flex-direction: column; gap: 4px; font-size: 13px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; }
.vk-notes { font-size: 12px; margin-bottom: 8px; }
.vk-notes > summary { cursor: pointer; color: var(--muted); }
.vk-note { margin-top: 8px; }
.vk-note-head { font-weight: 600; margin-bottom: 4px; }
[data-vk-locks] { display: flex; flex-direction: column; gap: 8px; }
.vk-vi { font-size: 12.5px; margin: 0 0 10px; grid-column: 1 / -1; }
.vk-vi > summary, .vk-orig > summary { cursor: pointer; color: var(--muted); font-size: 12px; }
.vk-vi > summary { padding: 2px 0; }
.vk-vi > div { margin-top: 6px; padding: 10px 12px; color: var(--text); line-height: 1.55; background: #1f1f1f;
  border: 1px solid var(--line); border-radius: 8px; }
.vk-orig { margin-top: 4px; }
.vk-note pre { white-space: pre-wrap; font: inherit; color: var(--muted); max-height: 220px; overflow: auto; margin: 0; padding: 8px; border-radius: 8px; background: var(--bg2, rgba(127,127,127,.08)); }
.vk-learn .ctl { flex: 1 1 260px; }
.modal.xl .vk-modal { flex: 1; min-height: 0; overflow: auto; padding-right: 4px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- iPad and other touch screens, narrow windows ---------- */
/* the assistant column hidden ("Ẩn Trợ lý" in the top bar, app.js): the work panel takes the whole width */
.tb-left > .btn { flex: none; }
.proj-name { min-width: 0; }
.chat-toggle { margin-left: auto; }
#app.chat-off .left, #app.chat-off .resizer { display: none; }
#app.chat-off .tb-left { width: auto; min-width: 0; }
.resizer { touch-action: none; }
@media (max-width: 900px) { .left, .tb-left { min-width: 300px; } }
/* the step bar scrolls to the page on screen (panels.js showStep); a very narrow one names only that page */
.pg-steps { position: relative; scrollbar-width: none; }
.pg-steps::-webkit-scrollbar { display: none; }
@container (max-width: 520px) { .pg-step.on:not(.view) .pg-t, .pg-step.on:not(.view) .pg-s { display: none; } .pg-step.on:not(.view) { padding: 3px; } }
/* the project board's header: a narrow screen puts the title and the close button on the first line, the export
   buttons under it (they need about 1,100px in one row) */
.board-head { height: auto; min-height: 56px; flex-wrap: wrap; row-gap: 8px; padding-top: 8px; padding-bottom: 8px; }
.board-head > * { flex-shrink: 0; }
.board-head h2 { flex-shrink: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1280px) {
  .board-head h2 { flex: 1 1 calc(100% - 120px); }
  .board-head [data-close] { order: 1; }
  .board-head > .btn:not([data-close]) { order: 2; }
}
/* the on-screen keyboard (touch.js sets --kb while it is open): dialogs end above it */
.modal-back { bottom: var(--kb, 0px); }
/* a long press shows an element's title (touch.js longPressTips) */
.tap-tip { position: fixed; z-index: 90; max-width: min(360px, calc(100vw - 16px)); max-height: 40vh; overflow: auto; padding: 8px 11px; border-radius: 9px; background: #2b2b2b; color: var(--text); border: 1px solid var(--line2); box-shadow: 0 10px 30px rgba(0,0,0,.45); font-size: 12.5px; line-height: 1.45; white-space: pre-wrap; pointer-events: none; animation: fade .1s; }
@media (hover: none) {
  button[title], a[title], [role="button"][title], .badge[title], .pg-step { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}
/* a tapped block shows its tools (panels.js); with no hover, a faint ⋯ marks the blocks that have them */
.touch-on > .sblk-tools { display: flex; }
@media (hover: none) {
  .script.editable .sblk:not(.on), .beat:not(.on), .acard-sec[data-field]:not(.on), .prompt-box[data-field]:not(.on), .witem:not(.on) { padding-right: 30px; }
  .script.editable .sblk:not(.on)::after, .beat:not(.on)::after, .acard-sec[data-field]:not(.on)::after,
  .prompt-box[data-field]:not(.on)::after, .witem:not(.on)::after {
    content: "⋯"; position: absolute; top: 3px; right: 4px; width: 22px; height: 22px; border-radius: 50%; display: grid;
    place-items: center; font-size: 14px; line-height: 1; color: var(--dim); background: rgba(127,127,127,.1); pointer-events: none;
  }
  .touch-on::after { color: var(--text) !important; background: rgba(139,92,246,.35) !important; }
  .thumb-btn, .vk-thumb [data-vk-del] { opacity: .85; }
  .ep-actions, .card-acts, .scene-top .btn, .tr-head .btn { opacity: 1; }
}
/* finger-sized buttons and fields (Apple asks for about 44 points); a mouse keeps the compact sizes */
@media (pointer: coarse) {
  .btn { height: 38px; padding: 0 14px; }
  .btn.sm { height: 34px; padding: 0 11px; }
  .btn.icon { width: 38px; padding: 0; }
  .btn.sm.icon { width: 34px; }
  .sblk-tools { gap: 4px; padding: 4px; }
  .sblk-tools .btn { height: 34px; padding: 0 10px; }
  .ctl { height: 38px; }
  textarea.ctl { height: auto; }
  .seg button { padding: 8px 13px; }
  .chip { padding: 6px 12px; }
  .chip-add { padding: 7px 12px; }
  .menu button { padding: 11px 12px; }
  .send { width: 40px; height: 40px; }
  .pg-step { padding: 5px 11px 5px 5px; }
  .pg-n { width: 24px; height: 24px; }
  .thumb-btn { width: 36px; height: 36px; }
  .mc-a, .sdc-foot, .ep-actions, .card-acts, .mu-row { gap: 8px; }
  .check-row input, input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .badge.ep-go { padding: 6px 11px; font-size: 11.5px; }
  .label-tag[data-act] { padding: 5px 9px; }
  .switch { width: 44px; height: 26px; }
  .switch::after { width: 20px; height: 20px; }
  .switch.on::after { transform: translateX(18px); }
  summary { padding-top: 6px; padding-bottom: 6px; }
  /* the divider: a wider strip to grab, with a grip in the middle */
  .resizer { width: 20px; margin: 0 -10px; }
  .resizer::after { left: 9px; }
  .resizer::before { content: ""; position: absolute; top: 50%; left: 6px; width: 8px; height: 44px; margin-top: -22px; border-radius: 4px; background: #3a3a3a; z-index: 1; }
}

/* ---------- phones (31/10, the admin: "giao diện khi dùng trên điện thoại không ổn lắm"): no sideways scrolling,
   one column at a time behind a tab bar at the bottom (app.js setPane), the work panel scrolling as one, dialogs on
   the whole screen. Wider screens (computers, iPads) are as they were. ---------- */
.mtabs, .tb-more { display: none; }
@media (max-width: 640px) {
  /* the project's top bar: back, the project's name, ⋯ (Góp ý, Board dự án), the account */
  .tb-left { width: auto; min-width: 0; flex: 1; gap: 4px; padding: 0 4px 0 6px; }
  .tb-right { flex: none; gap: 6px; padding: 0 8px 0 0; }
  .tb-left [data-top="feedback"], .tb-left .chat-toggle, .tb-right [data-top="board"], .user-nm { display: none; }
  .tb-right .tb-more { display: inline-flex; margin-left: 0; }
  .proj-name { flex: 1; font-size: 15px; justify-content: flex-start; }
  /* one column at a time: the work panel, or the assistant */
  .left, .tb-left { min-width: 0; }
  .left { width: 100%; display: none; }
  .resizer { display: none !important; }
  #app.pane-left .left { display: flex !important; }
  #app.pane-left .right { display: none; }
  /* the work panel scrolls as one: the step bar and the section's head go up with the page */
  .right { display: block; overflow-y: auto; overscroll-behavior: contain; }
  .right .r-body { overflow: visible; padding: 12px; }
  .r-head { padding: 7px 12px; }
  .r-head .ttl { white-space: normal; flex-wrap: wrap; row-gap: 2px; }
  .pgbar { padding: 8px 12px; gap: 6px; }
  .pg-step:not(.view) .pg-t { display: none; }
  .pg-step:not(.view) { padding: 3px; }
  .pg-check { display: none; }
  .pg-msg { flex-basis: 100%; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  /* the tab bar */
  .mtabs { display: flex; flex: none; border-top: 1px solid var(--line); background: var(--panel); padding-bottom: env(safe-area-inset-bottom); }
  .mtabs button { flex: 1; height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; background: none; border: 0; color: var(--dim); font-size: 11.5px; font-weight: 600; position: relative; }
  .mtabs button.on { color: var(--text); }
  .mtabs button.on::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 2px; border-radius: 2px; background: var(--brand); }
  .mt-dot { display: none; position: absolute; top: 8px; left: calc(50% + 9px); width: 9px; height: 9px; border-radius: 50%; background: var(--brand); }
  #app.chat-busy .mt-dot { display: block; animation: blink 1.2s infinite; }
  #app.chat-new .mt-dot { display: block; }
  html[style*="--kb"] .mtabs { display: none; }  /* typing: the keyboard has the bottom */
  #toasts { bottom: 70px; max-width: calc(100vw - 24px); }
  /* the home page */
  .home-head { padding: 0 12px; gap: 8px; height: 56px; }
  .home-head .hh-t { display: none; }
  .logo-img { height: 40px; }
  .home main { padding: 16px 12px; }
  .home h1 { font-size: 22px; }
  .start-head { flex-wrap: wrap; }
  /* dialogs on the whole screen, nothing running off to the side */
  /* one screen-sized cell: a tall dialog (Sửa tập with 36 beats) scrolls its body, its Lưu stays on screen (1/11) */
  .modal-back { padding: 0; place-items: stretch; grid-template: minmax(0, 1fr) / minmax(0, 1fr); }
  .modal, .modal.wide, .modal.xwide, .modal.xl { width: 100%; max-width: 100%; height: 100%; max-height: none; border-radius: 0; border: 0; }
  .modal-body { flex: 1; min-height: 0; overflow-x: hidden; }
  .modal-foot { flex-wrap: wrap; padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
  .form { grid-template-columns: minmax(0, 1fr); }
  .form > *, .form label { min-width: 0; }
  .ctl { min-width: 0; max-width: 100%; }
  .menu { max-width: calc(100vw - 16px); }
}
/* phones, second round (31/10): the shot list as cards, then what the section-by-section check at 360-414px found */
@media (max-width: 640px) {
  /* a beat's frame around its scenes is a line over them: two boxes inside each other left too little width */
  .sd-beat { padding: 12px 0 0; border: 0; border-top: 1px solid var(--line2); border-radius: 0; }
  /* Phân cảnh: the scene's buttons on their own line, then each shot a card (panels.js shotSceneHTML): its number,
     seconds and camera on the first line, then what happens, who, the lines, and the rest smaller; a tap edits it */
  .shs-head .spacer { flex-basis: 100%; height: 0; }
  .shs-loc { max-width: calc(100% - 130px); }
  .shs-table { overflow: visible; }
  .shot-table, .shot-table tbody { display: block; min-width: 0; }
  .shot-table thead { display: none; }
  .shot-table tbody tr { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 12px; border-bottom: 1px solid var(--line); }
  .shot-table tbody tr:last-child { border-bottom: 0; }
  .shot-table td, .shot-table td.shs-who { display: block; padding: 0; border: 0; min-width: 0; font-size: 13px; line-height: 1.5; }
  .shot-table tbody tr:hover td { background: none; }
  .shot-table td:has(> .dim:only-child) { display: none; }  /* an empty field */
  .shot-table td.shs-i { font-size: 14px; }
  .shot-table td.shs-i::before { content: "#"; color: var(--dim); }
  .shot-table td.shs-sec { color: var(--muted); margin-right: 4px; }
  .shot-table td.shs-cam { order: 1; padding: 1px 9px; border: 1px solid var(--line2); border-radius: 999px; font-size: 12px; color: var(--text); }
  .shot-table td.shs-frm { order: 1; margin-left: auto; width: auto; min-width: 0; position: static; box-shadow: none; background: none; }  /* the frame at the right of the first line */
  .shot-table td[data-l] { flex: 1 1 100%; }
  .shot-table td[data-l]::before { content: attr(data-l) ": "; font-weight: 600; color: var(--dim); }
  .shot-table td.shs-act { order: 2; color: var(--text); }
  .shot-table td.shs-who { order: 3; color: var(--text); }
  .shot-table td.shs-who div { display: inline; }
  .shot-table td.shs-who div + div::before { content: ", "; color: var(--dim); }
  .shot-table td.shs-dlg { order: 4; color: var(--text); }
  .shot-table td.shs-spot, .shot-table td.shs-frame, .shot-table td.shs-comp, .shot-table td.shs-snd { order: 5; min-width: 0; font-size: 12px; }
  /* Tài khoản: the four tabs two by two (scrolling sideways hid the last one), each account a card (app.js
     usersModal): the box beside, the name and its badges, the menu; then role, projects, use, last sign-in */
  .acc-tabs { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; }
  .acc-tabs button { justify-content: center; padding: 7px 8px; }
  table.u-accounts, table.u-accounts tbody { display: block; }
  table.u-accounts thead tr { display: flex; align-items: center; }
  table.u-accounts thead th:nth-child(n+3) { display: none; }
  table.u-accounts thead th { border: 0; }
  table.u-accounts tbody tr { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; column-gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.u-accounts tbody tr.u-grp { display: block; padding: 0; }
  table.u-accounts td { display: block; padding: 0; border: 0; min-width: 0; }
  table.u-accounts tr.u-grp td { padding: 10px 8px 8px; }
  table.u-accounts td.u-sel { grid-row: span 5; padding-top: 2px; }
  table.u-accounts td.u-who { grid-column: 2; overflow-wrap: anywhere; }
  table.u-accounts td.u-menu { grid-column: 3; grid-row: 1; }
  table.u-accounts td[data-l] { grid-column: 2 / 4; margin-top: 3px; font-size: 12.5px; }
  table.u-accounts td[data-l]::before { content: attr(data-l) ": "; color: var(--dim); }
  /* Kết nối mô hình: the state and its button on a line under the text, which gets the card's width */
  .conn-grid { grid-template-columns: minmax(0, 1fr); }
  .conn-card { flex-wrap: wrap; }
  .conn-card .ci { flex: 1 1 calc(100% - 52px); }
  .conn-card .cs { flex: 1 1 100%; flex-direction: row; justify-content: space-between; align-items: center; padding-left: 52px; }
  /* the home page's empty "+ Tạo … mới" boxes: low */
  .pnew { min-height: 0; padding: 18px 12px; }
  .home-adv > summary { flex-wrap: wrap; }
  .home-adv > summary .dim { flex-basis: 100%; padding-left: 26px; }
  /* small text a size up (a phone is read at arm's length) */
  .badge, .tab .count, .ref-kinds .count, .witem .badge, .vk-thumb .badge, .sdc-added, .label-tag, .variant-of b, .pick small, .spd-days { font-size: 11.5px; }
  .fld > span { font-size: 12px; white-space: normal; }
  .costtag { font-size: 11.5px; height: 18px; }
  .hook b, .kv b, .prompt-box b, .acard-sec .sec-t, .ep-idea b, .ep-core b, .dna-group, .rule-f label, .audit-sub, .beat-form label { font-size: 11px; }
}
/* phones (31/10, the admin: "thanh tiến độ ở trên gim lại được không"): the steps stay at the top of the work panel
   while it scrolls, the stage's note and button go up with the page. .pgbar's own box gives way so the steps stick for
   the whole panel, not only while the bar is on screen. */
@media (max-width: 640px) {
  .pgbar { display: contents; }
  .pg-steps { position: sticky; top: 0; z-index: 4; background: #171717; padding: 8px 12px; border-bottom: 1px solid var(--line); }
  .pg-row { background: #171717; padding: 8px 12px; border-bottom: 1px solid var(--line); }
  /* Nhân vật's frames (panels.js framesHTML): closer in; 3 tiles a row, the head's buttons on their own line, the
     look tapped on the whole screen with Quay lại on top (2/11). (.r-inner.wide's container would hold that screen in
     its own box: its queries are for wide panels only.) */
  .r-inner.wide { container-type: normal; }
  .cfam { padding: 10px; border-radius: 12px; }
  .cfam, .cfam .acard, .ltile { scroll-margin-top: 70px; }
  .cfam-ttl { flex: 1 1 190px; }  /* the rest of the first line: the summary goes under it */
  .cfam-ttl .dim { max-width: none; white-space: normal; }
  .cfam-head .spacer { display: none; }
  .cfam-acts { flex-basis: 100%; }
  .cfam-acts [data-act="fam-draw"] { order: 3; }  /* the two short ones on a line, the long one under them */
  .cfam.closed .cfam-acts { display: none; }  /* a folded frame: its head and strip; the buttons once it is open */
  .cfam-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
  .cfam-detail { display: none; }
  .cfam-split.sheet-open .cfam-detail { display: block; position: fixed; inset: 0; z-index: 50; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
  .cfam-sheet-bar { display: flex; align-items: center; gap: 8px; position: sticky; top: 0; z-index: 1; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); }
  .cfam-sheet-bar .btn svg { transform: rotate(90deg); }
  .cfam-sheet-bar b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .cfam-split.sheet-open .cfam-detail .acard { border: 0; border-radius: 0; }
}
/* (14/11) Phân cảnh → Diễn biến tạo hình (panels.js lookPlanHTML, lookPlanModal) */
.lp-box { border: 1px solid var(--line); border-radius: 10px; background: #1b1b1b; padding: 8px 12px; margin: 0 0 10px; }
.lp-box > summary { cursor: pointer; font-size: 13px; }
.lp-hint { font-size: 12px; margin: 6px 0 8px; }
.lp-top { display: flex; align-items: flex-start; gap: 10px; }
.lp-top .lp-hint { flex: 1; }
.lp-top .btn { flex: none; margin-top: 6px; }
.lp-edit-row .lp-why { grid-column: 1 / 4; font-size: 12px; font-style: italic; }
.lp-row { border-top: 1px solid var(--line); padding: 8px 0 4px; }
.lp-who { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 8px; font-size: 13px; }
.lp-who .btn.sm { padding: 2px 9px; }
.lp-state { font-size: 11px; padding: 1px 7px; border-radius: 999px; white-space: nowrap; }
.lp-ok { background: rgba(34,197,94,.15); color: #86efac; }
.lp-ok-t { color: #86efac; font-size: 12px; }
.lp-draft { background: #262626; color: var(--muted); border: 1px solid var(--line2); }
.lp-stale { background: rgba(245,158,11,.15); color: #fcd34d; }
.lp-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 2px; margin-top: 6px; font-size: 11.5px; }
.lp-chip { padding: 1px 7px; border-radius: 6px; background: #242424; border: 1px solid var(--line); color: var(--text); white-space: nowrap; }
.lp-chip b { color: var(--muted); font-weight: 600; margin-right: 2px; }
.lp-arrow { color: var(--muted); padding: 0 2px; }
.lp-edit { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.lp-edit-row { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 4px 10px; align-items: end; }
.lp-edit-row label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); min-width: 0; }
.lp-edit-row .lp-span { grid-column: 1 / 3; font-size: 11.5px; }
.lp-edit-row [data-lp-del] { grid-column: 3; grid-row: 1; }
.lp-preview { margin-top: 10px; font-size: 12.5px; line-height: 1.5; }
@media (max-width: 640px) { .lp-edit-row { grid-template-columns: 80px minmax(0, 1fr) auto; } }
/* (17/11) Đến cảnh and Prompt video's filter in the pinned bars (panels.js goSceneHTML, sdFilterHTML), as tall as
   the bar's small buttons; a scene named in the assistant's answer, a link to it (chat.js sceneLinks) */
.ctl.go-scene { width: 104px; height: 26px; font-size: 12px; }
.ctl.sd-filter { width: auto; max-width: 220px; height: 26px; font-size: 12px; }
@media (pointer: coarse) { .ctl.go-scene, .ctl.sd-filter { height: 34px; } }
.scene-link { display: inline; padding: 0; border: 0; background: none; font: inherit; color: #c4b5fd; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; cursor: pointer; }
.scene-link:hover { text-decoration-style: solid; }

/* (17/11) a long episode (371 scenes: 55,000 elements on Phân cảnh): the browser lays out and paints only the scene and
   prompt cards near the screen; one far away keeps the height it last had (or about a card's, never drawn yet). They
   already clip their content, so nothing looks different; scrolling, jumping to a scene and Ctrl+F work as before. */
.shs { content-visibility: auto; contain-intrinsic-block-size: auto 760px; }
.sdc { content-visibility: auto; contain-intrinsic-block-size: auto 380px; }
#right.cv-all .shs, #right.cv-all .sdc { content-visibility: visible; }  /* a jump, a redraw keeping the view (panels.js holdLayout) */

/* (17/11) the computer asks for less motion: nothing slides, fades or blinks; a card the page jumps to is still marked
   (the same violet edge, held still while it shows); the loading spinner still turns, slower, as it says work goes on */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; scroll-behavior: auto !important; }
  .modal-back, .menu, .toast, .board, .dna-back, .tap-tip { animation: none; }
  .typing i, #app.chat-busy .mt-dot { animation: none; opacity: .7; }
  .ep.flash, .shs.flash, .sdc.flash, .sd.flash, .cfam.flash { animation: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(139,92,246,.2); }
  .spin { animation-duration: 1.6s; }
}
