html {
    overflow-y: scroll;
}

html.scroll-locked {
    overflow: hidden;
}

#searchPage {
    width: 100%;
    max-width: 1000px;
    margin: auto;
    padding: 16px;
    font-family: var(--mainFont);
    box-sizing: border-box;
}

/* ── Search top section — unified box ──────────────────────── */

#searchTopSection {
    background: white;
    border-radius: 16px;
    margin-bottom: 12px;
}

#searchBarRow {
    display: flex;
    align-items: center;
    padding: 4px 6px 4px 12px;
}

.search-bar-icon {
    font-size: 1.1rem;
    color: #bbb;
    flex-shrink: 0;
    margin-right: 8px;
    user-select: none;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

#searchInput {
    flex: 1;
    height: 30px;
    background: transparent;
    border: none;
    padding: 0 10px 0 0;
    font-size: 0.85rem;
    font-family: var(--mainFont);
    outline: none;
    color: #222;
    min-width: 0;
}

#searchInput::placeholder {
    color: #aaa;
}

.search-v-divider {
    width: 1px;
    height: 20px;
    background: #d0d0d0;
    flex-shrink: 0;
    margin: 0 4px;
}

.search-h-divider {
    height: 1px;
    background: #d0d0d0;
    margin: 0 10px;
}

/* ── Sort dropdown ─────────────────────────────────────────── */

#sortWrapper {
    position: relative;
    flex-shrink: 0;
}

#sortBtn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100px;
    height: 30px;
    padding: 0 8px 0 12px;
    background: transparent;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--mainFont);
    font-size: 0.9rem;
    font-weight: 500;
    white-space: nowrap;
    color: #222;
    transition: background 0.15s;
    box-sizing: border-box;
}

#sortBtn:hover {
    background: #e8e8e8;
}

#sortBtn .material-symbols-rounded {
    font-size: 1.15rem;
    color: #555;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

#sortDropdown {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background: white;
    border-radius: 14px;
    box-shadow: 0 4px 18px rgba(0,0,0,0.12);
    overflow: hidden;
    z-index: 200;
    min-width: 100px;
}

#sortDropdown.open {
    display: block;
}

.sort-option {
    display: block;
    width: 100%;
    padding: 10px 18px;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    font-family: var(--mainFont);
    font-size: 0.88rem;
    color: #222;
    transition: background 0.1s;
}

.sort-option:hover {
    background: #f5f5f5;
}

.sort-option.active {
    font-weight: 700;
}

/* ── Tab bar ───────────────────────────────────────────────── */

#searchTabBar {
    display: flex;
    padding: 4px;
    gap: 4px;
}

#searchTabBar button {
    background-color: transparent;
    border: none;
    outline: none;
    cursor: pointer;
    padding: 6px 8px;
    transition: color 0.2s;
    flex: 1;
    text-align: center;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.85rem;
    color: #bbb;
    font-family: var(--mainFont);
}

#searchTabBar button:hover {
    color: #777;
}

#searchTabBar button.active {
    color: #333;
    font-weight: 700;
}

/* ── Two-column grid ───────────────────────────────────────── */

#searchGrid {
    display: flex;
    align-items: flex-start;
}

#searchResultsColumn {
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    padding: 0px 24px;
}

/* ── Filters column ────────────────────────────────────────── */

#searchFiltersColumn {
    flex-shrink: 0;
    width: 140px;
    padding: 8px 0px 8px 16px;
    box-sizing: border-box;
    margin-right: 24px
}

#filterSectionCategories {
    margin-top: 16px;
}

.filter-group-title {
    font-size: 0.72rem;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 6px;
    margin-top: 4px;
    padding-left: 2px;
}

.filter-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    height: 38px;
    padding: 0 12px;
    background: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--mainFont);
    font-size: 0.88rem;
    color: #222;
    text-align: left;
    margin-bottom: 6px;
    transition: background 0.12s;
}

.filter-btn-icon {
    font-size: 1.1rem;
    color: #333;
    flex-shrink: 0;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.filter-btn:hover:not(:disabled):not(.active) {
    background: #f5f5f5;
}

.filter-btn.active:hover {
    background: #444;
}

.filter-btn.active {
    background: #222;
    color: white;
    font-weight: 600;
}

.filter-btn.active .filter-btn-icon {
    color: white;
}

.filter-btn-disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.filter-separator {
    margin: 10px 0;
    border: none;
    border-top: 0.5px solid #d3d3d373;
    border-radius: 2px;
}

/* ── Category filter buttons ───────────────────────────────── */

.filter-cat-btn {
    display: block;
    width: 100%;
    padding: 7px 12px;
    background: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-family: var(--mainFont);
    font-size: 0.85rem;
    font-weight: 600;
    text-align: left;
    margin-bottom: 5px;
    transition: background 0.12s, color 0.12s;
    text-transform: capitalize;
}

.filter-cat-btn-politics         { color: #222; }
.filter-cat-btn-politics.active  { background: #222; color: white; }

.filter-cat-btn-technology         { color: #0D6FFF; }
.filter-cat-btn-technology.active  { background: #0D6FFF; color: white; }

.filter-cat-btn-lifestyle         { color: #7849ba; }
.filter-cat-btn-lifestyle.active  { background: #7849ba; color: white; }

.filter-cat-btn-business         { color: #EEBC1D; }
.filter-cat-btn-business.active  { background: #EEBC1D; color: white; }

.filter-cat-btn-health         { color: #FB0D44; }
.filter-cat-btn-health.active  { background: #FB0D44; color: white; }

.filter-cat-btn-science         { color: #34C759; }
.filter-cat-btn-science.active  { background: #34C759; color: white; }

/* ── Author links ──────────────────────────────────────────── */

.author-link {
    text-decoration: none;
    color: inherit;
}

.author-link:hover strong {
    color: #555;
}

/* ── User search cards ─────────────────────────────────────── */

.user-search-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    background: white;
    border-radius: 20px;
    text-decoration: none;
    color: #222;
    font-family: var(--mainFont);
    transition: background 0.12s;
}

.user-search-card:hover {
    background: #fafafa;
}

.user-search-avatar-wrap {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    overflow: hidden;
    outline: 2.5px solid #ebebeb;
    background: #f0f0f0;
    flex-shrink: 0;
}

.user-search-avatar-wrap .user-search-avatar {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--ux, 50%) var(--uy, 50%);
    transform-origin: var(--ux, 50%) var(--uy, 50%);
    transform: scale(var(--uz, 1));
    display: block;
    border-radius: 0;
    border: none;
}

/* Legacy bare .user-search-avatar (no wrapper) */
.user-search-card > .user-search-avatar {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    border: 2.5px solid #ebebeb;
    background: #f0f0f0;
    flex-shrink: 0;
}

.user-search-info {
    flex: 1;
    min-width: 0;
}

.user-search-name {
    font-size: 0.97rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-search-sub {
    font-size: 0.78rem;
    color: #999;
    margin-top: 2px;
}

/* ── Empty states ──────────────────────────────────────────── */

.search-empty,
.search-filter-empty,
.search-initial {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px 24px 48px;
    font-family: var(--mainFont);
    gap: 8px;
    text-align: center;
}

.search-empty,
.search-filter-empty {
    display: none;
}

.search-empty-icon {
    font-size: 2.8rem;
    color: #ddd;
    font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

.search-empty-text {
    font-size: 0.92rem;
    color: #bbb;
}

/* ── Mobile filter button (hidden on desktop) ──────────────── */

#mobileFilterDivider,
#mobileFilterBtn,
#mobileFilterHandle {
    display: none;
}

/* ── Mobile ────────────────────────────────────────────────── */

@media (max-width: 800px) {
    #searchPage {
        padding: 10px;
    }

    #searchResultsColumn {
        padding: 0px 4px;
    }

    #mobileFilterDivider {
        display: block;
    }

    #mobileFilterBtn {
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        width: 36px;
        height: 30px;
        background: transparent;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        color: #555;
        transition: background 0.15s, color 0.15s;
    }

    #mobileFilterBtn .material-symbols-rounded {
        font-size: 1.2rem;
        font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    }

    #mobileFilterBtn.active {
        background: #333;
        color: white;
    }

    /* Filter column becomes a bottom sheet */
    #searchFiltersColumn {
        display: none;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        padding: 0 20px 40px;
        background: white;
        border-radius: 20px 20px 0 0;
        box-shadow: 0 -4px 24px rgba(0,0,0,0.15);
        box-sizing: border-box;
        z-index: 1001;
    }

    #searchFiltersColumn.mobile-open {
        display: block;
        animation: filterSlideUp 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    }

    @keyframes filterSlideUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }

    /* Real tappable handle bar */
    #mobileFilterHandle {
        display: flex;
        justify-content: center;
        align-items: center;
        padding: 12px 0 14px;
        cursor: pointer;
        margin: 0 -20px;
    }

    #mobileFilterHandle::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: #e0e0e0;
        border-radius: 2px;
    }

    /* Backdrop */
    #mobileFilterBackdrop {
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.15);
        z-index: 1000;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.32s cubic-bezier(0.32, 0.72, 0, 1);
    }

    #mobileFilterBackdrop.visible {
        opacity: 1;
        pointer-events: auto;
    }
}
