* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #4A90E2;
    --secondary-color: #6BB3FF;
    --text-dark: #333;
    --text-light: #666;
    --bg-light: #F0F8FF;
    --border-color: #B8D4F0;
    --shadow: 0 2px 8px rgba(74,144,226,0.2);
    --shadow-hover: 0 4px 16px rgba(74,144,226,0.3);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif;
    background: linear-gradient(135deg, #87CEEB 0%, #6BB3FF 50%, #4A90E2 100%);
    min-height: 100vh;
    color: var(--text-dark);
    line-height: 1.6;
    position: relative;
    overflow-x: hidden;
    transition: background 1s ease-in-out;
}

/* 夜晚主题 */
body.night-mode {
    background: #0a0a0a;
    color: #e0e0e0;
}

/* 星空容器 */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    opacity: 0;
    transition: opacity 1s ease-in-out;
    pointer-events: none;
}

body.night-mode .stars-container {
    opacity: 1;
}

/* 星星样式 */
.star {
    position: absolute;
    background: white;
    border-radius: 50%;
    animation: twinkle 3s infinite;
}

.star.small {
    width: 1px;
    height: 1px;
}

.star.medium {
    width: 2px;
    height: 2px;
}

.star.large {
    width: 3px;
    height: 3px;
}

/* 星星闪烁动画 */
@keyframes twinkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

/* 月亮样式 */
.moon {
    position: fixed;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #f5f5dc 0%, #d4d4d4 50%, #a0a0a0 100%);
    box-shadow: 0 0 40px rgba(245, 245, 220, 0.6),
                0 0 80px rgba(245, 245, 220, 0.4),
                inset -15px -15px 30px rgba(0, 0, 0, 0.2);
    z-index: 0;
    transition: left 0.5s ease-out, top 0.5s ease-out, opacity 0.5s ease-in-out;
    pointer-events: none;
    will-change: left, top;
    opacity: 0;
}

body.night-mode .moon {
    opacity: 1;
}

/* 月亮上的阴影（模拟月相） */
.moon::before {
    content: '';
    position: absolute;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, rgba(0, 0, 0, 0.3) 0%, transparent 70%);
    top: 10px;
    left: 10px;
}

/* 太阳样式 */
.sun {
    position: fixed;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, #FFD700 0%, #FFA500 100%);
    box-shadow: 0 0 60px rgba(255, 215, 0, 0.8), 
                0 0 100px rgba(255, 165, 0, 0.6),
                inset -10px -10px 20px rgba(255, 200, 0, 0.3);
    z-index: 0;
    transition: left 0.5s ease-out, top 0.5s ease-out, opacity 0.5s ease-in-out;
    pointer-events: none;
    will-change: left, top;
    opacity: 1;
}

body.night-mode .sun {
    opacity: 0;
}

/* 顶部导航栏 */
.top-navbar {
    position: fixed;
    top: 10px;
    left: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

/* 网站标题 */
.site-title {
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    white-space: nowrap;
    min-width: 120px;
    flex-shrink: 0;
}

body.night-mode .site-title {
    text-shadow: 0 2px 10px rgba(255,255,255,0.3);
}

/* 右上角按钮 */
.top-actions {
    display: flex;
    gap: 10px;
    flex-shrink: 0;
    margin-right: 10px;
}

.btn-theme-toggle,
.btn-login,
.btn-admin,
.btn-add-site,
.btn-logout {
    padding: 8px 20px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-theme-toggle {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 18px;
    padding: 8px 16px;
    backdrop-filter: blur(10px);
}

.btn-theme-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

body.night-mode .btn-theme-toggle {
    background: rgba(255, 255, 255, 0.1);
}

.btn-login {
    background: var(--primary-color);
    color: white;
}

.btn-login:hover {
    background: #357ABD;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-admin {
    background: var(--bg-light);
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn-admin:hover {
    background: white;
    box-shadow: var(--shadow);
}

.btn-add-site {
    background: linear-gradient(135deg, #34d399 0%, #059669 100%);
    color: white;
    box-shadow: 0 12px 25px rgba(52, 211, 153, 0.35);
    border-radius: 999px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.btn-add-site:hover {
    background-position: right center;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 18px 30px rgba(52, 211, 153, 0.45);
}

body.night-mode .btn-add-site {
    background: linear-gradient(135deg, #22c55e 0%, #047857 100%);
    box-shadow: 0 12px 25px rgba(5, 150, 105, 0.45);
}

body.night-mode .btn-add-site:hover {
    box-shadow: 0 18px 30px rgba(5, 150, 105, 0.55);
}

.btn-logout {
    background: #EF4444;
    color: white;
}

.btn-logout:hover {
    background: #DC2626;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

body.night-mode .btn-logout {
    background: #DC2626;
}

body.night-mode .btn-logout:hover {
    background: #B91C1C;
}

/* 主容器 */
.main-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 30px 20px;
    padding-top: 90px;
    position: relative;
    z-index: 1;
}

/* 标题区域 */
.hero-section {
    text-align: center;
    color: white;
    margin-bottom: 50px;
    padding: 40px 0;
}

.hero-title {
    font-size: 2.5em;
    font-weight: 600;
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

body.night-mode .hero-title {
    text-shadow: 0 2px 10px rgba(255,255,255,0.3);
}

.hero-subtitle {
    font-size: 1.2em;
    opacity: 0.9;
    font-weight: 300;
}

/* 搜索区域 - 顶部固定 */
.search-section-top {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    justify-content: center;
    max-width: 65%;
    min-width: 300px;
}

/* 搜索区域 - 原样式保留用于其他页面 */
.search-section {
    margin-bottom: 50px;
}

.search-box {
    width: 100%;
    max-width: 100%;
    margin: 0;
    position: relative;
    display: flex;
    align-items: center;
    background: white;
    border-radius: 50px;
    padding: 0 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    transition: all 0.3s;
}

.search-box:focus-within {
    box-shadow: 0 6px 30px rgba(0,0,0,0.2);
    transform: translateY(-2px);
}

.search-icon {
    width: 20px;
    height: 20px;
    color: var(--text-light);
    margin-right: 10px;
}

#searchInput {
    flex: 1;
    padding: 18px 10px;
    border: none;
    font-size: 16px;
    outline: none;
    background: transparent;
}

.search-btn {
    padding: 12px 30px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s;
}

.search-btn:hover {
    background: #357ABD;
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(74,144,226,0.4);
}

/* 分类容器 */
.categories-container {
    display: grid;
    gap: 25px;
}

.category {
    background: white;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s;
}

.category:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
}

.category-title {
    font-size: 1.5em;
    color: var(--text-dark);
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--primary-color);
    font-weight: 600;
}

.sites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}

.site-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 12px;
    background: var(--bg-light);
    border-radius: 12px;
    text-decoration: none;
    color: var(--text-dark);
    transition: all 0.3s;
    cursor: pointer;
    border: 2px solid transparent;
}

.site-item:hover {
    background: white;
    border-color: var(--primary-color);
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    color: var(--text-dark);
}

.site-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    margin-bottom: 10px;
    object-fit: cover;
    background: white;
    box-shadow: var(--shadow);
}

.site-name {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 6px;
    word-break: break-word;
    line-height: 1.3;
}

.site-description {
    font-size: 11px;
    color: var(--text-light);
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 精选推荐 */
.featured-section {
    margin-bottom: 50px;
}

.section-title {
    font-size: 2em;
    color: white;
    margin-bottom: 30px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.2);
    font-weight: 600;
}

body.night-mode .section-title {
    text-shadow: 0 2px 10px rgba(255,255,255,0.3);
}

/* 登录模态框 */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
    overflow-y: auto;
    padding: 40px 20px;
}

.modal-content {
    background-color: white;
    margin: auto;
    padding: 40px;
    border-radius: 20px;
    width: 90%;
    max-width: 480px;
    max-height: calc(100vh - 80px);
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    position: relative;
    overflow-y: auto;
}

.close {
    color: var(--text-light);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 20px;
    top: 15px;
    transition: color 0.3s;
}

.close:hover {
    color: var(--text-dark);
}

.modal-content h2 {
    margin-bottom: 30px;
    color: var(--text-dark);
    font-size: 1.8em;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-dark);
    font-weight: 500;
}

.form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.btn-submit {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 10px;
    box-shadow: 0 12px 20px rgba(99, 102, 241, 0.35);
    background-size: 200%;
}

.btn-submit:hover {
    background-position: right center;
    transform: translateY(-2px);
    box-shadow: 0 18px 30px rgba(99, 102, 241, 0.45);
}

.btn-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
    min-height: 20px;
}

.success-message {
    color: #10B981;
    font-size: 14px;
    margin-top: 10px;
    text-align: center;
    min-height: 20px;
}

.form-group .required {
    color: #e74c3c;
}

.form-group .optional {
    color: #999;
    font-weight: normal;
}

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: #666;
}

body.night-mode .form-hint {
    color: #999;
}

.form-group textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 15px;
    transition: all 0.3s;
    font-family: inherit;
    resize: vertical;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.form-actions .btn-submit {
    flex: 1;
    margin-top: 0;
}

.btn-cancel {
    padding: 14px 20px;
    background: #e0e0e0;
    color: var(--text-dark);
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-cancel:hover {
    background: #d0d0d0;
}

body.night-mode .btn-cancel {
    background: #333;
    color: #e0e0e0;
}

body.night-mode .btn-cancel:hover {
    background: #444;
}

/* 自动完成样式 */
.autocomplete-wrapper {
    position: relative;
}

.autocomplete-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

body.night-mode .autocomplete-suggestions {
    background: #1a1a1a;
    border-color: #444;
}

.autocomplete-suggestions.show {
    display: block;
}

.autocomplete-suggestion {
    padding: 12px 15px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

body.night-mode .autocomplete-suggestion {
    border-bottom-color: #333;
}

.autocomplete-suggestion:last-child {
    border-bottom: none;
}

.autocomplete-suggestion:hover,
.autocomplete-suggestion.selected {
    background: var(--bg-light);
}

body.night-mode .autocomplete-suggestion:hover,
body.night-mode .autocomplete-suggestion.selected {
    background: #2a2a2a;
}

/* 后台管理样式 */
.admin-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    margin-bottom: 30px;
    position: relative;
}

.admin-header h1 {
    font-size: 2.5em;
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.btn-back-home {
    padding: 10px 24px;
    background: white;
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.btn-back-home:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.admin-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.admin-panel {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: var(--shadow);
}

.admin-panel h2 {
    color: var(--text-dark);
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 3px solid var(--primary-color);
    font-size: 1.5em;
}

.form-select, input[type="text"], input[type="url"], textarea {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 14px;
    transition: all 0.3s;
    font-family: inherit;
}

.form-select:focus, input[type="text"]:focus, input[type="url"]:focus, textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #357ABD;
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn-danger {
    background: #e74c3c;
    color: white;
    padding: 8px 16px;
    font-size: 13px;
}

.btn-danger:hover {
    background: #c0392b;
}

.categories-list, .sites-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.category-item, .site-item-admin {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-light);
    border-radius: 10px;
    transition: all 0.3s;
}

.category-item:hover, .site-item-admin:hover {
    background: #f0f0f0;
}

.category-item span, .site-item-admin span {
    flex: 1;
    color: var(--text-dark);
}

.empty-message {
    text-align: center;
    color: var(--text-light);
    padding: 40px;
    font-size: 16px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .top-actions {
        top: 10px;
        right: 10px;
        flex-direction: column;
        gap: 8px;
    }
    
    .btn-theme-toggle,
    .btn-login,
    .btn-admin,
    .btn-add-site {
        padding: 6px 16px;
        font-size: 12px;
    }
    
    .btn-theme-toggle {
        font-size: 16px;
        padding: 6px 12px;
    }
    
    .search-section-top {
        top: 70px;
        padding: 15px;
    }
    
    .main-container {
        padding-top: 140px;
    }
    
    .hero-title {
        font-size: 1.8em;
    }
    
    .hero-subtitle {
        font-size: 1em;
    }
    
    .search-box {
        flex-direction: column;
        border-radius: 15px;
        padding: 15px;
    }
    
    .search-btn {
        width: 100%;
        margin-top: 10px;
    }
    
    .admin-content {
        grid-template-columns: 1fr;
    }
    
    .sites-grid {
        grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
        gap: 10px;
    }
    
    .site-item {
        padding: 12px 8px;
    }
    
    .site-icon {
        width: 40px;
        height: 40px;
    }
    
    .site-name {
        font-size: 12px;
    }
    
    .site-description {
        font-size: 10px;
    }
    
    .category {
        padding: 15px;
    }
    
    .category-title {
        font-size: 1.3em;
        margin-bottom: 15px;
    }
    
    .categories-container {
        gap: 20px;
    }
}
