/* ============================================================
   Developer Blog Theme — Expert Informational Portal
   E-E-A-T optimized, Core Web Vitals ready
   Sections: Reset, Fonts, Variables, Accessibility, Topbar,
   Header, Navigation, Search, Mobile Menu, Main, Breadcrumbs,
   Hero, Sections, Article Cards, Categories, Popular,
   Blog Layout, Article Full, Prose, TOC, Author Bio,
   Newsletter, Share, Pagination, Buttons, Contact,
   Footer, Back-to-top, Progress Bar, Responsive, Print
   ============================================================ */

/* ===== Reset ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}
html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}
body {
    font-family: var(--font-sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background 0.25s ease, color 0.25s ease;
    min-height: 100vh;
}
a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s ease;
}
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; display: block; }
ul, ol { list-style: none; }
button, input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
}
button { cursor: pointer; }

/* ===== Fonts (@font-face) ===== */
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/inter-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('../fonts/inter-500.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('../fonts/inter-600.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/inter-700.woff2') format('woff2');
}
@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('../fonts/inter-800.woff2') format('woff2');
}
@font-face {
    font-family: 'Merriweather';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('../fonts/merriweather-400.woff2') format('woff2');
}
@font-face {
    font-family: 'Merriweather';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('../fonts/merriweather-700.woff2') format('woff2');
}

/* ===== CSS Custom Properties — Light Mode ===== */
:root {
    /* Colors */
    --bg: #ffffff;
    --bg-secondary: #f7f8fa;
    --bg-card: #ffffff;
    --bg-elevated: #ffffff;
    --text: #111827;
    --text-secondary: #525252;       /* WCAG AA on white: 7.1:1 */
    --text-muted: #6b6b6b;           /* WCAG AA on white: 4.6:1 */
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --primary-ghost: rgba(79,70,229,0.06);
    --primary-rgb: 79,70,229;
    --accent: #0891b2;
    --accent-light: #ecfeff;
    --success: #059669;
    --success-light: #ecfdf5;
    --warning: #d97706;
    --warning-light: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fef2f2;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --border-focus: var(--primary);

    /* Shadows — depth system */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --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.05);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.08), 0 8px 10px -6px rgba(0,0,0,0.04);
    --shadow-card-hover: 0 20px 40px -12px rgba(79,70,229,0.15), 0 8px 16px -8px rgba(0,0,0,0.08);

    /* Radii */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-full: 9999px;

    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-serif: 'Merriweather', Georgia, 'Times New Roman', serif;

    /* Layout */
    --content-width: 720px;
    --container-width: 1180px;
    --header-height: 64px;
    --topbar-height: 36px;
    --sidebar-width: 300px;
    --toc-width: 260px;
    --transition: 0.2s ease;
    --transition-slow: 0.35s ease;

    /* Category badge colors */
    --cat-1: #4f46e5; --cat-1-bg: #eef2ff;
    --cat-2: #0891b2; --cat-2-bg: #ecfeff;
    --cat-3: #059669; --cat-3-bg: #ecfdf5;
    --cat-4: #d97706; --cat-4-bg: #fffbeb;
    --cat-5: #dc2626; --cat-5-bg: #fef2f2;
    --cat-6: #7c3aed; --cat-6-bg: #f5f3ff;
    --cat-7: #db2777; --cat-7-bg: #fdf2f8;
    --cat-8: #0d9488; --cat-8-bg: #f0fdfa;
}

/* ===== CSS Custom Properties — Dark Mode ===== */
html.dark {
    --bg: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1a1d27;
    --bg-elevated: #22252f;
    --text: #f1f3f7;
    --text-secondary: #a1a5b2;
    --text-muted: #6e7280;
    --primary: #818cf8;
    --primary-hover: #a5b4fc;
    --primary-light: rgba(129,140,248,0.1);
    --primary-ghost: rgba(129,140,248,0.06);
    --primary-rgb: 129,140,248;
    --accent: #22d3ee;
    --accent-light: rgba(34,211,238,0.1);
    --success: #34d399;
    --success-light: rgba(52,211,153,0.1);
    --warning: #fbbf24;
    --warning-light: rgba(251,191,36,0.1);
    --danger: #f87171;
    --danger-light: rgba(248,113,113,0.1);
    --border: #2a2d37;
    --border-light: #1e2028;
    --border-focus: var(--primary);
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3), 0 1px 2px rgba(0,0,0,0.2);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.35), 0 2px 4px -2px rgba(0,0,0,0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4), 0 4px 6px -4px rgba(0,0,0,0.25);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.4), 0 8px 10px -6px rgba(0,0,0,0.25);
    --shadow-card-hover: 0 20px 40px -12px rgba(129,140,248,0.12), 0 8px 16px -8px rgba(0,0,0,0.3);

    --cat-1: #818cf8; --cat-1-bg: rgba(129,140,248,0.12);
    --cat-2: #22d3ee; --cat-2-bg: rgba(34,211,238,0.12);
    --cat-3: #34d399; --cat-3-bg: rgba(52,211,153,0.12);
    --cat-4: #fbbf24; --cat-4-bg: rgba(251,191,36,0.12);
    --cat-5: #f87171; --cat-5-bg: rgba(248,113,113,0.12);
    --cat-6: #a78bfa; --cat-6-bg: rgba(167,139,250,0.12);
    --cat-7: #f472b6; --cat-7-bg: rgba(244,114,182,0.12);
    --cat-8: #2dd4bf; --cat-8-bg: rgba(45,212,191,0.12);
}

/* ===== Accessibility ===== */
.skip-to-content {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 9999;
    padding: 12px 24px;
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    border-radius: 0 0 var(--radius) var(--radius);
    transition: top 0.15s ease;
    text-decoration: none;
}
.skip-to-content:focus {
    top: 0;
    color: #fff;
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}
/* Anchor heading scroll offset */
.prose h2[id],
.prose h3[id],
.prose h4[id],
h2[id], h3[id], h4[id] {
    scroll-margin-top: calc(var(--header-height) + var(--topbar-height) + 24px);
}

/* ===== Container ===== */
.container {
    max-width: var(--container-width);
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== Topbar ===== */
.topbar {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    transition: background 0.25s ease;
}
.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.topbar-contacts {
    display: flex;
    align-items: center;
    gap: 20px;
}
.topbar-contacts a {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    transition: color 0.2s ease;
}
.topbar-contacts a:hover {
    color: var(--primary);
}
.topbar-contacts svg {
    flex-shrink: 0;
    opacity: 0.7;
}
.topbar-tagline {
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    transition: box-shadow 0.25s ease, background 0.25s ease;
}
.site-header.scrolled {
    box-shadow: var(--shadow-md);
}
.header-container {
    display: flex;
    align-items: center;
    height: var(--header-height);
    gap: 32px;
}
.site-logo {
    font-size: 20px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.5px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}
.site-logo:hover { color: var(--primary); }
.site-logo img {
    height: 32px;
    width: auto;
}

/* ===== Navigation ===== */
.main-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}
.nav-link {
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    padding: 8px 14px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    background: none;
    border: none;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
}
.nav-link:hover,
.nav-link.active {
    color: var(--text);
    background: var(--primary-ghost);
}
.nav-link.active {
    color: var(--primary);
    font-weight: 600;
}

/* Nav dropdown */
.nav-dropdown { position: relative; }
.nav-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 4px;
}
.nav-dropdown-btn svg {
    transition: transform 0.2s ease;
    flex-shrink: 0;
}
.nav-dropdown[aria-expanded="true"] .nav-dropdown-btn svg,
.nav-dropdown:hover .nav-dropdown-btn svg {
    transform: rotate(180deg);
}
.nav-dropdown-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xl);
    min-width: 220px;
    padding: 6px;
    z-index: 110;
    animation: dropdownFadeIn 0.15s ease;
}
@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}
.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown[aria-expanded="true"] .nav-dropdown-menu {
    display: block;
}
.nav-dropdown-menu a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    color: var(--text-secondary);
    font-size: 14px;
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
    min-height: 44px;
}
.nav-dropdown-menu a:hover {
    color: var(--text);
    background: var(--primary-ghost);
}
.nav-dropdown-menu a .cat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Header actions */
.header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.search-toggle,
.theme-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}
.search-toggle:hover,
.theme-toggle:hover {
    color: var(--text);
    background: var(--primary-ghost);
}

/* Dark mode toggle icons */
.icon-moon { display: none; }
html.dark .icon-sun { display: none; }
html.dark .icon-moon { display: block; }

/* ===== Search Overlay ===== */
.search-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 200;
    display: flex;
    align-items: flex-start;
    padding-top: 120px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.search-overlay.open {
    opacity: 1;
    pointer-events: auto;
}
.search-form {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 4px;
    box-shadow: var(--shadow-xl);
    max-width: 640px;
    margin: 0 auto;
    width: 100%;
    border: 1px solid var(--border);
}
.search-form input {
    flex: 1;
    border: none;
    background: none;
    padding: 16px 20px;
    font-size: 18px;
    color: var(--text);
    outline: none;
    font-family: var(--font-sans);
}
.search-form input::placeholder { color: var(--text-muted); }
.search-close {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg-secondary);
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all 0.2s ease;
    flex-shrink: 0;
}
.search-close:hover {
    background: var(--danger-light);
    color: var(--danger);
}

/* ===== Mobile Menu Button ===== */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    width: 44px;
    height: 44px;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: var(--radius);
}
.mobile-menu-btn span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    transition: all 0.25s ease;
    border-radius: 2px;
}
.mobile-menu-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.mobile-menu-btn.active span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

/* Mobile overlay */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 90;
    opacity: 0;
    transition: opacity 0.3s ease;
}
.mobile-overlay.open { display: block; opacity: 1; }

/* Mobile menu */
.mobile-menu {
    position: fixed;
    top: var(--header-height);
    left: 0; right: 0;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 24px;
    z-index: 95;
    display: none;
    flex-direction: column;
    gap: 4px;
    box-shadow: var(--shadow-xl);
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
}
.mobile-menu.open { display: flex; }
.mobile-menu a {
    color: var(--text);
    font-size: 16px;
    font-weight: 500;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light);
    min-height: 44px;
    display: flex;
    align-items: center;
}
.mobile-menu a:last-child { border-bottom: none; }
.mobile-submenu-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-top: 8px;
    padding: 8px 0 4px;
}
.mobile-submenu-item {
    padding-left: 16px !important;
    font-size: 15px !important;
    color: var(--text-secondary) !important;
}

/* ===== Main ===== */
.site-main {
    min-height: calc(100vh - var(--header-height) - var(--topbar-height) - 200px);
    padding: 40px 0;
}

/* ===== Breadcrumbs ===== */
.breadcrumbs {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px;
}
.breadcrumbs a {
    color: var(--text-secondary);
    transition: color 0.2s ease;
}
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs .sep {
    margin: 0 6px;
    color: var(--border);
    font-size: 12px;
}
.breadcrumbs .current {
    color: var(--text);
    font-weight: 500;
}

/* ===== Hero Section (legacy — kept for blog page hero) ===== */

/* ===== Sections ===== */
.section {
    margin-bottom: 80px;
}
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    gap: 16px;
}
.section-title {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text);
    margin-bottom: 0;
    padding-left: 16px;
    border-left: 3px solid var(--primary);
}
.section-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    white-space: nowrap;
}
.section-link:hover {
    opacity: 0.8;
}
.section-action {
    text-align: center;
    margin-top: 32px;
}

/* ===== Article Cards ===== */
.articles-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
.articles-grid.cols-2 {
    grid-template-columns: repeat(2, 1fr);
}
.article-card {
    background: var(--bg-card, var(--bg));
    border: 1px solid var(--border);
    border-top: 2px solid var(--card-accent, var(--primary));
    border-radius: var(--radius-lg);
    transition: all 0.25s ease;
    overflow: hidden;
}
.article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,.08);
    border-color: var(--card-accent, var(--primary));
}
.card-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 28px;
    color: var(--text);
}
.card-link:hover { color: var(--text); }
.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.cat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--primary);
    background: rgba(79, 70, 229, 0.06);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}
[data-theme="dark"] .cat-label {
    background: rgba(129, 140, 248, 0.1);
}
.card-reading {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}
.card-link h3 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -0.2px;
    margin-bottom: 8px;
}
.card-link p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.55;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.card-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light, var(--border));
}

/* ===== Category Badge ===== */
.category-badge {
    display: inline-flex;
    align-items: center;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    letter-spacing: 0.2px;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.category-badge:hover {
    background: var(--primary);
    color: #fff;
}
.category-badge.small {
    font-size: 11px;
    padding: 3px 10px;
}
/* Colored category badges */
.category-badge[data-cat-color="1"] { color: var(--cat-1); background: var(--cat-1-bg); }
.category-badge[data-cat-color="1"]:hover { background: var(--cat-1); color: #fff; }
.category-badge[data-cat-color="2"] { color: var(--cat-2); background: var(--cat-2-bg); }
.category-badge[data-cat-color="2"]:hover { background: var(--cat-2); color: #fff; }
.category-badge[data-cat-color="3"] { color: var(--cat-3); background: var(--cat-3-bg); }
.category-badge[data-cat-color="3"]:hover { background: var(--cat-3); color: #fff; }
.category-badge[data-cat-color="4"] { color: var(--cat-4); background: var(--cat-4-bg); }
.category-badge[data-cat-color="4"]:hover { background: var(--cat-4); color: #fff; }
.category-badge[data-cat-color="5"] { color: var(--cat-5); background: var(--cat-5-bg); }
.category-badge[data-cat-color="5"]:hover { background: var(--cat-5); color: #fff; }
.category-badge[data-cat-color="6"] { color: var(--cat-6); background: var(--cat-6-bg); }
.category-badge[data-cat-color="6"]:hover { background: var(--cat-6); color: #fff; }
.category-badge[data-cat-color="7"] { color: var(--cat-7); background: var(--cat-7-bg); }
.category-badge[data-cat-color="7"]:hover { background: var(--cat-7); color: #fff; }
.category-badge[data-cat-color="8"] { color: var(--cat-8); background: var(--cat-8-bg); }
.category-badge[data-cat-color="8"]:hover { background: var(--cat-8); color: #fff; }

/* ===== Categories Grid ===== */
.cat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
}
.cat-card {
    display: flex;
    flex-direction: column;
    padding: 28px;
    background: var(--bg-card, var(--bg));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    transition: all 0.25s ease;
    position: relative;
}
.cat-card:hover {
    border-color: var(--cat-color, var(--primary));
    box-shadow: 0 8px 24px rgba(0,0,0,.08);
    transform: translateY(-2px);
    color: var(--text);
}
.cat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}
.cat-card-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background: rgba(99, 102, 241, 0.08);
    color: var(--cat-color, var(--primary));
    flex-shrink: 0;
}
.cat-card:hover .cat-card-icon {
    background: var(--cat-color, var(--primary));
    color: #fff;
}
.cat-card-metric {
    font-size: 28px;
    font-weight: 800;
    color: var(--cat-color, var(--primary));
    line-height: 1;
    font-variant-numeric: tabular-nums;
    letter-spacing: -1px;
}
.cat-card-title {
    font-size: 17px;
    font-weight: 700;
    margin-bottom: 6px;
}
.cat-card-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cat-card-arrow {
    color: var(--text-muted);
    margin-top: 12px;
    transition: transform 0.2s ease, color 0.2s ease;
    display: inline-flex;
}
.cat-card:hover .cat-card-arrow {
    transform: translateX(4px);
    color: var(--cat-color, var(--primary));
}

/* ===== Popular Articles — Leaderboard ===== */
.popular-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.popular-item {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 24px 28px;
    color: var(--text);
    transition: background 0.2s ease;
    border-bottom: 1px solid var(--border-light, var(--border));
}
.popular-item:last-child {
    border-bottom: none;
}
.popular-item:hover {
    background: var(--bg-secondary);
    color: var(--text);
}
.popular-rank {
    font-size: 36px;
    font-weight: 800;
    color: var(--border);
    min-width: 56px;
    font-variant-numeric: tabular-nums;
    letter-spacing: -2px;
    line-height: 1;
    transition: color 0.2s ease;
}
.popular-item:hover .popular-rank {
    color: var(--primary);
}
.popular-content {
    flex: 1;
    min-width: 0;
}
.popular-content h4 {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin-top: 4px;
}
.popular-stats {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    min-width: 80px;
    flex-shrink: 0;
}
.popular-views {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}
.popular-time {
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== Blog Layout (main + sidebar) ===== */
.blog-layout {
    display: grid;
    grid-template-columns: 1fr var(--sidebar-width);
    gap: 48px;
}
.blog-layout--single {
    grid-template-columns: 1fr;
}
.blog-layout--single .blog-sidebar {
    display: none;
}
.page-title {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
    color: var(--text);
}
.page-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 28px;
    line-height: 1.6;
}
.category-desc {
    color: var(--text-secondary);
    margin-bottom: 28px;
    font-size: 15px;
    line-height: 1.6;
}

/* Sidebar */
.blog-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 24px);
    align-self: start;
}
.sidebar-widget {
    margin-bottom: 24px;
    padding: 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    transition: background 0.25s ease;
}
.sidebar-widget h3 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 16px;
}
.sidebar-list { list-style: none; }
.sidebar-list li {
    border-bottom: 1px solid var(--border-light);
}
.sidebar-list li:last-child { border-bottom: none; }
.sidebar-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    transition: color 0.2s ease;
    min-height: 44px;
}
.sidebar-list a:hover { color: var(--primary); }
.sidebar-list a.active { color: var(--primary); font-weight: 700; }
.sidebar-list .count {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 12px;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

/* Tag cloud */
.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.tag {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
    min-height: 36px;
}
.tag:hover,
.tag.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ===== Article Full ===== */
.article-full {
    max-width: var(--content-width);
    margin: 0 auto;
}
/* Article with TOC layout */
.article-with-toc {
    display: grid;
    grid-template-columns: 1fr var(--toc-width);
    gap: 48px;
    max-width: calc(var(--content-width) + var(--toc-width) + 48px);
    margin: 0 auto;
    align-items: start;
}
.article-with-toc .article-full {
    max-width: var(--content-width);
    margin: 0;
}

.article-header { margin-bottom: 36px; }
.article-meta-top {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.article-meta-top .reading-time {
    display: flex;
    align-items: center;
    gap: 4px;
}
.views-count {
    display: flex;
    align-items: center;
    gap: 4px;
}
.article-header h1 {
    font-size: 40px;
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -1px;
    color: var(--text);
}
.article-author {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 16px;
}
.author-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 15px;
    flex-shrink: 0;
}
.author-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.article-hero-image {
    margin-bottom: 36px;
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.article-hero-image img {
    width: 100%;
    height: auto;
}

/* ===== Prose (article body) ===== */
.prose {
    font-family: var(--font-serif);
    font-size: 18px;
    line-height: 1.85;
    color: var(--text);
}
.prose h2 {
    font-family: var(--font-sans);
    font-size: 26px;
    font-weight: 800;
    margin: 48px 0 16px;
    letter-spacing: -0.3px;
    color: var(--text);
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-light);
}
.prose h3 {
    font-family: var(--font-sans);
    font-size: 20px;
    font-weight: 700;
    margin: 36px 0 12px;
    color: var(--text);
}
.prose h4 {
    font-family: var(--font-sans);
    font-size: 17px;
    font-weight: 700;
    margin: 28px 0 10px;
    color: var(--text);
}
.prose p { margin-bottom: 20px; }
.prose ul, .prose ol {
    margin-bottom: 20px;
    padding-left: 28px;
}
.prose ul { list-style: disc; }
.prose ol { list-style: decimal; }
.prose li {
    margin-bottom: 8px;
    padding-left: 4px;
}
.prose blockquote {
    border-left: 4px solid var(--primary);
    margin: 28px 0;
    padding: 20px 28px;
    background: var(--bg-secondary);
    border-radius: 0 var(--radius) var(--radius) 0;
    font-style: italic;
    color: var(--text-secondary);
}
.prose blockquote p:last-child { margin-bottom: 0; }
.prose img {
    border-radius: var(--radius-lg);
    margin: 28px 0;
}
.prose a {
    color: var(--primary);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: text-decoration-color 0.2s ease;
}
.prose a:hover {
    text-decoration-thickness: 2px;
}
.prose code {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.88em;
    border: 1px solid var(--border);
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}
.prose pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 24px;
    border-radius: var(--radius-lg);
    overflow-x: auto;
    margin: 28px 0;
    font-size: 14px;
    line-height: 1.7;
    border: 1px solid #313244;
}
.prose pre code {
    background: none;
    padding: 0;
    color: inherit;
    border: none;
    font-size: inherit;
}
.prose table {
    width: 100%;
    border-collapse: collapse;
    margin: 28px 0;
    font-family: var(--font-sans);
    font-size: 15px;
}
.prose th, .prose td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
}
.prose th {
    background: var(--bg-secondary);
    font-weight: 600;
}
.prose hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 40px 0;
}
.prose figure {
    margin: 28px 0;
}
.prose figcaption {
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
    font-family: var(--font-sans);
    font-style: italic;
}

/* ===== Table of Contents (sticky sidebar) ===== */
.toc-sidebar {
    position: sticky;
    top: calc(var(--header-height) + 24px);
    align-self: start;
    max-height: calc(100vh - var(--header-height) - 48px);
    overflow-y: auto;
}
.toc-card {
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
}
.toc-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.toc-list {
    list-style: none;
}
.toc-list li {
    margin-bottom: 2px;
}
.toc-list a {
    display: block;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    border-left: 2px solid transparent;
    transition: all 0.15s ease;
    line-height: 1.4;
}
.toc-list a:hover {
    color: var(--primary);
    background: var(--primary-ghost);
}
.toc-list a.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--primary-ghost);
    font-weight: 600;
}
.toc-list .toc-h3 {
    padding-left: 24px;
    font-size: 12px;
}

/* ===== Author Bio Card ===== */
.author-bio {
    display: flex;
    gap: 20px;
    padding: 28px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-light);
    margin-top: 48px;
}
.author-bio-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 24px;
    flex-shrink: 0;
}
.author-bio-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}
.author-bio-info {
    flex: 1;
}
.author-bio-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}
.author-bio-role {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 8px;
}
.author-bio-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}
.author-bio-links {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}
.author-bio-links a {
    width: 36px;
    height: 36px;
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}
.author-bio-links a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ===== Newsletter CTA ===== */
.newsletter-section {
    background: var(--bg-secondary);
    padding: 56px 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.newsletter-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 48px;
}
.newsletter-text {
    flex-shrink: 0;
}
.newsletter-section h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 4px;
    letter-spacing: -0.3px;
}
.newsletter-section > .container > .newsletter-inner > .newsletter-text > p,
.newsletter-inner > .newsletter-text > p {
    font-size: 15px;
    color: var(--text-secondary);
    margin-bottom: 0;
}
.newsletter-action {
    flex: 1;
    max-width: 440px;
}
.newsletter-form {
    display: flex;
    gap: 8px;
}
.newsletter-form input[type="email"] {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
}
.newsletter-form input[type="email"]:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.08);
}
.newsletter-form button {
    padding: 12px 24px;
    background: var(--text);
    color: var(--bg);
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: opacity 0.2s ease;
    white-space: nowrap;
}
.newsletter-form button:hover {
    opacity: 0.85;
}
.newsletter-privacy {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 8px;
}
.newsletter-privacy a {
    color: var(--text-secondary);
    text-decoration: underline;
}

/* ===== Share ===== */
.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-top: 40px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}
.tags-label,
.share-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    margin-right: 4px;
}
.article-share {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 20px;
}
.share-btn {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    border: 1px solid var(--border-light);
}
.share-btn:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Related */
.related-section {
    max-width: var(--content-width);
    margin: 56px auto 0;
    padding-top: 48px;
    border-top: 1px solid var(--border);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 48px;
}
.page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    height: 44px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}
.page-link:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-ghost);
}
.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.page-link.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ===== Buttons ===== */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--primary);
    border: none;
    border-radius: var(--radius);
    color: #fff;
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    min-height: 44px;
    cursor: pointer;
}
.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    box-shadow: var(--shadow-md);
}
.btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 28px;
    border: 2px solid var(--primary);
    border-radius: var(--radius);
    color: var(--primary);
    font-weight: 600;
    font-size: 15px;
    transition: all 0.2s ease;
    min-height: 44px;
    background: transparent;
    cursor: pointer;
}
.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    color: var(--primary);
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s ease;
    min-height: 44px;
    background: var(--primary-ghost);
    cursor: pointer;
}
.btn-ghost:hover {
    background: var(--primary-light);
    color: var(--primary-hover);
}

/* ===== Contact Page ===== */
.contact-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin-top: 32px;
}
.contact-info-item {
    margin-bottom: 28px;
}
.contact-info-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.contact-info-label svg {
    opacity: 0.6;
}
.contact-info-value {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}
.contact-info-value a {
    color: var(--text);
    transition: color 0.2s ease;
}
.contact-info-value a:hover {
    color: var(--primary);
}
.contact-info-value.email-value {
    font-size: 17px;
    font-weight: 600;
}
.contact-info-value.email-value a {
    color: var(--primary);
}
.contact-info-value.address-value {
    font-size: 16px;
    font-weight: 400;
    color: var(--text-secondary);
    line-height: 1.5;
}
.contact-form-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 32px;
    border: 1px solid var(--border);
}
.contact-form-card h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.form-input,
.form-textarea {
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    font-family: var(--font-sans);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    min-height: 44px;
}
.form-input:focus,
.form-textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}
.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}
.form-textarea {
    resize: vertical;
    min-height: 120px;
}

/* ===== Empty state ===== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: var(--text-muted);
    font-size: 16px;
}
.empty-state svg {
    margin: 0 auto 16px;
    opacity: 0.4;
}

/* ===== Footer ===== */
.site-footer {
    border-top: 1px solid var(--border);
    padding: 56px 0 24px;
    background: var(--bg-secondary);
    transition: background 0.25s ease;
}
.footer-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr 1fr 1fr;
    gap: 40px;
    margin-bottom: 40px;
}
.footer-logo {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    display: inline-block;
    margin-bottom: 12px;
}
.footer-logo:hover { color: var(--primary); }
.footer-desc {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 16px;
}
.footer-social {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}
.footer-social a {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    border: 1px solid var(--border);
}
.footer-social a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.footer-phone {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.footer-phone:hover { color: var(--primary); }
.footer-email {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}
.footer-email:hover { color: var(--primary); }

.footer-col h4 {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    margin-bottom: 16px;
    color: var(--text-muted);
}
.footer-col ul { list-style: none; }
.footer-col li { margin-bottom: 10px; }
.footer-col a {
    color: var(--text-secondary);
    font-size: 14px;
    transition: color 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.footer-col a:hover { color: var(--primary); }
.footer-address {
    color: var(--text-muted);
    font-size: 13px;
    font-style: normal;
    line-height: 1.5;
}

/* Footer newsletter mini form */
.footer-newsletter {
    margin-top: 16px;
}
.footer-newsletter-form {
    display: flex;
    gap: 6px;
}
.footer-newsletter-form input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    outline: none;
    min-width: 0;
}
.footer-newsletter-form input:focus {
    border-color: var(--primary);
}
.footer-newsletter-form button {
    padding: 10px 14px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease;
}
.footer-newsletter-form button:hover {
    background: var(--primary-hover);
}

.footer-bottom {
    padding-top: 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
    gap: 8px;
}
.footer-bottom a {
    color: var(--text-muted);
}
.footer-bottom a:hover {
    color: var(--primary);
}

.sape-links {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 12px;
    padding: 8px 0;
}
.sape-links a { color: var(--text-secondary); }

/* ===== Back to Top ===== */
.back-to-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s ease;
    box-shadow: var(--shadow-lg);
    z-index: 50;
}
.back-to-top.visible {
    opacity: 1;
    transform: translateY(0);
}
.back-to-top:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

/* ===== Reading Progress Bar ===== */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: var(--primary);
    z-index: 9999;
    transition: width 0.1s linear;
    pointer-events: none;
}

/* ===== Responsive: 1024px ===== */
@media (max-width: 1024px) {
    .articles-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .footer-grid {
        grid-template-columns: 1fr 1fr;
        gap: 32px;
    }
    .blog-layout {
        grid-template-columns: 1fr 260px;
        gap: 32px;
    }
    .article-with-toc {
        grid-template-columns: 1fr;
        max-width: var(--content-width);
    }
    .toc-sidebar {
        display: none;
    }
    .hero-image { height: 380px; }
}

/* ===== Responsive: 768px ===== */
@media (max-width: 768px) {
    .topbar { display: none; }
    .main-nav { display: none; }
    .mobile-menu-btn { display: flex; }

    .articles-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .blog-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    .blog-sidebar { position: static; }

    .article-header h1 {
        font-size: 28px;
        letter-spacing: -0.5px;
    }
    .prose {
        font-size: 16px;
        line-height: 1.75;
    }
    .prose h2 { font-size: 22px; }
    .prose h3 { font-size: 18px; }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 28px;
    }
    .footer-bottom {
        flex-direction: column;
        text-align: center;
    }

    .related-section .articles-grid {
        grid-template-columns: 1fr;
    }

    .page-title { font-size: 26px; }
    .container { padding: 0 16px; }
    .site-main { padding: 24px 0; }

    .newsletter-inner { flex-direction: column; gap: 24px; text-align: center; }
    .newsletter-action { max-width: 100%; }
    .newsletter-form {
        flex-direction: column;
    }
    .newsletter-form button {
        width: 100%;
    }

    .contact-grid {
        grid-template-columns: 1fr;
    }

    .author-bio {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    .author-bio-links {
        justify-content: center;
    }

    .cat-grid {
        grid-template-columns: 1fr 1fr;
    }
    .popular-stats { display: none; }
    .popular-rank { font-size: 28px; min-width: 40px; }
    .popular-item { padding: 16px 20px; gap: 16px; }
}

/* ===== Responsive: 480px ===== */
@media (max-width: 480px) {
    .header-container { gap: 12px; }
    .site-logo { font-size: 17px; }

    .article-header h1 { font-size: 24px; }

    .cat-grid {
        grid-template-columns: 1fr;
    }
    .popular-rank { font-size: 24px; min-width: 32px; }

    .pagination { gap: 4px; }
    .page-link {
        min-width: 40px;
        height: 40px;
        padding: 0 10px;
    }
}

/* ===== Home Hero ===== */
.home-hero {
    background: var(--bg);
    padding: 80px 0 64px;
    border-bottom: 1px solid var(--border-light, var(--border));
}
.home-hero-inner {
    max-width: 720px;
}
.home-hero-accent {
    color: var(--primary);
    margin-bottom: 24px;
}
.home-hero-label {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--primary);
    margin-bottom: 16px;
}
.home-hero h1 {
    font-size: 52px;
    font-weight: 800;
    letter-spacing: -2px;
    line-height: 1.08;
    color: var(--text);
    margin-bottom: 20px;
}
.home-hero-tagline {
    font-size: 18px;
    color: var(--text-secondary);
    line-height: 1.6;
    max-width: 540px;
    margin-bottom: 40px;
}
.home-hero-stats {
    display: flex;
    gap: 48px;
    margin-bottom: 40px;
}
.hero-stat {
    display: flex;
    flex-direction: column;
}
.hero-stat-num {
    font-size: 32px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
    letter-spacing: -1px;
    line-height: 1;
}
.hero-stat-label {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 4px;
}
.home-hero-cta {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid var(--border);
    padding: 12px 24px;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}
.home-hero-cta:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(79, 70, 229, 0.04);
}

/* ===== Featured Grid (homepage) ===== */
.featured-grid {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 24px;
}
.featured-main-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 40px;
    background: var(--bg-card, var(--bg));
    border: 1px solid var(--border);
    border-left: 3px solid var(--primary);
    border-radius: var(--radius-lg);
    color: var(--text);
    transition: all 0.25s ease;
}
.featured-main-link:hover {
    border-color: var(--primary);
    box-shadow: 0 12px 40px rgba(0,0,0,.08);
    color: var(--text);
}
.featured-main-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.reading-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: var(--text-muted);
}
.featured-main-link h3 {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 12px;
}
.featured-main-link p {
    font-size: 15px;
    color: var(--text-secondary);
    line-height: 1.6;
    flex: 1;
}
.featured-footer {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light, var(--border));
}
.featured-side {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.featured-side-link {
    display: flex;
    flex-direction: column;
    padding: 28px;
    background: var(--bg-card, var(--bg));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    transition: all 0.25s ease;
    flex: 1;
}
.featured-side-link:hover {
    border-color: var(--primary);
    box-shadow: 0 8px 24px rgba(0,0,0,.06);
    color: var(--text);
}
.featured-side-link h4 {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
    margin: 8px 0;
}

/* ===== Card Image (img tag) ===== */
.card-image-wrap .card-img,
.card-img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform 0.4s ease;
}
.article-card:hover .card-img { transform: scale(1.05); }
.card-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
}

/* ===== Category Card Accent ===== */
.category-card-accent {
    border-left-width: 4px !important;
    border-left-style: solid !important;
}
.category-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 8px;
}

/* ===== Experts Grid ===== */
.experts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}
.expert-card {
    padding: 32px;
    background: var(--bg-card, var(--bg));
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all 0.25s ease;
}
.expert-card:hover {
    box-shadow: 0 8px 30px rgba(0,0,0,.06);
    transform: translateY(-2px);
}
.expert-card-top {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}
.expert-monogram {
    width: 48px;
    height: 48px;
    border: 2px solid var(--border);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: var(--text);
    flex-shrink: 0;
    background: var(--bg-secondary);
}
.expert-info {
    display: flex;
    flex-direction: column;
}
.expert-name {
    font-size: 17px;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}
.expert-role {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
}
.expert-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
}
.expert-metrics {
    display: flex;
    gap: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border-light, var(--border));
}
.expert-metric {
    display: flex;
    flex-direction: column;
}
.expert-metric-val {
    font-size: 18px;
    font-weight: 800;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}
.expert-metric-lbl {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Article Newsletter CTA ===== */
.article-newsletter {
    margin-top: 48px;
    padding: 36px;
    background: var(--primary-light);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    text-align: center;
}
.article-newsletter h3 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}
.article-newsletter p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}
.article-newsletter .newsletter-form {
    max-width: 420px;
}
.article-newsletter .newsletter-form input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
}
.article-newsletter .newsletter-form input::placeholder { color: var(--text-muted); }
.article-newsletter .newsletter-form button {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.article-newsletter .newsletter-form button:hover {
    background: var(--primary-hover);
    color: #fff;
}
.newsletter-msg {
    margin-top: 12px;
    font-size: 14px;
    min-height: 20px;
}
.newsletter-msg-success { color: #16a34a; }
.newsletter-msg-error { color: #dc2626; }
.newsletter-section .newsletter-msg-success { color: #bbf7d0; }
.newsletter-section .newsletter-msg-error { color: #fecaca; }

/* ===== Author Info (article header) ===== */
.author-info { display: flex; flex-direction: column; }
.author-name { font-weight: 600; color: var(--text); font-size: 14px; }
.author-label { font-size: 12px; color: var(--text-muted); }

/* ===== Blog Featured (articles list page) ===== */
/* Blog Featured (text-based, reuses featured-main-link) */
.blog-featured {
    margin-bottom: 40px;
}
.blog-featured .featured-main-link {
    border-left: 3px solid var(--primary);
}

/* ===== Sidebar Popular ===== */
.sidebar-popular { display: flex; flex-direction: column; gap: 4px; }
.sidebar-popular-item {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 0;
    color: var(--text);
    border-bottom: 1px solid var(--border-light, var(--border));
    transition: color 0.2s ease;
}
.sidebar-popular-item:last-child { border-bottom: none; }
.sidebar-popular-item:hover { color: var(--primary); }
.sidebar-popular-rank {
    font-size: 20px;
    font-weight: 800;
    color: var(--border);
    min-width: 28px;
    text-align: center;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    transition: color 0.2s ease;
}
.sidebar-popular-item:hover .sidebar-popular-rank {
    color: var(--primary);
}
.sidebar-popular-info h4 {
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 4px;
}

/* ===== Form Groups ===== */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ===== Page Content ===== */
.page-content { max-width: var(--content-width); margin: 0 auto; }
.page-header { margin-bottom: 36px; }
.page-header h1 {
    font-size: 36px;
    font-weight: 800;
    letter-spacing: -0.8px;
    line-height: 1.2;
}

/* ===== Pagination Additions ===== */
.page-dots {
    display: flex;
    align-items: center;
    padding: 0 4px;
    color: var(--text-muted);
    font-size: 14px;
}
.page-prev, .page-next {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* ===== TOC Toggle (mobile) ===== */
.toc-toggle {
    display: none;
    position: fixed;
    bottom: 80px;
    right: 24px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    z-index: 50;
}

/* ===== Responsive Additions ===== */
@media (max-width: 1024px) {
    .featured-grid { grid-template-columns: 1fr; }
    .featured-side { flex-direction: row; }
}

@media (max-width: 768px) {
    .home-hero h1 { font-size: 36px; letter-spacing: -1px; }
    .home-hero-stats { gap: 32px; }
    .hero-stat-num { font-size: 24px; }

    .featured-grid { grid-template-columns: 1fr; }

    .experts-grid { grid-template-columns: 1fr; }

    .toc-toggle { display: flex; }
    .toc-sidebar.toc-open .toc-card {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 80;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 60vh;
        overflow-y: auto;
        box-shadow: var(--shadow-xl);
        background: var(--bg-card);
    }

    /* blog-featured now text-only, no grid changes needed */
}

@media (max-width: 480px) {
    .home-hero h1 { font-size: 28px; }
    .home-hero-stats { gap: 24px; }
    .hero-stat-num { font-size: 20px; }
}

/* ===== Print ===== */
@media print {
    .topbar,
    .site-header,
    .site-footer,
    .back-to-top,
    .article-share,
    .article-tags,
    .related-section,
    .search-overlay,
    .mobile-menu,
    .mobile-overlay,
    .reading-progress,
    .toc-sidebar,
    .toc-toggle,
    .newsletter-section,
    .article-newsletter,
    .home-hero,
    .blog-sidebar,
    .author-bio-links {
        display: none !important;
    }
    .article-full,
    .article-with-toc {
        max-width: 100%;
        display: block;
    }
    body {
        color: #000;
        background: #fff;
        font-size: 12pt;
    }
    .prose {
        font-size: 12pt;
    }
    .prose a {
        color: #000;
        text-decoration: underline;
    }
    .prose a::after {
        content: ' (' attr(href) ')';
        font-size: 10pt;
        color: #666;
    }
    .article-header h1 {
        font-size: 24pt;
    }
    .prose pre {
        white-space: pre-wrap;
        border: 1px solid #ccc;
        background: #f5f5f5;
        color: #000;
    }
    .author-bio {
        break-inside: avoid;
    }
}

/* ===== 404 Error Page ===== */
.error-404 {
    text-align: center;
    padding: 60px 20px 80px;
}
.error-code {
    font-size: 120px;
    font-weight: 800;
    line-height: 1;
    color: var(--border);
    margin-bottom: 8px;
}
.error-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 12px;
}
.error-text {
    font-size: 17px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}
.error-search {
    max-width: 440px;
    margin: 0 auto 32px;
    display: flex;
    gap: 8px;
}
.error-search input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
}
.error-search .btn-primary {
    padding: 10px 20px;
    border-radius: 8px;
}
.error-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== Search Results Page ===== */
.search-results-page {
    padding-top: 32px;
    padding-bottom: 60px;
    min-height: 50vh;
}
.search-results-page .page-title {
    margin-bottom: 24px;
}
.search-count {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-size: 15px;
}
.search-prompt,
.search-empty {
    text-align: center;
    padding: 60px 20px;
}
.search-prompt svg,
.search-empty svg {
    margin-bottom: 16px;
    opacity: .5;
}
.search-prompt p,
.search-empty p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}
.search-empty h2 {
    margin-bottom: 8px;
}
.search-inline-form {
    display: flex;
    gap: 8px;
    max-width: 440px;
    margin: 0 auto;
}
.search-inline-form input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 15px;
    background: var(--bg);
    color: var(--text);
}
.search-inline-form .btn-primary {
    padding: 10px 20px;
    border-radius: 8px;
}

/* ===== Newsletter Success ===== */
.newsletter-success {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 16px 24px;
    background: rgba(34, 197, 94, .12);
    border: 1px solid rgba(34, 197, 94, .3);
    border-radius: 10px;
    color: #16a34a;
    font-weight: 500;
    font-size: 15px;
}
[data-theme="dark"] .newsletter-success {
    color: #4ade80;
}
