.hero {
    padding: 3.5rem 0 2.5rem;
    text-align: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    margin-bottom: 0;
}
.hero-badge {
    display: inline-block;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 100px;
    padding: 0.28rem 0.85rem;
    font-size: 0.76rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    margin-bottom: 1rem;
}

.hero-badge-dot {
    display: inline-block;
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 999px;
    background: var(--success);
    box-shadow: 0 0 0 0 rgba(var(--success-rgb), 0.45);
    animation: heroBadgePulse 1.8s ease-in-out infinite;
}

@keyframes heroBadgePulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(var(--success-rgb), 0.45);
    }
    50% {
        opacity: 0.55;
        transform: scale(0.75);
        box-shadow: 0 0 0 0.45rem rgba(var(--success-rgb), 0);
    }
}
.hero h1 {
    font-size: 2.75rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    line-height: 1.15;
}
.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    max-width: 520px;
    margin: 0 auto 1.75rem;
}
.hero-stats {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    font-size: 0.85rem;
    opacity: 0.8;
    margin-top: 1rem;
    flex-wrap: wrap;
}
.hero-stats span { display: flex; align-items: center; gap: 0.35rem; }
.search-section {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 1.25rem 0;
    position: relative;
    z-index: 1;
}
.search-inner {
    display: flex;
    align-items: center;
    max-width: 560px;
    margin: 0 auto;
    position: relative;
    border-radius: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.11), 0 20px 60px rgba(var(--shadow-color-rgb), 0.22);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.search-inner:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.28), 0 20px 60px rgba(var(--shadow-color-rgb), 0.3);
}
.search-icon-fixed {
    position: absolute;
    left: 1rem;
    font-size: 1rem;
    pointer-events: none;
    color: var(--text-muted);
}
#toolSearch {
    width: 100%;
    height: 54px;
    padding: 0 58px 0 20px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}
#toolSearch:focus {
    outline: none;
}
#toolSearch::-webkit-search-decoration,
#toolSearch::-webkit-search-cancel-button,
#toolSearch::-webkit-search-results-button,
#toolSearch::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}
#toolSearch::-ms-clear,
#toolSearch::-ms-reveal {
    display: none;
    width: 0;
    height: 0;
}
#toolSearch::placeholder { color: var(--text-muted); }
.main-search-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: var(--on-primary);
    cursor: pointer;
    padding: 0;
    transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}
.main-search-btn:hover {
    box-shadow: 0 8px 18px rgba(var(--primary-rgb), 0.28);
}
.main-search-btn:active {
    transform: translateY(-50%) scale(0.97);
}
.main-search-clear {
    display: none;
    font-size: 1.35rem;
    line-height: 1;
}
.main-search-btn.has-query .main-search-icon {
    display: none;
}
.main-search-btn.has-query .main-search-clear {
    display: block;
}
.categories-section { padding: 1.25rem 0 0; }
.categories-scroll {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    justify-content: center;
    overflow: visible;
    max-width: 980px;
    margin: 0 auto;
}
.categories-scroll::-webkit-scrollbar { display: none; }
.cat-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.44rem 0.92rem;
    border-radius: 100px;
    border: 2px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
}
.cat-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(var(--primary-rgb), 0.06);
}
.cat-btn.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}
.cat-count {
    background: rgba(255,255,255,0.25);
    border-radius: 100px;
    padding: 0 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
}
.cat-btn:not(.active) .cat-count {
    background: var(--border);
    color: var(--text-muted);
}
/* ✅ FIX: results bar — count only, no category label */
.results-bar {
    padding: 1rem 0 0.6rem;
    font-size: 0.84rem;
    color: var(--text-muted);
    min-height: 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.results-count { font-weight: 500; }
.results-visible {
    color: var(--text-muted);
    font-size: 0.78rem;
}
.category-page-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 650;
}
.category-page-link:hover { text-decoration: underline; }
.tools-section { padding: 1.25rem 0 4rem; }
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.25rem;
}
.tool-card {
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    cursor: pointer;
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    position: relative;
    text-decoration: none;
    color: var(--text);
    content-visibility: auto;
    contain-intrinsic-size: 170px;
}
.tool-card:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(var(--primary-rgb), 0.15);
}
.tool-card:active {
    transform: translateY(-1px);
}
.tool-card:focus-visible {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.16);
}
.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.5rem;
}
.tool-icon { font-size: 2rem; line-height: 1; flex-shrink: 0; }
.tool-badges { display: flex; gap: 0.35rem; flex-wrap: wrap; justify-content: flex-end; }
.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 100px;
    letter-spacing: 0.02em;
}
.badge-popular { background: #fef3c7; color: #92400e; }
.badge-new { background: #d1fae5; color: #065f46; }
.badge-category { background: rgba(var(--primary-rgb), 0.1); color: var(--primary); }
.category-badge-link {
    position: relative;
    z-index: 2;
    text-decoration: none;
}
.category-badge-link:hover {
    text-decoration: underline;
}
[data-theme="dark"] .badge-popular { background: rgba(251,191,36,0.15); color: #fbbf24; }
[data-theme="dark"] .badge-new { background: rgba(16,185,129,0.15); color: #34d399; }
.tool-card h2 { font-size: 1.05rem; font-weight: 600; color: var(--text); margin: 0; }
.tool-card p { font-size: 0.875rem; color: var(--text-muted); line-height: 1.55; flex-grow: 1; margin: 0; }
.tool-cta {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    margin-top: 0.25rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: gap 0.2s ease;
}
.tool-card:hover .tool-cta { gap: 0.5rem; }
.highlight {
    background: rgba(var(--primary-rgb), 0.2);
    color: var(--primary);
    border-radius: 3px;
    padding: 0 2px;
    font-weight: 600;
}
[data-theme="dark"] .highlight {
    background: rgba(var(--primary-rgb), 0.35);
    color: #a5b4fc;
}
.empty-state {
    display: none;
    text-align: center;
    padding: 4rem 1rem;
    color: var(--text-muted);
    grid-column: 1 / -1;
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h3 { color: var(--text); margin-bottom: 0.5rem; }
.empty-state button {
    margin-top: 1rem;
    padding: 0.6rem 1.5rem;
    border-radius: 100px;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    transition: color 0.2s ease, background-color 0.2s ease;
}
.empty-state button:hover { background: var(--primary); color: white; }
.tools-pagination {
    display: flex;
    justify-content: center;
    padding: 1.35rem 0 0;
}

.tools-pagination[hidden] {
    display: none;
}

.load-more-tools {
    min-height: 44px;
    border: 1px solid rgba(var(--primary-rgb), 0.35);
    border-radius: 999px;
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
    cursor: pointer;
    font: inherit;
    font-weight: 700;
    padding: 0.72rem 1.35rem;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.load-more-tools:hover {
    background: rgba(var(--primary-rgb), 0.14);
    border-color: rgba(var(--primary-rgb), 0.55);
    transform: translateY(-1px);
}

.load-more-tools:focus-visible {
    outline: none;
    box-shadow: 0 0 0 4px rgba(var(--primary-rgb), 0.16);
}
@media (max-width: 768px) {
    .hero h1 { font-size: 2rem; }
    .tools-grid { grid-template-columns: 1fr; }
    .categories-section { padding-top: 1rem; }
    .categories-scroll {
        flex-wrap: nowrap;
        justify-content: flex-start;
        overflow-x: auto;
        scrollbar-width: none;
        scroll-snap-type: x proximity;
        max-width: none;
        margin: 0;
        padding-bottom: 0.15rem;
    }
    .cat-btn {
        padding: 0.48rem 0.82rem;
        font-size: 0.8rem;
        scroll-snap-align: start;
    }
    .results-bar { padding-bottom: 0.75rem; }
    .tools-section { padding-top: 1rem; }
    .tools-grid { gap: 0.85rem; }
    .tool-card {
        display: grid;
        grid-template-columns: 2.65rem 1fr;
        grid-template-areas:
            "icon top"
            "icon title"
            "icon desc"
            "icon cta";
        gap: 0.25rem 0.8rem;
        padding: 1rem;
        min-height: 0;
    }
    .tool-card .card-top {
        display: contents;
    }
    .tool-icon {
        grid-area: icon;
        width: 2.65rem;
        height: 2.65rem;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        background: var(--bg);
        border: 1px solid var(--border);
        font-size: 1.55rem;
    }
    .tool-badges {
        grid-area: top;
        justify-content: flex-start;
        min-width: 0;
    }
    .badge {
        padding: 0.14rem 0.48rem;
        font-size: 0.64rem;
    }
    .tool-card h2 {
        grid-area: title;
        font-size: 1rem;
        line-height: 1.25;
    }
    .tool-card p {
        grid-area: desc;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-size: 0.82rem;
        line-height: 1.45;
    }
    .tool-cta {
        grid-area: cta;
        margin-top: 0.25rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 420px) {
    .tool-card {
        grid-template-columns: 2.45rem 1fr;
        gap: 0.2rem 0.7rem;
        padding: 0.9rem;
    }
    .tool-icon {
        width: 2.45rem;
        height: 2.45rem;
        font-size: 1.4rem;
    }
}

/* Premium homepage layer */
.hero {
    padding: 5rem 0 3.25rem;
    background: transparent;
    color: var(--text);
    margin-bottom: 0;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 999px;
    padding: 0.34rem 0.78rem;
    font-size: 0.74rem;
    font-weight: 650;
    letter-spacing: 0.075em;
    text-transform: uppercase;
}

.hero h1 {
    max-width: 820px;
    margin: 0 auto 1rem;
    color: var(--text);
    font-size: clamp(2.35rem, 5vw, 4.4rem);
    font-weight: 850;
    line-height: 1.05;
    letter-spacing: 0;
}

.hero-subtitle {
    max-width: 650px;
    color: var(--text-muted);
    opacity: 1;
    font-size: 1.08rem;
    line-height: 1.75;
}

.hero-stats {
    gap: 0.7rem;
    opacity: 1;
}

.hero-stats span {
    min-height: 32px;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text-muted);
    box-shadow: 0 1px 0 rgba(var(--on-primary-rgb), 0.03) inset;
}

.hero-stats span::before {
    content: "✓";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1rem;
    height: 1rem;
    border-radius: 999px;
    background: rgba(var(--success-rgb), 0.14);
    color: var(--success);
    font-size: 0.72rem;
    font-weight: 900;
    line-height: 1;
}

.search-section {
    background: transparent;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    border-top: 0;
    border-bottom: 0;
    padding: 0 0 2rem;
}

.search-inner {
    max-width: 560px;
}

#toolSearch {
    min-height: 54px;
    border: 0;
    border-radius: 16px;
    background: transparent;
    box-shadow: none;
}

#toolSearch:focus {
    border-color: transparent;
    box-shadow: none;
}

.categories-section {
    padding: 1.9rem 0 0;
}

.categories-scroll {
    justify-content: flex-start;
}

.cat-btn {
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 620;
    letter-spacing: 0;
    min-height: 38px;
    padding: 0.36rem 0.72rem;
    gap: 0.32rem;
    line-height: 1;
    box-shadow: 0 1px 0 rgba(var(--on-primary-rgb), 0.035) inset;
}

.cat-btn:hover {
    background: var(--surface-2);
    color: var(--text);
    border-color: rgba(var(--primary-rgb), 0.34);
    box-shadow: 0 0 0 2px rgba(var(--primary-rgb), 0.07);
}

.cat-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-color: transparent;
    color: var(--on-primary);
    box-shadow: 0 5px 14px rgba(var(--primary-rgb), 0.18);
}

.cat-count,
.cat-btn:not(.active) .cat-count {
    background: rgba(var(--primary-rgb), 0.12);
    color: inherit;
    min-width: 1.15rem;
    padding: 0.08rem 0.34rem;
    font-size: 0.68rem;
    line-height: 1.2;
}

.results-bar {
    border-bottom-color: var(--border);
}

.tools-section {
    padding: 1.35rem 0 4.5rem;
}

.tools-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1rem;
}

.tool-card {
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    padding: 1.35rem;
    gap: 0.75rem;
    box-shadow: 0 1px 0 rgba(var(--on-primary-rgb), 0.03) inset;
}

.tool-card::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(var(--primary-rgb), 0.08), transparent 58%);
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
}

.tool-card:hover {
    transform: translateY(-3px);
    border-color: rgba(var(--primary-rgb), 0.5);
    box-shadow: var(--shadow-lg), 0 0 0 1px var(--card-glow);
}

.tool-card:hover::before {
    opacity: 1;
}

.tool-icon {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 13px;
    background: var(--surface-2);
    font-size: 1.35rem;
    margin-bottom: 0;
}

.badge {
    border: 1px solid transparent;
    letter-spacing: 0;
}

.badge-category {
    border-color: rgba(var(--primary-rgb), 0.22);
}

.tool-card h2 {
    font-size: 1rem;
    font-weight: 750;
}

.tool-cta {
    color: var(--primary);
}

@media (max-width: 768px) {
    .hero {
        padding: 3.75rem 0 2.4rem;
    }

    .hero h1 {
        font-size: clamp(2rem, 11vw, 2.8rem);
    }

    .categories-scroll {
        justify-content: flex-start;
    }

    .search-section {
        padding-bottom: 1.55rem;
    }

    .categories-section {
        padding-top: 1.45rem;
    }

    .cat-btn {
        min-height: 40px;
        padding: 0.42rem 0.78rem;
    }

    .tool-card:hover {
        transform: none;
    }
}
