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

:root {
    --bg: #fafafa;
    --surface: #ffffff;
    --text: #1a1a1a;
    --text-secondary: #6b7280;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --border: #e5e7eb;
    --code-bg: #f3f4f6;
    --radius: 8px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
    --max-width: 720px;
    --article-width: 680px;
}

html { scroll-behavior: smooth; }

body {
    font-family: Georgia, 'Times New Roman', serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6,
nav, a, button, .label {
    font-family: Inter, system-ui, -apple-system, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

img { max-width: 100%; height: auto; display: block; }

/* Header */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(250, 250, 250, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.header-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 1.5rem;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.site-logo {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}
.site-logo:hover { color: var(--text); }
.site-logo span { color: var(--accent); }

.nav-links { display: flex; align-items: center; gap: 1.5rem; }
.nav-links a {
    font-size: 0.875rem;
    color: var(--text-secondary);
    transition: color 0.2s;
}
.nav-links a:hover { color: var(--text); }

.nav-toggle {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
}
.nav-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text);
    margin: 5px 0;
    transition: 0.3s;
}

/* Main container */
.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

.container-wide {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem 4rem;
}

/* Article cards */
.article-card {
    display: block;
    padding: 1.75rem 0;
    border-bottom: 1px solid var(--border);
    transition: transform 0.2s;
}
.article-card:first-child { padding-top: 0; }
.article-card:last-child { border-bottom: none; }
.article-card:hover { transform: translateY(-1px); }

.article-card .card-meta {
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}
.article-card .card-meta .category {
    color: var(--accent);
    font-weight: 600;
}

.article-card h2 {
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: var(--text);
    letter-spacing: -0.01em;
}
.article-card h2:hover { color: var(--accent); }

.article-card .excerpt {
    font-size: 1rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 0.75rem;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card .card-footer {
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Article page */
.article-header {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.article-header .article-meta {
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}
.article-header .article-meta .category {
    color: var(--accent);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.article-byline {
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.article-byline .byline-author { font-weight: 500; }
.article-byline .byline-badge {
    background: #ede9fe;
    color: #7c3aed;
    padding: 0.15rem 0.5rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 600;
}
.article-byline .byline-pipeline {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.7;
}

.article-header h1 {
    font-size: clamp(1.75rem, 5vw, 2.5rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.03em;
    margin-bottom: 1rem;
}

.article-body { font-size: 1.125rem; }
.article-body h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 2.5rem 0 1rem;
    letter-spacing: -0.02em;
}
.article-body h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 2rem 0 0.75rem;
}
.article-body p { margin-bottom: 1.5rem; }
.article-body ul, .article-body ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}
.article-body li { margin-bottom: 0.5rem; }
.article-body blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 1.25rem;
    margin: 1.5rem 0;
    color: var(--text-secondary);
    font-style: italic;
}
.article-body code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    background: var(--code-bg);
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}
.article-body pre {
    background: var(--code-bg);
    padding: 1.25rem;
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
}
.article-body pre code {
    background: none;
    padding: 0;
    font-size: inherit;
}
.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1.5rem;
    font-size: 1rem;
}
.article-body th, .article-body td {
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    text-align: left;
}
.article-body th {
    background: var(--code-bg);
    font-weight: 600;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.9rem;
}

/* Citations */
.citation a {
    color: var(--accent);
    font-size: 0.75em;
    font-weight: 600;
    text-decoration: none;
}
.citation a:hover { text-decoration: underline; }

/* References */
.references {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}
.references h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.references ol {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}
.references li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
}
.references li a {
    color: var(--accent);
}
.references li a:hover { text-decoration: underline; }
.references-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 1rem;
}

/* Research Sources */
.research-sources {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}
.research-sources h3 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.research-sources ul {
    padding-left: 1.5rem;
    margin-bottom: 1rem;
}
.research-sources li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.6;
}
.research-sources li a {
    color: var(--accent);
}
.research-sources li a:hover { text-decoration: underline; }
.research-note {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 1rem;
}

/* Research notes */
.research-notes {
    margin-top: 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}
.research-notes summary {
    padding: 1rem 1.25rem;
    cursor: pointer;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
}
.research-notes summary:hover { color: var(--text); }
.research-notes-content {
    padding: 0 1.25rem 1.25rem;
    font-size: 0.85rem;
    line-height: 1.8;
    color: var(--text-secondary);
}
.research-notes-content p { margin-bottom: 0.25rem; }
.research-notes-content strong { color: var(--text); }

/* FAQ section */
.faq-section {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}
.faq-section h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}
.faq-item {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}
.faq-item:last-child { border-bottom: none; }
.faq-item h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}
.faq-item p {
    color: var(--text-secondary);
    line-height: 1.7;
}

/* Tags */
.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 2rem;
}
.tag {
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    background: var(--code-bg);
    border-radius: 99px;
    color: var(--text-secondary);
    transition: all 0.2s;
}
.tag:hover {
    background: var(--accent);
    color: white;
}

/* Reading progress bar */
.reading-progress {
    position: fixed;
    top: 64px;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--accent);
    z-index: 99;
    transition: width 0.1s;
}

/* Breadcrumbs */
.breadcrumbs {
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
}
.breadcrumbs a { color: var(--text-secondary); }
.breadcrumbs a:hover { color: var(--accent); }
.breadcrumbs span { margin: 0 0.5rem; }

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}
.pagination a, .pagination span {
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    transition: all 0.2s;
}
.pagination a:hover {
    border-color: var(--accent);
    color: var(--accent);
}
.pagination .current {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

/* Footer */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 2rem 1.5rem;
    text-align: center;
    font-family: Inter, system-ui, sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.site-footer a { color: var(--text-secondary); }
.site-footer a:hover { color: var(--accent); }

/* 404 page */
.error-page {
    text-align: center;
    padding: 6rem 1.5rem;
}
.error-page h1 {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 800;
    color: var(--border);
    letter-spacing: -0.04em;
}
.error-page h2 {
    font-size: 1.5rem;
    margin: 1rem 0;
}
.error-page p {
    color: var(--text-secondary);
    margin-bottom: 2rem;
}

/* Admin styles */
.admin-body {
    font-family: Inter, system-ui, sans-serif;
    background: #f9fafb;
    min-height: 100vh;
}

.admin-header {
    background: #111827;
    color: white;
    padding: 0 1.5rem;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.admin-header .admin-logo {
    font-weight: 700;
    font-size: 1rem;
    color: white;
}
.admin-header .admin-logo span { color: #60a5fa; }
.admin-header nav { display: flex; gap: 1.25rem; align-items: center; }
.admin-header nav a {
    font-size: 0.85rem;
    color: #9ca3af;
    transition: color 0.2s;
}
.admin-header nav a:hover, .admin-header nav a.active { color: white; }
.admin-header nav .logout { color: #f87171; }
.admin-header nav .logout:hover { color: #fca5a5; }

.admin-container {
    max-width: 900px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.admin-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}
.admin-card h2 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

/* Stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}
.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

/* Forms */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    color: var(--text);
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
    background: var(--surface);
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}
.form-group textarea { min-height: 120px; resize: vertical; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 500;
    font-family: Inter, system-ui, sans-serif;
    border: 1px solid transparent;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: var(--accent-hover); color: white; }
.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--text-secondary); }
.btn-danger {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

/* Table */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.admin-table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}
.admin-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table .title-cell {
    font-weight: 500;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.admin-table .title-cell a { color: var(--text); }
.admin-table .title-cell a:hover { color: var(--accent); }

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 500;
}
.status-published { background: #dcfce7; color: #166534; }
.status-draft { background: #fef3c7; color: #92400e; }

.source-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 99px;
    font-size: 0.75rem;
    font-weight: 500;
}
.source-cron { background: #ede9fe; color: #5b21b6; }
.source-manual { background: #dbeafe; color: #1e40af; }

/* Alert messages */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.875rem;
    margin-bottom: 1rem;
}
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #eff6ff; color: #1e40af; border: 1px solid #bfdbfe; }

/* Login page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 2rem;
    width: 100%;
    max-width: 380px;
}
.login-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    text-align: center;
}
.login-card .subtitle {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
}

/* Preview area */
.preview-area {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-top: 1rem;
    max-height: 500px;
    overflow-y: auto;
}
.preview-area h2 { font-size: 1.25rem; margin-bottom: 0.5rem; }
.preview-area h3 { font-size: 1.1rem; }
.preview-area p { color: var(--text-secondary); font-size: 0.95rem; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Responsive */
@media (max-width: 768px) {
    .nav-links {
        display: none;
        position: absolute;
        top: 64px;
        left: 0;
        right: 0;
        background: var(--surface);
        flex-direction: column;
        padding: 1rem 1.5rem;
        border-bottom: 1px solid var(--border);
        gap: 1rem;
    }
    .nav-links.open { display: flex; }
    .nav-toggle { display: block; }

    .header-inner { position: relative; }

    .container { padding: 1.5rem 1rem 3rem; }
    .container-wide { padding: 1.5rem 1rem 3rem; }

    .article-body { font-size: 1rem; }
    .article-header h1 { font-size: 1.5rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .admin-table { font-size: 0.8rem; }
    .admin-table th, .admin-table td { padding: 0.5rem; }
    .admin-table .hide-mobile { display: none; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .article-header .article-meta { flex-direction: column; gap: 0.5rem; }
}
