/* ===== osuz-v34-mobile-header-catalog-fix ===== */
/* V34 mobile: one clean header/search + bottom catalog; legacy catalog overlays disabled. */
#osuzCatalogPanel { display:none !important; }

@media (max-width: 767px) {
  :root { --osuz-v34-bottom: 68px; }
  body { padding-bottom: calc(var(--osuz-v34-bottom) + env(safe-area-inset-bottom)) !important; }

  /* Catalog is NOT a top-header control on phones. */
  .site-header-top [data-osuz-catalog-toggle],
  .auth-site-header [data-osuz-catalog-toggle],
  .osuz-desktop-catalog-button,
  .osuz-catalog-button[data-osuz-catalog-toggle] {
    display:none !important;
    visibility:hidden !important;
  }

  /* Compact first row for every non-index page. */
  body:not([data-osuz-page="index"]) .site-header-top > .max-w-\[1400px\],
  body:not([data-osuz-page="index"]) .site-header-top > .max-w-\[1200px\],
  body:not([data-osuz-page="index"]) .auth-site-header > .auth-header-inner,
  body:not([data-osuz-page="index"]) .auth-site-header > div {
    display:grid !important;
    grid-template-columns:minmax(0,1fr) auto !important;
    grid-template-rows:50px 46px !important;
    align-items:center !important;
    column-gap:10px !important;
    row-gap:8px !important;
    width:100% !important;
    min-height:111px !important;
    height:auto !important;
    padding:6px 10px 9px !important;
    margin:0 auto !important;
  }

  body:not([data-osuz-page="index"]) .site-header-top .header-brand,
  body:not([data-osuz-page="index"]) .site-header-top > div > a:first-child,
  body:not([data-osuz-page="index"]) .auth-site-header .header-brand,
  body:not([data-osuz-page="index"]) .auth-site-header > div > a:first-child {
    grid-column:1 !important;
    grid-row:1 !important;
    justify-self:start !important;
    margin:0 !important;
  }

  body:not([data-osuz-page="index"]) .site-header-top .header-actions,
  body:not([data-osuz-page="index"]) .site-header-top .osuz-mobile-header-actions,
  body:not([data-osuz-page="index"]) .auth-site-header .header-actions,
  body:not([data-osuz-page="index"]) .auth-site-header .osuz-mobile-header-actions {
    grid-column:2 !important;
    grid-row:1 !important;
    justify-self:end !important;
    margin:0 !important;
    gap:8px !important;
  }

  /* Keep only language + theme in the upper mobile row. */
  .site-header-top .osuz-mobile-header-actions > a,
  .site-header-top .header-actions > a,
  .auth-site-header .osuz-mobile-header-actions > a,
  .auth-site-header .header-actions > a,
  #mobileMenuBtn {
    display:none !important;
  }

  /* Search MUST be visible as row two on catalog/product/cart/orders/auth. */
  body:not([data-osuz-page="index"]) .osuz-desktop-search-slot,
  body[data-osuz-page="category"] .osuz-desktop-search-slot {
    grid-column:1 / -1 !important;
    grid-row:2 !important;
    display:flex !important;
    width:100% !important;
    max-width:none !important;
    min-width:0 !important;
    margin:0 !important;
    order:initial !important;
  }
  body:not([data-osuz-page="index"]) form.osuz-header-search,
  body:not([data-osuz-page="index"]) .category-header-search {
    display:flex !important;
    width:100% !important;
    max-width:none !important;
    min-width:0 !important;
    height:44px !important;
    margin:0 !important;
  }
  body[data-osuz-page="category"] .category-header-search { flex:1 1 auto !important; }
  body[data-osuz-page="category"] .category-search-suggest { top:48px !important; }

  /* Index keeps its own dedicated second-row search and it must always show. */
  body[data-osuz-page="index"] .site-header-top > .max-w-\[1400px\],
  body[data-osuz-page="index"] .site-header-top > .max-w-\[1200px\] {
    min-height:56px !important;
    height:56px !important;
    padding:5px 10px !important;
  }
  body[data-osuz-page="index"] .header-search-wrap { display:none !important; }
  body[data-osuz-page="index"] .mobile-top-search-wrap {
    display:block !important;
    visibility:visible !important;
    opacity:1 !important;
    background:#067890 !important;
    padding:0 10px 9px !important;
    margin:0 !important;
  }
  body[data-osuz-page="index"] .mobile-top-search-shell {
    display:flex !important;
    width:100% !important;
    height:44px !important;
    border-radius:11px !important;
  }
  body[data-osuz-page="index"] .mobile-top-search-shell input { display:block !important; min-width:0 !important; flex:1 1 auto !important; }

  /* The new catalog sits BELOW the complete header, with breathing room. */
  #osuzV34Catalog {
    position:fixed !important;
    z-index:420 !important;
    left:8px !important;
    right:8px !important;
    top:var(--osuz-v34-catalog-top, 122px) !important;
    bottom:calc(var(--osuz-v34-bottom) + env(safe-area-inset-bottom) + 8px) !important;
    display:none !important;
    flex-direction:column !important;
    overflow:hidden !important;
    background:#fff !important;
    border:1px solid #dbe4ee !important;
    border-radius:16px !important;
    box-shadow:0 22px 70px rgba(15,23,42,.22) !important;
  }
  #osuzV34Catalog.open { display:flex !important; }
  body.dark-mode #osuzV34Catalog { background:#0b111b !important; border-color:#334155 !important; color:#f8fafc !important; }
  body.osuz-v34-catalog-open { overflow:hidden !important; }

  .v34-cat-head {
    flex:0 0 auto; display:grid; grid-template-columns:40px 1fr 40px; align-items:center;
    min-height:58px; padding:8px 10px; border-bottom:1px solid #e2e8f0; background:inherit;
  }
  body.dark-mode .v34-cat-head { border-color:#263548; }
  .v34-cat-title { min-width:0; text-align:center; font-size:18px; line-height:1.2; font-weight:900; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; }
  .v34-cat-back,.v34-cat-close { width:38px;height:38px;border:0;border-radius:10px;background:#f1f5f9;display:inline-flex;align-items:center;justify-content:center;color:#0f172a; }
  .v34-cat-back[hidden] { visibility:hidden; display:inline-flex !important; }
  body.dark-mode .v34-cat-back,body.dark-mode .v34-cat-close { background:#182333;color:#f8fafc; }
  .v34-cat-back svg,.v34-cat-close svg { width:19px;height:19px; }

  .v34-cat-list { flex:1 1 auto; min-height:0; overflow-y:auto; -webkit-overflow-scrolling:touch; padding:8px 10px 16px; }
  .v34-cat-row {
    width:100%; min-height:52px; border:0; border-bottom:1px solid #edf2f7; background:transparent;
    display:flex; align-items:center; justify-content:space-between; gap:12px; padding:10px 8px;
    color:#172033; font-size:14px; font-weight:800; text-align:left;
  }
  .v34-cat-row:last-child { border-bottom:0; }
  .v34-cat-row:active { background:#e7f9fc; }
  .v34-cat-row-all { color:#008aa3; background:#f4fbfc; border-radius:10px; margin-bottom:4px; border-bottom:0; }
  .v34-cat-row svg { width:18px;height:18px;flex:0 0 auto;color:#64748b; }
  body.dark-mode .v34-cat-row { color:#f8fafc;border-color:#243142; }
  body.dark-mode .v34-cat-row-all { background:#102a31;color:#67e8f9; }
  .v34-cat-state { padding:22px 12px;color:#64748b;font-size:14px;text-align:center; }

  /* Bottom tab has five equal cells; catalog is opened here only. */
  .osuz-mobile-bottom-final { grid-template-columns:repeat(5,minmax(0,1fr)) !important; }
  .osuz-mobile-bottom-final button[data-v34-mobile-catalog] {
    appearance:none;border:0;background:transparent;position:relative;display:flex !important;
    flex-direction:column;align-items:center;justify-content:center;gap:4px;min-width:0;
    color:#64748b;font:inherit;font-size:9px;font-weight:800;padding:3px 2px;cursor:pointer;
  }
  .osuz-mobile-bottom-final button[data-v34-mobile-catalog] svg { width:20px !important;height:20px !important; }
  .osuz-mobile-bottom-final button[data-v34-mobile-catalog].active { color:#067890 !important; }
  .osuz-mobile-bottom-final button[data-v34-mobile-catalog].active::before {
    content:"";position:absolute;top:0;left:28%;right:28%;height:2px;border-radius:0 0 3px 3px;background:#0abbd0;
  }
}

@media (min-width: 768px) {
  #osuzV34Catalog {
    position:fixed; z-index:420; left:50%; transform:translateX(-50%); width:min(1040px,calc(100vw - 48px));
    top:var(--osuz-v34-catalog-top, 124px); display:none; grid-template-columns:320px 1fr;
    max-height:min(620px,calc(100vh - var(--osuz-v34-catalog-top,124px) - 24px)); overflow:hidden;
    background:#fff;border:1px solid #dbe4ee;border-radius:0 0 18px 18px;box-shadow:0 28px 80px rgba(15,23,42,.24);
  }
  #osuzV34Catalog.open { display:grid; }
  .v34-desktop-roots { overflow:auto;padding:10px;border-right:1px solid #e2e8f0; }
  .v34-desktop-subs { overflow:auto;padding:18px 20px; }
  .v34-desktop-root,.v34-desktop-sub { width:100%;border:0;background:transparent;display:flex;align-items:center;justify-content:space-between;gap:12px;text-align:left;border-radius:10px;color:#172033; }
  .v34-desktop-root { min-height:44px;padding:8px 10px;font-weight:800; }
  .v34-desktop-root.active,.v34-desktop-root:hover { background:#dff7fb;color:#007d94; }
  .v34-desktop-sub { min-height:42px;padding:7px 9px;font-weight:700; }
  .v34-desktop-sub:hover { background:#f3f8fb; }
  .v34-desktop-root svg,.v34-desktop-sub svg { width:17px;height:17px; }
  .v34-desktop-heading { margin:2px 0 10px;font-size:12px;font-weight:900;text-transform:uppercase;letter-spacing:.08em;color:#64748b; }
  body.dark-mode #osuzV34Catalog { background:#0b111b;border-color:#334155;color:#f8fafc; }
  body.dark-mode .v34-desktop-roots { border-color:#263548; }
  body.dark-mode .v34-desktop-root,body.dark-mode .v34-desktop-sub { color:#f8fafc; }
  body.dark-mode .v34-desktop-root.active,body.dark-mode .v34-desktop-root:hover { background:#12313a;color:#67e8f9; }
  body.dark-mode .v34-desktop-sub:hover { background:#162130; }
  .v34-mobile-only { display:none !important; }
}

/* ===== osuz-v35-mobile-search-catalog-clean ===== */
/* V35: final mobile search + clean one-column catalog. */
@media (max-width:767px){
  /* Never render desktop catalog panes on phones. */
  #osuzV34Catalog .v34-desktop-roots,
  #osuzV34Catalog .v34-desktop-subs{
    display:none !important;
    visibility:hidden !important;
  }
  #osuzV34Catalog .v34-mobile-only{display:flex !important;}
  #osuzV34Catalog .v34-cat-list.v34-mobile-only{
    display:block !important;
    padding:10px 10px 18px !important;
    background:#fff !important;
  }
  body.dark-mode #osuzV34Catalog .v34-cat-list.v34-mobile-only{background:#0b111b !important;}

  #osuzV34Catalog{
    left:10px !important;
    right:10px !important;
    border-radius:16px !important;
    overflow:hidden !important;
  }
  #osuzV34Catalog .v34-cat-head{
    min-height:54px !important;
    padding:7px 9px !important;
  }
  #osuzV34Catalog .v34-cat-title{
    font-size:17px !important;
    font-weight:900 !important;
  }
  #osuzV34Catalog .v34-cat-row{
    box-sizing:border-box !important;
    width:100% !important;
    min-height:50px !important;
    margin:0 !important;
    padding:0 12px !important;
    display:flex !important;
    align-items:center !important;
    justify-content:space-between !important;
    gap:12px !important;
    border:0 !important;
    border-bottom:1px solid #e8eef5 !important;
    border-radius:0 !important;
    background:#fff !important;
    color:#172033 !important;
    font-size:13px !important;
    line-height:1.25 !important;
    font-weight:750 !important;
    text-align:left !important;
    white-space:normal !important;
  }
  #osuzV34Catalog .v34-cat-row > span{
    display:block !important;
    flex:1 1 auto !important;
    min-width:0 !important;
    overflow-wrap:anywhere !important;
  }
  #osuzV34Catalog .v34-cat-row > svg{
    display:block !important;
    flex:0 0 18px !important;
    width:18px !important;
    height:18px !important;
    color:#64748b !important;
  }
  #osuzV34Catalog .v34-cat-row-all{
    min-height:46px !important;
    margin:0 0 8px !important;
    border:1px solid #bfeaf0 !important;
    border-radius:11px !important;
    background:#effbfd !important;
    color:#007c91 !important;
  }
  #osuzV34Catalog .v34-cat-row:active{background:#eefafd !important;}
  body.dark-mode #osuzV34Catalog .v34-cat-row{
    background:#0b111b !important;
    color:#f8fafc !important;
    border-bottom-color:#263548 !important;
  }
  body.dark-mode #osuzV34Catalog .v34-cat-row-all{
    background:#102a31 !important;
    color:#67e8f9 !important;
    border-color:#23505b !important;
  }

  /* Index mobile search: force the actual existing search row to be visible. */
  body[data-osuz-page="index"] nav.site-header > .mobile-top-search-wrap{
    display:block !important;
    visibility:visible !important;
    opacity:1 !important;
    position:relative !important;
    z-index:2 !important;
    width:100% !important;
    height:auto !important;
    min-height:53px !important;
    padding:0 10px 9px !important;
    margin:0 !important;
    background:#067890 !important;
    border:0 !important;
  }
  body[data-osuz-page="index"] nav.site-header > .mobile-top-search-wrap > .mobile-top-search-shell,
  body[data-osuz-page="index"] #mobileTopSearchForm{
    display:flex !important;
    visibility:visible !important;
    opacity:1 !important;
    width:100% !important;
    height:44px !important;
    min-height:44px !important;
    margin:0 !important;
    border-radius:11px !important;
    overflow:hidden !important;
    background:#fff !important;
  }
  body[data-osuz-page="index"] #mobileTopSearchInput{
    display:block !important;
    visibility:visible !important;
    opacity:1 !important;
    flex:1 1 auto !important;
    min-width:0 !important;
    height:100% !important;
    font-size:12px !important;
    color:#0f172a !important;
  }
  body[data-osuz-page="index"] #mobileTopSearchButton{
    display:inline-flex !important;
    visibility:visible !important;
    opacity:1 !important;
    height:100% !important;
    padding:0 15px !important;
    background:#111827 !important;
    color:#fff !important;
    font-size:12px !important;
    font-weight:800 !important;
  }
}

/* ===== osuz-v53-mobile-catalog-section ===== */
/* V53: на телефонах «Каталог» — полноэкранный раздел (а не плавающий поп-ап). Адрес: #catalog, кнопка «назад» закрывает раздел. */
@media (max-width:767px){
  #osuzV34Catalog{
    left:0!important;right:0!important;top:0!important;
    bottom:calc(var(--osuz-v34-bottom,68px) + env(safe-area-inset-bottom))!important;
    border:0!important;border-radius:0!important;box-shadow:none!important;
    background:#fff!important;z-index:420!important;
  }
  body.dark-mode #osuzV34Catalog{background:#0b111b!important}
  #osuzV34Catalog .v34-cat-head{
    padding-top:calc(7px + env(safe-area-inset-top))!important;
    min-height:calc(54px + env(safe-area-inset-top))!important;
    background:#fff!important;position:sticky;top:0;z-index:1;
  }
  body.dark-mode #osuzV34Catalog .v34-cat-head{background:#0b111b!important}
}

/* OSUZ mobile polish: catalog header alignment and inner-page breathing room.
   This is intentionally scoped to phones and to cart/orders only. */
@media (max-width: 767px) {
  /* The legacy .v34-mobile-only flex rule must not override the header grid. */
  #osuzV34Catalog .v34-cat-head.v34-mobile-only {
    display: grid !important;
    grid-template-columns: 44px minmax(0, 1fr) 44px !important;
    align-items: center !important;
    column-gap: 8px !important;
    min-height: calc(64px + env(safe-area-inset-top, 0px)) !important;
    padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px !important;
    box-sizing: border-box !important;
  }
  #osuzV34Catalog .v34-cat-back {
    grid-column: 1 !important;
    grid-row: 1 !important;
    justify-self: start !important;
  }
  #osuzV34Catalog .v34-cat-title {
    grid-column: 2 !important;
    grid-row: 1 !important;
    width: 100% !important;
    min-width: 0 !important;
    text-align: center !important;
    margin: 0 !important;
  }
  #osuzV34Catalog .v34-cat-close {
    grid-column: 3 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    width: 38px !important;
    height: 38px !important;
    flex: none !important;
  }
  /* Existing header is fixed. Give headings 24px of breathing room below it. */
  body[data-osuz-page="orders"] > main.pt-36,
  body[data-osuz-page="cart"] > main.pt-36 {
    padding-top: 148px !important;
  }
}
