:root {
  --bg: #07080c;
  --panel: #0d0f15;
  --panel-2: #12151d;
  --panel-3: #171b25;
  --line: rgba(255, 255, 255, 0.075);
  --line-2: rgba(255, 255, 255, 0.12);
  --txt: #eef1f7;
  --muted: #8b93a7;
  --muted-2: #6b7386;
  --accent: #8b5cf6;
  --accent-2: #22d3ee;
  --ok: #34d399;
  --r: 14px;
  --shadow: 0 20px 50px -20px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font-family: "Plex Arabic", -apple-system, "Segoe UI", sans-serif;
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font-family: inherit; color: inherit; }
button { cursor: pointer; }
::selection { background: rgba(139, 92, 246, 0.35); }

/* ---------- scrollbars ---------- */
.panel::-webkit-scrollbar, .filmstrip::-webkit-scrollbar { width: 10px; height: 10px; }
.panel::-webkit-scrollbar-thumb, .filmstrip::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.09); border-radius: 99px; border: 3px solid transparent; background-clip: content-box;
}
.panel::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.18); background-clip: content-box; }

/* ---------- topbar ---------- */
.topbar {
  height: 66px;
  display: flex; align-items: center; gap: 20px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(20, 23, 31, 0.92), rgba(9, 10, 14, 0.92));
  backdrop-filter: blur(14px);
  position: relative; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; min-width: 208px; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 12px;
  display: grid; place-items: center;
  color: #fff;
  background: linear-gradient(145deg, #8b5cf6, #6d28d9 55%, #1e1b4b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 8px 20px -8px rgba(139, 92, 246, 0.9);
}
.brand-mark svg { width: 23px; height: 23px; }
.brand-txt { display: flex; flex-direction: column; line-height: 1.15; }
.brand-txt b { font-size: 16px; font-weight: 700; letter-spacing: -0.2px; }
.brand-txt span { font-size: 10.5px; color: var(--muted); letter-spacing: 0.1px; }

.topbar-mid { display: flex; align-items: center; gap: 10px; margin-inline: auto; }
.size-wrap {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px;
  padding: 4px 10px 4px 4px;
}
.size-label { font-size: 11px; color: var(--muted); padding-inline-start: 2px; }
.select {
  appearance: none; background: transparent; border: 0; outline: 0;
  font-size: 12.5px; font-weight: 500; padding: 5px 4px; min-width: 196px;
  cursor: pointer; text-overflow: ellipsis;
}
.select option { background: #12151d; color: var(--txt); }
.dims {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
  padding: 6px 10px; border-radius: 9px; direction: ltr;
}
.actions { display: flex; align-items: center; gap: 8px; }
.divider { width: 1px; height: 24px; background: var(--line-2); margin: 0 4px; }

.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 10px;
  border: 1px solid var(--line-2); background: var(--panel-2);
  font-size: 12.5px; font-weight: 500; white-space: nowrap;
  transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s;
}
.btn:hover { background: var(--panel-3); border-color: rgba(255, 255, 255, 0.18); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: linear-gradient(135deg, #8b5cf6, #6d28d9);
  border-color: rgba(255, 255, 255, 0.16);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 10px 24px -12px rgba(139, 92, 246, 1);
  font-weight: 700;
}
.btn.primary:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.5; pointer-events: none; }
.btn.ghost { background: rgba(255, 255, 255, 0.03); }

.icon-btn {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid transparent; background: transparent;
  color: var(--muted); transition: 0.15s;
}
.icon-btn:hover { color: var(--txt); background: rgba(255, 255, 255, 0.06); border-color: var(--line); }
.icon-btn svg { width: 17px; height: 17px; }

/* ---------- app layout ---------- */
.app { display: grid; grid-template-columns: 374px 1fr; height: calc(100vh - 66px); }

.panel {
  border-inline-start: 1px solid var(--line);
  background: linear-gradient(180deg, #0c0e13, #090a0e);
  overflow-y: auto; overflow-x: hidden;
  display: flex; flex-direction: column;
  padding-bottom: 10px;
}

/* ---------- sections ---------- */
.section { border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.section > summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; font-size: 12.5px; font-weight: 700; color: #cfd5e3;
  letter-spacing: 0.1px;
}
.section > summary::-webkit-details-marker { display: none; }
.section > summary:hover { color: #fff; }
.section > summary::after {
  content: ""; width: 7px; height: 7px; border-inline-end: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted); transform: rotate(45deg); margin-inline-start: 8px;
  transition: transform 0.2s; flex: 0 0 auto;
}
.section[open] > summary::after { transform: rotate(-135deg); }
.count {
  margin-inline-start: auto; margin-inline-end: 10px;
  font-size: 10.5px; font-weight: 500; color: var(--muted);
  background: rgba(255, 255, 255, 0.05); border-radius: 6px; padding: 1px 7px;
}
.section-body { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 12px; }

/* ---------- slides ---------- */
.slides { display: flex; flex-direction: column; gap: 7px; }
.slide-item {
  display: flex; align-items: center; gap: 9px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 11px; padding: 6px 8px 6px 6px;
  position: relative; transition: 0.15s;
}
.slide-item:hover { border-color: var(--line-2); background: var(--panel-3); }
.slide-item.active { border-color: rgba(139, 92, 246, 0.65); background: rgba(139, 92, 246, 0.09); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.08); }
.slide-item.dragging { opacity: 0.4; }
.slide-item.drop-before { box-shadow: 0 -2px 0 var(--accent); }
.slide-grip {
  color: #4d5466; cursor: grab; padding: 2px 0; display: flex; flex: 0 0 auto;
}
.slide-grip:active { cursor: grabbing; }
.slide-thumb {
  width: 30px; height: 50px; border-radius: 5px; object-fit: cover;
  background: #1b1f29; border: 1px solid rgba(255, 255, 255, 0.09); flex: 0 0 auto;
}
.slide-input {
  flex: 1 1 auto; min-width: 0; background: transparent; border: 0; outline: 0;
  font-size: 12px; padding: 4px 2px; color: #dfe4ef;
  border-bottom: 1px solid transparent;
}
.slide-input:focus { border-bottom-color: rgba(139, 92, 246, 0.6); }
.slide-num {
  font-size: 10px; color: var(--muted-2); font-variant-numeric: tabular-nums; flex: 0 0 auto; width: 12px; text-align: center;
}
.slide-del {
  border: 0; background: transparent; color: #565e70; width: 22px; height: 22px;
  border-radius: 6px; display: grid; place-items: center; font-size: 15px; line-height: 1; flex: 0 0 auto;
}
.slide-del:hover { background: rgba(244, 63, 94, 0.15); color: #fb7185; }
.add-slide {
  width: 100%; height: 38px; border-radius: 10px;
  border: 1px dashed rgba(139, 92, 246, 0.4); background: rgba(139, 92, 246, 0.06);
  color: #c4b5fd; font-size: 12px; font-weight: 500;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: 0.15s;
}
.add-slide:hover { background: rgba(139, 92, 246, 0.14); border-color: rgba(139, 92, 246, 0.7); color: #ede9fe; }
.hint { margin: 0; font-size: 10.5px; color: var(--muted-2); line-height: 1.6; }

/* ---------- layouts ---------- */
.layouts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.layout-card {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px;
  padding: 6px 4px 5px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  transition: 0.15s; color: var(--muted);
}
.layout-card:hover { border-color: var(--line-2); background: var(--panel-3); }
.layout-card.on { border-color: rgba(139, 92, 246, 0.7); background: rgba(139, 92, 246, 0.1); color: #ddd6fe; }
.layout-card svg { width: 100%; height: 38px; }
.layout-card span { font-size: 10px; font-weight: 500; }
.layout-card .st { fill: currentColor; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label {
  font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px;
  justify-content: space-between;
}
.field > label em { font-style: normal; color: var(--muted-2); font-size: 10px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.input {
  width: 100%; background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 8px 10px; font-size: 12.5px; outline: 0; transition: 0.15s;
}
.input:focus { border-color: rgba(139, 92, 246, 0.7); box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12); }
.input.area { resize: vertical; min-height: 74px; line-height: 1.6; }
.input::placeholder { color: #4f5668; }

.color-field {
  display: flex; align-items: center; gap: 7px;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 4px 8px 4px 4px; height: 36px;
}
.color-field input[type="color"] {
  width: 26px; height: 26px; border: 0; padding: 0; background: none; border-radius: 7px; cursor: pointer;
}
.color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.color-field input[type="color"]::-webkit-color-swatch { border: 1px solid rgba(255,255,255,.18); border-radius: 7px; }
.color-field span { font-size: 10.5px; color: var(--muted); direction: ltr; font-variant-numeric: tabular-nums; }

.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch {
  width: 32px; height: 32px; border-radius: 9px; border: 2px solid transparent;
  padding: 0; position: relative; transition: 0.15s;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
}
.swatch:hover { transform: translateY(-1px); }
.swatch.on { border-color: #fff; box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.5); }

.seg {
  display: flex; gap: 2px; padding: 3px; background: var(--panel-2);
  border: 1px solid var(--line); border-radius: 9px;
}
.seg button {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font-size: 11px; padding: 5px 4px; border-radius: 6px; transition: 0.15s; white-space: nowrap;
}
.seg button:hover { color: var(--txt); }
.seg button.on { background: rgba(139, 92, 246, 0.22); color: #e9e3ff; box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.45); }

.toggles { display: flex; gap: 14px; }
.check { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: #c3cad9; cursor: pointer; }
.check input { appearance: none; width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid #3b4254; background: var(--panel-2); position: relative; cursor: pointer; }
.check input:checked { background: var(--accent); border-color: var(--accent); }
.check input:checked::after {
  content: ""; position: absolute; inset: 0; margin: auto; width: 7px; height: 4px;
  border-left: 1.7px solid #fff; border-bottom: 1.7px solid #fff; transform: rotate(-45deg) translate(0.5px, -1px);
}

input[type="range"] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 18px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 4px; border-radius: 99px;
  background: linear-gradient(90deg, rgba(139, 92, 246, 0.85), rgba(34, 211, 238, 0.5));
  opacity: 0.65;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px;
  border-radius: 50%; background: #fff; border: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5), 0 0 0 3px rgba(139, 92, 246, 0.25);
}
input[type="range"]:active::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.4); }

.shuffle {
  height: 34px; border-radius: 9px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03); color: #a8b0c2;
  font-size: 11.5px; display: flex; align-items: center; justify-content: center; gap: 7px;
}
.shuffle:hover { color: #fff; background: rgba(255, 255, 255, 0.06); border-color: var(--line-2); }

.reqs { margin: 0; padding-inline-start: 16px; font-size: 10.5px; color: var(--muted-2); line-height: 1.85; }

.panel-foot {
  margin-top: auto; padding: 14px 16px 6px; font-size: 10.5px; color: var(--muted-2);
  display: flex; align-items: center; gap: 7px;
}
.dot-live { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 8px var(--ok); }

/* ---------- workspace ---------- */
.workspace { display: flex; flex-direction: column; min-width: 0; position: relative; }

.stage {
  flex: 1 1 auto; position: relative; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(139, 92, 246, 0.09), transparent 55%),
    radial-gradient(rgba(255, 255, 255, 0.055) 1px, transparent 1px);
  background-size: auto, 22px 22px;
  padding: 26px 44px;
  overflow: hidden;
}
.stage::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at 50% 50%, transparent 40%, rgba(4, 5, 8, 0.55) 100%);
}
.stage-glow {
  position: absolute; width: 60%; height: 60%; border-radius: 50%;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.16), transparent 68%);
  filter: blur(40px); pointer-events: none;
}
.canvas-wrap { position: relative; display: flex; align-items: center; justify-content: center; z-index: 1; max-width: 100%; max-height: 100%; }
#preview {
  display: block; border-radius: 6px;
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, 0.9), 0 0 0 1px rgba(255, 255, 255, 0.07);
  max-height: 100%; max-width: 100%;
}

.stage-tools {
  position: absolute; bottom: 16px; inset-inline-start: 18px;
  display: flex; align-items: center; gap: 4px; z-index: 3;
  background: rgba(14, 16, 22, 0.82); border: 1px solid var(--line-2);
  border-radius: 99px; padding: 4px; backdrop-filter: blur(10px);
}
.tool {
  width: 30px; height: 30px; border-radius: 99px; border: 0; background: transparent;
  color: var(--muted); display: grid; place-items: center;
}
.tool:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.tool svg { width: 16px; height: 16px; }
.tool-count { font-size: 11px; color: #b9c0cf; min-width: 46px; text-align: center; font-variant-numeric: tabular-nums; direction: ltr; }

/* ---------- filmstrip ---------- */
.filmstrip-wrap {
  flex: 0 0 auto; border-top: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(12, 14, 19, 0.85), rgba(8, 9, 13, 0.95));
  padding: 10px 16px 12px;
}
.filmstrip { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 2px; min-height: 84px; align-items: center; }
.film-item {
  position: relative; border: 1px solid var(--line); border-radius: 9px;
  background: var(--panel-2); padding: 0; overflow: hidden; flex: 0 0 auto;
  height: 78px; transition: 0.15s; box-shadow: 0 6px 16px -10px rgba(0, 0, 0, 0.9);
}
.film-item img { height: 100%; width: auto; display: block; }
.film-item:hover { border-color: var(--line-2); transform: translateY(-1px); }
.film-item.on { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.35), 0 10px 20px -10px #000; }
.film-item .badge {
  position: absolute; top: 4px; inset-inline-start: 4px;
  background: rgba(0, 0, 0, 0.62); border-radius: 5px; font-size: 9px;
  padding: 1px 5px; color: #e7eaf2; backdrop-filter: blur(4px);
}
.film-add {
  height: 78px; width: 52px; border-radius: 9px; border: 1px dashed var(--line-2);
  background: rgba(255, 255, 255, 0.02); color: var(--muted);
  display: grid; place-items: center; flex: 0 0 auto;
}
.film-add:hover { border-color: rgba(139, 92, 246, 0.6); color: #c4b5fd; background: rgba(139, 92, 246, 0.06); }

/* ---------- drop overlay ---------- */
.drop-overlay {
  position: absolute; inset: 14px; z-index: 30; border-radius: 18px;
  border: 2px dashed rgba(139, 92, 246, 0.75);
  background: rgba(12, 8, 28, 0.82); backdrop-filter: blur(6px);
  display: none; align-items: center; justify-content: center;
}
.drop-overlay.show { display: flex; }
.drop-card { display: flex; flex-direction: column; align-items: center; gap: 6px; color: #ddd6fe; }
.drop-card b { font-size: 15px; }
.drop-card span { font-size: 11.5px; color: #a5a0c9; }

/* ---------- toast ---------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translate(-50%, 20px);
  background: rgba(20, 23, 31, 0.96); border: 1px solid var(--line-2);
  color: #e9edf6; font-size: 12.5px; padding: 10px 18px; border-radius: 11px;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: 0.22s ease; z-index: 100;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .app { grid-template-columns: 330px 1fr; }
  .brand-txt span { display: none; }
  .dims { display: none; }
}
@media (max-width: 900px) {
  body { overflow: auto; }
  .app { grid-template-columns: 1fr; height: auto; }
  .panel { order: 2; border-inline-start: 0; border-top: 1px solid var(--line); max-height: none; }
  .workspace { order: 1; height: 72vh; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 12px; gap: 10px; }
  .topbar-mid { order: 3; width: 100%; margin: 0; }
  .select { min-width: 0; flex: 1; }
  .size-wrap { flex: 1; }
  .stage { padding: 16px 20px 44px; }
  .btn span { display: none; }
}
