/* ============================================================
   studio.css — واجهة المحرر (خارج المسرح). لا علاقة له بشكل الفيديو.
   ============================================================ */
:root{
  --bg:#F1F2FA; --surface:#FFFFFF; --fg:#14172B; --muted:#5A5F7D; --line:#D9DCEC; --focus:#2B3BFF; --danger:#B3261E;
  --ui:"IBM Plex Sans Arabic","Tajawal",Tahoma,sans-serif;
  --disp:"Cairo","Tajawal",Tahoma,sans-serif;
}
@media (prefers-color-scheme: dark){
  :root:not([data-theme="light"]){ --bg:#0B0D1C; --surface:#151830; --fg:#ECEEF8; --muted:#9BA1C2; --line:#272B4A; --focus:#9AA8FF; --danger:#FF8A80; color-scheme:dark }
}
:root[data-theme="dark"]{ --bg:#0B0D1C; --surface:#151830; --fg:#ECEEF8; --muted:#9BA1C2; --line:#272B4A; --focus:#9AA8FF; --danger:#FF8A80; color-scheme:dark }

body{
  margin:0; background:var(--bg); color:var(--fg); font-family:var(--ui); font-size:16px; line-height:1.7;
  padding-block:24px 56px;
  padding-left:max(16px, env(safe-area-inset-left, 0px));
  padding-right:max(16px, env(safe-area-inset-right, 0px));
}
.app{max-width:86rem; margin-inline:auto; display:grid; gap:20px}
.top{display:flex; flex-wrap:wrap; gap:6px 24px; align-items:end; justify-content:space-between}
.eyebrow{margin:0; font-size:.88rem; color:var(--muted); font-weight:500}
h1{margin:0; font-family:var(--disp); font-weight:900; font-size:clamp(1.5rem,4vw,2.2rem); line-height:1.3; text-wrap:balance}
.total{margin:0; color:var(--muted); font-size:.9rem; font-variant-numeric:tabular-nums}

.studio{display:grid; grid-template-columns:minmax(0,1fr); gap:18px; align-items:start}
.player{min-width:0; order:1}
.editor{min-width:0; order:2; background:var(--surface); border:1px solid var(--line); border-radius:10px; display:flex; flex-direction:row-reverse; align-items:stretch; overflow:hidden}
.sidepanel{min-width:0; order:3; background:var(--surface); border:1px solid var(--line); border-radius:10px; display:flex; flex-direction:row-reverse; align-items:stretch; overflow:hidden}
.sh{margin:0 0 10px; font:800 1rem var(--disp)}
.editor .sclist{margin-bottom:0}
.epane[hidden]{display:none}
@media (min-width:1180px){
  .app{max-width:120rem}
  .studio{grid-template-columns:minmax(320px,390px) minmax(0,1fr) minmax(340px,410px)}
  .player{order:0; position:sticky; top:calc(12px + env(safe-area-inset-top, 0px))}
  .editor, .sidepanel{order:0; position:sticky; top:calc(12px + env(safe-area-inset-top, 0px)); max-height:calc(100dvh - 24px - env(safe-area-inset-top, 0px))}
}
/* شريط التبويبات الرأسي (على نمط الفوتوشوب) */
.rail{display:flex; flex-direction:column; gap:2px; padding:6px 4px; background:color-mix(in srgb, var(--fg) 5%, var(--surface)); border-inline-start:1px solid var(--line); flex:0 0 62px; overflow-y:auto}
.rail button{appearance:none; background:none; border:0; border-radius:8px; padding:.55rem .1rem .4rem; display:grid; justify-items:center; gap:3px; font:700 .68rem/1.2 var(--ui); color:var(--muted); cursor:pointer; position:relative}
.rail button svg{width:22px; height:22px}
.rail button:hover{color:var(--fg); background:color-mix(in srgb, var(--fg) 8%, transparent)}
.rail button[aria-selected="true"]{color:var(--fg); background:var(--surface); box-shadow:0 0 0 1px var(--line) inset}
.rail button[aria-selected="true"]::before{content:""; position:absolute; top:22%; bottom:22%; inset-inline-start:-4px; width:3px; border-radius:3px; background:var(--focus)}
.rail button:focus-visible{outline:2px solid var(--focus); outline-offset:-2px}
.tpanes{flex:1 1 auto; min-width:0; padding:12px; overflow:auto}
/* أكورديون مجموعات المشهد */
.grp.acc{padding:0; margin-bottom:8px; overflow:hidden}
.grp.acc > summary{list-style:none; cursor:pointer; display:flex; align-items:center; justify-content:space-between; gap:8px; padding:.55rem .8rem; font:800 .88rem var(--ui); background:color-mix(in srgb, var(--fg) 4%, transparent)}
.grp.acc > summary::-webkit-details-marker{display:none}
.grp.acc > summary::after, .lyed > summary::after{content:""; flex:none; width:.55em; height:.55em; border-inline-end:2px solid currentColor; border-bottom:2px solid currentColor; transform:rotate(45deg); transition:transform .2s; margin-inline-start:auto; opacity:.7}
.grp.acc[open] > summary::after, .lyed[open] > summary::after{transform:rotate(-135deg)}
.grp.acc[open] > summary{border-bottom:1px solid var(--line)}
.accb{padding:10px 12px 2px}
.lyed > summary{list-style:none; display:flex; align-items:center; gap:8px}
.lyed > summary::-webkit-details-marker{display:none}
.lyed[open]{border-color:var(--focus)}
.controls{display:flex; flex-wrap:wrap; gap:10px 14px; align-items:center; margin-top:14px}
.btn{appearance:none; border:1px solid var(--line); background:var(--surface); color:var(--fg); font:600 .92rem var(--ui); padding:.45rem .9rem; border-radius:8px; cursor:pointer; display:inline-flex; gap:.5rem; align-items:center; justify-content:center}
.btn:hover{border-color:var(--fg)}
.btn.sm{padding:.3rem .7rem; font-size:.85rem}
.btn.danger{color:var(--danger)}
.btn svg{width:14px; height:14px; flex:none}
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .chap button:focus-visible, .tabs button:focus-visible, .pick:focus-visible, .ops button:focus-visible, .lc:focus-visible{outline:2px solid var(--focus); outline-offset:2px}
/* الخط الزمني */
.tlbar{position:relative; margin-top:10px; touch-action:none; cursor:ew-resize; user-select:none}
.chap{display:flex; gap:2px; height:2.5rem}
.chap button{appearance:none; flex:1 1 0; min-width:0; border:0; border-bottom:5px solid var(--c); border-radius:6px; font:800 .8rem var(--ui); cursor:pointer; overflow:hidden; padding:0; opacity:.88}
.chap button:hover{opacity:1}
.chap button.on{opacity:1; outline:2px solid var(--focus); outline-offset:1px}
.playhead{position:absolute; top:-5px; bottom:-5px; width:2px; margin-inline-start:-1px; background:var(--focus); pointer-events:none; box-shadow:0 0 0 1px var(--surface)}
.playhead::before{content:""; position:absolute; top:-4px; left:50%; width:10px; height:10px; margin-left:-5px; border-radius:50%; background:var(--focus)}
.tools{display:flex; flex-wrap:wrap; gap:8px; margin-top:12px}
.btn.on{background:var(--fg); color:var(--bg)}
#seek{flex:1 1 160px; min-width:0; accent-color:var(--focus); height:1.4rem}
.time{font-variant-numeric:tabular-nums; color:var(--muted); font-size:.9rem; min-width:5.5em}
.note2{margin:12px 0 0; color:var(--muted); font-size:.85rem}

.tabs{display:flex; gap:2px; border-bottom:1px solid var(--line); margin-bottom:14px; overflow-x:auto}
.tabs button{appearance:none; background:none; border:0; border-bottom:2px solid transparent; padding:.5rem .65rem; font:700 .88rem var(--ui); color:var(--muted); cursor:pointer; white-space:nowrap}
.tabs button[aria-selected="true"]{color:var(--fg); border-bottom-color:var(--focus)}
.btnrow{display:flex; flex-wrap:wrap; gap:8px; margin-bottom:12px}
.sclist{list-style:none; margin:0 0 14px; padding:0; display:grid; gap:6px}
.sc{display:grid; grid-template-columns:14px minmax(0,1fr); align-items:center; gap:6px; border:1px solid var(--line); border-radius:8px; padding:2px 8px 2px 4px; background:var(--bg)}
.sc.on{border-color:var(--focus); background:var(--surface); box-shadow:0 0 0 1px var(--focus) inset}
.sc .dot{width:14px; height:14px; border-radius:4px; display:block; border:2px solid var(--line)}
.pick{appearance:none; background:none; border:0; text-align:start; font:700 .88rem var(--ui); color:var(--fg); cursor:pointer; padding:.5rem .3rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0}
.pick small{color:var(--muted); font-weight:500; margin-inline-start:.4rem}
.ops{display:flex; gap:2px}
.ops button{appearance:none; background:none; border:1px solid transparent; color:var(--muted); border-radius:6px; min-width:1.9rem; height:1.9rem; cursor:pointer; font:600 .8rem var(--ui)}
.ops button:hover:not(:disabled){border-color:var(--line); color:var(--fg)}
.ops button:disabled{opacity:.35; cursor:default}
.grp{border:1px solid var(--line); border-radius:8px; margin:0 0 12px; padding:10px 12px 2px; min-width:0}
.grp legend{font-weight:800; font-size:.85rem; padding:0 6px}
.field{display:grid; gap:4px; margin-bottom:12px; min-width:0}
.field > label, .lbl{font-size:.82rem; color:var(--muted); font-weight:600}
.field input[type="text"], .field input[type="number"], .field select, .field textarea, #jsonBox, .sel{width:100%; box-sizing:border-box; padding:.45rem .6rem; border:1px solid var(--line); background:var(--bg); color:var(--fg); border-radius:6px; font:inherit; font-size:.92rem}
.field textarea, #jsonBox{resize:vertical}
.field.chk{grid-auto-flow:column; justify-content:start; align-items:center; gap:8px}
.field.chk > label{color:var(--fg)}
.crow{display:flex; align-items:center; gap:8px}
.crow code{font:500 .82rem var(--ui); color:var(--muted); direction:ltr}
input[type="color"]{width:2.6rem; height:2rem; padding:0; border:1px solid var(--line); border-radius:6px; background:var(--bg); cursor:pointer}
.rangerow{display:flex; align-items:center; gap:10px}
.rangerow input{flex:1; min-width:0; accent-color:var(--focus)}
.rangerow output{font-variant-numeric:tabular-nums; color:var(--muted); font-size:.85rem; min-width:2.6em}
.ritem{border:1px dashed var(--line); border-radius:8px; padding:10px 10px 4px; margin:6px 0 8px}
.ritem .btn{margin-bottom:8px}
.imgrow{display:grid; gap:8px}
.imgprev{height:5.5rem; border-radius:8px; background:center/cover no-repeat; border:1px solid var(--line)}
.hint{margin:0 0 12px; color:var(--muted); font-size:.85rem}
#msg{min-height:1.6em; margin:8px 0 0; font-size:.88rem; color:var(--muted)}
bdi{unicode-bidi:isolate}

/* المكتبة */
.lg h3{margin:14px 0 8px; font:800 .9rem var(--ui); color:var(--muted)}
.libg{display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:10px}
.lc{border:1px solid var(--line); border-radius:8px; padding:6px; background:var(--bg); cursor:pointer; display:grid; gap:6px; align-content:start; min-width:0}
.lc:hover{border-color:var(--focus)}
.lc .nm{font:700 .82rem/1.35 var(--ui); overflow-wrap:anywhere}
.lc .nm small{display:block; color:var(--muted); font-weight:500}

.iconpick{border:1px solid var(--line, #cfd3e6); border-radius:8px; padding:.3rem .5rem; background:var(--card, transparent)}
.iconpick summary{cursor:pointer; display:flex; align-items:center; gap:.6rem; font-weight:700}
.iconpick summary svg, .icob svg{width:22px; height:22px; stroke:currentColor; fill:none; stroke-width:2; stroke-linecap:round; stroke-linejoin:round}
.icogrid{display:grid; grid-template-columns:repeat(auto-fill, minmax(38px, 1fr)); gap:4px; max-height:190px; overflow:auto; margin-top:.5rem}
.icob{display:grid; place-items:center; height:38px; border:1px solid var(--line, #cfd3e6); border-radius:8px; background:none; color:inherit; cursor:pointer}
.icob:hover, .icob:focus-visible{outline:2px solid currentColor}
.lyed{border:1px solid var(--line, #cfd3e6); border-radius:8px; padding:.4rem .6rem; margin:.5rem 0}
.lyed summary{cursor:pointer; font-weight:800}

/* قائمة المشاهد: سحب لإعادة الترتيب */
.sc{cursor:grab}
.sc.dragging{opacity:.45}
.sc.over{box-shadow:0 -3px 0 var(--focus)}
.editing{outline:2px solid #2B3BFF; outline-offset:4px; cursor:text; user-select:text; -webkit-user-select:text; min-width:1em}

/* العارض: إرشادات وتحديد */
.guides{position:absolute; inset:0; z-index:15; pointer-events:none;
  background:
    linear-gradient(90deg, transparent calc(33.333% - .5px), rgba(255,255,255,.55) calc(33.333% - .5px) calc(33.333% + .5px), transparent calc(33.333% + .5px) calc(66.666% - .5px), rgba(255,255,255,.55) calc(66.666% - .5px) calc(66.666% + .5px), transparent calc(66.666% + .5px)),
    linear-gradient(0deg, transparent calc(33.333% - .5px), rgba(255,255,255,.55) calc(33.333% - .5px) calc(33.333% + .5px), transparent calc(33.333% + .5px) calc(66.666% - .5px), rgba(255,255,255,.55) calc(66.666% - .5px) calc(66.666% + .5px), transparent calc(66.666% + .5px)),
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(255,61,129,.7) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(0deg, transparent calc(50% - .5px), rgba(255,61,129,.7) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px))}
.guides::after{content:""; position:absolute; inset:5%; border:1px dashed rgba(255,225,77,.9)}
.selbox{position:absolute; z-index:20; border:2px solid #2B3BFF; box-shadow:0 0 0 1px rgba(255,255,255,.8); pointer-events:none}
.hnd{position:absolute; width:14px; height:14px; background:#fff; border:2px solid #2B3BFF; border-radius:50%; pointer-events:auto; touch-action:none; box-sizing:border-box}
.hnd.se{right:-8px; bottom:-8px; cursor:nwse-resize}
.hnd.sw{left:-8px; bottom:-8px; cursor:nesw-resize}
.hnd.ne{right:-8px; top:-8px; cursor:nesw-resize}
.hnd.nw{left:-8px; top:-8px; cursor:nwse-resize}
.hnd:hover{background:#2B3BFF}
.hnd.rot{left:50%; top:-28px; margin-left:-7px; cursor:grab}
.hnd.rot::after{content:""; position:absolute; left:50%; top:100%; width:2px; height:14px; margin-left:-1px; background:#2B3BFF}
.selbox:not(.lay) .rot{display:none}
.snapl{position:absolute; z-index:19; pointer-events:none}
.snapl.v{top:0; bottom:0; width:0; border-left:1px dashed #ff3d81}
.snapl.h{left:0; right:0; height:0; border-top:1px dashed #ff3d81}

/* ملء الشاشة (حقيقي أو احتياطي) */
.player:fullscreen, .player.pseudo-fs{background:#000; color:#fff; --fg:#fff; --bg:#000; --surface:#1d1f33; --line:#3a3e5c; --muted:#b8bdd9; display:flex; flex-direction:column; justify-content:center; padding:12px; box-sizing:border-box; overflow:auto}
.player.pseudo-fs{position:fixed; inset:0; z-index:9999; top:0 !important}
.player:fullscreen .stage, .player.pseudo-fs .stage{width:min(100%, calc((100dvh - 150px) * var(--arn, 1.7778)))}
.player:fullscreen .note2, .player.pseudo-fs .note2, .player:fullscreen .tools, .player.pseudo-fs .tools{display:none}

/* نافذة اللقطة */
.shotdlg{position:fixed; inset:0; background:rgba(0,0,0,.72); display:grid; place-items:center; z-index:10000; padding:16px}
.shotdlg[hidden]{display:none}
.shotbox{background:var(--surface); color:var(--fg); border-radius:12px; padding:14px; max-width:min(94vw, 1100px); max-height:94dvh; overflow:auto; display:grid; gap:10px}
.shotbox img{display:block; max-width:100%; max-height:68dvh; margin:auto; border-radius:8px; background:#14172B}

svg[hidden]{display:none}
.sc .ops{display:none}
.sc.on .ops, .sc:hover .ops, .sc:focus-within .ops{display:flex; grid-column:1 / -1; justify-content:flex-end; padding-bottom:2px}
.pick{white-space:normal; line-height:1.4}
.pick small{display:block; margin:0}
.selbox.low .hnd.rot{top:auto; bottom:-28px}
.selbox.low .hnd.rot::after{top:auto; bottom:100%}

/* v4 */
.chap{position:relative}
.chap button{position:relative}
.chap .rz{position:absolute; top:0; bottom:0; inset-inline-end:-4px; width:8px; cursor:col-resize; z-index:3; touch-action:none}
.chap .rz::after{content:""; position:absolute; top:20%; bottom:20%; left:3px; width:2px; border-radius:2px; background:currentColor; opacity:.35}
.chap .rz:hover::after{opacity:1}
.lc.tc .btnrow{padding:.3rem .4rem 0}
.lc[hidden],.lg[hidden]{display:none}

.dsg{display:grid; grid-template-columns:repeat(2,1fr); gap:.5rem}
.dsc{display:flex; flex-direction:column; gap:.25rem; align-items:flex-start; text-align:start; padding:.6rem .7rem; border-radius:12px; border:1px solid color-mix(in srgb,currentColor 20%,transparent); cursor:pointer; min-height:5.2rem; font:inherit}
.dsc b{font-size:1.05rem; line-height:1.2}
.dsc small{font-size:.72rem; opacity:.8; line-height:1.3}
.dsc .sw{display:flex; gap:3px} .dsc .sw i{width:.8rem; height:.8rem; border-radius:50%; display:block; border:1px solid rgba(255,255,255,.5)}
.dsc:hover{transform:translateY(-1px); box-shadow:0 4px 14px rgba(0,0,0,.2)}
.dsc:focus-visible{outline:3px solid #2B3BFF; outline-offset:2px}

.lotf .field{margin-bottom:10px}
.lotcols{display:grid; grid-template-columns:repeat(auto-fill,minmax(110px,1fr)); gap:6px; margin:6px 0}
.lotc{display:flex; align-items:center; gap:6px; font-size:.8rem}
.lotc code{direction:ltr; color:var(--muted)}
.lott{display:flex; align-items:center; gap:6px; font-size:.85rem; padding-block:2px}

/* ---------- الأصول: المؤثرات الصوتية، Lottie، الوسائط ---------- */
.apane .achk{display:flex; gap:.5rem; align-items:center; margin:.2rem 0 .6rem; font-size:.82rem; color:var(--muted)}
.achips{display:flex; flex-wrap:wrap; gap:6px; margin:.4rem 0 .8rem}
.chip{appearance:none; border:1px solid var(--line); background:var(--surface); color:var(--fg); border-radius:99px; padding:.25rem .75rem; font:700 .75rem var(--ui); cursor:pointer}
.chip.on{background:var(--focus); color:#fff; border-color:var(--focus)}
.acat{margin:0 0 .8rem; border:1px solid var(--line); border-radius:10px; overflow:hidden}
.acat > summary{cursor:pointer; padding:.5rem .8rem; font:800 .85rem var(--ui); background:color-mix(in srgb, var(--fg) 5%, var(--surface)); list-style:none}
.acat > summary::-webkit-details-marker{display:none}
.acat > summary small{color:var(--muted); font-weight:600}
.alist{display:grid}
.arow{display:grid; grid-template-columns:auto 1fr auto auto auto; gap:.5rem; align-items:center; padding:.4rem .6rem; border-top:1px solid var(--line)}
.arow:hover{background:color-mix(in srgb, var(--focus) 7%, transparent)}
.anm{font:700 .82rem var(--ui); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0}
.adu{color:var(--muted); font:600 .72rem var(--ui); font-variant-numeric:tabular-nums}
.apb{appearance:none; width:30px; height:30px; border-radius:50%; border:1px solid var(--line); background:var(--surface); color:var(--fg); cursor:pointer; font-size:.8rem; display:inline-grid; place-items:center; flex:0 0 auto}
.apb:hover{border-color:var(--focus)} .apb.on{background:var(--focus); color:#fff; border-color:var(--focus)}
.apb.del{color:var(--danger); width:26px; height:26px}
.agrid{display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.6rem; padding:.6rem}
.acard{border:1px solid var(--line); border-radius:10px; padding:.4rem; display:grid; gap:.25rem; min-width:0; background:var(--surface)}
.acard:hover{border-color:var(--focus)}
.aprev{aspect-ratio:1.5/1; border-radius:8px; overflow:hidden; background:color-mix(in srgb, var(--fg) 8%, var(--surface)); display:grid; place-items:center}
.aprev img,.aprev video{width:100%; height:100%; object-fit:cover; display:block}
.aprev.lot svg{width:100%; height:100%}
.aprev.aud{color:var(--focus)} .aprev.aud svg{width:38%; height:38%}
.abar{display:flex; gap:.3rem; align-items:center; flex-wrap:wrap}
.abar .btn{padding:.2rem .55rem}
.clips{display:grid; gap:.6rem}
.clip{border:1px solid var(--line); border-radius:10px; padding:.5rem .6rem; display:grid; gap:.3rem}
.clh{display:flex; gap:.5rem; align-items:center} .clh .anm{flex:1 1 auto}
.hint.warn{color:var(--danger)}

/* ===== التايم لاين الاحترافي ===== */
.mtl{--rh:38px; border:1px solid var(--line,#2a2f4a); border-radius:10px; background:var(--surface,#1b1f36); overflow:hidden; margin-top:.4rem; user-select:none}
.mtt{display:flex; flex-wrap:wrap; gap:.3rem; align-items:center; padding:.35rem .45rem; border-bottom:1px solid var(--line,#2a2f4a)}
.mtt .sep{width:1px; height:18px; background:var(--line,#2a2f4a); margin:0 .15rem}
.mtt .btn[aria-pressed="true"]{outline:2px solid var(--focus); outline-offset:-2px}
.mtb{display:grid; grid-template-columns:104px minmax(0,1fr); max-height:300px; overflow-y:auto; overflow-x:hidden; position:relative}
.mth{border-inline-end:1px solid var(--line,#2a2f4a); background:rgba(0,0,0,.12); z-index:5}
.mhr{display:flex; align-items:center; justify-content:space-between; gap:.25rem; padding:0 .4rem; font:700 .7rem var(--ui); border-bottom:1px solid rgba(255,255,255,.06); box-sizing:border-box; overflow:hidden; white-space:nowrap}
.mhr.ruler,.mhr.old{opacity:.7; font-weight:600}
.mhr .ln{overflow:hidden; text-overflow:ellipsis; flex:1 1 auto; min-width:0}
.lbs{display:flex; gap:1px; flex:none}
.lb{appearance:none; border:0; background:transparent; color:inherit; cursor:pointer; font-size:.7rem; padding:1px 2px; border-radius:4px; opacity:.75; line-height:1}
.lb:hover{opacity:1; background:rgba(255,255,255,.12)} .lb.on{opacity:1; color:#ffb020}
.mts{overflow-x:auto; overflow-y:hidden; position:relative; scrollbar-width:thin}
.mti{position:relative; min-width:100%}
.mrul{position:relative; height:22px; border-bottom:1px solid rgba(255,255,255,.1); cursor:col-resize; background:rgba(0,0,0,.18)}
.mrul .tk{position:absolute; top:0; bottom:0; width:0; pointer-events:none}
.mrul .tk i{position:absolute; top:12px; bottom:0; width:1px; background:rgba(255,255,255,.4)} .mrul .tk.s i{top:16px; opacity:.5}
.mrul .tk b{position:absolute; top:1px; font:600 .62rem var(--ui); opacity:.8; margin-inline-start:3px; white-space:nowrap; direction:ltr}
.mti .tlbar{position:relative; height:34px}
.mti .chap{height:34px; gap:0}
.mti .chap button{border-radius:0; border-bottom-width:4px; box-shadow:inset -1px 0 0 rgba(0,0,0,.35); font-size:.72rem}
.mold{position:relative; height:22px; border-bottom:1px solid rgba(255,255,255,.06)}
.mold .mc{height:16px; top:3px}
.lane{position:relative; box-sizing:border-box; border-bottom:1px solid rgba(255,255,255,.07)}
.lane.video{background:rgba(120,150,255,.05)} .lane.audio{background:rgba(80,220,160,.05)}
.lane.dim{opacity:.45} .lane.drop{outline:2px dashed var(--focus); outline-offset:-2px} .lane.locked{background-image:repeating-linear-gradient(45deg,rgba(255,255,255,.05) 0 6px,transparent 6px 12px)}
.sb{position:absolute; bottom:0; width:0; border-inline-start:1px dashed rgba(255,255,255,.22); pointer-events:none; z-index:1}
.mc{position:absolute; top:3px; height:32px; box-sizing:border-box; border-radius:6px; overflow:hidden; cursor:grab; color:#fff; font:700 .68rem var(--ui); border:1px solid rgba(255,255,255,.35); touch-action:none; z-index:2}
.mc.v{background-color:#3b5bdb} .mc.a{background-color:#0f9d6e} .mc.s{background-color:#c9760e}
.mc.keyed{box-shadow:inset 0 0 0 2px #e0f}
.mc.muted{opacity:.5} .mc.sel{outline:2px solid #fff; outline-offset:0; z-index:4; box-shadow:0 0 0 3px var(--focus)}
.mc.drag{opacity:.85; z-index:9; cursor:grabbing}
.mc:focus-visible{outline:2px solid var(--focus)}
.mc .mcn{position:absolute; inset:2px 8px auto 8px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; text-shadow:0 1px 2px rgba(0,0,0,.7); pointer-events:none}
.mc.v .mcn{background:rgba(0,0,0,.45); border-radius:4px; padding:0 4px; inset-inline-end:auto; max-width:calc(100% - 16px)}
.mc .mcn em{font-style:normal; background:rgba(0,0,0,.45); border-radius:4px; padding:0 3px; margin-inline-start:4px; font-size:.62rem} .mc .mcn em.k{background:#c026d3}
.mc canvas.wv{position:absolute; inset:auto 0 1px 0; width:100%; height:16px; opacity:.9; pointer-events:none}
.mc .fd{position:absolute; top:0; bottom:0; pointer-events:none; background:linear-gradient(90deg,rgba(0,0,0,.55),transparent)} .mc .fd.in{inset-inline-start:0} .mc .fd.out{inset-inline-end:0; transform:scaleX(-1)}
.mh{position:absolute; top:0; bottom:0; width:9px; cursor:col-resize; z-index:3; background:rgba(255,255,255,.0)}
.mh.s{inset-inline-start:0} .mh.e{inset-inline-end:0}
.mc:hover .mh,.mc.sel .mh{background:rgba(255,255,255,.35)}
.mc.old{cursor:pointer; border-style:dashed}
.mti .playhead{top:0; bottom:0; z-index:8}
.mti .playhead::before{top:-1px}
.vclips{position:absolute; inset:0; pointer-events:none; overflow:hidden; z-index:30}
.vclip{position:absolute; transform-origin:center; pointer-events:none}
.vclip video{display:block; width:100%; height:100%; object-fit:fill}
.vclip canvas.vk{display:none; position:absolute; inset:0; width:100%; height:100%}
.vclip.keyed video{opacity:0} .vclip.keyed canvas.vk{display:block}
.vclip.picked{outline:2px solid #5fe0ff; outline-offset:2px; cursor:move}
.cgrp{border:1px solid var(--line,#2a2f4a); border-radius:8px; padding:.5rem .6rem; margin:.5rem 0}
.cgrp h3{margin:0 0 .4rem; font:800 .8rem var(--ui)}
.sw{display:inline-block; width:.8em; height:.8em; border-radius:50%; border:1px solid #888; margin-inline-end:.3em; vertical-align:-1px}
.btn.on{outline:2px solid var(--focus); outline-offset:-2px}
.mtb{grid-template-columns:112px minmax(0,1fr)}
.mhr.lanehd{flex-direction:column; align-items:stretch; justify-content:center; gap:1px; padding:2px 5px}
.mhr.lanehd .ln{font-size:.68rem; flex:none}
.mhr.lanehd .lbs{justify-content:flex-start; gap:2px}

/* ===== التايم لاين بعرض الشاشة (مثل المحررات المتقدمة) ===== */
.app{max-width:120rem}
.mtl{margin-top:0}
.mtb{max-height:240px; grid-template-columns:132px minmax(0,1fr)}
.mtl .mtt{flex-wrap:nowrap; overflow-x:auto}
@media (min-width:1100px){
  .mtl{position:sticky; bottom:0; z-index:40; box-shadow:0 -6px 18px rgba(0,0,0,.25); background:var(--surface)}
  .editor, .sidepanel{max-height:calc(100dvh - 24px - 330px - env(safe-area-inset-top, 0px))}
}
@media (max-width:700px){ .mtb{grid-template-columns:84px minmax(0,1fr)} .mhr.lanehd .lbs .lb:nth-child(n+3){display:none} }
.elgrid{display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.6rem; padding:.5rem}
.elcard{appearance:none; text-align:start; cursor:pointer; border:1px solid var(--line); border-radius:10px; background:var(--bg); padding:.4rem; display:flex; flex-direction:column; gap:.2rem; font:inherit; color:inherit; content-visibility:auto; contain-intrinsic-size:160px}
.elcard:hover,.elcard:focus-visible{outline:2px solid var(--focus)}
.elcard b{font:800 .78rem var(--ui)} .elcard small{opacity:.65; font-size:.68rem}
.elprev{position:relative; overflow:hidden; border-radius:8px; aspect-ratio:16/9; background:color-mix(in srgb, var(--fg) 8%, var(--surface))}
.elprev .stage.thumb{border-radius:8px}
.elcard.hplay,.lc.hplay{border-color:var(--focus)}

/* منع تسرّب التمرير من القوائم الداخلية إلى الصفحة */
.tpanes,.rail,.icogrid,.mtb,.mts,.shotbox,.player:fullscreen,.player.pseudo-fs,textarea,select[multiple],#libBox,#galBox,#elbox,.sclist{overscroll-behavior:contain}
.tpanes,.rail{scrollbar-width:thin}
.elcard,.lc{-webkit-tap-highlight-color:transparent}

/* ===== تخطيط مساحة عمل بعرض/ارتفاع الشاشة على سطح المكتب: لا تمرير للصفحة، والقوائم تتمرر داخليًا، والتايم لاين لا يغطي شيئًا ===== */
@media (min-width:1100px) and (min-height:560px){
  html{height:100%}
  body{height:100dvh; box-sizing:border-box; overflow:hidden; padding-block:10px}
  .app{height:100%; grid-template-rows:auto minmax(0,1fr) auto; gap:10px; max-width:none}
  .top{flex-wrap:nowrap; align-items:center}
  .top > div{display:flex; align-items:baseline; gap:.2rem 1rem; flex-wrap:wrap}
  h1{font-size:1.25rem; line-height:1.4}
  .eyebrow{font-size:.8rem}
  .studio{min-height:0; align-items:stretch}
  .player,.editor,.sidepanel{position:static; max-height:none; min-height:0}
  .player{overflow:auto; overscroll-behavior:contain; padding-inline-end:2px}
  .mtl{position:static; display:flex; flex-direction:column; max-height:clamp(170px,31vh,330px); box-shadow:none}
  .mtl .mtb{flex:1 1 auto; min-height:0; max-height:none}
}

/* أزرار أيقونية (btn-icons.js) */
.btn.io{padding:.38rem .55rem; min-width:2.2rem}
.btn.io>span:not(.ico){display:none}
.btn.io svg, .btn svg.bi{width:17px; height:17px; flex:none}
.btn.sm.io{padding:.32rem .5rem; min-width:2rem}
.btn.io:hover{background:color-mix(in srgb, var(--fg) 8%, var(--surface))}
.btn.io.danger{color:var(--danger)}
.apb svg.bi{width:14px; height:14px}
.ops button svg.bi{width:16px;height:16px}

.chap .rz.last{inset-inline-end:0}
.chap .rz.drag::after, .chap .rz:hover::after{opacity:1; background:var(--focus)}
body.rz-drag{cursor:col-resize; user-select:none}
body.rz-drag *{cursor:col-resize !important}

/* أزرار ملء الشاشة العائمة */
.fsbar,.fstoast{display:none}
.player:fullscreen .fsbar,.player.pseudo-fs .fsbar{display:flex; position:absolute; top:14px; inset-inline-start:14px; gap:8px; z-index:30; opacity:.55; transition:opacity .2s}
.player:fullscreen .fsbar:hover,.player.pseudo-fs .fsbar:hover,.fsbar:focus-within{opacity:1}
.fsbar .btn{background:rgba(20,23,43,.85); color:#fff; border-color:rgba(255,255,255,.35); backdrop-filter:blur(6px)}
.fsbar .btn:hover{background:#2B3BFF}
.player:fullscreen .fstoast:not([hidden]),.player.pseudo-fs .fstoast:not([hidden]){display:block; position:absolute; bottom:22px; left:50%; transform:translateX(-50%); background:rgba(20,23,43,.92); color:#fff; padding:.5rem 1rem; border-radius:8px; z-index:30; font:600 .9rem var(--ui)}

/* زر التسجيل */
#mRec.recording{background:#d92d2d; color:#fff; border-color:#d92d2d; animation:recp 1.2s ease-in-out infinite}
#mRec .rect{display:inline !important; font:700 .75rem var(--ui); margin-inline-start:.35rem; font-variant-numeric:tabular-nums}
@keyframes recp{50%{box-shadow:0 0 0 4px rgba(217,45,45,.28)}}

/* شريط إضافة العناصر الدائم */
.addbar{position:sticky; top:-12px; z-index:6; margin:-12px -12px 12px; padding:9px 12px; background:var(--surface); border-bottom:1px solid var(--line); display:flex; align-items:center; gap:8px; flex-wrap:wrap}
.addlbl{font:700 .78rem var(--ui); color:var(--muted)}
.addbtns{display:flex; gap:5px; flex-wrap:wrap}
.addb{background:var(--bg)}
.lychips{display:flex; flex-wrap:wrap; gap:5px; margin:2px 0 10px}
.lychip{appearance:none; border:1px solid var(--line); background:var(--surface); color:var(--fg); border-radius:999px; padding:.18rem .65rem .18rem .35rem; font:600 .78rem var(--ui); cursor:pointer; display:inline-flex; gap:.4rem; align-items:center; max-width:100%}
.lychip b{display:inline-grid; place-items:center; min-width:1.2rem; height:1.2rem; border-radius:50%; background:var(--line); font-size:.68rem}
.lychip.on{background:var(--fg); color:var(--bg); border-color:var(--fg)}
.lychip.on b{background:var(--bg); color:var(--fg)}
