/* ===== CSS Variables & Theme ===== */
:root {
    --bg-primary: #f5f7fa;
    --bg-secondary: #ffffff;
    --bg-card: #ffffff;
    --text-primary: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #999;
    --border-color: rgba(0,0,0,0.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --radius: 12px;
    --radius-sm: 8px;
    --hero-overlay: linear-gradient(
        to bottom,
        rgba(0,0,0,0.55) 15%,
        rgba(0,0,0,0.35) 40%,
        rgba(245,247,250,0.7) 70%,
        rgba(245,247,250,1) 100%
    );
    --search-bg: rgba(255,255,255,0.95);
    --search-border: rgba(255,255,255,0.6);
    --hot-header-text: #fff;
    --footer-bg: #1a1a2e;
    --footer-text: #ccc;
    --tab-bg: rgba(255,255,255,0.25);
    --tab-active-bg: rgba(255,255,255,0.95);
    --tab-text: rgba(255,255,255,0.85);
    --tab-active-text: var(--accent);
    --site-card-hover: #f0f0ff;
    --scrollbar-track: #f1f1f1;
    --scrollbar-thumb: #ccc;
}

[data-theme="dark"] {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #1e1e35;
    --text-primary: #e0e0e0;
    --text-secondary: #aaa;
    --text-muted: #777;
    --border-color: rgba(255,255,255,0.08);
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 30px rgba(0,0,0,0.5);
    --hero-overlay: linear-gradient(
        to bottom,
        rgba(0,0,0,0.6) 0%,
        rgba(0,0,0,0.45) 40%,
        rgba(15,15,26,0.8) 75%,
        rgba(15,15,26,1) 100%
    );
    --search-bg: rgba(30,30,53,0.95);
    --search-border: rgba(255,255,255,0.1);
    --footer-bg: #0a0a15;
    --footer-text: #888;
    --tab-bg: rgba(255,255,255,0.08);
    --tab-active-bg: rgba(30,30,53,0.95);
    --tab-text: rgba(255,255,255,0.6);
    --tab-active-text: #818cf8;
    --site-card-hover: #2a2a45;
    --scrollbar-track: #1a1a2e;
    --scrollbar-thumb: #333;
}

/* ===== Global ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial,
                 "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background 0.3s, color 0.3s;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }

/* ===== Theme Toggle ===== */
.theme-toggle {
    position: absolute; top: 20px; right: 20px; z-index: 10;
    width: 46px; height: 46px; border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    color: #fff; font-size: 1.2rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s;
    box-shadow: 0 2px 15px rgba(0,0,0,0.2);
}
.theme-toggle:hover { transform: scale(1.1); background: rgba(255,255,255,0.25); }
[data-theme="dark"] .theme-toggle { border-color: rgba(255,255,255,0.2); background: rgba(30,30,53,0.6); }

/* ===== Back to Top ===== */
.back-to-top {
    position: fixed; bottom: 30px; right: 24px; z-index: 1000;
    width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--accent); color: #fff; font-size: 1.1rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 12px rgba(99,102,241,0.4);
    opacity: 0; visibility: hidden; transform: translateY(10px);
    transition: opacity 0.3s, visibility 0.3s, transform 0.3s, background 0.3s;
}
.back-to-top.visible { opacity: 1; visibility: visible; transform: translateY(0); }
.back-to-top:hover { background: var(--accent-hover); transform: translateY(-2px); }

/* ===== Hero Section ===== */
.hero-section {
    position: relative;
    background: url('../images/background.avif') center / cover no-repeat;
    padding: 80px 0 60px; min-height: 420px;
    display: flex; align-items: center;
}
.hero-overlay { position: absolute; inset: 0; background: var(--hero-overlay); z-index: 1; }
.hero-title {
    text-align: center; font-size: 2.8rem; font-weight: 800; color: #fff;
    text-shadow: 0 2px 20px rgba(0,0,0,0.3); margin-bottom: 8px; letter-spacing: 2px;
}
.hero-subtitle {
    text-align: center; color: rgba(255,255,255,0.85); font-size: 1.1rem;
    margin-bottom: 36px; text-shadow: 0 1px 8px rgba(0,0,0,0.2);
}

/* ===== Search Box ===== */
.search-box { max-width: 680px; }
.search-tabs { display: flex; gap: 4px; margin-bottom: 10px; justify-content: center; flex-wrap: wrap; }
.search-tab {
    padding: 6px 16px; border: none; border-radius: 20px;
    background: var(--tab-bg); color: var(--tab-text); font-size: 0.88rem;
    cursor: pointer; transition: all 0.25s;
    backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}
.search-tab:hover { background: rgba(255,255,255,0.5); color: var(--text-primary); }
.search-tab.active {
    background: var(--tab-active-bg); color: var(--tab-active-text);
    font-weight: 600; box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.search-form .input-group {
    background: var(--search-bg); border-radius: 50px; overflow: hidden;
    box-shadow: var(--shadow-lg); border: 1px solid var(--search-border);
}
.search-input {
    border: none !important; padding: 14px 24px !important; font-size: 1.05rem;
    background: transparent !important; color: var(--text-primary) !important;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus { box-shadow: none !important; }
.search-btn {
    padding: 14px 28px !important;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff !important; font-weight: 600; border: none; font-size: 1rem;
    transition: all 0.3s;
}
.search-btn:hover { background: linear-gradient(135deg, #4f46e5, #7c3aed); }

/* ===== Section Title ===== */
.section-title {
    font-size: 1.3rem; font-weight: 700; color: var(--text-primary);
    margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.section-title i { font-size: 1.1rem; }

/* ===== Hot Section ===== */
.hot-section { background: var(--bg-primary); }
.hot-list-wrapper {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent; padding-bottom: 8px;
}
.hot-list-wrapper::-webkit-scrollbar { height: 6px; }
.hot-list-wrapper::-webkit-scrollbar-track { background: transparent; }
.hot-list-wrapper::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
.hot-list-scroll { display: flex; gap: 16px; }
.hot-card {
    flex: 1; min-width: 260px; background: var(--bg-card);
    border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
    transition: box-shadow 0.3s, transform 0.3s; border: 1px solid var(--border-color);
}
.hot-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.hot-card-header {
    padding: 10px 14px; display: flex; align-items: center; gap: 6px;
    background: var(--bg-card); color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}
.hot-card-logo { width: 20px; height: 20px; object-fit: contain; border-radius: 4px; flex-shrink: 0; }
.hot-card-name { font-weight: 700; font-size: 0.9rem; }
.hot-card-label { font-size: 0.78rem; color: var(--text-muted); margin-left: auto; }
.hot-refresh-btn {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    padding: 2px 4px; font-size: 0.9rem; line-height: 1; border-radius: 4px;
    transition: color 0.2s, background 0.2s; display: flex; align-items: center; margin-left: 4px;
}
.hot-refresh-btn:hover { color: var(--accent); background: var(--site-card-hover); }
.hot-refresh-btn.spinning i { animation: spin 0.6s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.hot-card-body {
    height: 300px; overflow-y: auto; padding: 4px 0;
    scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) transparent;
}
.hot-card-body::-webkit-scrollbar { width: 4px; }
.hot-card-body::-webkit-scrollbar-track { background: transparent; }
.hot-card-body::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 2px; }
.hot-item {
    display: flex; align-items: baseline; padding: 6px 14px; gap: 8px;
    transition: background 0.15s; cursor: pointer;
}
.hot-item:hover { background: var(--site-card-hover); }
.hot-rank {
    flex-shrink: 0; width: 18px; height: 18px; border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 700; color: #fff; background: #ccc;
}
.hot-rank.top1 { background: #ff4757; }
.hot-rank.top2 { background: #ff6b35; }
.hot-rank.top3 { background: #ffa502; }
.hot-text {
    flex: 1; font-size: 0.8rem; line-height: 1.45; color: var(--text-primary);
    overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.hot-heat { flex-shrink: 0; font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.loading-spinner {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    height: 100%; gap: 12px; color: var(--text-muted); font-size: 0.9rem;
}
.loading-spinner .spinner-border { width: 2rem; height: 2rem; }

/* ===== Navigation Section ===== */
.nav-section { background: var(--bg-primary); }
.nav-category {
    background: var(--bg-card); border-radius: var(--radius); padding: 24px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
}
.site-card {
    display: flex; align-items: center; justify-content: center; gap: 8px;
    border-radius: var(--radius-sm); transition: all 0.25s; text-decoration: none;
    color: var(--text-primary); border: 1px solid var(--border-color);
}
.site-card:hover {
    transform: translateY(-2px); box-shadow: var(--shadow-md);
    color: var(--accent); border-color: var(--accent);
    background: var(--site-card-hover); z-index: 10;
}
.site-icon { width: 16px; height: 16px; object-fit: contain; flex-shrink: 0; border-radius: 2px; }
.site-icon-lg { width: 32px; height: 32px; border-radius: 6px; }
.search-tab-icon { width: 14px; height: 14px; object-fit: contain; vertical-align: -1px; border-radius: 2px; }
.site-info { flex: 1; min-width: 0; }
.site-name { font-weight: 700; font-size: 0.92rem; line-height: 1.3; color: var(--text-primary); }
.site-desc {
    font-size: 0.75rem; line-height: 1.4; color: var(--text-muted); margin-top: 2px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tooltip { --bs-tooltip-max-width: 280px; --bs-tooltip-font-size: 0.78rem; }

/* Large card */
.site-card-lg {
    padding: 16px; justify-content: flex-start; gap: 12px;
    background: linear-gradient(135deg, rgba(99,102,241,0.05), rgba(139,92,246,0.05));
}
.site-card-lg .site-name { font-size: 1.05rem; }
.site-card-lg .site-desc { font-size: 0.78rem; }
.site-card-lg:hover {
    background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(139,92,246,0.12));
}
.site-card-lg:hover .site-name { color: var(--accent); }

/* Detail card */
.site-card-detail {
    padding: 10px 12px; justify-content: flex-start; gap: 10px;
    background: var(--bg-secondary);
}
.site-card-detail .site-icon { width: 22px; height: 22px; border-radius: 4px; }
.site-card-detail .site-name { font-size: 0.88rem; }
.site-card-detail .site-desc { font-size: 0.72rem; }
.site-card-detail:hover .site-name { color: var(--accent); }

/* Small card */
.site-card-sm {
    padding: 12px 10px; font-size: 0.9rem; font-weight: 500;
    background: var(--bg-secondary);
}

/* ===== Footer ===== */
.site-footer {
    background: var(--footer-bg); color: var(--footer-text);
    padding: 36px 0 24px; margin-top: 40px;
}
.footer-links {
    display: flex; justify-content: center; gap: 28px; flex-wrap: wrap; margin-bottom: 20px;
}
.footer-links a {
    color: var(--footer-text); font-size: 0.95rem; transition: color 0.25s;
    display: flex; align-items: center; gap: 4px;
}
.footer-links a:hover { color: #fff; }
.footer-copy { text-align: center; font-size: 0.85rem; color: #666; line-height: 1.8; }
.footer-copy a { color: #888; transition: color 0.25s; }
.footer-copy a:hover { color: #fff; }

/* ===== Subpage ===== */
.page-section { background: var(--bg-primary); min-height: 60vh; padding: 40px 0; }
.page-card {
    background: var(--bg-card); border-radius: var(--radius); padding: 32px;
    box-shadow: var(--shadow-sm); border: 1px solid var(--border-color);
}
.page-card h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 20px; }
.page-card .form-control { background: var(--bg-secondary); border-color: var(--border-color); color: var(--text-primary); }
.page-card .form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 .25rem rgba(99,102,241,.15); }
.page-card .btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6); border: none;
    padding: 10px 32px; font-weight: 600;
}
.page-card .btn-primary:hover { background: linear-gradient(135deg, #4f46e5, #7c3aed); }

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .hero-title { font-size: 2.2rem; }
    .hero-section { padding: 60px 0 50px; min-height: 360px; }
    .hot-list-scroll { min-width: max-content; }
    .hot-card { flex: none; width: 280px; min-width: 280px; }
}
@media (max-width: 767.98px) {
    .hero-title { font-size: 1.8rem; letter-spacing: 1px; }
    .hero-subtitle { font-size: 0.95rem; margin-bottom: 24px; }
    .hero-section { padding: 50px 0 40px; min-height: 320px; }
    .search-tab { padding: 5px 12px; font-size: 0.8rem; }
    .search-input { padding: 12px 18px !important; font-size: 0.95rem; }
    .search-btn { padding: 12px 20px !important; font-size: 0.9rem; }
    .hot-card { width: 260px; min-width: 260px; }
    .hot-card-body { height: 260px; }
    .nav-category { padding: 16px; }
    .section-title { font-size: 1.15rem; }
    .site-card-lg { padding: 14px 12px; }
    .site-card-lg .site-name { font-size: 0.95rem; }
    .theme-toggle { top: 12px; right: 12px; width: 40px; height: 40px; font-size: 1rem; }
    .back-to-top { bottom: 20px; right: 16px; width: 38px; height: 38px; font-size: 1rem; }
    .footer-links { gap: 16px; }
    .page-card { padding: 20px; }
}
@media (max-width: 575.98px) {
    .search-tabs { gap: 3px; }
    .search-tab { padding: 4px 10px; font-size: 0.78rem; }
}

/* ===== Smooth transitions ===== */
.hero-section, .hot-section, .nav-section, .nav-category, .hot-card,
.site-card, .site-footer, .search-form .input-group, .search-tab {
    transition: background 0.3s, color 0.3s, border-color 0.3s, box-shadow 0.3s;
}

/* ===== Animations ===== */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.hot-card { animation: fadeInUp 0.5s ease forwards; }
.hot-card:nth-child(1) { animation-delay: 0.05s; }
.hot-card:nth-child(2) { animation-delay: 0.15s; }
.hot-card:nth-child(3) { animation-delay: 0.25s; }
.hot-card:nth-child(4) { animation-delay: 0.35s; }
.nav-category { animation: fadeInUp 0.5s ease forwards; }
