/* ============================================
   WS Theme switching (dark / light) + Home header
   ============================================ */

/* ---------- Site background: flat colors from provided design assets ---------- */
html:not([data-theme="light"]) body,
html:not([data-theme="light"]) .app {
    background: #14161c !important;
    animation: none !important;
}

html[data-theme="light"] body,
html[data-theme="light"] .app {
    background: #ffffff !important;
    animation: none !important;
}

/* ---------- iOS optimizations ---------- */
/* Horizontal ribbons: momentum scroll, GPU layer, no snap fights */
.category-group-container {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y;
    transform: translateZ(0);
}

/* Expanded grid must never clip or keep stale horizontal scroll */
.category-group-block.expanded .category-group-container {
    overflow-x: visible !important;
    touch-action: pan-y;
    transform: none;
}

/* Banner track on its own GPU layer for smooth swipe */
.toty-banner .banner-track {
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Prevent iOS double-tap zoom + text-select flicker on interactive elements */
.product-card,
.category-card-wrapper,
.filter-chip,
.nav-link,
.toty-banner {
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* ---------- Liquid glass (glassmorphism) surfaces (search, toggle, nav, chips) ---------- */
.ws-search-bar,
.ws-theme-toggle,
.bottom-nav .nav-container,
.filter-chip {
    background: rgba(255, 255, 255, 0.06) !important;
    backdrop-filter: blur(18px) saturate(160%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.15),
        0 8px 24px rgba(0, 0, 0, 0.25);
}

html[data-theme="light"] .ws-search-bar,
html[data-theme="light"] .ws-theme-toggle,
html[data-theme="light"] .bottom-nav .nav-container,
html[data-theme="light"] .filter-chip {
    background: rgba(255, 255, 255, 0.45) !important;
    backdrop-filter: blur(18px) saturate(170%);
    -webkit-backdrop-filter: blur(18px) saturate(170%);
    border: 1px solid rgba(255, 255, 255, 0.65) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.8),
        0 8px 24px rgba(60, 150, 90, 0.12);
}

/* ---------- Product cards: reference design (rounded, overlapping badge, pill button) ---------- */
.product-card {
    overflow: visible !important;
    border-radius: 16px !important;
    border: none !important;
    background: #1b1e25 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
}

.product-card .product-image {
    border-radius: 16px 16px 0 0 !important;
    overflow: hidden !important;
    border-bottom: none;
}

.product-card .product-content {
    background: #1b1e25 !important;
    border-radius: 0 0 16px 16px !important;
    padding: 10px 12px 12px;
}

.product-card .product-title {
    font-size: 14px;
    font-weight: 700;
}

.product-card .price-current {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.product-card .price-old {
    font-size: 12px;
    font-weight: 600;
}

.product-card .product-button {
    border-radius: 999px !important;
    background: #35e07c !important;
    color: #073b1e !important;
    font-weight: 600 !important;
    font-size: 13px;
    padding: 8px 12px !important;
}

@media (hover: hover) and (pointer: fine) {
    .product-card .product-button:hover {
        background: #4aeb8d !important;
        color: #073b1e !important;
    }
}

/* Light theme: white card like the reference */
html[data-theme="light"] .product-card,
html[data-theme="light"] .product-card .product-content {
    background: #ffffff !important;
    box-shadow: 0 8px 24px rgba(10, 15, 20, 0.1) !important;
}

html[data-theme="light"] .product-card .product-title,
html[data-theme="light"] .product-card .price-current {
    color: #14181d !important;
}

html[data-theme="light"] .product-card .price-old {
    color: rgba(10, 15, 20, 0.4) !important;
}

/* "Еще N >" count pill on light theme */
html[data-theme="light"] .category-group-action-container {
    background: rgba(10, 15, 20, 0.06) !important;
    border-color: rgba(10, 15, 20, 0.1) !important;
    color: #14181d !important;
}

/* ---------- Section filter chips: solid dark pills like the reference ---------- */
.filter-chip {
    background: #1d2024 !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    color: #ffffff !important;
    font-weight: 700 !important;
    font-size: 12px !important;
    padding: 6px 12px !important;
    height: auto !important;
    border-radius: 999px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.filter-chip:hover {
    background: #262a2f !important;
    color: #ffffff !important;
}

.filter-chip.active {
    background: var(--accent, #21bc60) !important;
    border-color: var(--accent, #21bc60) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(33, 188, 96, 0.35);
}

html[data-theme="light"] .filter-chip {
    background: #ffffff !important;
    border: 1px solid rgba(10, 15, 20, 0.1) !important;
    color: #14181d !important;
    box-shadow: 0 2px 8px rgba(10, 15, 20, 0.06);
}

html[data-theme="light"] .filter-chip:hover {
    background: #f2f5f2 !important;
    color: #14181d !important;
}

html[data-theme="light"] .filter-chip.active {
    background: var(--accent, #21bc60) !important;
    border-color: var(--accent, #21bc60) !important;
    color: #ffffff !important;
}

/* Category rows and "Popular" lie directly on the page background: no frames */
#page-home .home-block,
#page-home .category-group-block {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    border-radius: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
}

/* ---------- Prettier loading splash ---------- */
.loader {
    background:
        radial-gradient(ellipse 80% 60% at 50% 20%, rgba(0, 230, 91, 0.16), transparent 65%),
        radial-gradient(ellipse 60% 40% at 20% 95%, rgba(0, 230, 91, 0.08), transparent 60%),
        #070b08 !important;
}

html[data-theme="light"] .loader {
    background:
        radial-gradient(ellipse 80% 60% at 50% 20%, rgba(72, 220, 120, 0.25), transparent 65%),
        radial-gradient(ellipse 60% 40% at 20% 95%, rgba(140, 235, 120, 0.18), transparent 60%),
        #f2faf0 !important;
}

.loader-brand {
    font-size: 30px !important;
    letter-spacing: 6px !important;
    background: linear-gradient(120deg, #00e65b 20%, #b8ffd0 50%, #00e65b 80%);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: loaderShine 2.2s linear infinite !important;
    text-shadow: none;
    filter: drop-shadow(0 0 18px rgba(0, 230, 91, 0.45));
}

@keyframes loaderShine {
    0% { background-position: 200% center; }
    100% { background-position: 0% center; }
}

.loader .spinner {
    width: 44px !important;
    height: 44px !important;
    filter: drop-shadow(0 0 10px rgba(0, 230, 91, 0.5));
}

/* ---------- Home header (logo + search + toggle) ---------- */
.ws-home-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 10px 0 4px;
}

.ws-home-logo {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ws-home-logo img {
    height: 30px;
    width: auto;
    object-fit: contain;
}

.ws-search-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ws-search-bar {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    height: 38px;
    padding: 0 14px;
    border-radius: var(--radius-full);
    background: var(--search-bg, rgba(255, 255, 255, 0.08));
    border: 1px solid var(--border);
    transition: background 0.3s ease, border-color 0.3s ease;
}

.ws-search-bar svg {
    flex-shrink: 0;
    color: var(--text-secondary);
}

.ws-search-bar input {
    flex: 1;
    min-width: 0;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
}

.ws-search-bar input::placeholder {
    color: var(--text-secondary);
}

/* Slider-style theme toggle: knob slides left (dark) <-> right (light) */
.ws-theme-toggle {
    flex-shrink: 0;
    width: 72px;
    height: 36px;
    padding: 4px;
    border-radius: var(--radius-full);
    background: var(--search-bg, rgba(255, 255, 255, 0.08));
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    cursor: pointer;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.ws-theme-toggle .ws-toggle-knob {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--toggle-knob-bg, #1c1f24);
    color: var(--toggle-knob-fg, #ffffff);
    transition: background 0.3s ease, color 0.3s ease, transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateX(0);
}

html[data-theme="light"] .ws-theme-toggle .ws-toggle-knob {
    transform: translateX(30px);
}

/* Hide the original lower search bar on home (top one replaces it) */
#page-home div[style*="margin-top: 16px"]:has(#homeSearchInput),
#homeSearchResults {
    display: none !important;
}

/* ---------- Bottom nav like the mockup: icons + labels, active = green ---------- */
.bottom-nav .nav-link {
    width: 60px !important;
    height: auto !important;
    padding: 6px 0 4px !important;
    border-radius: 14px !important;
    flex-direction: column !important;
    gap: 3px !important;
    font-size: 10px !important;
}

.bottom-nav .nav-link svg {
    width: 24px !important;
    height: 24px !important;
}

.bottom-nav .nav-label {
    display: block !important;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    font-family: 'Nunito', 'Inter', sans-serif;
}

.bottom-nav .nav-link.active {
    background: none !important;
    color: var(--accent, #00e65b) !important;
}

.bottom-nav .nav-container {
    padding: 8px 10px;
    border-radius: 26px;
}

/* ---------- Desktop sizes ---------- */
@media (min-width: 768px) {
    .ws-home-header {
        gap: 18px;
        padding: 18px 0 8px;
    }

    .ws-home-logo img {
        height: 42px;
    }

    .ws-search-bar {
        height: 42px;
        padding: 0 16px;
    }

    .ws-search-bar input {
        font-size: 16px;
    }

    .ws-theme-toggle {
        width: 84px;
        height: 42px;
        padding: 5px;
    }

    .ws-theme-toggle .ws-toggle-knob {
        width: 30px;
        height: 30px;
    }

    html[data-theme="light"] .ws-theme-toggle .ws-toggle-knob {
        transform: translateX(36px);
    }

    .bottom-nav {
        max-width: 520px;
    }

    .bottom-nav .nav-link {
        width: 76px !important;
    }

    .bottom-nav .nav-link svg {
        width: 26px !important;
        height: 26px !important;
    }

    .bottom-nav .nav-label {
        font-size: 11px;
    }
}

/* ---------- Category banner sizing ---------- */
#categoryBannerWrap img {
    max-height: 240px;
}

@media (min-width: 768px) {
    #categoryBannerWrap img {
        max-height: 340px;
        aspect-ratio: auto !important;
        object-fit: cover;
    }
}

/* ---------- Mini action pills like the mockup: vivid filled buttons ---------- */
.ws-home-logo {
    display: none !important;
}

.mini-actions-row .mini-action-btn {
    padding: 10px 16px !important;
    border-radius: 999px !important;
    font-size: 13px !important;
    font-weight: 800 !important;
    color: #ffffff !important;
    border: none !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.mini-actions-row .mini-action-btn svg {
    width: 15px !important;
    height: 15px !important;
    color: #ffffff !important;
}

/* Reviews - blue (stronger gradient) */
.mini-actions-row .mini-action-btn:nth-child(1 of .mini-action-btn) {
    background: linear-gradient(135deg, #4db5ff 0%, #0a5fd6 100%) !important;
}

/* Top up - teal/green (stronger gradient) */
.mini-actions-row .mini-action-btn:nth-child(2 of .mini-action-btn) {
    background: linear-gradient(135deg, #17e8c0 0%, #048767 100%) !important;
}

/* Roulette - purple/violet (stronger gradient) */
.mini-actions-row .mini-action-btn:nth-child(3 of .mini-action-btn) {
    background: linear-gradient(135deg, #6420e8 0%, #c26bff 100%) !important;
}

/* Bonuses - yellow-green (stronger gradient) */
.mini-actions-row .mini-action-btn:nth-child(4 of .mini-action-btn) {
    background: linear-gradient(135deg, #c3e024 0%, #669404 100%) !important;
}

/* ============================================
   LIGHT THEME
   ============================================ */
html[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-tertiary: #f1f3f5;

    --bg-card: #ffffff;
    --bg-card-hover: #f6f7f8;

    --text-primary: #101214;
    --text-secondary: rgba(10, 15, 20, 0.6);
    --text-muted: rgba(10, 15, 20, 0.38);

    --border: rgba(10, 15, 20, 0.08);
    --border-active: rgba(0, 200, 83, 0.55);

    --gradient-dark: linear-gradient(180deg, rgba(0, 0, 0, 0.035) 0%, rgba(0, 0, 0, 0.01) 100%);

    --shadow-sm: 0 2px 8px rgba(20, 30, 40, 0.08);
    --shadow-md: 0 8px 24px rgba(20, 30, 40, 0.1);
    --shadow-lg: 0 16px 48px rgba(20, 30, 40, 0.14);
    --shadow-accent: 0 8px 32px rgba(0, 200, 83, 0.18);

    --search-bg: #e2e4e7;
    --toggle-knob-bg: #14161a;
    --toggle-knob-fg: #ffffff;
}

html[data-theme="light"],
html[data-theme="light"] body {
    background: #ffffff !important;
    --tg-theme-bg-color: #ffffff;
    --tg-theme-secondary-bg-color: #ffffff;
}

html[data-theme="light"] body::before,
html[data-theme="light"] body::after {
    opacity: 0.07;
}

/* Common surfaces that hardcode dark colors.
   Paint only the rounded .nav-container, keep the outer .bottom-nav transparent
   so no square corners peek out behind the rounded panel. */
html[data-theme="light"] .bottom-nav {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
}

html[data-theme="light"] .bottom-nav .nav-container,
html[data-theme="light"] .side-nav {
    background: rgba(255, 255, 255, 0.94) !important;
    border-color: rgba(10, 15, 20, 0.08) !important;
    backdrop-filter: blur(20px);
    box-shadow: 0 4px 20px rgba(20, 30, 40, 0.12);
}

html[data-theme="light"] .bottom-nav .nav-item,
html[data-theme="light"] .bottom-nav .nav-label {
    color: rgba(10, 15, 20, 0.5) !important;
}

html[data-theme="light"] .bottom-nav .nav-item svg {
    color: rgba(10, 15, 20, 0.5) !important;
}

html[data-theme="light"] .bottom-nav .nav-item.active,
html[data-theme="light"] .bottom-nav .nav-item.active svg,
html[data-theme="light"] .bottom-nav .nav-item.active .nav-label {
    color: var(--accent, #21bc60) !important;
}

html[data-theme="light"] .page,
html[data-theme="light"] .home-scroll {
    color: var(--text-primary);
}

html[data-theme="light"] .modal-overlay .modal,
html[data-theme="light"] .product-detail-overlay .product-detail,
html[data-theme="light"] .sheet,
html[data-theme="light"] .card {
    color: var(--text-primary);
}

/* ---------- Light theme: neutralize inline white text/backgrounds (chats, orders, purchases, profile) ---------- */
html[data-theme="light"] [style*="color:#fff"],
html[data-theme="light"] [style*="color: #fff"],
html[data-theme="light"] [style*="color:white"],
html[data-theme="light"] [style*="color: white"] {
    color: #14181d !important;
}

html[data-theme="light"] [style*="color:rgba(255,255,255"],
html[data-theme="light"] [style*="color: rgba(255,255,255"],
html[data-theme="light"] [style*="color: rgba(255, 255, 255"] {
    color: rgba(10, 15, 20, 0.55) !important;
}

/* Translucent white cards/dividers become dark-tinted so they stay visible */
html[data-theme="light"] [style*="background:rgba(255,255,255,0.0"],
html[data-theme="light"] [style*="background: rgba(255,255,255,0.0"],
html[data-theme="light"] [style*="background:rgba(255,255,255,0.1"],
html[data-theme="light"] [style*="background: rgba(255,255,255,0.1"] {
    background: rgba(10, 15, 20, 0.05) !important;
}

html[data-theme="light"] [style*="border-bottom:1px solid rgba(255,255,255"],
html[data-theme="light"] [style*="border-bottom: 1px solid rgba(255,255,255"],
html[data-theme="light"] [style*="border:1px solid rgba(255,255,255"],
html[data-theme="light"] [style*="border: 1px solid rgba(255,255,255"],
html[data-theme="light"] [style*="border-top: 1px solid rgba(255,255,255"] {
    border-color: rgba(10, 15, 20, 0.12) !important;
}

/* Keep white text on colored/gradient buttons and accents */
html[data-theme="light"] [style*="background: linear-gradient"][style*="color"],
html[data-theme="light"] [style*="background:linear-gradient"][style*="color"],
html[data-theme="light"] [style*="background: var(--accent"][style*="color"],
html[data-theme="light"] [style*="background:var(--accent"][style*="color"] {
    color: #ffffff !important;
}

/* Reviews section on light theme (overrides inline dark styles) */
html[data-theme="light"] #reviews-avg-rating {
    background: #ffffff !important;
    border-color: rgba(10, 15, 20, 0.1) !important;
    box-shadow: 0 2px 10px rgba(10, 15, 20, 0.06);
}

html[data-theme="light"] #avg-rating-number {
    color: #14181d !important;
}

html[data-theme="light"] #reviews-count-badge {
    background: rgba(10, 15, 20, 0.07) !important;
}

/* Rating bar tracks (keep green fill inside untouched) */
html[data-theme="light"] #rating-bars-container > div > div {
    background: rgba(10, 15, 20, 0.1) !important;
}

/* Empty stars */
html[data-theme="light"] #avg-rating-stars span[style*="255,255,255"],
html[data-theme="light"] #avg-rating-stars span[style*="255, 255, 255"] {
    color: rgba(10, 15, 20, 0.18) !important;
}

/* "Leave a review" button */
html[data-theme="light"] #home-reviews-section button {
    background: #ffffff !important;
    border-color: rgba(10, 15, 20, 0.12) !important;
}

/* Review cards and any white-tinted inline surfaces inside the section */
html[data-theme="light"] #home-reviews-section div[style*="background: rgba(255, 255, 255"],
html[data-theme="light"] #home-reviews-section div[style*="background: rgba(255,255,255"],
html[data-theme="light"] #home-reviews-section div[style*="background:rgba(255,255,255"] {
    background: #ffffff !important;
    border-color: rgba(10, 15, 20, 0.1) !important;
}

html[data-theme="light"] #home-reviews-section [style*="color: white"],
html[data-theme="light"] #home-reviews-section [style*="color:#fff"],
html[data-theme="light"] #home-reviews-section [style*="color: #fff"] {
    color: #14181d !important;
}

/* ==================== FULL LIGHT THEME ADAPTATION ==================== */

/* Product cards: white surface instead of hardcoded dark */
html[data-theme="light"] .product-card {
    background: #ffffff !important;
    border: 1px solid rgba(10, 15, 20, 0.08) !important;
    box-shadow: 0 2px 10px rgba(10, 15, 20, 0.05);
}

html[data-theme="light"] .product-content {
    background: #ffffff !important;
}

html[data-theme="light"] .product-title,
html[data-theme="light"] .product-price {
    color: #14181d !important;
}

/* Inline white text sitting directly on the page background -> dark.
   Elements with their own inline background (green buttons, chips) are excluded. */
html[data-theme="light"] .page [style*="color: white"]:not([style*="background"]),
html[data-theme="light"] .page [style*="color:white"]:not([style*="background"]),
html[data-theme="light"] .page [style*="color: #fff"]:not([style*="background"]),
html[data-theme="light"] .page [style*="color:#fff"]:not([style*="background"]),
html[data-theme="light"] .page [style*="color: rgb(255, 255, 255)"]:not([style*="background"]) {
    color: #14181d !important;
}

/* ...but keep white text inside banners, sliders and other branded dark surfaces */
html[data-theme="light"] [class*="banner"] [style*="color: white"]:not([style*="background"]),
html[data-theme="light"] [class*="banner"] [style*="color:#fff"]:not([style*="background"]),
html[data-theme="light"] [class*="banner"] [style*="color: #fff"]:not([style*="background"]),
html[data-theme="light"] [id*="banner"] [style*="color: white"]:not([style*="background"]),
html[data-theme="light"] [id*="banner"] [style*="color:#fff"]:not([style*="background"]),
html[data-theme="light"] [id*="banner"] [style*="color: #fff"]:not([style*="background"]),
html[data-theme="light"] [class*="slide"] [style*="color: white"]:not([style*="background"]),
html[data-theme="light"] [class*="slide"] [style*="color: #fff"]:not([style*="background"]),
html[data-theme="light"] [id*="roulette" i] [style*="color: white"]:not([style*="background"]),
html[data-theme="light"] [id*="roulette" i] [style*="color: #fff"]:not([style*="background"]),
html[data-theme="light"] [style*="background: linear-gradient"] [style*="color: white"]:not([style*="background"]),
html[data-theme="light"] [style*="background: linear-gradient"] [style*="color: #fff"]:not([style*="background"]),
html[data-theme="light"] [style*="background: linear-gradient"] [style*="color:#fff"]:not([style*="background"]) {
    color: #ffffff !important;
}

/* Filter chips on category pages: readable on light background */
html[data-theme="light"] .filter-chip {
    background: #ffffff !important;
    border: 1px solid rgba(10, 15, 20, 0.12) !important;
    color: #14181d !important;
}

html[data-theme="light"] .filter-chip.active {
    background: #14181d !important;
    color: #ffffff !important;
    border-color: #14181d !important;
}

/* Semi-transparent white translucent panels -> solid white cards */
html[data-theme="light"] .page [style*="background: rgba(255, 255, 255, 0.0"],
html[data-theme="light"] .page [style*="background: rgba(255,255,255,0.0"],
html[data-theme="light"] .page [style*="background: rgba(255, 255, 255, 0.1"],
html[data-theme="light"] .page [style*="background:rgba(255,255,255,0.0"] {
    background: #ffffff !important;
    border-color: rgba(10, 15, 20, 0.1) !important;
    color: #14181d !important;
}

html[data-theme="light"] .page [style*="background: rgba(255,255,255,0.0"] svg,
html[data-theme="light"] .page [style*="background: rgba(255, 255, 255, 0.0"] svg {
    color: #14181d !important;
}

/* Login page: pale translucent auth buttons -> readable */
html[data-theme="light"] #page-profile button[style*="rgba(0,136,204"],
html[data-theme="light"] #page-profile button[style*="rgba(0, 136, 204"],
html[data-theme="light"] #page-profile a[style*="background: rgba("] {
    color: #14181d !important;
    background: #ffffff !important;
    border-color: rgba(10, 15, 20, 0.15) !important;
}

/* Generic hardcoded dark surfaces inside pages -> white */
html[data-theme="light"] .page [style*="background: rgb(6"],
html[data-theme="light"] .page [style*="background: #0d"],
html[data-theme="light"] .page [style*="background: #16"],
html[data-theme="light"] .page [style*="background: #1a"],
html[data-theme="light"] .page [style*="background: #1c"] {
    background: #ffffff !important;
    color: #14181d !important;
    border-color: rgba(10, 15, 20, 0.1) !important;
}

/* Muted white-ish inline text -> muted dark */
html[data-theme="light"] .page [style*="color: rgba(255, 255, 255, 0."]:not([style*="background"]),
html[data-theme="light"] .page [style*="color: rgba(255,255,255,0."]:not([style*="background"]) {
    color: rgba(10, 15, 20, 0.55) !important;
}

/* Dark knob theme values (defaults for dark theme) — knob clearly visible */
html:not([data-theme="light"]) {
    --search-bg: rgba(255, 255, 255, 0.08);
    --toggle-knob-bg: #3d434b;
    --toggle-knob-fg: #ffffff;
}

html:not([data-theme="light"]) .ws-theme-toggle .ws-toggle-knob {
    border: 1px solid rgba(255, 255, 255, 0.22);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

/* Header must not touch the banner below it */
.ws-home-header {
    margin-bottom: 12px;
}

/* Main layout flex gap: rows were 24px apart */
#home-layout-container {
    gap: 10px !important;
}

/* Compact action pills (like the reference example) */
.mini-actions-row .mini-action-btn {
    padding: 7px 14px !important;
    font-size: 12px !important;
}

.mini-actions-row .mini-action-btn svg {
    width: 13px !important;
    height: 13px !important;
}

/* ---------- Mobile refinements ---------- */
@media (max-width: 767px) {
    /* Raise search panel + theme toggle */
    .ws-home-header {
        padding: 2px 0 0;
        gap: 8px;
        margin-bottom: 10px;
    }

    #home-layout-container {
        gap: 6px !important;
    }

    /* Category icons: slightly larger icons and less rounded */
    .category-card-wrapper {
        width: 68px !important;
    }

    .category-card-wrapper .category-card {
        width: 68px !important;
        height: 68px !important;
        border-radius: 12px !important;
    }

    .category-card-wrapper .category-name,
    .category-card-wrapper > div:last-child {
        font-size: 10px !important;
    }

    #page-home .category-group-container {
        gap: 12px !important;
    }

    /* Smaller action pills on phone */
    .mini-actions-row .mini-action-btn {
        padding: 6px 12px !important;
        font-size: 11px !important;
    }

    .mini-actions-row .mini-action-btn svg {
        width: 12px !important;
        height: 12px !important;
    }

    /* Hide promo cards on mobile */
    #home-promo-cards,
    .promo-cards {
        display: none !important;
    }

    /* Tighter spacing between category rows (games -> apps) */
    #page-home .category-group-block,
    #page-home .home-block {
        margin-top: 2px !important;
        margin-bottom: 2px !important;
        padding-top: 4px !important;
        padding-bottom: 0 !important;
    }

    #page-home .category-group-container {
        padding-bottom: 2px !important;
    }

    /* Bottom nav: slightly smaller and raised */
    .bottom-nav {
        bottom: 14px !important;
    }

    .bottom-nav .nav-container {
        padding: 6px 8px;
        border-radius: 22px;
    }

    .bottom-nav .nav-link {
        width: 54px !important;
        padding: 4px 0 3px !important;
        gap: 2px !important;
    }

    .bottom-nav .nav-link svg {
        width: 21px !important;
        height: 21px !important;
    }

    .bottom-nav .nav-label {
        font-size: 9px;
    }
}


/* ==========================================================================
   AGY OVERRIDES: BORDER CLIPPING, ICON CROPPING & LIGHT THEME READABILITY FIXES
   ========================================================================== */

/* 1. Global fix for rounded corner overflow clipping bug in Safari/WebKit */
/* NOTE: .product-image is intentionally excluded — overflow:hidden + border-radius handle clipping.
   The radial gradient mask was causing dark edge artifacts on product images. */
.product-card,
.category-card,
.filter-category-card,
.purchase-item-card,
.promo-card,
.promo-card-image,
.product-detail-image,
.product-logo,
.ws-search-bar,
.ws-theme-toggle {
    -webkit-mask-image: -webkit-radial-gradient(white, black) !important;
    mask-image: -webkit-radial-gradient(white, black) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    background-clip: padding-box !important;
}

/* Product image container: use standard overflow clipping, no mask needed */
.product-card .product-image {
    -webkit-mask-image: none !important;
    mask-image: none !important;
}

/* Ensure absolute images inside cards do not overlap or cut the border stroke */
.product-card .product-image img,
.product-detail-image img,
.promo-card-image img {
    border-radius: 0 !important;
    box-sizing: border-box !important;
}

/* Fill image container fully, no scale hack needed */
.product-card .product-image img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
}

/* 2. Thicker (2px) Inset box-shadow to paint stroke lines ON TOP of absolute content */
.product-card {
    box-shadow: inset 0 0 0 1.2px rgba(255, 255, 255, 0.12), 0 8px 24px rgba(0, 0, 0, 0.3) !important;
    border-radius: 16px !important;
}

html[data-theme="light"] .product-card {
    box-shadow: inset 0 0 0 1.2px rgba(10, 15, 20, 0.12), 0 8px 24px rgba(10, 15, 20, 0.05) !important;
    border: none !important;
    border-radius: 16px !important;
}


.filter-category-card {
    box-shadow: inset 0 0 0 1.2px rgba(255, 255, 255, 0.15), 0 4px 10px rgba(0,0,0,0.35) !important;
    border: none !important;
    border-radius: 20px !important;
}


html[data-theme="light"] .filter-category-card {
    box-shadow: inset 0 0 0 1.2px rgba(10, 15, 20, 0.16), 0 4px 10px rgba(10, 15, 20, 0.06) !important;
    border: none !important;
    border-radius: 20px !important;
}

.promo-card {
    box-shadow: inset 0 0 0 2px rgba(0, 200, 83, 0.25) !important;
    border: none !important;
}

.purchase-item-card {
    box-shadow: inset 0 0 0 1.2px rgba(255, 255, 255, 0.12), 0 4px 15px rgba(0, 0, 0, 0.3) !important;
    border: none !important;
    border-radius: 16px !important;
}

html[data-theme="light"] .purchase-item-card {
    box-shadow: inset 0 0 0 1.2px rgba(10, 15, 20, 0.12), 0 4px 15px rgba(10, 15, 20, 0.04) !important;
    border: none !important;
    border-radius: 16px !important;
}



/* ==================== LIGHT THEME OVERRIDES ==================== */
html[data-theme="light"] {
    --text-primary: #101214;
    --text-secondary: rgba(10, 15, 20, 0.65);
    --text-muted: rgba(10, 15, 20, 0.45);
}

/* Inputs and textareas styling */
html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] [id^="wizardField_"] {
    background: #f1f3f5 !important;
    border: 1px solid #dcdfe3 !important;
    color: #101214 !important;
}

html[data-theme="light"] input::placeholder,
html[data-theme="light"] textarea::placeholder {
    color: rgba(10, 15, 20, 0.45) !important;
}

/* Fix "В каталог" empty state button */
html[data-theme="light"] .empty-state button,
html[data-theme="light"] button[onclick="switchPage('home')"] {
    background: #101214 !important;
    color: #ffffff !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18) !important;
    border: none !important;
}

/* Cart Promo apply button */
html[data-theme="light"] button[onclick="applyPromoCode()"] {
    background: #f1f3f5 !important;
    border: 1px solid #c8cbd0 !important;
    color: #101214 !important;
}

html[data-theme="light"] button[onclick="applyPromoCode()"]:hover {
    background: #e2e5e9 !important;
}

/* Cart Wizard navigation buttons */
html[data-theme="light"] button[onclick="prevCartStep()"] {
    background: #f1f3f5 !important;
    border: 1px solid #c8cbd0 !important;
    color: #101214 !important;
}

html[data-theme="light"] button[onclick="prevCartStep()"] svg {
    stroke: #101214 !important;
}

/* Cart active discounts summaries */
html[data-theme="light"] div[style*="background:rgba(0,200,83,0.08)"],
html[data-theme="light"] div[style*="background: rgba(0, 200, 83, 0.08)"] {
    background: rgba(0, 200, 83, 0.07) !important;
    border: 1px solid rgba(0, 200, 83, 0.15) !important;
}

html[data-theme="light"] div[style*="background:rgba(255,180,0,0.08)"],
html[data-theme="light"] div[style*="background: rgba(255,180,0,0.08)"] {
    background: rgba(255, 180, 0, 0.08) !important;
    border: 1px solid rgba(255, 180, 0, 0.2) !important;
}

/* Cart Referral and Roulette apply/use buttons */
html[data-theme="light"] button[onclick="applyReferralBonus()"],
html[data-theme="light"] button[onclick="applyRouletteBonus()"] {
    color: #ffffff !important;
}

/* Purchases page elements */
html[data-theme="light"] .purchase-item-card {
    background: #f7f8fa !important;
}

html[data-theme="light"] .purchase-item-card * {
    color: #101214 !important;
}

html[data-theme="light"] .purchase-item-card svg {
    stroke: #101214 !important;
}

html[data-theme="light"] .purchase-item-card div[style*="background: rgba(255,255,255,0.08)"],
html[data-theme="light"] .purchase-item-card div[style*="background:rgba(255,255,255,0.08)"] {
    background: rgba(10, 15, 20, 0.06) !important;
}

html[data-theme="light"] .purchase-item-card span[style*="color:rgba(255,255,255"],
html[data-theme="light"] .purchase-item-card div[style*="color:rgba(255,255,255"] {
    color: rgba(10, 15, 20, 0.55) !important;
}

/* Profile cards and sections (Telegram user details block, referral block, etc.) */
html[data-theme="light"] #page-profile div[style*="background:rgba(255,255,255,0.04)"],
html[data-theme="light"] #page-profile div[style*="background: rgba(255,255,255,0.04)"],
html[data-theme="light"] #page-profile div[style*="background:rgba(255,255,255,0.03)"],
html[data-theme="light"] #page-profile div[style*="background: rgba(255,255,255,0.03)"] {
    background: #f7f8fa !important;
    border: 1px solid rgba(10, 15, 20, 0.08) !important;
    color: #101214 !important;
}

html[data-theme="light"] #page-profile div[style*="background:rgba(255,255,255,0.04)"] *,
html[data-theme="light"] #page-profile div[style*="background: rgba(255,255,255,0.04)"] * {
    color: #101214 !important;
}

/* User ID copy container in profile */
html[data-theme="light"] #page-profile div[onclick^="navigator.clipboard.writeText"] {
    background: rgba(10, 15, 20, 0.05) !important;
    border: 1px solid rgba(10, 15, 20, 0.08) !important;
    color: #101214 !important;
}

html[data-theme="light"] #page-profile div[onclick^="navigator.clipboard.writeText"] * {
    color: #101214 !important;
}

/* Profile action menu list icons */
html[data-theme="light"] #page-profile div[style*="background:rgba(255,255,255,0.06)"],
html[data-theme="light"] #page-profile div[style*="background: rgba(255,255,255,0.06)"] {
    background: rgba(10, 15, 20, 0.06) !important;
}

html[data-theme="light"] #page-profile div[style*="background:rgba(255,255,255,0.06)"] svg,
html[data-theme="light"] #page-profile div[style*="background: rgba(255,255,255,0.06)"] svg {
    color: #101214 !important;
    stroke: #101214 !important;
}

/* Referral link panel and button in profile */
html[data-theme="light"] #page-profile div[style*="background:rgba(0,200,83,0.08)"] {
    background: rgba(0, 200, 83, 0.05) !important;
    border-color: rgba(0, 200, 83, 0.15) !important;
}

html[data-theme="light"] #page-profile div[onclick="showProfileReferralLink()"] {
    background: rgba(0, 200, 83, 0.1) !important;
    border-color: rgba(0, 200, 83, 0.25) !important;
    color: #00c853 !important;
}

/* Manage promocodes button in profile */
html[data-theme="light"] #page-profile div[style*="background:rgba(58,123,213,0.15)"] {
    background: rgba(58, 123, 213, 0.08) !important;
    color: #3a7bd5 !important;
}

/* Partner stats button in profile */
html[data-theme="light"] #page-profile div[style*="background:rgba(0,200,83,0.12)"] {
    background: rgba(0, 200, 83, 0.08) !important;
    color: #00c853 !important;
}

/* Logout row icon in profile */
html[data-theme="light"] #page-profile div[style*="background:rgba(255,68,68,0.1)"] {
    background: rgba(255, 68, 68, 0.08) !important;
    color: #ff4444 !important;
}



/* ==================== PROFILE SECTION CLASS-BASED STYLES (DARK/DEFAULT) ==================== */
.profile-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 16px;
    padding: 18px 20px;
    margin-bottom: 12px;
}
.profile-card.profile-menu-container {
    padding: 4px 20px;
}
.profile-card.profile-promo-card {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 14px;
}
.profile-name {
    font-size: 22px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1.2;
}
.profile-id-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 6px;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    cursor: pointer;
    position: relative;
}
.profile-id-btn span {
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.7);
    font-family: monospace;
}
.profile-id-btn svg {
    color: rgba(255, 255, 255, 0.4);
}
.profile-email-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.4);
    margin-top: 4px;
}
.profile-label {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 4px;
}
.profile-balance {
    font-size: 28px;
    font-weight: 800;
    color: #ffffff;
}
.profile-stat-icon svg {
    color: rgba(255, 255, 255, 0.6);
}
.profile-stat-value {
    font-size: 17px;
    font-weight: 700;
    color: #ffffff;
}
.profile-stat-label {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 2px;
}
.profile-menu-row {
    display: flex;
    align-items: center;
    padding: 12px 14px;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    margin-bottom: 8px;
    transition: background 0.2s;
}
.profile-menu-row:last-child {
    margin-bottom: 0;
}
.profile-menu-row:hover {
    background: rgba(255, 255, 255, 0.06);
}
.profile-menu-icon-wrapper {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-right: 14px;
}
.profile-menu-icon-wrapper svg {
    color: #ffffff;
}
.profile-menu-text {
    flex: 1;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
}
.profile-promo-gift-icon {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    background: rgba(0, 200, 83, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 22px;
}
.profile-promo-title {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
}
.profile-promo-subtitle {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.4);
    line-height: 1.3;
    margin-top: 2px;
}
.profile-promo-btn {
    padding: 8px 16px;
    background: rgba(0, 200, 83, 0.12);
    border: 1px solid rgba(0, 200, 83, 0.3);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    color: #00c853;
    cursor: pointer;
    flex-shrink: 0;
}

/* ==================== PROFILE SECTION CLASS-BASED STYLES (LIGHT MODE) ==================== */
html[data-theme="light"] .profile-card {
    background: #f7f8fa !important;
    border: 1px solid rgba(10, 15, 20, 0.08) !important;
    box-shadow: 0 4px 12px rgba(10, 15, 20, 0.03) !important;
}
html[data-theme="light"] .profile-name {
    color: #101214 !important;
}
html[data-theme="light"] .profile-id-btn {
    background: rgba(10, 15, 20, 0.05) !important;
}
html[data-theme="light"] .profile-id-btn span {
    color: rgba(10, 15, 20, 0.7) !important;
}
html[data-theme="light"] .profile-id-btn svg {
    color: rgba(10, 15, 20, 0.4) !important;
}
html[data-theme="light"] .profile-email-label {
    color: rgba(10, 15, 20, 0.4) !important;
}
html[data-theme="light"] .profile-label {
    color: rgba(10, 15, 20, 0.6) !important;
}
html[data-theme="light"] .profile-balance {
    color: #101214 !important;
}
html[data-theme="light"] .profile-stat-icon svg {
    color: rgba(10, 15, 20, 0.7) !important;
    stroke: rgba(10, 15, 20, 0.7) !important;
}
html[data-theme="light"] .profile-stat-value {
    color: #101214 !important;
}
html[data-theme="light"] .profile-stat-label {
    color: rgba(10, 15, 20, 0.45) !important;
}
html[data-theme="light"] .profile-menu-row {
    background: #eaecef !important;
    border: 1px solid rgba(10, 15, 20, 0.06) !important;
}
html[data-theme="light"] .profile-menu-row:hover {
    background: #e2e5e9 !important;
}
html[data-theme="light"] .profile-menu-row svg {
    stroke: #101214 !important;
}
html[data-theme="light"] .profile-menu-icon-wrapper {
    background: rgba(10, 15, 20, 0.06) !important;
}
html[data-theme="light"] .profile-menu-icon-wrapper svg {
    color: #101214 !important;
    stroke: #101214 !important;
}
html[data-theme="light"] .profile-menu-text {
    color: #101214 !important;
}
html[data-theme="light"] .profile-promo-title {
    color: #101214 !important;
}
html[data-theme="light"] .profile-promo-subtitle {
    color: rgba(10, 15, 20, 0.5) !important;
}
html[data-theme="light"] .profile-promo-gift-icon {
    background: rgba(0, 200, 83, 0.08) !important;
}
html[data-theme="light"] .profile-promo-btn {
    background: rgba(0, 200, 83, 0.08) !important;
    border: 1px solid rgba(0, 200, 83, 0.2) !important;
}
html[data-theme="light"] #page-profile path[stroke*="rgba(255,255,255"] {
    stroke: rgba(10, 15, 20, 0.4) !important;
}


/* Additional bulletproof profile overrides targeting raw inline-styled containers */
html[data-theme="light"] #page-profile div,
html[data-theme="light"] #page-profile span,
html[data-theme="light"] #profile-content div,
html[data-theme="light"] #profile-content span {
    color: #101214 !important;
}

/* Ensure colored status labels and logout button remain colored */
html[data-theme="light"] #page-profile [style*="color:#00c853"],
html[data-theme="light"] #page-profile [style*="color: #00c853"],
html[data-theme="light"] #page-profile [style*="color:rgb(0, 200, 83)"],
html[data-theme="light"] #page-profile [style*="color:rgb(0,200,83)"],
html[data-theme="light"] #profile-content [style*="color:#00c853"],
html[data-theme="light"] #profile-content [style*="color: #00c853"],
html[data-theme="light"] #profile-content [style*="color:rgb(0, 200, 83)"],
html[data-theme="light"] #profile-content [style*="color:rgb(0,200,83)"] {
    color: #00c853 !important;
}

html[data-theme="light"] #page-profile [style*="color:#ff6b6b"],
html[data-theme="light"] #page-profile [style*="color:rgb(255, 107, 107)"],
html[data-theme="light"] #page-profile [style*="color:rgb(255,107,107)"],
html[data-theme="light"] #profile-content [style*="color:#ff6b6b"],
html[data-theme="light"] #profile-content [style*="color:rgb(255, 107, 107)"],
html[data-theme="light"] #profile-content [style*="color:rgb(255,107,107)"] {
    color: #ff6b6b !important;
}

/* Force dark strokes on SVGs in profile container */
html[data-theme="light"] #page-profile svg,
html[data-theme="light"] #profile-content svg {
    stroke: #101214 !important;
}



/* Keep branded SVGs colored */
html[data-theme="light"] #page-profile svg[stroke="#3a7bd5"] *,
html[data-theme="light"] #page-profile svg[stroke="#00c853"] *,
html[data-theme="light"] #page-profile svg[stroke="#ff6b6b"] *,
html[data-theme="light"] #profile-content svg[stroke="#3a7bd5"] *,
html[data-theme="light"] #profile-content svg[stroke="#00c853"] *,
html[data-theme="light"] #profile-content svg[stroke="#ff6b6b"] * {
    stroke: inherit !important;
}

/* Adjust card backgrounds when inline white background is converted to solid white */
html[data-theme="light"] #page-profile div[style*="background:rgba(255,255,255"],
html[data-theme="light"] #page-profile div[style*="background: rgba(255,255,255"],
html[data-theme="light"] #profile-content div[style*="background:rgba(255,255,255"],
html[data-theme="light"] #profile-content div[style*="background: rgba(255,255,255"] {
    background: #f7f8fa !important;
    border: 1px solid rgba(10, 15, 20, 0.08) !important;
}

/* Fix for profile cards headers and letters */
html[data-theme="light"] #page-profile div[style*="background:linear-gradient"] {
    color: #ffffff !important;
}
html[data-theme="light"] #page-profile div[style*="background:linear-gradient"] * {
    color: #ffffff !important;
}
