/* AI Video Factory responsive shell v2
 * Additive safety layer: keeps existing page visuals and business modules intact.
 */
:root {
  --avf-shell-sidebar-width: 140px;
  --avf-shell-topbar-height: 56px;
  --avf-mobile-nav-height: 66px;
}

html,
body,
.app-container,
.main-layout,
.content-area,
.step-content {
  min-width: 0;
  max-width: 100%;
}

html,
body {
  width: 100%;
}

body.avf-responsive-shell {
  overflow-x: clip;
}

body.avf-responsive-shell .app-container {
  min-height: 100vh;
  height: 100dvh;
}

body.avf-responsive-shell .main-layout,
body.avf-responsive-shell .content-area {
  width: 100%;
}

body.avf-responsive-shell .sidebar {
  width: var(--avf-shell-sidebar-width) !important;
  min-width: var(--avf-shell-sidebar-width);
}

body.avf-shell-tablet {
  --avf-shell-sidebar-width: 56px;
}

body.avf-shell-tablet .sidebar .nav-item {
  justify-content: center;
  gap: 0;
  padding-inline: 6px !important;
}

body.avf-shell-tablet .sidebar .nav-item > span:not(.nav-icon) {
  display: none !important;
}

body.avf-shell-tablet .sidebar .nav-icon {
  margin: 0;
}

body[data-avf-page="create"].avf-responsive-shell .avfmk {
  left: var(--avf-shell-sidebar-width) !important;
}

body.avf-shell-mobile {
  --avf-shell-sidebar-width: 0px;
  --avf-shell-topbar-height: 56px;
}

body.avf-shell-mobile .sidebar {
  display: none !important;
}

body.avf-shell-mobile .topbar {
  position: relative;
  min-height: var(--avf-shell-topbar-height) !important;
  padding: 6px 10px !important;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  gap: 8px !important;
  overflow: visible;
}

body.avf-shell-mobile .topbar-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  letter-spacing: 0;
}

body.avf-shell-mobile .topbar-keys,
body.avf-shell-mobile .service-status,
body.avf-shell-mobile .topbar > .btn:not(.btn-login):not(.btn-logout) {
  display: none !important;
}

body.avf-shell-mobile .theme-btn,
body.avf-shell-mobile .user-status {
  flex: 0 0 auto;
  margin: 0 !important;
}

body.avf-shell-mobile .user-status .user-name,
body.avf-shell-mobile .user-status .vip-badge {
  display: none !important;
}

body.avf-shell-mobile .topbar:has(.avf-progress-rail:not([hidden])) {
  min-height: 100px !important;
  padding-bottom: 50px !important;
}

body.avf-shell-mobile .topbar .avf-progress-rail:not([hidden]) {
  position: absolute !important;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 44px !important;
  padding-inline: 8px !important;
  overflow-x: auto !important;
  overflow-y: hidden !important;
  scrollbar-width: none;
}

body.avf-shell-mobile .topbar .avf-progress-rail::-webkit-scrollbar {
  display: none;
}

body.avf-shell-mobile .content-area {
  min-width: 0;
  padding-bottom: calc(var(--avf-mobile-nav-height) + env(safe-area-inset-bottom));
}

body.avf-shell-mobile .step-content {
  min-width: 0;
  scroll-padding-bottom: calc(var(--avf-mobile-nav-height) + 16px);
}

body.avf-shell-mobile .panel,
body.avf-shell-mobile .panel-content,
body.avf-shell-mobile .avfhome,
body.avf-shell-mobile .shell {
  min-width: 0;
  max-width: 100%;
}

body.avf-shell-mobile .hero h1 {
  font-size: clamp(28px, 9.5vw, 38px);
  line-height: 1.14;
}

body.avf-shell-mobile .hero .thesis br {
  display: none;
}

body.avf-shell-mobile #my-panel {
  width: min(400px, 100vw) !important;
  max-width: 100vw;
}

body.avf-shell-mobile #panel-5-mixer.mx-fusion-ui .avfv5timelinebox .tl-scroll {
  max-width: 100%;
  overflow-x: auto !important;
  overscroll-behavior-inline: contain;
}

body.avf-shell-mobile #panel-5-mixer.mx-fusion-ui .avfv5timelinebox .tl-inner {
  min-width: 720px !important;
}

body.avf-shell-mobile footer {
  bottom: calc(var(--avf-mobile-nav-height) + env(safe-area-inset-bottom) + 5px) !important;
  max-width: calc(100vw - 20px);
  overflow: hidden;
  text-overflow: ellipsis;
}

.avf-mobile-nav,
.avf-mobile-more-backdrop,
.avf-mobile-more-sheet {
  display: none;
}

body.avf-shell-mobile .avf-mobile-nav {
  position: fixed;
  z-index: 10020;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--avf-mobile-nav-height) + env(safe-area-inset-bottom));
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: stretch;
  gap: 3px;
  border-top: 1px solid color-mix(in srgb, var(--border-color) 88%, transparent);
  background: color-mix(in srgb, var(--bg-secondary) 94%, transparent);
  box-shadow: 0 -10px 28px rgba(18, 14, 8, .08);
  backdrop-filter: blur(16px) saturate(1.1);
}

.avf-mobile-nav a,
.avf-mobile-nav button {
  min-width: 0;
  min-height: 52px;
  padding: 4px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 11px;
  line-height: 1.1;
  text-decoration: none;
  cursor: pointer;
}

.avf-mobile-nav a[aria-current="page"] {
  color: var(--accent-start);
  background: rgba(var(--accent-rgb), .1);
}

.avf-mobile-nav .avf-mobile-nav-icon {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.avf-mobile-nav .avf-mobile-nav-create {
  color: #fff;
  background: var(--accent-start);
  box-shadow: 0 7px 18px rgba(var(--accent-rgb), .2);
}

.avf-mobile-nav a:focus-visible,
.avf-mobile-nav button:focus-visible,
.avf-mobile-more-sheet a:focus-visible,
.avf-mobile-more-sheet button:focus-visible {
  outline: 2px solid var(--accent-start);
  outline-offset: 1px;
}

body.avf-shell-mobile .avf-mobile-more-backdrop {
  position: fixed;
  z-index: 10030;
  inset: 0;
  display: block;
  border: 0;
  background: rgba(15, 13, 10, .48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms cubic-bezier(.23, 1, .32, 1);
}

body.avf-shell-mobile .avf-mobile-more-sheet {
  position: fixed;
  z-index: 10031;
  left: 10px;
  right: 10px;
  bottom: calc(var(--avf-mobile-nav-height) + env(safe-area-inset-bottom) + 8px);
  padding: 14px;
  display: block;
  border: 1px solid var(--border-color);
  border-radius: 18px;
  background: var(--bg-card);
  box-shadow: 0 24px 64px rgba(15, 13, 10, .24);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px);
  transition: transform 320ms cubic-bezier(.23, 1, .32, 1), opacity 200ms ease-out;
}

body.avf-shell-mobile.avf-mobile-more-open .avf-mobile-more-backdrop,
body.avf-shell-mobile.avf-mobile-more-open .avf-mobile-more-sheet {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.avf-mobile-more-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.avf-mobile-more-head strong {
  font-size: 16px;
  font-weight: 650;
}

.avf-mobile-more-head button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 12px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 18px;
}

.avf-mobile-more-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.avf-mobile-more-grid a {
  min-height: 52px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  text-decoration: none;
}

.avf-mobile-more-grid a[aria-current="page"] {
  border-color: rgba(var(--accent-rgb), .42);
  background: rgba(var(--accent-rgb), .1);
}

@media (prefers-reduced-motion: reduce) {
  .avf-mobile-more-backdrop,
  .avf-mobile-more-sheet {
    transition: none !important;
  }
}

/* Mobile polish: keep the stage clear and move legal/assistant chrome out of content. */
body.avf-shell-mobile .hero h1 {
  font-size: clamp(27px, 7.6vw, 32px);
}

body.avf-shell-mobile footer {
  display: none !important;
}

body.avf-shell-mobile #yxFab {
  right: 10px !important;
  bottom: calc(var(--avf-mobile-nav-height) + env(safe-area-inset-bottom) + 50px) !important;
  width: 48px !important;
  height: 48px !important;
}

body.avf-shell-mobile #yxFab .yx-phx {
  width: 29px !important;
  height: 29px !important;
}

body.avf-shell-mobile #yxToast {
  bottom: calc(var(--avf-mobile-nav-height) + env(safe-area-inset-bottom) + 48px) !important;
}

.avf-mobile-legal {
  min-height: 44px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  text-decoration: none;
}

.avf-mobile-legal:hover {
  color: var(--text-primary);
}


/* Materials: keep link input and both actions fully visible on narrow phones. */
body.avf-shell-mobile #panel-1 .p1omni {
  box-sizing: border-box;
  display: grid !important;
  grid-template-columns: 18px minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas:
    "icon input input"
    "upload upload search";
  gap: 8px 10px;
  height: auto !important;
  padding: 10px 12px !important;
  align-items: center;
}

body.avf-shell-mobile #panel-1 .p1omni > svg {
  grid-area: icon;
}

body.avf-shell-mobile #panel-1 #avfp1Q {
  grid-area: input;
  box-sizing: border-box;
  min-width: 0;
  width: 100% !important;
}

body.avf-shell-mobile #panel-1 .p1updl {
  grid-area: upload;
}

body.avf-shell-mobile #panel-1 .p1go {
  grid-area: search;
}

body.avf-shell-mobile #panel-1 .p1updl,
body.avf-shell-mobile #panel-1 .p1go {
  box-sizing: border-box;
  min-width: 0;
  width: 100% !important;
  min-height: 44px;
}

/* Avatar: keep save actions tappable; wrap only on genuinely narrow phones. */
body.avf-shell-mobile #avatarDownloadWrap > * {
  min-height: 44px !important;
}

@media (max-width: 380px) {
  body.avf-shell-mobile #avatarDownloadWrap {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
    width: 100% !important;
  }

  body.avf-shell-mobile #avatarDownloadWrap > * {
    min-width: 0;
    width: 100% !important;
  }

  body.avf-shell-mobile #avatarSaveBtn {
    grid-column: 1 / -1;
  }
}

/* Assets: contain the decorative hero glow inside narrow screens. */
body.avf-shell-mobile #avfmcHero::after {
  right: 0;
  top: -64px;
  width: 160px;
  height: 160px;
}

/* Script: enlarge only primary editing controls on mobile. */
body.avf-shell-mobile.avf-page-script .zoom-btn,
body.avf-shell-mobile.avf-page-script .expand-btn {
  min-width: 36px;
  width: 36px;
  min-height: 36px;
  height: 36px;
}

body.avf-shell-mobile.avf-page-script #wordCountSelect {
  min-height: 36px;
}

body.avf-shell-mobile.avf-page-script #rewriteCopyLibraryToggle,
body.avf-shell-mobile.avf-page-script #saveRewriteCopyBtn,
body.avf-shell-mobile.avf-page-script #useRewriteCopyBtn {
  min-height: 44px;
}

body.avf-shell-mobile.avf-page-script .avfp2opt {
  font-size: 12px !important;
}

/* Voice: improve mobile preview and consent touch targets. */
body.avf-shell-mobile.avf-page-voice .preset-play {
  min-width: 40px;
  width: 40px;
  min-height: 40px;
  height: 40px;
}

body.avf-shell-mobile.avf-page-voice .preset-lang {
  font-size: 12px !important;
  line-height: 1.35;
}

body.avf-shell-mobile.avf-page-voice #voiceCloneConsent {
  min-width: 18px;
  width: 18px !important;
  height: 18px !important;
  flex: 0 0 18px;
}

/* Avatar: clarify mobile selectors without changing the workflow. */
body.avf-shell-mobile.avf-page-avatar .avfp4dubpick,
body.avf-shell-mobile.avf-page-avatar .avfp4rowtoggle {
  min-height: 40px;
  padding-top: 6px;
  padding-bottom: 6px;
}

body.avf-shell-mobile.avf-page-avatar .avfp4tag {
  font-size: 12px !important;
}

body.avf-shell-mobile.avf-page-avatar #avfp4ConsentBox {
  min-width: 18px;
  width: 18px !important;
  height: 18px !important;
  flex: 0 0 18px;
}

/* Editor: strengthen mobile workspace and preview controls. */
body.avf-shell-mobile.avf-page-editor .editor-workspace-tab {
  min-height: 44px;
}

body.avf-shell-mobile.avf-page-editor .avfpb-overlay button {
  min-width: 40px !important;
  min-height: 40px !important;
  height: 40px !important;
}

body.avf-shell-mobile.avf-page-editor .ruisi-cover-entry__action {
  min-height: 40px;
  font-size: 12px !important;
}

body.avf-shell-mobile.avf-page-editor .ruisi-cover-entry small,
body.avf-shell-mobile.avf-page-editor .ruisi-cover-picker small {
  font-size: 12px !important;
}

/* Assets: make mobile return and sign-in actions easier to tap. */
body.avf-shell-mobile.avf-page-assets #avfmcX,
body.avf-shell-mobile.avf-page-assets .avfmc-top .avfmc-btn {
  min-height: 40px;
}

body.avf-shell-mobile.avf-page-assets .avfmc-top .avfmc-btn {
  font-size: 12px !important;
}

body.avf-shell-mobile.avf-page-assets #avfmcLogin {
  min-height: 44px;
}

/* Assets: replace the anonymous empty hero strip with one clear hint. */
body.avf-shell-mobile.avf-page-assets #avfmcHero:empty {
  min-height: 72px;
  justify-content: center;
}

body.avf-shell-mobile.avf-page-assets #avfmcHero:empty::before {
  content: "\767B\5F55\540E\67E5\770B\4EBA\7269\3001\4F5C\54C1\4E0E\7D20\6750";
  width: 100%;
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
}

/* Create: keep the lone purple primary action inside the shared Yaojin system. */
body.avf-page-create #panel-5-mixer .awb-actions #mxUploadAvatarBtn.awb-primary {
  background: linear-gradient(135deg, var(--accent-start), var(--accent-end)) !important;
  color: #fff !important;
  box-shadow: 0 10px 22px -14px rgba(var(--accent-rgb), 0.78);
}
