/**
 * Pro Editor — lock to one viewport (no page scroll), portrait-friendly layout
 */

/* ── Viewport lock when Pro Editor is active ── */
body.cap-pro-editor-active {
  overflow: hidden;
  height: 100dvh;
  max-height: 100dvh;
}

body.cap-pro-editor-active .app-shell {
  padding-top: 0;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
}

body.cap-pro-editor-active .workspace {
  margin-left: 0;
  width: 100%;
  max-width: none;
  min-height: 0;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

body.cap-pro-editor-active .main-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

body.cap-pro-editor-active #panel-timeline.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

body.cap-pro-editor-active #panel-timeline .capcut-editor {
  flex: 1;
  min-height: 0;
  height: 100%;
  max-height: 100dvh;
}

body.cap-pro-editor-active .app-footer {
  display: none;
}

/* ── Flex chain: preview fills remaining space ── */
body.cap-pro-editor-active .cap-center {
  flex: 1;
  min-height: 0;
}

body.cap-pro-editor-active .cap-stage {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  padding: 0.25rem 0.5rem 0;
}

body.cap-pro-editor-active .cap-preview-shell {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  container-type: size;
  container-name: preview;
}

body.cap-pro-editor-active .cap-preview-frame,
body.cap-pro-editor-active #capcut-editor .ve-preview-frame {
  max-height: 100%;
  max-width: 100%;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

body.cap-pro-editor-active #capcut-editor .ve-preview-frame[data-aspect="9:16"] {
  aspect-ratio: 9 / 16;
  width: min(100cqw, calc(100cqh * 9 / 16));
  height: min(100cqh, calc(100cqw * 16 / 9));
  max-width: 100%;
  max-height: 100%;
}

body.cap-pro-editor-active #capcut-editor .ve-preview-frame[data-aspect="16:9"] {
  aspect-ratio: 16 / 9;
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: min(100cqh, calc(100cqw * 9 / 16));
  max-width: 100%;
  max-height: 100%;
}

body.cap-pro-editor-active #capcut-editor .ve-preview-frame[data-aspect="1:1"] {
  aspect-ratio: 1 / 1;
  width: min(100cqw, 100cqh);
  height: min(100cqh, 100cqw);
  max-width: 100%;
  max-height: 100%;
}

body.cap-pro-editor-active .cap-transport {
  flex-shrink: 0;
  padding: 0.3rem 0.5rem;
  gap: 0.35rem 0.5rem;
}

body.cap-pro-editor-active .cap-preview-scrub-wrap {
  flex-shrink: 0;
  padding: 0 0.5rem 0.2rem;
}

body.cap-pro-editor-active .cap-status {
  flex-shrink: 0;
  min-height: 1.5rem;
  padding: 0.2rem 0.75rem;
  font-size: 0.72rem;
}

body.cap-pro-editor-active .cap-timeline {
  flex-shrink: 0;
  min-height: 0;
}

/* Compact topbar */
body.cap-pro-editor-active .cap-topbar {
  flex-shrink: 0;
  min-height: 2.5rem;
  padding: 0.35rem 0.65rem;
}

/* Mobile inspector toggle — desktop hidden */
.cap-mobile-inspector-btn {
  display: none;
}

/* ── Portrait / narrow: collapse side panels, drawer inspector ── */
@media (orientation: portrait), (max-width: 900px) {
  body.cap-pro-editor-active {
    --cap-topbar-h: 2.5rem;
    --cap-status-h: 1.5rem;
  }

  body.cap-pro-editor-active .cap-workspace {
    grid-template-columns: 52px 1fr !important;
  }

  body.cap-pro-editor-active .cap-resizer-v {
    display: none !important;
  }

  body.cap-pro-editor-active .cap-sidebar-right:not(.cap-mobile-drawer) {
    display: none !important;
  }

  body.cap-pro-editor-active .cap-sidebar-left {
    width: 52px !important;
    min-width: 52px;
    position: relative;
    z-index: 2;
  }

  body.cap-pro-editor-active .cap-sidebar-left .cap-panel-area {
    position: fixed;
    left: 52px;
    top: var(--cap-topbar-h, 2.5rem);
    bottom: calc(var(--cap-timeline-h) + var(--cap-status-h, 1.5rem));
    width: min(82vw, 300px);
    z-index: 70;
    transform: translateX(-108%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.55);
    border-right: 1px solid var(--cap-border);
  }

  body.cap-pro-editor-active .cap-sidebar-left.cap-left-open .cap-panel-area {
    transform: translateX(0);
  }

  body.cap-pro-editor-active .cap-mobile-inspector-btn {
    display: inline-flex;
  }

  body.cap-pro-editor-active .cap-sidebar-right.cap-mobile-drawer {
    display: flex !important;
    position: fixed;
    left: 0;
    right: 0;
    bottom: calc(var(--cap-timeline-h) + var(--cap-status-h, 1.5rem));
    width: 100% !important;
    max-height: min(40dvh, 300px);
    z-index: 75;
    border-top: 1px solid var(--cap-border);
    transform: translateY(calc(100% + 1rem));
    transition: transform 0.22s ease;
    box-shadow: 0 -10px 36px rgba(0, 0, 0, 0.5);
    background: var(--cap-panel);
  }

  body.cap-pro-editor-active .cap-sidebar-right.cap-mobile-drawer.cap-drawer-open {
    transform: translateY(0);
  }

  body.cap-pro-editor-active .cap-topbar-center .cap-project-name-input {
    width: min(140px, 36vw);
    font-size: 0.75rem;
  }

  body.cap-pro-editor-active .cap-logo-wordmark {
    display: none;
  }

  body.cap-pro-editor-active .cap-share-pill {
    display: none;
  }

  body.cap-pro-editor-active .cap-transport .cap-volume {
    width: 3.5rem;
  }

  body.cap-pro-editor-active .cap-timeline-tools {
    padding: 0.25rem 0.5rem;
  }

  body.cap-pro-editor-active .cap-timeline-tools .cap-tool {
    width: 1.75rem;
    height: 1.75rem;
  }
}

@media (orientation: portrait) and (max-height: 700px) {
  body.cap-pro-editor-active .cap-preview-scrub-wrap {
    display: none;
  }

  body.cap-pro-editor-active .cap-transport {
    padding: 0.2rem 0.4rem;
  }

  body.cap-pro-editor-active .cap-tbtn {
    width: 1.85rem;
    height: 1.85rem;
  }
}

/* Backdrop when left panel open on mobile */
.cap-left-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(0, 0, 0, 0.35);
}

body.cap-pro-editor-active.cap-left-panel-open .cap-left-backdrop {
  display: block;
}
