:root {
    --text-scale: 1;
    --brand-primary: #7B4AE2;
    --brand-secondary: #00D4FF;
}

/* ── Global: prevent horizontal overflow on mobile ── */
/* Use clip (not hidden) — hidden creates a scroll container that breaks position:sticky */
html, body {
    overflow-x: clip;
    max-width: 100vw;
}

body {
    font-size: calc(1rem * var(--text-scale));
}

/* ── Brand ── */
.brand-text {
    font-weight: 800;
    font-size: 21px;
    letter-spacing: -0.02em;
    color: var(--bs-body-color);
}

/* ── Navbar ── */
.navbar {
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    z-index: 1030;
}

/* ── Article card ── */
.article-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
    border-radius: 0.75rem;
    overflow: hidden;
}
.article-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.12) !important;
}
.article-card h3,
.article-card h6 {
    color: var(--bs-body-color);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ── Category tabs ── */
.category-tabs {
    /* stickiness handled by parent <header class="sticky-top"> wrapper */
}
.category-tabs nav {
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}
.category-tabs nav::-webkit-scrollbar {
    display: none;
}

/* ── Hero card ── */
.hero-card {
    border-radius: 0.75rem;
    overflow: hidden;
}
.hero-card .hero-img {
    min-height: 220px;
    position: relative;
    overflow: hidden;
    background-color: var(--bs-secondary-bg);
}
.hero-card .hero-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}
.hero-card .hero-body {
    padding: 1.25rem;
}

@media (min-width: 768px) {
    .hero-card .hero-inner {
        display: flex;
    }
    .hero-card .hero-img {
        flex: 0 0 58%;
        min-height: 300px;
    }
    .hero-card .hero-body {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        padding: 1.5rem;
    }
}

/* ── Settings chips ── */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: 2rem;
    border: 1px solid var(--bs-border-color);
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    color: var(--bs-body-color);
}
.chip:hover {
    border-color: var(--brand-primary);
}
.chip.active {
    background-color: var(--chip-color, var(--brand-primary));
    border-color: var(--chip-color, var(--brand-primary));
    color: #fff;
}

/* ── Settings sticky bottom bar ── */
.settings-bottom-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: var(--bs-body-bg);
    border-top: 1px solid var(--bs-border-color);
    padding: 0.75rem 0;
    box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
}

/* ── Scroll to top ── */
.scroll-top-btn {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1040;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}
.scroll-top-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── App banner (top, dismissible) ── */
.app-banner {
    font-size: 0.875rem;
    background-color: var(--bs-tertiary-bg);
}

/* ── Get App section (above footer) ── */
.get-app-section {
    background: linear-gradient(135deg, rgba(123, 74, 226, 0.06) 0%, rgba(0, 212, 255, 0.06) 100%);
    border-top: 1px solid var(--bs-border-color);
}

/* ── Focus ring ── */
.form-control:focus {
    border-color: var(--brand-primary);
    box-shadow: 0 0 0 0.2rem rgba(123, 74, 226, 0.15);
}

/* ── Footer ── */
footer .btn-outline-secondary:hover {
    background-color: var(--brand-primary);
    border-color: var(--brand-primary);
    color: #fff;
}

/* ── Article body ── */
.article-body p {
    line-height: 1.8;
    margin-bottom: 1rem;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* ── Card image ── */
.card-img-top {
    background-color: var(--bs-secondary-bg);
}

/* ── Compact list view ── */
/* Force all columns to full-width (override Bootstrap col-sm-6 / col-lg-4) */
.list-view > div[class*="col"] {
    width: 100% !important;
    flex: 0 0 100% !important;
    max-width: 100% !important;
}
.list-view .article-card {
    flex-direction: row !important;
    border-radius: 0.5rem;
}
/* Override inline height:200px on card-img-top */
.list-view .article-card .card-img-top {
    width: 110px !important;
    min-width: 110px;
    height: auto !important;
    min-height: 90px;
    border-radius: 0.5rem 0 0 0.5rem !important;
}
.list-view .article-card .card-body {
    padding: 0.75rem;
}
/* Hide category badge in compact mode */
.list-view .article-card .card-body > .mb-2:first-child {
    display: none;
}
/* Hide description in compact mode */
.list-view .article-card .card-text {
    display: none !important;
}
.list-view .article-card .card-title {
    font-size: 0.9rem;
    margin-bottom: 0.4rem !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
@media (min-width: 576px) {
    .list-view .article-card .card-img-top {
        width: 140px !important;
        min-width: 140px;
    }
}

/* ── Search Typeahead Dropdown ── */
.typeahead-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1060;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-top: none;
    border-radius: 0 0 0.75rem 0.75rem;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.15);
    max-height: 420px;
    overflow-y: auto;
    scrollbar-width: thin;
}
.ta-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.875rem;
    text-decoration: none;
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--bs-border-color-translucent);
    transition: background 0.1s;
}
.ta-item:hover,
.ta-item.active {
    background-color: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}
.ta-thumb {
    width: 48px;
    height: 48px;
    border-radius: 0.375rem;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--bs-secondary-bg);
}
.ta-thumb-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ccc;
    font-size: 1.25rem;
}
.ta-body {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}
.ta-title {
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ta-title mark {
    background: rgba(123, 74, 226, 0.2);
    color: inherit;
    padding: 0;
    border-radius: 2px;
}
.ta-meta {
    font-size: 0.7rem;
    color: var(--bs-secondary-color);
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-top: 0.15rem;
}
.ta-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}
.ta-all {
    display: block;
    text-align: center;
    padding: 0.625rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--brand-primary);
    text-decoration: none;
    border-top: 1px solid var(--bs-border-color);
}
.ta-all:hover,
.ta-all.active {
    background-color: var(--bs-tertiary-bg);
    color: var(--brand-primary);
}
.ta-msg {
    padding: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--bs-secondary-color);
}

/* ── Responsive ── */
@media (max-width: 575.98px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    .brand-text {
        font-size: 18px;
    }
    .hero-card .hero-body h2 {
        font-size: 1.25rem;
    }
}
