:root {
  --bg: #0b0b0f;
  --bg-2: #121218;
  --card: #16161d;
  --card-2: #1c1c25;
  --line: #2a2a35;
  --text: #f2efe9;
  --muted: #9a97a3;
  --accent: #e8a33d;
  --accent-ink: #1a1206;
  --good: #3ccf8e;
  --warn: #f0b429;
  --bad: #ff6b6b;
  --info: #6ea8fe;
  --radius: 14px;
  --font: 'IBM Plex Sans Arabic', system-ui, 'Segoe UI', Tahoma, sans-serif;
  --display: 'Reem Kufi', 'IBM Plex Sans Arabic', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
img, video { max-width: 100%; display: block; }

/* ===== الهيكل ===== */
.shell { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; grid-template-columns: minmax(0, 1fr); }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 20px; padding: 14px 24px; background: rgba(11, 11, 15, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--display); font-size: 24px; color: var(--accent); letter-spacing: .5px; }
.brand small { font-family: var(--font); font-size: 12px; color: var(--muted); }
.nav { display: flex; gap: 4px; margin-inline-start: auto; }
.nav a { padding: 8px 14px; border-radius: 10px; color: var(--muted); font-weight: 500; font-size: 15px; }
.nav a:hover { color: var(--text); background: var(--card); }
.nav a.on { color: var(--text); background: var(--card-2); }
.main { width: 100%; max-width: 1080px; margin: 0 auto; padding: 28px 24px 110px; }

@media (max-width: 760px) {
  .topbar { padding: 12px 16px; backdrop-filter: none; background: var(--bg); }
  .nav { position: fixed; bottom: 0; inset-inline: 0; margin: 0; justify-content: space-around; background: rgba(18, 18, 24, .96); border-top: 1px solid var(--line); padding: 8px 6px calc(8px + env(safe-area-inset-bottom)); backdrop-filter: blur(10px); }
  .nav a { flex: 1; text-align: center; font-size: 12.5px; padding: 8px 4px; }
  .main { padding: 18px 16px 110px; }
}

/* ===== عناصر ===== */
h1 { font-family: var(--display); font-weight: 700; font-size: 30px; margin: 0 0 6px; line-height: 1.3; }
h2 { font-size: 20px; margin: 0 0 12px; font-weight: 600; }
h3 { font-size: 16px; margin: 0 0 8px; font-weight: 600; }
.sub { color: var(--muted); margin: 0 0 22px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.card + .card { margin-top: 14px; }
.grid { display: grid; gap: 14px; }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.space { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13.5px; }
.mt { margin-top: 16px; } .mt2 { margin-top: 26px; }
.ltr { direction: ltr; text-align: left; unicode-bidi: plaintext; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 18px; border-radius: 11px; border: 1px solid var(--line); background: var(--card-2); cursor: pointer; font-weight: 600; font-size: 15px; transition: transform .08s, background .15s, border-color .15s; }
.btn:hover { border-color: #3a3a48; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #f2b14f; }
.btn.danger { color: var(--bad); }
.btn.ghost { background: transparent; }
.btn.big { padding: 14px 26px; font-size: 16.5px; border-radius: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.rec { border-color: #5a2a2a; }
.btn.rec.on { background: var(--bad); color: #fff; border-color: var(--bad); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(255, 107, 107, .18); } }

label.f, div.f { display: block; margin-bottom: 14px; }
label.f > span, div.f > span { display: block; font-size: 14px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=number], textarea, select {
  width: 100%; background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; padding: 11px 13px; outline: none; transition: border-color .15s;
}
textarea { resize: vertical; min-height: 90px; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.big-input { font-size: 18px; min-height: 120px; padding: 16px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg-2); cursor: pointer; font-size: 14.5px; user-select: none; }
.chip.on { border-color: var(--accent); background: rgba(232, 163, 61, .13); color: var(--text); }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--card-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge.good { color: var(--good); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); } .badge.info { color: var(--info); } .badge.accent { color: var(--accent); }

.notice { border: 1px solid #4a3a1a; background: rgba(232, 163, 61, .08); border-radius: 12px; padding: 12px 16px; font-size: 14.5px; margin-bottom: 18px; }
.notice.bad { border-color: #5a2a2a; background: rgba(255, 107, 107, .08); }

/* ===== الرئيسية ===== */
.hero { background: radial-gradient(120% 140% at 100% 0%, rgba(232, 163, 61, .16), transparent 55%), var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 28px; margin-bottom: 22px; }
.hero h1 { font-size: 34px; }
.meter { height: 8px; background: var(--bg-2); border-radius: 99px; overflow: hidden; border: 1px solid var(--line); }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.job { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 12px; border-radius: 13px; border: 1px solid var(--line); background: var(--card); cursor: pointer; transition: border-color .15s; }
.job:hover { border-color: #3a3a48; }
.job .thumb { width: 64px; height: 64px; border-radius: 10px; background: var(--bg-2) center/cover; border: 1px solid var(--line); }
.job .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; }
.list { display: grid; gap: 10px; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); border: 1px dashed var(--line); border-radius: 14px; }

/* ===== صفحة العمل ===== */
.stepper { display: flex; gap: 6px; margin: 4px 0 22px; overflow-x: auto; padding-bottom: 4px; }
.step { flex: 1; min-width: 92px; padding: 10px 8px; border-radius: 11px; background: var(--card); border: 1px solid var(--line); text-align: center; font-size: 13px; color: var(--muted); }
.step b { display: block; font-size: 12px; opacity: .7; font-weight: 500; }
.step.done { color: var(--text); border-color: #2f4a3c; }
.step.done b { color: var(--good); opacity: 1; }
.step.now { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); font-weight: 600; }
.step.now b { opacity: .8; }
.progress-line { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line); border-top-color: var(--accent); animation: spin .9s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.shot { display: grid; grid-template-columns: 34px 1fr; gap: 12px; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg-2); }
.shot .n { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--card-2); font-weight: 700; color: var(--accent); }
.shot .who { font-size: 13px; color: var(--muted); }
.shot .line { font-size: 17px; font-weight: 600; }
.shot .vis { font-size: 12.5px; color: var(--muted); direction: ltr; text-align: left; margin-top: 6px; }
.shot textarea { min-height: 54px; font-size: 16px; }
.shots-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.tile { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-2); }
.tile .media { aspect-ratio: 9/16; background: var(--card-2) center/cover; display: grid; place-items: center; color: var(--muted); font-size: 13px; position: relative; }
.tile .media video { width: 100%; height: 100%; object-fit: cover; }
.tile .cap { padding: 8px 10px; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.final { display: grid; grid-template-columns: minmax(0, 380px) 1fr; gap: 22px; align-items: start; }
.final video { width: 100%; border-radius: 14px; border: 1px solid var(--line); background: #000; }
@media (max-width: 760px) { .final { grid-template-columns: minmax(0, 1fr); } }
.final > *, .grid > *, .row > * { min-width: 0; }
.copybox { background: var(--bg-2); border: 1px solid var(--line); border-radius: 11px; padding: 12px; white-space: pre-wrap; font-size: 15px; }
.est { font-family: var(--display); font-size: 26px; color: var(--accent); }

.rec-line { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--bg-2); }
.rec-line audio { width: 100%; margin-top: 8px; height: 36px; }

/* ===== المكتبة ===== */
.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line); display: inline-block; vertical-align: middle; }
.logo { width: 56px; height: 56px; border-radius: 12px; background: var(--bg-2) center/contain no-repeat; border: 1px solid var(--line); flex: none; }
.avatar { width: 64px; height: 64px; border-radius: 50%; background: var(--card-2) center/cover; border: 1px solid var(--line); flex: none; display: grid; place-items: center; font-weight: 700; color: var(--accent); }
details.edit summary { cursor: pointer; color: var(--accent); font-weight: 600; margin-top: 10px; list-style: none; }
details.edit summary::-webkit-details-marker { display: none; }
details.edit[open] summary { margin-bottom: 12px; }

/* ===== الدخول ===== */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(80% 60% at 50% 0%, rgba(232, 163, 61, .14), transparent 60%), var(--bg); }
.login .card { width: 100%; max-width: 380px; padding: 30px; }
.login .brand { font-size: 44px; justify-content: center; margin-bottom: 6px; }

#toast { position: fixed; bottom: 90px; inset-inline: 0; margin: 0 auto; width: max-content; max-width: 90vw; background: var(--card-2); border: 1px solid var(--line); padding: 10px 18px; border-radius: 12px; opacity: 0; transform: translateY(10px); transition: .2s; pointer-events: none; z-index: 50; }
#toast.show { opacity: 1; transform: none; }
#toast.bad { border-color: var(--bad); color: var(--bad); }
table.costs { width: 100%; border-collapse: collapse; }
table.costs td, table.costs th { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: start; }

/* ===== وصول بالكيبورد ===== */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(232, 163, 61, .35); }
button.chip { font: inherit; color: var(--muted); }
button.chip.on { color: var(--text); }
.shots-grid.wide { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.shots-grid.wide .tile .media { aspect-ratio: 16/9; }
.shots-grid.square .tile .media { aspect-ratio: 1/1; }
dialog.dlg { background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 16px; padding: 22px; width: min(560px, calc(100vw - 32px)); }
dialog.dlg::backdrop { background: rgba(0, 0, 0, .6); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.badge[data-est] { white-space: normal; }
.mt-1 { margin-top: 6px; }
details#reedit .grid { margin-top: 8px; }
.bad-text { color: var(--bad, #e5484d); }
.row.music { gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.row.music audio { height: 34px; max-width: 100%; }
.row.check { gap: 10px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--line); }
@media (max-width: 760px) { .nav a { font-size: 11.5px; padding: 8px 2px; } }

/* المنتجات والبدايات البديلة */
.photo-thumb { display: block; width: 120px; max-width: 40%; aspect-ratio: 3/4; object-fit: cover; border-radius: 10px; margin: 8px 0; border: 1px solid var(--line, #2a2a33); }
.shot.hook { border-style: dashed; }
.photos { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.photos .ph { position: relative; width: 84px; height: 84px; border-radius: 10px; background: #111 center/cover no-repeat; border: 1px solid var(--line, #2a2a33); }
.photos .ph button { position: absolute; top: 4px; inset-inline-end: 4px; padding: 0 7px; line-height: 22px; border-radius: 999px; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; }
.product-card { border-top: 1px solid var(--line, #2a2a33); padding-top: 12px; margin-top: 12px; }
.photos .ph .dur { position: absolute; bottom: 4px; inset-inline-start: 4px; font-size: 11px; padding: 0 6px; border-radius: 6px; background: rgba(0,0,0,.65); color: #fff; }

/* زر بكلفته: النص والكلفة بنفس الزر (الصرف واضح قبل الضغط) */
.btn.cost-btn { display: inline-flex; align-items: center; gap: 12px; }
.btn.cost-btn .cost { font-weight: 800; padding: 2px 10px; border-radius: 999px; background: rgba(0, 0, 0, .18); font-variant-numeric: tabular-nums; direction: ltr; }
.btn.ghost.cost-btn .cost { background: rgba(232, 163, 61, .14); color: var(--accent); }

/* «المخرج»: بطاقات التصوير لكل لقطة */
details.director { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
details.director summary { cursor: pointer; list-style: none; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-weight: 600; color: var(--accent); }
details.director summary::-webkit-details-marker { display: none; }
details.director .dir-sum { font-weight: 500; font-size: 13px; color: var(--muted); }
.dir-group { margin-top: 10px; }
.dir-opts { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 4px; scrollbar-width: thin; }
.dir-card { flex: none; display: grid; justify-items: center; gap: 4px; min-width: 78px; padding: 10px 8px; border-radius: 12px; border: 1px solid var(--line); background: var(--card-2); color: var(--text); font: inherit; font-size: 12.5px; cursor: pointer; }
.dir-card .ic { font-size: 22px; line-height: 1; }
.dir-card.on { border-color: var(--accent); background: rgba(232, 163, 61, .13); box-shadow: 0 0 0 1px var(--accent) inset; }
.dir-card.small { min-width: 64px; padding: 7px 6px; font-size: 12px; }
.dir-card.small .ic { font-size: 17px; }
.dir-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.look-all { display: grid; gap: 4px; margin: 6px 0 12px; }

/* الطلب الجديد ومكتبة المشروع جنبه */
.newjob { display: grid; gap: 16px; align-items: start; }
@media (min-width: 980px) { .newjob { grid-template-columns: minmax(0, 1fr) 320px; } .newjob .lib { position: sticky; top: 16px; } }
.lib h3 { margin: 0; }
.lib-brand { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.lib-brand .logo { display: grid; place-items: center; font-weight: 800; color: var(--accent); font-size: 22px; }
.lib-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 6px; }
.lib-item { display: grid; gap: 4px; padding: 6px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font: inherit; text-align: start; cursor: pointer; }
.lib-item .th { aspect-ratio: 4/3; border-radius: 8px; background: var(--card-2) center/cover no-repeat; display: grid; place-items: center; font-size: 22px; }
.lib-item .nm { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-item.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.lib-chars { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.lib-char { display: grid; justify-items: center; gap: 2px; width: 84px; text-align: center; }
.lib-char .av { width: 48px; height: 48px; border-radius: 50%; background: var(--card-2) center/cover; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; color: var(--accent); }
/* صف البطاقات يتمرر بمكانه: ما يوسّع اللقطة ولا الصفحة على الموبايل */
.shot { grid-template-columns: 34px minmax(0, 1fr); }
.shot > div, .dir-group, .look-all, details.director { min-width: 0; }
.dir-opts { max-width: 100%; }

/* العنوان الكبير بلونين: الجملة الأولى بيضاء والثانية بلون التمييز */
h1.display { font-size: clamp(30px, 5.2vw, 52px); font-weight: 700; line-height: 1.15; letter-spacing: -.3px; margin-bottom: 10px; }
h1.display em { font-style: normal; color: var(--accent); }

/* أمثلة الطلبات الجاهزة */
.examples { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 4px; }
.examples .ex { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 7px 12px; border-radius: 999px; border: 1px dashed var(--line); background: var(--bg-2); color: var(--muted); font: inherit; font-size: 13.5px; text-align: start; cursor: pointer; }
.examples .ex b { color: var(--text); font-weight: 600; }
.examples .ex:hover, .examples .ex:focus-visible { border-color: var(--accent); color: var(--text); outline: none; }
.examples .ex-ic { color: var(--accent); }
.examples .ex { border-radius: 14px; line-height: 1.5; }
