
/* ═══════════════════════════════════════════════════════════════════
   LLM Wiki — "Scholar's Ink" Theme
   A dark, editorial knowledge base inspired by research journals,
   illuminated manuscripts, and the texture of fine ink on paper.
   ═══════════════════════════════════════════════════════════════════ */

:root {
    --bg-deep: #08090C;
    --bg-primary: #0C0E13;
    --bg-secondary: #111318;
    --bg-surface: #171A22;
    --bg-elevated: #1D2029;
    --bg-glass: rgba(23, 26, 34, 0.75);

    --ink-primary: #D8D3CA;
    --ink-secondary: #A09B90;
    --ink-faded: #5C5850;
    --ink-ghost: #3A3733;

    --gold: #C8956C;
    --gold-bright: #E4B07C;
    --gold-dim: rgba(200, 149, 108, 0.10);
    --gold-glow: rgba(200, 149, 108, 0.06);

    --teal: #5DAE96;
    --teal-dim: rgba(93, 174, 150, 0.10);

    --slate-blue: #7A9BBF;
    --slate-blue-dim: rgba(122, 155, 191, 0.10);

    --rose: #BF6A7A;
    --rose-dim: rgba(191, 106, 122, 0.10);

    --border: rgba(200, 195, 185, 0.07);
    --border-hover: rgba(200, 195, 185, 0.14);

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --font-display: 'Fraunces', 'Noto Sans SC', serif;
    --font-body: 'EB Garamond', 'Noto Sans SC', Georgia, serif;
    --font-sans: 'Noto Sans SC', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --sidebar-w: 272px;
    --content-w: 880px;

    --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { font-size: 17px; scroll-behavior: smooth; }

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--ink-primary);
    line-height: 1.75;
    display: flex;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Subtle grain texture overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9999;
    opacity: 0.025;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
    color: var(--slate-blue);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover { color: var(--gold-bright); }

::selection {
    background: rgba(200, 149, 108, 0.25);
    color: var(--ink-primary);
}

/* ══════════════════════════════════════════════════════════════
   Sidebar — The Window
   ══════════════════════════════════════════════════════════════ */

#sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Soft glow at top of sidebar */
#sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 200px;
    background: radial-gradient(ellipse at 30% 0%, var(--gold-glow) 0%, transparent 70%);
    pointer-events: none;
}

.sidebar-header {
    position: relative;
    padding: 36px 28px 28px;
    border-bottom: 1px solid var(--border);
}

.site-title {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.title-icon {
    font-size: 1.4rem;
    color: var(--gold);
    line-height: 1;
}

.title-text {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--ink-primary);
    letter-spacing: 0.01em;
    font-optical-sizing: auto;
}

.site-subtitle {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    color: var(--ink-faded);
    margin-top: 6px;
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-weight: 400;
    padding-left: 32px;
}

.sidebar-nav {
    position: relative;
    padding: 20px 14px;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 16px;
    border-radius: var(--radius-sm);
    color: var(--ink-secondary);
    font-family: var(--font-sans);
    font-size: 0.84rem;
    font-weight: 500;
    transition: all var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-surface);
    color: var(--ink-primary);
}

.nav-item.active {
    background: var(--gold-dim);
    color: var(--gold);
    font-weight: 600;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: var(--gold);
}

.nav-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    opacity: 0.6;
}

.nav-item.active .nav-icon { opacity: 1; }

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border);
    padding: 16px;
}

.sidebar-search { position: relative; }

.search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--ink-faded);
    pointer-events: none;
    flex-shrink: 0;
}

#search-input {
    width: 100%;
    padding: 10px 12px 10px 36px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--ink-primary);
    font-family: var(--font-sans);
    font-size: 0.82rem;
    outline: none;
    transition: all var(--transition);
}

#search-input:focus {
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-dim);
}

#search-input::placeholder { color: var(--ink-faded); }

.search-results {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    max-height: 55vh;
    overflow-y: auto;
    background: var(--bg-elevated);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-md);
    box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 200;
}

.search-results.visible { display: block; }

.search-result-item {
    display: block;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
    text-decoration: none;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--bg-surface); }

.search-result-item .sr-title {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink-primary);
}

.search-result-item mark {
    background: rgba(200, 149, 108, 0.3);
    color: var(--gold-bright);
    border-radius: 2px;
    padding: 0 2px;
}

.search-result-item .sr-type {
    font-family: var(--font-sans);
    font-size: 0.62rem;
    color: var(--gold);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-left: 8px;
    font-weight: 600;
}

.search-result-item .sr-preview {
    font-size: 0.78rem;
    color: var(--ink-faded);
    margin-top: 3px;
    line-height: 1.5;
}

/* ══════════════════════════════════════════════════════════════
   Mobile Toggle
   ══════════════════════════════════════════════════════════════ */

#sidebar-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
}

#sidebar-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--ink-secondary);
    border-radius: 1px;
    transition: all var(--transition);
}

/* ══════════════════════════════════════════════════════════════
   Main Content
   ══════════════════════════════════════════════════════════════ */

#main {
    margin-left: var(--sidebar-w);
    flex: 1;
    padding: 48px 56px 100px;
    max-width: calc(var(--sidebar-w) + var(--content-w) + 112px);
    min-width: 0;
    position: relative;
    animation: pageIn 0.5s ease-out;
}

@keyframes pageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ══════════════════════════════════════════════════════════════
   Breadcrumb
   ══════════════════════════════════════════════════════════════ */

.breadcrumb {
    font-family: var(--font-sans);
    font-size: 0.76rem;
    color: var(--ink-faded);
    margin-bottom: 24px;
    letter-spacing: 0.02em;
}

.breadcrumb a { color: var(--ink-faded); }
.breadcrumb a:hover { color: var(--gold); }
.breadcrumb .sep { margin: 0 8px; opacity: 0.3; }
.breadcrumb .current { color: var(--ink-secondary); }

/* ══════════════════════════════════════════════════════════════
   Home Page
   ══════════════════════════════════════════════════════════════ */

.home-header {
    margin-bottom: 48px;
    padding-bottom: 40px;
    border-bottom: 1px solid var(--border);
}

.home-title {
    font-family: var(--font-display);
    font-size: 3.2rem;
    font-weight: 800;
    color: var(--ink-primary);
    margin-bottom: 12px;
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.home-desc {
    font-family: var(--font-sans);
    font-size: 0.92rem;
    color: var(--ink-secondary);
    line-height: 1.7;
    max-width: 540px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 56px;
}

.stat-card {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 28px 20px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--transition);
    text-decoration: none;
    overflow: hidden;
}

.stat-card::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-lg);
    background: radial-gradient(ellipse at 50% 0%, var(--gold-glow) 0%, transparent 60%);
    opacity: 0;
    transition: opacity var(--transition);
}

.stat-card:hover {
    border-color: var(--gold);
    transform: translateY(-3px);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(200, 149, 108, 0.08);
}

.stat-card:hover::after { opacity: 1; }

.stat-icon {
    font-size: 1.4rem;
    margin-bottom: 10px;
    opacity: 0.5;
    position: relative;
    z-index: 1;
}

.stat-number {
    font-family: var(--font-display);
    font-size: 2.4rem;
    font-weight: 800;
    color: var(--gold);
    line-height: 1;
    position: relative;
    z-index: 1;
}

.stat-label {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    color: var(--ink-faded);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-top: 8px;
    position: relative;
    z-index: 1;
}

.home-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 40px;
}

.section-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--ink-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    letter-spacing: -0.01em;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.recent-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
    text-decoration: none;
}

.recent-item:hover { background: var(--bg-surface); }

.recent-type {
    font-family: var(--font-sans);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 3px;
    font-weight: 600;
    min-width: 64px;
    text-align: center;
    flex-shrink: 0;
}

.recent-type.entities { background: var(--gold-dim); color: var(--gold); }
.recent-type.concepts { background: var(--teal-dim); color: var(--teal); }
.recent-type.queries { background: var(--slate-blue-dim); color: var(--slate-blue); }

.recent-title {
    flex: 1;
    font-size: 0.92rem;
    color: var(--ink-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.recent-date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--ink-faded);
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   Tag Cloud
   ══════════════════════════════════════════════════════════════ */

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    align-items: center;
}

.tag {
    font-family: var(--font-sans);
    display: inline-block;
    padding: 3px 11px;
    border-radius: 20px;
    font-size: 0.74rem;
    font-weight: 500;
    background: color-mix(in srgb, var(--tag-color, #888) 10%, transparent);
    color: var(--tag-color, #888);
    border: 1px solid color-mix(in srgb, var(--tag-color, #888) 16%, transparent);
    transition: all var(--transition);
    white-space: nowrap;
}

.tag:hover {
    background: color-mix(in srgb, var(--tag-color, #888) 20%, transparent);
    border-color: color-mix(in srgb, var(--tag-color, #888) 50%, transparent);
    transform: translateY(-1px);
}

.tag small { opacity: 0.5; font-size: 0.7em; }

/* ══════════════════════════════════════════════════════════════
   Page Grid — Entity / Concept Cards
   ══════════════════════════════════════════════════════════════ */

.page-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.page-grid.compact-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 10px;
}

.page-card {
    display: flex;
    flex-direction: column;
    padding: 22px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
    text-decoration: none;
    cursor: pointer;
    position: relative;
    overflow: hidden;
}

.page-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold), var(--teal));
    opacity: 0;
    transition: opacity var(--transition);
}

.page-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-elevated);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.page-card:hover::before { opacity: 1; }

.page-card.compact { padding: 16px 18px; }

.page-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.page-card-title {
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--ink-primary);
    line-height: 1.3;
}

.page-card-date {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--ink-faded);
    white-space: nowrap;
    margin-left: 12px;
    padding-top: 3px;
}

.page-card-preview {
    font-size: 0.86rem;
    color: var(--ink-secondary);
    line-height: 1.55;
    flex: 1;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.page-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

/* ══════════════════════════════════════════════════════════════
   List View — Queries / Papers
   ══════════════════════════════════════════════════════════════ */

.list-view {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: all var(--transition);
    text-decoration: none;
}

.list-item:hover {
    border-color: var(--border-hover);
    background: var(--bg-elevated);
    transform: translateX(4px);
}

.list-item h3 {
    font-family: var(--font-body);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink-primary);
    margin-bottom: 4px;
}

.list-item p {
    font-size: 0.84rem;
    color: var(--ink-faded);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.list-item-date {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--ink-faded);
}

.list-item-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    text-align: right;
    flex-shrink: 0;
    margin-left: 24px;
}

/* ══════════════════════════════════════════════════════════════
   Papers
   ══════════════════════════════════════════════════════════════ */

.paper-item .paper-id {
    font-family: var(--font-mono);
    font-size: 0.76rem;
    color: var(--ink-faded);
}

.paper-title-link {
    color: inherit;
    text-decoration: none;
}

.paper-title-link:hover {
    color: var(--gold-bright);
}

.paper-original-title,
.paper-original-title-block {
    display: block;
    font-family: var(--font-body);
    color: var(--ink-faded);
}

.paper-original-title {
    font-size: 0.78rem;
    margin-bottom: 6px;
}

.paper-original-title-block {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.paper-quality {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 120px;
    padding: 3px 8px;
    background: var(--teal-dim);
    border: 1px solid color-mix(in srgb, var(--teal) 22%, transparent);
    border-radius: var(--radius-xs);
    color: var(--teal);
    font-family: var(--font-mono);
    font-size: 0.68rem;
}

.paper-quality.source_limited {
    background: var(--gold-dim);
    border-color: color-mix(in srgb, var(--gold) 22%, transparent);
    color: var(--gold);
}

.paper-quality.pending_brief {
    background: var(--slate-blue-dim);
    border-color: color-mix(in srgb, var(--slate-blue) 22%, transparent);
    color: var(--slate-blue);
}

.hot-item {
    gap: 18px;
}

.hot-rank {
    width: 46px;
    flex-shrink: 0;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--gold-bright);
}

.hot-new,
.hot-mentions {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--ink-faded);
}

.hot-new {
    color: var(--gold-bright);
}

.hot-updated {
    font-family: var(--font-mono);
    font-size: 0.78rem;
}

.md-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 10px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--gold);
    font-family: var(--font-mono);
    font-size: 0.74rem;
    transition: all var(--transition);
}

.md-link:hover {
    border-color: var(--gold);
    background: var(--gold-dim);
}

/* ══════════════════════════════════════════════════════════════
   Category Navigation — Concepts
   ══════════════════════════════════════════════════════════════ */

.cat-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 40px;
    padding: 18px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.cat-nav-item {
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.78rem;
    color: var(--ink-secondary);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.cat-nav-item:hover {
    color: var(--gold);
    border-color: var(--gold);
    background: var(--gold-dim);
}

.cat-nav-item .cat-count {
    font-size: 0.64rem;
    font-weight: 700;
    color: var(--gold);
}

.category-section {
    margin-bottom: 48px;
    animation: pageIn 0.4s ease-out both;
}

.category-title {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--ink-primary);
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    letter-spacing: -0.01em;
}

.category-title .cat-count {
    font-family: var(--font-sans);
    font-size: 0.68rem;
    background: var(--gold-dim);
    color: var(--gold);
    padding: 2px 9px;
    border-radius: 10px;
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   Detail Page — The Reading Room
   ══════════════════════════════════════════════════════════════ */

.detail-header { margin-bottom: 36px; }

.detail-top-bar {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.view-md-btn {
    font-family: var(--font-sans);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 7px 16px;
    background: var(--gold-dim);
    border: 1px solid color-mix(in srgb, var(--gold) 24%, transparent);
    border-radius: var(--radius-sm);
    color: var(--gold);
    font-size: 0.78rem;
    font-weight: 500;
    transition: all var(--transition);
}

.view-md-btn:hover {
    background: color-mix(in srgb, var(--gold) 18%, transparent);
    border-color: var(--gold);
    color: var(--gold-bright);
}

.md-icon { font-size: 0.85rem; }

.detail-content {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 36px;
}

.detail-meta {
    position: sticky;
    top: 40px;
    align-self: start;
    padding: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.detail-type-badge {
    font-family: var(--font-sans);
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 4px 10px;
    border-radius: 4px;
    display: inline-block;
    margin-bottom: 14px;
}

.detail-type-badge.entities { background: var(--gold-dim); color: var(--gold); }
.detail-type-badge.concepts { background: var(--teal-dim); color: var(--teal); }
.detail-type-badge.queries { background: var(--slate-blue-dim); color: var(--slate-blue); }
.detail-type-badge.papers { background: var(--gold-dim); color: var(--gold-bright); }

.detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 18px;
}

.meta-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}

.meta-label {
    font-family: var(--font-sans);
    color: var(--ink-faded);
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.meta-value {
    font-family: var(--font-mono);
    color: var(--ink-secondary);
    font-size: 0.76rem;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.source-link {
    font-size: 0.72rem;
    color: var(--slate-blue);
}

.detail-body { min-width: 0; }

.detail-body h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 28px;
    line-height: 1.15;
    color: var(--ink-primary);
    letter-spacing: -0.02em;
}

.detail-body h2 {
    font-family: var(--font-display);
    font-size: 1.45rem;
    font-weight: 600;
    margin-top: 44px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    color: var(--ink-primary);
    letter-spacing: -0.01em;
}

.detail-body h3 {
    font-family: var(--font-body);
    font-size: 1.2rem;
    font-weight: 600;
    margin-top: 28px;
    margin-bottom: 10px;
    color: var(--ink-primary);
}

.detail-body p {
    margin-bottom: 16px;
    line-height: 1.85;
    color: color-mix(in srgb, var(--ink-primary) 90%, transparent);
}

.detail-body ul, .detail-body ol {
    margin-bottom: 16px;
    padding-left: 28px;
}

.detail-body li {
    margin-bottom: 6px;
    line-height: 1.7;
}

.detail-body li::marker { color: var(--ink-faded); }

.detail-body blockquote {
    border-left: 3px solid var(--gold);
    padding: 14px 24px;
    margin: 20px 0;
    background: color-mix(in srgb, var(--gold) 3%, transparent);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--ink-secondary);
    font-style: italic;
}

.detail-body code {
    font-family: var(--font-mono);
    font-size: 0.82em;
    padding: 2px 7px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 3px;
    color: var(--gold);
}

.detail-body pre {
    margin: 20px 0;
    padding: 20px 24px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow-x: auto;
    font-size: 0.82rem;
    line-height: 1.65;
}

.detail-body pre code {
    padding: 0;
    background: none;
    border: none;
    color: var(--ink-primary);
}

.detail-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 0.88rem;
}

.detail-body th, .detail-body td {
    padding: 12px 16px;
    border: 1px solid var(--border);
    text-align: left;
}

.detail-body th {
    background: var(--bg-surface);
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--ink-primary);
    letter-spacing: 0.02em;
}

.detail-body td { color: var(--ink-secondary); }

.detail-body tr:hover td { background: var(--bg-surface); }

.detail-body strong {
    color: var(--ink-primary);
    font-weight: 600;
}

/* ══════════════════════════════════════════════════════════════
   Wikilinks — The Threads
   ══════════════════════════════════════════════════════════════ */

.wikilink {
    color: var(--teal);
    border-bottom: 1px solid color-mix(in srgb, var(--teal) 30%, transparent);
    transition: all var(--transition);
    padding: 0 1px;
}

.wikilink:hover {
    color: #7CC9AE;
    border-bottom-color: var(--teal);
    background: var(--teal-dim);
    border-radius: 2px;
}

.wikilink.broken {
    color: var(--rose);
    border-bottom: 1px dotted var(--rose);
    opacity: 0.65;
    cursor: help;
}

/* ══════════════════════════════════════════════════════════════
   Backlinks — The Web
   ══════════════════════════════════════════════════════════════ */

.backlinks-section {
    margin-top: 56px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.backlinks-section h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 14px;
    color: var(--ink-secondary);
}

.backlinks-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.backlink-item {
    display: inline-block;
    padding: 7px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--ink-secondary);
    font-family: var(--font-body);
    font-size: 0.88rem;
    transition: all var(--transition);
}

.backlink-item:hover {
    border-color: var(--teal);
    color: var(--teal);
    background: var(--teal-dim);
    transform: translateY(-1px);
}

/* ══════════════════════════════════════════════════════════════
   Tags Page
   ══════════════════════════════════════════════════════════════ */

.tag-section {
    margin-bottom: 36px;
}

.tag-section h2 {
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tag-count {
    font-family: var(--font-sans);
    font-size: 0.7rem;
    color: var(--ink-faded);
}

.tag-page-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-page-link {
    font-family: var(--font-sans);
    padding: 5px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--ink-secondary);
    font-size: 0.82rem;
    transition: all var(--transition);
}

.tag-page-link:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-dim);
}

/* ══════════════════════════════════════════════════════════════
   Listing Header
   ══════════════════════════════════════════════════════════════ */

.listing-header { margin-bottom: 36px; }

.listing-header h1 {
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: 800;
    margin-bottom: 10px;
    letter-spacing: -0.02em;
}

.listing-desc {
    font-family: var(--font-sans);
    color: var(--ink-secondary);
    font-size: 0.9rem;
}

/* ══════════════════════════════════════════════════════════════
   Responsive
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
    #sidebar {
        transform: translateX(-100%);
        transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    }

    #sidebar.open { transform: translateX(0); }

    #sidebar-toggle { display: flex; }

    #main {
        margin-left: 0;
        padding: 24px 20px 80px;
    }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .home-grid { grid-template-columns: 1fr; }
    .detail-content { grid-template-columns: 1fr; }
    .detail-meta { position: static; order: -1; }
}

@media (max-width: 600px) {
    html { font-size: 15px; }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .page-grid { grid-template-columns: 1fr; }

    .list-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .list-item-meta {
        margin-left: 0;
        margin-top: 10px;
        text-align: left;
    }
}

/* ══════════════════════════════════════════════════════════════
   Chinese Research Desk Refresh
   ══════════════════════════════════════════════════════════════ */

:root {
    --bg-deep: #EEF2F4;
    --bg-primary: #F9FAF8;
    --bg-secondary: #F3F6F7;
    --bg-surface: #FFFFFF;
    --bg-elevated: #F7FAFB;
    --bg-glass: rgba(255, 255, 255, 0.88);

    --ink-primary: #18202B;
    --ink-secondary: #4B596A;
    --ink-faded: #7A8794;
    --ink-ghost: #C9D0D7;

    --gold: #A0632D;
    --gold-bright: #C17C3A;
    --gold-dim: rgba(160, 99, 45, 0.10);
    --gold-glow: rgba(160, 99, 45, 0.06);

    --teal: #1F7A68;
    --teal-dim: rgba(31, 122, 104, 0.10);
    --slate-blue: #335C9B;
    --slate-blue-dim: rgba(51, 92, 155, 0.10);
    --rose: #B84A5A;
    --rose-dim: rgba(184, 74, 90, 0.10);

    --border: rgba(26, 36, 49, 0.10);
    --border-hover: rgba(26, 36, 49, 0.20);

    --radius-xs: 4px;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 8px;
    --radius-xl: 8px;

    --font-display: 'Noto Sans SC', 'Fraunces', system-ui, sans-serif;
    --font-body: 'Noto Sans SC', 'EB Garamond', system-ui, sans-serif;
    --content-w: 1120px;
}

body {
    background:
        linear-gradient(90deg, rgba(51, 92, 155, 0.04), transparent 32%),
        linear-gradient(180deg, #F7F8F5 0%, #EEF2F4 100%);
    color: var(--ink-primary);
}

body::before {
    opacity: 0.035;
    mix-blend-mode: multiply;
}

#sidebar {
    background: rgba(249, 250, 248, 0.94);
    border-right: 1px solid rgba(26, 36, 49, 0.12);
    box-shadow: 12px 0 36px rgba(28, 38, 55, 0.06);
    backdrop-filter: blur(16px);
}

#sidebar::before { display: none; }

.sidebar-header {
    padding: 30px 24px 24px;
    background: linear-gradient(180deg, rgba(51, 92, 155, 0.07), transparent);
}

.title-text {
    font-size: 1.14rem;
    letter-spacing: 0;
}

.site-subtitle {
    padding-left: 0;
    letter-spacing: 0;
    text-transform: none;
    line-height: 1.5;
}

.nav-item {
    border: 1px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    background: #FFFFFF;
    border-color: var(--border);
    box-shadow: 0 8px 22px rgba(28, 38, 55, 0.07);
}

#search-input {
    background: #FFFFFF;
    border-color: rgba(26, 36, 49, 0.14);
}

.search-results {
    background: #FFFFFF;
    box-shadow: 0 -18px 42px rgba(28, 38, 55, 0.16);
}

#main {
    max-width: calc(var(--sidebar-w) + var(--content-w) + 96px);
    padding: 44px 48px 96px;
}

.home-header,
.listing-header {
    background: rgba(255, 255, 255, 0.62);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    margin-bottom: 28px;
    box-shadow: 0 14px 34px rgba(28, 38, 55, 0.06);
}

.home-title,
.listing-header h1 {
    font-size: 2.45rem;
    letter-spacing: 0;
}

.home-desc,
.listing-desc {
    max-width: 820px;
    color: var(--ink-secondary);
}

.stats-grid {
    margin-bottom: 34px;
}

.stat-card,
.page-card,
.list-item,
.cat-nav,
.detail-meta,
.reading-guide,
.tag-page-link {
    background: var(--bg-surface);
    border-color: var(--border);
    box-shadow: 0 8px 24px rgba(28, 38, 55, 0.055);
}

.stat-card:hover,
.page-card:hover,
.list-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 38px rgba(28, 38, 55, 0.12);
}

.home-grid {
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.85fr);
    gap: 28px;
}

.section-title.secondary {
    margin-top: 26px;
}

.focus-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.focus-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: #FFFFFF;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--ink-secondary);
    font-family: var(--font-sans);
    font-size: 0.82rem;
}

.focus-item strong {
    color: var(--slate-blue);
    font-family: var(--font-mono);
}

.recent-item {
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
    border-radius: 0;
}

.recent-item:hover {
    background: transparent;
}

.recent-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.recent-title {
    white-space: normal;
    font-weight: 600;
    line-height: 1.35;
}

.recent-preview {
    color: var(--ink-secondary);
    font-size: 0.82rem;
    line-height: 1.6;
}

.summary-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 2px;
}

.summary-chip {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    background: var(--slate-blue-dim);
    color: var(--slate-blue);
    font-family: var(--font-sans);
    font-size: 0.68rem;
    line-height: 1.35;
}

.page-card {
    padding: 20px;
}

.page-card-header.compact {
    margin-bottom: 8px;
}

.page-card-header.compact h3 {
    color: var(--ink-primary);
    font-size: 1rem;
    line-height: 1.35;
}

.page-card-header.compact span {
    color: var(--ink-faded);
    font-family: var(--font-mono);
    font-size: 0.66rem;
    white-space: nowrap;
}

.page-card-preview,
.list-item p,
.page-card.compact p {
    color: var(--ink-secondary);
    -webkit-line-clamp: 4;
}

.list-item {
    align-items: flex-start;
}

.list-item-main {
    min-width: 0;
}

.list-item-type {
    display: inline-flex;
    margin-bottom: 8px;
    padding: 3px 8px;
    border-radius: var(--radius-xs);
    font-family: var(--font-sans);
    font-size: 0.66rem;
    font-weight: 700;
}

.list-item-type.entities { background: var(--gold-dim); color: var(--gold); }
.list-item-type.concepts { background: var(--teal-dim); color: var(--teal); }
.list-item-type.queries { background: var(--slate-blue-dim); color: var(--slate-blue); }

.cat-nav {
    position: sticky;
    top: 0;
    z-index: 4;
    backdrop-filter: blur(16px);
}

.cat-nav-item {
    border-radius: var(--radius-xs);
    background: #FFFFFF;
}

.category-section {
    scroll-margin-top: 90px;
}

.detail-header {
    margin-bottom: 22px;
}

.detail-content {
    grid-template-columns: 240px minmax(0, 1fr);
}

.detail-meta {
    top: 24px;
}

.detail-body {
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 34px 42px;
    box-shadow: 0 16px 40px rgba(28, 38, 55, 0.07);
}

.reading-guide {
    padding: 18px 20px;
    margin-bottom: 30px;
    border-left: 4px solid var(--slate-blue);
}

.guide-kicker {
    font-family: var(--font-sans);
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--slate-blue);
    margin-bottom: 8px;
}

.reading-guide p {
    color: var(--ink-secondary);
    margin-bottom: 12px;
}

.reading-guide ol {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 18px;
    margin: 0;
    padding-left: 20px;
}

.reading-guide li {
    color: var(--ink-secondary);
    font-size: 0.86rem;
    margin-bottom: 0;
}

.detail-body h1 {
    font-size: 2rem;
    letter-spacing: 0;
}

.detail-body h2 {
    letter-spacing: 0;
    border-bottom-color: rgba(51, 92, 155, 0.16);
}

.detail-body pre {
    background: #172033;
}

.detail-body pre code {
    color: #EEF2F4;
}

.detail-body table {
    background: #FFFFFF;
}

.backlinks-section {
    margin-left: 276px;
}

@media (max-width: 900px) {
    .home-grid,
    .detail-content {
        grid-template-columns: 1fr;
    }
    .detail-body {
        padding: 26px 22px;
    }
    .backlinks-section {
        margin-left: 0;
    }
    .cat-nav {
        position: static;
    }
}

@media (max-width: 600px) {
    #main {
        padding: 72px 16px 72px;
    }
    .home-header,
    .listing-header {
        padding: 22px 18px;
    }
    .home-title,
    .listing-header h1 {
        font-size: 1.9rem;
    }
    .focus-grid,
    .reading-guide ol {
        grid-template-columns: 1fr;
    }
    .recent-date {
        display: none;
    }
}

/* ══════════════════════════════════════════════════════════════
   Scrollbar
   ══════════════════════════════════════════════════════════════ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--ink-ghost);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--ink-faded); }
