:root {
    --bg-color: #ffffff;
    --bg-secondary: #f7f9ff;
    --text-color: #101828;
    --accent-color: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.06);
    --border-color: #dde4ff;
    --highlight-color: #22c55e;
    --font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --base-font-size: 16px;
}

/* Base resets */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    font-size: var(--base-font-size);
    background: radial-gradient(circle at top left, #ffe4f3, #e0f2fe, #ecfdf3);
    color: var(--text-color);
    line-height: 1.5;
}

/* Layout */
#page-wrapper {
    background-color: var(--bg-color);
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.12);
}

/* Top bar */
#top-bar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.top-left {
    min-width: 0;
}

.site-title {
    font-size: 1.6rem;
    letter-spacing: 0.03em;
    background: linear-gradient(90deg, #ef4444, #f97316, #eab308, #22c55e, #3b82f6, #a855f7);
    -webkit-background-clip: text;
    color: transparent;
}

.site-subtitle {
    font-size: 0.9rem;
    color: #64748b;
}

.top-right {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

/* Search */
.search-container {
    display: flex;
    align-items: center;
    background-color: var(--bg-secondary);
    border-radius: 999px;
    padding: 4px 6px 4px 10px;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

#globalSearchInput {
    border: none;
    background: transparent;
    outline: none;
    padding: 4px 6px;
    min-width: 200px;
    font-size: 0.9rem;
}

.primary-btn {
    border-radius: 999px;
    border: none;
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.35);
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.primary-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(34, 197, 94, 0.4);
    filter: brightness(1.05);
}

/* Font slider */
.font-slider-container {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(248, 250, 252, 0.9);
    font-size: 0.8rem;
}

.font-slider-container label {
    white-space: nowrap;
}

#fontSizeSlider {
    width: 110px;
}

/* Theme switcher */
.theme-switcher {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.theme-btn {
    width: 18px;
    height: 18px;
    border-radius: 4px;
    border: 1px solid rgba(148, 163, 184, 0.65);
    cursor: pointer;
    padding: 0;
}

/* Distinct rainbow-ish theme button colors */
.theme-btn[data-theme="theme1"] { background: linear-gradient(135deg, #f97316, #facc15); }
.theme-btn[data-theme="theme2"] { background: linear-gradient(135deg, #22c55e, #a3e635); }
.theme-btn[data-theme="theme3"] { background: linear-gradient(135deg, #3b82f6, #06b6d4); }
.theme-btn[data-theme="theme4"] { background: linear-gradient(135deg, #a855f7, #ec4899); }
.theme-btn[data-theme="theme5"] { background: linear-gradient(135deg, #0ea5e9, #22c55e); }
.theme-btn[data-theme="theme6"] { background: linear-gradient(135deg, #f97316, #ef4444); }
.theme-btn[data-theme="theme7"] { background: linear-gradient(135deg, #facc15, #22c55e); }
.theme-btn[data-theme="theme8"] { background: linear-gradient(135deg, #3b82f6, #a855f7); }
.theme-btn[data-theme="theme9"] { background: linear-gradient(135deg, #ec4899, #f97316); }
.theme-btn[data-theme="theme10"] { background: linear-gradient(135deg, #22c55e, #3b82f6, #a855f7); }

/* Filters */
.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.filter-btn {
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    padding: 4px 10px;
    font-size: 0.8rem;
    background-color: #f8fafc;
    cursor: pointer;
    color: #334155;
}

.filter-btn.active {
    background: linear-gradient(90deg, #22c55e, #3b82f6);
    color: #ffffff;
    border-color: transparent;
}

/* Tiles section (similar to screenshot) */
.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 8px;
}

.source-tile {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 10px 10px 8px 10px;
    cursor: default;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
    transition: transform 0.1s ease, box-shadow 0.1s ease, border-color 0.1s ease;
}

.source-tile h3 {
    font-size: 0.9rem;
    margin: 0 0 4px 0;
}

.source-tile p {
    font-size: 0.75rem;
    margin: 0;
    color: #6b7280;
}

.source-tile:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.14);
    border-color: rgba(56, 189, 248, 0.9);
}

/* Thumbnail grid (6x6) */
.thumbnail-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

/* Responsive: adapt columns but still 36 items */
@media (max-width: 1024px) {
    .thumbnail-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
@media (max-width: 768px) {
    #top-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .top-right {
        justify-content: flex-start;
    }

    .thumbnail-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 520px) {
    .thumbnail-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .search-container {
        width: 100%;
    }

    #globalSearchInput {
        width: 100%;
    }
}

.thumb-item {
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background-color: #f9fafb;
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

.thumb-item img {
    display: block;
    width: 100%;
}

.thumb-item a {
    text-decoration: none;
}

.thumb-title {
    text-align: center;
    font-size: 0.8rem;
    color: #111827;
    background: linear-gradient(90deg, #e0f2fe, #ecfeff);
}

/* Footer */
#footer {
    border-top: 1px solid rgba(148, 163, 184, 0.35);
    padding-top: 12px;
}

.footer-top {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    align-items: center;
}

.footer-info {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.footer-text {
    margin: 0;
    font-size: 0.8rem;
    color: #6b7280;
}

.footer-email {
    font-size: 0.8rem;
}

.footer-email a {
    color: #22c55e;
    font-weight: 600;
}

.footer-socials {
    display: flex;
    gap: 6px;
}

.social-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: #ffffff;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(15, 23, 42, 0.25);
}

/* Rainbow-ish social colors */
.social-facebook { background: #1d4ed8; }
.social-twitter { background: #0ea5e9; }
.social-instagram { background: linear-gradient(135deg, #f97316, #ec4899, #8b5cf6); }
.social-linkedin { background: #0a66c2; }
.social-youtube { background: #ef4444; }

.footer-bottom-text {
    margin: 6px 0 0 0;
    font-size: 0.75rem;
    text-align: right;
    color: #9ca3af;
}

/* Search highlight */
.search-highlight {
    background-color: rgba(34, 197, 94, 0.2);
    border-bottom: 2px solid #22c55e;
    padding: 0 1px;
}

/* Search popup */
.search-popup {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background-color: rgba(15, 23, 42, 0.35);
    z-index: 1000;
}

.search-popup.visible {
    display: flex;
}

.search-popup-content {
    width: min(480px, 90vw);
    max-height: 70vh;
    background-color: #ffffff;
    border-radius: 10px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.4);
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.close-popup-btn {
    border: none;
    background: transparent;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    color: #6b7280;
}

.search-results-list {
    overflow-y: auto;
    padding-right: 4px;
    font-size: 0.85rem;
}

.search-result-item {
    padding: 6px 8px;
    border-radius: 6px;
    margin-bottom: 4px;
    background-color: #f9fafb;
    border: 1px solid #e5e7eb;
    cursor: pointer;
}

.search-result-item:hover {
    background-color: #e0f2fe;
}

.search-result-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.search-result-snippet {
    color: #6b7280;
}

/* Utility */
.hidden {
    display: none !important;
}
