/* Адаптив: телефон / планшет. Грузится после страничных стилей. */

html { color-scheme: light only; -webkit-text-size-adjust: 100%; }
img, svg, video { max-width: 100%; height: auto; }
input, select, textarea, button { color-scheme: light; }

/* iOS: clip часто игнорируется → страница уезжает влево-вправо */
html, body {
  max-width: 100%;
  width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}
@supports (overflow: clip) {
  html, body { overflow-x: clip; }
}

@media (max-width: 860px) {
  html, body {
    overflow-x: hidden !important;
    max-width: 100% !important;
  }
  @supports (overflow: clip) {
    html, body { overflow-x: clip !important; }
  }
  .container,
  .header-inner,
  .hero-inner,
  .page-head,
  .map-card,
  .search-box,
  .listing-grid,
  .cat-grid,
  .origin-row {
    max-width: 100%;
    min-width: 0;
  }
  .container { padding-left: 14px; padding-right: 14px; }
  input, select, textarea, button { max-width: 100%; }
  .listing-card, .cat-card, .origin-btn { min-width: 0; }
  .page-head h1 { white-space: normal !important; }
  .footer-req-pop { white-space: normal !important; max-width: min(320px, calc(100vw - 28px)); }
  .cn-pay-methods { grid-template-columns: 1fr 1fr !important; }
  .item-side__price { font-size: 22px; overflow-wrap: anywhere; }
  .item-side__title { font-size: 17px; }
  .cab-tabs {
    overflow-x: auto;
    flex-wrap: nowrap !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
  }

  /* отрицательный margin выталкивает шапку за край экрана */
  .header-actions .btn-ghost:last-child { margin-right: 0 !important; }

  .map-card { overflow: hidden; }
  #dealMap { width: 100% !important; max-width: 100% !important; }
  .section-promo, .map-promo {
    white-space: normal !important;
    max-width: 100%;
    overflow-wrap: anywhere;
  }
  .kaspersky-note { white-space: normal !important; max-width: 100%; }

  /* --- тестбар land --- */
  .cis-test-bar,
  .cis-testbar { position: static !important; }
  .cis-test-bar .inner {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    align-items: end;
    padding: 6px 12px !important;
    gap: 6px 8px !important;
  }
  .cis-test-bar b {
    grid-column: 1 / -1;
    grid-row: 1;
    font-size: 11px;
    width: auto;
  }
  .cis-test-bar .pill { display: none !important; }
  .cis-test-bar label:nth-of-type(1) { grid-column: 1; grid-row: 2; }
  .cis-test-bar label:nth-of-type(2) { grid-column: 2; grid-row: 2; }
  .cis-test-bar a { grid-row: 3; }
  .cis-test-bar label {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
  }
  .cis-test-bar select {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    padding: 5px 8px;
    font-size: 13px;
  }
  .cis-test-bar a { font-size: 12px; min-width: 0; }

  /* --- тестбар лента/кабинет --- */
  .cis-testbar {
    padding: 6px 12px !important;
    font-size: 12px !important;
    gap: 6px 10px !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    max-width: 100%;
    min-width: 0;
  }
  .cis-testbar select { max-width: 140px; font-size: 13px; flex: 0 0 auto; }

  /* --- чипсы: скролл внутри ряда, не всей страницы --- */
  .chips, .subchips {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    margin-bottom: 12px;
    padding-bottom: 2px;
    max-width: 100%;
    min-width: 0;
  }
  .chips::-webkit-scrollbar,
  .subchips::-webkit-scrollbar { display: none; }
  .chip { flex: 0 0 auto; white-space: nowrap; }

  .from-flags {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    max-width: 100%;
    min-width: 0;
  }
  .from-flags::-webkit-scrollbar { display: none; }
  .from-flag { flex: 0 0 auto; }

  .lang-pick, .section-flags, .lang-switch {
    max-width: 100%;
    min-width: 0;
  }
  .section-flags, .lang-switch {
    flex-wrap: wrap !important;
  }

  /* --- модалки --- */
  .modal-overlay {
    align-items: flex-start !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 10px 10px 28px !important;
  }
  .modal,
  .modal.modal-wide {
    width: 100%;
    max-width: 100% !important;
    margin: 0;
    max-height: none;
  }
  .cn-preview { display: none !important; }
  .modal-overlay.cn-create-overlay {
    flex-direction: column !important;
    padding: 10px 10px 28px !important;
    gap: 0 !important;
  }
}

@media (max-width: 940px) {
  .header { position: sticky; top: 0; }
  .header-inner {
    flex-wrap: wrap !important;
    height: auto !important;
    padding-top: 10px !important;
    padding-bottom: 0 !important;
    gap: 8px 8px !important;
    justify-content: flex-start !important;
    align-items: center !important;
  }
  /* лого + auth всегда в одной строке; nav — ниже */
  .header-inner > .logo {
    order: 1 !important;
    flex: 1 1 0% !important;
    min-width: 0 !important;
    max-width: none !important;
  }
  .logo-word {
    font-size: 15px !important;
    letter-spacing: .06em !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .logo-img { width: 36px !important; height: 36px !important; flex-shrink: 0; }
  .header-inner > .header-actions {
    order: 2 !important;
    margin-left: auto !important;
    flex: 0 0 auto !important;
    max-width: none;
    gap: 4px;
  }
  .header-actions .user-name { display: none !important; }
  .header-actions .btn-ghost,
  .header-actions .btn-auth-login,
  .header-actions .btn-auth-register {
    display: inline-flex !important;
    align-items: center;
    padding: 6px 8px;
    font-size: 12px;
    min-height: 34px;
    line-height: 1.15;
    white-space: nowrap;
  }
  .nav {
    order: 3 !important;
    width: 100% !important;
    flex: 0 0 100% !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: stretch !important;
    justify-content: space-between !important;
    gap: 2px !important;
    margin: 0 !important;
    padding: 6px 0 8px !important;
    border-top: 1px solid var(--border, #DDE1E7);
    overflow: visible !important;
    -webkit-overflow-scrolling: auto;
    scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a {
    width: auto !important;
    flex: 1 1 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    padding: 6px 2px !important;
    min-height: 40px;
    display: inline-flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal !important;
    font-size: 11px !important;
    line-height: 1.15 !important;
    gap: 0;
    border-radius: 6px;
  }
  .nav a .nav-badge {
    position: absolute;
    top: 1px;
    right: 0;
    margin-left: 0 !important;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    font-size: 9px;
  }
  .nav a .nav-badge-dot {
    top: 4px !important;
    right: 4px;
    margin-left: 0 !important;
    position: absolute !important;
  }
  .burger { display: none !important; }
}

@media (max-width: 700px) {
  .header-subbar {
    display: flex !important;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 12px 10px !important;
  }
  .header-subbar .btn-create-promo,
  .header-subbar .btn-green {
    flex: 1 1 100%;
    width: 100%;
    max-width: none !important;
    font-size: 15px;
    min-height: 42px;
  }
  .header-subbar .section-flags,
  .header-subbar .lang-pick {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    flex-wrap: wrap !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .kaspersky-note { display: none !important; }
  .page-head {
    flex-direction: column;
    align-items: stretch !important;
    gap: 10px;
  }
  .page-head .btn,
  .page-head-create { width: 100%; }
  .page-head h1 { font-size: 20px; }
}

@media (max-width: 640px) {
  .search-bar { flex-direction: column !important; }
  .search-bar .sf { flex: 1 1 auto; min-height: 48px; }
  .search-bar .sf + .sf { border-left: none; border-top: 1px solid var(--border, #DDE1E7); }
  .search-bar .btn { width: 100%; min-height: 48px; }

  .search-box { grid-template-columns: 1fr !important; }
  .sf-q { grid-column: 1; }
  .sf-city { border-right: none; border-bottom: 1px solid var(--border, #DDE1E7); }
  .search-box .btn-primary { grid-column: 1; grid-row: auto; padding: 12px; width: 100%; }

  .cab-actions { flex-wrap: wrap; }
  .cab-actions .btn { flex: 1 1 calc(50% - 6px); min-height: 40px; }
}

@media (max-width: 580px) {
  .container { padding-left: 12px; padding-right: 12px; }
  .origin-row { grid-template-columns: 1fr 1fr !important; }
  .origin-btn {
    min-height: 52px !important;
    font-size: 12.5px !important;
    padding: 10px 8px !important;
    gap: 8px !important;
  }
  .cat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .cat-card h3, .cat-grid h3 { font-size: 13.5px; line-height: 1.25; }
  .cat-card > div { min-width: 0; flex: 1; }
  .cat-card h3 { overflow-wrap: break-word; hyphens: auto; }
  .listing-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .bank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .bank-name { overflow-wrap: anywhere; }
  .trust-grid { grid-template-columns: 1fr !important; }
  .header-actions .btn-ghost,
  .header-actions .btn-auth-login,
  .header-actions .btn-auth-register {
    padding: 5px 7px;
    font-size: 11.5px;
    min-height: 32px;
  }
  .logo-word { font-size: 14px !important; letter-spacing: .04em !important; }
  .logo-img { width: 32px !important; height: 32px !important; }
  .hero h1 { font-size: 24px !important; }
  .section-promo { font-size: 14px !important; white-space: normal !important; }
  .cis-countries { grid-template-columns: 1fr !important; }
  .create-2col { grid-template-columns: 1fr !important; }
}

@media (max-width: 340px) {
  .origin-row { grid-template-columns: 1fr !important; }
  .logo-word { font-size: 13px !important; letter-spacing: .04em !important; }
}

@media (max-width: 360px) {
  .listing-grid { grid-template-columns: 1fr !important; }
  .cat-grid { grid-template-columns: 1fr !important; }
}

@media (min-width: 700px) and (max-width: 940px) {
  .origin-row { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .listing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)) !important; }
}

@media (min-width: 861px) and (max-width: 1100px) {
  .listing-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (min-width: 1101px) and (max-width: 1280px) {
  .listing-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
