@media (max-width: 768px) {
  body.sg-mobile-swap-popup-open {
    overflow: hidden !important;
    touch-action: none;
  }

  .sg-mobile-swap-dismiss-layer {
    position: fixed;
    inset: 0;
    z-index: 10039;
    display: block;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(3, 6, 12, .7);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    cursor: default;
  }/* Compact mobile bottom sheet instead of a full-height panel. */
  .editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap {
    position: fixed !important;
    top: auto !important;
    right: 8px !important;
    bottom: calc(8px + env(safe-area-inset-bottom, 0px)) !important;
    left: 8px !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: min(92dvh, 760px) !important;
    margin: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    border-radius: 24px !important;
    border: 1px solid rgba(255,255,255,.13) !important;
    background: linear-gradient(180deg, rgba(26,28,35,.995), rgba(8,10,15,.995)) !important;
    box-shadow: 0 28px 90px rgba(0,0,0,.62), inset 0 1px 0 rgba(255,255,255,.04) !important;
    z-index: 10040 !important;
  }/* Main editor CSS hides all mobile panel headers; restore it only here. */
  .editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .left-panel-header {
    position: relative !important;
    z-index: 5 !important;
    flex: 0 0 56px !important;
    min-height: 56px !important;
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 9px 10px !important;
    border-bottom: 1px solid rgba(255,255,255,.08) !important;
    background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.015)) !important;
  }.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .left-panel-title {
    display: block !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
  }.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .lp-title-row {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
  }.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .left-panel-header .lp-title {
    display: block !important;
    max-width: 100% !important;
    overflow: hidden !important;
    color: #fff !important;
    font-size: 16px !important;
    font-weight: 800 !important;
    line-height: 1.15 !important;
    white-space: nowrap !important;
    text-overflow: ellipsis !important;
  }.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .left-panel-header .lp-subtitle {
    display: block !important;
    margin-top: 2px !important;
    color: rgba(255,255,255,.58) !important;
    font-size: 10px !important;
    line-height: 1.1 !important;
  }.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .lp-back,
  .editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .lp-close {
    position: static !important;
    flex: 0 0 38px !important;
    width: 38px !important;
    min-width: 38px !important;
    height: 38px !important;
    min-height: 38px !important;
    margin: 0 !important;
    padding: 0 !important;
    display: grid !important;
    place-items: center !important;
    overflow: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    border: 1px solid rgba(255,255,255,.14) !important;
    border-radius: 13px !important;
    background: rgba(255,255,255,.065) !important;
    color: #fff !important;
    font-size: 21px !important;
    line-height: 1 !important;
    box-shadow: inset 0 1px 0 rgba(255,255,255,.045) !important;
    -webkit-tap-highlight-color: transparent;
  }.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .lp-back:active,
  .editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .lp-close:active {
    transform: scale(.94) !important;
    background: rgba(255,255,255,.12) !important;
  }.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .tour-help-btn,
  .editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap > .sg-mobile-swap-close-btn {
    display: none !important;
  }.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap .left-panel-body {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    max-height: calc(min(92dvh, 760px) - 56px) !important;
    overflow: hidden !important;
    padding: 0 !important;
  }

  .editor-shell.is-mobile .mobile-tool-page--swap,
  .editor-shell.is-mobile .mobile-tool-content--swap {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(min(92dvh, 760px) - 56px) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    padding: 0 !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-page {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: calc(min(92dvh, 760px) - 56px) !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-top {
    flex: 0 1 auto !important;
    min-height: 0 !important;
    max-height: calc(min(92dvh, 760px) - 116px) !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 11px 11px 8px !important;
  }

  /* The popup header already contains the tool title. */
  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-title {
    display: none !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-top > div:first-child {
    margin-bottom: 9px !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-top > div:first-child > div:last-child {
    font-size: 11px !important;
    line-height: 1.35 !important;
    opacity: .72 !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-refs {
    margin-top: 7px !important;
    padding: 10px !important;
    border-radius: 17px !important;
    background: rgba(3,7,13,.48) !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-refs-row {
    min-height: 34px !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-refs-btn {
    min-height: 34px !important;
    padding: 0 12px !important;
    border-radius: 11px !important;
    font-size: 11px !important;
  }

  /* Reference preview: compact when empty, large enough after upload. */
  .editor-shell.is-mobile .mobile-tool-content--swap .ai-refs > div:nth-child(2) {
    min-height: 112px !important;
    margin-top: 7px !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-refs > div:nth-child(2) > div {
    width: min(100%, 230px) !important;
    height: 112px !important;
    border-radius: 13px !important;
    font-size: 30px !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-refs > div:nth-child(2) > button {
    max-width: min(100%, 240px) !important;
    max-height: 210px !important;
    border-radius: 13px !important;
    background-size: contain !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-agent__modes {
    display: grid !important;
    grid-template-columns: minmax(0,1fr) minmax(0,1fr) !important;
    gap: 7px !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-agent__mode {
    min-height: 54px !important;
    padding: 8px 9px !important;
    border-radius: 13px !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-agent__mode span {
    font-size: 11px !important;
    line-height: 1.15 !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap label {
    margin-top: 10px !important;
    padding: 9px 10px !important;
    gap: 8px !important;
    border-radius: 13px !important;
    font-size: 10px !important;
    line-height: 1.3 !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap label input[type="checkbox"] {
    flex: 0 0 auto !important;
    width: 16px !important;
    height: 16px !important;
    margin-top: 0 !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-footer {
    position: relative !important;
    flex: 0 0 auto !important;
    margin: 0 !important;
    padding: 9px 11px calc(10px + env(safe-area-inset-bottom, 0px)) !important;
    border-top: 1px solid rgba(255,255,255,.08) !important;
    background: rgba(8,10,15,.985) !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-run {
    width: 100% !important;
    min-height: 49px !important;
    height: 49px !important;
    border-radius: 15px !important;
    font-size: 14px !important;
    font-weight: 800 !important;
  }
  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-top {
    padding-top: 9px !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-top > div:first-child:empty {
    display: none !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-footer {
    position: sticky !important;
    bottom: 0 !important;
    z-index: 6 !important;
  }

}

@media (max-width: 380px) {.editor-shell.is-mobile .left-panel.left-panel--tool-ai-face-swap {
    right: 5px !important;
    bottom: calc(5px + env(safe-area-inset-bottom, 0px)) !important;
    left: 5px !important;
    border-radius: 21px !important;
  }

  .editor-shell.is-mobile .mobile-tool-content--swap .ai-hair-top {
    padding-right: 8px !important;
    padding-left: 8px !important;
  }
}
