/* 环泊酚文献库 —— 浅色卡片主题 */
:root {
    --bg: #f4f6fa;
    --card: #ffffff;
    --ink: #1f2733;
    --ink-2: #5b6675;
    --ink-3: #8a94a3;
    --line: #e5eaf1;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-soft: #e8f0fe;
    --red: #e11d48;
    --orange: #ea580c;
    --green: #16a34a;
    --purple: #7c3aed;
    --blue: #0284c7;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(31, 39, 51, 0.05), 0 6px 24px rgba(31, 39, 51, 0.07);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        "Source Han Sans SC", "Noto Sans CJK SC", -apple-system, "Segoe UI",
        Roboto, sans-serif;
    line-height: 1.65;
    font-size: 15px;
}

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 24px 64px; }

/* ---------- 顶栏 ---------- */
.topbar {
    background: linear-gradient(120deg, #1e3a8a 0%, #2563eb 55%, #0ea5e9 100%);
    color: #fff;
    padding: 28px 0 32px;
    margin-bottom: -18px;
}
.topbar .container { padding-bottom: 0; }
.topbar h1 {
    margin: 0 0 4px;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.topbar .subtitle { margin: 0; opacity: 0.85; font-size: 13px; }
.topnav { margin-top: 14px; display: flex; gap: 8px; }
.topnav a {
    color: #fff;
    background: rgba(255, 255, 255, 0.14);
    border: 1px solid rgba(255, 255, 255, 0.25);
    padding: 5px 14px;
    border-radius: 999px;
    font-size: 13px;
    transition: background 0.15s;
}
.topnav a:hover { background: rgba(255, 255, 255, 0.28); text-decoration: none; }

/* ---------- 卡片与统计 ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 24px;
    margin-top: 22px;
}
.card h2 {
    margin: 0 0 14px;
    font-size: 17px;
    font-weight: 650;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card h2::before {
    content: "";
    display: inline-block;
    width: 4px;
    height: 16px;
    border-radius: 2px;
    background: var(--brand);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    margin-top: 22px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 20px 14px;
    position: relative;
    overflow: hidden;
}
.stat-card::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 3px;
    background: var(--accent, var(--brand));
}
.stat-card .num {
    font-size: 30px;
    font-weight: 750;
    line-height: 1.15;
    color: var(--accent, var(--brand));
    font-variant-numeric: tabular-nums;
}
.stat-card .label { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.stat-card .desc { color: var(--ink-3); font-size: 12px; margin-top: 6px; }

/* ---------- 搜索 ---------- */
.search-box { display: flex; gap: 10px; }
.search-box input[type="search"], .search-box input[type="text"] {
    flex: 1;
    padding: 11px 16px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: inherit;
}
.search-box input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-soft);
}
.btn {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 10px 22px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.15s;
    font-family: inherit;
    white-space: nowrap;
}
.btn:hover { background: var(--brand-dark); text-decoration: none; color: #fff; }
.btn.ghost {
    background: #fff;
    color: var(--brand);
    border: 1px solid var(--brand);
}
.btn.ghost:hover { background: var(--brand-soft); }
.quick-words { margin-top: 10px; font-size: 13px; color: var(--ink-3); }
.quick-words a { margin: 0 6px 0 0; }

/* ---------- 表格 ---------- */
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
table.data th, table.data td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}
table.data th {
    color: var(--ink-2);
    font-weight: 600;
    font-size: 13px;
    background: #f8fafc;
    position: sticky;
    top: 0;
}
table.data tbody tr:hover { background: #f6f9ff; }
table.data .idx { color: var(--ink-3); width: 56px; }
table.data .year { width: 64px; font-variant-numeric: tabular-nums; }
table.data .type { width: 110px; }
table.data .lang { width: 64px; }
table.data .ops { width: 90px; }

/* ---------- 徽章 / 标签 ---------- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.7;
    white-space: nowrap;
}
.badge-rct { background: #e8f7ee; color: var(--green); }
.badge-meta { background: #f3e8ff; color: var(--purple); }
.badge-review { background: #e8f0fe; color: var(--blue); }
.badge-pre { background: #fff1e8; color: var(--orange); }
.badge-default { background: #eef1f5; color: var(--ink-2); }
.badge-zh { background: #fdeef2; color: var(--red); }
.badge-en { background: #eef1f5; color: var(--ink-2); }

.tag {
    display: inline-block;
    background: var(--brand-soft);
    color: var(--brand-dark);
    border-radius: 6px;
    padding: 1px 9px;
    font-size: 12.5px;
    margin: 2px 4px 2px 0;
}
.tag.plain { background: #eef1f5; color: var(--ink-2); }
.tag.warn { background: #fff1e8; color: var(--orange); }

/* ---------- 搜索结果 ---------- */
.hit {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 14px 18px;
    margin-bottom: 12px;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.hit:hover { border-color: #c7d7f8; box-shadow: 0 4px 16px rgba(37, 99, 235, 0.08); }
.hit .hit-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.hit .hit-title { font-size: 15.5px; font-weight: 650; color: var(--ink); }
.hit .hit-title:hover { color: var(--brand-dark); }
.hit .score {
    font-size: 12px;
    color: var(--brand);
    background: var(--brand-soft);
    border-radius: 6px;
    padding: 1px 7px;
    font-variant-numeric: tabular-nums;
}
.hit .heading { color: var(--ink-3); font-size: 12.5px; }
.hit .snippet { color: var(--ink-2); font-size: 13.5px; margin-top: 6px; }
.search-meta { color: var(--ink-3); font-size: 13px; margin: 4px 0 16px; }
.empty {
    text-align: center;
    color: var(--ink-3);
    padding: 48px 0;
    font-size: 14px;
}

/* ---------- 文献详情 ---------- */
.paper-head h1 { font-size: 22px; margin: 0 0 10px; line-height: 1.4; }
.paper-head .authors { color: var(--ink-2); font-size: 14px; margin-bottom: 12px; }
.meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px 24px;
    font-size: 14px;
}
.meta-grid .k { color: var(--ink-3); font-size: 12.5px; }
.meta-grid .v { color: var(--ink); margin-top: 1px; word-break: break-all; }
.section h3 {
    font-size: 15px;
    font-weight: 650;
    margin: 0 0 8px;
    color: var(--ink);
}
.section .body { color: var(--ink-2); font-size: 14px; }
.abstract { text-align: justify; }
.doi { font-family: "SF Mono", Menlo, Consolas, monospace; font-size: 12.5px; }

/* ---------- 原文 PDF ---------- */
.pdf-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}
.pdf-toolbar .btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 8px;
    background: var(--brand);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
}
.pdf-toolbar .btn.ghost {
    background: transparent;
    color: var(--brand);
    border: 1px solid var(--brand);
}
.pdf-toolbar .btn:hover { opacity: .88; }
iframe.pdf-frame {
    width: 100%;
    height: 720px;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #f5f5f5;
}

/* ---------- 全文（OCR Markdown） ---------- */
details.fulltext summary {
    cursor: pointer;
    color: var(--brand);
    font-size: 14px;
    user-select: none;
}
details.fulltext summary:hover { color: var(--brand-dark); }
pre.fulltext-pre {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px 18px;
    margin: 12px 0 0;
    font-family: "SF Mono", Menlo, Consolas, "Courier New", monospace;
    font-size: 12.5px;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 600px;
    overflow: auto;
}

/* ---------- 图谱页 ---------- */
.graph-toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.graph-toolbar input {
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 14px;
    outline: none;
    width: 240px;
    font-family: inherit;
}
.graph-toolbar input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
#cy {
    width: 100%;
    height: 66vh;
    min-height: 460px;
    background: radial-gradient(circle at 30% 20%, #fbfdff 0%, #f2f6fc 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.legend { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; font-size: 12.5px; color: var(--ink-2); }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.graph-hint { color: var(--ink-3); font-size: 12.5px; margin-top: 8px; }

/* ---------- 图谱侧边栏 ---------- */
.sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 360px;
    max-width: 100vw;
    height: 100vh;
    background: var(--card);
    box-shadow: -4px 0 24px rgba(31, 39, 51, 0.14);
    z-index: 60;
    padding: 22px 22px 32px;
    overflow-y: auto;
    transform: translateX(105%);
    transition: transform 0.25s ease;
}
.sidebar.open { transform: translateX(0); }
.sidebar-close {
    position: absolute;
    top: 14px;
    right: 16px;
    border: none;
    background: #eef1f5;
    color: var(--ink-2);
    width: 30px;
    height: 30px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    line-height: 1;
}
.sidebar-close:hover { background: #e2e8f0; }
.sidebar h3 {
    margin: 0 34px 4px 0;
    font-size: 18px;
    line-height: 1.4;
}
.sidebar h4 {
    margin: 20px 0 10px;
    font-size: 14px;
    font-weight: 650;
    color: var(--ink);
    border-top: 1px solid var(--line);
    padding-top: 14px;
}
.sidebar-focus { margin-top: 12px; padding: 7px 16px; font-size: 13px; }
.rel-item {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    margin-bottom: 8px;
    font-size: 13.5px;
}
.rel-item a { font-weight: 600; }
.rel-name {
    background: var(--brand-soft);
    color: var(--brand-dark);
    border-radius: 6px;
    padding: 1px 8px;
    font-size: 12.5px;
    font-family: "SF Mono", Menlo, Consolas, monospace;
}
.edge-detail {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 14px;
}
.edge-detail .edge-endpoints { margin-bottom: 6px; line-height: 1.8; }
.paper-link {
    display: block;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 9px 12px;
    margin-bottom: 8px;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
.paper-link:hover {
    border-color: var(--brand);
    box-shadow: 0 2px 10px rgba(37, 99, 235, 0.08);
    text-decoration: none;
    color: var(--brand-dark);
}

/* ---------- 页脚 ---------- */
.footer {
    text-align: center;
    color: var(--ink-3);
    font-size: 12.5px;
    margin-top: 40px;
}

.load-more { text-align: center; margin-top: 18px; }
.muted { color: var(--ink-3); font-size: 13px; }

@media (max-width: 720px) {
    .container { padding: 0 14px 48px; }
    .card { padding: 16px; }
    .search-box { flex-direction: column; }
    .sidebar { width: 100%; }
}
