/* Shared mobile navigation. Keep the existing buttons and route handlers. */
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) {
  --cv-bottom-nav-height: 68px;
  --cv-bottom-nav-item: 54px;
  --cv-bottom-nav-pad: 6px;
  --cv-bottom-nav-radius: 25px;
  --cv-bottom-nav-item-radius: 19px;
  --cv-bottom-nav-gap: 0px;
  --cv-bottom-nav-extra: 35px;
  --cv-bottom-nav-clearance: calc(var(--cv-bottom-nav-height) + var(--cv-bottom-nav-gap) + var(--cv-bottom-nav-extra) + 16px + env(safe-area-inset-bottom, 0px));
  --cv-nav-safe-top: env(safe-area-inset-top, 0px);
}
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open):not(:has(#cvBottomNavWrap .cv-first-topup-bonus:not([hidden]))) {
  --cv-bottom-nav-extra: 0px;
}
html.cv-mobile-editorial:not(.cv-desktop-mode) body.cv-telegram-expanded:not(.welcome-open) {
  --cv-nav-safe-top: var(--cv-fullscreen-safe-top, 104px);
}
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .cv-first-topup-bonus {
  bottom: calc(var(--cv-bottom-nav-height) + var(--cv-bottom-nav-gap) + 8px + env(safe-area-inset-bottom, 0px)) !important;
  animation: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) .bottom-nav-wrap {
  padding: 0 max(14px, env(safe-area-inset-right, 0px)) calc(var(--cv-bottom-nav-gap) + env(safe-area-inset-bottom, 0px)) max(14px, env(safe-area-inset-left, 0px)) !important;
  background: linear-gradient(180deg, transparent, rgba(8, 9, 7, .88)) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav {
  --cv-dock-index: 0;
  position: relative !important;
  isolation: isolate;
  box-sizing: border-box !important;
  width: 100% !important;
  max-width: 460px !important;
  height: var(--cv-bottom-nav-height) !important;
  min-height: var(--cv-bottom-nav-height) !important;
  max-height: var(--cv-bottom-nav-height) !important;
  display: grid !important;
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  grid-template-rows: var(--cv-bottom-nav-item) !important;
  gap: 0 !important;
  padding: var(--cv-bottom-nav-pad) !important;
  border: 1px solid rgba(223, 207, 151, .22) !important;
  border-radius: var(--cv-bottom-nav-radius) !important;
  background: linear-gradient(160deg, rgba(36, 37, 30, .98), rgba(19, 21, 17, .97)) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .28), inset 0 1px rgba(255, 255, 255, .055) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  overflow: hidden !important;
  animation: none !important;
}

html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav::before {
  content: "" !important;
  display: block !important;
  position: absolute !important;
  inset: var(--cv-bottom-nav-pad) auto auto var(--cv-bottom-nav-pad) !important;
  width: calc((100% - var(--cv-bottom-nav-pad) * 2) / 3) !important;
  height: var(--cv-bottom-nav-item) !important;
  border: 0 !important;
  border-radius: var(--cv-bottom-nav-item-radius) !important;
  background: linear-gradient(125deg, #f3e5b5 0%, #dfc477 65%, #d7b65f 100%) !important;
  box-shadow: inset 0 1px 0 #fff4d6, 0 3px 10px #0002 !important;
  transform: translateX(calc(var(--cv-dock-index) * 100%)) !important;
  opacity: 0;
  filter: none !important;
  pointer-events: none !important;
  z-index: 0 !important;
  animation: none !important;
  transition: transform 240ms cubic-bezier(.22, .75, .25, 1), opacity 120ms ease !important;
}

html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav:has(:is(#allModelsNav, #aiStudioNav, #balanceNav).active)::before {
  opacity: 1;
}
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav:has(#aiStudioNav.active) { --cv-dock-index: 1; }
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav:has(#balanceNav.active) { --cv-dock-index: 2; }

html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav) {
  box-sizing: border-box !important;
  position: relative !important;
  z-index: 1 !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  height: var(--cv-bottom-nav-item) !important;
  min-height: var(--cv-bottom-nav-item) !important;
  max-height: var(--cv-bottom-nav-item) !important;
  min-width: 0 !important;
  gap: 5px !important;
  margin: 0 !important;
  padding: 5px 3px !important;
  border: 0 !important;
  border-radius: var(--cv-bottom-nav-item-radius) !important;
  background: transparent !important;
  box-shadow: none !important;
  color: #a8aaa0 !important;
  transform: none !important;
  filter: none !important;
  transition: color 160ms ease !important;
  animation: none !important;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav).active {
  color: #272718 !important;
}
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav):focus-visible {
  outline: 2px solid #fff2c7 !important;
  outline-offset: -3px !important;
}

html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav) .cv-nav-icon,
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav) svg {
  width: 22px !important;
  height: 22px !important;
  margin: 0 !important;
  color: inherit !important;
  stroke: currentColor !important;
  stroke-width: 1.65 !important;
  fill: none !important;
  filter: none !important;
  transform: none !important;
}

html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav) .cv-nav-label {
  display: block !important;
  margin: 0 !important;
  color: inherit !important;
  font-family: inherit !important;
  font-size: 10.5px !important;
  font-weight: 650 !important;
  line-height: 1.15 !important;
  letter-spacing: -.015em !important;
  text-transform: none !important;
  white-space: nowrap !important;
}

html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav::after,
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav)::before,
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav)::after {
  display: none !important;
}

/* Reserve actual dock height in each of the three independently scrolling pages. */
html.cv-mobile-editorial:not(.cv-desktop-mode) body.cv-all-models-open:not(.welcome-open):not(.cv-model-settings-open) .app,
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvAiStudioScreen.cv-ms-catalogue,
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) :is(#balanceScreen, #generationListScreen, #myCommunityScreen) > .cv-cabinet-screen {
  padding-bottom: var(--cv-bottom-nav-clearance) !important;
}
html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) :is(#cvAiStudioScreen, #balanceScreen, #generationListScreen, #myCommunityScreen) {
  scroll-padding-bottom: var(--cv-bottom-nav-clearance);
}

@media (max-height: 600px) {
  html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) {
    --cv-bottom-nav-height: 60px;
    --cv-bottom-nav-item: 48px;
    --cv-bottom-nav-pad: 5px;
    --cv-bottom-nav-radius: 22px;
    --cv-bottom-nav-item-radius: 16px;
    --cv-bottom-nav-gap: 0px;
  }
  html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav) {
    gap: 3px !important;
    padding-block: 3px !important;
  }
  /* The studio section switcher must fit between Telegram controls and the dock. */
  html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvAiStudioScreen .cv-ms-jump {
    top: calc((100vh + var(--cv-nav-safe-top) - var(--cv-bottom-nav-clearance)) / 2);
    top: calc((100dvh + var(--cv-nav-safe-top) - var(--cv-bottom-nav-clearance)) / 2);
    max-height: max(44px, calc(100vh - var(--cv-nav-safe-top) - var(--cv-bottom-nav-clearance) - 24px));
    max-height: max(44px, calc(100dvh - var(--cv-nav-safe-top) - var(--cv-bottom-nav-clearance) - 24px));
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    grid-auto-rows: minmax(44px, max-content);
  }
}
@media (max-height: 420px) {
  html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) {
    --cv-bottom-nav-height: 54px;
    --cv-bottom-nav-item: 44px;
    --cv-bottom-nav-pad: 4px;
    --cv-bottom-nav-radius: 20px;
    --cv-bottom-nav-item-radius: 14px;
    --cv-bottom-nav-gap: 0px;
  }
  html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav) :is(.cv-nav-icon, svg) {
    width: 20px !important;
    height: 20px !important;
  }
}

/* Older webviews still show a selected page, without the sliding highlight. */
@supports not selector(:has(*)) {
  html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav :is(#allModelsNav, #aiStudioNav, #balanceNav).active {
    background: #e4cc8a !important;
  }
}

/* Reuse the balance card's entrance, not the disabled cabinet-panel animation.
   Animate content only, never fixed screen roots.
   Active-route selectors cancel the effect as soon as the user switches away. */
@media (prefers-reduced-motion: no-preference) {
  html.cv-mobile-editorial:not(.cv-desktop-mode) body.cv-all-models-open:not(.welcome-open):not(.cv-model-settings-open):has(#allModelsNav.active) :is(#cvAllModelsHub, #cvMobileInspiration, #taskGrid),
  html.cv-mobile-editorial:not(.cv-desktop-mode) body.cv-ai-studio-open:not(.welcome-open):has(#aiStudioNav.active) #cvAiStudioScreen.active > .cv-ms-shell > :is(.cv-ms-heading, .cv-studio-shortcuts, .cv-ms-section) {
    animation: cvBalanceEnter 420ms cubic-bezier(.2, .8, .2, 1) 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav::before,
  html.cv-mobile-editorial:not(.cv-desktop-mode) body:not(.welcome-open) #cvBottomNavWrap .bottom-nav .nav-btn {
    transition: none !important;
  }
}
