/* ==========================================================================
   base.css — سیستم طراحی ویرایشگر ویدیو آلفا
   رنگ‌ها، تایپوگرافی، دکمه‌ها، اسلایدرها، شیت‌ها، پیام‌ها و پنجره‌ها
   ========================================================================== */
:root {
  --bg: #0a0a0f;
  --bg1: #0f0f16;
  --bg2: #14141d;
  --bg3: #1b1b26;
  --bg4: #232331;
  --bg5: #2c2c3c;
  --line: rgba(255, 255, 255, 0.07);
  --line2: rgba(255, 255, 255, 0.12);
  --line3: rgba(255, 255, 255, 0.2);
  --tx: #f3f3f8;
  --tx2: #a9abbe;
  --tx3: #6f7186;
  --ac: #7c5cff;
  --ac-l: #9b84ff;
  --ac-d: #5b3fe0;
  --ac2: #22d3ee;
  --ac-soft: rgba(124, 92, 255, 0.16);
  --grad: linear-gradient(120deg, #7c5cff 0%, #a855f7 48%, #22d3ee 100%);
  --grad2: linear-gradient(135deg, #8b5cf6, #ec4899);
  --ok: #34d399;
  --warn: #fbbf24;
  --err: #fb5779;
  --r1: 8px;
  --r2: 12px;
  --r3: 16px;
  --r4: 22px;
  --r5: 28px;
  --sh1: 0 2px 8px rgba(0, 0, 0, 0.35);
  --sh2: 0 14px 40px -12px rgba(0, 0, 0, 0.75);
  --sh-ac: 0 10px 28px -10px rgba(124, 92, 255, 0.85);
  --font: "AE UI", "Vazirmatn", Tahoma, "Segoe UI", system-ui, sans-serif;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --spring: cubic-bezier(0.34, 1.4, 0.5, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --c-video: #5b5bf0;
  --c-overlay: #0ea5e9;
  --c-text: #f59e0b;
  --c-sticker: #ec4899;
  --c-fx: #a855f7;
  --c-look: #14b8a6;
  --c-adjust: #84cc16;
  --c-audio: #10b981;
  --c-voice: #06b6d4;
  --c-sfx: #f97316;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--tx);
  font-family: var(--font); font-size: 14px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  overflow: hidden; overscroll-behavior: none; touch-action: manipulation;
}
body { position: fixed; inset: 0; width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { cursor: default; opacity: 0.45; }
img, svg, canvas, video { display: block; }
::selection { background: rgba(124, 92, 255, 0.45); }
.hide { display: none !important; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.num { font-feature-settings: "tnum" 1; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.sep { height: 1px; background: var(--line); margin: 10px 0; }
.muted { color: var(--tx2); }
.dim { color: var(--tx3); }
.ellip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.scroll-y { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; scrollbar-width: none; }
.scroll-x::-webkit-scrollbar { display: none; }
.scroll-y::-webkit-scrollbar { width: 6px; }
.scroll-y::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 6px; }

/* ---------------- آیکن ---------------- */
.ic { width: 22px; height: 22px; flex: 0 0 auto; stroke: currentColor; fill: none; }
.ic.sm { width: 18px; height: 18px; }
.ic.xs { width: 15px; height: 15px; }
.ic.lg { width: 28px; height: 28px; }
.ic.fill { fill: currentColor; stroke: none; }
[dir="rtl"] .ic.flip-rtl { transform: scaleX(-1); }

/* ---------------- دکمه‌ها ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 8px 16px; border-radius: var(--r2);
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line);
  font-weight: 600; font-size: 13.5px; color: var(--tx); white-space: nowrap;
  transition: transform 0.15s var(--ease), background 0.2s, border-color 0.2s, box-shadow 0.2s, opacity 0.2s;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(0.96); }
.btn:hover { background: rgba(255, 255, 255, 0.09); }
.btn.pri { background: var(--grad); border-color: transparent; color: #fff; box-shadow: var(--sh-ac); }
.btn.pri:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: #fff; background: #e11d48; border-color: transparent; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 15.5px; border-radius: var(--r3); padding: 10px 22px; }
.btn.sm { min-height: 32px; padding: 4px 12px; font-size: 12.5px; border-radius: 10px; }
.ibtn {
  width: 40px; height: 40px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--tx); transition: background 0.2s, transform 0.15s var(--ease), color 0.2s; flex: 0 0 auto; position: relative;
}
.ibtn:hover { background: rgba(255, 255, 255, 0.07); }
.ibtn:active { transform: scale(0.9); }
.ibtn.sm { width: 34px; height: 34px; border-radius: 10px; }
.ibtn.round { border-radius: 50%; }
.ibtn.on { color: var(--ac-l); background: var(--ac-soft); }
.ibtn:disabled { opacity: 0.32; }

.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600;
  background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); color: var(--tx2);
  white-space: nowrap; flex: 0 0 auto; transition: all 0.18s var(--ease);
}
.chip:active { transform: scale(0.95); }
.chip.on { background: var(--tx); color: #0b0b12; border-color: transparent; }
.chip.ac.on { background: var(--ac); color: #fff; }
.chips { display: flex; gap: 8px; flex-wrap: nowrap; padding: 2px 16px; }
.chips.wrap { flex-wrap: wrap; padding: 0; }

.seg { display: inline-flex; background: rgba(255, 255, 255, 0.05); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.seg button { height: 32px; padding: 0 12px; border-radius: 9px; font-size: 12.5px; font-weight: 600; color: var(--tx2); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg button.on { background: var(--bg5); color: var(--tx); box-shadow: var(--sh1); }

.badge {
  display: inline-flex; align-items: center; height: 18px; padding: 0 6px; border-radius: 6px;
  font-size: 10px; font-weight: 700; background: var(--grad); color: #fff; letter-spacing: 0;
}
.badge.pro { background: linear-gradient(135deg, #f59e0b, #ef4444); }
.badge.new { background: linear-gradient(135deg, #22d3ee, #6366f1); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ac); display: inline-block; }

/* ---------------- ورودی‌ها ---------------- */
.input, .textarea {
  width: 100%; background: var(--bg3); border: 1px solid var(--line2); border-radius: var(--r2);
  padding: 10px 14px; outline: none; transition: border-color 0.2s, box-shadow 0.2s; color: var(--tx);
}
.input:focus, .textarea:focus { border-color: var(--ac); box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.22); }
.textarea { resize: none; min-height: 84px; line-height: 1.8; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--tx2); font-weight: 600; }

.switch { position: relative; display: inline-block; width: 44px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch i { position: absolute; inset: 0; border-radius: 99px; background: var(--bg5); transition: background 0.2s; }
.switch i::after { content: ""; position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform 0.22s var(--spring); box-shadow: var(--sh1); }
.switch input:checked + i { background: var(--ac); }
.switch input:checked + i::after { transform: translateX(-18px); }

/* ---------------- اسلایدر اختصاصی ---------------- */
.sl { display: flex; flex-direction: column; gap: 4px; padding: 6px 0; user-select: none; -webkit-user-select: none; }
.sl-head { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; color: var(--tx2); gap: 8px; }
.sl-head b { font-weight: 600; color: var(--tx); font-size: 12.5px; min-width: 40px; text-align: left; direction: ltr; font-feature-settings: "tnum" 1; }
.sl-head .sl-name { display: flex; align-items: center; gap: 6px; }
.sl-track { position: relative; height: 30px; touch-action: none; cursor: pointer; }
.sl-track::before { content: ""; position: absolute; left: 0; right: 0; top: 13px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, 0.12); }
.sl-fill { position: absolute; top: 13px; height: 4px; border-radius: 4px; background: var(--grad); }
.sl-zero { position: absolute; top: 9px; width: 2px; height: 12px; border-radius: 2px; background: rgba(255, 255, 255, 0.35); transform: translateX(-1px); }
.sl-knob {
  position: absolute; top: 4px; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 0 4px rgba(124, 92, 255, 0.0);
  transition: box-shadow 0.2s, transform 0.15s var(--ease);
}
.sl.drag .sl-knob { transform: scale(1.12); box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 0 7px rgba(124, 92, 255, 0.3); }
.sl-bubble {
  position: absolute; bottom: 30px; transform: translateX(-50%); background: var(--tx); color: #0b0b12;
  font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 8px; pointer-events: none; opacity: 0;
  transition: opacity 0.15s; direction: ltr; white-space: nowrap;
}
.sl.drag .sl-bubble { opacity: 1; }

/* ---------------- شیت پایین صفحه (موبایل) ---------------- */
.sheet-wrap { position: fixed; inset: 0; z-index: 60; pointer-events: none; }
.sheet-wrap.modal { pointer-events: auto; background: rgba(0, 0, 0, 0.45); opacity: 0; transition: opacity 0.25s; }
.sheet-wrap.modal.show { opacity: 1; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; pointer-events: auto;
  background: var(--bg2); border-radius: var(--r4) var(--r4) 0 0; border-top: 1px solid var(--line2);
  box-shadow: 0 -18px 50px -10px rgba(0, 0, 0, 0.65);
  transform: translateY(105%); transition: transform 0.32s var(--ease);
  display: flex; flex-direction: column; max-height: 82%; padding-bottom: var(--safe-b);
}
.sheet.show { transform: translateY(0); }
.sheet-grab { height: 22px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; touch-action: none; cursor: grab; }
.sheet-grab::before { content: ""; width: 40px; height: 4.5px; border-radius: 4px; background: rgba(255, 255, 255, 0.22); }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 0 12px 8px 12px; flex: 0 0 auto; min-height: 44px; }
.sheet-head h3 { margin: 0; font-size: 15.5px; font-weight: 800; flex: 1; display: flex; align-items: center; gap: 8px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding: 0 16px 14px; }
.sheet-body.nopad { padding: 0 0 12px; }
.done-btn { width: 36px; height: 36px; border-radius: 50%; background: var(--tx); color: #0b0b12; display: inline-flex; align-items: center; justify-content: center; }
.done-btn:active { transform: scale(0.9); }

/* ---------------- پنجره‌ی گفتگو ---------------- */
.dlg-wrap { position: fixed; inset: 0; z-index: 90; background: rgba(4, 4, 8, 0.6); display: flex; align-items: center; justify-content: center; padding: 18px; opacity: 0; transition: opacity 0.2s; }
.dlg-wrap.show { opacity: 1; }
.dlg {
  width: 100%; max-width: 400px; background: var(--bg2); border: 1px solid var(--line2); border-radius: var(--r4);
  box-shadow: var(--sh2); padding: 22px 20px 18px; transform: translateY(14px) scale(0.97); transition: transform 0.28s var(--spring);
}
.dlg-wrap.show .dlg { transform: none; }
.dlg h3 { margin: 0 0 6px; font-size: 17px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.dlg p { margin: 0 0 16px; color: var(--tx2); font-size: 13.5px; line-height: 1.9; }
.dlg .acts { display: flex; gap: 10px; }
.dlg .acts .btn { flex: 1; }
.dlg-ic { width: 46px; height: 46px; border-radius: 15px; display: flex; align-items: center; justify-content: center; margin-bottom: 12px; background: var(--ac-soft); color: var(--ac-l); }
.dlg-ic.err { background: rgba(251, 87, 121, 0.14); color: var(--err); }

/* ---------------- پیام کوتاه ---------------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(96px + var(--safe-b)); z-index: 100; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  display: inline-flex; align-items: center; gap: 10px; max-width: 520px; background: rgba(30, 30, 42, 0.97); border: 1px solid var(--line2);
  color: var(--tx); padding: 10px 16px; border-radius: 14px; box-shadow: var(--sh2); font-size: 13px; font-weight: 600;
  transform: translateY(16px); opacity: 0; transition: all 0.3s var(--spring); pointer-events: auto;
}
.toast.show { transform: none; opacity: 1; }
.toast .ic { color: var(--ac-l); }
.toast.err .ic { color: var(--err); }
.toast.ok .ic { color: var(--ok); }
.toast .t-act { color: var(--ac-l); font-weight: 800; margin-right: 6px; padding: 2px 6px; }

/* ---------------- منو ---------------- */
.menu-wrap { position: fixed; inset: 0; z-index: 85; }
.menu {
  position: absolute; min-width: 190px; background: var(--bg3); border: 1px solid var(--line2); border-radius: 16px;
  box-shadow: var(--sh2); padding: 6px; transform-origin: top; animation: menuIn 0.18s var(--ease);
}
.menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border-radius: 10px; font-size: 13.5px; color: var(--tx); text-align: right; }
.menu button:hover { background: rgba(255, 255, 255, 0.06); }
.menu button.danger { color: var(--err); }
.menu .sep { margin: 4px 6px; }
@keyframes menuIn { from { opacity: 0; transform: scale(0.95) translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------------- شبکه‌ی کاشی‌ها (فیلتر، افکت، استیکر...) ---------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 10px; }
.tiles.big { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
.tiles.small { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 8px; }
.tile { display: flex; flex-direction: column; gap: 6px; align-items: stretch; text-align: center; position: relative; min-width: 0; }
.tile .th {
  position: relative; aspect-ratio: 1 / 1; border-radius: 14px; overflow: hidden; background: var(--bg4);
  border: 2px solid transparent; transition: border-color 0.18s, transform 0.18s var(--ease); display: flex; align-items: center; justify-content: center;
}
.tile .th img, .tile .th canvas { width: 100%; height: 100%; object-fit: cover; }
.tile:active .th { transform: scale(0.95); }
.tile.on .th { border-color: var(--tx); }
.tile .nm { font-size: 11.5px; color: var(--tx2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.on .nm { color: var(--tx); font-weight: 700; }
.tile .th .ic { color: var(--tx2); }
.tile .corner { position: absolute; top: 5px; left: 5px; }
.tile .fav { position: absolute; bottom: 4px; left: 4px; width: 22px; height: 22px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,0.8); }

.shimmer { background: linear-gradient(100deg, var(--bg4) 30%, var(--bg5) 50%, var(--bg4) 70%); background-size: 300% 100%; animation: shimmer 1.4s infinite linear; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 2.5px solid rgba(255, 255, 255, 0.18); border-top-color: var(--tx); animation: spin 0.8s linear infinite; }

/* ---------------- رنگ‌چین ---------------- */
.cp { display: flex; flex-direction: column; gap: 12px; }
.cp-sw { display: flex; gap: 9px; flex-wrap: wrap; }
.cp-sw button { width: 32px; height: 32px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.12); position: relative; flex: 0 0 auto; }
.cp-sw button.on { box-shadow: 0 0 0 2px var(--bg2), 0 0 0 4px var(--tx); }
.cp-sw button.none { background: repeating-conic-gradient(#444 0 25%, #888 0 50%) 50% / 12px 12px; }
.cp-sw button.none::after { content: ""; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 2px; background: #ef4444; transform: rotate(45deg); }
.cp-sv { position: relative; height: 150px; border-radius: 14px; touch-action: none; cursor: crosshair; overflow: hidden; }
.cp-sv i { position: absolute; width: 20px; height: 20px; margin: -10px 0 0 -10px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); pointer-events: none; }
.cp-hue, .cp-alpha { position: relative; height: 18px; border-radius: 10px; touch-action: none; cursor: pointer; direction: ltr; }
.cp-hue { background: linear-gradient(90deg, red, #ff0, lime, cyan, blue, #f0f, red); }
.cp-alpha { background: repeating-conic-gradient(#555 0 25%, #999 0 50%) 50% / 12px 12px; }
.cp-alpha b { position: absolute; inset: 0; border-radius: 10px; }
.cp-hue i, .cp-alpha i { position: absolute; top: -3px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); pointer-events: none; }
.cp-row { display: flex; gap: 10px; align-items: center; }
.cp-prev { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line2); flex: 0 0 auto; background-clip: padding-box; }
.cp-hex { direction: ltr; text-align: left; font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; }

/* ---------------- برگه‌ها ---------------- */
.tabs { display: flex; gap: 4px; padding: 0 12px; border-bottom: 1px solid var(--line); flex: 0 0 auto; }
.tabs button { position: relative; height: 40px; padding: 0 12px; font-size: 13px; font-weight: 700; color: var(--tx3); white-space: nowrap; }
.tabs button.on { color: var(--tx); }
.tabs button.on::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2.5px; border-radius: 3px; background: var(--grad); }

.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 10px; padding: 28px 16px; color: var(--tx2); }
.empty .ic { width: 40px; height: 40px; color: var(--tx3); }
.prog { height: 6px; background: rgba(255, 255, 255, 0.1); border-radius: 6px; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--grad); border-radius: 6px; transition: width 0.3s; }

/* ---------------- بارگذاری اولیه ---------------- */
#boot { position: fixed; inset: 0; z-index: 200; background: var(--bg); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; transition: opacity 0.4s; }
#boot.out { opacity: 0; pointer-events: none; }
.logo-mark { width: 64px; height: 64px; border-radius: 20px; background: var(--grad); display: flex; align-items: center; justify-content: center; box-shadow: var(--sh-ac); }
.logo-mark svg { width: 36px; height: 36px; }
#boot .bar { width: 120px; height: 3px; border-radius: 3px; background: rgba(255,255,255,0.08); overflow: hidden; }
#boot .bar i { display: block; width: 40%; height: 100%; background: var(--grad); animation: bootbar 1.1s var(--ease) infinite; }
@keyframes bootbar { 0% { transform: translateX(-140%); } 100% { transform: translateX(300%); } }

@media (hover: hover) {
  .tile:hover .th { border-color: rgba(255, 255, 255, 0.25); }
  .tile.on:hover .th { border-color: var(--tx); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
