/*
 * KIBERHUB | Mobile Performance & Floating Dock v2.0
 * Layer loaded AFTER the production bundle. No database or framework changes.
 */
:root {
  --kb-dock-height: 72px;
  --kb-dock-gap: 14px;
}
img, video, svg { max-width: 100%; }
img { vertical-align: middle; }
:where(.p-card, .pc2, .promo, .cat-tile, .sub-tile, .service-home-grid > a) { min-width: 0; }
:where(.p-name, .p-sp, .promo-text, .cat-tile, .sub-tile, .service-home-grid > a) { overflow-wrap: anywhere; }
.p-img img.kiber-product-photo, .pc2-img img.kiber-product-photo {
  max-width: 100%; max-height: 100%; object-fit: contain;
}
:where(.hero-bg, .promo-upload, .sh2-bg img, .sv2-hero-bg img) {
  display: block; object-fit: cover;
}
/* Avoid unpredictable font zooming and horizontal overflow on narrow devices. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { min-width: 0; }
@media (hover: none) and (pointer: coarse) {
  .p-card:hover, .promo:hover, .cat-tile:hover, .stat-card:hover {
    transform: none !important;
  }
  .p-card:hover::before, .promo:hover::before,
  .cat-tile:hover::before { opacity: 0; }
  .p-card, .promo, .cat-tile { -webkit-tap-highlight-color: transparent; }
}
/* Float the mobile dock above the bottom safe area (iOS gesture bar included). */
@media (max-width: 991.98px) {
  :root { --kb-dock-bottom: calc(var(--kb-dock-gap) + env(safe-area-inset-bottom, 0px)); }
  body, body.has-bottom-nav { padding-bottom: calc(var(--kb-dock-height) + 52px + env(safe-area-inset-bottom, 0px)); }
  .bottom-nav.d-lg-none {
    box-sizing: border-box;
    position: fixed;
    z-index: 1030;
    left: 50%;
    right: auto;
    bottom: var(--kb-dock-bottom);
    transform: translate3d(-50%, 0, 0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    width: min(500px, calc(100% - 28px));
    height: var(--kb-dock-height);
    padding: 7px 7px 8px;
    border: 1px solid var(--line2);
    border-radius: 999px;
    background: var(--surface) !important;
    box-shadow: 0 12px 36px rgba(10, 26, 58, .20), 0 3px 8px rgba(10, 26, 58, .06);
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    isolation: isolate;
    overflow: visible;
  }
  /* Raised semi-circular cap ties the central search action to the floating dock. */
  .bottom-nav.d-lg-none::before {
    content: "";
    position: absolute;
    z-index: -1;
    left: 50%;
    top: -17px;
    width: 77px;
    height: 54px;
    transform: translateX(-50%);
    border: 1px solid var(--line2);
    border-bottom: 0;
    border-radius: 60px 60px 18px 18px;
    background: var(--surface);
    pointer-events: none;
  }
  .bottom-nav.d-lg-none > a,
  .bottom-nav.d-lg-none > button {
    display: flex;
    flex: 1 1 0;
    min-width: 0;
    align-self: stretch;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    padding: 7px 1px 5px;
    margin: 0;
    border: 0;
    border-radius: 20px;
    background: transparent;
    color: var(--mut);
    font-size: 10px;
    font-weight: 650;
    line-height: 1.2;
    text-decoration: none;
    text-align: center;
    transition: color .18s ease, background-color .18s ease, transform .18s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    cursor: pointer;
  }
  .bottom-nav.d-lg-none > :is(a, button) > i,
  .bottom-nav.d-lg-none .bn-ico > i { font-size: 19px; line-height: 23px; }
  .bottom-nav.d-lg-none > :is(a, button) > span:last-child {
    display: block;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .bottom-nav.d-lg-none > :is(a,button).active,
  .bottom-nav.d-lg-none > :is(a,button)[aria-current="page"] { color: var(--blue2); }
  .bottom-nav.d-lg-none > :is(a,button):focus-visible {
    outline: 2px solid var(--blue); outline-offset: 2px;
  }
  .bottom-nav.d-lg-none > :is(a,button):active { transform: scale(.96); }
  .bottom-nav.d-lg-none .bn-ico { position: relative; line-height: 23px; }
  .bottom-nav.d-lg-none .hdr-count {
    position: absolute; top: -8px; right: -13px;
    min-width: 16px; height: 16px; line-height: 16px; font-size: 9px;
  }
  .bottom-nav.d-lg-none > .bn-primary {
    position: relative;
    padding-top: 2px;
    overflow: visible;
    gap: 3px;
    color: var(--blue2);
  }
  .bottom-nav.d-lg-none .bn-primary-icon {
    flex: 0 0 auto;
    position: relative;
    display: grid;
    place-items: center;
    height: 56px;
    width: 56px;
    margin-top: -31px;
    border: 4px solid var(--surface);
    border-radius: 50%;
    background: linear-gradient(145deg, #318dff, #155de4);
    color: #fff;
    box-shadow: 0 6px 17px rgba(23, 97, 230, .30), inset 0 1px 2px rgba(255,255,255,.25);
  }
  .bottom-nav.d-lg-none .bn-primary-icon i { font-size: 19px; }
  .bottom-nav.d-lg-none > .bn-primary > span:last-child {
    transform: translateY(-2px);
    font-size: 10px;
    font-weight: 800;
  }
  .bottom-nav.d-lg-none > :is(a,button):not(.bn-primary):hover {
    color: var(--blue2);
    background: var(--tint2);
  }
  .to-top { bottom: calc(105px + env(safe-area-inset-bottom, 0px)); right: 16px; }
  .nx-toasts { bottom: calc(106px + env(safe-area-inset-bottom, 0px)); }
  .container, .container-fluid { min-width: 0; }
  .hdr-row, .hdr-actions, .slide-text, .promo-text { min-width: 0; }
  .hero-wrap { padding-top: 10px; }
  .hero { border-radius: 18px; }
  .hslide { min-height: clamp(320px, 72vw, 430px); padding: 24px 24px 42px; align-items: center; }
  .hslide.has-photo .slide-text { max-width: min(540px, 95%); }
  .hslide.has-photo .hero-bg { object-position: 58% center; }
  .hslide.has-photo .hero-shade {
    background: linear-gradient(90deg, rgba(4, 10, 24, .84) 0%, rgba(4, 10, 24, .64) 55%, rgba(4,10,24,.25) 100%);
  }
  .slide-text h1 { max-width: 100%; text-wrap: balance; }
  .slide-sub { max-width: 44ch; }
  .p-grid, .cat-tiles, .sub-tiles, .promos, .service-home-grid {
    min-width: 0;
  }
  .p-grid > *, .cat-tiles > *, .sub-tiles > *, .promos > * {
    min-width: 0;
  }
  .promo-upload { max-width: 52%; height: 100%; object-fit: contain; }
  .p-grid.list { grid-template-columns: minmax(0, 1fr); }
  .p-grid.list .p-card { max-width: 100%; }
  .p-grid.list .p-card > * { min-width: 0; }
  /* Turn off costly perpetual page decorations on touchscreens. */
  .ticker-track, .brands-track { animation: none !important; }
  .ticker { overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .ticker::-webkit-scrollbar { display: none; }
  .fan, .hero .fan, .gallery-main .fan, .q-vis .fan {
    animation: none !important;
  }
}
@media (max-width: 767.98px) {
  .block { padding-left: 0; padding-right: 0; }
  .container { --bs-gutter-x: 24px; }
  .hero { border-radius: 16px; }
  .hslide { min-height: 360px; padding: 22px 20px 48px; }
  .hslide.has-photo .hero-bg { object-position: center; }
  .hslide.has-photo .hero-shade {
    background: linear-gradient(90deg, rgba(5,11,25,.86), rgba(5,11,25,.65) 67%, rgba(5,11,25,.33));
  }
  .hslide .slide-text { max-width: 100%; width: 100%; }
  .hslide .slide-text h1 { font-size: clamp(1.7rem, 5.3vw, 2.35rem); line-height: 1.12; }
  .hslide .slide-sub { font-size: .86rem; line-height: 1.55; }
  .slide-art { max-width: 65%; opacity: .28; }
  .cat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .p-grid.cols-6, .p-grid.cols-5, .p-grid.cols-4,
  .p-grid.cols-3, .p-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .p-card { display: flex; flex-direction: column; min-width: 0; border-radius: 15px; }
  .p-card .p-info { min-width: 0; flex: 1 1 auto; }
  .p-img { height: auto; min-height: 0; aspect-ratio: 1.28 / 1; }
  .p-img .art { max-height: 96%; }
  .p-img > img { width: 100%; height: 100%; object-fit: contain; }
  .p-card .p-name { overflow-wrap: anywhere; }
  .p-card .p-buy { margin-top: auto; }
  .p-card .p-price { min-width: 0; }
  .p-card .p-price b { font-size: clamp(14px, 3.7vw, 19px); white-space: nowrap; }
  .p-card .p-actions { min-width: 0; }
  .p-actions .btn-buy { min-width: 0; flex: 1 1 auto; }
  .p-actions .btn-buy span { display: inline; }
  .p-actions .btn-buy { font-size: 12px; gap: 5px; }
  .p-actions .btn-buy i { font-size: 13px; }
  .promos { grid-template-columns: minmax(0,1fr); }
  .promo { min-height: 190px; overflow: hidden; }
  .promo .promo-text { max-width: 62%; }
  .promo-upload { max-width: 45%; width: 45%; padding: 4px; object-fit: contain; }
  .service-home-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .gallery, .g-stage, .gallery-main { max-width: 100%; min-width: 0; }
  .gallery img { object-fit: contain; }
  .cart-canvas { max-width: 100vw; }
  .foot-main .row > * { min-width: 0; }
  .search input { font-size: 16px; } /* suppress iOS focus zoom */
}
@media (max-width: 430px) {
  :root { --kb-dock-height: 68px; --kb-dock-gap: 12px; }
  .bottom-nav.d-lg-none { width: calc(100% - 22px); padding-left: 4px; padding-right: 4px; }
  .bottom-nav.d-lg-none > a, .bottom-nav.d-lg-none > button { font-size: 9px; gap: 3px; }
  .bottom-nav.d-lg-none .bn-primary-icon { width: 54px; height: 54px; }
  .hslide { min-height: 340px; padding: 20px 16px 44px; }
  .hero-carousel .carousel-control-prev, .hero-carousel .carousel-control-next {
    top: auto; bottom: 8px; height: 36px; width: 36px; z-index: 5;
  }
  .hero-carousel .carousel-control-prev { left: 9px; }
  .hero-carousel .carousel-control-next { right: 9px; }
  .hero-carousel .carousel-indicators { margin-bottom: 14px; }
  .cat-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .cat-tile { min-width: 0; }
  .p-grid { gap: 9px !important; }
  .p-card .p-actions .btn-buy span { display: inline; }
  .p-card .p-actions { gap: 5px; }
  .p-card .p-actions .p-eye { flex: 0 0 31px; width: 31px; min-width: 31px; }
  .p-card .p-deliv { font-size: 10px; }
  .promo .promo-text { max-width: 62%; }
  .promo .promo-text b { font-size: 1.13rem; }
  .service-home-grid { gap: 9px; }
}
@media (max-width: 360px) {
  .bottom-nav.d-lg-none > a, .bottom-nav.d-lg-none > button { font-size: 8px; }
  .bottom-nav.d-lg-none .bn-primary-icon { width: 50px; height: 50px; }
  .p-card .p-actions .btn-buy span { display: none; }
  .hslide .slide-text h1 { font-size: 1.55rem; }
  .cat-tiles { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 992px) {
  .bottom-nav.d-lg-none { display: none !important; }
}
@media (prefers-reduced-motion: reduce) {
  .bottom-nav *, .p-card *, .promo * { animation: none !important; transition: none !important; }
  .ticker-track { animation: none !important; }
}
/* Low-power preference already detected by header.php; avoid compositor work. */
html.lite .bottom-nav,
html.lite .bottom-nav::before { box-shadow: 0 5px 15px rgba(10,26,58,.14); }
html.lite .hero::before, html.lite .hslide::before { animation: none !important; }

/* v3: narrow-screen layout safety for long CRM titles & catalogue cards. */
@media (max-width: 767.98px) {
  .hslide h1 span,
  .slide-text h1 span,
  .promo-text b { white-space: normal; overflow-wrap: anywhere; }
  /* Show the full six-card selection instead of silently hiding the last two. */
  .p-grid.cols-6 > :nth-child(n+5),
  .pop-pane .p-grid.cols-6 > :nth-child(n+5) { display: flex !important; }
  .bottom-nav.d-lg-none > :is(a, button) { min-height: 48px; }
  .gallery-main img,
  .g-stage img,
  .pp-stage img { max-width: 100%; height: auto; object-fit: contain; }
}
@media (max-width: 430px) {
  .p-grid.list .p-card { grid-template-columns: minmax(92px, 108px) minmax(0, 1fr); gap: 6px 10px; }
  .p-grid.list .p-img { height: 105px; }
  .p-grid.list .p-buy { grid-column: 1 / -1; }
  .bottom-nav.d-lg-none { max-width: 100%; }
}


/* ===== KIBERHUB v4 / Mobile Search Experience ===== */
@media (max-width: 991.98px) {
  /* No second oversized search row: the dock + header icon open a proper search view. */
  .site-header .hdr-row > .search { display: none !important; }
  .site-header .kb-head-search { display: inline-flex !important; width: 38px; height: 42px; align-items: center; justify-content: center; }
  .site-header .kb-head-search .hdr-ico { color: var(--blue2, #479aff); }
  .bottom-nav.d-lg-none { box-shadow: 0 20px 50px rgba(0, 0, 0, .3), 0 4px 16px rgba(35, 99, 230, .1); }
  .bottom-nav.d-lg-none > .bn-primary { color: var(--head, #fff); }
  .bottom-nav.d-lg-none .bn-primary-icon { background: linear-gradient(135deg, #53b5ff 0%, #266cff 51%, #174acf 100%); box-shadow: 0 9px 23px rgba(29, 103, 248, .4), inset 0 1px 2px rgba(255,255,255,.25); }
  body.kb-search-open { overflow: hidden !important; }
  body.kb-search-open > .bottom-nav, body.kb-search-open .bottom-nav.d-lg-none { visibility: hidden; pointer-events: none; }
  body.kb-search-open #siteHeader { pointer-events: none; }
  .kb-search-overlay:not([hidden]) { display: flex; }
}
.kb-search-overlay[hidden] { display: none !important; }
.kb-search-overlay { display: none; }
@media (max-width: 991.98px) {
  .kb-search-overlay {
    position: fixed; inset: 0; z-index: 2400; width: 100%;
    height: 100vh; height: 100dvh;
    min-width: 0; margin: 0;
    background: var(--bg, #080f1f);
    color: var(--txt, #e5eaf8);
    overflow: hidden;
    isolation: isolate;
  }
  .kb-search-overlay::before {
    content: ''; position: absolute; z-index: -1; pointer-events: none;
    top: -170px; right: -160px; width: 440px; height: 440px; border-radius: 50%;
    background: radial-gradient(circle, rgba(39, 116, 255, .20), rgba(39, 116, 255, .06) 42%, transparent 70%);
  }
  .kb-search-shell { box-sizing: border-box; width: 100%; min-height: 0; max-width: 660px; margin: 0 auto; display: flex; flex-direction: column; padding: calc(18px + env(safe-area-inset-top, 0px)) 18px max(16px, env(safe-area-inset-bottom, 0px)); }
  .kb-search-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex: 0 0 auto; }
  .kb-search-brand { display: inline-flex; align-items: center; gap: 10px; color: var(--head, #fff); font-weight: 900; font-size: 19px; letter-spacing: .03em; line-height: 1.15; text-decoration: none; }
  .kb-search-brand:hover { color: var(--head, #fff); }
  .kb-search-brand-icon { display: grid; place-items: center; width: 40px; height: 40px; border: 1px solid rgba(91, 157, 255, .33); border-radius: 13px; background: rgba(41, 120, 255, .11); color: #589fff; font-size: 17px; }
  .kb-search-brand-accent { color: #4599ff; }
  .kb-search-brand small { display: block; margin-top: 4px; letter-spacing: .09em; font-size: 8px; font-weight: 750; color: var(--mut, #8a99b4); }
  .kb-search-close { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border-radius: 14px; border: 1px solid var(--line2, #273958); color: var(--txt, #fff); background: var(--surface, #111a2a); font-size: 18px; transition: background .15s ease; }
  .kb-search-close:active { transform: scale(.96); }
  .kb-search-intro { margin: clamp(26px, 5vh, 54px) 0 22px; flex: 0 0 auto; }
  .kb-search-eyebrow { display: flex; align-items: center; gap: 8px; color: #5eaaff; font-size: 10px; font-weight: 850; letter-spacing: .13em; }
  .kb-search-eyebrow span { width: 6px; height: 6px; border-radius: 50%; background: #55a5ff; box-shadow: 0 0 10px rgba(80,165,255,.65); }
  .kb-search-intro h2 { margin: 10px 0 8px; color: var(--head, #fff); font-size: clamp(29px, 8vw, 42px); letter-spacing: -.04em; line-height: 1.09; font-weight: 900; }
  .kb-search-intro h2 em { font-style: normal; color: #469bff; }
  .kb-search-intro p { max-width: 370px; color: var(--mut, #a0adbd); font-size: 13px; line-height: 1.5; margin: 0; }
  .kb-search-form { display: flex; align-items: center; position: relative; flex: 0 0 auto; width: 100%; height: 61px; padding: 5px 5px 5px 15px; border-radius: 19px; background: var(--surface, #121e34); border: 1px solid rgba(76, 148, 255, .5); box-shadow: 0 5px 28px rgba(36, 105, 235, .13), 0 0 0 3px rgba(50, 129, 255, .055); }
  .kb-search-form:focus-within { border-color: #448fff; box-shadow: 0 5px 26px rgba(36, 105, 235, .15), 0 0 0 3px rgba(44, 121, 254, .10); }
  .kb-search-input-icon { flex: none; color: #4a96ff; font-size: 17px; margin-right: 12px; }
  .kb-search-form #kbSearchInput { outline: none; border: 0; min-width: 0; width: 100%; flex: 1 1 auto; height: 100%; background: transparent; box-shadow: none; color: var(--head, #fff); font-size: 16px; font-weight: 600; padding: 0; -webkit-appearance: none; appearance: none; }
  .kb-search-form #kbSearchInput::placeholder { color: var(--mut, #8e9aac); font-weight: 450; font-size: 13px; }
  .kb-search-form #kbSearchInput::-webkit-search-cancel-button { display: none; }
  .kb-search-clear { flex: none; width: 30px; height: 34px; border: 0; background: transparent; color: var(--mut, #8e9aac); }
  .kb-search-clear[hidden] { display: none; }
  .kb-search-go { flex: none; width: 48px; height: 48px; border: 0; border-radius: 14px; background: linear-gradient(135deg, #429fff, #2061ed); color: #fff; box-shadow: 0 5px 12px rgba(22, 91, 222, .26); display: grid; place-items: center; font-size: 17px; }
  .kb-search-main { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; margin-top: 22px; padding: 16px 12px 10px; border: 1px solid var(--line2, #273755); border-radius: 23px; background: var(--card, #0d172c); }
  .kb-search-hint { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 6px 10px; border-bottom: 1px solid var(--line, #253249); color: var(--txt2, #a2b1c8); font-size: 11px; font-weight: 600; }
  .kb-search-hint i { margin-right: 5px; color: #65acff; }
  .kb-search-live-dot { color: #42dca5; border-radius: 99px; background: rgba(38, 191, 141, .12); font-size: 9px; letter-spacing: .09em; padding: 5px 7px; }
  .search-dd.kb-search-results { display: block; position: static; min-height: 0; max-height: none; flex: 1 1 auto; width: 100%; border: none; background: transparent; box-shadow: none !important; margin: 0; padding: 10px 1px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; -webkit-overflow-scrolling: touch; animation: none !important; scrollbar-width: thin; }
  .kb-search-results .sd-title { padding: 10px 9px 9px; font-size: 10px; letter-spacing: .12em; }
  .kb-search-results .sd-item { padding: 10px 9px; gap: 11px; min-height: 60px; border-radius: 13px; animation: none; }
  .kb-search-results .sd-ico { width: 44px; height: 44px; border-radius: 12px; }
  .kb-search-results .sd-ico img { display: block; width: 100%; height: 100%; object-fit: contain; }
  .kb-search-results .sd-name { min-width: 0; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
  .kb-search-results .sd-name small { margin-top: 3px; font-size: 11px; font-weight: 450; }
  .kb-search-results .sd-price { font-size: 12px; flex: none; }
  .kb-search-results .sd-tags { gap: 9px; padding: 0 8px 15px; }
  .kb-search-results .sd-tags a { font-weight: 600; font-size: 12px; padding: 8px 12px; background: var(--surface, #19263b); border-color: var(--line2); }
  .kb-search-results .sd-recent { padding: 11px 10px; font-size: 13px; }
  .kb-search-results .sd-all { margin: 8px 4px; padding: 13px 15px; border-radius: 13px; font-size: 13px; }
  .kb-search-bottom { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; gap: 10px; padding: 14px 3px 0; font-size: 11px; color: var(--mut, #8e9aac); }
  .kb-search-bottom a { color: #589eff; font-weight: 700; text-decoration: none; }
  .kb-search-bottom a i { margin-right: 5px; }
  .kb-search-bottom > span i { color: #e9b647; }
  .kb-search-close:focus-visible, .kb-search-go:focus-visible, .kb-search-clear:focus-visible, .kb-search-results a:focus-visible { outline: 2px solid #5eaaff; outline-offset: 2px; }
}
@media (max-width: 390px) {
  .kb-search-shell { padding-left: 12px; padding-right: 12px; }
  .kb-search-intro { margin-top: 26px; }
  .kb-search-intro h2 { font-size: 30px; }
  .kb-search-main { margin-top: 16px; padding: 12px 8px 8px; }
  .kb-search-bottom > span { display: none; }
  .kb-search-results .sd-price { max-width: 94px; white-space: normal; text-align: right; }
  .kb-search-results .sd-item { padding-left: 5px; padding-right: 5px; gap: 7px; }
}
@media (max-width: 991.98px) and (max-height: 670px) {
  .kb-search-intro { margin: 14px 0 12px; }
  .kb-search-intro p { display: none; }
  .kb-search-form { height: 55px; }
  .kb-search-go { width: 44px; height: 44px; }
  .kb-search-main { margin-top: 14px; }
}
@media (min-width: 992px) { .kb-search-overlay { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .kb-search-overlay *, .bottom-nav.d-lg-none * { animation: none !important; transition: none !important; } }

/* ============================================================================
   KIBERHUB DESIGN SYSTEM v5 / HEADER, CATALOG, SMALL SCREENS
   Reason: safe 100% width layout, toolbar wrapped into real responsive columns,
   active grid/list contrast restored in light theme, single-row mobile header.
   ============================================================================ */
:root { --kb-blue: #2478ee; --kb-blue-hi: #4ca3ff; }
html { max-width: 100%; overflow-x: clip; }
body { max-width: 100%; overflow-x: clip; }
.site-header, .main-nav, .page-fade, main { max-width: 100%; min-width: 0; }
.page-fade > .container, main > .container, .container { min-width: 0; }
.row > [class^="col-"], .row > [class*=" col-"] { min-width: 0; }
:where(.p-grid, .p-card, .p-card .p-info, .p-card .p-buy, .p-card .p-actions, .toolbar, .sub-tile) { min-width: 0; }
:where(.page-title, .p-name, .p-short, .sub-tile b, .nx-crumbs, .p-sp) { overflow-wrap: anywhere; }
.nx-crumbs { min-width: 0; }
.nx-crumbs .breadcrumb-item { max-width: 100%; }
/* App header: dense, modern and predictable in both themes. */
.site-header { border-bottom: 1px solid var(--line2); }
.site-header .hdr-row { gap: clamp(8px, 1.2vw, 18px); }
.site-header .kb-header-logo { gap: 0; flex-shrink: 0; display: inline-flex; flex-direction: column; align-items: flex-start; justify-content: center; line-height: 1; }
.site-header .kb-logo-tagline { display: none; font-family: 'Inter', sans-serif; letter-spacing: .16em; font-size: 7px; font-weight: 800; color: var(--mut); margin-top: 7px; white-space: nowrap; }
.site-header .hdr-actions { align-items: center; gap: 5px; }
.site-header .hdr-act { display: inline-flex; justify-content: center; align-items: center; min-width: 40px; min-height: 40px; border: 1px solid transparent; border-radius: 13px; padding: 5px 7px; }
.site-header .hdr-act:hover { border-color: var(--line2); background: var(--tint2); color: var(--blue2); }
.site-header .hdr-act:focus-visible { outline: 2px solid var(--kb-blue); outline-offset: 2px; }
.site-header .hdr-ico { font-size: 18px; height: 24px; }
.site-header .hdr-count { border: 2px solid var(--surface); box-shadow: none; top: -11px; right: -13px; }
.site-header .avatar-sm { box-shadow: none; }
/* View panel: never let controls force a wider document. */
.kb-catalog-toolbar {
  display: flex; flex-wrap: nowrap; align-items: flex-end; justify-content: space-between;
  gap: 12px; padding: 13px 15px; border: 1px solid var(--line2); border-radius: 18px;
  background: var(--card); box-shadow: 0 3px 18px rgba(var(--shc), .045);
  min-width: 0; width: 100%;
}
.kb-catalog-toolbar .kb-sort-form { display: flex; flex-wrap: nowrap; min-width: 0; max-width: 100%; gap: 12px; align-items: flex-end; flex: 1 1 auto; }
.kb-catalog-toolbar .kb-sort-field { flex: 0 1 280px; min-width: 0; }
.kb-catalog-toolbar .kb-per-field { flex: 0 0 110px; min-width: 0; }
.kb-catalog-toolbar .kb-sort-field, .kb-catalog-toolbar .kb-per-field { display: flex; flex-direction: column; gap: 6px; }
.kb-catalog-toolbar label, .kb-catalog-toolbar .kb-view-caption { margin: 0; color: var(--mut); font-size: 11px; letter-spacing: .015em; font-weight: 700; line-height: 1.25; white-space: nowrap; }
.kb-catalog-toolbar .form-select.form-select-sm {
  display: block; width: 100%; min-width: 0; max-width: 100%; height: 42px;
  border: 1px solid var(--line2); background-color: var(--surface); color: var(--head);
  border-radius: 12px; font-size: 13px; font-weight: 650;
  padding: 6px 33px 6px 12px; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: none; cursor: pointer;
}
.kb-catalog-toolbar .form-select:focus { border-color: var(--kb-blue); box-shadow: 0 0 0 3px rgba(36,120,238,.13); }
.kb-layout-control { display: flex; align-items: flex-end; gap: 8px; flex: 0 0 auto; }
.kb-catalog-toolbar .kb-view-caption { display: none; }
.kb-catalog-toolbar .view-switch { flex: 0 0 auto; display: flex; align-items: center; gap: 5px; padding: 3px; background: var(--bg2); border-radius: 13px; border: 1px solid var(--line); }
.kb-catalog-toolbar .view-switch button,
[data-theme="light"] .kb-catalog-toolbar .view-switch button {
  display: inline-grid; place-items: center; flex: none; width: 36px; height: 36px;
  background: transparent; border: 1px solid transparent; border-radius: 10px;
  color: var(--mut); padding: 0; box-shadow: none; font-size: 15px;
  transition: background .15s, color .15s, box-shadow .15s, transform .15s;
}
.kb-catalog-toolbar .view-switch button i { display: block; color: inherit; font-size: 15px; line-height: 1; }
/* Later light-theme stylesheet used to paint an active button white! We override with
   a higher specificity and never depend on inherited icon contrast. */
.kb-catalog-toolbar .view-switch button.active,
[data-theme="light"] .kb-catalog-toolbar .view-switch button.active,
[data-theme="dark"] .kb-catalog-toolbar .view-switch button.active {
  background: linear-gradient(145deg, #398dff, #125bd8) !important;
  border-color: #216fdf !important; color: #fff !important;
  box-shadow: 0 3px 10px rgba(24,103,220,.25) !important;
}
.kb-catalog-toolbar .view-switch button.active i { color: #fff !important; }
.kb-catalog-toolbar .view-switch button:not(.active):hover { background: var(--surface) !important; color: var(--blue2) !important; }
.kb-catalog-toolbar .view-switch button:focus-visible { outline: 2px solid var(--kb-blue); outline-offset: 2px; }
/* Consistent product grid / list mode even in nested Bootstrap rows */
#productGrid, #favGrid { width: 100%; max-width: 100%; }
#productGrid.list, #favGrid.list { grid-template-columns: minmax(0,1fr) !important; }
#productGrid.list .p-card, #favGrid.list .p-card { min-width: 0; max-width: 100%; }
/* Layout moves at tablet width rather than pushing into the next virtual viewport. */
@media(max-width: 991.98px) {
  .site-header { box-shadow: 0 3px 18px rgba(var(--shc),.045); }
  .topbar { display: none !important; }
  .site-header .hdr-row, .site-header.scrolled .hdr-row {
    display: flex; flex-direction: row; flex-wrap: nowrap !important; justify-content: space-between;
    align-items: center; min-height: 65px; padding: 11px 0 !important; gap: 7px;
  }
  .site-header .kb-logo-tagline { display: block; }
  .site-header .kb-header-logo { max-width: min(43%, 210px); min-width: 0; }
  .site-header .kb-header-logo picture { max-width: 100%; }
  .site-header .kb-header-logo .logo-img { width: min(100%, 194px); max-width: 100%; height: auto; object-fit: contain; }
  .site-header .hdr-row > .search { display: none !important; }
  .site-header .hdr-actions { margin-left: auto; flex-shrink: 0; gap: 4px; }
  .site-header .hdr-act { height: 39px; width: 39px; min-width: 0; min-height: 0; padding: 0; background: var(--tint2); border: 1px solid var(--line); border-radius: 12px; }
  .site-header .hdr-ico { font-size: 17px; }
  .site-header .kb-head-search { display: none !important; } /* central dock search is clearer */
  .site-header .hdr-actions > .dropdown { min-width: 0; }
  .site-header .hdr-cart { position: relative; }
  .main-nav { border-top: 1px solid var(--line); background: var(--surface); }
  .main-nav .container {
    min-height: 0; max-width: 100%; display: flex; align-items: center;
    gap: 8px; justify-content: space-between; flex-wrap: nowrap;
    padding-top: 9px; padding-bottom: 9px;
  }
  .main-nav .btn-catalog {
    display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    height: 38px; flex: 0 1 auto; min-width: 0; max-width: 56%;
    padding: 0 16px; border-radius: 11px;
    font-size: 12px; text-transform: uppercase; letter-spacing: .06em; font-weight: 850;
    background: linear-gradient(130deg, #3a95ff 0%, #1d68e3 100%);
    box-shadow: none;
  }
  .main-nav .city-dd { flex: 0 1 auto; max-width: 52%; min-width: 0; }
  .main-nav .city-btn { display: flex; align-items: center; justify-content: center; min-width: 0; gap: 7px; max-width: 100%; padding: 7px 9px; background: var(--tint2); border: 1px solid var(--line); border-radius: 11px; color: var(--txt); font-weight: 650; }
  .main-nav .city-btn #cityName { max-width: 140px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .main-nav .city-btn i { flex-shrink: 0; }
  .bottom-nav.d-lg-none { max-width: calc(100% - 20px); }
  .bottom-nav.d-lg-none > :is(a,button) > span:last-child { overflow: visible; text-overflow: clip; }
  .kb-catalog-toolbar { flex-wrap: wrap; align-items: stretch; padding: 12px; gap: 12px; }
  .kb-catalog-toolbar .kb-sort-form { flex: 1 1 100%; width: 100%; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .45fr); gap: 9px; }
  .kb-catalog-toolbar .kb-sort-field, .kb-catalog-toolbar .kb-per-field { min-width: 0; width: auto; flex: initial; }
  .kb-layout-control { border-top: 1px solid var(--line); padding-top: 10px; width: 100%; justify-content: space-between; align-items: center; }
  .kb-catalog-toolbar .kb-view-caption { display: inline; }
  .kb-catalog-toolbar .view-switch { margin-left: auto; }
  .sub-tiles { min-width: 0; }
  .sub-tiles .sub-tile { min-width: 0; }
}
@media(max-width: 575.98px) {
  .site-header .hdr-row, .site-header.scrolled .hdr-row { min-height: 59px; padding: 9px 0 !important; }
  .site-header .kb-header-logo { max-width: min(51%, 188px); }
  .site-header .hdr-actions { gap: 3px; }
  .site-header .hdr-act { width: 37px; height: 37px; border-radius: 11px; }
  /* Cabinet is available from the floating dock, so its duplicate icon is hidden on narrow phones. */
  .site-header .hdr-actions > .dropdown:not(.notif-dd):not(.city-dd) { display: none; }
  .site-header .hdr-actions > a[href="login.php"] { display: none; }
  .site-header .kb-logo-tagline { font-size: 6px; letter-spacing: .12em; margin-top: 6px; }
  .main-nav .btn-catalog { max-width: 50%; padding-inline: 12px; }
  .main-nav .city-dd { max-width: 52%; }
  .main-nav .city-btn { font-size: 12px; gap: 5px; }
  .main-nav .city-btn #cityName { max-width: 120px; }
  .p-grid.cols-3, .p-grid.cols-4, .p-grid.cols-5, .p-grid.cols-6 { grid-template-columns: repeat(2, minmax(0,1fr)) !important; }
  .p-card .p-info { padding: 10px 2px 4px; }
  .p-card .p-buy { padding-left: 2px; padding-right: 2px; }
  .p-card .p-name { font-size: clamp(12px,3.4vw,14px); line-height: 1.36; min-height: 2.72em; }
  .p-card .p-sp, .p-card .p-meta { font-size: 11px; }
  .p-card .p-price b { font-size: clamp(14px, 3.8vw, 18px); white-space: normal; }
  .p-card .p-actions .btn-buy { font-size: 12px; }
  .sub-tiles { grid-template-columns: minmax(0,1fr); gap: 10px; }
  .sub-tiles .sub-tile { border-radius: 16px; padding: 14px 16px; gap: 12px; }
  .sub-tiles .sub-tile .cat-tile-ico { flex: 0 0 46px; width: 46px; height: 46px; border-radius: 13px; }
  .sub-tiles .sub-tile b { font-size: 15px; }
  .crumbs-wrap { padding-top: 13px; padding-bottom: 8px; }
  .nx-crumbs { display: flex; flex-wrap: wrap; white-space: normal; gap: 4px 0; line-height: 1.4; }
  .page-title { line-height: 1.15; }
  /* The fixed navbar must never be wider than the user's viewport. */
  .bottom-nav.d-lg-none { width: calc(100% - 20px); left: 50%; right: auto; }
}
@media(max-width: 374.98px) {
  .site-header .kb-header-logo { max-width: 51%; }
  .site-header .kb-logo-tagline { font-size: 5.5px; letter-spacing: .075em; }
  .site-header .hdr-act { width: 34px; height: 36px; }
  .main-nav .city-btn #cityName { max-width: 102px; }
  .kb-catalog-toolbar .kb-sort-form { grid-template-columns: minmax(0,1fr) 95px; }
  .kb-catalog-toolbar .form-select.form-select-sm { padding-left: 9px; padding-right: 29px; font-size: 12px; }
  .p-card { padding: 8px; }
  .p-grid.cols-3 { gap: 8px; }
}
@media(min-width: 992px) {
  .site-header .kb-logo-tagline { display: none; }
  .kb-catalog-toolbar { flex-wrap: nowrap; }
  .kb-layout-control { align-self: flex-end; }
}
@media(prefers-reduced-motion: reduce) {
  .kb-catalog-toolbar .view-switch button, .site-header .hdr-act { transition: none; }
}
