/* ============================================================
   Frameline — Storyboard Studio
   Theme: production paperwork. Warm black board, bone paper,
   one grease-pencil red. Archivo (condensed for display) + Plex Mono.
   ============================================================ */
:root, .present {
  color-scheme: dark;
  --sheet: #e8e3d6;
  --paper-2: #ffffff;
  --backdrop: rgba(5, 5, 4, 0.8);
  --display: "Archivo", "Noto Kufi Arabic", sans-serif;
  --bg: #0d0d0c;
  --bg-2: #111110;
  --surface: #151514;
  --surface-2: #1a1a18;
  --surface-3: #22221f;
  --surface-4: #2c2c28;
  --line: rgba(236, 232, 223, 0.09);
  --line-2: rgba(236, 232, 223, 0.17);
  --line-3: rgba(236, 232, 223, 0.32);
  --text: #ece8df;
  --text-2: #a5a197;
  --text-3: #6c6961;
  --paper: #e8e3d6;
  --ink: #151513;
  --pencil: #23211e;
  --accent: #f0502e;
  --accent-2: #ff6b4a;
  --accent-ink: #fff;
  --accent-soft: rgba(240, 80, 46, 0.12);
  --danger: #f0502e;
  --danger-soft: rgba(240, 80, 46, 0.12);
  --ok: #ece8df;
  --radius: 6px;
  --radius-sm: 4px;
  --shadow: 0 24px 50px -24px rgba(0, 0, 0, 0.9);
  --font: "Archivo", "IBM Plex Sans Arabic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "IBM Plex Sans Arabic", ui-monospace, "Cascadia Code", monospace;
  --arabic: "IBM Plex Sans Arabic", var(--font);
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --card-min: 290px;
}

/* Light theme: the same production sheet, printed on bone paper */
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f1ede4;
  --bg-2: #ebe6db;
  --surface: #f8f5ef;
  --surface-2: #ece7dd;
  --surface-3: #e3ddd0;
  --surface-4: #d6cfc0;
  --line: rgba(28, 26, 22, 0.1);
  --line-2: rgba(28, 26, 22, 0.18);
  --line-3: rgba(28, 26, 22, 0.38);
  --text: #191815;
  --text-2: #57534b;
  --text-3: #8b867b;
  --paper: #191815;
  --paper-2: #000000;
  --ink: #f6f2ea;
  --sheet: #fffdf8;
  --accent: #d63b1b;
  --accent-2: #bf3216;
  --accent-soft: rgba(214, 59, 27, 0.1);
  --danger: #d63b1b;
  --danger-soft: rgba(214, 59, 27, 0.1);
  --ok: #191815;
  --shadow: 0 24px 50px -24px rgba(60, 45, 20, 0.35);
  --backdrop: rgba(30, 26, 20, 0.45);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { min-height: 100vh; overflow-x: hidden; }
#app { position: relative; min-height: 100vh; }

img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
svg { flex-shrink: 0; }
.ar { font-family: var(--arabic); }
::selection { background: var(--accent); color: #fff; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
kbd {
  font-family: var(--mono); font-size: 10.5px; padding: 1px 5px; border-radius: 3px;
  border: 1px solid var(--line-3); color: var(--text);
}

/* Shared type roles */
.btn, .chip-btn, .seg button, .tab, .meta-pill, .scene-status, .add-row, .add-scene-row, .hint,
.pc-meta, .save-state, .crumbs, .menu-title, .foot-note, .card-foot, .versions-head, .s-extra {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .05em;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: var(--radius-sm);
  border: 1px solid transparent; background: transparent;
  font-size: 11.5px; font-weight: 500; line-height: 1;
  cursor: pointer; white-space: nowrap; user-select: none;
  transition: background .15s, border-color .15s, color .15s, transform .12s, opacity .15s;
}
.btn svg { width: 15px; height: 15px; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; pointer-events: none; }
.btn-primary, .btn-gpt { background: var(--paper); color: var(--ink); }
.btn-primary:hover, .btn-gpt:hover { background: var(--paper-2); }
.btn-secondary { border-color: var(--line-2); color: var(--text); }
.btn-secondary:hover { border-color: var(--text); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--accent); color: #fff; }
.btn-danger:hover { background: var(--accent-2); }
.btn-lg { height: 46px; padding: 0 20px; font-size: 12px; }
.btn-lg svg { width: 16px; height: 16px; }
.w-full { width: 100%; }

.icon-btn {
  width: 34px; height: 34px; display: inline-grid; place-items: center;
  border-radius: var(--radius-sm); border: 1px solid transparent; background: transparent;
  color: var(--text-2); cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.icon-btn svg { width: 16px; height: 16px; }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.sm { width: 28px; height: 28px; }
.icon-btn.sm svg { width: 14px; height: 14px; }
.icon-btn.outlined { border-color: var(--line-2); }
.icon-btn.danger:hover { color: var(--accent); background: var(--accent-soft); }
.icon-btn:disabled { opacity: .3; pointer-events: none; }

.chip-btn {
  display: inline-flex; align-items: center; gap: 7px; height: 28px; padding: 0 10px;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: transparent;
  font-size: 10.5px; font-weight: 500; color: var(--text-2); cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
}
.chip-btn svg { width: 13px; height: 13px; }
.chip-btn:hover { border-color: var(--text); color: var(--text); }
.chip-btn:disabled { opacity: .35; pointer-events: none; }
.chip-btn.gpt { color: var(--text); border-color: var(--line-3); }
.chip-btn.gpt svg { color: var(--accent); }
.chip-btn.gpt:hover { background: var(--paper); border-color: var(--paper); color: var(--ink); }
.scenes.d-s .chip-btn:not(.gpt) .lbl { display: none; }

.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg button {
  height: 30px; min-width: 34px; padding: 0 11px; border: 0; border-right: 1px solid var(--line-2);
  background: transparent; color: var(--text-3); font-size: 10.5px; font-weight: 500; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .15s, color .15s;
}
.seg button:last-child { border-right: 0; }
.seg button svg { width: 13px; height: 13px; }
.seg button:hover { color: var(--text); }
.seg button.on { background: var(--paper); color: var(--ink); }

/* ---------- Topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px;
  height: 60px; padding: 0 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-2);
}
.tb-left, .tb-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.topbar > div:empty { display: none; }
.topbar:has(> div:empty) { grid-template-columns: 1fr auto; }
.tb-right { justify-content: flex-end; }
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark { width: 11px; height: 11px; background: var(--accent); }
.brand-name { font-stretch: 62%; font-weight: 800; font-size: 22px; line-height: 1; text-transform: uppercase; letter-spacing: .02em; }
.crumbs { display: flex; align-items: center; gap: 8px; color: var(--text-3); font-size: 11px; min-width: 0; }
.crumbs a:hover { color: var(--text); }
.crumbs .crumb-current { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }

.tabs { position: relative; display: inline-flex; border: 1px solid var(--line-2); border-radius: var(--radius-sm); overflow: hidden; }
.tabs .thumb { display: none; }
.tab {
  position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 16px; color: var(--text-3); font-weight: 500; font-size: 11px;
  transition: color .25s;
}
.tab svg { width: 14px; height: 14px; }
.tab:hover { color: var(--text); }
.tab { transition: color .25s, background-color .25s; }
.tab.active { color: var(--ink); background: var(--paper); }
.tab-count { font-size: 10.5px; opacity: .7; }

.save-state { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-3); margin-right: 6px; }
.save-state svg { width: 13px; height: 13px; }
.save-state.saving { color: var(--text-2); }
.save-state.saving svg { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Home ---------- */
.home { max-width: 1360px; margin: 0 auto; padding: 0 28px 100px; }

.search {
  display: flex; align-items: center; gap: 8px; height: 36px; padding: 0 12px; width: 280px; max-width: 100%;
  border-radius: var(--radius-sm); border: 1px solid var(--line-2); color: var(--text-3); transition: border-color .15s;
}
.search:focus-within { border-color: var(--text); }
.search svg { width: 15px; height: 15px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-size: 13px; color: var(--text); }

.project-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }
.project-card {
  position: relative; border-radius: var(--radius); overflow: hidden; cursor: pointer;
  background: var(--surface); border: 1px solid var(--line-2);
  transition: border-color .2s; animation: rise .5s var(--ease) both;
}
.project-card:hover { border-color: var(--line-3); }
.pc-cover { position: relative; aspect-ratio: 16/10; background: var(--surface-2); display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: 1fr 1fr; gap: 1px; overflow: hidden; }
.pc-cover > * { min-width: 0; min-height: 0; overflow: hidden; }
.pc-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform .7s var(--ease); }
.project-card:hover .pc-cover img { transform: scale(1.04); }
.pc-cover .main { grid-row: 1 / 3; }
.pc-cover.one { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.pc-cover.two { grid-template-rows: 1fr; }
.pc-cover.empty { display: grid; place-items: center; grid-template-columns: 1fr; grid-template-rows: 1fr; }
.pc-cover.empty .ph-frame { position: absolute; inset: 0; }
.ph-frame {
  width: 100%; height: 100%; position: relative; background-color: var(--surface-2);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 33.34% 33.34%; background-position: -1px -1px;
}
.pc-empty-label { position: relative; z-index: 1; display: flex; align-items: center; gap: 8px; color: var(--text-3); font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; }
.pc-empty-label svg { width: 13px; height: 13px; }
.pc-tag { position: absolute; top: 0; left: 0; z-index: 2; font-family: var(--mono); font-size: 10.5px; line-height: 1; padding: 5px 7px; background: var(--ink); color: var(--paper); }
.pc-body { padding: 14px 16px 14px; }
.pc-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.pc-title-row h3 { font-stretch: 75%; font-size: 21px; font-weight: 700; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pc-logline { margin-top: 4px; color: var(--text-2); font-size: 13px; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 39px; }
.pc-meta { display: flex; align-items: center; gap: 14px; margin-top: 14px; padding-top: 11px; border-top: 1px solid var(--line); font-size: 10.5px; color: var(--text-3); }
.pc-meta span { display: inline-flex; align-items: center; gap: 6px; }
.pc-meta svg { width: 12px; height: 12px; }
.pc-meta .pc-time { margin-left: auto; }
.mini-bar { width: 34px; height: 3px; background: var(--surface-4); overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: var(--text); }

.empty-note { grid-column: 1 / -1; padding: 40px; text-align: center; color: var(--text-3); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Project ---------- */
.project { max-width: 1480px; margin: 0 auto; padding: 0 28px 120px; }
.project-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding: 36px 0 22px; border-bottom: 1px solid var(--line-2); margin-bottom: 4px;
}
.project-head .ph-text { flex: 1; min-width: 280px; }
.title-input {
  width: 100%; border: 0; outline: 0; background: transparent;
  font-stretch: 62%; font-size: clamp(36px, 4.6vw, 64px); font-weight: 800; line-height: 1; text-transform: uppercase;
  padding: 2px 0;
}
.title-input::placeholder, .logline-input::placeholder { color: var(--text-3); }
.logline-input { width: 100%; border: 0; outline: 0; background: transparent; margin-top: 8px; font-size: 15px; color: var(--text-2); }
.ph-meta { display: flex; align-items: center; flex-wrap: wrap; border: 1px solid var(--line-2); border-radius: var(--radius-sm); }
.meta-pill { display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-right: 1px solid var(--line-2); font-size: 10.5px; color: var(--text-3); }
.meta-pill:last-child { border-right: 0; }
.meta-pill svg { width: 13px; height: 13px; }
.meta-pill b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.meta-pill select { border: 0; outline: 0; background: transparent; color: var(--text); font-weight: 500; cursor: pointer; font-size: 10.5px; }
.meta-pill select option { background: var(--surface-2); }

#view { animation: fadeIn .3s var(--ease); }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } }

/* ---------- Storyboard ---------- */
.sb-toolbar {
  position: sticky; top: 60px; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 12px 0; margin-bottom: 14px; background: var(--bg);
}
.sb-toolbar .grp { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hint { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 10.5px; }
.hint svg { width: 13px; height: 13px; }

.scenes { display: flex; flex-direction: column; gap: 44px; }
.scenes.d-s { --card-min: 220px; }
.scenes.d-m { --card-min: 290px; }
.scenes.d-l { --card-min: 400px; }
.scene { animation: rise .45s var(--ease) both; }
.scene-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; padding-bottom: 10px; border-bottom: 1px solid var(--line-2); }
.scene-no { font-family: var(--mono); font-size: 10.5px; line-height: 1; color: #fff; padding: 5px 7px; background: var(--accent); letter-spacing: .05em; white-space: nowrap; }
.scene-title {
  flex: 0 1 auto; min-width: 220px; width: auto; field-sizing: content; max-width: 100%;
  border: 0; outline: 0; background: transparent; border-bottom: 1px solid transparent;
  font-stretch: 62%; font-size: 28px; font-weight: 800; line-height: 1.1; text-transform: uppercase; padding: 0;
  transition: border-color .15s;
}
.scene-title:hover { border-color: var(--line-2); }
.scene-title:focus { border-color: var(--text); }
.scene-title::placeholder { color: var(--text-3); }
.scene-status { display: inline-flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--text-3); }
.scene-status svg { width: 13px; height: 13px; }
.scene-status.done { color: var(--text); }
.scene-status.done svg { color: var(--accent); }
.scene-runtime { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); font-family: var(--mono); font-size: 10.5px; }
.scene-runtime svg { width: 12px; height: 12px; }
.scene-tools { margin-left: auto; display: flex; gap: 2px; opacity: .5; transition: opacity .2s; }
.scene:hover .scene-tools, .scene-tools:focus-within { opacity: 1; }

.shot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: 16px; align-items: start; transition: box-shadow .2s; }
.scene.file-over .shot-grid { box-shadow: 0 0 0 8px var(--bg), 0 0 0 9px var(--paper); }

.shot {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 8px 8px 10px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line-2);
  transition: border-color .2s, opacity .2s; animation: rise .4s var(--ease) both;
}
.shot:hover { border-color: var(--line-3); }
.shot.dragging { opacity: .3; }
.shot.drop-before::before, .shot.drop-after::after { content: ""; position: absolute; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.shot.drop-before::before { left: -10px; }
.shot.drop-after::after { right: -10px; }
.shot-grid.drop-end .add-tile { border-color: var(--accent); border-style: solid; }

.frame { position: relative; border-radius: 2px; overflow: hidden; background: var(--surface-2); }
.frame img { width: 100%; height: 100%; object-fit: cover; transition: transform .6s var(--ease), opacity .3s; }
.frame img:not([src]) { opacity: 0; }
.shot:hover .frame img { transform: scale(1.02); }
.frame.file-over { outline: 2px solid var(--paper); outline-offset: 2px; }
.frame-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  border: 0; cursor: pointer; color: var(--text-3); background-color: var(--surface-2);
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 33.34% 33.34%; background-position: -1px -1px;
  transition: color .2s;
}
.frame-empty svg { width: 22px; height: 22px; stroke-width: 1.5; margin-bottom: 2px; }
.frame-empty span { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); }
.frame-empty small { font-size: 11.5px; }
.frame-empty:hover { color: var(--text); }
.frame-empty:hover span { color: var(--text); }
.shot-no, .ver-badge {
  position: absolute; top: 0; z-index: 2; font-family: var(--mono); font-size: 10.5px; line-height: 1;
  padding: 5px 7px; background: var(--ink); color: var(--paper); pointer-events: none;
}
.shot-no { left: 0; }
.ver-badge { right: 0; display: inline-flex; align-items: center; gap: 4px; background: var(--accent); color: #fff; }
.ver-badge svg { width: 10px; height: 10px; }
.frame-zoom, .grip {
  position: absolute; bottom: 0; z-index: 2; width: 28px; height: 28px; display: grid; place-items: center;
  background: var(--ink); color: var(--paper); border: 0; opacity: 0; transition: opacity .15s, background .15s, color .15s;
}
.frame-zoom { right: 0; cursor: pointer; }
.grip { left: 0; cursor: grab; }
.frame-zoom svg, .grip svg { width: 14px; height: 14px; }
.frame-zoom:hover, .grip:hover { background: var(--paper); color: var(--ink); }
.shot:hover .frame-zoom, .shot:hover .grip { opacity: 1; }
.has-img { cursor: grab; }

.shot-actions { display: flex; align-items: center; gap: 6px; }
.shot-actions .spacer { flex: 1; }
.desc-box { padding: 8px 2px 0; border-top: 1px solid var(--line-2); transition: border-color .15s; }
.desc-box:focus-within { border-color: var(--text); }
.desc-box label { display: block; font-family: var(--mono); font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--text-3); margin-bottom: 3px; }
.desc-box textarea {
  width: 100%; border: 0; outline: 0; background: transparent; resize: none; overflow: hidden;
  font-size: 14px; line-height: 1.45; color: var(--text); min-height: 20px;
}
.desc-box textarea::placeholder { color: var(--text-3); }
.shot-foot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 0 2px; }
.mini-select, .mini-dur {
  height: 24px; border-radius: 3px; background: transparent; border: 1px solid var(--line-2); color: var(--text-2);
  font-family: var(--mono); font-size: 10.5px; padding: 0 5px; outline: 0; cursor: pointer; transition: border-color .15s, color .15s;
}
.mini-select:hover, .mini-dur:hover, .mini-select:focus, .mini-dur:focus-within { border-color: var(--text); color: var(--text); }
.mini-select option { background: var(--surface-2); color: var(--text); }
.mini-dur { display: inline-flex; align-items: center; gap: 4px; cursor: text; }
.mini-dur svg { width: 11px; height: 11px; color: var(--text-3); }
.mini-dur input { width: 28px; border: 0; outline: 0; background: transparent; font-family: var(--mono); font-size: 10.5px; color: inherit; text-align: right; -moz-appearance: textfield; }
.mini-dur input::-webkit-inner-spin-button { -webkit-appearance: none; }
.tags { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; border-radius: 3px;
  background: var(--surface-3); border: 1px solid transparent; font-size: 12px; color: var(--text); cursor: pointer;
  transition: border-color .15s;
}
.tag i { width: 7px; height: 7px; background: var(--c, var(--accent)); }
.tag svg { width: 12px; height: 12px; }
.tag:hover { border-color: var(--line-3); }
.tag.add { width: 24px; padding: 0; justify-content: center; color: var(--text-3); border: 1px dashed var(--line-3); background: transparent; }
.tag.add:hover { color: var(--text); border-color: var(--text); border-style: solid; }

.add-tile {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end; gap: 3px; text-align: left;
  min-height: 220px; border-radius: var(--radius); padding: 16px;
  border: 1px dashed var(--line-3); background: transparent; color: var(--text-3); cursor: pointer;
  transition: border-color .2s, color .2s;
}
.add-tile:hover { border-color: var(--text); border-style: solid; color: var(--text-2); }
.add-tile .ico { margin-bottom: auto; color: var(--accent); }
.add-tile .ico svg { width: 24px; height: 24px; stroke-width: 1.5; }
.add-tile strong { font-stretch: 62%; font-weight: 800; font-size: 24px; line-height: 1; text-transform: uppercase; color: var(--text); }
.add-tile small { font-size: 12.5px; }
.add-tile .link { margin-top: 8px; border: 0; background: none; color: var(--text-2); font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; padding: 0; }
.add-tile .link:hover { color: var(--text); }

.add-scene-row {
  width: 100%; margin-top: 44px; height: 52px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px dashed var(--line-3); background: transparent; color: var(--text-3); cursor: pointer; font-size: 11px; font-weight: 500;
  transition: border-color .2s, color .2s;
}
.add-scene-row svg { width: 14px; height: 14px; }
.add-scene-row:hover { border-color: var(--text); border-style: solid; color: var(--text); }

/* ---------- Script ---------- */
.script-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 40px; align-items: start; padding-top: 28px; }
.script-nav { position: sticky; top: 88px; display: flex; flex-direction: column; gap: 14px; }
.progress-card { display: flex; align-items: center; gap: 14px; padding: 0 0 14px; border-bottom: 1px solid var(--line-2); }
.ring { position: relative; width: 52px; height: 52px; }
.ring svg { width: 52px; height: 52px; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 3; }
.ring .bg { stroke: var(--surface-4); }
.ring .fg { stroke: var(--accent); transition: stroke-dashoffset .6s var(--ease); }
.ring span { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--mono); font-size: 11px; font-weight: 500; }
.progress-card strong { display: block; font-stretch: 62%; font-size: 24px; font-weight: 800; text-transform: uppercase; line-height: 1; }
.progress-card small { color: var(--text-3); font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }
.snav { display: flex; flex-direction: column; }
.snav a {
  display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line);
  color: var(--text-3); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; transition: color .15s;
}
.snav a:hover, .snav a.active { color: var(--text); }
.snav .nav-dot { width: 8px; height: 8px; border: 1px solid var(--text-3); transition: background .2s, border-color .2s; }
.snav a.filled .nav-dot { background: var(--text); border-color: var(--text); }
.snav a.active .nav-dot { border-color: var(--accent); }
.snav a.active.filled .nav-dot { background: var(--accent); }
.snav .nav-ar { font-family: var(--arabic); font-size: 12.5px; letter-spacing: 0; direction: rtl; }

.script-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.s-card { scroll-margin-top: 140px; padding: 20px 22px 22px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line-2); animation: rise .45s var(--ease) both; }
.s-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.s-icon { color: var(--accent); display: grid; place-items: center; }
.s-icon svg { width: 18px; height: 18px; }
.s-head > div:nth-child(2) { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.s-head h3 { font-stretch: 62%; font-size: 26px; font-weight: 800; text-transform: uppercase; line-height: 1; }
.s-head .s-ar { font-family: var(--arabic); color: var(--text-3); font-size: 14px; }
.s-head .s-num { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.s-head .s-extra { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--text-3); font-size: 10.5px; }

.big-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--line-2); outline: 0; background: transparent;
  font-stretch: 75%; font-size: 34px; font-weight: 700; padding: 4px 0 10px; transition: border-color .15s;
}
.big-input:focus { border-color: var(--text); }
.big-input::placeholder { color: var(--text-3); }
.field, .area {
  width: 100%; border: 1px solid var(--line-2); outline: 0; background: var(--bg-2); border-radius: var(--radius-sm);
  font-size: 14px; padding: 9px 12px; transition: border-color .15s; color: var(--text);
}
.field:focus, .area:focus { border-color: var(--text); }
.field::placeholder, .area::placeholder { color: var(--text-3); }
.area { resize: none; overflow: hidden; line-height: 1.6; min-height: 42px; }
.area.story { font-size: 16px; line-height: 1.7; min-height: 180px; padding: 16px 18px; }
select.field { cursor: pointer; appearance: none; padding-right: 30px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236c6961' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; }
select.field option { background: var(--surface-2); }
.foot-note { display: flex; justify-content: flex-end; gap: 14px; margin-top: 8px; font-size: 10.5px; color: var(--text-3); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.char-card, .place-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: var(--radius-sm);
  background: var(--bg-2); border: 1px solid var(--line-2); animation: rise .35s var(--ease) both;
}
.char-card { border-top: 2px solid var(--c); }
.card-top { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 3px; flex-shrink: 0; display: grid; place-items: center; cursor: pointer;
  background: var(--c); color: var(--ink); border: 0; font-family: var(--mono); font-weight: 500; font-size: 12px;
}
.name-input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; font-stretch: 75%; font-size: 20px; font-weight: 700; padding: 2px 0; }
.name-input::placeholder { color: var(--text-3); }
.card-row { display: flex; gap: 8px; }
.card-row > * { flex: 1; min-width: 0; }
.card-foot { display: flex; align-items: center; justify-content: space-between; font-size: 10.5px; color: var(--text-3); }
.card-foot span { display: inline-flex; align-items: center; gap: 5px; }
.card-foot svg { width: 12px; height: 12px; }
.slug { color: var(--text); }
.place-icon { width: 34px; height: 34px; border-radius: 3px; display: grid; place-items: center; border: 1px solid var(--line-2); color: var(--text-2); flex-shrink: 0; }
.place-icon svg { width: 16px; height: 16px; }

.list { display: flex; flex-direction: column; }
.row-item {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 10px 0;
  border-top: 1px solid var(--line); animation: rise .3s var(--ease) both;
}
.list .row-item:first-child { border-top-color: var(--line-2); }
.row-n { height: 34px; display: grid; place-items: center start; font-family: var(--mono); font-size: 11px; color: var(--accent); }
.row-item .area { background: transparent; border-color: transparent; padding: 6px 0; min-height: 34px; font-size: 15px; }
.row-item .area:focus { border-color: transparent; }
.row-tools { display: flex; gap: 0; opacity: .35; transition: opacity .2s; }
.row-item:hover .row-tools, .row-item:focus-within .row-tools { opacity: 1; }

.line-item { grid-template-columns: 180px minmax(0, 1fr) auto; position: relative; padding-left: 12px; }
.line-who { display: flex; flex-direction: column; gap: 6px; }
.line-who select.field { font-family: var(--mono); font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text); padding: 8px 30px 8px 10px; }
.line-who .field { padding: 6px 10px; font-size: 12.5px; font-style: italic; }
.line-item::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 2px; background: var(--c, transparent); }

.add-row {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; height: 34px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px dashed var(--line-3); background: transparent; color: var(--text-2); cursor: pointer; font-size: 10.5px; font-weight: 500;
  transition: border-color .2s, color .2s;
}
.add-row svg { width: 14px; height: 14px; }
.add-row:hover { border-color: var(--text); border-style: solid; color: var(--text); }
.s-empty { padding: 16px 0; border-top: 1px solid var(--line-2); color: var(--text-3); font-size: 13.5px; }

/* Screenplay read view */
.page {
  background: var(--sheet); color: #1b1a17; border-radius: 2px; box-shadow: 0 0 0 1px var(--line); padding: 72px 80px 90px; max-width: 820px; width: 100%; margin: 0 auto;
  font-family: "Courier Prime", "IBM Plex Sans Arabic", "Courier New", monospace; font-size: 15px; line-height: 1.6;
  animation: rise .5s var(--ease) both;
}
.page [dir="rtl"], .page :dir(rtl) { font-family: var(--arabic); }
.page .tp { text-align: center; padding: 40px 0 70px; border-bottom: 1px dashed #b9b3a4; margin-bottom: 40px; }
.page .tp h1 { font-size: 26px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.page .tp p { margin-top: 14px; font-style: italic; color: #5b574e; }
.page .tp small { display: block; margin-top: 30px; color: #8a8478; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; }
.page h4 { font-size: 15px; font-weight: 700; text-transform: uppercase; margin: 34px 0 12px; display: flex; justify-content: space-between; gap: 10px; }
.page h4 span { font-family: var(--arabic); font-weight: 500; color: #8a8478; text-transform: none; }
.page p { margin-bottom: 12px; white-space: pre-wrap; }
.page .muted { color: #9a9488; font-style: italic; }
.page .slugline { font-weight: 700; text-transform: uppercase; margin-top: 18px; }
.page .dlg { margin: 18px auto; max-width: 400px; }
.page .cue { text-align: center; text-transform: uppercase; font-weight: 700; }
.page .paren { text-align: center; color: #5b574e; }
.page .speech { white-space: pre-wrap; text-align: center; }
.page .char-line b { text-transform: uppercase; }

/* ---------- Modal ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 24px; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity .2s; }
.modal {
  position: relative; width: min(520px, 100%); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line-3); border-radius: var(--radius); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(12px); transition: opacity .25s var(--ease), transform .35s var(--ease);
}
.modal-wrap.open .modal-backdrop { opacity: 1; }
.modal-wrap.open .modal { opacity: 1; transform: none; }
.modal-wrap.closing .modal { opacity: 0; transform: translateY(6px); transition-duration: .16s; }
.modal-wrap.closing .modal-backdrop { opacity: 0; transition-duration: .16s; }
.modal.lg { width: min(640px, 100%); }
.modal.xl { width: min(1120px, 100%); }
.m-head { display: flex; align-items: flex-start; gap: 14px; padding: 22px 22px 0; }
.m-head h3 { font-stretch: 62%; font-size: 30px; font-weight: 800; text-transform: uppercase; line-height: 1; }
.m-head p { color: var(--text-2); font-size: 13.5px; margin-top: 6px; }
.m-head .icon-btn { margin-left: auto; margin-top: -4px; margin-right: -6px; }
.m-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 18px; }
.m-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 0 22px 22px; }
.m-foot .left { margin-right: auto; }
.label { display: block; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-2); margin-bottom: 7px; }
.label small { color: var(--text-3); font-size: inherit; text-transform: none; letter-spacing: 0; font-family: var(--font); font-size: 12px; }

.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.choice {
  position: relative; display: flex; flex-direction: column; gap: 6px; padding: 14px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line-2); transition: border-color .15s, background .15s, color .15s;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice svg { width: 18px; height: 18px; color: var(--text-3); margin-bottom: 6px; }
.choice strong { font-stretch: 62%; font-size: 20px; font-weight: 800; text-transform: uppercase; line-height: 1; }
.choice small { font-size: 12px; color: var(--text-3); line-height: 1.4; }
.choice:hover { border-color: var(--line-3); }
.choice:has(input:checked) { border-color: var(--paper); background: var(--paper); color: var(--ink); }
.choice:has(input:checked) svg { color: var(--accent); }
.choice:has(input:checked) small { color: #5b574e; }
.ratio-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ratio {
  display: inline-flex; align-items: center; gap: 9px; height: 38px; padding: 0 12px 0 10px; border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--line-2); font-size: 11.5px; font-family: var(--mono); color: var(--text-2);
  transition: border-color .15s, background .15s, color .15s;
}
.ratio input { position: absolute; opacity: 0; pointer-events: none; }
.ratio i { display: block; border: 1.5px solid currentColor; }
.ratio:hover { border-color: var(--line-3); }
.ratio:has(input:checked) { border-color: var(--paper); color: var(--ink); background: var(--paper); }

/* ---------- ChatGPT modal ---------- */
.gpt-modal { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); }
.gpt-left { padding: 22px; background: var(--bg-2); border-right: 1px solid var(--line-2); display: flex; flex-direction: column; gap: 16px; }
.gpt-frame { position: relative; border-radius: 2px; overflow: hidden; background: #000; }
.gpt-frame img { width: 100%; height: 100%; object-fit: contain; }
.versions-head { display: flex; align-items: center; gap: 8px; font-size: 10.5px; color: var(--text-2); margin-bottom: 10px; }
.versions-head svg { width: 13px; height: 13px; }
.versions-head span { color: var(--text-3); }
.ver-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 6px; }
.ver { position: relative; flex: 0 0 auto; width: 112px; border-radius: 2px; overflow: hidden; cursor: pointer; border: 0; outline: 1px solid var(--line-2); background: var(--surface); padding: 0; opacity: .6; transition: opacity .15s; }
.ver:hover { opacity: 1; }
.ver.on { opacity: 1; outline: 2px solid var(--accent); }
.ver img { width: 100%; aspect-ratio: 16/10; object-fit: cover; }
.ver span { position: absolute; left: 0; top: 0; font-family: var(--mono); font-size: 10px; line-height: 1; padding: 4px 6px; background: var(--ink); color: var(--paper); }
.ver.on span { background: var(--accent); color: #fff; }
.ver-note { font-size: 12.5px; color: var(--text-3); line-height: 1.5; padding-top: 10px; border-top: 1px solid var(--line-2); }
.ver-note b { color: var(--text); font-weight: 500; }
.ver-note svg { width: 13px; height: 13px; vertical-align: -2px; margin-right: 4px; }

.gpt-right { padding: 22px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.gpt-head { display: flex; align-items: center; gap: 12px; }
.gpt-logo { color: var(--accent); display: grid; place-items: center; }
.gpt-logo svg { width: 22px; height: 22px; }
.gpt-head h3 { font-stretch: 62%; font-size: 30px; font-weight: 800; text-transform: uppercase; line-height: 1; }
.gpt-head p { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin-top: 4px; }
.gpt-head .icon-btn { margin-left: auto; }
.suggest { display: flex; flex-wrap: wrap; gap: 6px; }
.suggest button {
  height: 26px; padding: 0 9px; border-radius: 3px; border: 1px solid var(--line-2); background: transparent; color: var(--text-2);
  font-size: 12px; cursor: pointer; transition: color .15s, border-color .15s;
}
.suggest button:hover { color: var(--text); border-color: var(--text); }
.toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--text-2); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { position: relative; width: 32px; height: 18px; border-radius: 2px; background: var(--surface-4); transition: background .2s; flex-shrink: 0; }
.switch::after { content: ""; position: absolute; left: 3px; top: 3px; width: 12px; height: 12px; background: var(--paper); transition: transform .25s var(--ease); }
.toggle input:checked + .switch { background: var(--accent); }
.toggle input:checked + .switch::after { transform: translateX(14px); background: #fff; }
.toggle input:focus-visible + .switch { outline: 2px solid var(--text); outline-offset: 2px; }
details.preview { border-radius: var(--radius-sm); border: 1px solid var(--line-2); background: var(--bg-2); }
details.preview summary { cursor: pointer; padding: 9px 12px; font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-2); list-style: none; display: flex; align-items: center; gap: 8px; }
details.preview summary::-webkit-details-marker { display: none; }
details.preview summary svg { width: 13px; height: 13px; transition: transform .2s; }
details.preview[open] summary svg { transform: rotate(90deg); }
details.preview pre { padding: 0 12px 12px; font-family: var(--mono); font-size: 11.5px; line-height: 1.6; color: var(--text-2); white-space: pre-wrap; word-break: break-word; }

.steps { list-style: none; display: flex; flex-direction: column; border-top: 1px solid var(--line-2); }
.step { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line-2); transition: opacity .25s; }
.step strong { display: block; font-size: 14px; font-weight: 600; }
.step p { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.step-n { width: 26px; height: 26px; display: grid; place-items: center; font-family: var(--mono); font-size: 11px; border: 1px solid var(--line-3); color: var(--text-2); transition: background .25s, color .25s, border-color .25s; }
.step-n svg { width: 13px; height: 13px; }
.step.current .step-n { background: var(--accent); border-color: var(--accent); color: #fff; }
.step.done { opacity: .55; }
.step:not(.current) .btn-gpt { background: transparent; border-color: var(--line-2); color: var(--text); }
.step.current .btn-secondary { background: var(--paper); color: var(--ink); border-color: var(--paper); }
.return-drop {
  display: flex; align-items: center; justify-content: center; gap: 10px; text-align: center; padding: 18px; border-radius: var(--radius-sm);
  border: 1px dashed var(--line-3); color: var(--text-2); font-size: 13px; cursor: pointer; transition: border-color .2s, color .2s;
}
.return-drop svg { width: 17px; height: 17px; color: var(--text-3); }
.return-drop:hover, .return-drop.over { border-color: var(--text); border-style: solid; color: var(--text); }
.return-drop b { color: var(--text); font-weight: 600; }
.return-drop u { text-underline-offset: 3px; }

/* ---------- Popover / menu ---------- */
.popover {
  position: fixed; z-index: 150; min-width: 200px; max-width: 300px; padding: 5px; border-radius: var(--radius);
  background: var(--surface-2); border: 1px solid var(--line-3); box-shadow: var(--shadow);
  opacity: 0; transform: translateY(-4px); transition: opacity .15s, transform .2s var(--ease);
}
.popover.open { opacity: 1; transform: none; }
.menu-item {
  width: 100%; display: flex; align-items: center; gap: 10px; padding: 8px 9px; border-radius: 3px; border: 0; background: transparent;
  font-size: 13px; color: var(--text); cursor: pointer; text-align: left;
}
.menu-item svg { width: 14px; height: 14px; color: var(--text-3); }
.menu-item:hover { background: var(--surface-4); }
.menu-item.danger, .menu-item.danger svg { color: var(--accent-2); }
.menu-sep { height: 1px; background: var(--line-2); margin: 5px 0; }
.menu-title { padding: 6px 9px 4px; font-size: 10px; color: var(--text-3); }
.menu-item .check { margin-left: auto; width: 16px; height: 16px; border: 1px solid var(--line-3); display: grid; place-items: center; }
.menu-item .check svg { width: 11px; height: 11px; color: var(--ink); opacity: 0; }
.menu-item.on .check { background: var(--paper); border-color: var(--paper); }
.menu-item.on .check svg { opacity: 1; }
.menu-item .dot { width: 9px; height: 9px; background: var(--c); flex-shrink: 0; }
.pop-input { display: flex; gap: 6px; padding: 4px 4px 2px; }
.pop-input input { flex: 1; min-width: 0; height: 30px; border-radius: 3px; border: 1px solid var(--line-2); background: var(--bg-2); outline: 0; padding: 0 9px; font-size: 12.5px; }
.pop-input input:focus { border-color: var(--text); }
.pop-empty { padding: 8px 9px; font-size: 12.5px; color: var(--text-3); }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 14px; border-radius: var(--radius-sm);
  background: var(--paper); color: var(--ink); box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 500; animation: toastIn .35s var(--ease) both; max-width: min(560px, calc(100vw - 32px));
}
.toast.out { animation: toastOut .2s ease both; }
.toast > svg { width: 15px; height: 15px; }
.toast.error > svg { color: #c93a1c; }
.toast button { height: 26px; padding: 0 10px; border-radius: 3px; border: 0; background: var(--ink); color: var(--paper); font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; cursor: pointer; }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(6px); } }

/* ---------- Present / animatic ---------- */
.present { position: fixed; inset: 0; z-index: 120; background: #070706; display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; animation: fadeIn .3s var(--ease); }
.pr-top { display: flex; align-items: center; gap: 14px; padding: 14px 22px; border-bottom: 1px solid var(--line); }
.pr-top .scene-no { flex-shrink: 0; }
.pr-top h4 { font-stretch: 62%; font-size: 24px; font-weight: 800; text-transform: uppercase; line-height: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pr-top .counter { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--text-3); }
.pr-stage { position: relative; display: grid; place-items: center; padding: 24px 80px 0; min-height: 0; }
.pr-stage img { max-width: 100%; max-height: 100%; object-fit: contain; animation: prIn .4s var(--ease); }
.pr-stage .pr-empty { width: min(900px, 100%); aspect-ratio: 16/9; display: grid; place-items: center; color: var(--text-3); font-family: var(--mono); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; border: 1px dashed var(--line-3); }
@keyframes prIn { from { opacity: 0; } }
.pr-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; display: grid; place-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); background: transparent; color: var(--text); cursor: pointer; transition: background .15s, color .15s; }
.pr-nav:hover { background: var(--paper); color: var(--ink); }
.pr-nav svg { width: 20px; height: 20px; }
.pr-nav.prev { left: 18px; } .pr-nav.next { right: 18px; }
.pr-caption { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; padding: 18px 24px 10px; text-align: center; }
.pr-caption p { font-size: 18px; max-width: 760px; line-height: 1.45; }
.pr-caption .meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: center; width: 100%; }
.pr-caption .meta .tag { cursor: default; }
.pr-bottom { display: flex; align-items: center; gap: 14px; padding: 10px 22px 18px; }
.pr-play { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 0; background: var(--paper); color: var(--ink); display: grid; place-items: center; cursor: pointer; flex-shrink: 0; }
.pr-play svg { width: 16px; height: 16px; }
.filmstrip { flex: 1; display: flex; gap: 4px; overflow-x: auto; padding: 4px 2px; scrollbar-width: none; }
.filmstrip::-webkit-scrollbar { display: none; }
.fs-item { position: relative; flex: 0 0 96px; aspect-ratio: 16/9; overflow: hidden; border: 0; outline: 1px solid var(--line); cursor: pointer; background: var(--surface-2); opacity: .45; transition: opacity .2s; padding: 0; }
.fs-item img { width: 100%; height: 100%; object-fit: cover; }
.fs-item:hover { opacity: .85; }
.fs-item.on { opacity: 1; outline: 2px solid var(--paper); }
.fs-item .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); width: 0; }
.fs-item.on.playing .bar { animation: bar var(--d, 3s) linear forwards; }
@keyframes bar { to { width: 100%; } }
.fs-item.scene-start { margin-left: 12px; }
.fs-item.scene-start:first-child { margin-left: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 1080px) {
  .gpt-modal { grid-template-columns: 1fr; }
  .gpt-left { border-right: 0; border-bottom: 1px solid var(--line-2); }
}
@media (max-width: 960px) {
  .script-layout { grid-template-columns: 1fr; gap: 20px; }
  .script-nav { position: static; }
  .snav { flex-direction: row; overflow-x: auto; gap: 18px; border-bottom: 1px solid var(--line-2); }
  .snav a { grid-template-columns: 10px auto; white-space: nowrap; border-bottom: 0; }
  .snav .nav-ar { display: none; }
  .progress-card { display: none; }
  .topbar { grid-template-columns: auto 1fr; height: auto; padding: 10px 16px; row-gap: 8px; }
  .topbar .tabs { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .crumbs { display: none; }
  .sb-toolbar { top: 100px; }
}
@media (max-width: 640px) {
  .home, .project { padding-left: 16px; padding-right: 16px; }
  .tb-right .btn span.lbl { display: none; }
  .tb-right .btn { padding: 0 10px; }
  .save-state, .hint { display: none; }
  .choice-grid { grid-template-columns: 1fr; }
  .line-item { grid-template-columns: 1fr; }
  .row-item { grid-template-columns: 26px minmax(0,1fr); }
  .row-item .row-tools { grid-column: 1 / -1; justify-content: flex-end; }
  .page { padding: 40px 24px; }
  .pr-stage { padding: 12px 12px 0; }
  .pr-nav { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Print ---------- */
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; color: #111 !important; }
  .topbar, .sb-toolbar, .shot-actions, .add-tile, .scene-tools, .add-scene-row,
  .frame-zoom, .grip, .tag.add, #toasts, .script-nav, .ph-meta { display: none !important; }
  .project { padding: 0; max-width: none; }
  .project-head, .scene-head { border-color: #bbb; }
  .title-input, .logline-input, .scene-title { color: #111 !important; }
  .scene { break-inside: avoid-page; animation: none; }
  .scene-status, .scene-runtime { color: #555; }
  .shot-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 10px; }
  .shot { break-inside: avoid; background: #fff; border: 1px solid #ccc; animation: none; }
  .desc-box { border-color: #ccc; }
  .desc-box textarea, .mini-select, .mini-dur, .tag { color: #111 !important; background: transparent; }
  .mini-select, .mini-dur { border-color: #ccc; }
  .script-layout { display: block; padding: 0; }
  .page { max-width: none; padding: 0; background: #fff; }
}


/* ============================================================
   Display font (Archivo for Latin, Noto Kufi Arabic for Arabic)
   ============================================================ */
.hero h1, .brand-name, .section-head h2, .new-tile strong, .pc-title-row h3, .title-input, .scene-title,
.add-tile strong, .s-head h3, .progress-card strong, .big-input, .name-input, .m-head h3, .choice strong,
.gpt-head h3, .pr-top h4 { font-family: var(--display); }
.lang-btn { font-family: var(--arabic); font-size: 15px; font-weight: 600; line-height: 1; }
html[lang="ar"] .lang-btn { font-family: var(--mono); font-size: 11.5px; letter-spacing: .04em; }

/* ============================================================
   Arabic
   ============================================================ */
html[lang="ar"] body { font-size: 15px; }
html[lang="ar"], html[lang="ar"] .present { --mono: "IBM Plex Sans Arabic", "IBM Plex Mono", ui-monospace, monospace; --font: "IBM Plex Sans Arabic", "Archivo", system-ui, sans-serif; }
html[lang="ar"] * { letter-spacing: 0 !important; }
html[lang="ar"] :is(.section-head h2, .new-tile strong, .title-input, .scene-title, .add-tile strong, .s-head h3,
  .progress-card strong, .m-head h3, .choice strong, .gpt-head h3, .pr-top h4) { line-height: 1.4; font-weight: 700; }
html[lang="ar"] .section-head h2 { font-size: 28px; }
html[lang="ar"] .title-input { font-size: clamp(30px, 3.8vw, 52px); }
html[lang="ar"] .scene-title { font-size: 23px; }
html[lang="ar"] :is(.new-tile strong, .add-tile strong, .progress-card strong) { font-size: 21px; }
html[lang="ar"] :is(.s-head h3, .m-head h3, .gpt-head h3) { font-size: 22px; }
html[lang="ar"] .choice strong { font-size: 17px; }
html[lang="ar"] :is(.btn, .chip-btn, .seg button, .tab, .add-row, .add-scene-row, .label, .snav a, .desc-box label, .menu-title) { font-size: 12.5px; }
html[lang="ar"] :is(.meta-pill, .scene-status, .hint, .pc-meta, .save-state, .slate, .strip-head, .versions-head, .s-extra, .card-foot, .frame-empty span, .panel figcaption b) { font-size: 12px; }
html[lang="ar"] .page h4, html[lang="ar"] .page .cue { font-family: var(--arabic); }

/* ============================================================
   Right-to-left layout
   ============================================================ */
[dir="rtl"] :is(.shot-no, .grip, .panel-no, .pc-tag, .ver span) { left: auto; right: 0; }
[dir="rtl"] :is(.ver-badge, .frame-zoom) { right: auto; left: 0; }
[dir="rtl"] .shot.drop-before::before { left: auto; right: -10px; }
[dir="rtl"] .shot.drop-after::after { right: auto; left: -10px; }
[dir="rtl"] :is(.scene-tools, .s-head .s-num, .s-head .s-extra, .pc-meta .pc-time, .pr-top .counter, .m-head .icon-btn, .gpt-head .icon-btn) { margin-left: 0; margin-right: auto; }
[dir="rtl"] .s-head .s-extra + .s-num { margin-right: 0; }
[dir="rtl"] .m-head .icon-btn { margin-left: -6px; }
[dir="rtl"] .m-foot .left { margin-right: 0; margin-left: auto; }
[dir="rtl"] .line-item { padding-left: 0; padding-right: 12px; }
[dir="rtl"] .line-item::before { left: auto; right: 0; }
[dir="rtl"] select.field { padding-right: 12px; padding-left: 30px; background-position: left 11px center; }
[dir="rtl"] .line-who select.field { padding: 8px 10px 8px 30px; }
[dir="rtl"] :is(.new-tile, .add-tile, .menu-item) { text-align: right; }
[dir="rtl"] .mini-dur input { text-align: left; }
[dir="rtl"] .switch::after { left: auto; right: 3px; }
[dir="rtl"] .toggle input:checked + .switch::after { transform: translateX(-14px); }
[dir="rtl"] .pr-nav.prev { left: auto; right: 18px; }
[dir="rtl"] .pr-nav.next { right: auto; left: 18px; }
[dir="rtl"] :is(.pr-nav svg, .flip svg) { transform: scaleX(-1); }
[dir="rtl"] details.preview summary svg { transform: scaleX(-1); }
[dir="rtl"] details.preview[open] summary svg { transform: rotate(90deg); }
[dir="rtl"] .fs-item.scene-start { margin-left: 0; margin-right: 12px; }
[dir="rtl"] .fs-item.scene-start:first-child { margin-right: 0; }
[dir="rtl"] .popover { transform-origin: top left; }

/* Inputs that hold codes or links stay left-to-right */
input[dir="ltr"] { text-align: left; }

/* Smooth theme switch */
html.theme-anim, html.theme-anim * { transition: background-color .3s ease, border-color .3s ease, color .3s ease !important; }


/* ============================================================
   Simpler pass: personal workspace, calmer type
   ============================================================ */
.home { max-width: 1240px; padding-top: 40px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; padding-bottom: 22px; margin-bottom: 24px; border-bottom: 1px solid var(--line-2); }
.page-head h1 { font-family: var(--display); font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.page-head p { margin-top: 4px; color: var(--text-3); font-size: 14px; }
.page-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.empty-home { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 80px 24px; border: 1px dashed var(--line-3); border-radius: var(--radius); }
.empty-home .ico { color: var(--accent); margin-bottom: 4px; }
.empty-home .ico svg { width: 30px; height: 30px; stroke-width: 1.5; }
.empty-home strong { font-family: var(--display); font-size: 22px; font-weight: 700; }
.empty-home p { max-width: 46ch; color: var(--text-2); }
.empty-home .row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 10px; }

/* Headings: sentence case, normal width, no shouting */
.brand-name, .title-input, .scene-title, .add-tile strong, .s-head h3, .progress-card strong,
.m-head h3, .choice strong, .gpt-head h3, .pr-top h4, .pc-title-row h3, .name-input, .big-input {
  font-stretch: 100%; text-transform: none; letter-spacing: -0.01em;
}
.brand-name { font-size: 17px; font-weight: 700; }
.title-input { font-size: clamp(28px, 3.4vw, 40px); font-weight: 700; line-height: 1.15; }
.scene-title { font-size: 20px; font-weight: 600; }
.s-head h3, .m-head h3, .gpt-head h3 { font-size: 20px; font-weight: 700; line-height: 1.25; }
.progress-card strong { font-size: 17px; font-weight: 700; }
.add-tile strong { font-size: 17px; font-weight: 600; }
.choice strong { font-size: 15px; font-weight: 600; }
.pr-top h4 { font-size: 17px; font-weight: 600; }
.pc-title-row h3 { font-size: 17px; font-weight: 600; }
.name-input { font-size: 16px; font-weight: 600; }
.big-input { font-size: 26px; font-weight: 700; }

/* Buttons and labels: drop the all-caps mono */
.btn, .chip-btn, .seg button, .tab, .add-row, .add-scene-row, .label, .snav a, .meta-pill, .scene-status,
.hint, .pc-meta, .save-state, .crumbs, .card-foot, .versions-head, .s-extra, .desc-box label, .frame-empty span,
.add-tile .link, details.preview summary, .menu-title, .toast button, .gpt-head p, .progress-card small {
  font-family: var(--font); text-transform: none; letter-spacing: 0;
}
.btn { font-size: 13px; }
.btn-lg { font-size: 14px; }
.chip-btn { font-size: 12.5px; }
.tab, .add-row, .add-scene-row, .snav a { font-size: 13px; }
.label, .desc-box label { font-size: 12.5px; }
.meta-pill, .scene-status, .hint, .pc-meta, .save-state, .crumbs, .card-foot, .versions-head, .s-extra, .gpt-head p, .progress-card small { font-size: 12.5px; }
.gpt-head p { margin-top: 2px; }
.steps { margin-top: 4px; }
.gpt-right { gap: 16px; }
html[lang="ar"] .page-head h1 { font-size: 30px; line-height: 1.4; }
.pc-empty-label { font-family: var(--font); text-transform: none; letter-spacing: 0; font-size: 12.5px; }
