/**
 * Unified fluid layout for front and admin.
 * Load LAST after style.css / responsive.css / admin.css.
 *
 * Fluid wrap ≠ tear down the chrome:
 * - Text / cards / content grids shrink & wrap as width changes
 * - Nav hamburger, admin sidebar, table scroll shells stay structural
 */

:root {
    --layout-page-padding-x: clamp(0.625rem, 2.5vw, 2.5rem);
    --layout-page-max: 1600px;
    --layout-content-max: 2400px;
    --admin-sidebar-w: 250px;
    --admin-topbar-h: 60px;
    --fluid-col-min: 240px;
}

/* ========== Site-wide fluid text (safe, structure-preserving) ========== */
html {
    overflow-x: clip;
}

body {
    overflow-x: clip;
    max-width: 100%;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* Allow flex/grid children to shrink instead of forcing page overflow */
body :where(
    .main-wrapper,
    .container,
    .content-wrapper-container,
    section,
    article,
    aside,
    .card,
    .product-card,
    .news-card,
    .touchsite-stat-card,
    .admin-layout,
    .admin-content,
    .admin-main,
    .card-body,
    .form-group,
    .form-row,
    .table-responsive,
    .table-responsive-wrap
) {
    min-width: 0;
    max-width: 100%;
}

/* Continuous wrap for readable content (not chrome / code / controls) */
body :where(
    p, h1, h2, h3, h4, h5, h6,
    li, dd, dt, blockquote, figcaption,
    td, th, label, small,
    .card-title, .card-text, .section-title, .section-subtitle,
    .product-name, .product-card-title, .product-info,
    .news-card-title, .news-card-summary, .news-card-excerpt,
    .admin-title, .dashboard-subtitle, .form-help, .help-text,
    .alert, .meta, .excerpt, .description,
    .products-sidebar-nav-text
) {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
}

/* Keep intentional single-line / code / form chrome intact */
body :where(
    pre, code, kbd, samp,
    input, textarea, select, button,
    .btn, .nav-link-rapoo, .nav-item-rapoo,
    .admin-sidebar a, .admin-menu-link, .admin-nav-link,
    .admin-topbar-title, .admin-topbar-btn,
    .pagination-link, .breadcrumb,
    [data-no-wrap], .nowrap, .text-nowrap
),
body :where(pre, code, kbd, samp) * {
    overflow-wrap: normal;
    word-break: normal;
}

/* Media scales inside fluid shells; absolute/cover images keep their own rules */
body :where(img, video, iframe, embed, object) {
    max-width: 100%;
}

body :where(img:not([width]):not([style*="position"]), video) {
    height: auto;
}

/* Content card grids: columns reflow by available width (not viewport breakpoints) */
body:not(.admin-body) :where(
    .product-grid,
    .products-grid,
    .products-grid-rapoo,
    .applications-grid-rapoo,
    .features-grid-rapoo,
    .home-media-grid.is-grid,
    .news-grid:not(.news-grid-single-column),
    .news-list-grid,
    .grid-2, .grid-3, .grid-4,
    .touchsite-stat-list,
    .solution-grid,
    .services-grid,
    .download-grid,
    .faq-grid
) {
    /* Avoid min() wrapping minmax: embedded preview kernel may fail to break columns */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/*
 * Homepage/list overrides: style.css inline column counts block auto-fit above.
 * Determine the number of columns with the actual width of the container，Debug device width same set of logic as true shrinking window。
 * Note: .products-grid-zlan / .solutions-grid column counts come from list template CSS.
 */
body:not(.admin-body) .products-grid-rapoo,
body:not(.admin-body) .applications-grid-rapoo,
body:not(.admin-body) .features-grid-rapoo,
body:not(.admin-body) .home-media-grid.is-grid,
body:not(.admin-body) .news-grid-rapoo {
    display: grid !important;
    /* Embedded preview: avoid min() + minmax failures in some engines */
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Admin content card grids — same idea; sidebar/topbar chrome unchanged */
.admin-body :where(
    .stats-grid,
    .dashboard-command-grid,
    .dashboard-quick-grid,
    .form-grid,
    .admin-cards-grid,
    .grid-2, .grid-3, .grid-4
) {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Flex toolbars wrap instead of overflowing */
body :where(
    .form-actions,
    .page-actions,
    .card-header,
    .toolbar,
    .filter-bar,
    .admin-header,
    .dashboard-header,
    .dashboard-header-meta,
    .dashboard-overview-actions
) {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

/* Tables: cell text wraps; wide tables scroll inside shell (layout stays) */
body :where(table) {
    max-width: 100%;
}

body :where(.table-responsive, .table-responsive-wrap, .admin-content .card-body) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ========== Front-end ========== */

.main-wrapper {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Top bar: fluid padding, stay within viewport */
.navbar-container-rapoo {
    width: 100%;
    max-width: min(var(--layout-page-max), 100%);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--layout-page-padding-x);
    padding-right: var(--layout-page-padding-x);
    box-sizing: border-box;
    min-width: 0;
}

.nav-brand-rapoo,
.nav-search-rapoo {
    min-width: 0;
}

.nav-menu-rapoo {
    min-width: 0;
}

/* Main content containers: shared horizontal padding and box model */
.container {
    width: 100%;
    max-width: min(var(--layout-content-max), 100%);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--layout-page-padding-x);
    padding-right: var(--layout-page-padding-x);
    box-sizing: border-box;
}

/* Product list/detail: full width so sidebar does not center when narrowed */
body.products .container,
body.product-detail .container,
body.product-list .container,
body.product .container {
    max-width: 100%;
}

body:not(.home):not(.products):not(.product-detail):not(.product-list):not(.product) .container {
    max-width: min(1200px, 100%);
}

/* Product two-column layout full width; sidebar flush left */
body.products .products-layout,
body.product-detail .products-layout {
    max-width: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
}

.content-wrapper-container {
    width: 100%;
    max-width: min(1600px, 100%);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--layout-page-padding-x);
    padding-right: var(--layout-page-padding-x);
    box-sizing: border-box;
}

/* Button groups: wrap without overflow */
.form-actions,
.page-actions,
.card-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    min-width: 0;
}

.main-wrapper .btn {
    max-width: 100%;
    box-sizing: border-box;
}

.footer .container {
    width: 100%;
    max-width: min(var(--layout-page-max), 100%);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--layout-page-padding-x);
    padding-right: var(--layout-page-padding-x);
    box-sizing: border-box;
}

/* ========== Admin ========== */
.admin-body {
    overflow-x: clip;
    max-width: 100%;
}

.admin-layout {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Top bar: grid instead of absolute positioning to avoid overlap on narrow widths */
.admin-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    column-gap: 0.75rem;
    padding-left: var(--layout-page-padding-x);
    padding-right: var(--layout-page-padding-x);
    box-sizing: border-box;
}

.admin-topbar-left {
    justify-self: start;
    min-width: 0;
}

.admin-topbar-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: min(40ch, 100%);
}

.admin-topbar-center {
    position: static !important;
    left: auto !important;
    top: auto !important;
    transform: none !important;
    justify-self: center;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    max-width: 100%;
    min-width: 0;
}

.admin-topbar-right {
    justify-self: end;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    min-width: 0;
}

.admin-topbar-btn {
    max-width: 100%;
    box-sizing: border-box;
}

/* Main area width: avoid margin-left + 100% causing horizontal scrollbar */
.admin-sidebar {
    width: var(--admin-sidebar-w);
}

.admin-content {
    width: calc(100% - var(--admin-sidebar-w));
    max-width: calc(100% - var(--admin-sidebar-w));
    margin-left: var(--admin-sidebar-w);
    min-width: 0;
    box-sizing: border-box;
    padding: 0 clamp(0.75rem, 2vw, 2rem) clamp(0.75rem, 2vw, 2rem);
}

.sidebar-collapsed .admin-content {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
}

/* Sidebar toggle follows sidebar width */
.admin-sidebar-toggle {
    left: calc(var(--admin-sidebar-w) - 12px);
}

.sidebar-collapsed .admin-sidebar-toggle {
    left: 12px;
}

/* Admin header, stats, cards */
.admin-header {
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: flex-start;
}

.admin-title {
    font-size: clamp(1.25rem, 2.5vw, 2rem);
    word-break: break-word;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

/* Tables and card bodies: horizontal scroll instead of breaking layout */
.admin-content .card-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    min-width: 0;
}

.admin-content .table,
.admin-content table {
    width: 100%;
    max-width: 100%;
    border-collapse: collapse;
}

.admin-content .table-responsive-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

/* Resizable dual panes: stack on narrow screens to avoid min-width scrollbars */
@media (max-width: 900px) {
    .admin-resizable-panels {
        flex-direction: column !important;
    }

    .admin-resizable-panel {
        min-width: 0 !important;
        flex: 1 1 auto !important;
    }

    .admin-resize-handle {
        width: 100% !important;
        height: 8px !important;
        min-height: 8px;
        cursor: row-resize;
    }
}

@media (max-width: 1024px) {
    :root {
        --admin-sidebar-w: 200px;
    }
}

@media (max-width: 768px) {
    .admin-topbar {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
        height: auto;
        min-height: var(--admin-topbar-h);
        row-gap: 0.5rem;
    }

    .admin-topbar-left,
    .admin-topbar-center,
    .admin-topbar-right {
        justify-self: stretch;
        width: 100%;
    }

    .admin-topbar-center {
        justify-content: flex-start;
        padding-top: 0.25rem;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
    }

    .admin-topbar-right {
        justify-content: flex-end;
    }

    .products-admin-tabs {
        flex-wrap: wrap;
    }

    .products-admin-tab {
        min-width: 0;
        flex: 1 1 min(100%, 200px);
    }
}

/* ========== Admin sidebar collapse (must win over admin.css / admin-flat conflicts) ========== */
.admin-sidebar {
    position: fixed !important;
    top: var(--admin-topbar-h, 56px) !important;
    left: 0 !important;
    bottom: 0 !important;
    width: var(--admin-sidebar-w) !important;
    max-width: min(var(--admin-sidebar-w), 85vw) !important;
    height: auto !important;
    transform: translateX(0) !important;
    transition: transform 0.25s ease !important;
    z-index: 1100 !important;
    overflow-x: hidden !important;
}

.admin-body.sidebar-collapsed .admin-sidebar,
.sidebar-collapsed .admin-sidebar {
    transform: translateX(-100%) !important;
    pointer-events: none !important;
}

.admin-sidebar-toggle {
    position: fixed !important;
    top: calc(50% + (var(--admin-topbar-h, 56px) / 4)) !important;
    left: calc(var(--admin-sidebar-w) - 1px) !important;
    right: auto !important;
    transform: translateY(-50%) !important;
    z-index: 1200 !important;
    width: 22px !important;
    height: 52px !important;
    margin: 0 !important;
    border: 1px solid #111827 !important;
    border-left: none !important;
    border-radius: 0 10px 10px 0 !important;
    background: #1f2937 !important;
    color: #ffffff !important;
    box-shadow: 2px 0 8px rgba(15, 23, 42, 0.2) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    font-size: 16px !important;
    font-weight: 700 !important;
    transition: left 0.25s ease, background 0.15s ease, color 0.15s ease !important;
}

.admin-body.sidebar-collapsed .admin-sidebar-toggle,
.sidebar-collapsed .admin-sidebar-toggle {
    left: 0 !important;
    border-left: 1px solid #111827 !important;
    border-right: 1px solid #111827 !important;
    border-radius: 0 10px 10px 0 !important;
    pointer-events: auto !important;
    background: #1f2937 !important;
    color: #ffffff !important;
}

.admin-sidebar-toggle:hover {
    background: #2563eb !important;
    color: #ffffff !important;
}

.admin-body.sidebar-collapsed .admin-content,
.sidebar-collapsed .admin-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

/* Narrow window: sidebar overlays content (no permanent left margin) */
@media (max-width: 1024px) {
    .admin-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .admin-body:not(.sidebar-collapsed) .admin-sidebar {
        box-shadow: 8px 0 28px rgba(15, 23, 42, 0.18) !important;
    }

    .admin-body:not(.sidebar-collapsed)::after {
        content: '';
        position: fixed;
        inset: var(--admin-topbar-h, 56px) 0 0 0;
        background: rgba(15, 23, 42, 0.35);
        z-index: 1090;
        pointer-events: auto;
    }

    .admin-body.sidebar-collapsed::after {
        display: none;
    }
}

/* ========== News list / detail: left wide, right narrow + force wrap ========== */
.news-section .content-wrapper-container,
.article-main .container {
    container-type: inline-size;
    container-name: news-shell;
}

.news-layout-with-sidebar {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(var(--lt-side-min, 220px), var(--lt-side-w, 300px)) !important;
    gap: var(--lt-gap, 1.75rem) !important;
    align-items: start !important;
    width: 100% !important;
    min-width: 0 !important;
}

.news-content-main,
.news-ranking-sidebar,
.article-detail-main,
.article-detail-sidebar {
    min-width: 0 !important;
}

.news-ranking-sidebar {
    max-width: var(--lt-side-w, 300px) !important;
    width: 100% !important;
    max-height: none !important;
    overflow: visible !important;
}

.article-detail-layout {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) minmax(220px, 300px) !important;
    gap: 1.5rem 2rem !important;
    align-items: start !important;
    width: 100% !important;
    min-width: 0 !important;
}

.article-detail-sidebar {
    max-width: 300px !important;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Kill leftover nowrap / ellipsis that blocked shrink wrapping (keep ranking / aside titles single-line) */
.news-ranking-link,
.news-card-title,
.news-card-title a,
.news-card-summary,
.news-card-meta,
.news-card-category,
.news-card-link,
.news-tag-item,
.article-detail-title,
.article-detail-summary,
.article-detail-body,
.article-detail-body p,
.article-detail-body h1,
.article-detail-body h2,
.article-detail-body h3,
.article-detail-body h4,
.article-detail-body li,
.article-detail-body td,
.article-detail-body th,
.article-detail-body span,
.article-detail-body a,
.article-aside-card p,
.article-aside-meta li span {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

.news-ranking-text,
.news-ranking-title,
.article-aside-card h2,
.article-latest-text {
    min-width: 0 !important;
    max-width: 100% !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
}

.article-detail-body [style*="white-space:nowrap"],
.article-detail-body [style*="white-space: nowrap"],
.news-card [style*="white-space:nowrap"],
.news-card [style*="white-space: nowrap"] {
    white-space: normal !important;
}

.article-detail-body table {
    display: block;
    max-width: 100%;
    overflow-x: auto;
}

@container news-shell (max-width: 1024px) {
    .news-layout-with-sidebar,
    .article-detail-layout {
        grid-template-columns: 1fr !important;
    }

    .news-ranking-sidebar,
    .article-detail-sidebar {
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .news-content-main .news-card,
    .news-card {
        grid-template-columns: 1fr !important;
    }

    .news-content-main .news-card-image,
    .news-card-image {
        width: min(var(--lt-img-w, 300px), 86%) !important;
        max-width: min(var(--lt-img-w, 300px), 86%) !important;
        margin: 0.85rem auto 0.25rem !important;
        justify-self: center !important;
    }
}

@media (max-width: 1024px) {
    .news-layout-with-sidebar,
    .article-detail-layout {
        grid-template-columns: 1fr !important;
    }

    .news-ranking-sidebar,
    .article-detail-sidebar {
        max-width: none !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .news-content-main .news-card,
    .news-card {
        grid-template-columns: 1fr !important;
    }

    .news-content-main .news-card-image,
    .news-card-image {
        width: min(var(--lt-img-w, 300px), 86%) !important;
        max-width: min(var(--lt-img-w, 300px), 86%) !important;
        margin: 0.85rem auto 0.25rem !important;
        justify-self: center !important;
    }

    .news-card-title,
    .news-card-title a,
    .news-card-summary,
    .news-card-body,
    .news-card-text {
        min-width: 0 !important;
        max-width: 100% !important;
        white-space: normal !important;
        overflow-wrap: anywhere !important;
        word-break: break-word !important;
    }
}

/* ========== Unified fluid shells (container width, not viewport) ========== */
.home-layout-root,
.home-chrome-block,
.products-section-rapoo,
.applications-section-rapoo,
.features-section-rapoo,
.products-tab-content-rapoo,
.main-content .container,
.home-layout-root .container,
.content-wrapper-container {
    container-type: inline-size;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

@container (max-width: 900px) {
    .products-grid-rapoo,
    .applications-grid-rapoo,
    .features-grid-rapoo,
    .home-media-grid.is-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

@container (max-width: 560px) {
    .products-grid-rapoo,
    .applications-grid-rapoo,
    .features-grid-rapoo,
    .home-media-grid,
    .home-media-grid.is-grid,
    .home-media-grid.is-puzzle {
        grid-template-columns: 1fr !important;
    }

    .home-media-item {
        grid-column: auto !important;
        grid-row: auto !important;
    }
}

/* Debug device width: same goal as container queries; beat inline !important */
/* Product/scenario list columns from list template; this file handles homepage grids */
html.debug-device-tablet .products-grid-rapoo,
html.debug-device-tablet .applications-grid-rapoo,
html.debug-device-tablet .features-grid-rapoo,
html.debug-device-tablet .home-media-grid.is-grid,
html.debug-device-tablet .news-grid-rapoo {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

html.debug-device-mobile .products-grid-rapoo,
html.debug-device-mobile .applications-grid-rapoo,
html.debug-device-mobile .features-grid-rapoo,
html.debug-device-mobile .home-media-grid,
html.debug-device-mobile .home-media-grid.is-grid,
html.debug-device-mobile .home-media-grid.is-puzzle,
html.debug-device-mobile .news-grid-rapoo {
    grid-template-columns: 1fr !important;
}

html.debug-device-mobile .home-media-item,
html.debug-device-tablet .home-media-item {
    grid-column: auto !important;
    grid-row: auto !important;
    min-width: 0 !important;
    max-width: 100% !important;
}

/* Home News Card Copywriting Is Always Decisive */
.news-item-rapoo,
.news-link-rapoo,
.news-content-rapoo,
.news-title-rapoo,
.news-summary-rapoo,
.news-meta-rapoo {
    min-width: 0 !important;
    max-width: 100% !important;
}

.news-title-rapoo,
.news-summary-rapoo {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
}

/* News tabs: wrap when narrow */
.news-tabs-rapoo {
    display: flex !important;
    flex-wrap: wrap !important;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
}

.news-tab-rapoo {
    min-width: 0 !important;
    white-space: normal !important;
}

/* Homepage product/app/feature card copy: always decisive */
.product-item-rapoo,
.product-info-rapoo,
.product-name-rapoo,
.product-desc-rapoo,
.home-media-item,
.home-media-caption,
.application-card-rapoo,
.feature-card-rapoo {
    min-width: 0 !important;
    max-width: 100% !important;
}

.product-name-rapoo,
.product-desc-rapoo,
.home-media-caption,
.home-media-caption *,
.application-title-rapoo,
.application-desc-rapoo,
.feature-title-rapoo,
.feature-desc-rapoo,
.section-title-rapoo,
.section-subtitle-rapoo {
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    max-width: 100% !important;
}

/* Product tabs: 1x4 wide; 2x2 when narrow (4 tabs) */
.products-tabs-rapoo,
.products-tabs-inner-rapoo {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
    gap: 0 !important;
    min-width: 0 !important;
    max-width: 100% !important;
    width: 100% !important;
    box-sizing: border-box !important;
    overflow: visible !important;
}

.products-tabs-rapoo .products-tab-rapoo,
.products-tabs-inner-rapoo .products-tab-rapoo {
    flex: none !important;
    min-width: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    white-space: normal !important;
    text-align: center !important;
    box-sizing: border-box !important;
}

/* Narrow container: two rows, two columns */
@container (max-width: 960px) {
    .products-tabs-rapoo,
    .products-tabs-inner-rapoo {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .products-tabs-rapoo .products-tab-rapoo,
    .products-tabs-inner-rapoo .products-tab-rapoo {
        border-right: 1px solid rgba(255, 255, 255, 0.2) !important;
        border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
    }

    .products-tabs-rapoo .products-tab-rapoo:nth-child(2n),
    .products-tabs-inner-rapoo .products-tab-rapoo:nth-child(2n) {
        border-right: none !important;
    }

    .products-tabs-rapoo .products-tab-rapoo:nth-last-child(-n+2),
    .products-tabs-inner-rapoo .products-tab-rapoo:nth-last-child(-n+2) {
        border-bottom: none !important;
    }
}

/* Debug device width / viewport fallback when CQ misses */
@media (max-width: 960px) {
    .products-tabs-rapoo,
    .products-tabs-inner-rapoo {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

html.debug-device-mobile .products-tabs-rapoo,
html.debug-device-tablet .products-tabs-rapoo,
html.debug-device-mobile .products-tabs-inner-rapoo,
html.debug-device-tablet .products-tabs-inner-rapoo {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

/*
 * Cursor side preview: viewport may stay wide so @media does not fire,
 * but panel is narrow → use container queries / wrapping.
 */
.news-section-rapoo,
.news-section-rapoo .container,
.contact-main,
.contact-container,
.contact-page .container,
.contact-form-section .container,
.news-section,
.article-main {
    container-type: inline-size;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

@container (max-width: 960px) {
    /* Contact main column: higher specificity over wide two-column !important */
    .contact-main .contact-wrapper,
    .contact-container .contact-wrapper,
    .content-wrapper-container .contact-wrapper,
    .contact-form-wrapper,
    .contact-hero-inner,
    .contact-map-wrapper,
    .contact-channel-grid,
    .contact-summary-grid,
    .contact-sales-grid,
    .contact-offices-grid,
    .contact-metrics-grid {
        grid-template-columns: 1fr !important;
        gap: 1.5rem !important;
    }

    .contact-form-card .form-grid,
    .contact-form .form-row {
        grid-template-columns: 1fr !important;
    }

    .news-layout-with-sidebar,
    .article-detail-layout {
        grid-template-columns: 1fr !important;
    }

    .news-ranking-sidebar,
    .article-detail-sidebar {
        max-width: 100% !important;
        width: 100% !important;
    }

    .news-grid-rapoo {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .news-tabs-rapoo {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: stretch !important;
        gap: 0 !important;
    }

    .news-tab-rapoo {
        flex: 1 1 40% !important;
        min-width: 0 !important;
        justify-content: center !important;
        white-space: normal !important;
    }
}

@container (max-width: 720px) {
    .news-grid:not(.news-grid-single-column),
    .news-list-grid,
    .news-grid-rapoo,
    .contact-gallery-grid,
    .contact-channel-grid {
        grid-template-columns: 1fr !important;
    }
}

/* Footer contact forms: auto-fit columns; .contact-wrapper controlled in page CSS */
body:not(.admin-body) .contact-form-wrapper {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)) !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

body:not(.admin-body) .contact-info,
body:not(.admin-body) .contact-form-container,
body:not(.admin-body) .contact-form-intro,
body:not(.admin-body) .contact-form-card {
    min-width: 0 !important;
    max-width: 100% !important;
}

/* Front-end: force wrap in narrow preview; match Chrome full-screen */
body:not(.admin-body) .main-wrapper :where(
    .container, .content-wrapper-container, section, article, .card,
    .news-card, .product-card, .contact-info, .contact-form-container
) {
    min-width: 0;
    max-width: 100%;
}

body:not(.admin-body) :where(
    p, h1, h2, h3, h4, h5, h6, li, td, th, label,
    .section-title, .section-subtitle, .card-title, .card-text
) {
    overflow-wrap: break-word;
    word-wrap: break-word;
}
