/* Motion Content Studio. Flat dark theme: no gradients, no shadows. */
:root {
  --bg: #0b0f19;
  --card: #151c2c;
  --card-2: #1b2438;
  --border: #263149;
  --ink: #e6e8eb;
  --muted: #9aa3af;
  --accent: #f59e0b;
  --accent-hi: #fbbf24;
  --on-accent: #0b0f19;
  --danger: #f97066;
  --ok: #34d399;
  --info: #60a5fa;
  --radius: 12px;
  --radius-sm: 8px;
  --muted-2: #8a94a6;
  --line: #1f283b;
}

* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent-hi); }
h1, h2, h3 { line-height: 1.25; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 3px solid var(--accent-hi); outline-offset: 2px; }

.wrap { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.875rem; }

/* Header and banner */
.topbar { border-bottom: 1px solid var(--border); background: var(--bg); }
.topbar .bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
/* Marketing pages (landing, /format): one row, brand left, nav right, same container as the content */
.topbar > .wrap { display: flex; align-items: center; justify-content: space-between; gap: 8px 12px; min-height: 64px; padding-block: 12px; }
.projectbar { display: flex; align-items: center; justify-content: flex-end; gap: 8px; flex: none; white-space: nowrap; }
.projectbar .navlink { color: var(--muted); font-weight: 600; font-size: 0.875rem; text-decoration: none; padding: 8px 10px; border-radius: var(--radius-sm); }
.projectbar .navlink:hover { color: var(--ink); }
@media (max-width: 559px) { .projectbar .navlink { display: none; } }
.iconbtn { min-width: 36px; padding: 4px; }
.bar-spacer { flex: 1; }
.acct { position: relative; flex: none; }
.acct-btn { border-radius: 50%; width: 36px; height: 36px; min-width: 36px; padding: 0; border-color: var(--border); background: var(--card); }
.acct-btn svg { width: 18px; height: 18px; }
.acct-menu { position: absolute; inset-inline-end: 0; top: calc(100% + 6px); z-index: 70; min-width: 200px; max-width: calc(100vw - 16px); padding: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.acct-menu[hidden] { display: none; }
.acct-menu .sb-mi { text-decoration: none; }
.demo-tag { font-size: 0.8125rem; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; flex: none; }
.curproj strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36ch; }
.linkbtn { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-hi); text-decoration: underline; cursor: pointer; }
/* Save bar (app only): sticky at the top of the content, one slim row. Clean is muted and thin, dirty gets the amber accent, error the danger colour.
   Below dialogs (top layer), the sidebar drawer (60) and menus (70). The status text always comes with a check or dot, never colour alone. */
.savebar { position: sticky; top: 0; z-index: 40; background: var(--card); border-bottom: 1px solid var(--border); white-space: normal; line-height: 1.4; }
.savebar[hidden] { display: none; }
.savebar-in { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; padding-top: 4px; padding-bottom: 4px; min-width: 0; }
.savebar[data-state="dirty"] { border-bottom-color: var(--accent); }
.savebar[data-state="dirty"] .savebar-in { padding-top: 8px; padding-bottom: 8px; }
.savebar[data-state="error"] { border-bottom-color: var(--danger); }
.savebar[data-state="error"] .savebar-in { padding-top: 8px; padding-bottom: 8px; }
.save-ctx { font-size: 0.75rem; font-weight: 600; color: var(--accent-hi); border: 1px solid var(--accent); border-radius: 999px; padding: 0 8px; flex: none; }
.save-ctx[hidden] { display: none; }
.save-note { display: inline-flex; align-items: center; gap: 6px; flex: 1 1 200px; font-size: 0.8125rem; color: var(--muted); min-width: 0; overflow-wrap: anywhere; }
.save-note::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; border: 1.5px solid var(--muted); }
.save-note[data-state="clean"]::before, .save-note[data-state="saved"]::before { width: 5px; height: 9px; border: solid var(--ok); border-width: 0 2px 2px 0; border-radius: 0; transform: rotate(45deg) translate(-1px, -1px); }
.save-note[data-state="dirty"] { color: var(--ink); }
.save-note[data-state="dirty"]::before { background: var(--accent); border-color: var(--accent); }
.save-note[data-state="error"] { color: var(--ink); }
.save-note[data-state="error"]::before { background: var(--danger); border-color: var(--danger); }
.save-note a { color: var(--accent-hi); }
.savebar-actions { display: inline-flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px 8px; margin-inline-start: auto; }
.savebar[data-state="clean"] .btn, .savebar[data-state="saved"] .btn { min-height: 28px; padding-block: 2px; }
#save-btn { white-space: nowrap; }
.conflict-actions { display: inline-flex; flex-wrap: wrap; gap: 8px; }
.conflict-actions[hidden] { display: none; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; color: var(--ink); text-decoration: none; }
.mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; flex: none; }
.banner { background: #2a2110; border-bottom: 1px solid #5b4414; color: #fde7b0; font-size: 0.9rem; }
.banner .wrap { padding-top: 8px; padding-bottom: 8px; }

/* Sidebar: projects and folders. Desktop is a 280px column that can be hidden; under 900px it is an off-canvas drawer. */
.layout { display: flex; align-items: flex-start; }
.content { flex: 1 1 0; min-width: 0; }
.sidebar { position: sticky; top: 0; flex: none; width: 300px; min-width: 300px; height: 100vh; display: flex; flex-direction: column; gap: 14px; padding: 16px; overflow-y: auto; background: var(--bg); border-inline-end: 1px solid var(--border); }
.sidebar[data-open="false"] { display: none; }
.sb-head { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.sb-head .sec { flex: none; }
.sb-count { flex: 1; font-size: 0.75rem; font-variant-numeric: tabular-nums; color: var(--muted); background: var(--card-2); border-radius: 999px; padding: 0 8px; width: fit-content; flex: none; }
.sb-head .iconbtn { margin-inline-start: auto; }
.sb-search { position: relative; }
.sb-search > svg { position: absolute; inset-inline-start: 12px; top: 50%; width: 16px; height: 16px; margin-top: -8px; color: var(--muted); pointer-events: none; }
.sb-search .input { padding-inline-start: 36px; }
.sb-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); font-size: 0.75rem; color: var(--muted); }
.sb-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sb-actions #p-new { grid-column: 1 / -1; min-height: 44px; }
.sb-actions .btn { padding-inline: 8px; white-space: nowrap; }
.sb-tree { flex: 1; min-height: 120px; display: flex; flex-direction: column; gap: 2px; padding-top: 12px; border-top: 1px solid var(--line); overflow-y: auto; }
.sb-tree.drop-root { outline: 2px dashed var(--accent); outline-offset: -2px; }
.sb-rootdrop { display: none; margin-top: auto; padding: 14px 8px; text-align: center; font-size: 0.8125rem; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius-sm); }
.sb-tree[data-dragging] .sb-rootdrop { display: block; }
.sb-empty { padding: 8px 8px; margin: 0; }
.tr { position: relative; display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 4px 4px 4px 10px; font-size: 0.875rem; border-radius: var(--radius-sm); border-inline-start: 2px solid transparent; cursor: pointer; color: #c5cbd6; user-select: none; }
.tr[aria-level="2"] { margin-inline-start: 22px; }
.tr[aria-level="2"]::before { content: ""; position: absolute; inset-inline-start: -12px; top: -2px; bottom: -2px; border-inline-start: 1px solid var(--line); }
.tr:hover { background: var(--card); color: var(--ink); }
.tr > svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.tr[data-kind="project"][aria-selected="true"] { background: rgba(245, 158, 11, 0.12); border-inline-start-color: var(--accent); color: var(--accent-hi); }
.tr[data-kind="project"][aria-selected="true"] > svg { color: var(--accent-hi); }
.tr[data-has-active] .tr-name { color: var(--accent-hi); }
.tr.drop { background: rgba(245, 158, 11, 0.18); outline: 2px dashed var(--accent); outline-offset: -2px; }
.tr:focus-visible { outline: 3px solid var(--accent-hi); outline-offset: -3px; }
.tr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tr-count { font-size: 0.75rem; background: var(--card-2); border-radius: 999px; padding: 0 8px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tr-menu { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; opacity: 1; }
@media (hover: hover) { .tr-menu { opacity: 0; } }
.tr-menu svg { width: 16px; height: 16px; }
.tr:hover .tr-menu, .tr:focus-within .tr-menu, .tr-menu:focus-visible { opacity: 1; }
.tr-menu:hover { background: var(--card-2); color: var(--ink); }
.sb-menu { position: fixed; z-index: 70; min-width: 200px; max-width: calc(100vw - 16px); padding: 4px; background: var(--card); border: 1px solid var(--border); border-radius: 10px; }
.sb-mi { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 6px 10px; border: 0; border-radius: 6px; background: none; text-align: start; cursor: pointer; color: var(--ink); }
.sb-mi span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-mi svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.sb-mi:hover, .sb-mi:focus-visible { background: var(--card-2); }
.sb-mi:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: -2px; }
.sb-mi.danger, .sb-mi.danger svg { color: var(--danger); }
.sb-mi[aria-current="true"] svg:last-child { color: var(--accent-hi); }
.sb-scrim { display: none; }
@media (max-width: 899px) {
  .sidebar { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 60; width: min(86vw, 320px); height: 100dvh; transform: translateX(-100%); transition: transform 0.2s; }
  .sidebar[data-open="false"] { display: flex; visibility: hidden; }
  .sidebar[data-open="true"] { transform: none; }
  .sb-scrim { position: fixed; inset: 0; z-index: 55; background: rgba(5, 8, 14, 0.7); }
  .sb-scrim:not([hidden]) { display: block; }
  .curproj .muted { display: none; }
  .curproj strong { max-width: 18ch; }
}
@media (max-width: 480px) { .brand-name { display: none; } }

/* Controls: secondary buttons are ghost; only the primary action is filled */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 8px 16px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid #2f3b57; background: transparent; font-weight: 600; text-decoration: none; color: var(--ink);
}
.btn:hover:not(:disabled) { background: var(--card-2); border-color: #44527a; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent-hi); border-color: var(--accent-hi); }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 0.875rem; }
.btn.ghost { border-color: transparent; color: #c5cbd6; font-weight: 500; }
.btn.ghost:hover:not(:disabled) { border-color: transparent; color: var(--ink); }
.btn svg { width: 16px; height: 16px; flex: none; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .label { font-size: 0.875rem; font-weight: 500; color: #c5cbd6; }
.input, select.input, textarea.input {
  width: 100%; min-height: 44px; padding: 8px 12px; border-radius: 8px;
  border: 1px solid #34425f; background: var(--bg);
}
textarea.input { min-height: 220px; resize: vertical; line-height: 1.8; font-family: Vazirmatn, Inter, system-ui, -apple-system, "Segoe UI", sans-serif; }
html { color-scheme: dark; }

/* Custom dropdown (button + listbox) */
.dd { position: relative; min-width: 0; }
.dd-btn {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; padding: 8px 12px;
  border-radius: 8px; border: 1px solid #34425f; background: var(--bg); text-align: start; cursor: pointer;
}
.dd-btn:hover { border-color: var(--muted); }
.dd-btn[aria-expanded="true"] { border-color: var(--accent); }
.dd-btn .dd-val { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-btn svg { width: 16px; height: 16px; flex: none; color: var(--muted); transition: transform 0.15s; }
.dd-btn[aria-expanded="true"] svg { transform: rotate(180deg); }
.dd-list {
  position: absolute; z-index: 40; inset-inline: 0; top: calc(100% + 4px); max-height: 260px; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
  background: var(--card); border: 1px solid var(--border); border-radius: 10px; min-width: min(100%, 220px); outline: none;
}
.dd-list[hidden] { display: none; }
.dd-list li { padding: 10px 12px; border-radius: 6px; cursor: pointer; border-inline-start: 3px solid transparent; }
.dd-list li.active { background: rgba(245, 158, 11, 0.14); color: var(--accent-hi); }
.dd-list li[aria-selected="true"] { color: var(--accent); font-weight: 600; border-inline-start-color: var(--accent); }
.dd-list:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 0; }

input[type="range"] { width: 100%; accent-color: var(--accent); min-height: 32px; }
.hint { font-size: 0.8125rem; line-height: 1.5; color: var(--muted-2); }

/* Layout pieces */
main.wrap { padding-top: 20px; padding-bottom: 56px; }
.card { background: var(--card); border-radius: var(--radius); padding: 20px; }
.card h2 { font-size: 1.05rem; margin-bottom: 12px; }
.panel { background: var(--card); border-radius: var(--radius); padding: 20px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* Page structure: header, then zones 40px apart, each opened by a small uppercase label */
.page > * + * { margin-top: 40px; }
.page > .pagehead + * { margin-top: 24px; }
.pagehead h2 { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.pagehead p { margin: 6px 0 0; color: var(--muted); max-width: 64ch; }
.sec-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; }
.sec { margin: 0; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.sec-divider { border-top: 1px solid var(--line); margin: 40px 0 28px; }
section > .hint { margin: 10px 0 24px; }
section > .panel + .folderrow, section > .panel + .folder-note { margin-top: 12px; }
.folderrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 12px; padding: 4px 0; }
.folderrow svg { width: 18px; height: 18px; color: var(--muted); flex: none; }
.folder-label { font-weight: 500; color: #c5cbd6; font-size: 0.875rem; }
.folder-status { flex: 1 1 140px; min-width: 0; overflow-wrap: anywhere; }
.folder-note { margin: 2px 0 0; }

/* Settings: collapsible panel with a one-line summary */
.settings-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.settings-head .label { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.settings .summary { margin-top: 2px; overflow-wrap: anywhere; }
.settings-body { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.settings-body[hidden] { display: none; }

/* Audio and Import screens: three numbered steps. Set up is outline only, Generate (and the paste card) is the raised focal surface, Review is plain rows. */
.page > .step { margin-top: 32px; }
.page > .pagehead + .step { margin-top: 24px; }
.step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 14px; }
.step-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.step-chip { display: inline-grid; place-items: center; flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--card-2); color: var(--muted); font-size: 0.75rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.step-sum { flex: 1 1 180px; min-width: 0; color: var(--muted); font-size: 0.875rem; overflow-wrap: anywhere; }
.step-tools { margin-inline-start: auto; }
.step-setup { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.step-setup .step-head { margin-bottom: 0; }
.step-setup .settings-body { margin-top: 16px; }
.step-setup .grid2 { margin-top: 14px; }
.step-setup .step-head + .grid2 { margin-top: 16px; }
#ad-root .step-setup .step-head { margin-bottom: 14px; }
#ad-root .step-setup .step-head + .grid2 { margin-top: 0; }
.step-row { margin-top: 14px; padding-top: 6px; border-top: 1px solid var(--line); }
.step-row .folderrow { margin-top: 6px; }
.step-generate { background: var(--card); border: 1px solid #3a4560; border-top: 2px solid var(--accent); border-radius: var(--radius); padding: 18px 20px 20px; }
.step-generate .step-chip { background: var(--accent); color: var(--on-accent); }
.step-head-plain { margin-bottom: 14px; }
.state-badge { font-size: 0.75rem; font-weight: 600; padding: 2px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.state-badge.ready { color: var(--ok); border-color: var(--ok); }
.state-badge.needs { color: var(--accent-hi); border-color: var(--accent); }
.gen-reason { margin: 12px 0 0; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; color: var(--accent-hi); font-size: 0.875rem; }
.gen-reason[hidden] { display: none; }
.btn.is-blocked { opacity: 0.55; }
.reel-others { margin: 12px 0 0; }
.actionbar { background: none; padding: 0; }
.actionbar-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px 16px; }
.actionbar-progress { margin-top: 12px; }
.progress-text { justify-content: space-between; margin-bottom: 6px; color: #c5cbd6; }
.actionbar .progress { height: 6px; }

/* Lists: lighter rows, hairline dividers, 1px status accent, actions on the right */
/* One card per audio item, like the Visual Board scenes */
.list { display: grid; gap: 14px; }
.item { display: grid; gap: 12px; background: var(--card); border-inline-start: 2px solid #3a4560; border-radius: var(--radius); padding: 16px 20px; scroll-margin-top: 120px; }
.item[data-status="generating"] { border-inline-start-color: var(--info); }
.item[data-status="saved"], .item[data-status="ready"] { border-inline-start-color: var(--ok); }
.item[data-status="error"] { border-inline-start-color: var(--danger); }
.num { display: inline-grid; place-items: center; min-width: 32px; height: 32px; padding: 0 6px; border-radius: var(--radius-sm); background: var(--card-2); color: var(--muted); font-size: 0.8125rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.item-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 32px; }
.item-head .pill { margin-inline-start: auto; }
.item-title { margin: 0; font-size: 1rem; font-weight: 600; }
.item-main { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 20px; align-items: start; }
.item-text { min-width: 0; display: grid; gap: 8px; align-content: start; }
.item-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-start; justify-content: flex-end; }
@media (max-width: 639px) { .item-main { grid-template-columns: minmax(0, 1fr); } .item-actions { justify-content: flex-start; } .item { padding: 14px 16px; } }
.item .content { line-height: 1.7; font-size: 0.95rem; color: #cfd5de; }
.clamp.long:not(.open) { display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; -webkit-mask-image: linear-gradient(#000 60%, transparent); mask-image: linear-gradient(#000 60%, transparent); }
.more { justify-self: start; background: none; border: 0; padding: 4px 0; min-height: 32px; color: var(--accent-hi); font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
.more:hover { text-decoration: underline; }

.tabs-host { container-type: inline-size; margin-bottom: 28px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); }
.tab {
  flex: none; min-height: 44px; padding: 8px 12px; background: none; border: 0; border-bottom: 3px solid transparent; margin-bottom: -1px;
  color: var(--muted); font-weight: 600; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.tab:focus-visible { outline-offset: -3px; }
.tab svg { width: 16px; height: 16px; flex: none; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--accent-hi); border-bottom-color: var(--accent); }
.tab .count { flex: none; font-size: 0.75rem; line-height: 1.5; background: var(--card-2); border-radius: 999px; padding: 0 6px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tab .count:empty { display: none; }
.tab .tab-ratio { padding: 3px 6px; }
.tab .tab-ratio.vbadge::before { width: 6px; height: 10px; border-width: 1.5px; }
.tab .tab-ratio.hbadge::before { width: 10px; height: 6px; border-width: 1.5px; }
/* Second main row: the workspaces, nested under Import & Parse with a lighter, pill-like look */
.tabs-ws { border-bottom: 0; gap: 6px; margin: 10px 0 0 14px; padding-inline-start: 12px; border-inline-start: 2px solid var(--line); }
.tabs-ws .tab { min-height: 40px; margin: 0; padding: 6px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.tabs-ws .tab[aria-selected="true"] { background: #263149; border-color: var(--accent); }
.tab[data-empty="true"]:not([aria-selected="true"]) { opacity: 0.55; }
.tabs:not(.tabs-ws) .tab { flex: none; }
@container (max-width: 900px) { .tabs:not(.tabs-ws) .tab { flex: none; } .tabs-ws { margin-inline-start: 6px; padding-inline-start: 8px; } }
/* Sub-tabs: lighter segmented control under the main tab */
.subbar { margin-bottom: 24px; }
.subtabs { display: flex; flex-wrap: wrap; gap: 2px; padding: 3px; background: var(--card); border-radius: var(--radius-sm); width: fit-content; max-width: 100%; }
.subtab { flex: 0 1 auto; min-height: 36px; padding: 4px 12px; background: none; border: 0; border-radius: 6px; color: var(--muted); font: inherit; font-size: 0.875rem; font-weight: 500; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center; white-space: nowrap; }
.subtab svg { width: 14px; height: 14px; flex: none; }
.subtab:hover { color: var(--ink); }
.subtab[aria-selected="true"] { background: #263149; color: var(--ink); font-weight: 600; }
.subtab .count { font-size: 0.6875rem; line-height: 1.5; padding: 0 6px; border-radius: 999px; background: var(--card-2); color: var(--muted); font-variant-numeric: tabular-nums; }
.subtab .count:empty { display: none; }
.subtab[aria-selected="true"] .count { background: var(--bg); }
@media (max-width: 559px) { .subtabs { width: 100%; } .subtab { flex: 1 1 auto; padding: 4px 8px; } }
@media (max-width: 479px) { .tab { padding: 8px 8px; } .tab > svg { display: none; } }
.runstat { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -12px 0 20px; padding: 8px 12px; background: var(--card); border-left: 2px solid var(--accent); border-radius: var(--radius-sm); font-size: 0.875rem; }
.runstat[hidden] { display: none; }
.mchip { font-size: 0.75rem; padding: 1px 8px; border-radius: 999px; border: 1px solid #3a4560; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.mchip[data-s="part"] { border-color: var(--accent); color: var(--accent-hi); }
.mchip[data-s="done"] { border-color: var(--ok); color: var(--ok); }
/* Below ~900px of content width the tabs wrap into rows that share the width, so nothing is clipped or scrolled. */
@container (max-width: 900px) {
  .tabs { flex-wrap: wrap; }
  .tab { flex: 1 1 auto; justify-content: center; }
}

.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (min-width: 960px) { .stats { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.stat { background: var(--card); border-radius: var(--radius-sm); padding: 14px 16px; }
.stat b { display: block; font-size: 1.75rem; color: var(--ink); line-height: 1.1; font-variant-numeric: tabular-nums; }

.grid2 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .grid2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.grid3 { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 760px) { .grid3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.warn { margin-top: 12px; border: 1px solid #5b4414; background: #2a2110; color: #fde7b0; border-radius: 8px; padding: 10px 12px; font-size: 0.9rem; }
.warn ul { margin: 4px 0 0; padding-inline-start: 18px; }

/* Content text: direction and font come from the project's content language */
.content { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.9; }
/* Mixed-script text: per-paragraph direction (Persian lines RTL, English lines LTR) and alignment that follows it */
[dir="auto"] { unicode-bidi: plaintext; text-align: start; }
.script-arabic { font-family: Vazirmatn, Inter, system-ui, sans-serif; }
.prompt {
  direction: ltr; text-align: left; unicode-bidi: isolate;
  font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.8125rem; line-height: 1.6;
  background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; white-space: pre-wrap; overflow-wrap: anywhere;
}
.promptlabel { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 16px 0 6px; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.promptlabel.first { margin-top: 0; }
.nocaps { text-transform: none; font-weight: 400; letter-spacing: 0; color: var(--muted-2); }

/* Visual Board: quiet sticky summary, lighter scene rows */
.board-bar { position: sticky; top: 0; z-index: 10; background: var(--bg); padding: 10px 0; }
.board-meters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; }
@media (min-width: 720px) { .board-meters { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); } }
.meter-top { display: flex; justify-content: space-between; gap: 8px; font-size: 0.75rem; color: var(--muted); margin-bottom: 4px; }
.meter-top b { font-variant-numeric: tabular-nums; color: var(--ink); font-weight: 600; }
.board-meters .progress, .miniprogress .progress { height: 4px; border: 0; background: var(--card-2); }
.miniprogress { margin-top: 12px; padding: 14px 16px; background: var(--card); border-radius: var(--radius-sm); }
.board-controls { justify-content: space-between; margin-bottom: 20px; }
.seg { display: inline-flex; gap: 2px; padding: 2px; background: var(--card); border-radius: var(--radius-sm); }
.seg .btn { border-color: transparent; font-weight: 500; color: var(--muted); }
.seg .btn[aria-pressed="true"] { background: #263149; color: var(--ink); font-weight: 600; }
#board-count { margin-bottom: 12px; }
.scenes { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); container-type: inline-size; }
.flowpill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border: 1px solid #5b4414; border-radius: 999px; color: var(--accent-hi); font-size: 0.75rem; font-weight: 600; line-height: 1.5; }
.flowpill svg { width: 12px; height: 12px; }
.pbox { display: flex; flex-direction: column; min-width: 0; }
.pbox .promptlabel { min-height: 32px; margin-bottom: 4px; }
.pbox .prompt { flex: 1; }
@container (min-width: 720px) {
}

/* Progress strip: one segmented row of toggles, never wraps */
.chips { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid #2f3b57; border-radius: var(--radius-sm); }
.chip { position: relative; display: flex; align-items: center; justify-content: center; gap: 6px; flex: 0 0 auto; min-height: 40px; padding: 4px 12px; font-size: 0.8125rem; font-weight: 500; color: var(--muted); cursor: pointer; white-space: nowrap; }
.chip + .chip { border-inline-start: 1px solid #2f3b57; }
.chip:first-child { border-start-start-radius: calc(var(--radius-sm) - 1px); border-end-start-radius: calc(var(--radius-sm) - 1px); }
.chip:last-child { border-start-end-radius: calc(var(--radius-sm) - 1px); border-end-end-radius: calc(var(--radius-sm) - 1px); }
.chip:hover { background: var(--card-2); }
.chip input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.chip svg { width: 16px; height: 16px; flex: none; }
.chip-l { white-space: nowrap; }
.chip-check { display: none; }
.chip:has(input:checked) { background: rgba(52, 211, 153, 0.12); color: var(--ok); }
.chip:has(input:checked) .chip-check { display: inline-block; width: 16px; height: 16px; flex: none; }
.chip:has(input:focus-visible) { outline: 3px solid var(--accent-hi); outline-offset: 2px; position: relative; z-index: 1; }
/* Narrow screens: icon and check only; the full label stays in title and aria-label. */
@media (max-width: 400px) { .chip { gap: 4px; padding-inline: 10px; } .chip-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); } }

/* Reels Studio (9:16): one full-width card per reel, three sections each */
.reels-grid { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.reel { border-top: 2px solid #3a4560; }
.reel[data-status="progress"] { border-top-color: var(--accent); }
.reel[data-status="done"] { border-top-color: var(--ok); }
.reel .clamp { font-size: 0.95rem; color: #cfd5de; line-height: 1.7; }
.reel audio { width: 100%; height: 36px; }
.rnote { margin-top: 8px; }
.warmup { color: var(--muted-2); opacity: 0.6; }
.dimtoggle { gap: 8px; margin-inline-end: auto; }
.vbadge::before { content: ""; display: inline-block; width: 7px; height: 12px; border: 2px solid currentColor; border-radius: 2px; }

/* Status: small dot plus text, never colour alone */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 0.8125rem; font-weight: 500; color: var(--muted); white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; flex: none; }
.pill.generating { color: var(--info); }
.pill.saved, .pill.ready, .pill.st-done { color: var(--ok); }
.pill.error { color: var(--danger); }
.pill.st-todo { color: var(--muted); }
.pill.st-progress { color: var(--accent-hi); }
.badge { display: inline-flex; align-items: center; gap: 6px; background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 0.75rem; padding: 2px 10px; border-radius: 999px; }
.badge.plain { background: var(--card-2); color: var(--muted); font-weight: 600; }

.progress { height: 8px; background: var(--bg); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width 0.2s; }

.audio-row audio, .item audio { width: 100%; max-width: 440px; height: 36px; }
.errtext { color: var(--danger); font-size: 0.875rem; }

.copybtn { border-color: transparent; color: #c5cbd6; font-weight: 500; }
.copybtn[data-state="copied"] { color: var(--ok); }

.footer { border-top: 1px solid var(--border); padding: 20px 0 28px; color: var(--muted); font-size: 0.9rem; }
.footer .wrap { display: flex; flex-wrap: wrap; gap: 8px 20px; justify-content: space-between; }

/* Tailwind preflight resets dialog margin, which pins modals top-left; restore centering. */
dialog { position: fixed; inset: 0; margin: auto; height: fit-content; max-height: calc(100vh - 32px); overflow: auto; background: var(--card); color: var(--ink); border: 1px solid var(--border); border-radius: 12px; padding: 20px; width: calc(100% - 32px); max-width: 420px; }
dialog:not([open]) { display: none; }
dialog::backdrop { background: rgba(5, 8, 14, 0.7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
dialog h2 { font-size: 1.1rem; margin-bottom: 12px; }
dialog .row { justify-content: flex-end; margin-top: 16px; }
/* Confirm dialogs: primary and secondary action in one row (secondary left, primary right), rare actions as links under a hairline. */
.dlg-actions { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 10px; margin-top: 16px; }
.dlg-actions .btn { min-height: 40px; justify-content: center; }
.dlg-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.dlg-foot[hidden] { display: none; }
.linkact { min-height: 32px; padding: 0 2px; background: none; border: 0; color: var(--muted); font: inherit; font-size: 0.8125rem; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.linkact:hover { color: var(--ink); }
.linkact.danger { color: var(--danger); }
.mig-dlg { width: min(520px, calc(100vw - 24px)); padding: 22px 24px; }
.mig-line { margin: 0 0 4px; }
.dlg-stats { display: flex; flex-wrap: wrap; gap: 8px 24px; margin: 14px 0 4px; padding: 10px 14px; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.875rem; color: var(--muted); }
.dlg-stats b { color: var(--ink); font-weight: 600; }
@media (max-width: 480px) {
  .dlg-actions { flex-direction: column; }
  .dlg-actions .btn { width: 100%; }
  .dlg-foot { flex-wrap: wrap; }
}

.toast { position: fixed; inset-inline: 16px; bottom: 16px; max-width: 420px; margin-inline: auto; background: var(--card-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; z-index: 50; }
.toast:empty { display: none; }

.empty { text-align: center; padding: 32px 16px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); }
.empty .btn { margin-top: 12px; }

/* Landing */
.hero { padding: 28px 16px 32px; display: grid; gap: 28px; grid-template-columns: minmax(0, 1fr); align-items: center; }
.hero .eyebrow { color: var(--accent-hi); font-weight: 600; font-size: 0.875rem; margin: 0 0 12px; }
.hero-img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 14px; background: var(--card); }
@media (min-width: 900px) { .hero { padding: 56px 16px 48px; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); gap: 40px; } }
.hero h1 { font-size: clamp(1.75rem, 6vw, 3rem); max-width: 18ch; }
.hero p.lead { font-size: 1.0625rem; color: var(--muted); max-width: 60ch; margin: 16px 0 24px; }
.steps { counter-reset: s; display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); padding: 0; list-style: none; }
@media (min-width: 760px) { .steps { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.steps li { counter-increment: s; }
.steps li::before { content: counter(s); display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-weight: 700; margin-bottom: 8px; }

@media (max-width: 480px) {
  .btn.block-sm { width: 100%; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* Covers & SEO: the main 16:9 cover card at comfortable full width */
.hbadge::before { content: ""; display: inline-block; width: 12px; height: 7px; border: 2px solid currentColor; border-radius: 2px; }
.seo-text { font-size: 0.95rem; color: #cfd5de; }
.copybtn { white-space: nowrap; }
.copyico { display: inline-flex; align-items: center; justify-content: center; flex: none; min-width: 32px; min-height: 32px; padding: 0; border: 1px solid transparent; border-radius: var(--radius-sm); background: transparent; color: var(--muted); cursor: pointer; }
.copyico:hover { color: var(--ink); border-color: var(--line); }
.copyico[data-state="copied"] { color: var(--ok); }
.copyico svg { width: 16px; height: 16px; }
@media (pointer: coarse) { .copyico { min-width: 40px; min-height: 40px; } }

/* Import: outdated sample hint */
.notebar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; margin-top: 12px; padding: 8px 12px; border: 1px solid #5b4414; background: #2a2110; color: #fde7b0; border-radius: var(--radius-sm); font-size: 0.875rem; }
.notebar[hidden] { display: none; }
.notebar span { display: inline-flex; align-items: center; gap: 8px; }
.notebar svg { width: 16px; height: 16px; flex: none; }

/* Reels Studio: collapsible reel cards */
.reel-head { margin: 0; font-size: 1rem; }
.reel-toggle { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; width: 100%; min-height: 44px; padding: 0; background: none; border: 0; color: inherit; font: inherit; text-align: start; cursor: pointer; border-radius: var(--radius-sm); }
.reel-toggle:focus-visible { outline-offset: 4px; }
.reel-toggle > svg { width: 18px; height: 18px; flex: none; color: var(--muted); transition: transform 0.15s; }
.reel-toggle[aria-expanded="true"] > svg { transform: rotate(90deg); }
.reel-name { font-weight: 600; font-size: 1rem; }
.reel-mini { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-inline-start: auto; font-size: 0.8125rem; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dots { display: inline-flex; gap: 4px; }
.dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid #4a5675; }
.dot[data-s="part"] { border-color: var(--accent); background: rgba(245, 158, 11, 0.35); }
.dot[data-s="done"] { border-color: var(--ok); background: var(--ok); }
.reel-body { margin-top: 8px; }
.reel-body[hidden] { display: none; }

/* Input format guide (/format) */
.fmt { padding-top: 24px; padding-bottom: 56px; container: fmt / inline-size; }
.fmt code { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.8125rem; background: var(--card-2); padding: 1px 6px; border-radius: 4px; overflow-wrap: anywhere; }
.fmt-flow { margin: 0; padding-inline-start: 20px; display: grid; gap: 8px; color: #cfd5de; max-width: 72ch; }
.fmt-list { margin: 8px 0 0; padding-inline-start: 18px; display: grid; gap: 6px; color: #cfd5de; font-size: 0.9375rem; }
.fmt-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: 0.9375rem; word-break: normal; overflow-wrap: normal; }
.fmt-table th:nth-child(1) { width: 18%; }
.fmt-table th:nth-child(2) { width: 42%; }
.fmt-table th:nth-child(3) { width: 40%; }
.fmt-table th, .fmt-table td { text-align: start; vertical-align: top; padding: 14px 16px; line-height: 1.55; border-bottom: 1px solid var(--border); }
.fmt-table thead th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.fmt-table tbody th { color: var(--ink); }
.fmt-table td { color: #cfd5de; }
@container fmt (max-width: 640px) {
  .fmt-table { table-layout: auto; }
  .fmt-table th:nth-child(n) { width: auto; }
  .fmt-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .fmt-table, .fmt-table tbody, .fmt-table tr, .fmt-table th, .fmt-table td { display: block; }
  .fmt-table tr { background: var(--card); border-radius: var(--radius-sm); margin-bottom: 12px; padding: 6px 0; }
  .fmt-table th, .fmt-table td { border: 0; padding: 6px 14px; }
  .fmt-table td::before { content: attr(data-label); display: block; font-size: 0.6875rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted-2); }
}
.fmt-tpl { max-height: 420px; overflow: auto; }
.fmt-out { margin-top: 16px; display: grid; gap: 12px; }
.fmt-found { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px 16px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); font-size: 0.875rem; }
.fmt-found .ok { color: var(--ok); }
.fmt-found .miss { color: var(--muted); }
@media (max-width: 560px) { .hide-sm { display: none; } }

/* Attached panel: the tab strip (folder tabs for the reels, or the section tabs) and the content share one bordered surface */
.attached { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.subbar.folder + .attached { border-top-left-radius: 0; }
.attach-strip { background: var(--card); border-bottom: 1px solid var(--line); border-radius: var(--radius) var(--radius) 0 0; padding: 8px; }
.subbar.folder + .attached .attach-strip { border-top-left-radius: 0; }
.attach-strip .subbar { margin: 0; }
.attach-strip .subtabs { background: none; padding: 0; width: 100%; }
.attach-body { padding: 24px 20px 28px; }
@media (max-width: 559px) { .attach-body { padding: 16px 12px 20px; } .attach-strip { padding: 6px; } }
.subbar.folder { margin: 0 0 -1px; position: relative; z-index: 1; }
.subbar.folder .subtabs { background: none; padding: 0; gap: 4px; width: 100%; }
.subbar.folder .subtab { min-height: 44px; padding: 6px 18px; border: 1px solid var(--line); border-bottom: 0; border-radius: 8px 8px 0 0; background: var(--bg); color: var(--muted); font-weight: 600; flex: 0 1 auto; }
.subbar.folder .subtab:hover { color: var(--ink); }
.subbar.folder .subtab[aria-selected="true"] { background: var(--card); color: var(--accent-hi); padding-bottom: 7px; margin-bottom: -1px; }
@media (max-width: 559px) { .subbar.folder .subtab { flex: 1 1 0; padding: 6px 8px; } }
.reelsbar { display: grid; gap: 16px; }
.reelsbar .board-bar { position: static; }
.attach-body .board-bar { background: none; padding: 0; position: static; }
.attach-body .page > * + * { margin-top: 24px; }

/* In-app format guide */
.fmt-dlg { width: min(960px, calc(100vw - 32px)); max-width: none; max-height: calc(100vh - 48px); overflow: auto; padding: 0; background: var(--bg); }
.fmt-dlg-bar { position: sticky; top: 0; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 20px; background: var(--card); border-bottom: 1px solid var(--border); }
.fmt-dlg .fmt { padding: 24px 20px 40px; }
.fmt-dlg .pagehead h1 { display: none; }
.fmt-dlg .row { justify-content: flex-start; margin-top: 0; }
@media (max-width: 559px) { .fmt-dlg { width: 100vw; max-height: 100vh; border-radius: 0; } .fmt-dlg .fmt { padding: 16px 12px 32px; } }

/* Overview page and the sidebar status badge */
.ov > * + * { margin-top: 24px; }
.ov-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 0; align-content: end; }
.ov-dates dd { margin: 2px 0 0; font-variant-numeric: tabular-nums; }
.ov-err { color: var(--danger); }
.ov-err[hidden] { display: none; }
.ov [aria-invalid="true"] { border-color: var(--danger); }
.ov-reels { display: grid; gap: 16px; }
.ov-reel { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; padding-top: 16px; border-top: 1px solid var(--line); }
.ov-reel:first-child { padding-top: 0; border-top: 0; }
@media (min-width: 760px) { .ov-reel { grid-template-columns: 9rem 11rem minmax(0, 1fr); align-items: start; } .ov-reel-name { padding-top: 30px; } }
.ov-check { display: grid; gap: 24px; }
@media (min-width: 760px) { .ov-check { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.ov-group { display: grid; gap: 12px; align-content: start; }
.ov-group .meter { margin: 0; }
.st-badge.dot i { width: 8px; height: 8px; }
.st-badge { flex: none; display: inline-flex; align-items: center; gap: 5px; font-size: 0.6875rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.st-badge i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.st-badge[data-status="in_production"] i { background: var(--info); }
.st-badge[data-status="ready"] i { background: var(--ok); }
.st-badge[data-status="published"] i { background: var(--accent); }
.st-badge[data-status="draft"] { opacity: 0.85; }
@media (max-width: 899px) { .st-badge { font-size: 0.75rem; } }

/* Project title above the tabs */
.projhead { margin-bottom: 20px; }
.ph-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; min-width: 0; }
.ph-title { margin: 0; flex: 1 1 auto; min-width: 0; display: flex; align-items: center; font-size: 1.75rem; line-height: 1.25; font-weight: 700; letter-spacing: -0.01em; }
.ph-name { display: inline-flex; align-items: center; gap: 10px; max-width: 100%; min-width: 0; padding: 2px 8px; margin-inline-start: -8px; border: 1px solid transparent; border-radius: var(--radius-sm); background: none; color: var(--ink); font: inherit; text-align: start; cursor: text; }
.ph-name > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ph-name svg { width: 18px; height: 18px; flex: none; color: var(--muted); }
.ph-name:hover { border-color: var(--border); background: var(--card); }
.ph-name:focus-visible { outline: 3px solid var(--accent-hi); outline-offset: 2px; }
.ph-input { font-size: 1.5rem; font-weight: 700; min-height: 48px; width: 100%; }
.ph-meta { margin: 4px 0 0; font-size: 0.8125rem; color: var(--muted); }
.projhead .st-badge { font-size: 0.8125rem; flex: none; }
.ph-row > .btn { flex: none; }
@media (max-width: 559px) { .ph-title { font-size: 1.375rem; } }

/* One card per work item, one per row, the same anatomy everywhere (itemCardHtml in ui.js). */
.icards, .reel-stack { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
.reel-stack { gap: 0; }
.isec + .isec { margin-top: 28px; }
.icard { display: grid; gap: 14px; min-width: 0; background: var(--card); border-inline-start: 2px solid #3a4560; border-radius: var(--radius); padding: 18px 20px; scroll-margin-top: 120px; }
.icard[data-status="progress"] { border-inline-start-color: var(--accent); }
.icard[data-status="done"], .icard[data-done="true"] { border-inline-start-color: var(--ok); }
.icard.flash { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
.icard-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; }
.icard-title { margin: 0; font-size: 1rem; }
.icard-head .pill { margin-inline-start: auto; }
.icard-narr, .icard .seo-text { margin: 0; }
.icard-prompts { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
@media (min-width: 900px) { .icard-prompts.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.icard .prompt { background: var(--bg); }
.icard-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.icard-foot .copybtn { flex: none; white-space: nowrap; }
.icard-foot .chips { flex: 0 1 auto; margin: 0; }
.icard:not(:has(.icard-foot > *)) .icard-foot { display: none; }

/* Audio item cards (shared icard), estimate line, fix list, credit rates */
.icard[data-status="generating"] { border-inline-start-color: var(--info); }
.icard[data-status="saved"], .icard[data-status="ready"] { border-inline-start-color: var(--ok); }
.icard[data-status="error"] { border-inline-start-color: var(--danger); }
.icard-meta { margin-inline-start: 4px; }
.icard audio, .preview-row audio { width: 100%; max-width: 440px; height: 36px; }
.preview-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.est { margin: 12px 0 0; font-size: 0.875rem; color: var(--muted); }
.est.warn-text { color: var(--accent-hi); }
.est:empty { display: none; }
.fixlist { margin-top: 10px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.fixlist summary { cursor: pointer; font-size: 0.875rem; color: var(--accent-hi); }
.fixlist ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.fixlist li { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; font-size: 0.875rem; }
.fixlist li[data-sev="error"] span { color: var(--danger); }
.rates { margin: 16px 0 0; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; }
.rates legend { padding: 0 6px; font-size: 0.875rem; font-weight: 600; }
.rate-row { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 16px; margin: 10px 0; }
.rate-name { flex: 1 1 100%; font-family: var(--mono, monospace); font-size: 0.8125rem; color: var(--muted); }
.rate-row label { display: grid; gap: 4px; font-size: 0.8125rem; }
.rate-row .input { width: 9rem; }

/* Director Prompt vault */
.dp { padding: 20px; display: grid; gap: 14px; }
.dp-note { margin: 0; }
.dp-empty { margin: 0; padding: 10px 12px; border: 1px solid #5b4414; border-radius: var(--radius-sm); color: var(--accent-hi); }
.dp-box { max-height: min(60vh, 560px); overflow: auto; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); font-family: "JetBrains Mono", "Vazirmatn", ui-monospace, Menlo, Consolas, monospace; font-size: 0.8125rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.dp-edit { width: 100%; min-height: min(55vh, 520px); font-family: "JetBrains Mono", "Vazirmatn", ui-monospace, Menlo, Consolas, monospace; font-size: 0.8125rem; line-height: 1.7; }
.dp-actions { align-items: center; margin-top: 15px; }
.dp-dlg .row { margin-top: 0; }

/* How it works (Import & Parse) */
.howto { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 20px 16px; margin-bottom: 20px; }
.how-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.how-head h3 { margin: 0; font-size: 1rem; font-weight: 700; }
.how-steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.how-steps[hidden] { display: none; }
@media (min-width: 900px) { .how-steps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.how-step { display: grid; grid-template-columns: auto auto minmax(0, 1fr); align-items: center; grid-template-rows: auto 1fr auto; gap: 6px 10px; align-content: stretch; padding: 14px 16px; background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.how-step h4 { margin: 0; font-size: 0.9375rem; }
.how-step p { grid-column: 1 / -1; align-self: start; margin: 0; font-size: 0.875rem; color: var(--muted); line-height: 1.55; }
.how-step .btn { grid-column: 1 / -1; justify-self: start; align-self: end; margin-top: auto; }
.how-step > svg { width: 18px; height: 18px; color: var(--accent-hi); }
.how-chip { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 0.75rem; font-weight: 700; }

/* Generate everything: persistent pipeline panel */
.pipe { display: grid; gap: 8px; margin: 0 0 20px; padding: 12px 16px; background: var(--card); border: 1px solid #3a4560; border-left: 2px solid var(--accent); border-radius: var(--radius-sm); }
.pipe[hidden] { display: none; }
.pipe-top { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }
.pipe .progress { height: 6px; }
.pipe-actions { margin-top: 4px; }

/* Next action banner, prompt pack */
.nextbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: 0 0 16px; padding: 8px 12px; background: var(--card); border-inline-start: 2px solid var(--accent); border-radius: var(--radius-sm); font-size: 0.9375rem; }
.nextbar[hidden] { display: none; }
.nextbar-l { color: var(--accent-hi); font-weight: 700; }
.nextbar-t { flex: 1 1 200px; min-width: 0; }

/* Focused card */
.icard:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

/* Media drop zone, thumbnails, storage meter */
.dropzone { display: flex; align-items: center; gap: 14px; margin: 0 0 16px; padding: 14px 18px; border: 1px dashed #44527a; border-radius: var(--radius); background: var(--card); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--card-2); }
.dropzone > svg { width: 22px; height: 22px; color: var(--accent-hi); flex: none; }
.dropzone strong { display: block; font-size: 0.9375rem; }
.dropzone .hint { display: block; margin-top: 2px; }
/* Media slots: the panel between a card's prompts and its footer. Empty: a compact dashed drop target. Filled: picture or player, file facts, actions. */
.mslots { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); min-width: 0; }
@media (min-width: 900px) { .mslots.two { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.mslot { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mslot-label { display: flex; align-items: center; gap: 8px; min-height: 24px; font-size: 0.75rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.mslot-label .mslot-flag { text-transform: none; letter-spacing: 0; color: var(--accent-hi); }
.mslot-drop { display: flex; align-items: center; gap: 12px; min-height: 64px; padding: 10px 14px; border: 1px dashed #44527a; border-radius: var(--radius-sm); background: var(--bg); cursor: pointer; }
.mslot-drop:hover, .mslot.over .mslot-drop, .mslot.over .mslot-filled { border-color: var(--accent); background: var(--card-2); }
.mslot-drop > svg { width: 20px; height: 20px; color: var(--accent-hi); flex: none; }
.mslot-drop strong { display: block; font-size: 0.875rem; }
.mslot-drop .hint { display: block; }
.mslot-filled { display: flex; align-items: flex-start; gap: 14px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.mslot-media { flex: none; width: 144px; max-width: 40%; }
.mslot-thumb { display: block; width: 100%; aspect-ratio: 16 / 10; padding: 0; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--card-2); overflow: hidden; cursor: zoom-in; color: var(--muted); }
.mslot-thumb:hover { border-color: var(--accent); }
.mslot-thumb img, .mslot-thumb .mph { width: 100%; height: 100%; object-fit: cover; display: grid; place-items: center; }
.mslot-video video { display: block; width: 100%; aspect-ratio: 16 / 10; border-radius: var(--radius-sm); background: #000; object-fit: contain; }
.mslot-info { min-width: 0; flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.mslot-file { max-width: 100%; font-size: 0.875rem; font-weight: 600; overflow-wrap: anywhere; }
.mslot-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.mslot-busy { display: grid; gap: 8px; padding: 10px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--bg); }
.mslot-busy .progress { height: 6px; }
.mslot-busyrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
@media (max-width: 520px) { .mslot-filled { flex-direction: column; } .mslot-media { width: 100%; max-width: none; } }
.lightbox { max-width: min(1100px, calc(100% - 24px)); width: 100%; padding: 12px; }
.lb-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.lb-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.lb-body { display: grid; place-items: center; }
.lb-body img, .lb-body video { max-width: 100%; max-height: calc(100vh - 140px); border-radius: var(--radius-sm); background: #000; }
dialog:has(.resform) { max-width: 560px; }
.res-h { margin: 14px 0 6px; }
.res-list { max-height: 28vh; overflow: auto; }
.unused { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.storage { display: grid; gap: 8px; font-size: 0.875rem; }
.storage .progress { height: 6px; }
.sb-foot.warn-text { color: var(--accent-hi); }

/* Setup tab, audio status line, per-run settings, estimate lines */
.setup-line { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 0 0 14px; padding: 8px 12px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.setup-line .step-sum { flex: 1 1 200px; min-width: 0; }
.runchips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 0 0 12px; }
.chipline { font-family: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace; font-size: 0.8125rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 3px 12px; overflow-wrap: anywhere; }
.pill.custom { color: var(--accent-hi); }
.linkbtn { background: none; border: 0; padding: 0; color: var(--accent-hi); text-decoration: underline; cursor: pointer; font-size: 0.8125rem; }
.est-lines { display: grid; gap: 4px; font-size: 0.8125rem; color: var(--muted); }
.est-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 28px; }
.used { margin: 0; }
.plan { margin-top: 16px; padding: 12px 16px; border: 1px solid var(--line); border-radius: var(--radius); }
.plan-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.plan p { margin: 0; color: var(--muted); }
.runform .field + .field { margin-top: 12px; }

/* Import & Parse: mode toggle and the AI Director screen */
.seg.imp-mode { display: flex; width: 100%; }
.seg.imp-mode .btn { flex: 1 1 0; justify-content: center; min-height: 40px; }
.ad-btns { justify-content: flex-start; margin-top: 4px; }
.ad-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 14px 0 0; }
.ad-chip { padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.8125rem; color: var(--muted); }
.ad-max { display: inline-flex; align-items: center; gap: 8px; margin-inline-start: auto; }
.ad-max .input { width: 5rem; min-height: 32px; padding: 2px 8px; }
.ad-steps { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 0; padding: 0; list-style: none; counter-reset: ad; }
.ad-steps li { counter-increment: ad; padding: 3px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.75rem; color: var(--muted-2); }
.ad-steps li::before { content: counter(ad) ". "; }
.ad-steps li.past { color: var(--ok); border-color: var(--ok); }
.ad-steps li.on { color: var(--accent-hi); border-color: var(--accent); font-weight: 600; }
.ad-status { margin: 12px 0 0; min-height: 1.5em; }
.ad-cost { display: grid; gap: 4px; margin: 12px 0 0; padding: 10px 14px; background: var(--card-2); border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.875rem; }
.ad-stream { max-height: min(55vh, 520px); overflow: auto; margin-top: 12px; padding: 14px 16px; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-sm); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.8; }
.ad-stream[hidden] { display: none; }
.ad-convo { margin-top: 14px; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; }
.ad-convo > summary { cursor: pointer; font-weight: 600; }
.ad-turn { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px 12px; margin-bottom: 8px; }
.ad-turn > summary { cursor: pointer; font-size: 0.875rem; overflow-wrap: anywhere; }
.ad-turn-tools { margin: 8px 0; }
.ad-turn .ad-stream { max-height: 320px; margin-top: 4px; }
.ad-log { margin: 10px 0 0; padding: 0; list-style: none; }
#ad-reply-box { margin-top: 14px; }
@media (max-width: 560px) { .ad-btns .btn { flex: 1 1 100%; justify-content: center; } .ad-max { margin-inline-start: 0; } }

/* Setup: a sub-section inside a provider card (rates, plan), set off by a hairline */
.subsec { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.subsec .rates { margin: 0; padding: 0; border: 0; }
.subsec .rates legend { padding: 0; font-size: 0.9375rem; }
.subsec .plan { margin-top: 16px; }

.field-err { color: var(--danger); font-size: 0.8125rem; font-weight: 500; }
.field-err[hidden] { display: none; }
.ad-model { margin-top: 12px; max-width: 28rem; }
.card-toggle { margin-inline-start: auto; }
.card-toggle svg { transition: transform 0.15s; }
.card-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.card-body { margin-top: 16px; }
.card-body > :first-child { margin-top: 0; }
.card-body[hidden] { display: none; }
@media (prefers-reduced-motion: reduce) { .card-toggle svg { transition: none; } }
.ad-fb { margin-top: 14px; }

/* Guide dialog and the "?" links */
.guide-dlg { height: 100vh; max-height: 100vh; margin-block: 0; }
.guide { padding: 20px 20px 48px; max-width: 760px; margin: 0 auto; }
.guide-start { border: 1px solid var(--accent); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 12px; }
.guide-start p { margin: 4px 0 0; }
.guide-toc ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 12px 0 24px; padding: 0; counter-reset: gt; }
.guide-toc li { counter-increment: gt; }
.guide-toc li::before { content: counter(gt) ". "; color: var(--muted-2); }
.guide-toc a { display: inline-block; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); font-size: 0.875rem; }
.guide-sec { padding: 20px 0; border-top: 1px solid var(--line); scroll-margin-top: 64px; }
.guide-sec:focus { outline: none; }
.guide-sec h3 { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; margin: 0 0 8px; }
.guide-n { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #0B0F19; font-size: 0.875rem; font-weight: 700; flex: none; }
.guide-sec h4 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 14px 0 4px; }
.guide-sec p, .guide-sec li { line-height: 1.6; }
.guide-sec ul { margin: 0; padding-left: 20px; }
.guide-demo { margin-top: 12px; }
.guide-help { display: inline-flex; align-items: center; justify-content: center; min-width: 32px; min-height: 32px; margin-left: 6px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); font-size: 0.875rem; font-weight: 600; cursor: pointer; vertical-align: middle; }
.guide-help:hover { color: var(--ink); border-color: var(--accent); }
.how-head [data-guide] { margin-left: auto; }
@media (max-width: 559px) { .guide { padding: 16px 12px 40px; } .guide-dlg { width: 100vw; } }
