:root {
    --color-bg: #f0f4f8;
    --color-surface: #ffffff;
    --color-primary: #1e3a5f;
    --color-primary-light: #2b6cb0;
    --color-accent: #3182ce;
    --color-text: #2d3748;
    --color-muted: #718096;
    --color-border: #e2e8f0;
    --radius: 12px;
    --shadow-sm: 0 1px 3px rgba(30, 58, 95, 0.08);
    --shadow-md: 0 8px 24px rgba(30, 58, 95, 0.1);
    --header-h: 64px;
    --wrap: min(1100px, 100% - 2rem);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font);
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.65;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.rtl { direction: rtl; }

img { max-width: 100%; height: auto; }

a { color: var(--color-accent); }

.wrap {
    width: var(--wrap);
    margin-inline: auto;
    padding-inline: 1rem;
}

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: linear-gradient(135deg, var(--color-primary) 0%, #2c5282 100%);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.site-header .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--header-h);
    gap: 1rem;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 1rem;
}

.logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.02em;
}

.logo:hover { opacity: 0.92; }

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    padding: 10px;
    border: none;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    height: 2px;
    background: #fff;
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

.nav-toggle[aria-expanded="true"] span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 1.25rem;
}

.main-nav a {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    font-size: 0.9375rem;
    padding: 0.35rem 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.15s, color 0.15s;
}

.main-nav a:hover {
    color: #fff;
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.site-main {
    flex: 1;
    padding: 1.75rem 0 3rem;
}

/* 全站语言栏 */
.site-lang-bar {
    background: #fff;
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.site-lang-inner {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
    padding-block: 0.65rem;
}

.site-lang-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-muted);
    flex-shrink: 0;
}

.lang-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.lang-tab {
    display: inline-block;
    padding: 0.35rem 0.75rem;
    font-size: 0.8125rem;
    text-decoration: none;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.lang-tab:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.lang-tab.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.meta-tag {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    background: #ebf8ff;
    color: var(--color-primary-light);
}

.meta-tag-warn {
    background: #fffaf0;
    color: #c05621;
}

.original-title {
    font-size: 0.875rem;
    color: var(--color-muted);
    margin-bottom: 0.5rem;
}

.lang-missing-notice {
    margin: 0 0 1.25rem;
    padding: 0.75rem 1rem;
    background: #fffaf0;
    border: 1px solid #fbd38d;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #744210;
}

.article-lang-switch .lang-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.lang-pill.done:not(.active) {
    border-color: #9ae6b4;
    background: #f0fff4;
}

/* Hero & cards */
.hero {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: clamp(1.25rem, 4vw, 2rem);
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
}

.hero h1 {
    font-size: clamp(1.35rem, 4vw, 1.75rem);
    color: var(--color-primary);
    margin-bottom: 0.5rem;
    line-height: 1.35;
}

.hero p {
    color: var(--color-muted);
    font-size: 0.9375rem;
    max-width: 52ch;
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}

.section-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--color-primary);
    padding-left: 0.75rem;
    border-left: 4px solid var(--color-accent);
}

/* Category grid */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.cat-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.25rem 1.35rem;
    text-decoration: none;
    color: inherit;
    border: 1px solid var(--color-border);
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}

.cat-card:hover {
    border-color: var(--color-accent);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.cat-card h2 {
    font-size: 1.0625rem;
    color: var(--color-primary);
}

.cat-card .count {
    font-size: 0.8125rem;
    color: var(--color-muted);
}

/* Article list */
.article-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.article-item {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 1.15rem 1.35rem;
    border: 1px solid var(--color-border);
    border-inline-start: 4px solid var(--color-accent);
    transition: box-shadow 0.15s;
}

.article-item:hover {
    box-shadow: var(--shadow-sm);
}

.article-item h2 {
    font-size: clamp(1rem, 2.5vw, 1.125rem);
    line-height: 1.45;
    margin-bottom: 0.4rem;
}

.article-item h2 a {
    color: var(--color-primary);
    text-decoration: none;
}

.article-item h2 a:hover {
    color: var(--color-accent);
    text-decoration: underline;
}

.article-meta {
    font-size: 0.8125rem;
    color: var(--color-muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
}

.article-excerpt {
    margin-top: 0.6rem;
    font-size: 0.9375rem;
    color: #4a5568;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.65;
}

.article-excerpt .excerpt-p {
    margin: 0 0 0.35em;
    display: inline;
}

.article-excerpt .excerpt-heading {
    display: block;
    margin-bottom: 0.25em;
    color: var(--color-primary);
}

.article-excerpt .excerpt-ul {
    margin: 0.25em 0 0.35em 1.1em;
    padding: 0;
    display: inline;
}

.article-excerpt .excerpt-ul li {
    display: inline;
    list-style: none;
}

.article-excerpt .excerpt-ul li::before {
    content: "• ";
}

.article-excerpt .excerpt-ul li + li::before {
    content: " • ";
}

.article-excerpt strong {
    font-weight: 600;
    color: #2d3748;
}

/* Article detail */
.breadcrumb {
    font-size: 0.875rem;
    color: var(--color-muted);
    margin-bottom: 1.25rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
}

.breadcrumb a {
    color: var(--color-accent);
    text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.breadcrumb .sep { opacity: 0.5; }

.breadcrumb .current {
    color: var(--color-text);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.article-detail {
    padding: clamp(1.25rem, 4vw, 2.25rem);
}

.article-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: #ebf8ff;
    color: var(--color-primary-light);
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    margin-bottom: 0.75rem;
}

.article-header h1 {
    font-size: clamp(1.35rem, 4vw, 1.85rem);
    line-height: 1.4;
    color: var(--color-primary);
    margin-bottom: 0.75rem;
}

.article-header .article-meta {
    font-size: 0.875rem;
}

.meta-link {
    color: var(--color-accent);
    text-decoration: none;
}

.meta-link:hover { text-decoration: underline; }

.lang-switch {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem;
    margin-top: 1rem;
}

.lang-switch .lang-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.lang-label {
    font-size: 0.8125rem;
    color: var(--color-muted);
    margin-right: 0.25rem;
}

.lang-pill {
    font-size: 0.8125rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s;
}

.lang-pill:hover {
    border-color: var(--color-accent);
    color: var(--color-accent);
}

.lang-pill.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.analysis-content {
    font-size: clamp(1rem, 2vw, 1.0625rem);
    line-height: 1.85;
    color: #374151;
}

.analysis-content p { margin-bottom: 1em; }

.analysis-content h2,
.analysis-content h3,
.analysis-content .md-h1 {
    margin: 1.5em 0 0.6em;
    color: var(--color-primary);
    line-height: 1.35;
}

.analysis-content h2,
.analysis-content .md-h1 { font-size: 1.25rem; }

.analysis-content h3 { font-size: 1.1rem; }

.analysis-content ul {
    margin: 0.75em 0 1em 1.25em;
}

.analysis-content li { margin-bottom: 0.35em; }

.analysis-content.rtl ul {
    margin-inline: 0 1.25em 1em 0;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 2rem;
}

.pagination a,
.pagination span {
    min-width: 2.5rem;
    text-align: center;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.875rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-accent);
}

.pagination a:hover {
    border-color: var(--color-accent);
    background: #ebf8ff;
}

.pagination .current {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* Empty & buttons */
.empty,
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--color-muted);
}

.empty-state h2 {
    color: var(--color-primary);
    margin-bottom: 0.75rem;
    font-size: 1.25rem;
}

.empty-state p { margin-bottom: 1.25rem; }

.btn {
    display: inline-block;
    padding: 0.65rem 1.35rem;
    background: var(--color-primary);
    color: #fff !important;
    text-decoration: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: background 0.15s;
}

.btn:hover { background: var(--color-primary-light); }

/* Footer */
.site-footer {
    background: var(--color-primary);
    color: rgba(255, 255, 255, 0.88);
    padding: 1.5rem 0;
    font-size: 0.875rem;
    text-align: center;
    margin-top: auto;
}

/* Mobile nav */
@media (max-width: 768px) {
    .nav-toggle { display: flex; }

    .site-lang-inner {
        flex-direction: column;
        align-items: flex-start;
    }

    .lang-tabs {
        width: 100%;
    }

    .main-nav {
        position: fixed;
        top: var(--header-h);
        left: 0;
        right: 0;
        background: var(--color-primary);
        flex-direction: column;
        align-items: stretch;
        padding: 0.75rem 1rem 1.25rem;
        gap: 0;
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        visibility: hidden;
        transition: max-height 0.25s, opacity 0.2s, visibility 0.2s;
        box-shadow: var(--shadow-md);
    }

    .main-nav.is-open {
        max-height: 70vh;
        overflow-y: auto;
        opacity: 1;
        visibility: visible;
    }

    .main-nav a {
        padding: 0.75rem 0.5rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .main-nav a:last-child { border-bottom: none; }

    .article-item {
        padding: 1rem 1.1rem;
    }

    .breadcrumb .current {
        white-space: normal;
    }
}

@media (min-width: 769px) {
    .logo { font-size: 1.35rem; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .cat-card:hover { transform: none; }
}
