@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg-primary: #eef2f7;
    --bg-secondary: #e2e8f0;
    --bg-card: #ffffff;
    --bg-card-hover: #f8fafc;
    --bg-code: #1e293b;
    --border: #e5e9f0;
    --border-hover: #cbd5e1;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #4f46e5;
    --accent-hover: #4338ca;
    --accent-dim: rgba(79, 70, 229, 0.08);
    --accent-secondary: #7c3aed;
    --rail-bg: #0b1220;
    --header-bg: #0f172a;
    --header-text: #f1f5f9;
    --header-text-muted: #94a3b8;
    --sidebar-bg: #ffffff;
    --sidebar-border: #e5e9f0;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.05), 0 4px 16px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 4px 12px rgba(15, 23, 42, 0.06), 0 12px 40px rgba(15, 23, 42, 0.08);
    --shadow-xl: 0 8px 24px rgba(15, 23, 42, 0.08), 0 20px 60px rgba(15, 23, 42, 0.12);
    --rail-w: 68px;
    --header-h: 64px;
    --sidebar-w: 288px;
    --content-max: 1120px;
    --read-width: 760px;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --transition: 0.2s ease;
}

:root[data-theme="dark"] {
    --bg-primary: #0b1120;
    --bg-secondary: #1e293b;
    --bg-card: #111a2e;
    --bg-card-hover: #16223c;
    --bg-code: #0b1120;
    --border: #1e2a44;
    --border-hover: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-dim: rgba(129, 140, 248, 0.14);
    --rail-bg: #070c17;
    --header-bg: #0b1120;
    --sidebar-bg: #0d1526;
    --sidebar-border: #1e2a44;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.35), 0 12px 40px rgba(0, 0, 0, 0.4);
    --shadow-xl: 0 8px 24px rgba(0, 0, 0, 0.4), 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.7;
    font-size: 16px;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }
img { max-width: 100%; height: auto; }

/* ============ APP SHELL ============ */
.app { min-height: 100vh; }

.rail {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--rail-w);
    background: var(--rail-bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 0;
    z-index: 200;
    gap: 8px;
}

.rail-logo {
    width: 40px; height: 40px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 0.95rem;
    margin-bottom: 8px;
    flex-shrink: 0;
}
.rail-logo:hover { color: #fff; transform: translateY(-1px); }

.rail-items {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
    scrollbar-width: none;
}
.rail-items::-webkit-scrollbar { display: none; }

.rail-bottom { display: flex; flex-direction: column; gap: 4px; }

.rail-item {
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    color: rgba(226, 232, 240, 0.55);
    transition: all var(--transition);
    position: relative;
}
.rail-item:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
}
.rail-item.active {
    color: #fff;
    background: rgba(99, 102, 241, 0.25);
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.4);
}
.rail-item.active::before {
    content: '';
    position: absolute;
    left: -14px; top: 50%;
    transform: translateY(-50%);
    width: 3px; height: 22px;
    background: #818cf8;
    border-radius: 0 3px 3px 0;
}

.shell { min-height: 100vh; }

/* ============ HEADER ============ */
.header {
    position: sticky;
    top: 0;
    z-index: 150;
    background: var(--header-bg);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    height: var(--header-h);
    padding: 0 24px;
}

.sidebar-toggle {
    display: none;
    background: none; border: none;
    color: var(--header-text);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-xs);
}
.sidebar-toggle:hover { background: rgba(255,255,255,0.08); }

.logo { display: flex; align-items: center; gap: 12px; color: var(--header-text); flex-shrink: 0; }
.logo:hover { color: var(--header-text); }

.logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.95rem; font-weight: 800; color: #fff;
    flex-shrink: 0;
}
.logo-icon-img {
    background: none;
    width: auto;
    height: 46px;
    border-radius: 0;
    object-fit: contain;
    padding: 0;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-name { font-size: 1.2rem; font-weight: 800; letter-spacing: -0.3px; }
.logo-tagline { font-size: 0.68rem; color: var(--header-text-muted); font-weight: 400; letter-spacing: 0.3px; }

.nav {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: 12px;
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    color: var(--header-text-muted);
    font-size: 0.85rem; font-weight: 500;
    transition: all var(--transition);
    display: flex; align-items: center; gap: 6px;
    white-space: nowrap;
}
.nav a:hover, .nav a.active { color: #fff; background: rgba(255, 255, 255, 0.1); }

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

.search-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    color: var(--header-text-muted);
    cursor: pointer;
    display: flex; align-items: center; gap: 10px;
    font-size: 0.85rem; font-family: var(--font-sans);
    transition: all var(--transition);
    min-width: 200px;
}
.search-btn:hover { border-color: rgba(255, 255, 255, 0.2); background: rgba(255, 255, 255, 0.1); color: #fff; }
.search-btn-text { flex: 1; text-align: left; }
.search-btn kbd {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 7px; border-radius: 4px;
    font-size: 0.72rem; font-family: var(--font-mono);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--header-text-muted);
}

.theme-toggle {
    width: 40px; height: 40px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--header-text-muted);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}
.theme-toggle:hover { color: #fff; border-color: rgba(255, 255, 255, 0.2); background: rgba(255,255,255,0.1); }
.theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }

/* ============ COLUMNS ============ */
.columns { display: flex; align-items: flex-start; }

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 16px 12px 84px;
}

.sidebar-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 8px 12px;
}
.sidebar-title {
    font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted);
}
.sidebar-collapse {
    background: none; border: none; cursor: pointer;
    color: var(--text-muted); padding: 4px; border-radius: var(--radius-xs);
    display: flex;
}
.sidebar-collapse:hover { color: var(--text-primary); background: var(--bg-primary); }

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }

.sidebar-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem; font-weight: 600;
    transition: all var(--transition);
}
.sidebar-link:hover { background: var(--bg-primary); color: var(--text-primary); }
.sidebar-link.active { background: var(--accent-dim); color: var(--accent); }
.sidebar-link svg { flex-shrink: 0; }

.topic-group { display: flex; flex-direction: column; }

.topic-head {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 9px 10px;
    background: none; border: none; cursor: pointer;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 0.9rem; font-weight: 600;
    font-family: var(--font-sans);
    text-align: left;
    transition: all var(--transition);
}
.topic-head:hover { background: var(--bg-primary); color: var(--text-primary); }

.topic-head-icon {
    width: 30px; height: 30px;
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.topic-head-icon svg { width: 18px; height: 18px; }
.topic-c1 .topic-head-icon { background: #dbeafe; color: #2563eb; }
.topic-c2 .topic-head-icon { background: #dcfce7; color: #16a34a; }
.topic-c3 .topic-head-icon { background: #fce7f3; color: #db2777; }
.topic-c4 .topic-head-icon { background: #e0e7ff; color: #4f46e5; }
.topic-c5 .topic-head-icon { background: #fee2e2; color: #dc2626; }
.topic-c6 .topic-head-icon { background: #fef3c7; color: #d97706; }
.topic-c7 .topic-head-icon { background: #cffafe; color: #0891b2; }
:root[data-theme="dark"] .topic-head-icon { background: rgba(255,255,255,0.06) !important; }

.topic-head-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic-head-count {
    background: var(--bg-primary);
    color: var(--text-muted);
    font-size: 0.7rem; font-weight: 700;
    padding: 1px 8px; border-radius: 10px;
    flex-shrink: 0;
}
.topic-chevron { color: var(--text-muted); flex-shrink: 0; transition: transform var(--transition); }
.topic-group.open .topic-chevron { transform: rotate(180deg); }

.topic-children {
    position: relative;
    display: none;
    flex-direction: column;
    padding: 2px 0 8px 0;
    margin-left: 16px;
    gap: 1px;
}
.topic-group.open .topic-children { display: flex; }
/* continuous vertical guide line */
.topic-children::before {
    content: '';
    position: absolute;
    left: 6px; top: 2px; bottom: 12px;
    width: 1.5px;
    background: var(--border);
    border-radius: 2px;
}

.topic-child {
    position: relative;
    padding: 7px 10px 7px 26px;
    border-radius: var(--radius-xs);
    color: var(--text-secondary);
    font-size: 0.83rem; font-weight: 500;
    line-height: 1.4;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    transition: all var(--transition);
}
/* colored dot sitting on the guide line (positive offset so overflow:hidden won't clip it) */
.topic-child::before {
    content: '';
    position: absolute;
    left: 3px; top: 50%;
    transform: translateY(-50%);
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    box-shadow: 0 0 0 3px var(--sidebar-bg);
}
.topic-child:hover { color: var(--text-primary); background: var(--bg-primary); }
.topic-child.active { color: var(--text-primary); font-weight: 600; }
.topic-child.current {
    background: var(--accent-dim);
    color: var(--accent);
    font-weight: 700;
    white-space: normal;
}
.topic-child.empty { color: var(--text-muted); font-style: italic; }
.topic-child.empty::before { display: none; }
.topic-child.view-more { font-weight: 600; color: var(--accent); }
.topic-child.view-more::before { display: none; }

/* per-topic colors: child dots, view-more link, count badge */
.topic-c1 .topic-child::before { background: #2563eb; }
.topic-c2 .topic-child::before { background: #16a34a; }
.topic-c3 .topic-child::before { background: #db2777; }
.topic-c4 .topic-child::before { background: #4f46e5; }
.topic-c5 .topic-child::before { background: #dc2626; }
.topic-c6 .topic-child::before { background: #d97706; }
.topic-c7 .topic-child::before { background: #0891b2; }

.topic-c1 .topic-child.view-more { color: #2563eb; }
.topic-c2 .topic-child.view-more { color: #16a34a; }
.topic-c3 .topic-child.view-more { color: #db2777; }
.topic-c4 .topic-child.view-more { color: #4f46e5; }
.topic-c5 .topic-child.view-more { color: #dc2626; }
.topic-c6 .topic-child.view-more { color: #d97706; }
.topic-c7 .topic-child.view-more { color: #0891b2; }

.topic-c1 .topic-head-count { background: #dbeafe; color: #2563eb; }
.topic-c2 .topic-head-count { background: #dcfce7; color: #16a34a; }
.topic-c3 .topic-head-count { background: #fce7f3; color: #db2777; }
.topic-c4 .topic-head-count { background: #e0e7ff; color: #4f46e5; }
.topic-c5 .topic-head-count { background: #fee2e2; color: #dc2626; }
.topic-c6 .topic-head-count { background: #fef3c7; color: #d97706; }
.topic-c7 .topic-head-count { background: #cffafe; color: #0891b2; }
:root[data-theme="dark"] .topic-head-count { background: rgba(255, 255, 255, 0.08); }

.sidebar-cta {
    padding: 18px 16px;
    background: linear-gradient(135deg, var(--accent-dim), transparent);
    border: 1px solid var(--sidebar-border);
    border-radius: var(--radius);
    text-align: center;
    margin-top: 20px;
}
.cta-icon {
    width: 42px; height: 42px;
    margin: 0 auto 10px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
}
.cta-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.cta-text { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; margin-bottom: 14px; }
.cta-btn {
    display: block;
    padding: 9px 16px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff; font-weight: 600; font-size: 0.85rem;
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.cta-btn:hover { color: #fff; opacity: 0.92; transform: translateY(-1px); }

.sidebar-scrim {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
}

/* collapsed sidebar (desktop) */
:root.sidebar-collapsed .sidebar { display: none; }

/* Floating Content Explorer toggle */
.sidebar-fab {
    position: fixed;
    left: 20px; bottom: 20px;
    z-index: 190;
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 18px;
    background: var(--accent); color: #fff;
    border: none; border-radius: 30px;
    font-family: var(--font-sans); font-size: 0.85rem; font-weight: 600;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(79, 70, 229, 0.35);
    transition: background var(--transition), transform var(--transition), box-shadow var(--transition);
}
.sidebar-fab:hover { background: var(--accent-hover); transform: translateY(-2px); box-shadow: 0 8px 26px rgba(79, 70, 229, 0.45); }
.sidebar-fab .fab-icon { display: inline-flex; }
.sidebar-fab .fab-open { display: none; }
:root.sidebar-collapsed .sidebar-fab .fab-close { display: none; }
:root.sidebar-collapsed .sidebar-fab .fab-open { display: inline-flex; }

/* ============ CONTENT ============ */
.content { flex: 1; min-width: 0; }

/* ============ HERO ============ */
.hero {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 28px 28px 14px;
}

.hero-card {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 40px;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 28px;
    box-shadow: var(--shadow-lg);
    position: relative;
    overflow: hidden;
}
.hero-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #a855f7);
}

.hero-image {
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 16/9;
    background-color: var(--bg-secondary);
    background-size: cover;
    background-position: center;
    box-shadow: var(--shadow);
}
.hero-image::before {
    content: "";
    position: absolute;
    inset: -24px;
    background-image: inherit;
    background-size: cover;
    background-position: center;
    filter: blur(20px) saturate(1.15);
    transform: scale(1.15);
}
.hero-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.28);
}
:root[data-theme="dark"] .hero-image::after { background: rgba(11, 17, 32, 0.4); }
.hero-image a { position: relative; z-index: 1; display: block; width: 100%; height: 100%; }
.hero-image img { width: 100%; height: 100%; object-fit: contain; transition: transform 0.5s ease; }
.hero-card:hover .hero-image img { transform: scale(1.03); }

.hero-featured-badge {
    position: absolute;
    top: 14px; left: 14px;
    z-index: 2;
    display: inline-flex; align-items: center; gap: 5px;
    background: rgba(255, 255, 255, 0.95);
    color: var(--accent);
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    backdrop-filter: blur(4px);
}

.hero-badge {
    display: inline-flex; align-items: center; gap: 6px;
    background: var(--accent-dim);
    color: var(--accent);
    padding: 6px 14px;
    border-radius: 24px;
    font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
    margin-bottom: 18px;
}

.hero-title {
    font-size: 1.9rem; font-weight: 800;
    line-height: 1.25; margin-bottom: 14px;
    letter-spacing: -0.5px;
}
.hero-title a { color: var(--text-primary); }
.hero-title a:hover { color: var(--accent); }

.hero-excerpt { color: var(--text-secondary); font-size: 0.98rem; line-height: 1.65; margin-bottom: 18px; }

.hero-meta {
    display: flex; align-items: center; gap: 10px;
    color: var(--text-muted); font-size: 0.83rem;
    margin-bottom: 22px; flex-wrap: wrap;
}
.hero-meta-item { display: flex; align-items: center; gap: 5px; color: var(--text-secondary); }
.hero-meta-dot { width: 4px; height: 4px; background: var(--text-muted); border-radius: 50%; }
.hero-tag {
    display: inline-block;
    padding: 3px 12px; border-radius: 20px;
    font-size: 0.76rem; font-weight: 600;
    background: var(--accent-dim); color: var(--accent);
    transition: all var(--transition);
}
.hero-tag:hover { background: var(--accent); color: #fff; }

.hero-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn-primary {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 24px;
    background: var(--accent); color: #fff;
    font-weight: 600; font-size: 0.92rem;
    border-radius: var(--radius-sm);
    transition: all 0.25s ease;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.25);
}
.btn-primary:hover { background: var(--accent-hover); color: #fff; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(79, 70, 229, 0.35); }

.btn-secondary {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 11px 20px;
    background: var(--bg-card);
    color: var(--text-secondary);
    font-weight: 600; font-size: 0.92rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }

/* ============ SECTION / POST GRID ============ */
.section {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 26px 28px 40px;
}

.section-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 22px;
}
.section-title {
    font-size: 1.3rem; font-weight: 700;
    color: var(--text-primary);
    display: flex; align-items: center; gap: 10px;
}
.section-title::before {
    content: '';
    width: 4px; height: 22px;
    background: var(--accent); border-radius: 2px;
}
.view-all {
    color: var(--accent); font-size: 0.88rem; font-weight: 600;
    display: flex; align-items: center; gap: 6px;
}

.post-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }

.post-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    display: flex; flex-direction: column;
}
.post-card:hover { border-color: var(--border-hover); transform: translateY(-3px); box-shadow: var(--shadow-lg); }

.post-card-image {
    position: relative;
    aspect-ratio: 16/9;
    overflow: hidden;
    background-color: var(--bg-secondary);
    background-size: cover;
    background-position: center;
}
/* blurred fill of the same image so nothing is cropped and no empty bars */
.post-card-image::before {
    content: "";
    position: absolute;
    inset: -24px;
    background-image: inherit;
    background-size: cover;
    background-position: center;
    filter: blur(18px) saturate(1.15);
    transform: scale(1.15);
}
.post-card-image::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.28);
}
:root[data-theme="dark"] .post-card-image::after { background: rgba(11, 17, 32, 0.4); }
.post-card-image a { position: relative; z-index: 1; display: block; width: 100%; height: 100%; }
.post-card-image img {
    width: 100%; height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
}
.post-card:hover .post-card-image img { transform: scale(1.04); }

.post-card-body { padding: 18px; display: flex; flex-direction: column; flex: 1; }

.post-card-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.tag-pill {
    display: inline-block;
    padding: 3px 10px; border-radius: 20px;
    font-size: 0.68rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
    background: var(--accent-dim); color: var(--accent);
    transition: all var(--transition);
}
.tag-pill:hover { background: var(--accent); color: #fff; }

.post-card-title {
    font-size: 1.02rem; font-weight: 700; line-height: 1.4;
    margin-bottom: 8px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.post-card-title a { color: var(--text-primary); }
.post-card-title a:hover { color: var(--accent); }

.post-card-excerpt {
    color: var(--text-secondary); font-size: 0.86rem; line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    margin-bottom: 16px;
}

.post-card-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.post-meta { display: flex; align-items: center; gap: 14px; color: var(--text-muted); font-size: 0.78rem; }
.post-meta-item { display: flex; align-items: center; gap: 5px; }
.post-meta .dot { width: 3px; height: 3px; background: var(--text-muted); border-radius: 50%; }

.post-card-arrow {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: var(--accent-dim);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition);
}
.post-card-arrow:hover { background: var(--accent); color: #fff; transform: translateX(2px); }

/* ============ TAG PAGE ============ */
.tag-header {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 40px 28px 20px;
    text-align: center;
}
.tag-header h1 { font-size: 2rem; font-weight: 800; margin-bottom: 8px; }
.tag-header p { color: var(--text-secondary); max-width: 600px; margin: 0 auto; font-size: 1rem; }
.tag-count { color: var(--accent); font-size: 0.9rem; margin-bottom: 8px; font-weight: 600; }

/* ============ POST DETAIL ============ */
.post-header {
    max-width: var(--read-width);
    margin: 0 auto;
    padding: 40px 24px 20px;
    text-align: center;
}
.post-header .post-tags { display: flex; justify-content: center; gap: 8px; margin-bottom: 16px; }
.post-header h1 { font-size: 2.4rem; font-weight: 800; line-height: 1.2; letter-spacing: -1px; margin-bottom: 16px; }
.post-header .post-excerpt { color: var(--text-secondary); font-size: 1.12rem; line-height: 1.6; margin-bottom: 20px; }
.post-header .post-meta { justify-content: center; }

.post-feature-image { max-width: 880px; margin: 0 auto 36px; padding: 0 24px; }
.post-feature-image img { width: 100%; border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* ============ ARTICLE CONTENT ============ */
.post-content { max-width: var(--read-width); margin: 0 auto; padding: 0 24px 56px; }
.post-content h2 {
    font-size: 1.55rem; font-weight: 700; margin: 44px 0 16px;
    padding-top: 22px; border-top: 1px solid var(--border);
    letter-spacing: -0.3px; color: var(--text-primary);
}
.post-content h2:first-child { border-top: none; margin-top: 0; padding-top: 0; }
.post-content h3 { font-size: 1.28rem; font-weight: 700; margin: 30px 0 12px; color: var(--text-primary); }
.post-content h4 { font-size: 1.1rem; font-weight: 600; margin: 22px 0 8px; color: var(--text-primary); }
.post-content p { margin-bottom: 20px; color: var(--text-secondary); font-size: 1.04rem; line-height: 1.8; }
.post-content a { color: var(--accent); text-decoration: underline; text-decoration-color: rgba(79, 70, 229, 0.3); text-underline-offset: 3px; }
.post-content a:hover { text-decoration-color: var(--accent); }
/* ignore Ghost's stale width/height attrs; size responsively, centered */
.post-content img {
    width: auto;
    height: auto;
    max-width: 100%;
    display: block;
    margin: 22px auto;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.post-content .kg-image { max-width: 100%; }
.post-content figure.kg-image-card { text-align: center; }
/* responsive video / embeds (YouTube etc.) — full column width, 16:9 */
.post-content .kg-embed-card { margin: 22px 0; text-align: center; }
.post-content .kg-embed-card p { margin: 0; width: 100%; }
.post-content iframe {
    display: block;
    width: 100%;
    max-width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    margin: 0 auto;
    border: 0;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}
.post-content ul, .post-content ol { margin-bottom: 20px; padding-left: 24px; color: var(--text-secondary); }
.post-content li { margin-bottom: 8px; font-size: 1.04rem; line-height: 1.7; }
.post-content blockquote {
    border-left: 3px solid var(--accent);
    background: var(--accent-dim);
    padding: 16px 22px; margin: 22px 0;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    font-style: italic; color: var(--text-secondary);
}
.code-wrap { position: relative; margin: 22px 0; }
.post-content pre {
    background: var(--bg-code);
    border: 1px solid #24314d;
    border-radius: var(--radius-sm);
    padding: 20px; margin: 0;
    overflow: auto;
    max-height: 460px;
    font-family: var(--font-mono); font-size: 0.86rem; line-height: 1.65;
    color: #e2e8f0;
}
.code-wrap pre { margin: 0; }
/* keep highlight.js theme's token colors but use our container bg/padding */
.post-content pre code.hljs { background: transparent; padding: 0; }
.copy-btn {
    position: absolute; top: 10px; right: 10px; z-index: 2;
    padding: 5px 12px;
    font-size: 0.74rem; font-weight: 500; font-family: var(--font-sans);
    background: rgba(255, 255, 255, 0.1); color: #cbd5e1;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: var(--radius-xs); cursor: pointer;
    transition: all var(--transition);
}
.copy-btn:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }
.post-content code { font-family: var(--font-mono); font-size: 0.88em; }
.post-content p code, .post-content li code, .post-content td code {
    background: var(--accent-dim);
    padding: 2px 8px; border-radius: 4px;
    font-size: 0.85em; color: var(--accent);
}
.post-content table { width: 100%; border-collapse: collapse; margin: 22px 0; overflow-x: auto; display: block; }
.post-content th, .post-content td { padding: 12px 16px; border: 1px solid var(--border); text-align: left; }
.post-content th { background: var(--bg-secondary); font-weight: 600; color: var(--text-primary); }
.post-content td { color: var(--text-secondary); background: var(--bg-card); }
.post-content figure { margin: 22px 0; }
.post-content figcaption { text-align: center; color: var(--text-muted); font-size: 0.85rem; margin-top: 8px; }
.post-content .kg-card, .post-content .kg-image-card, .post-content .kg-gallery-card, .post-content .kg-bookmark-card { margin: 22px 0; }
.post-content .kg-bookmark-container {
    display: flex; border: 1px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden;
    text-decoration: none; transition: border-color var(--transition);
    background: var(--bg-card);
}
.post-content .kg-bookmark-container:hover { border-color: var(--accent); }
.post-content .kg-bookmark-content { flex: 1; padding: 16px; }
.post-content .kg-bookmark-title { font-weight: 600; font-size: 0.95rem; color: var(--text-primary); }
.post-content .kg-bookmark-description { color: var(--text-secondary); font-size: 0.85rem; margin-top: 4px; }

.related-posts {
    max-width: var(--content-max);
    margin: 0 auto;
    padding: 36px 28px 50px;
    border-top: 1px solid var(--border);
}

/* ============ SEARCH ============ */
.search-page { max-width: 1040px; margin: 0 auto; padding: 40px 28px 56px; }
.search-hero { margin-bottom: 22px; }
.search-title { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.5px; }
.search-sub { color: var(--text-muted); font-size: 1rem; margin-top: 6px; }

.search-box {
    position: relative;
    display: flex; align-items: center; gap: 10px;
    background: var(--bg-card);
    border: 2px solid var(--border);
    border-radius: 14px;
    padding: 0 16px;
    margin-bottom: 26px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-dim); }
.search-box-icon { color: var(--accent); flex-shrink: 0; }
.search-box-input {
    flex: 1; min-width: 0;
    border: none; background: none; outline: none;
    font-size: 1.05rem; padding: 15px 4px;
    color: var(--text-primary); font-family: var(--font-sans);
}
.search-box-input::placeholder { color: var(--text-muted); }
.search-box kbd {
    background: var(--bg-primary);
    color: var(--text-muted);
    padding: 3px 9px; border-radius: 6px;
    font-size: 0.72rem; font-family: var(--font-mono);
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.popular { margin-bottom: 30px; }
.popular-label { display: block; font-size: 0.82rem; font-weight: 700; color: var(--text-secondary); margin-bottom: 12px; }
.popular-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.pop-chip {
    padding: 7px 16px; border-radius: 20px;
    border: 1px solid transparent;
    font-size: 0.85rem; font-weight: 600;
    cursor: pointer; font-family: var(--font-sans);
    transition: all var(--transition);
}
.pop-chip:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.pop-c1 { background: #dcfce7; color: #16a34a; }
.pop-c2 { background: #fef3c7; color: #d97706; }
.pop-c3 { background: #e0e7ff; color: #4f46e5; }
.pop-c4 { background: #dbeafe; color: #2563eb; }
.pop-c5 { background: #fce7f3; color: #db2777; }
.pop-c6 { background: #cffafe; color: #0891b2; }
:root[data-theme="dark"] .pop-chip { background: rgba(255,255,255,0.06); border-color: var(--border); }

.search-empty {
    grid-column: 1 / -1;
    text-align: center; padding: 40px 20px;
    color: var(--text-muted); font-size: 0.95rem;
    background: var(--bg-card); border: 1px dashed var(--border); border-radius: var(--radius);
}

.search-more { display: flex; justify-content: center; margin-top: 28px; }

/* ============ PAGE CONTENT ============ */
.page-header { max-width: var(--read-width); margin: 0 auto; padding: 40px 24px 20px; }
.page-header h1 { font-size: 2.2rem; font-weight: 800; letter-spacing: -0.5px; }

/* ============ FOOTER ============ */
.footer { background: var(--header-bg); color: var(--header-text); padding: 48px 28px; margin-top: 30px; }
.footer-inner { max-width: var(--content-max); margin: 0 auto; display: grid; grid-template-columns: 1.8fr 1.1fr 1.1fr; gap: 48px; }
.footer .logo { color: var(--header-text); }
.footer .logo-tagline { color: var(--header-text-muted); }
.footer-brand p { color: var(--header-text-muted); font-size: 0.9rem; margin-top: 16px; line-height: 1.6; max-width: 380px; }
.footer-heading { font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: #a5b4fc; margin-bottom: 18px; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: 10px; }
.footer-links a { color: rgba(226, 232, 240, 0.7); font-size: 0.9rem; }
.footer-links a:hover { color: #fff; }
.footer-links-2col { columns: 2; column-gap: 24px; }
.footer-links-2col li { break-inside: avoid; }
.footer-bottom {
    max-width: var(--content-max);
    margin: 36px auto 0; padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex; align-items: center; justify-content: space-between;
    color: var(--header-text-muted); font-size: 0.82rem;
}
.footer-made { display: inline-flex; align-items: center; gap: 7px; }
.footer-made svg { color: #f43f5e; }
.social-links { display: flex; gap: 12px; }
.footer-brand .social-links { margin-top: 22px; }
.social-links a {
    width: 36px; height: 36px; border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.15);
    display: flex; align-items: center; justify-content: center;
    color: var(--header-text-muted); transition: all var(--transition);
}
.social-links a:hover { color: #fff; border-color: rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.08); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1180px) {
    .post-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 980px) {
    .hero-card { grid-template-columns: 1fr; gap: 22px; }
    .nav { display: none; }
}

@media (max-width: 860px) {
    :root { --header-h: 56px; }
    .rail { display: none; }
    .shell { margin-left: 0; }

    .sidebar {
        position: fixed;
        top: 0; left: 0; bottom: 0;
        height: 100vh;
        z-index: 160;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        box-shadow: var(--shadow-xl);
    }
    .app.sidebar-open .sidebar { transform: translateX(0); }
    .app.sidebar-open .sidebar-scrim { display: block; }
    /* on mobile the sidebar is a drawer; ignore the desktop-collapsed state */
    :root.sidebar-collapsed .sidebar { display: flex; }

    .sidebar-toggle { display: flex; }
    .logo-tagline { display: none; }
    .search-btn { min-width: auto; padding: 8px 12px; }
    .search-btn-text, .search-btn kbd { display: none; }

    .hero { padding: 20px 16px 10px; }
    .hero-card { padding: 18px; }
    .hero-title { font-size: 1.5rem; }
    .section { padding: 20px 16px 36px; }
    .post-grid { grid-template-columns: 1fr; }
    .post-header h1 { font-size: 1.8rem; }
    .footer { padding: 32px 16px; }
    .footer-inner { grid-template-columns: 1fr; gap: 30px; }
    .footer-bottom { flex-direction: column; gap: 16px; text-align: center; }
}

/* ============ UTILITIES / ANIMATION ============ */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
@keyframes fadeInUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.animate-in { animation: fadeInUp 0.5s ease forwards; }

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

/* ============ Pagination ============ */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin: 40px 0 8px;
    flex-wrap: wrap;
}
.pagination .page-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
}
.pagination a.page-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--bg-card-hover);
}
.pagination .page-link.disabled {
    opacity: 0.4;
    cursor: default;
}
.pagination .page-current {
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0 4px;
}
