:root {
    --bg: #f0f2f5;
    --card-bg: #fff;
    --text: #1a1a2e;
    --text-secondary: #555;
    --text-muted: #999;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --accent-glow: rgba(37, 99, 235, 0.15);
    --border: #e8e8e8;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.1);
    --badge-bg: #f5f5f5;
    --sidebar-bg: #fff;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 100px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --sidebar-w: 200px;
    --rightbar-w: 220px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1117;
        --card-bg: #181b25;
        --text: #e8e8f0;
        --text-secondary: #a0a0b8;
        --text-muted: #666680;
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --accent-light: #172554;
        --accent-glow: rgba(59, 130, 246, 0.12);
        --border: #2a2d3a;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
        --shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
        --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.3);
        --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.35);
        --badge-bg: #2a2d3a;
        --sidebar-bg: #181b25;
    }
    .brand-logo [fill="#888"] {
        fill: #666680;
    }
    .brand,
    .mobile-brand {
        color: #e8e8f0;
    }
}

*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
        Arial, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 6px;
    height: 4px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ===== Layout ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

/* ===== Left sidebar ===== */
.sidebar-left {
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}
.sidebar-left-inner {
    padding: 16px 14px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.brand {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent);
    white-space: nowrap;
    letter-spacing: -0.3px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

/* Date nav */
.date-nav {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.date-nav a {
    padding: 5px 10px;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border: 1.5px solid transparent;
    transition: all var(--transition);
    display: block;
}
.date-nav a:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}
.date-nav a.active {
    background: linear-gradient(135deg, var(--accent), #1e40af);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px var(--accent-glow);
}
.nav-more {
    position: relative;
}
.nav-more-btn {
    width: 100%;
    padding: 5px 10px;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
    cursor: pointer;
    transition: all var(--transition);
    display: flex;
    align-items: center;
    gap: 4px;
    text-align: left;
}
.nav-more-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.nav-dropdown {
    display: none;
    margin-top: 3px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--card-bg);
    box-shadow: var(--shadow);
    max-height: 200px;
    overflow-y: auto;
    animation: fadeSlideUp 0.15s ease;
}
.nav-dropdown a {
    display: block;
    padding: 5px 10px;
    font-size: 11px;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px solid var(--border);
    transition: all 0.15s;
}
.nav-dropdown a:last-child {
    border-bottom: none;
}
.nav-dropdown a:hover {
    background: var(--accent-light);
    color: var(--accent);
}
.nav-dropdown a.active {
    color: var(--accent);
    font-weight: 700;
}
.nav-more:hover .nav-dropdown {
    display: block;
}

/* Date tag on news items */
.date-tag {
    display: inline-block;
    font-size: 10px;
    color: var(--text-muted);
    background: var(--accent-light);
    padding: 1px 5px;
    border-radius: 3px;
    margin-left: 4px;
    vertical-align: middle;
    opacity: 0.7;
}

/* Topic tabs */
.topic-tabs {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.topic-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    background: transparent;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    width: 100%;
    text-align: left;
}
.topic-tab::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--accent), #1e40af);
    opacity: 0;
    transition: opacity var(--transition);
}
.topic-tab.active {
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 12px var(--accent-glow);
}
.topic-tab.active::before {
    opacity: 1;
}
.topic-tab span {
    position: relative;
    z-index: 1;
}
.topic-tab:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ===== Right sidebar ===== */
.sidebar-right {
    position: sticky;
    top: 0;
    height: 100vh;
    width: var(--rightbar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-right-inner {
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* Search */
.search-bar {
    position: relative;
    width: 100%;
}
.search-bar input {
    width: 100%;
    padding: 7px 10px 7px 30px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: all var(--transition);
}
.search-bar input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: var(--card-bg);
}
.search-bar input::placeholder {
    color: var(--text-muted);
}
.search-bar svg {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    transition: color var(--transition);
}
.search-bar input:focus + svg,
.search-bar:focus-within svg {
    color: var(--accent);
}
.search-count {
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    padding: 2px 6px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    font-weight: 500;
    display: inline-block;
    margin-top: 4px;
}

/* Filters */
.filter-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.filter-btn {
    padding: 6px 12px;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    border: 1.5px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-align: left;
    display: flex;
    align-items: center;
    gap: 5px;
}
.filter-btn.active {
    background: linear-gradient(135deg, var(--accent), #1e40af);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 2px 8px var(--accent-glow);
}
.filter-btn:hover:not(.active) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-light);
}

/* ===== Main content ===== */
.main {
    flex: 1;
    min-width: 0;
    padding: 16px 24px;
    contain: layout style;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 16px;
    transition: box-shadow var(--transition);
    content-visibility: auto;
    contain-intrinsic-size: auto 120px;
}
.card:hover {
    box-shadow: var(--shadow-hover);
}
.card h3 {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}
.card h3 .count {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    background: var(--bg);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    margin-left: auto;
}
.news-list {
    list-style: none;
    padding: 0;
}
.news-item {
    padding: 8px 0;
    border-bottom: 1px solid transparent;
    transition: border-bottom-color var(--transition);
}
.news-item:last-child {
    border-bottom: none;
}
.news-item:not(:last-child) {
    border-bottom-color: var(--border);
}
.news-item a,
.news-item span {
    color: var(--text);
    font-size: 13.5px;
    line-height: 1.6;
}
.source-tag {
    display: inline-flex;
    align-items: center;
    background: var(--badge-bg);
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    margin-left: 6px;
    vertical-align: middle;
}

/* Empty state */
.empty {
    text-align: center;
    padding: 64px 20px;
    color: var(--text-muted);
}
.empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.6;
}
.empty p {
    font-size: 14px;
}

/* Show more */
.show-more-btn {
    display: block;
    width: 100%;
    margin-top: 8px;
    padding: 8px;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
    color: var(--accent);
    cursor: pointer;
    transition: all var(--transition);
}
.show-more-btn:hover {
    border-color: var(--accent);
    background: var(--accent-light);
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-muted);
    font-size: 11px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}
.footer a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.footer a:hover {
    text-decoration: underline;
}

/* Back to top */
.back-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px var(--accent-glow);
    opacity: 0;
    pointer-events: none;
    z-index: 50;
    transition: opacity 0.2s ease;
    will-change: opacity;
}
.back-top.visible {
    opacity: 1;
    pointer-events: auto;
}
.back-top:hover {
    box-shadow: 0 6px 20px var(--accent-glow);
}

/* Skeleton */
.skeleton {
    animation: pulse 1.5s ease-in-out infinite;
}
.skeleton-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
}
.skeleton-line {
    height: 14px;
    background: var(--border);
    border-radius: 6px;
    margin-bottom: 10px;
}
.skeleton-line.short {
    width: 60%;
}
.skeleton-line.medium {
    width: 80%;
}
.skeleton-line.title {
    width: 45%;
    height: 18px;
    margin-bottom: 16px;
}

/* Animations */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}
@keyframes cardIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.card {
    animation: cardIn 0.25s ease both;
}

/* ===== Mobile header ===== */
.mobile-header {
    display: none;
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--sidebar-bg);
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    align-items: center;
    gap: 8px;
}
.mobile-brand {
    font-size: 16px;
    font-weight: 800;
    color: var(--accent);
    white-space: nowrap;
    letter-spacing: -0.3px;
}
.hamburger {
    width: 36px;
    height: 36px;
    background: var(--card-bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.hamburger:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.mobile-search {
    flex: 1;
    position: relative;
}
.mobile-search input {
    width: 100%;
    padding: 7px 12px 7px 30px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    background: var(--bg);
    color: var(--text);
    outline: none;
}
.mobile-search input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}
.mobile-search svg {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.mobile-bar {
    display: none;
    gap: 6px;
    overflow-x: auto;
    padding: 8px 14px;
    border-bottom: 1px solid var(--border);
    background: var(--sidebar-bg);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.mobile-bar::-webkit-scrollbar {
    display: none;
}
.mobile-bar .topic-tab,
.mobile-bar .filter-btn {
    flex-shrink: 0;
    padding: 4px 12px;
    font-size: 11px;
    border-radius: var(--radius-pill);
    width: auto;
}
.mobile-bar a {
    flex-shrink: 0;
    padding: 4px 12px;
    background: var(--card-bg);
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border: 1.5px solid var(--border);
    transition: all var(--transition);
}
.mobile-bar a:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.mobile-bar a.active {
    background: linear-gradient(135deg, var(--accent), #1e40af);
    color: #fff;
    border-color: transparent;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 99;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.show {
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
    .sidebar-right {
        display: none;
    }
    .mobile-bar.right-bar {
        display: flex;
    }
    :root {
        --rightbar-w: 0;
    }
}
@media (max-width: 768px) {
    .sidebar-left {
        transform: translateX(-100%);
        position: fixed;
        z-index: 100;
    }
    .sidebar-left.open {
        transform: translateX(0);
    }
    .mobile-header {
        display: flex;
    }
    .mobile-bar.top-bar {
        display: flex;
    }
    .layout {
        flex-direction: column;
    }
    .main {
        padding: 12px 14px;
    }
    .sidebar-overlay.show {
        display: block;
    }
}
@media (max-width: 480px) {
    .mobile-bar .topic-tab {
        padding: 3px 10px;
        font-size: 10px;
    }
    .mobile-bar .filter-btn {
        padding: 3px 10px;
        font-size: 10px;
    }
    .mobile-bar a {
        padding: 3px 10px;
        font-size: 10px;
    }
}
