/* Modern CSS Reset & Variables */
:root {
    --primary-color: #2563eb; /* Modern Blue */
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --background-color: #f8fafc;
    --surface-color: #ffffff;
    --text-main: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --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);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
    font-family: var(--font-sans);
    background-color: var(--background-color);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary-color); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--primary-hover); }

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

/* --- Layout & Header --- */
.site-container { display: flex; flex-direction: column; min-height: 100vh; }

.site-header {
    background: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
    padding: 0.75rem 0;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 4rem;
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.025em;
    background: linear-gradient(to right, var(--primary-color), #4f46e5);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.site-nav a {
    color: var(--text-secondary);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    transition: all 0.2s;
}

.site-nav a:hover, .site-nav a.active {
    color: var(--primary-color);
    background-color: #eff6ff;
}

/* --- Main Content Area --- */
.main-container { flex: 1; padding: 2rem 0; }

.site-banner {
    width: 100%;
    margin-bottom: 2.5rem;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    max-height: 300px; /* Limit height for banner look */
}
.site-banner img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 2.5rem;
    align-items: start;
}

/* --- Sidebar & Widgets --- */
.sidebar-column { display: flex; flex-direction: column; gap: 1.5rem; }

.widget {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.widget-title {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8fafc;
    color: var(--text-main);
    margin: 0;
}

.widget-content { padding: 1.25rem; }

.hot-list, .category-list { list-style: none; }
.hot-list li, .category-list li {
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px dashed var(--border-color);
}
.hot-list li:last-child, .category-list li:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.hot-list a, .category-list a {
    display: block;
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.5;
}
.hot-list a:hover, .category-list a:hover { color: var(--primary-color); transform: translateX(2px); transition: transform 0.2s; }

.view-count { font-size: 0.8rem; color: var(--text-muted); margin-left: 0.5rem; }

/* --- Article List --- */
.category-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.cat-link {
    padding: 0.5rem 1rem;
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.cat-link:hover, .cat-link.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.article-list { display: flex; flex-direction: column; gap: 1.5rem; }

.article-item {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

.article-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.article-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.75rem;
    line-height: 1.3;
}

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

.article-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.meta-item { display: flex; align-items: center; gap: 0.25rem; }

.article-excerpt {
    color: var(--text-secondary);
    margin-bottom: 1.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1.25rem; }
.tag {
    background-color: #f1f5f9;
    color: var(--text-secondary);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
}

.read-more {
    display: inline-flex;
    align-items: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* --- Pagination --- */
.pagination { display: flex; justify-content: center; gap: 0.5rem; margin-top: 3rem; }
.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 0.75rem;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    transition: all 0.2s;
}
.page-link:hover, .page-link.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* --- Article Detail --- */
.article-detail {
    background: var(--surface-color);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.article-header { margin-bottom: 2rem; border-bottom: 1px solid var(--border-color); padding-bottom: 2rem; }
.article-cover { margin: -2.5rem -2.5rem 2rem -2.5rem; overflow: hidden; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 400px; }
.article-cover img { width: 100%; height: 100%; object-fit: cover; }

.article-detail .article-title { font-size: 2.25rem; margin-bottom: 1rem; }

.article-content { font-size: 1.1rem; line-height: 1.8; color: #334155; }
.article-content h2 { font-size: 1.75rem; margin-top: 2.5rem; margin-bottom: 1.25rem; color: var(--text-main); font-weight: 700; }
.article-content h3 { font-size: 1.4rem; margin-top: 2rem; margin-bottom: 1rem; color: var(--text-main); font-weight: 600; }
.article-content p { margin-bottom: 1.5rem; }
.article-content ul, .article-content ol { margin-bottom: 1.5rem; padding-left: 1.5rem; }
.article-content li { margin-bottom: 0.5rem; }
.article-content blockquote {
    border-left: 4px solid var(--primary-color);
    background-color: #f8fafc;
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    font-style: italic;
    color: var(--text-secondary);
}
.article-content img { max-width: 100%; height: auto; border-radius: var(--radius-md); margin: 1.5rem 0; }

/* Adjacent Links */
.adjacent-links {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}
.adjacent-links a {
    display: flex;
    flex-direction: column;
    padding: 1.5rem;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    text-decoration: none;
    color: var(--text-main);
    font-weight: 600;
}
.adjacent-links a:hover {
    background: white;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    color: var(--primary-color);
}
.adjacent-links .prev-link { text-align: left; }
.adjacent-links .next-link { text-align: right; }
.adjacent-links a::before, .adjacent-links a::after {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: normal;
}
.adjacent-links .prev-link::before { content: "上一篇"; }
.adjacent-links .next-link::after { content: "下一篇"; margin-bottom: 0; margin-top: 0.5rem; }

/* Related Recommendations Grid (Logo/Card Style) */
.related-recommendations {
    margin-top: 2.5rem;
}
.related-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    padding-left: 1rem;
    border-left: 4px solid var(--primary-color);
    color: var(--text-main);
}
.related-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}
.related-card {
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
}
.related-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}
.related-card-img {
    height: 120px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 1rem;
}
.related-card-img img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    background: transparent; /* Ensure logos look good */
}
.related-card-body {
    padding: 1rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.related-card-title {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    line-height: 1.4;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.related-card-meta {
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Sidebar Banner */
.sidebar-banner {
    margin-bottom: 1.5rem;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.sidebar-banner img {
    width: 100%;
    height: auto;
    display: block;
}

/* Sidebar List Style (Compact) */
.sidebar-list-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem 0;
    border-bottom: 1px dashed var(--border-color);
}
.sidebar-list-item:last-child { border-bottom: none; }
.sidebar-thumb {
    width: 60px;
    height: 40px;
    background: #f1f5f9;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    overflow: hidden;
}
.sidebar-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-info { flex: 1; min-width: 0; }
.sidebar-info-title {
    font-size: 0.9rem;
    font-weight: 500;
    line-height: 1.4;
    margin-bottom: 0.25rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.sidebar-info-meta { font-size: 0.75rem; color: var(--text-muted); }

/* --- Footer --- */
.site-footer {
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: auto;
    text-align: center;
    color: var(--text-secondary);
}

/* --- Admin Styles (Preserved & Modernized) --- */
.admin-container { display: flex; min-height: 100vh; background: #f1f5f9; }
.sidebar { width: 260px; background: #1e293b; color: white; flex-shrink: 0; }
.logo { padding: 1.5rem; border-bottom: 1px solid rgba(255,255,255,0.1); }
.logo h2 { font-size: 1.25rem; color: white; }
.menu { padding: 1rem 0; }
.menu-item { display: flex; align-items: center; padding: 0.75rem 1.5rem; color: #94a3b8; transition: 0.2s; }
.menu-item:hover, .menu-item.active { background: #334155; color: white; border-left: 3px solid var(--primary-color); }
.menu-item span { margin-right: 0.75rem; }

.main-content { flex: 1; display: flex; flex-direction: column; overflow-x: hidden; }
.header { background: white; padding: 1rem 2rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.content { padding: 2rem; }

.card { background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); margin-bottom: 1.5rem; }
.card-header { padding: 1.25rem 1.5rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.card-body { padding: 1.5rem; }

.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; padding: 1rem; background: #f8fafc; color: var(--text-secondary); font-weight: 600; border-bottom: 1px solid var(--border-color); }
.table td { padding: 1rem; border-bottom: 1px solid var(--border-color); color: var(--text-main); }
.table tr:last-child td { border-bottom: none; }

.btn { display: inline-flex; align-items: center; justify-content: center; padding: 0.5rem 1rem; border-radius: var(--radius-md); font-weight: 500; transition: 0.2s; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--primary-color); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: white; border-color: var(--border-color); color: var(--text-main); }
.btn-secondary:hover { background: #f8fafc; border-color: #cbd5e1; }
.btn-danger { background: var(--danger-color); color: white; }

.form-control { width: 100%; padding: 0.625rem; border: 1px solid var(--border-color); border-radius: var(--radius-md); transition: 0.2s; }
.form-control:focus { outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }

/* Adjacent Articles Widget */
.adj-section {
    margin-bottom: 1.5rem;
}
.adj-section:last-child {
    margin-bottom: 0;
}
.adj-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.75rem;
    padding-bottom: 0.25rem;
    border-bottom: 2px solid var(--border-color);
    display: inline-block;
}

/* Image Placeholder Style */
img {
    background-color: #f1f5f9;
    position: relative;
}
/* Fallback for broken images if alt text is shown */
img::after {
    content: attr(alt);
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    text-align: center;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .content-wrapper { grid-template-columns: 1fr; }
    .sidebar-column { order: 2; }
}

@media (max-width: 768px) {
    .admin-container { flex-direction: column; }
    .sidebar { width: 100%; height: auto; }
    .adjacent-links { grid-template-columns: 1fr; }
    .article-detail { padding: 1.5rem; }
    .article-title { font-size: 1.25rem; }
}

/* Random Link Cloud (Spider Pool) */
.random-cloud-section {
    background: #f8fafc;
    border-top: 1px solid var(--border-color);
    padding: 2rem 0;
    margin-top: 3rem;
}
.cloud-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
    color: var(--text-main);
}
.cloud-tags {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
}
.cloud-tags a {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 99px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    line-height: 1.5;
}
.cloud-tags a:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
