/* =========================
   CSS 变量 & 主题
   ========================= */
:root {
    /* 亮色主题 */
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-hover: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --accent-light: #e0e7ff;
    --accent-soft: rgba(99, 102, 241, 0.08);
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #0b1120;
    --bg-secondary: #111827;
    --bg-tertiary: #1e293b;
    --bg-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-tertiary: #64748b;
    --border-color: #334155;
    --border-light: #1e293b;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-light: #312e81;
    --accent-soft: rgba(129, 140, 248, 0.12);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -2px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
}

/* =========================
   Reset & Base
   ========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
}

input, select {
    font-family: inherit;
    outline: none;
    border: none;
}

svg {
    flex-shrink: 0;
}

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

/* =========================
   Header
   ========================= */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 24px;
    height: 68px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

.logo svg {
    color: var(--accent);
}

.search-box {
    flex: 1;
    max-width: 560px;
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    padding: 0 14px;
    height: 44px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.search-box:focus-within {
    background: var(--bg-secondary);
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-box > svg {
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: transparent;
    padding: 0 12px;
    font-size: 15px;
    color: var(--text-primary);
    height: 100%;
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.clear-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: var(--text-tertiary);
    transition: var(--transition);
    opacity: 0;
    visibility: hidden;
}

.search-box:focus-within .clear-btn:not(:disabled),
.search-box input:not(:placeholder-shown) ~ .clear-btn {
    opacity: 1;
    visibility: visible;
}

.clear-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.icon-sun,
[data-theme="dark"] .icon-moon {
    display: none;
}

[data-theme="dark"] .icon-sun {
    display: block;
}

.icon-moon {
    display: block;
}

.mobile-only {
    display: none;
}

/* =========================
   Main Layout
   ========================= */
.main {
    flex: 1;
    padding: 28px 0;
}

.layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 28px;
    align-items: start;
}

/* =========================
   Sidebar
   ========================= */
.sidebar {
    position: sticky;
    top: 96px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar-section {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.sidebar-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 16px;
}

.category-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.category-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    font-size: 14px;
    color: var(--text-secondary);
    transition: var(--transition);
    text-align: left;
}

.category-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.category-item.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.category-item.active svg {
    color: var(--accent);
}

.category-item > span:nth-of-type(1) {
    flex: 1;
}

.count {
    font-size: 12px;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.category-item.active .count {
    background: var(--accent-light);
    color: var(--accent);
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 999px;
    font-size: 13px;
    transition: var(--transition);
    cursor: pointer;
    border: 1px solid transparent;
}

.tag-chip:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-light);
}

.tag-chip.active {
    background: var(--accent);
    color: #fff;
}

.data-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.info-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.info-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

/* =========================
   Content
   ========================= */
.content {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 0;
}

.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.result-hint {
    font-size: 14px;
    color: var(--text-secondary);
}

.result-hint strong {
    color: var(--accent);
    font-weight: 700;
}

.sort-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--text-secondary);
}

.sort-label select {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
}

.sort-label select:hover {
    background: var(--bg-hover);
}

.sort-label select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.active-filters {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    background: var(--accent-soft);
    border: 1px solid var(--accent-light);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
}

.filter-prefix {
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

#activeFilterChips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    flex: 1;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-secondary);
    color: var(--accent);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    border: 1px solid var(--accent-light);
}

.filter-chip button {
    display: flex;
    align-items: center;
    color: var(--accent);
    opacity: 0.7;
    transition: var(--transition);
}

.filter-chip button:hover {
    opacity: 1;
}

.clear-all-btn {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    flex-shrink: 0;
}

.clear-all-btn:hover {
    background: var(--bg-secondary);
    color: var(--danger);
}

/* =========================
   News Grid & Cards
   ========================= */
.news-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
}

.news-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition);
    position: relative;
}

.news-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-xl);
    border-color: var(--accent-light);
}

.news-image {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.news-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.news-card:hover .news-image img {
    transform: scale(1.05);
}

.news-image-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    background: linear-gradient(135deg, var(--bg-tertiary) 0%, var(--bg-hover) 100%);
}

.news-category-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 5px 12px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.03em;
}

[data-theme="dark"] .news-category-badge {
    background: rgba(99, 102, 241, 0.85);
}

.news-content {
    padding: 18px 20px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

.news-title {
    font-size: 17px;
    font-weight: 700;
    line-height: 1.5;
    color: var(--text-primary);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: var(--transition);
}

.news-card:hover .news-title {
    color: var(--accent);
}

.news-summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.65;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    flex: 1;
}

.news-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.news-tag {
    padding: 3px 10px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 999px;
    font-size: 11px;
    transition: var(--transition);
    cursor: pointer;
}

.news-tag:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.news-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
    gap: 12px;
}

.news-source {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
    min-width: 0;
}

.news-source span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
}

.news-date {
    font-size: 12px;
    color: var(--text-tertiary);
    white-space: nowrap;
    flex-shrink: 0;
}

/* =========================
   Loading & Empty
   ========================= */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
    color: var(--text-secondary);
}

.loading p {
    font-size: 14px;
}

.spinner {
    width: 42px;
    height: 42px;
    border: 3px solid var(--bg-tertiary);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 12px;
    text-align: center;
    color: var(--text-tertiary);
}

.empty-state svg {
    opacity: 0.4;
    margin-bottom: 12px;
}

.empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 8px;
}

.primary-btn {
    padding: 10px 22px;
    background: var(--accent);
    color: #fff;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 600;
    transition: var(--transition);
}

.primary-btn:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

/* =========================
   Pagination
   ========================= */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    flex-wrap: wrap;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    transition: var(--transition);
}

.page-btn:hover:not(:disabled) {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent-light);
}

.page-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.page-numbers {
    display: flex;
    align-items: center;
    gap: 6px;
}

.page-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.page-number:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.page-number.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
    font-weight: 700;
}

.page-ellipsis {
    padding: 0 8px;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* =========================
   Footer
   ========================= */
.footer {
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
    padding: 28px 0;
    margin-top: 40px;
}

.footer-inner {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.footer p {
    font-size: 14px;
    color: var(--text-secondary);
}

.footer-sub {
    font-size: 12px !important;
    color: var(--text-tertiary) !important;
}

/* =========================
   Back to Top
   ========================= */
.back-to-top {
    position: fixed;
    bottom: 28px;
    right: 28px;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-lg);
    transition: var(--transition);
    z-index: 90;
}

.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

/* =========================
   Responsive
   ========================= */
@media (max-width: 1024px) {
    .layout {
        grid-template-columns: 240px 1fr;
        gap: 20px;
    }

    .container {
        padding: 0 20px;
    }
}

@media (max-width: 768px) {
    .header-inner {
        height: 60px;
        gap: 12px;
    }

    .logo span {
        display: none;
    }

    .search-box {
        height: 40px;
    }

    .search-box input {
        font-size: 14px;
    }

    .mobile-only {
        display: flex;
    }

    .layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        background: var(--bg-primary);
        z-index: 200;
        padding: 80px 20px 20px;
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        gap: 20px;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 190;
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
    }

    .sidebar-overlay.open {
        opacity: 1;
        visibility: visible;
    }

    .main {
        padding: 20px 0;
    }

    .news-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .news-content {
        padding: 16px;
    }

    .news-title {
        font-size: 16px;
    }

    .filter-bar {
        padding: 12px 16px;
    }

    .filter-right {
        width: 100%;
    }

    .sort-label {
        width: 100%;
        justify-content: space-between;
    }

    .sort-label select {
        flex: 1;
    }

    .active-filters {
        padding: 10px 14px;
    }

    .back-to-top {
        bottom: 20px;
        right: 20px;
        width: 42px;
        height: 42px;
    }

    .footer {
        padding: 20px 0;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .header-actions .icon-btn {
        width: 38px;
        height: 38px;
    }

    .pagination {
        gap: 6px;
    }

    .page-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .page-number {
        min-width: 36px;
        height: 36px;
        padding: 0 10px;
        font-size: 13px;
    }
}

/* =========================
   Skeleton Animation
   ========================= */
@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }
    100% {
        background-position: 468px 0;
    }
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-tertiary) 0px,
        var(--bg-hover) 40px,
        var(--bg-tertiary) 80px
    );
    background-size: 800px 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-radius: var(--radius-md);
}
