:root {
  --text: #1c2a44;
  --muted: #7b8aa5;
  --accent: #2f6bff;
  --accent-hot: #5b8cff;
  --accent-soft: rgba(47, 107, 255, 0.14);
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.78);
  --line: rgba(255, 255, 255, 0.7);
  --line-soft: rgba(120, 150, 200, 0.22);
  --shadow: 0 12px 32px rgba(70, 110, 180, 0.18);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --vv-height: 100dvh;
  --vv-offset-top: 0px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: var(--vv-height, 100dvh);
  background: #000;
  color: var(--text);
  font-family: Vazirmatn, Tahoma, sans-serif;
  overflow: hidden;
}

#player,
.artplayer-app {
  position: fixed !important;
  inset: 0 !important;
  top: var(--vv-offset-top, 0px) !important;
  width: 100% !important;
  height: var(--vv-height, 100dvh) !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: #000 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

.art-video-player .art-bottom,
.art-video-player .art-controls,
.art-video-player .art-mask,
.art-video-player .art-notice,
.art-video-player .art-info,
.art-video-player .art-settings,
.art-video-player .art-mini-progress-bar,
.art-control,
.art-progress {
  display: none !important;
  pointer-events: none !important;
}

.editor-ui {
  position: absolute;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  direction: rtl;
  font-family: Vazirmatn, Tahoma, sans-serif;
}

.editor-ui * {
  direction: rtl;
  font-family: Vazirmatn, Tahoma, sans-serif !important;
  -webkit-tap-highlight-color: transparent;
  box-sizing: border-box !important;
}

.editor-ui button {
  appearance: none;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  min-width: 0 !important;
  min-height: 0 !important;
  padding: 0;
}

/* ========== CROP ========== */
.crop-layer {
  position: absolute;
  inset: 0;
  z-index: 40;
  pointer-events: none;
  transition: opacity 0.2s ease, filter 0.2s ease;
}

.crop-shade {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 35, 0.5);
  -webkit-mask-image: var(--crop-mask);
  mask-image: var(--crop-mask);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 100% 100%;
  mask-size: 100% 100%;
  pointer-events: none;
}

.crop-frame {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  z-index: 41;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 0 4px rgba(47, 107, 255, 0.35),
    0 10px 28px rgba(30, 60, 120, 0.25);
  transition: opacity 0.2s ease, box-shadow 0.2s ease;
}

.crop-frame.is-rect { border-radius: 24px; }
.crop-frame.is-circle { border-radius: 50%; }

.crop-frame .move-hit {
  position: absolute;
  inset: 12px;
  border-radius: inherit;
  cursor: grab;
}
.crop-frame .move-hit:active { cursor: grabbing; }

.crop-frame .corner {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 2.5px solid var(--accent);
  box-shadow: 0 4px 14px rgba(47, 107, 255, 0.28);
  z-index: 2;
  touch-action: none;
}

.crop-frame.is-rect .corner.nw { top: -9px; left: -9px; cursor: nwse-resize; }
.crop-frame.is-rect .corner.ne { top: -9px; right: -9px; cursor: nesw-resize; }
.crop-frame.is-rect .corner.sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.crop-frame.is-rect .corner.se { bottom: -9px; right: -9px; cursor: nwse-resize; }

.crop-frame.is-circle .corner { display: none; }
.crop-frame.is-circle .corner.se {
  display: block;
  right: 4%;
  bottom: 4%;
  border-color: var(--accent);
  cursor: nwse-resize;
}

.crop-badge {
  position: absolute;
  top: -28px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 10px;
  font-weight: 800;
  color: var(--text);
  white-space: nowrap;
  pointer-events: none;
}

/* ========== TRIM ========== */
.trim-box {
  pointer-events: auto;
  position: absolute;
  left: 50%;
  bottom: calc(70px + var(--safe-bottom));
  transform: translateX(-50%) translateY(8px);
  width: min(300px, calc(100% - 40px));
  padding: 10px 12px;
  border-radius: 22px;
  background: var(--glass-strong);
  backdrop-filter: blur(22px) saturate(1.2);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: none;
  gap: 8px;
  opacity: 0;
  z-index: 60;
  transition: opacity 0.2s ease, transform 0.22s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.trim-box.is-open {
  display: grid;
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.editor-ui.is-focus-trim .trim-box.is-open {
  z-index: 220;
  opacity: 1;
  box-shadow:
    0 0 0 1.5px rgba(47, 107, 255, 0.35),
    0 14px 34px rgba(70, 110, 180, 0.22);
  filter: none;
}

.editor-ui.is-focus-trim .crop-layer {
  z-index: 180;
  opacity: 0.38;
  filter: saturate(0.75);
}

.editor-ui.is-focus-trim .crop-frame {
  pointer-events: auto !important;
  box-shadow: 0 0 0 1.5px rgba(255, 255, 255, 0.55);
}

.editor-ui.is-focus-crop .crop-layer {
  z-index: 220;
  opacity: 1;
  filter: none;
}

.editor-ui.is-focus-crop .crop-frame {
  pointer-events: auto;
  box-shadow:
    0 0 0 2px #fff,
    0 0 0 6px rgba(47, 107, 255, 0.28);
}

.editor-ui.is-focus-crop .trim-box.is-open {
  z-index: 35;
  opacity: 0.4;
  filter: saturate(0.7);
}

.trim-box .meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 10px;
  color: var(--muted);
  padding: 0 2px;
}
.trim-box .meta strong {
  color: var(--text);
  font-weight: 800;
}
.trim-box .meta .span-chip {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.scrub {
  position: relative;
  height: 26px;
  touch-action: none;
  user-select: none;
  display: flex;
  align-items: center;
}

.scrub-track {
  position: absolute;
  inset-inline: 0;
  height: 7px;
  border-radius: 999px;
  background: rgba(120, 150, 200, 0.2);
}

.scrub-range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: transparent;
  border-radius: 999px;
  pointer-events: auto;
  touch-action: none;
  cursor: grab;
  z-index: 1;
}
.scrub-range::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 999px;
  background: linear-gradient(90deg, #5b8cff, #2f6bff);
  box-shadow: 0 2px 8px rgba(47, 107, 255, 0.3);
  pointer-events: none;
}
.scrub-range:active { cursor: grabbing; }

.scrub-played {
  position: absolute;
  height: 7px;
  top: 50%;
  margin-top: -3.5px;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 999px;
  pointer-events: none;
  z-index: 2;
}

.handle {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  margin-left: -9px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--accent);
  box-shadow: 0 3px 10px rgba(47, 107, 255, 0.28);
  touch-action: none;
  z-index: 3;
}

/* ========== GLASS PILL ========== */
.pill-wrap {
  pointer-events: auto;
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(12px + var(--safe-bottom));
  display: flex;
  justify-content: center;
  z-index: 300;
  padding: 0 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: var(--glass);
  backdrop-filter: blur(22px) saturate(1.25);
  -webkit-backdrop-filter: blur(22px) saturate(1.25);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.pill-cluster {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.pill-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #6e7f9c;
  position: relative;
  transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.pill-btn:active { transform: scale(0.92); }

.pill-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}

.pill-btn.active {
  color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px rgba(47, 107, 255, 0.18);
}

.pill-btn.play {
  width: 42px;
  height: 42px;
  background: linear-gradient(145deg, #5b8cff, #2f6bff);
  color: #fff;
  box-shadow:
    0 8px 18px rgba(47, 107, 255, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.pill-btn.play svg { width: 18px; height: 18px; }

.pill-btn.ok {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.7);
}

.pill-btn.trim-on {
  background: var(--accent-soft);
  color: var(--accent);
}

.pill-label { display: none; }

.toast {
  pointer-events: none;
  position: absolute;
  top: calc(14px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--glass-strong);
  backdrop-filter: blur(16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 110;
  max-width: 90%;
  text-align: center;
}
.toast.show { opacity: 1; }
.toast.ok { color: #1f7a4c; }
