/* Modern CSS Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #818cf8;
    --secondary: #8b5cf6;
    --accent: #06b6d4;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-gradient-start: #6366f1;
    --bg-gradient-end: #8b5cf6;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-body);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

/* Header Styles */
header {
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: white;
    padding: 40px 0 50px;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
    opacity: 0.5;
}

header .container {
    position: relative;
    z-index: 1;
}

header h1 {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
    text-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header .subtitle {
    font-size: 1.2rem;
    opacity: 0.85;
    font-weight: 400;
    margin-bottom: 28px;
}

header nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

header nav a {
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 100px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255,255,255,0.1);
}

header nav a:hover {
    background: rgba(255,255,255,0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

header nav a.active {
    background: rgba(255,255,255,0.9);
    color: var(--primary);
    font-weight: 600;
}

/* Main Content */
main {
    padding: 40px 0 60px;
}

/* Section Header */
section h2 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 12px;
}

section h2::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, #e2e8f0 0%, transparent 100%);
}

/* Articles Grid */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

/* Article Card */
.article-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #f1f5f9;
    position: relative;
    overflow: hidden;
}

.article-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary) 0%, var(--secondary) 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.article-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: #e2e8f0;
}

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

.article-card h3 {
    font-size: 1.15rem;
    font-weight: 600;
    line-height: 1.5;
    margin-bottom: 12px;
}

.article-card h3 a {
    color: var(--text-primary);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s;
}

.article-card h3 a:hover {
    color: var(--primary);
}

.article-card .meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 12px;
}

.article-card .meta::before {
    content: '📅';
    font-size: 0.875rem;
}

.article-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Related Links Sidebar */
aside.related-links {
    background: linear-gradient(135deg, #f0f9ff 0%, #f5f3ff 100%);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-top: 40px;
    border: 1px solid #e0e7ff;
}

aside.related-links h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

aside.related-links h3::before {
    content: '🔥';
}

aside.related-links ul {
    list-style: none;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

aside.related-links li a {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    background: white;
    transition: all 0.2s;
    font-size: 0.95rem;
    box-shadow: var(--shadow-sm);
}

aside.related-links li a::before {
    content: '→';
    color: var(--primary);
    font-weight: bold;
    transition: transform 0.2s;
}

aside.related-links li a:hover {
    color: var(--primary);
    background: white;
    box-shadow: var(--shadow-md);
    transform: translateX(4px);
}

aside.related-links li a:hover::before {
    transform: translateX(4px);
}

/* Footer */
footer {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #94a3b8;
    text-align: center;
    padding: 32px 0;
    margin-top: 60px;
}

footer p {
    font-size: 0.95rem;
}

/* Intro Section (Homepage) */
.intro {
    background: var(--bg-card);
    padding: 32px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 32px;
}

.intro p {
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 1.05rem;
    line-height: 1.7;
}

.intro p:last-child {
    margin-bottom: 0;
}

/* Stats Section */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin: 32px 0;
}

.stat-card {
    background: var(--bg-card);
    padding: 28px 20px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
    transition: transform 0.3s;
    border: 1px solid #f1f5f9;
}

.stat-card:hover {
    transform: translateY(-4px);
}

.stat-card .number {
    font-size: 2.5rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-card .label {
    color: var(--text-secondary);
    margin-top: 8px;
    font-size: 0.95rem;
    font-weight: 500;
}

/* Topic Grid (Homepage) */
.topic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.topic-card {
    background: var(--bg-card);
    padding: 28px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid #f1f5f9;
}

.topic-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
    border-color: #e0e7ff;
}

.topic-card h3 {
    margin-bottom: 12px;
    font-size: 1.2rem;
}

.topic-card h3 a {
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.topic-card h3 a:hover {
    color: var(--primary);
}

.topic-card p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
}

/* Article List (Homepage Latest) */
#latest-list {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 1px solid #f1f5f9;
}

.article-item a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    text-decoration: none;
    color: var(--text-primary);
    border-bottom: 1px solid #f1f5f9;
    transition: all 0.2s;
}

.article-item:last-child a {
    border-bottom: none;
}

.article-item a:hover {
    background: #f8fafc;
    padding-left: 28px;
}

.article-item .title {
    font-weight: 500;
    font-size: 1rem;
    transition: color 0.2s;
}

.article-item a:hover .title {
    color: var(--primary);
}

.article-item .date {
    color: var(--text-muted);
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Topics Index Page */
.topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

/* Tags Cloud */
.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    padding: 24px;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
}

.tags-cloud a {
    display: inline-block;
    background: linear-gradient(135deg, #f0f9ff 0%, #f5f3ff 100%);
    padding: 10px 20px;
    border-radius: 100px;
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.3s;
    border: 1px solid #e0e7ff;
}

.tags-cloud a:hover {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    color: white;
    transform: scale(1.05) translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: transparent;
}

/* Article Content Page */
.article-content {
    background: var(--bg-card);
    padding: 48px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    max-width: 900px;
    margin: 0 auto;
    border: 1px solid #f1f5f9;
}

.article-content h1 {
    font-size: 2.25rem;
    font-weight: 800;
    margin-bottom: 16px;
    color: var(--text-primary);
    line-height: 1.3;
}

.article-content .meta {
    color: var(--text-muted);
    margin-bottom: 32px;
    padding-bottom: 24px;
    border-bottom: 2px solid #f1f5f9;
    font-size: 0.95rem;
}

.article-content .tags {
    margin-top: 40px;
    padding-top: 24px;
    border-top: 2px solid #f1f5f9;
}

.article-content .tags a {
    display: inline-block;
    background: #f1f5f9;
    padding: 6px 14px;
    border-radius: 100px;
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-right: 10px;
    margin-bottom: 10px;
    transition: all 0.2s;
    font-weight: 500;
}

.article-content .tags a:hover {
    background: var(--primary);
    color: white;
}

.article-content .article-body {
    line-height: 1.8;
    font-size: 1.05rem;
    color: var(--text-secondary);
}

.article-content .article-body h1,
.article-content .article-body h2,
.article-content .article-body h3 {
    margin-top: 40px;
    margin-bottom: 20px;
    color: var(--text-primary);
    font-weight: 700;
}

.article-content .article-body h2 {
    font-size: 1.75rem;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 12px;
}

.article-content .article-body p {
    margin-bottom: 20px;
}

.article-content .article-body code {
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 6px;
    font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
    font-size: 0.9em;
    color: var(--primary-dark);
}

.article-content .article-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 24px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 24px 0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.article-content .article-body pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.article-content .article-body ul,
.article-content .article-body ol {
    margin: 20px 0;
    padding-left: 28px;
}

.article-content .article-body li {
    margin-bottom: 10px;
}

.article-content .article-body a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s;
}

.article-content .article-body a:hover {
    border-bottom-color: var(--primary);
}

.article-content .article-body blockquote {
    border-left: 4px solid var(--primary);
    padding: 16px 24px;
    margin: 24px 0;
    color: var(--text-secondary);
    font-style: italic;
    background: #f8fafc;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.article-content .article-body img {
    max-width: 100%;
    border-radius: var(--radius-md);
    margin: 24px 0;
    box-shadow: var(--shadow-lg);
}

/* Responsive Design */
@media (max-width: 768px) {
    header {
        padding: 32px 0 40px;
    }
    
    header h1 {
        font-size: 2rem;
    }
    
    header nav {
        gap: 6px;
    }
    
    header nav a {
        padding: 8px 14px;
        font-size: 0.9rem;
    }
    
    .articles-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    
    .article-card {
        padding: 20px;
    }
    
    .article-content {
        padding: 24px;
    }
    
    .article-content h1 {
        font-size: 1.75rem;
    }
    
    .stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .stat-card .number {
        font-size: 2rem;
    }
    
    aside.related-links ul {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 0 16px;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    :root {
        --text-primary: #f1f5f9;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --bg-body: #0f172a;
        --bg-card: #1e293b;
    }
}
