@import url('https://fonts.googleapis.com/css2?family=Almarai&display=swap');
:root{--bg:#0b0d12;--panel:#121620;--panel2:#171c27;--line:#292f3d;--text:#f7f8fa;--muted:#98a2b3;--accent:#7457ff;--accent2:#8f7aff;--ok:#24c77a;--danger:#ff5b6e;--shadow:0 18px 45px rgba(0,0,0,.28)}*{box-sizing:border-box}body{margin:0;background:radial-gradient(circle at top right,#19142c 0,#0b0d12 35%);color:var(--text);font-family:'Almarai',sans-serif;direction:rtl}.wrap{max-width:1180px;margin:auto;padding:26px 18px 70px}.topbar{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-bottom:20px}.brand{font-weight:800;font-size:22px}.nav{display:flex;gap:9px;flex-wrap:wrap}.btn,a.btn{border:0;border-radius:12px;padding:12px 18px;background:var(--accent);color:#fff;text-decoration:none;font-family:inherit;cursor:pointer;font-weight:700}


.btn.ghost{background:transparent;border:1px solid var(--line)}.btn.danger{background:var(--danger)}
.btn.secondary {
    background: #15803d;
    border: 1px solid #86efac;
}


.btn.secondary-2 {
    background: #242a37;
    
}
.btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    background: #242a37;
    border: 1px solid #646464;
}
.card{background:rgba(18,22,32,.92);border:1px solid var(--line);border-radius:20px;padding:22px;box-shadow:var(--shadow);margin-bottom:16px}.step{display:none}.step.active{display:block}.step-title{display:flex;align-items:center;gap:11px;font-size:20px;font-weight:800;margin-bottom:18px}.num{width:34px;height:34px;display:grid;place-items:center;border-radius:50%;background:var(--accent)}.grid{display:grid;grid-template-columns:repeat(4,1fr);gap:12px}.grid.three{grid-template-columns:repeat(3,1fr)}.choice{border:1px solid var(--line);background:var(--panel2);border-radius:16px;padding:8px;cursor:pointer;min-height:94px;transition:.18s}.choice:hover,.choice.selected{border-color:var(--accent2);box-shadow:0 0 0 2px rgba(116,87,255,.18)}.choice h4{margin:0 0 8px}.choice p,.muted{color:var(--muted);font-size:13px;line-height:1.7}.field{margin-bottom:14px}.field label{display:block;font-size:13px;font-weight:700;margin-bottom:7px;color:#d7dbe4}.input,textarea,select{width:100%;background:#0d1119;border:1px solid var(--line);color:#fff;border-radius:12px;padding:13px;font-family:inherit;outline:none}textarea{min-height:110px;resize:vertical}.input:focus,textarea:focus,select:focus{border-color:var(--accent)}.row{display:grid;grid-template-columns:1fr 1fr;gap:14px}.actions{display:flex;justify-content:space-between;gap:10px;margin-top:18px}.character-card img,.location-thumb{width:100%;aspect-ratio:4/5;object-fit:cover;border-radius:12px;background:#0d1119}.character-card{padding:10px}.character-card h4{margin:10px 4px 2px}.chips{display:flex;gap:7px;flex-wrap:wrap}.chip{background:#232938;border:1px solid #343b4d;padding:8px 11px;border-radius:999px;font-size:12px}.script-box{display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px}.script-part{background:#0d1119;border:1px solid var(--line);border-radius:14px;padding:14px}.script-part b{display:block;margin-bottom:8px;color:#bfb4ff}.summary{display:grid;grid-template-columns:1fr 1fr;gap:12px}.summary>div{background:#0d1119;border:1px solid var(--line);padding:14px;border-radius:14px}.progress{height:12px;background:#242a37;border-radius:99px;overflow:hidden}.progress>span{display:block;height:100%;width:0;background:linear-gradient(90deg,var(--accent),#b7aaff);transition:.3s}.notice{padding:12px 14px;border-radius:12px;background:#182139;border:1px solid #2d3e69;font-size:13px;line-height:1.7}.error{background:#351920;border-color:#69303c}.success{background:#153323;border-color:#285e42}.admin-table{width:100%;border-collapse:collapse}.admin-table th,.admin-table td{padding:11px;border-bottom:1px solid var(--line);text-align:right;vertical-align:middle}.thumb{width:62px;height:62px;object-fit:cover;border-radius:10px;background:#0d1119}.login{max-width:430px;margin:10vh auto}.small{font-size:12px}.ltr{direction:ltr;text-align:left}.hidden{display:none!important}audio{width:220px;max-width:100%}@media(max-width:900px){.grid,.grid.three{grid-template-columns:repeat(2,1fr)}.row,.summary,.script-box{grid-template-columns:1fr}}@media(max-width:560px){.grid,.grid.three{grid-template-columns:repeat(2, minmax(0, 1fr))}.wrap{padding:16px 12px}.card{padding:16px}.topbar{align-items:flex-start;flex-direction:column}.actions{position:sticky;bottom:8px;background:rgba(11,13,18,.94);padding:9px;border-radius:14px}}

/* ===== Single Page Builder ===== */
.single-builder-page{padding-bottom:118px}.builder-wrap{padding-bottom:40px}.builder-card{padding:0;overflow:hidden}.builder-card[open]{overflow:visible}.builder-summary{list-style:none;cursor:pointer;padding:18px 22px;display:flex;align-items:center;justify-content:space-between;gap:14px;user-select:none;background:rgba(255,255,255,.012)}.builder-summary::-webkit-details-marker{display:none}.builder-summary::after{content:'⌄';font-size:20px;color:var(--muted);transition:.18s}.builder-card[open]>.builder-summary::after{transform:rotate(180deg)}.summary-main{display:flex;align-items:center;gap:11px;font-size:18px;font-weight:800}.builder-card-body{padding:4px 22px 22px;border-top:1px solid rgba(255,255,255,.04)}

.card-state {
    margin-inline-start: auto;
    margin-inline-end: 8px;
    padding: 6px 10px;
    border: 1px solid #a9003a;
    border-radius: 999px;
    color: #ffffff;
    font-size: 11px;
    white-space: nowrap;
    background: #ff00006b;
}
.card-state.complete{color:#aaf0c8;border-color:#285e42;background:#153323}


.builder-card.is-complete {
    border-color: #4CAF50;
}
.custom-location-box{margin-top:14px;padding-top:14px;border-top:1px dashed var(--line)}.voice-ready-mark,.voice-missing-mark{display:inline-block;margin:4px 4px 2px;font-size:11px}.voice-ready-mark{color:#9fe8bf}.voice-missing-mark{color:#ffb0bb}.script-toolbar{display:flex;align-items:center;gap:12px;flex-wrap:wrap;margin-bottom:12px}.prompt-preview-box{margin-top:12px;background:#0d1119;border:1px solid var(--line);border-radius:14px;padding:12px}.prompt-preview-box summary{cursor:pointer;font-weight:700}.prompt-preview{white-space:pre-wrap;color:#cfd5df;line-height:1.7;margin:12px 0 0}.summary-wide{grid-column:1/-1}.final-video{width:100%;max-height:720px;border-radius:16px;background:#000}.builder-fixed-footer{position:fixed;z-index:80;right:0;left:0;bottom:0;background:rgba(9,11,16,.94);backdrop-filter:blur(18px);border-top:1px solid var(--line);box-shadow:0 -12px 36px rgba(0,0,0,.34)}.builder-footer-inner{max-width:1180px;margin:auto;padding:12px 18px;display:flex;align-items:center;justify-content:space-between;gap:16px}.footer-status-block{min-width:0;display:flex;flex-direction:column;gap:5px}.footer-status-block strong{font-size:14px}.footer-status-block span{font-size:11px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;max-width:650px}.footer-actions{display:flex;align-items:center;gap:10px;flex:0 0 auto}.voice-test-btn{min-width:150px}.final-generate-btn{min-width:150px}.character-grid .choice{position:relative}.character-grid .choice.selected:after{content:'✓';position:absolute;top:10px;left:10px;width:28px;height:28px;border-radius:50%;display:grid;place-items:center;background:var(--accent);font-weight:800}@media(max-width:700px){.single-builder-page{padding-bottom:170px}.builder-summary{padding:15px}.builder-card-body{padding:4px 15px 16px}.builder-footer-inner{align-items:stretch;flex-direction:column;padding:10px 12px}.footer-status-block span{max-width:100%}.footer-actions{display:grid;grid-template-columns:1fr 1fr}.voice-test-btn,.final-generate-btn{min-width:0}.card-state{display:none}.summary-main{font-size:16px}}

/* ===== Smart Script + Speech Tags ===== */
.full-script-editor{background:rgba(13,17,25,.55);border:1px solid var(--line);border-radius:16px;padding:16px}.full-script-head{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;margin-bottom:12px}.pause-legend{display:flex;flex-wrap:wrap;gap:7px}.pause-legend span{font-size:11px;color:#cfd5df;background:#171d28;border:1px solid #30384a;border-radius:999px;padding:7px 10px}.pause-legend b{color:#bfb4ff}.speech-tags{display:flex;flex-wrap:wrap;gap:8px;margin:10px 0 12px}.speech-tag{border:1px solid #343b4d;background:#171d28;color:#fff;border-radius:999px;padding:8px 11px;font-family:inherit;font-size:12px;cursor:pointer;transition:.16s}.speech-tag:hover{border-color:var(--accent2);background:#211d36;transform:translateY(-1px)}.speech-tag.pause-tag{background:#13221b;border-color:#285e42;color:#b8f1cf}.full-script-editor textarea{min-height:190px;line-height:2;font-size:15px}.smart-script-hint,.smart-duration-hint{margin-top:8px;color:var(--muted);font-size:12px;line-height:1.7}.smart-duration-hint.is-recommended{color:#b8f1cf}.smart-duration-hint.is-warning{color:#ffd59a}.script-part textarea{min-height:130px;line-height:1.9}.duration-pill{display:inline-flex;align-items:center;gap:6px;margin-inline-start:8px;padding:5px 9px;border-radius:999px;background:#153323;border:1px solid #285e42;color:#b8f1cf;font-size:11px}.duration-pill.warning{background:#372913;border-color:#705525;color:#ffd59a}@media(max-width:760px){.full-script-head{flex-direction:column}.pause-legend{width:100%}.speech-tag{font-size:11px;padding:7px 9px}}
.speech-tag.clean-tag{background:#25171a;border-color:#5c3037;color:#ffc6ce}.speech-tag.clean-tag:hover{background:#351d22;border-color:#8a4450}.footer-actions #downloadVoice{white-space:nowrap}@media(max-width:700px){.footer-actions{grid-template-columns:1fr 1fr 1fr}.footer-actions .btn{padding:10px 8px;font-size:11px}}

/* Cinematic director workflow */
.director-step-box{background:rgba(13,17,25,.6);border:1px solid var(--line);border-radius:16px;padding:16px}.director-step-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:12px}.director-step-head h3{margin:0 0 6px;font-size:16px}.cinematic-director-box{border-color:rgba(116,87,255,.35);box-shadow:inset 0 0 0 1px rgba(116,87,255,.05)}.cinematic-director-box textarea{min-height:220px;line-height:1.9}.approve-prompt-row{display:flex;align-items:center;gap:14px;margin-top:16px;padding:14px;border-radius:16px;background:rgba(116,87,255,.08);border:1px solid rgba(116,87,255,.25)}.final-approve-btn{min-width:170px}.tag-section-title{font-size:12px;font-weight:800;color:#d9d2ff;margin-top:10px}.motion-tags{padding-top:2px}.speech-tag.motion-tag{background:#13202a;border-color:#29485d}.speech-tag.motion-tag:hover{background:#172b39;border-color:#4b7896}.prompt-preview-box[open]{border-color:rgba(116,87,255,.35)}.prompt-preview{max-height:520px;overflow:auto}.full-script-editor textarea{min-height:230px}@media(max-width:760px){.director-step-head,.approve-prompt-row{flex-direction:column;align-items:stretch}.director-step-head .btn,.final-approve-btn{width:100%}}

/* ===== Cinematic scene-image director v03 ===== */
.character-voice-box{margin-top:16px;padding:14px 16px;border:1px solid rgba(116,87,255,.28);background:rgba(116,87,255,.07);border-radius:16px;display:flex;align-items:center;justify-content:space-between;gap:14px}.character-voice-box>div{min-width:0}.character-voice-box strong{display:block;margin-bottom:5px}.character-voice-box audio{display:none}.scene-image-manager{margin-top:18px;padding:16px;border:1px solid var(--line);border-radius:18px;background:rgba(13,17,25,.58)}.scene-image-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:12px}.scene-image-head label{font-weight:800}.scene-image-count{flex:0 0 auto;background:#211d36;border:1px solid rgba(116,87,255,.45);color:#d9d2ff;padding:7px 10px;border-radius:999px;font-size:12px}.scene-images-grid{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:10px;margin-top:12px}.scene-image-card{position:relative;min-width:0;border:1px solid var(--line);border-radius:15px;padding:8px;background:#0d1119;cursor:grab;transition:.16s}.scene-image-card:hover,.scene-image-card.drag-over{border-color:var(--accent2);box-shadow:0 0 0 2px rgba(116,87,255,.14)}.scene-image-card.dragging{opacity:.5}.scene-image-card img{width:100%;aspect-ratio:4/3;display:block;object-fit:cover;border-radius:10px;background:#151922}.scene-image-number{position:absolute;top:14px;right:14px;width:30px;height:30px;display:grid;place-items:center;border-radius:50%;background:rgba(9,11,16,.88);border:1px solid rgba(255,255,255,.24);font-size:12px;font-weight:800;backdrop-filter:blur(8px)}.scene-image-meta{display:flex;flex-direction:column;gap:4px;margin-top:8px;min-width:0}.scene-image-meta strong{font-size:12px}.scene-image-meta span{font-size:10px;color:var(--muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;direction:ltr;text-align:right}.scene-image-controls{display:grid;grid-template-columns:repeat(3,1fr);gap:5px;margin-top:8px}.scene-image-controls button{border:1px solid var(--line);background:#171d28;color:#fff;border-radius:9px;padding:6px;cursor:pointer}.scene-image-controls button:hover{border-color:var(--accent2)}.scene-image-controls .danger-mini{color:#ffc6ce;border-color:#5c3037;background:#25171a}.image-tag-btn{background:#201c38!important;border-color:#5e50a5!important;color:#e5e0ff!important}.image-picker-modal{position:fixed;z-index:160;inset:0;display:grid;place-items:center;padding:18px}.image-picker-backdrop{position:absolute;inset:0;background:rgba(4,6,10,.78);backdrop-filter:blur(9px)}.image-picker-panel{position:relative;z-index:1;width:min(920px,100%);max-height:min(82vh,760px);overflow:auto;background:#121620;border:1px solid #363d50;border-radius:22px;box-shadow:0 30px 90px rgba(0,0,0,.55);padding:18px}.image-picker-head{display:flex;align-items:flex-start;justify-content:space-between;gap:14px;margin-bottom:16px}.image-picker-close{width:38px;height:38px;border-radius:50%;border:1px solid var(--line);background:#1b202b;color:#fff;cursor:pointer}.image-picker-grid{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:12px}.image-picker-card{position:relative;border:1px solid var(--line);background:#0d1119;color:#fff;border-radius:15px;padding:8px;cursor:pointer;font-family:inherit;text-align:right;transition:.16s}.image-picker-card:hover{border-color:var(--accent2);transform:translateY(-2px);box-shadow:0 12px 26px rgba(0,0,0,.25)}.image-picker-card img{width:100%;aspect-ratio:4/3;object-fit:cover;border-radius:10px;display:block;margin-bottom:8px}.image-picker-card strong{font-size:12px}.image-picker-number{position:absolute;top:14px;right:14px;z-index:2;width:31px;height:31px;display:grid;place-items:center;border-radius:50%;background:rgba(9,11,16,.9);border:1px solid rgba(255,255,255,.25);font-weight:800}.scene-image-manager .input[type=file]{background:#10151f;border-style:dashed}.scene-image-manager .notice{margin-bottom:0}.director-step-box .notice.success{color:#c8f5da}.voice-ready-mark{font-weight:700}
@media(max-width:980px){.scene-images-grid{grid-template-columns:repeat(4,minmax(0,1fr))}.image-picker-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:700px){.character-voice-box,.scene-image-head{flex-direction:column;align-items:stretch}.character-voice-box .btn{width:100%}.scene-images-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.image-picker-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.image-picker-panel{padding:13px;border-radius:17px}.footer-actions{grid-template-columns:1fr}}


/* V08 MASTER AUDIO deterministic image timeline */
.master-timeline-rail{margin:12px 0 16px;padding:12px;border:1px solid rgba(116,87,255,.32);border-radius:14px;background:#0d1119;direction:ltr}.master-timeline-title{direction:rtl;text-align:right;font-size:11px;color:var(--muted);margin-bottom:10px}.master-timeline-track{position:relative;height:104px;border-radius:10px;background:linear-gradient(180deg,#171d28,#10141d);border:1px solid var(--line);overflow:visible}.master-timeline-track:after{content:'';position:absolute;left:0;right:0;top:72px;height:2px;background:#7457ff}.master-image-pin{position:absolute;top:7px;transform:translateX(-50%);width:64px;text-align:center;z-index:2}.master-image-pin:after{content:'';position:absolute;left:50%;top:58px;height:31px;border-left:1px dashed #bfb4ff}.master-image-pin img{width:54px;height:48px;object-fit:cover;border-radius:7px;border:2px solid #8f7aff;background:#151922;display:block;margin:auto}.master-image-pin b{display:block;font-size:9px;color:#e5e0ff;margin-top:3px;direction:rtl;white-space:nowrap}

/* V09 — approved compact character selector: exactly 6 cards per desktop row; voice sample lives on the image. */
.character-grid{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:10px}
.character-card{min-width:0;padding:8px}
.character-image-wrap{position:relative;width:100%}
.character-card .character-image-wrap img{display:block;width:100%;aspect-ratio:5/5;object-fit:cover;border-radius:11px;background:#fff}
.character-card h4{font-size:13px;margin:8px 2px 2px}.character-card p{font-size:10px;line-height:1.55;margin:2px}
.film-type-card p{margin-bottom:0}
@media(max-width:1000px){.character-grid{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(max-width:700px){.character-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:480px){.character-grid{grid-template-columns:repeat(2,minmax(0,1fr))}}
/* V11 multi-character architecture */
.character-card.selected{border-color:#8b73ff;box-shadow:0 0 0 2px rgba(139,115,255,.22)}
.interaction-tags{display:none}.multi-character-active .interaction-tags{display:block}.next-studio-row{display:flex;justify-content:flex-end;gap:12px;margin-top:18px}.master-audio-lock{border:1px solid rgba(61,214,140,.35);background:rgba(61,214,140,.07);padding:14px;border-radius:16px}

/* BytePlus Seedance 2.5 documented ratio and resolution choices. */
.aspect-choices,.resolution-choices{display:grid;gap:8px;padding:9px;border-radius:13px;background:#eef0ff;direction:ltr}
.aspect-choices{grid-template-columns:repeat(6,minmax(0,1fr))}
.resolution-choices{grid-template-columns:repeat(3,minmax(0,1fr))}
.aspect-choice,.resolution-choice{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:9px;min-height:84px;border:2px solid transparent;border-radius:10px;background:transparent;color:#27334a!important;font-weight:800!important;text-align:center;cursor:pointer;transition:background .15s,border-color .15s,box-shadow .15s}
.resolution-choice{min-height:55px;font-size:14px!important}
.aspect-choice:has(input:checked),.resolution-choice:has(input:checked){background:#fff;border-color:#715aff;box-shadow:0 2px 9px rgba(67,56,132,.18);color:#15152e!important}
.aspect-choice:focus-within,.resolution-choice:focus-within{outline:2px solid #4e32e8;outline-offset:2px}
.aspect-choice input,.resolution-choice input{position:absolute;inset:0;opacity:0;width:100%;height:100%;margin:0;cursor:pointer}
.aspect-shape{display:block;flex:none;border:2px solid currentColor;border-radius:2px;width:32px;height:32px}
.aspect-choice:nth-child(1) .aspect-shape{width:46px;height:20px}
.aspect-choice:nth-child(2) .aspect-shape{width:42px;height:24px}
.aspect-choice:nth-child(3) .aspect-shape{width:40px;height:30px}
.aspect-choice:nth-child(5) .aspect-shape{width:30px;height:40px}
.aspect-choice:nth-child(6) .aspect-shape{width:24px;height:42px}
@media(max-width:650px){.aspect-choices{grid-template-columns:repeat(3,minmax(0,1fr))}.aspect-choice{min-height:76px}}
/* Compact production review */
.studio-production-page h2{font-size:18px;margin:0 0 17px}
.studio-production-page .card{max-width:1050px;margin-inline:auto}
.studio-production-page .actions{align-items:center;flex-wrap:wrap}
.studio-production-page textarea{min-height:120px;line-height:1.8}
.studio-production-page .studio-image-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(135px,1fr));gap:10px}
.studio-image-grid figure{margin:0;background:#0d1119;border:1px solid var(--line);border-radius:12px;padding:8px}
.studio-image-grid img{display:block;width:100%;aspect-ratio:4/3;object-fit:cover;border-radius:9px}
.studio-image-grid figcaption{font-size:12px;color:var(--muted);padding-top:7px;text-align:center}
.studio-production-page video{display:block;margin-block:12px;max-width:100%;max-height:75vh}

/* Reference media and per-character voice audition */
.scene-media-upload>label{display:block;margin:8px 0;font-size:13px;font-weight:700;color:#d7dbe4}
.scene-media-upload>.input[type=file]{background:#10151f;border-style:dashed}
.character-preview-btn{display:block;width:calc(100% - 4px);margin:8px 2px 2px;padding:8px 10px;font-size:11px}
.character-preview-status{display:block;min-height:0;color:var(--muted);font-size:10px;line-height:1.5}
.scene-image-card video{display:block;width:100%;max-height:240px;object-fit:contain;border-radius:10px;background:#080a0f}
