/* Nerkhche shared mobile reliability layer — 2026-07-24 */

body.ndl-auth-required-page .ndl-topbar__actions {
  display: none !important;
}

.ndl-auth-gate {
  width: min(100%, 560px);
  margin-inline: auto;
  padding: 34px 28px;
  text-align: center;
}

.ndl-auth-gate__logo {
  width: 92px;
  height: 92px;
  margin: 0 auto 16px;
  object-fit: contain;
}

.ndl-auth-gate h2 {
  margin: 0;
  font-size: 24px;
}

.ndl-auth-gate p {
  margin: 8px auto 22px;
  color: var(--ndl-text-3);
  font-size: 13px;
  line-height: 1.9;
}

.ndl-auth-gate__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

@media (max-width: 960px) {
  html,
  body {
    max-width: 100%;
    overflow-x: clip;
  }

  /*
   * .ndl-app used to isolate the sidebar below its sibling backdrop.
   * Removing that stacking context keeps the backdrop over the page but
   * behind the open drawer, so every menu control remains tappable.
   */
  .ndl-app {
    isolation: auto;
  }

  .ndl-sidebar {
    z-index: var(--ndl-z-sidebar, 30) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .ndl-sidebar-backdrop {
    z-index: 29;
  }

  .ndl-mobile-header [data-ndl-nav-toggle],
  .ndl-mobile-theme,
  .ndl-auth-simple a,
  .ndl-auth-simple button,
  .ndl-theme-control button,
  .ndl-nav__item {
    min-height: 44px;
  }

  .ndl-mobile-header [data-ndl-nav-toggle],
  .ndl-mobile-theme,
  .ndl-theme-control button {
    min-width: 44px;
  }
}

@media (max-width: 700px) {
  /*
   * Mobile uses portrait artwork derived from the approved theme backgrounds.
   * It keeps both ornamental edges visible instead of magnifying the quiet
   * desktop center to fill a tall phone screen.
   */
  html[data-theme="dark"] body {
    background-color: #061115 !important;
    background-image:
      linear-gradient(rgba(3, 13, 20, .18), rgba(3, 13, 20, .34)),
      url("../assets/backgrounds/nerkhche-dark-mobile-20260724.webp") !important;
    background-size: cover, cover !important;
    background-position: center top, center top !important;
    background-attachment: fixed, fixed !important;
    background-repeat: no-repeat, no-repeat !important;
  }

  html[data-theme="light"] body {
    background-color: #eee9df !important;
    background-image:
      url("../assets/backgrounds/nerkhche-light-mobile-20260724.webp") !important;
    background-size: cover !important;
    background-position: center top !important;
    background-attachment: fixed !important;
    background-repeat: no-repeat !important;
  }

  html[data-theme="light"] body::after {
    background:
      radial-gradient(
        ellipse at center,
        rgba(249, 247, 241, .52) 0%,
        rgba(249, 247, 241, .38) 50%,
        rgba(249, 247, 241, .12) 100%
      ) !important;
  }

  .ndl-main,
  .ndl-main__inner,
  .ndl-page-root,
  .ndl-page-root > *,
  .ndl-toolbar,
  .ndl-section-head,
  .ndl-grid,
  .ndl-card {
    min-width: 0;
    max-width: 100%;
  }

  .ndl-main__inner,
  .ndl-page-root {
    width: 100%;
  }

  .ndl-btn,
  .ndl-mini-btn,
  .ndl-icon-action,
  .ndl-city-remove,
  [data-city-remove],
  [data-tsetmc-remove],
  [data-action="news-more"] {
    min-height: 44px;
  }

  .ndl-icon-action,
  .ndl-city-remove,
  [data-city-remove],
  [data-tsetmc-remove] {
    min-width: 44px;
  }

  .ndl-check,
  .ndl-visibility-toggle,
  .ndl-preference-list > label,
  .ndl-customize__row label,
  body[data-page="widgets"] label:has(input[type="checkbox"]) {
    min-height: 44px !important;
  }

  .ndl-visibility-toggle {
    min-width: 44px !important;
  }

  body[data-page="widgets"] input[type="checkbox"],
  body[data-page="profile"] input[type="checkbox"] {
    width: 18px;
    height: 18px;
  }

  /* Prices: prevent min-content sizing from widening the page at 375–390px. */
  body[data-page="prices"] .ndl-toolbar--prices,
  body[data-page="prices"] .ndl-price-grid,
  body[data-page="prices"] .ndl-section-head--market {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    margin-inline: 0 !important;
  }

  body[data-page="prices"] .ndl-toolbar--prices {
    align-items: stretch !important;
    overflow: hidden !important;
  }

  body[data-page="prices"] .ndl-toolbar--prices .ndl-tabs {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scrollbar-width: thin;
    padding-bottom: 4px;
  }

  body[data-page="prices"] .ndl-toolbar--prices .ndl-tab {
    flex: 0 0 auto;
    min-height: 44px;
  }

  body[data-page="prices"] .ndl-toolbar--prices .ndl-search,
  body[data-page="prices"] .ndl-toolbar--prices .ndl-crypto-manager,
  body[data-page="prices"] .ndl-toolbar--prices .ndl-tsetmc-search-host {
    flex: 1 1 100%;
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body[data-page="prices"] .ndl-toolbar--prices input {
    width: 100% !important;
    min-width: 0 !important;
    min-height: 44px;
  }

  /*
   * Search surfaces must never rise above the open navigation drawer.
   * The previous desktop z-index (200) was higher than the drawer (30).
   */
  body[data-page="prices"] .ndl-crypto-manager {
    z-index: 1 !important;
  }

  body.ndl-nav-open .ndl-crypto-manager,
  body.ndl-nav-open .ndl-tsetmc-search-host {
    z-index: 0 !important;
  }

  body.ndl-nav-open .ndl-tsetmc-results {
    visibility: hidden !important;
    pointer-events: none !important;
  }

  body[data-page="prices"] .ndl-price-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body[data-page="prices"] .ndl-price-grid > *,
  body[data-page="prices"] .ndl-market-card {
    min-width: 0 !important;
    max-width: 100% !important;
  }

  body[data-page="prices"] .ndl-live-status {
    min-width: 0;
    max-width: 100%;
    flex-wrap: wrap;
  }

  /* Stocks: keep the result panel contextual and easy to dismiss. */
  body[data-page="stocks"] .ndl-tsetmc-results {
    top: 72px;
    right: 12px;
    left: 12px;
    width: auto;
    max-height: min(46dvh, 360px);
    padding-top: 6px;
  }

  .ndl-tsetmc-results__head {
    position: sticky;
    top: -6px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 44px;
    padding: 6px 8px;
    background: var(--ndl-surface, #102126);
    border-bottom: 1px solid var(--ndl-border);
  }

  .ndl-tsetmc-results__head span {
    color: var(--ndl-text-3);
    font-size: 12px;
  }

  .ndl-tsetmc-results__close {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--ndl-border);
    border-radius: 12px;
    background: transparent;
    color: inherit;
    font-size: 22px;
  }

  .ndl-tsetmc-result {
    min-height: 52px;
  }

  /* Portfolio and Telegram controls stay usable when the keyboard is open. */
  body[data-page="portfolio"] .pf-modal-overlay {
    padding: 10px;
    align-items: flex-end;
  }

  body[data-page="portfolio"] .pf-modal {
    max-height: calc(100dvh - 20px);
    border-radius: 18px 18px 10px 10px;
  }

  body[data-page="portfolio"] .pf-modal-close,
  body[data-page="portfolio"] .pf-cat-tab,
  body[data-page="portfolio"] .pf-toggle-btn,
  body[data-page="portfolio"] .pf-range-btn,
  body[data-page="portfolio"] .btn-login {
    min-height: 44px;
  }

  body[data-page="telegram"] .ndl-connection,
  body[data-page="telegram"] .ndl-telegram-form,
  body[data-page="telegram"] .ndl-schedule-form {
    align-items: stretch;
  }

  body[data-page="telegram"] .ndl-connection {
    flex-direction: column;
  }

  body[data-page="telegram"] button,
  body[data-page="profile"] button,
  body[data-page="widgets"] button {
    min-height: 44px;
  }

  /*
   * Compact phone composition.
   * Desktop cards were previously stacked at full desktop height, which made
   * the price list and dashboard feel scaled down instead of mobile-native.
   */
  .ndl-page-root {
    gap: 12px !important;
  }

  .ndl-topbar {
    gap: 8px !important;
    margin-bottom: 10px !important;
  }

  .ndl-widget-grid {
    gap: 9px !important;
  }

  .ndl-widget-card {
    border-radius: 18px !important;
  }

  .ndl-widget-card__head {
    min-height: 54px !important;
    padding: 9px 11px !important;
  }

  .ndl-widget-card__body {
    padding: 10px 11px !important;
  }

  .ndl-widget-card__icon {
    width: 36px !important;
    height: 36px !important;
    border-radius: 12px !important;
  }

  .ndl-widget-card__icon img {
    width: 26px !important;
    height: 26px !important;
  }

  body[data-page="dashboard"] .ndl-dashboard-workspace {
    margin-top: 22px !important;
  }

  body[data-page="dashboard"] .ndl-hero--v15 {
    padding: 14px !important;
    gap: 10px !important;
    border-radius: 18px !important;
  }

  body[data-page="dashboard"] .ndl-hero--v15 h2 {
    margin-block: 6px !important;
    font-size: 22px !important;
    line-height: 1.5 !important;
  }

  body[data-page="dashboard"] .ndl-hero--v15 p {
    font-size: 10px !important;
    line-height: 1.8 !important;
  }

  body[data-page="dashboard"] .ndl-hero__actions {
    margin-top: 11px !important;
  }

  body[data-page="dashboard"] .ndl-hero-quotes {
    gap: 6px !important;
  }

  body[data-page="dashboard"] .ndl-hero-quote {
    min-height: 88px !important;
    padding: 9px !important;
    gap: 5px !important;
    border-radius: 14px !important;
  }

  body[data-page="dashboard"] .ndl-hero-quote__numbers b {
    font-size: 13px !important;
    white-space: nowrap !important;
  }

  body[data-page="dashboard"] .ndl-price-widget {
    gap: 10px !important;
  }

  body[data-page="dashboard"] .ndl-price-widget__rows {
    gap: 4px !important;
  }

  body[data-page="dashboard"] .ndl-mini-section-title {
    margin-bottom: 5px !important;
  }

  body[data-page="dashboard"] .ndl-price-widget__row {
    min-height: 52px !important;
    padding: 7px 8px !important;
    grid-template-columns: 30px minmax(0, 1fr) minmax(88px, max-content) !important;
    column-gap: 6px !important;
    border-radius: 10px !important;
  }

  body[data-page="dashboard"] .ndl-price-widget__row .ndl-asset-icon {
    width: 30px !important;
    height: 30px !important;
  }

  body[data-page="dashboard"] .ndl-price-widget__row .ndl-asset-icon img.ndl-asset-icon__image--flag {
    width: 28px !important;
    height: 22px !important;
  }

  body[data-page="dashboard"] .ndl-price-widget__quote {
    min-width: 88px !important;
    gap: 2px !important;
  }

  body[data-page="dashboard"] .ndl-price-widget__value b {
    font-size: 11px !important;
  }

  body[data-page="dashboard"] .ndl-price-widget__identity span {
    display: none;
  }

  body[data-page="prices"] .ndl-price-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  body[data-page="prices"] .ndl-market-card {
    min-height: 136px !important;
    padding: 10px !important;
    gap: 7px !important;
    align-content: start !important;
    border-radius: 15px !important;
  }

  body[data-page="prices"] .ndl-market-card__top {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: auto auto !important;
    height: auto !important;
    gap: 4px !important;
  }

  body[data-page="prices"] .ndl-data-meta {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 4px !important;
    min-height: 20px !important;
  }

  body[data-page="prices"] .ndl-data-meta b {
    padding: 2px 5px !important;
    font-size: 8px !important;
  }

  body[data-page="prices"] .ndl-data-meta time {
    display: none !important;
  }

  body[data-page="prices"] .ndl-market-card__identity-copy strong {
    font-size: 11px !important;
  }

  body[data-page="prices"] .ndl-market-card__identity-copy span {
    font-size: 8px !important;
  }

  body[data-page="prices"] .ndl-market-card__value {
    height: auto !important;
    margin-top: 0 !important;
    gap: 4px !important;
  }

  body[data-page="prices"] .ndl-market-card__value b {
    font-size: clamp(14px, 4.2vw, 17px) !important;
    white-space: nowrap !important;
    overflow-wrap: normal !important;
  }

  body[data-page="prices"] .ndl-market-card__value span {
    margin: 0 !important;
    font-size: 8px !important;
  }

  body[data-page="prices"] .ndl-market-card__change {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    height: auto !important;
    min-height: 24px !important;
    padding-top: 5px !important;
    gap: 4px !important;
  }

  body[data-page="prices"] .ndl-market-card__change span {
    font-size: 8px !important;
    white-space: nowrap !important;
  }

  body[data-page="prices"] .ndl-market-card__change strong {
    font-size: 10px !important;
    white-space: nowrap !important;
  }

  body[data-page="stocks"] .ndl-summary-grid {
    gap: 7px !important;
  }

  body[data-page="stocks"] .ndl-summary-card {
    min-height: 94px !important;
    padding: 11px !important;
    border-radius: 14px !important;
  }

  body[data-page="stocks"] .ndl-summary-card strong {
    font-size: 16px !important;
  }

  body[data-page="news"] .ndl-news-feed {
    gap: 7px !important;
  }

  body[data-page="news"] .ndl-news-line {
    border-radius: 12px !important;
  }

  body[data-page="news"] .ndl-news-line__link {
    grid-template-columns: 24px minmax(0, 1fr) 20px !important;
    gap: 6px !important;
    padding: 9px 8px !important;
  }

  body[data-page="news"] .ndl-news-line__main strong {
    display: -webkit-box;
    overflow: hidden;
    font-size: 11.5px !important;
    line-height: 1.6 !important;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }

  .ndl-auth-gate {
    padding: 28px 20px;
  }

  .ndl-auth-gate__logo {
    width: 82px;
    height: 82px;
  }
}

@media (max-width: 390px) {
  .ndl-main {
    padding-inline: 10px;
  }

  .ndl-auth-gate__actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  body[data-page="telegram"] .ndl-bots-page {
    gap: 10px;
  }

  body[data-page="telegram"] .ndl-bot-tabs {
    gap: 6px;
    padding: 5px;
    border-radius: 16px;
  }

  body[data-page="telegram"] .ndl-bot-tab {
    min-height: 54px;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 12px;
  }

  body[data-page="telegram"] .ndl-bot-tab__mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
  }

  body[data-page="telegram"] .ndl-bot-tab strong {
    font-size: 11px;
  }

  body[data-page="telegram"] .ndl-connection {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  body[data-page="telegram"] .ndl-connection__actions,
  body[data-page="telegram"] .ndl-connection > .ndl-btn {
    width: 100%;
  }

  body[data-page="telegram"] .ndl-connection__actions .ndl-btn {
    flex: 1 1 130px;
  }

  body[data-page="telegram"] .ndl-link-code {
    align-items: stretch;
  }

  body[data-page="telegram"] .ndl-link-code .ndl-btn {
    width: 100%;
  }

  body[data-page="telegram"] .ndl-inline-form {
    grid-template-columns: minmax(0, 1fr);
  }

  body[data-page="telegram"] .ndl-bot-help {
    align-items: stretch;
    flex-direction: column;
  }

  body[data-page="telegram"] .ndl-bot-help .ndl-btn {
    width: 100%;
  }
}

@media (max-width: 340px) {
  body[data-page="prices"] .ndl-price-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  body[data-page="prices"] .ndl-market-card {
    min-height: 118px !important;
  }
}

@media (max-height: 560px) and (max-width: 960px) {
  .ndl-brand {
    min-height: 54px;
    margin-bottom: 8px;
    padding-bottom: 8px;
  }

  .ndl-brand__logo {
    width: 46px !important;
    height: 46px !important;
  }

  .ndl-sidebar-signature {
    display: none;
  }
}
