/* Phone layouts shared by the public site, cabinet and Mini App. /docs is independent. */
@media (max-width: 760px) {
  html:has(body.mobile-site), html:has(body.subscription-page) {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  body.mobile-site, body.subscription-page { min-height: 100svh; }
  .mobile-site :is(button, a, input, select, textarea),
  .subscription-page :is(button, a, input, select, textarea) { touch-action: manipulation; }
  .mobile-site :is(input, select, textarea),
  .subscription-page :is(input, select, textarea) { font-size: 16px !important; }
  .mobile-site :is(button, .button, .btn), .subscription-page .sp-button {
    max-width: 100%;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .mobile-site .vectra-acquisition-settings { min-height: 44px; min-width: 44px; padding: 8px 10px; white-space: nowrap; overflow-wrap: normal; flex: 0 0 auto; }
  :is(.mobile-cabinet, .mobile-app) #vectra-acquisition-choice {
    bottom: calc(88px + env(safe-area-inset-bottom));
    max-height: calc(100dvh - 112px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    overflow-y: auto;
  }

  /* Landing: a readable first screen, full-width actions and balanced sections. */
  .mobile-landing .wrap {
    width: calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }
  .mobile-landing .site-header--landing .wrap { width: calc(100% - 32px); }
  .mobile-landing .hero-bento-card { border-radius: 20px; }
  .mobile-landing .hero-bento-content { padding: 24px 20px 0; min-width: 0; }
  .mobile-landing .hero-bento-title {
    font-size: clamp(30px, 7.8vw, 46px);
    line-height: 1.12;
    overflow-wrap: normal;
    text-wrap: balance;
  }
  .mobile-landing .hero-bento-desc { font-size: 15px; line-height: 1.6; }
  .mobile-landing .hero-bento-actions { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; max-width: none; gap: 10px; }
  .mobile-landing .hero-bento-actions .btn { width: 100%; max-width: none; min-height: 53px; padding: 12px 16px; font-size: 14px; line-height: 1.4; }
  .mobile-landing .btn-primary, .mobile-download .button-download {
    background: #24C4DC;
    color: #051721;
    font-weight: 800;
    box-shadow: none;
  }
  .mobile-landing .hero-bento-visual { min-height: 0; padding: 20px; }
  .mobile-landing .hero-art-wrapper { max-width: 200px; margin-inline: auto; }
  .mobile-landing :is(.summer-benefits-title, .section-title) {
    font-size: clamp(27px, 7.4vw, 38px);
    line-height: 1.15;
    overflow-wrap: normal;
    text-wrap: balance;
  }
  .mobile-landing :is(.config-card, .summary-card) { min-width: 0; padding: 22px 18px; }
  .mobile-landing .period-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .mobile-landing .device-select-grid { gap: 8px; }
  .mobile-landing .device-tile { padding-inline: 6px; }
  .mobile-landing .summary-row { align-items: baseline; }
  .mobile-landing .summary-row-val { max-width: 65%; text-align: right; }
  .mobile-landing .footer-links { gap: 0 16px; }
  .mobile-landing .footer-links a { display: inline-flex; align-items: center; min-height: 44px; }


  /* Keep the Android preview fully inside its card, including its rotation. */
  .mobile-landing .app-promo-card {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
    padding-bottom: 24px;
  }
  .mobile-landing .app-promo-visual {
    min-height: 0;
    padding: 12px 8px;
  }
  .mobile-landing .app-promo-phone {
    height: clamp(240px, 68vw, 280px);
    flex-shrink: 0;
    transform: rotate(2deg);
  }

  /* Download: prevent long headings from being clipped inside the hero card. */
  .mobile-download .wrap {
    width: calc(100% - 32px - env(safe-area-inset-left) - env(safe-area-inset-right));
  }
  .mobile-download .topbar-inner { flex-wrap: nowrap; gap: 8px; padding-block: 10px; }
  .mobile-download .topbar-inner .brand { flex: 0 1 128px; min-width: 80px; }
  .mobile-download .topbar-actions { margin-left: auto; min-width: 0; flex: 0 0 auto; gap: 6px; }
  .mobile-download .topbar-actions > .button { min-height: 44px; font-size: 12px; padding: 10px 8px; }
  .mobile-download .hero { padding: 24px 20px 18px; }
  .mobile-download .hero h1 {
    font-size: clamp(32px, 8.8vw, 54px);
    line-height: 1.08;
    letter-spacing: -.045em;
    overflow-wrap: normal;
    text-wrap: balance;
  }
  .mobile-download .hero h1 .hero-wordmark { width: min(100%, 320px); }
  .mobile-download .hero-description { font-size: 15px; line-height: 1.6; }
  .mobile-download .hero-art { min-height: 0; padding-block: 22px 4px; }
  .mobile-download .phone-hero { width: min(62vw, 250px); max-width: 100%; }
  .mobile-download .section { padding-top: 52px; }
  .mobile-download .section-heading h2,
  .mobile-download .how-to .section-heading h2,
  .mobile-download .final-cta h2 { font-size: clamp(28px, 8vw, 40px); line-height: 1.15; text-wrap: balance; }
  .mobile-download .footer-inner > div { flex-wrap: wrap; gap: 0 16px; }
  .mobile-download .footer-inner > div a { display: inline-flex; align-items: center; min-height: 44px; }
  .mobile-download .footer-app-link { min-width: 44px; min-height: 44px; }

  /* Browser login: short screens and an on-screen keyboard must still scroll. */
  body.mobile-login { padding: max(24px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom)) !important; }
  .mobile-login .login-container { width: 100%; min-width: 0; margin-block: auto; }
  .mobile-login .login-card { padding: 20px; border-radius: 20px; }
  .mobile-login :is(.tab-btn, .submit-btn) { min-height: 48px; height: auto; line-height: 1.4; }
  .mobile-login .brand-header { margin-bottom: 24px !important; }
  .mobile-login .footer-nav a { display: inline-flex; align-items: center; min-height: 44px; }

  /* Cabinet: keep every value readable and every device action touch-sized. */
  .mobile-cabinet #cabinet-shell .topbar {
    min-height: 56px;
    padding-inline: max(16px, env(safe-area-inset-left));
    padding-top: env(safe-area-inset-top);
  }
  .mobile-cabinet #cabinet-shell .topbar .wordmark-image { flex: 0 0 auto; width: clamp(116px, 34vw, 148px) !important; height: clamp(21px, 5.9vw, 26px) !important; }
  .mobile-cabinet #cabinet-shell .account-menu-trigger { min-height: 44px; }
  .mobile-cabinet #cabinet-shell .main-content {
    padding: 14px max(16px, env(safe-area-inset-right)) calc(108px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)) !important;
  }
  .mobile-cabinet #cabinet-shell .side-nav .nav-item { min-height: 54px; font-size: 10px; line-height: 1.2; }
  .mobile-cabinet #cabinet-shell .side-nav .nav-icon,
  .mobile-cabinet #cabinet-shell .side-nav .nav-icon svg { width: 20px; height: 20px; }
  .mobile-cabinet #cabinet-shell #main-content .portal-view-head h1 { font-size: 28px; line-height: 1.2; }
  .mobile-cabinet #cabinet-shell #main-content .dash-mini-cards {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 0 !important;
  }
  .mobile-cabinet #cabinet-shell #main-content .dash-mini-card {
    display: flex !important;
    min-width: 0 !important;
    gap: 12px !important;
    padding: 6px 0 !important;
    border: 0 !important;
  }
  .mobile-cabinet #cabinet-shell #main-content .dash-mini-card + .dash-mini-card { border-top: 1px solid var(--vectra-card-border) !important; }
  .mobile-cabinet #cabinet-shell #main-content .dash-mini-copy { min-width: 0; flex: 1; display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 8px; }
  .mobile-cabinet #cabinet-shell #main-content :is(.dash-mini-label, .dash-mini-value) {
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: normal !important;
    overflow-wrap: anywhere;
  }
  .mobile-cabinet #cabinet-shell #main-content .dash-mini-label { font-size: 12px !important; }
  .mobile-cabinet #cabinet-shell #main-content .dash-mini-value { font-size: 16px !important; }
  .mobile-cabinet #cabinet-shell #main-content .portal-device-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 8px !important; padding: 12px !important; }
  .mobile-cabinet #cabinet-shell #main-content .portal-device-main { min-width: 0; }
  .mobile-cabinet #cabinet-shell #main-content .portal-device-copy b {
    white-space: normal !important;
    overflow: visible !important;
    overflow-wrap: anywhere;
    line-height: 1.45 !important;
  }
  .mobile-cabinet #cabinet-shell #main-content .portal-device-actions { margin-left: 0; gap: 6px !important; }
  .mobile-cabinet #cabinet-shell #main-content :is(.portal-device-block, .portal-device-delete, .portal-blocked-row > button) {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
    flex: 0 0 44px !important;
  }
  .mobile-cabinet #cabinet-shell #main-content :is(#copy-master-btn, #toggle-qr-btn, #rotate-master-btn, #incy-connect-btn, .payment-history-more) {
    min-height: 44px !important;
    min-width: 44px;
    line-height: 1.4;
  }
  .mobile-cabinet #cabinet-shell #main-content .master-link-actions .button { min-height: 48px !important; font-size: 13px !important; }

  .mobile-cabinet #view-devices #master-sub-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 8px;
  }
  .mobile-cabinet #view-devices #master-sub-row > span:first-child { display: none; }
  .mobile-cabinet #view-devices #master-sub-row #copy-master-btn { width: auto; padding-inline: 10px; }
  .mobile-cabinet #view-devices #master-sub-row:focus-within { border-color: var(--vectra-primary); }
  .mobile-cabinet #view-devices #master-sub-input:focus-visible { outline: 0; box-shadow: none; }
  .mobile-cabinet #view-devices .master-link-actions { grid-template-columns: repeat(auto-fit, minmax(min(100%, 125px), 1fr)); }
  .mobile-cabinet #view-home .home-triad-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mobile-cabinet #view-home .home-triad-card { min-width: 0; gap: 7px; padding: 8px; }
  .mobile-cabinet #view-home .home-triad-art { width: 28px; height: 32px; flex-basis: 28px; }
  .mobile-cabinet #view-home .home-triad-foot { min-width: 0; }
  .mobile-cabinet #view-home .home-triad-arrow { display: none; }
  .mobile-cabinet #auth-screen .auth-layout { width: calc(100% - 32px); padding-block: 24px; min-height: 0; }
  .mobile-cabinet #auth-screen .auth-card { padding: 26px 20px; border-radius: 20px; }
  .mobile-cabinet #auth-screen .auth-card h2 { font-size: clamp(26px, 7vw, 32px); line-height: 1.2; }
  .mobile-cabinet #auth-screen .auth-card-copy { overflow-wrap: anywhere; }
  .mobile-cabinet #auth-screen :is(.code-back-button, #resend-code) { min-height: 44px; min-width: 44px; }
  .mobile-cabinet #auth-screen .auth-footer { padding-bottom: max(24px, env(safe-area-inset-bottom)); }

  /* Dialog content scrolls between the header and the always reachable footer. */
  .mobile-cabinet #portal-modal-root .portal-tariff-dialog {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-height: calc(100dvh - env(safe-area-inset-top)) !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }
  .mobile-cabinet #portal-modal-root .portal-tariff-dialog-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .mobile-cabinet #portal-modal-root :is(.portal-tariff-dialog-head, .portal-tariff-dialog-footer) { flex: 0 0 auto; }
  .mobile-cabinet #portal-modal-root .portal-tariff-dialog-footer { padding-bottom: max(16px, env(safe-area-inset-bottom)) !important; }
  .mobile-cabinet #portal-modal-root :is(.portal-tariff-close, .portal-tariff-step-back, .portal-history-close),
  .mobile-cabinet #dialog-root .dialog-close { min-width: 44px; min-height: 44px; }
  .mobile-cabinet #portal-modal-root .portal-history-toolbar button { min-height: 44px; }
  .mobile-cabinet #portal-modal-root .portal-history-search input { min-height: 44px; }
  .mobile-cabinet #portal-modal-root :is(.portal-promo-row input, .portal-promo-row button, #promo-code),
  .mobile-cabinet #portal-modal-root #promo-code + button { min-height: 44px !important; }
  .mobile-cabinet #vectra-onboarding-root .ob-content { min-height: 0; overscroll-behavior: contain; }
  .mobile-cabinet #vectra-onboarding-root .ob-subscription-field input { min-height: 44px; }
  .mobile-cabinet #vectra-onboarding-root .ob-subscription-field:focus-within { border-color: #24C4DC; box-shadow: 0 0 0 3px rgba(36,196,220,.13); }

  /* Mini App retains its own navigation and Telegram viewport management. */
  .mobile-app #app .app-brand-header { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: center; }
  .mobile-app #app .app-brand-header .brand-mark { grid-column: 1; grid-row: 1; width: 148px; max-width: 100%; margin: 0; }
  .mobile-app #app .app-brand-user { grid-column: 2; grid-row: 1; min-width: 0; max-width: 100%; }
  .mobile-app #app .app-brand-utility { display: none; }
  .mobile-app #web-logout-btn:not(.hidden) { display: inline-flex; width: auto; min-height: 44px; min-width: 44px; align-items: center; align-self: flex-end; gap: 6px; white-space: nowrap; overflow-wrap: normal; }
  .mobile-app #view-devices :is(#copy-master-btn, #toggle-qr-btn, #rotate-master-btn),
  .mobile-app #payment-history-open { min-height: 44px !important; min-width: 44px; }
  .mobile-app #devices-list > .card:has([data-remove]) { flex-wrap: wrap; gap: 12px; }
  .mobile-app #devices-list > .card:has([data-remove]) > div:first-child { flex: 1 1 100%; }
  .mobile-app #devices-list > .card:has([data-remove]) > div:last-child { margin-left: auto; gap: 12px !important; }
  .mobile-app #devices-list > .card:has([data-remove]) p:first-child { white-space: normal !important; overflow-wrap: anywhere; line-height: 1.45; }
  .mobile-app #app #view-devices #devices-list :is([data-remove], [data-block-remove]) { width: 44px !important; height: 44px !important; min-width: 44px; min-height: 44px; }
  .mobile-app #view-topup .dash-mini-cards { grid-template-columns: minmax(0, 1fr) !important; gap: 0 !important; }
  .mobile-app #view-topup .dash-mini-card { padding: 12px 0 !important; border: 0 !important; gap: 12px !important; }
  .mobile-app #view-topup .dash-mini-card + .dash-mini-card { border-top: 1px solid rgba(67,135,216,.28) !important; }
  .mobile-app #view-topup :is(.dash-mini-label, .dash-mini-value) { white-space: normal !important; overflow: visible !important; overflow-wrap: anywhere; }
  .mobile-app #view-topup .dash-mini-label { font-size: 12px !important; }
  .mobile-app #view-topup .dash-mini-value { font-size: 16px !important; }
  .mobile-app .real-tariff-dialog { max-height: calc(100dvh - env(safe-area-inset-top)); }
  .mobile-app .real-tariff-dialog-scroll { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
  .mobile-app :is(.real-tariff-close, .real-tariff-step-back) { min-width: 44px; min-height: 44px; }
  .mobile-app #tariff-purchase-sheet .real-tariff-dialog-footer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 4px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .mobile-app #tariff-purchase-sheet .real-tariff-dialog-footer .vectra-acquisition-settings { justify-self: end; }
  .mobile-app #tariff-purchase-sheet .real-tariff-dialog-footer #pay-btn {
    width: 100%; height: auto !important; min-height: 53px !important; gap: 12px; padding: 12px 16px !important;
    background: #24C4DC !important; color: #051721 !important; box-shadow: none !important;
  }
  .mobile-app #tariff-purchase-sheet #pay-btn .pay-btn-label { font-size: 14px !important; line-height: 1.4; min-width: 0; text-align: left; }
  .mobile-app #tariff-purchase-sheet #pay-btn > span:last-child { flex: 0 0 auto; flex-direction: column; align-items: flex-end; gap: 2px !important; white-space: nowrap; }
  .mobile-app #tariff-purchase-sheet #real-tariff-step-two #promo-box :is(input, button) { min-height: 44px !important; }
  .mobile-app :is(.modal-card, .payment-history-panel) { max-width: 100%; max-height: calc(100dvh - 24px); overflow-y: auto; }
  .mobile-app :is(.payment-history-modal-close, .modal-close) { min-width: 44px; min-height: 44px; }

  .mobile-ideas .header-inner { padding-inline: max(16px, env(safe-area-inset-left)); }
  .mobile-ideas .main { padding-inline: max(16px, env(safe-area-inset-left)); }
  .mobile-ideas .field input, .mobile-ideas .field textarea { min-height: 48px; }
  .mobile-ideas dialog { max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  .mobile-ideas .hero-note { font-size: 12px; line-height: 1.5; }
  .mobile-ideas .idea-meta { flex-wrap: wrap; gap: 6px 12px; }
  .mobile-ideas .site-link { justify-content: center; }

  body.mobile-happ { min-height: 100svh; padding: max(20px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
  .mobile-happ .card { margin-block: auto; padding: 24px 20px; }
  .mobile-happ :is(p, .err, .ok) { overflow-wrap: anywhere; }
  .subscription-page .sp-header-inner { padding-block: 8px; }
  .subscription-page .sp-header :is(.sp-header-buy, .sp-account) { min-height: 44px; }
  .subscription-page .sp-account { width: 44px; flex: 0 0 44px; }
  .subscription-page .sp-layout > *, .subscription-page .sp-step { min-width: 0; }
  .subscription-page :is(.sp-copy, .sp-help p, .sp-intro p) { overflow-wrap: anywhere; }
}

@media (max-width: 380px) {
  .mobile-download .topbar-inner .brand { width: 112px; }
  .mobile-download .screen-grid { grid-template-columns: minmax(0, 1fr); }
  .mobile-download .screen-card { max-width: 280px; width: 100%; margin-inline: auto; }
  .mobile-cabinet #cabinet-shell .side-nav .nav-item { font-size: 9px; }
  .mobile-cabinet #portal-modal-root .portal-tariff-dialog-footer { flex-wrap: wrap; gap: 12px; }
  .mobile-cabinet #portal-modal-root .portal-plan-actions { width: 100%; }
  .mobile-cabinet #vectra-onboarding-root .ob-apps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-height: 500px) and (max-width: 960px) {
  html:has(body.mobile-site) { scroll-padding-block: 72px calc(96px + env(safe-area-inset-bottom)); }
  .mobile-app #app .views { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
  body.mobile-login, body.mobile-happ { justify-content: flex-start !important; padding-top: max(16px, env(safe-area-inset-top)) !important; }
  .mobile-cabinet #portal-modal-root .portal-tariff-dialog-head { padding-block: 12px !important; }
  .mobile-cabinet #portal-modal-root .portal-tariff-dialog-footer { padding-top: 10px !important; }
}
