.animate-on-scroll{opacity:1!important;transform:none!important;}


:root {
    --color-success: #059669;
    --color-success-light: #10B981;
    --color-info: #2563EB;
    --color-info-50: #EFF6FF;
    --color-purple: #7C3AED;
    --color-purple-50: #F5F3FF;
    --color-danger: #E11D48;
    --color-warning: #D97706;
    --color-warning-50: #FFFBEB;
    --color-text-primary: #1C1917;
    --color-text-secondary: #57534E;
    --color-text-muted: #78716C;
    --color-border: #E7E5E4;
    --color-border-light: #F5F5F4;
    --color-bg: #F8FAFB;
    --color-bg-card: #FFFFFF;
    --shadow-card: 0 2px 8px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-card-rich: 0 4px 16px rgba(0,0,0,0.07), 0 1px 4px rgba(0,0,0,0.04), inset 0 1px 0 rgba(255,255,255,0.9);
    --radius-md: 12px;
    --radius-lg: 16px;
    --font-family: "DM Sans", -apple-system, "Noto Sans SC", "PingFang SC", sans-serif;
    --font-family-cn: "Noto Sans SC", "PingFang SC", sans-serif;
    --sidebar-width: 240px;
    --content-max: 920px;
    --content-pad: 40px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text-primary);
    line-height: 1.7;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

/* ===== Skip to content ===== */
.skip-to-content {
    position: absolute;
    left: -9999px;
    top: 4px;
    z-index: 9999;
    padding: 8px 16px;
    background: var(--color-info);
    color: #fff;
    border-radius: 6px;
    text-decoration: none;
    font-size: 13px;
}
.skip-to-content:focus { left: 4px; }

/* ===== Layout ===== */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
    position: relative;
}

/* ===== Sidebar ===== */
.sidebar-nav {
    width: var(--sidebar-width);
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background: #fff;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    padding: 24px 0 16px;
    transition: transform 280ms ease, width 280ms ease;
    z-index: 10;
}
.layout-wrapper.sidebar-collapsed .sidebar-nav {
    width: 0; min-width: 0; padding-left: 0; padding-right: 0;
    overflow: hidden; border-right: none; transform: none;
}
.layout-wrapper.sidebar-collapsed .sidebar-collapse-btn { left: 0; }

.sidebar-doc-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 0 18px 12px;
    border-bottom: 1px solid var(--color-border-light);
    margin-bottom: 8px;
}

.toc-section { padding: 4px 0; }

.toc-link {
    display: block;
    padding: 6px 18px;
    font-size: 13px;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-right: 2px solid transparent;
    transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
    line-height: 1.4;
}
.toc-link:hover { color: var(--color-info); background: var(--color-info-50); }
.toc-link.toc-active { color: var(--color-info); border-right-color: var(--color-info); background: var(--color-info-50); font-weight: 600; }
.toc-link.toc-sub { padding-left: 30px; font-size: 12px; color: var(--color-text-muted); }
.toc-link.toc-sub.toc-active { color: var(--color-info); }

.reading-progress-wrap {
    margin-top: auto;
    padding: 16px 18px 8px;
    border-top: 1px solid var(--color-border-light);
}
.reading-progress-label {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}
.reading-progress-track {
    height: 4px;
    background: var(--color-border);
    border-radius: 2px;
    overflow: hidden;
}
.reading-progress-fill {
    height: 100%;
    background: var(--color-info);
    border-radius: 2px;
    width: 0%;
    transition: width 0.1s linear;
}

/* ===== Collapse Button ===== */
.sidebar-collapse-btn {
    position: fixed;
    left: calc(var(--sidebar-width) - 12px);
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 48px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    font-size: 12px;
    color: var(--color-text-muted);
    z-index: 20;
    transition: left 280ms ease, background 150ms;
    display: flex;
    align-items: center;
    justify-content: center;
}
.sidebar-collapse-btn:hover { background: var(--color-info-50); color: var(--color-info); }
.sidebar-collapse-btn.collapsed-pos { left: 0; }

/* 移动端抽屉遮罩 */
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0; visibility: hidden;
    transition: opacity 0.28s ease, visibility 0.28s ease;
    z-index: 150;
}
.sidebar-backdrop.show { opacity: 1; visibility: visible; }
body.no-scroll { overflow: hidden; }
@media (min-width: 769px) { .sidebar-backdrop { display: none; } }

/* ===== Content Area ===== */
.content-area {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.content-inner {
    width: 100%;
    max-width: var(--content-max);
    padding: 48px var(--content-pad) 120px;
}

/* ===== Doc Header ===== */
.doc-header {
    background: linear-gradient(135deg, #059669 0%, #2563EB 50%, #7C3AED 100%);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    color: #fff;
    margin-bottom: 40px;
}
.header-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    align-items: center;
}
.meta-tag {
    background: rgba(255,255,255,0.2);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}
.doc-title {
    font-size: 32px;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 12px;
}
.doc-subtitle {
    font-size: 16px;
    opacity: 0.88;
    line-height: 1.6;
    margin-bottom: 20px;
}
.header-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.25);
}
.header-stat { font-size: 13px; opacity: 0.9; }
.header-stat strong { font-size: 20px; font-weight: 800; margin-right: 4px; }

/* ===== Chapter Label ===== */
.doc-chapter-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #A8A29E;
    padding: 36px 0 12px;
}
.doc-chapter-label::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--color-border-light);
}

/* ===== Section title ===== */
.section-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 8px;
    line-height: 1.3;
}
.section-desc {
    font-size: 14px;
    color: var(--color-text-secondary);
    margin-bottom: 24px;
    line-height: 1.7;
}

/* ===== Stat Cards ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.stat-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 20px;
    box-shadow: var(--shadow-card);
    border-top: 3px solid var(--stat-accent, #E7E5E4);
    transition: transform 150ms ease, box-shadow 150ms ease;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.stat-info    { --stat-accent: #2563EB; }
.stat-success { --stat-accent: #059669; }
.stat-warning { --stat-accent: #D97706; }
.stat-purple  { --stat-accent: #7C3AED; }
.stat-danger  { --stat-accent: #E11D48; }
.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-text-primary);
    font-variant-numeric: tabular-nums;
    line-height: 1.1;
    margin-bottom: 4px;
}
.stat-label { font-size: 13px; color: var(--color-text-secondary); }

/* ===== Mechanism Cards ===== */
.mechanism-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}
.mechanism-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
    transition: transform 150ms ease, box-shadow 150ms ease;
}
.mechanism-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card-rich); }
.mechanism-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--card-accent, var(--color-info));
}
.mechanism-card.accent-green { --card-accent: var(--color-success); }
.mechanism-card.accent-blue { --card-accent: var(--color-info); }
.mechanism-card.accent-purple { --card-accent: var(--color-purple); }
.mechanism-card.accent-amber { --card-accent: var(--color-warning); }
.mechanism-number {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}
.mechanism-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 10px;
    line-height: 1.3;
}
.mechanism-body {
    font-size: 13.5px;
    color: var(--color-text-secondary);
    line-height: 1.7;
}
.mechanism-tag {
    display: inline-block;
    margin-top: 12px;
    padding: 3px 10px;
    background: var(--color-info-50);
    color: var(--color-info);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
}
.mechanism-card.accent-green .mechanism-tag { background: #ECFDF5; color: var(--color-success); }
.mechanism-card.accent-purple .mechanism-tag { background: var(--color-purple-50); color: var(--color-purple); }
.mechanism-card.accent-amber .mechanism-tag { background: var(--color-warning-50); color: var(--color-warning); }

/* ===== Quote Block ===== */
.quote-block {
    background: linear-gradient(135deg, #F8FAFB 0%, #EEF2F6 100%);
    border-left: 3px solid var(--color-info);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 20px 24px;
    margin: 20px 0;
}
.quote-block.green { border-left-color: var(--color-success); }
.quote-block.purple { border-left-color: var(--color-purple); }
.quote-block.amber { border-left-color: var(--color-warning); }
.quote-text {
    font-size: 14.5px;
    color: var(--color-text-primary);
    line-height: 1.75;
    font-style: italic;
}
.quote-author {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 8px;
    font-style: normal;
    font-weight: 600;
}

/* ===== Insight Cards ===== */
.insight-list { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }
.insight-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-card);
    display: flex;
    gap: 16px;
}
.insight-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}
.insight-icon.green { background: #ECFDF5; }
.insight-icon.blue { background: var(--color-info-50); }
.insight-icon.purple { background: var(--color-purple-50); }
.insight-icon.amber { background: var(--color-warning-50); }
.insight-content {}
.insight-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 6px;
    line-height: 1.3;
}
.insight-body {
    font-size: 13.5px;
    color: var(--color-text-secondary);
    line-height: 1.7;
}
.insight-source {
    display: inline-block;
    margin-top: 8px;
    font-size: 11px;
    color: var(--color-text-muted);
    background: var(--color-border-light);
    padding: 2px 8px;
    border-radius: 4px;
}

/* ===== Timeline ===== */
.timeline { position: relative; padding-left: 28px; margin-bottom: 32px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 2px;
    background: linear-gradient(180deg, var(--color-success) 0%, var(--color-info) 100%);
}
.timeline-item { position: relative; margin-bottom: 20px; }
.timeline-dot {
    position: absolute;
    left: -24px;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--color-info);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--color-info);
}
.timeline-dot.green { background: var(--color-success); box-shadow: 0 0 0 2px var(--color-success); }
.timeline-dot.purple { background: var(--color-purple); box-shadow: 0 0 0 2px var(--color-purple); }
.timeline-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--color-text-muted);
    letter-spacing: 0.06em;
    margin-bottom: 4px;
}
.timeline-content {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    font-size: 13.5px;
    color: var(--color-text-secondary);
    line-height: 1.6;
    box-shadow: var(--shadow-card);
}
.timeline-title { font-size: 14px; font-weight: 700; color: var(--color-text-primary); margin-bottom: 4px; }

/* ===== Progress Bars ===== */
.progress-group { margin-bottom: 24px; }
.progress-item { margin-bottom: 14px; }
.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.progress-name { font-size: 13px; font-weight: 600; color: var(--color-text-primary); }
.progress-pct { font-size: 12px; font-weight: 700; color: var(--color-text-muted); }
.progress-track {
    height: 8px;
    background: var(--color-border);
    border-radius: 4px;
    overflow: hidden;
}
.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 1.2s cubic-bezier(.25,.46,.45,.94);
}
.bar-green { background: linear-gradient(90deg, #059669, #10B981); }
.bar-blue { background: linear-gradient(90deg, #2563EB, #3B82F6); }
.bar-purple { background: linear-gradient(90deg, #7C3AED, #8B5CF6); }
.bar-amber { background: linear-gradient(90deg, #D97706, #F59E0B); }

/* ===== Warning / Callout ===== */
.callout {
    border-radius: var(--radius-md);
    padding: 16px 18px;
    margin: 20px 0;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    font-size: 13.5px;
    line-height: 1.7;
}
.callout-icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }
.callout-body {}
.callout-title { font-weight: 700; margin-bottom: 4px; }
.callout.warning { background: var(--color-warning-50); border: 1px solid #FDE68A; color: #92400E; }
.callout.info { background: var(--color-info-50); border: 1px solid #BFDBFE; color: #1E40AF; }
.callout.success { background: #ECFDF5; border: 1px solid #A7F3D0; color: #065F46; }
.callout.purple { background: var(--color-purple-50); border: 1px solid #DDD6FE; color: #5B21B6; }

/* ===== Source Table ===== */
.source-table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 13px; }
.source-table th {
    text-align: left;
    padding: 10px 12px;
    background: #FAFAF9;
    color: var(--color-text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    border-bottom: 1px solid var(--color-border);
}
.source-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-border-light);
    color: var(--color-text-secondary);
    vertical-align: top;
    line-height: 1.5;
}
.source-table tr:hover td { background: rgba(0,0,0,0.018); }
.source-table a { color: var(--color-info); text-decoration: none; }
.source-table a:hover { text-decoration: underline; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.badge-p1 { background: #ECFDF5; color: #065F46; }
.badge-p2 { background: var(--color-info-50); color: #1E40AF; }
.badge-p3 { background: var(--color-purple-50); color: #5B21B6; }

/* ===== Divider ===== */
.section-divider { border: none; border-top: 1px solid var(--color-border-light); margin: 40px 0 0; }

/* ===== Scroll to Top ===== */
.scroll-to-top {
    position: fixed;
    bottom: 32px;
    right: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--color-info);
    color: #fff;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease, transform 150ms ease;
    box-shadow: 0 4px 12px rgba(37,99,235,0.3);
    z-index: 50;
}
.scroll-to-top.visible { opacity: 1; visibility: visible; }
.scroll-to-top:hover { transform: translateY(-2px); }

/* ===== Animate on scroll ===== */
.animate-on-scroll {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.42s ease, transform 0.42s ease;
}
.animate-on-scroll.visible { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
    .animate-on-scroll { transition: none; opacity: 1; transform: none; }
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root { --sidebar-width: 260px; }
    .sidebar-nav {
        position: fixed; top: 0; left: 0; bottom: 0;
        width: min(var(--sidebar-width), 82vw);
        height: 100%;
        transform: translateX(calc(-1 * var(--sidebar-width)));
        z-index: 200;
        box-shadow: 0 12px 32px rgba(0,0,0,0.18);
    }
    .sidebar-nav.mobile-open { transform: translateX(0); }
    .sidebar-collapse-btn,
    .sidebar-collapse-btn.collapsed-pos { left: 12px; top: 16px; transform: none; z-index: 210; }
    .content-inner { padding: 44px 16px 80px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .mechanism-grid { grid-template-columns: 1fr; }
    .doc-title { font-size: 24px; }
    .source-table { display: block; overflow-x: auto; }
}

/* 模型彩色强调标记(red/amber/blue/green)渲染为彩色文字 */
.hl-red { color: #ef4444; font-weight: 600; }
.hl-amber { color: #f59e0b; font-weight: 600; }
.hl-blue { color: #2563eb; font-weight: 600; }
.hl-green { color: #059669; font-weight: 600; }
.hl-em { font-style: italic; }
.hl-strong { font-weight: 700; }
