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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
    min-height: 100vh;
}

.nav-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #f093fb 100%);
    background-size: 200% 200%;
    animation: gradientShift 8s ease infinite;
    padding: 24px 0;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3);
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.nav-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.logo a {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: #fff;
    transition: transform 0.3s ease;
}

.logo a:hover {
    transform: scale(1.02);
}

.logo img {
    height: 44px;
    margin-right: 12px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.logo-text {
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    letter-spacing: 1px;
}

.search-box {
    flex: 1;
    max-width: 650px;
    margin: 0 24px;
}

.search-box .input-group {
    margin-bottom: 10px;
}

.search-box .search-addon {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 24px 0 0 24px;
    color: rgba(255, 255, 255, 0.8);
    padding: 0 16px;
}

.search-box .form-control {
    height: 48px;
    font-size: 16px;
    border: none;
    border-radius: 0;
    padding: 0 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

.search-box .form-control:focus {
    outline: none;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.search-box .btn {
    height: 48px;
    padding: 0 28px;
    border-radius: 0 24px 24px 0;
    border: none;
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.search-box .btn:hover {
    background: linear-gradient(135deg, #ee5a5a, #dc4a4a);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.search-engines {
    text-align: center;
}

.engine-label {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    margin-right: 12px;
}

.engine-link {
    color: rgba(255, 255, 255, 0.85);
    font-size: 12px;
    margin: 0 10px;
    text-decoration: none;
    padding: 3px 10px;
    border-radius: 12px;
    transition: all 0.3s;
    border: 1px solid transparent;
}

.engine-link:hover,
.engine-link.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

.header-right {
    color: #fff;
}

.main-container {
    padding: 32px 15px;
    min-height: calc(100vh - 220px);
}

.category-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 16px 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.category-nav .nav-pills {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.category-nav .nav-pills > li > a {
    color: #555;
    border-radius: 20px;
    padding: 8px 20px;
    margin-right: 10px;
    margin-bottom: 8px;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 500;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

.category-nav .nav-pills > li > a:hover {
    background-color: #f0f4ff;
    color: #667eea;
    border-color: #d6deff;
    transform: translateY(-1px);
}

.category-nav .nav-pills > li.active > a,
.category-nav .nav-pills > li.active > a:hover,
.category-nav .nav-pills > li.active > a:focus {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transform: translateY(-1px);
}

.nav-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 32px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
}

.loading {
    padding: 80px 0;
    color: #999;
}

.loading i {
    color: #667eea;
    margin-bottom: 20px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* === 树形目录结构 === */
.tree-root {
    margin-bottom: 36px;
}

.tree-root:last-child {
    margin-bottom: 0;
}

.directory-section {
    margin-bottom: 24px;
}

.directory-section:last-child {
    margin-bottom: 0;
}

.directory-section.level-1 {
    margin-left: 20px;
    padding-left: 16px;
    border-left: 2px solid #e0e4ea;
}

.directory-section.level-2 {
    margin-left: 40px;
    padding-left: 16px;
    border-left: 2px dashed #e0e4ea;
}

.directory-section.level-3 {
    margin-left: 60px;
    padding-left: 16px;
    border-left: 2px dotted #e0e4ea;
}

.directory-title {
    font-size: 18px;
    font-weight: 700;
    color: #333;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 3px solid transparent;
    border-image: linear-gradient(135deg, #667eea, #764ba2) 1;
    display: inline-block;
    position: relative;
}

.directory-title::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    width: 40px;
    height: 3px;
    background: linear-gradient(135deg, #ff6b6b, #f093fb);
    border-radius: 3px;
}

.directory-subtitle {
    font-size: 15px;
    font-weight: 600;
    color: #555;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #e8eaed;
}

.tree-children {
    margin-top: 12px;
}

.tree-child-item {
    margin-bottom: 16px;
}

/* === 网站卡片网格 === */
.site-grid {
    display: flex;
    flex-wrap: wrap;
    margin: -12px;
}

/* 不同层级的网格列数 */
.site-grid.grid-cols-level-6 .site-card { width: calc(16.666% - 24px); }
.site-grid.grid-cols-level-5 .site-card { width: calc(20% - 24px); }
.site-grid.grid-cols-level-4 .site-card { width: calc(25% - 24px); }
.site-grid.grid-cols-level-3 .site-card { width: calc(33.333% - 24px); }
.site-grid.grid-cols-level-2 .site-card { width: calc(50% - 24px); }

.site-card {
    width: calc(16.666% - 24px);
    margin: 12px;
    background: linear-gradient(145deg, #ffffff, #f8f9fa);
    border-radius: 12px;
    padding: 20px 12px;
    text-align: center;
    transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    border: 1px solid #e9ecef;
    position: relative;
    overflow: hidden;
}

.site-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #667eea, #764ba2, #f093fb);
    transform: scaleX(0);
    transition: transform 0.35s ease;
    transform-origin: left;
}

.site-card:hover::before {
    transform: scaleX(1);
}

.site-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(102, 126, 234, 0.15);
    background: #fff;
    border-color: #d6deff;
}

.site-icon {
    width: 56px;
    height: 56px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #f5f7fa, #e4e8ec);
    border-radius: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
}

.site-card:hover .site-icon {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.2);
}

.site-icon img {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
}

.site-icon .fa {
    font-size: 32px;
    color: #667eea;
}

.site-name {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 5px;
    font-weight: 500;
}

.site-desc {
    font-size: 12px;
    color: #888;
    margin-top: 6px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 5px;
}

.site-card a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.nav-footer {
    background: rgba(255, 255, 255, 0.95);
    padding: 24px 0;
    border-top: 1px solid #e9ecef;
    text-align: center;
    color: #888;
    font-size: 13px;
    margin-top: 40px;
}

.nav-footer p {
    margin: 0;
}

.no-data {
    text-align: center;
    padding: 80px 0;
    color: #999;
}

.no-data i {
    font-size: 56px;
    margin-bottom: 20px;
    color: #ddd;
}

.site-count {
    display: inline-block;
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    font-weight: 500;
}

.search-results {
    margin-bottom: 24px;
    padding: 16px 20px;
    background: #f0f4ff;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.search-results .result-count {
    color: #667eea;
    font-weight: 600;
}

@media (max-width: 1200px) {
    .site-grid.grid-cols-level-6 .site-card,
    .site-grid.grid-cols-level-5 .site-card { width: calc(20% - 24px); }
}

@media (max-width: 992px) {
    .site-grid .site-card { width: calc(25% - 24px) !important; }
    
    .nav-header .container {
        flex-direction: column;
    }
    
    .logo {
        margin-bottom: 16px;
    }
    
    .search-box {
        width: 100%;
        max-width: 100%;
        margin: 0 0 16px 0;
    }
    
    .logo-text {
        font-size: 22px;
    }
    
    .directory-section.level-1 { margin-left: 12px; }
    .directory-section.level-2 { margin-left: 24px; }
    .directory-section.level-3 { margin-left: 36px; }
}

@media (max-width: 768px) {
    .site-grid .site-card { width: calc(33.333% - 24px) !important; }
    
    .nav-content {
        padding: 24px 16px;
    }
    
    .directory-title {
        font-size: 16px;
    }
    
    .site-icon {
        width: 48px;
        height: 48px;
    }
    
    .site-icon img {
        width: 30px;
        height: 30px;
    }
}

@media (max-width: 480px) {
    .site-grid .site-card { width: calc(50% - 24px) !important; }
    
    .nav-header {
        padding: 16px 0;
    }
    
    .logo img {
        height: 36px;
    }
    
    .logo-text {
        font-size: 20px;
    }
    
    .search-box .form-control,
    .search-box .btn {
        height: 42px;
    }
}
