/* ============================================
   基础重置与全局样式
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    text-align: center;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
    min-height: 100vh;
}

body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

/* ============================================
   主题变量定义
   ============================================ */
:root[data-theme='light'] {
    /* 基础颜色 */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    
    /* 文本颜色 */
    --text-primary: #1a1a1a;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    
    /* 边框与阴影 */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e0;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
    
    /* 主色调 */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    
    /* 成功/警告色 */
    --success-color: #10b981;
    --warning-color: #f59e0b;
}

:root[data-theme='dark'] {
    /* 基础颜色 */
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-card: #262626;
    --bg-input: #2d2d2d;
    
    /* 文本颜色 */
    --text-primary: #f7fafc;
    --text-secondary: #cbd5e0;
    --text-muted: #a0aec0;
    
    /* 边框与阴影 */
    --border-color: #4a5568;
    --border-hover: #718096;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.5);
    
    /* 主色调 */
    --primary-color: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-light: #1e3a8a;
    
    /* 成功/警告色 */
    --success-color: #34d399;
    --warning-color: #fbbf24;
}

/* ============================================
   辅助类
   ============================================ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ============================================
   头部样式
   ============================================ */
.header {
    background-color: var(--bg-secondary);
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(10px);
    background-color: rgba(var(--bg-secondary-rgb), 0.95);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.site-title {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.control-btn {
    background: none;
    border: 2px solid var(--border-color);
    color: var(--text-primary);
    font-size: 1.2rem;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.control-btn:hover,
.control-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.theme-toggle {
    font-size: 1.3rem;
}

/* 导航 */
.nav {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    padding: 0.5rem 1.25rem;
    border-radius: 6px;
    transition: all 0.2s;
    font-weight: 500;
    border: 2px solid transparent;
}

.nav-link:hover,
.nav-link:focus {
    background-color: var(--primary-color);
    color: white;
    outline: none;
    border-color: var(--primary-color);
}

.nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

/* ============================================
   主内容区
   ============================================ */
.main {
    flex: 1;
    padding: 1.5rem 0 2.5rem;
}

/* ============================================
   搜索区域
   ============================================ */
.search-section {
    margin-bottom: 2.5rem;
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
}

/* 搜索引擎切换 */
.engine-toggles {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}

.engine-btn {
    padding: 0.6rem 1.25rem;
    border: 2px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.engine-btn:hover,
.engine-btn:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.engine-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.engine-icon {
    font-size: 1rem;
}

/* 搜索输入组 */
.search-input-group {
    display: flex;
    gap: 0;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s;
}

.search-input-group:focus-within {
    box-shadow: var(--shadow-hover);
}

.search-input {
    flex: 1;
    padding: 0.9rem 1.25rem;
    border: none;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 1rem;
    min-width: 0;
}

.search-input:focus {
    outline: none;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    padding: 0.9rem 1.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: background-color 0.2s;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.search-btn:hover,
.search-btn:focus {
    background-color: var(--primary-hover);
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ============================================
   网站分类区
   ============================================ */
.websites-section {
    margin-top: 1.5rem;
}

.section-title {
    font-size: 1.8rem;
    margin-bottom: 2rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

/* 分类标题 */
.category {
    margin-bottom: 2.5rem;
}

.category-title {
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--primary-color);
    color: var(--text-primary);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* 网站网格 */
.websites-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.25rem;
}

/* 卡片样式 */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
    transition: all 0.25s;
    text-align: left;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.card:hover,
.card:focus-within {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.website-link {
    color: inherit;
    text-decoration: none;
    display: block;
    flex: 1;
    outline: none;
}

.website-name {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.4;
}

.website-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.75rem;
    flex-grow: 1;
}

.website-url {
    color: var(--text-muted);
    font-size: 0.85rem;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    padding: 0.25rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    display: inline-block;
}

/* ============================================
   页脚样式
   ============================================ */
.footer {
    background-color: var(--bg-secondary);
    padding: 1.5rem 0;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

.footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

.footer a:hover {
    text-decoration: underline;
}

.footer-info {
    margin-top: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* ============================================
   关于页样式
   ============================================ */
.about-page .main {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
}

.about-content {
    width: 100%;
    max-width: 800px;
}

.about-card {
    text-align: left;
    padding: 2rem;
}

.about-title {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.about-text {
    font-size: 1.1rem;
    margin-bottom: 2rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* 功能特点 */
.about-features h3,
.about-stats h3,
.about-tech h3,
.about-shortcuts h3 {
    font-size: 1.4rem;
    margin: 2rem 0 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.feature-list {
    list-style: none;
    padding-left: 0;
}

.feature-list li {
    margin-bottom: 0.75rem;
    padding-left: 1.5rem;
    position: relative;
    color: var(--text-secondary);
}

.feature-list li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

/* 统计数据 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.25rem;
    text-align: center;
    border: 1px solid var(--border-color);
}

.stat-number {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary-color);
    line-height: 1;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* 技术标签 */
.tech-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1rem;
}

.tech-tag {
    background: var(--primary-light);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid var(--primary-color);
}


/* 返回按钮 */
.back-home {
    margin-top: 3rem;
    text-align: center;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.9rem 2rem;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
}

.btn-primary:hover,
.btn-primary:focus {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    outline: none;
}

/* ============================================
   紧凑模式
   ============================================ */
.compact-mode .websites-grid {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.compact-mode .card {
    padding: 1rem;
}

.compact-mode .website-name {
    font-size: 1.05rem;
    margin-bottom: 0.4rem;
}

.compact-mode .website-desc {
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.compact-mode .website-url {
    font-size: 0.8rem;
    padding: 0.2rem 0.4rem;
}

.compact-mode .category {
    margin-bottom: 2rem;
}

.compact-mode .category-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
}
/* ============================================
   作者联系信息样式
   ============================================ */
.about-author {
    margin: 2rem 0;
    padding: 1.5rem;
    background: var(--bg-secondary);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.about-author h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.author-info {
    text-align: center;
}

.author-info > p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1.1rem;
}

.contact-links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.contact-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--bg-card);
    color: var(--primary-color);
    text-decoration: none;
    border-radius: 8px;
    border: 2px solid var(--primary-color);
    transition: all 0.2s;
    font-weight: 500;
    min-width: 140px;
    justify-content: center;
}

.contact-link:hover,
.contact-link:focus {
    background: var(--primary-color);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    outline: none;
}

.contact-link .contact-icon {
    font-size: 1.2rem;
}

.contact-email {
    color: var(--text-muted);
    font-size: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-card);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    display: inline-block;
    margin: 0;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

/* 响应式调整 */
@media (max-width: 768px) {
    .contact-links {
        flex-direction: column;
        align-items: center;
    }
    
    .contact-link {
        width: 100%;
        max-width: 250px;
    }
    
    .about-author {
        padding: 1.25rem;
    }
}

@media (max-width: 480px) {
    .contact-link {
        min-width: unset;
        padding: 0.6rem 1.25rem;
        font-size: 0.95rem;
    }
    
    .about-author {
        padding: 1rem;
    }
}

/* ============================================
   响应式设计
   ============================================ */

/* 平板设备 */
@media (max-width: 1024px) {
    .websites-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
    
    .compact-mode .websites-grid {
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }
}

/* 大屏手机 */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 1rem;
    }
    
    .nav {
        margin-left: 0;
        width: 100%;
        justify-content: center;
    }
    
    .nav-link {
        padding: 0.4rem 1rem;
        font-size: 0.95rem;
    }
    
    .search-input-group {
        flex-direction: column;
        gap: 0;
    }
    
    .search-input {
        border-radius: 8px 8px 0 0;
        padding: 0.8rem 1rem;
    }
    
    .search-btn {
        border-radius: 0 0 8px 8px;
        padding: 0.8rem 1rem;
        justify-content: center;
    }
    
    .websites-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .engine-toggles {
        gap: 0.5rem;
    }
    
    .engine-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .section-title {
        font-size: 1.5rem;
    }
    
    .category-title {
        font-size: 1.25rem;
    }
    
    .about-card {
        padding: 1.5rem;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .tech-tags {
        gap: 0.5rem;
    }
    
    .tech-tag {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }
}

/* 小屏手机 */
@media (max-width: 480px) {
    .container {
        padding: 0 1rem;
    }
    
    .site-title {
        font-size: 1.3rem;
    }
    
    .control-btn {
        width: 40px;
        height: 40px;
        font-size: 1.1rem;
    }
    
    .section-title {
        font-size: 1.3rem;
    }
    
    .category-title {
        font-size: 1.15rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .website-name {
        font-size: 1.05rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .shortcut-list {
        grid-template-columns: 1fr;
    }
}

/* 超宽屏幕 */
@media (min-width: 1400px) {
    .websites-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .compact-mode .websites-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* 打印样式 */
@media print {
    .header-controls,
    .search-section,
    .footer {
        display: none;
    }
    
    .card {
        break-inside: avoid;
        border: 1px solid #ccc;
        box-shadow: none;
    }
}