@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Source+Sans+3:ital,wght@0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500&display=swap');

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

:root {
    --ink: #1e293b;
    --ink-muted: #64748b;
    --ink-faint: #94a3b8;
    --paper: #f1f6fa;
    --surface: #ffffff;
    --border: #d1e2ec;
    --border-soft: #e3eef5;

    --brand: #0d7c96;
    --blue: #0a6885;
    --teal: #0d7c96;
    --cyan: #18a0bd;
    --accent: #0d7c96;
    --accent-light: #42b8d4;
    --accent-dark: #0a5c72;
    --accent-blue: #0a6885;
    --accent-soft: #e6f3f8;
    --accent-glow: rgba(13, 124, 150, 0.16);

    --gradient-primary: linear-gradient(135deg, #0a6680 0%, #0d7c96 55%, #18a0bd 100%);
    --gradient-sidebar: linear-gradient(180deg, #062432 0%, #094e63 55%, #0d7c96 100%);
    --gradient-accent: linear-gradient(90deg, #0d7c96, #42b8d4);

    --sidebar-text: #eef6fc;
    --sidebar-muted: #b4d4e8;
    --sidebar-accent: #72ddf8;

    --code-bg: #ebf3f8;
    --code-dark: #062432;

    --radius: 10px;
    --radius-sm: 7px;

    --shadow-sm: 0 1px 3px rgba(14, 58, 92, 0.05);
    --shadow-md: 0 6px 20px rgba(14, 58, 92, 0.08);

    --font-ui: 'Source Sans 3', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-serif: 'Noto Serif SC', 'Songti SC', serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;

    /* Reading comfort */
    --reading-width: 38rem;
    --reading-font: 1.075rem;
    --reading-leading: 1.9;
    --ease: cubic-bezier(0.22, 1, 0.36, 1);

    --sidebar-width: 240px;
    --sidebar-min-width: 180px;
    --sidebar-max-width: 420px;
}

html {
    font-size: 15px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    font-family: var(--font-ui);
    color: var(--ink);
    background: var(--paper);
    line-height: 1.55;
    display: flex;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
}

::selection {
    background: rgba(13, 124, 150, 0.18);
    color: var(--accent-dark);
}

a:focus-visible,
button:focus-visible {
    outline: 2px solid var(--cyan);
    outline-offset: 2px;
    border-radius: 3px;
}

/* Reading progress bar */
.read-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 1300;
    background: var(--gradient-accent);
    box-shadow: 0 0 8px rgba(13, 124, 150, 0.5);
    transition: width 0.1s linear;
    pointer-events: none;
}

/* Back to top */
.back-to-top {
    position: fixed;
    right: max(22px, env(safe-area-inset-right, 0px));
    bottom: max(22px, env(safe-area-inset-bottom, 0px));
    z-index: 1500;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: var(--gradient-primary);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(13, 124, 150, 0.32);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(12px) scale(0.9);
    transition: opacity 0.25s var(--ease), transform 0.25s var(--ease), visibility 0.25s, box-shadow 0.25s var(--ease);
}

.back-to-top-icon {
    width: 22px;
    height: 22px;
    display: block;
    transition: transform 0.2s var(--ease);
}

.back-to-top.is-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateY(0) scale(1);
}

.back-to-top:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 10px 24px rgba(13, 124, 150, 0.4);
}

.back-to-top:hover .back-to-top-icon {
    transform: translateY(-1px);
}

/* ── Sidebar ── */
.sidebar-shell {
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    width: var(--sidebar-width);
    min-width: var(--sidebar-min-width);
    max-width: var(--sidebar-max-width);
    flex-shrink: 0;
    z-index: 200;
    overflow: visible;
}

.sidebar {
    width: 100%;
    height: 100vh;
    background: var(--gradient-sidebar);
    color: var(--sidebar-text);
    overflow-y: auto;
    overflow-anchor: none;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.12) transparent;
}

.sidebar-resizer {
    position: absolute;
    top: 0;
    right: -7px;
    width: 14px;
    height: 100%;
    cursor: col-resize;
    touch-action: none;
    z-index: 5;
    background: transparent;
    transition: background 0.15s var(--ease);
}

.sidebar-resizer::after {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    border-radius: 1px;
    background: rgba(13, 124, 150, 0.25);
    transition: background 0.15s var(--ease), width 0.15s var(--ease);
    pointer-events: none;
}

.sidebar-resizer:hover::after,
.sidebar-resizer.is-dragging::after,
.sidebar-resizer:focus-visible::after {
    width: 3px;
    background: rgba(94, 202, 232, 0.55);
}

.sidebar-resizer:focus-visible {
    outline: none;
}

body.sidebar-resizing {
    cursor: col-resize;
    user-select: none;
}

body.sidebar-resizing * {
    cursor: col-resize !important;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
}

.sidebar-header {
    padding: 16px 14px 12px;
    border-bottom: 1px solid rgba(13, 124, 150, 0.12);
}

.sidebar-header h1 {
    font-family: var(--font-serif);
    font-size: 0.82rem;
    font-weight: 600;
    color: #f0f9ff;
    line-height: 1.45;
    margin-bottom: 5px;
}

.sidebar-header .sidebar-title-link {
    color: inherit;
    text-decoration: none;
    transition: color 0.15s var(--ease), opacity 0.15s var(--ease);
}

.sidebar-header .sidebar-title-link:hover {
    color: #fff;
    opacity: 0.92;
}

.sidebar-header .subtitle {
    font-size: 0.66rem;
    color: var(--sidebar-accent);
    margin-bottom: 4px;
    line-height: 1.4;
    opacity: 0.95;
}

.sidebar-header .meta {
    font-size: 0.62rem;
    color: var(--sidebar-muted);
    line-height: 1.4;
}

.sidebar ul.toc {
    list-style: none;
    padding: 8px 0 12px;
    flex: 1;
}

/* Sidebar TOC — level 1: 部分标题 */
.sidebar .toc li.nav-l1 {
    font-size: 0.78rem;
    font-weight: 700;
    color: #f4fbff;
    padding: 12px 14px 5px;
    margin-top: 8px;
    letter-spacing: 0.02em;
    line-height: 1.35;
    text-shadow: 0 1px 2px rgba(4, 24, 38, 0.35);
}

.sidebar .toc li.nav-l1:first-child,
.sidebar .toc li.nav-l2:first-child { margin-top: 0; }

/* Level 2: 分组标题（如「前言」） */
.sidebar .toc li.nav-l2 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--sidebar-accent);
    padding: 10px 14px 4px;
    margin-top: 2px;
    letter-spacing: 0.02em;
    line-height: 1.35;
}

/* Level 3: 章节链接 */
.sidebar .toc li.nav-l3 > a {
    display: block;
    padding: 6px 12px 6px 22px;
    margin: 2px 8px;
    font-size: 0.71rem;
    font-weight: 500;
    color: var(--sidebar-muted);
    text-decoration: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    border-left: 2px solid transparent;
    border-radius: 6px;
    line-height: 1.45;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    background: rgba(4, 24, 38, 0.22);
}

.sidebar .toc li.nav-l3 > a:hover {
    background: rgba(4, 24, 38, 0.42);
    color: #fff;
    border-left-color: rgba(114, 221, 248, 0.65);
}

.sidebar .toc li.nav-l1.is-current-part,
.sidebar .toc li.nav-l2.is-current-part {
    color: #fff;
    opacity: 1;
    font-weight: 700;
}

.sidebar .toc li.nav-l3 > a.is-current,
.sidebar .toc li.nav-l3 a.is-current,
#sidebar-current-chapter {
    background: rgba(4, 24, 38, 0.72);
    color: #fff;
    border-left-color: var(--sidebar-accent);
    border-left-width: 3px;
    font-weight: 600;
    box-shadow:
        inset 0 0 0 1px rgba(255, 255, 255, 0.1),
        0 2px 8px rgba(4, 24, 38, 0.28);
    scroll-margin-block: 40vh;
}

.sidebar-header .sidebar-title-link.is-current {
    color: #fff;
}

.sidebar-header .sidebar-title-link.is-current::after {
    content: "";
    display: block;
    width: 28px;
    height: 2px;
    margin-top: 6px;
    background: var(--gradient-accent);
    border-radius: 1px;
}

/* Legacy class fallback */
.sidebar li.part {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--sidebar-accent);
    padding: 11px 14px 4px;
    margin-top: 6px;
    line-height: 1.35;
}

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid rgba(13, 124, 150, 0.12);
    font-size: 0.62rem;
    color: rgba(143, 197, 200, 0.6);
    line-height: 1.5;
}

.sidebar-footer a {
    color: var(--sidebar-accent);
    text-decoration: none;
}

.sidebar-footer a:hover { opacity: 0.85; }

/* Back to paper hub (top-left) */
.back-to-hub {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    color: var(--sidebar-accent);
    text-decoration: none;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 1px solid rgba(13, 124, 150, 0.12);
    transition: background 0.2s var(--ease), color 0.2s var(--ease);
    flex-shrink: 0;
}

.back-to-hub:hover {
    background: rgba(13, 124, 150, 0.14);
    color: #fff;
}

.back-to-hub-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(13, 124, 150, 0.2);
    flex-shrink: 0;
    transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.back-to-hub-arrow svg,
.back-to-hub-arrow-icon {
    width: 16px;
    height: 16px;
    display: block;
}

.back-to-hub:hover .back-to-hub-arrow {
    background: rgba(94, 202, 232, 0.28);
    transform: translateX(-2px);
}

.sidebar > .back-to-hub {
    display: flex;
    width: 100%;
    border-left: none;
}

.sidebar > .back-to-hub:hover {
    border-left-color: transparent;
}

.back-to-hub--mobile { display: none; }

/* ── Main content ── */
.content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(13, 124, 150, 0.28) transparent;
    background:
        radial-gradient(ellipse 60% 40% at 50% 0%, rgba(13, 124, 150, 0.04), transparent),
        var(--paper);
}

.content::-webkit-scrollbar {
    width: 6px;
}

.content::-webkit-scrollbar-track {
    background: transparent;
}

.content::-webkit-scrollbar-thumb {
    background: rgba(13, 124, 150, 0.18);
    border-radius: 999px;
}

.content::-webkit-scrollbar-thumb:hover {
    background: rgba(13, 124, 150, 0.32);
}

.content:hover::-webkit-scrollbar-thumb {
    background: rgba(13, 124, 150, 0.26);
}

.content-pane {
    max-width: calc(var(--reading-width) + 88px);
    margin: 0 auto;
    padding: 20px 24px 32px;
}

/* ── Mobile nav ── */
.nav-toggle {
    display: none;
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1200;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 8px;
    background: var(--gradient-primary);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 3px 12px rgba(13, 124, 150, 0.3);
    align-items: center;
    justify-content: center;
    padding: 0;
}

.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
    display: block;
    width: 16px;
    height: 2px;
    background: currentColor;
    border-radius: 1px;
    transition: transform 0.2s var(--ease);
}

.nav-toggle-icon { position: relative; }

.nav-toggle-icon::before,
.nav-toggle-icon::after {
    content: "";
    position: absolute;
    left: 0;
}

.nav-toggle-icon::before { top: -5px; }
.nav-toggle-icon::after { top: 5px; }

body.nav-open .nav-toggle-icon { background: transparent; }
body.nav-open .nav-toggle-icon::before { top: 0; transform: rotate(45deg); }
body.nav-open .nav-toggle-icon::after { top: 0; transform: rotate(-45deg); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(12, 25, 41, 0.5);
    backdrop-filter: blur(3px);
}

body.nav-open .sidebar-overlay { display: block; }

.content-topbar {
    display: none;
    height: 44px;
    flex-shrink: 0;
}

/* ── Welcome page ── */
.welcome h2 {
    font-family: var(--font-serif);
    font-size: 1.45rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--ink);
    line-height: 1.35;
}

.welcome h3 {
    font-size: 0.85rem;
    color: var(--ink-muted);
    font-weight: 400;
    font-style: italic;
    margin-bottom: 16px;
    line-height: 1.45;
}

.welcome .lead-block {
    margin-bottom: 20px;
    padding: 14px 16px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-left: 3px solid var(--blue);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.welcome .lead {
    font-family: var(--font-serif);
    font-size: 0.92rem;
    line-height: 1.7;
    color: var(--ink);
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0;
}

.welcome .lead-meta {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--ink-muted);
    margin: 10px 0 0;
}

.welcome .lead-meta a,
.welcome .lead a {
    color: var(--blue);
    text-decoration: none;
    border-bottom: 1px solid rgba(13, 124, 150, 0.3);
}

.welcome .lead-meta a:hover,
.welcome .lead a:hover { border-bottom-color: var(--blue); }

.toc-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.toc-card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 14px 12px;
    text-align: center;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.toc-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(13, 124, 150, 0.08);
    border-color: rgba(13, 124, 150, 0.2);
}

.toc-card h4 {
    font-family: var(--font-serif);
    font-size: 0.88rem;
    font-weight: 600;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.toc-card p {
    font-size: 0.78rem;
    color: var(--ink-muted);
    margin-bottom: 8px;
    line-height: 1.4;
}

.toc-card .chapters {
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--accent-dark);
    background: var(--accent-soft);
    padding: 2px 10px;
    border-radius: 999px;
    display: inline-block;
}

.welcome .note {
    font-size: 0.78rem;
    color: var(--ink-muted);
    line-height: 1.5;
}

.welcome .note a {
    color: var(--blue);
    text-decoration: none;
}

.welcome .note a:hover { text-decoration: underline; }

/* ── Article typography ── */
.article {
    font-family: var(--font-serif);
    font-size: var(--reading-font);
    line-height: var(--reading-leading);
    color: #273449;
    letter-spacing: 0.012em;
}

.article h1 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 6px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
    line-height: 1.4;
}

.article .article-meta {
    font-family: var(--font-ui);
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.chapter-header {
    margin-bottom: 18px;
    padding: 0 0 14px;
    border-bottom: 1px solid var(--border-soft);
}

.chapter-title-zh {
    font-size: 1.4rem;
    font-weight: 600;
    margin: 4px 0 6px;
    line-height: 1.35;
    color: var(--ink);
}

.chapter-title-en {
    font-family: var(--font-ui);
    font-size: 0.82rem;
    color: var(--ink-muted);
    font-style: italic;
    margin: 0;
    line-height: 1.45;
}

.article h2 {
    font-size: 1.16rem;
    font-weight: 600;
    margin: 2em 0 0.7em;
    padding: 0 0 6px;
    color: var(--ink);
    border-bottom: 2px solid var(--accent-soft);
    position: relative;
    line-height: 1.45;
    scroll-margin-top: 64px;
}

.article h2::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 38px;
    height: 2px;
    background: var(--gradient-accent);
}

.article h3 {
    font-size: 1.04rem;
    font-weight: 600;
    margin: 1.7em 0 0.6em;
    color: var(--accent-dark);
    border-left: 3px solid var(--cyan);
    padding-left: 11px;
    line-height: 1.5;
    scroll-margin-top: 64px;
}

.article h4 {
    font-size: 0.98rem;
    font-weight: 600;
    margin: 1.4em 0 0.5em;
    color: var(--ink);
}

.article p {
    margin-bottom: 1em;
    text-align: justify;
    text-justify: inter-character;
}

.article ul, .article ol {
    margin: 0.8em 0 1.1em;
    padding-left: 1.5em;
}

.article li {
    margin-bottom: 0.45em;
    line-height: var(--reading-leading);
    padding-left: 0.2em;
}

.article li::marker {
    color: var(--teal);
    font-weight: 600;
}

.article blockquote {
    border-left: 3px solid var(--cyan);
    padding: 12px 18px;
    margin: 1.4em 0;
    background: linear-gradient(90deg, var(--accent-soft) 0%, rgba(236, 254, 255, 0) 100%);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--ink-muted);
    line-height: 1.75;
    font-size: 0.96em;
}

.article table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
    font-family: var(--font-ui);
    font-size: 0.8rem;
    line-height: 1.45;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.article th {
    background: linear-gradient(135deg, #e0f2fe 0%, #ccfbf1 100%);
    color: var(--accent-dark);
    font-weight: 600;
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.article td {
    padding: 6px 10px;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
}

.article tr:last-child td { border-bottom: none; }
.article tr:hover td { background: var(--paper); }

.article code {
    font-family: var(--font-mono);
    background: var(--code-bg);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.82em;
    color: var(--accent-blue);
}

.article pre {
    font-family: var(--font-mono);
    background: var(--code-dark);
    color: #c6ede0;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 14px 0;
    font-size: 0.78rem;
    line-height: 1.55;
    border-left: 3px solid var(--cyan);
}

.article pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.article .ref {
    font-family: var(--font-ui);
    font-size: 0.74rem;
    color: var(--ink-muted);
    padding-left: 2em;
    text-indent: -2em;
    margin-bottom: 4px;
    line-height: 1.5;
}

/* References — collapsed by default; title matches h2, content only when open */
.article .references-panel {
    margin: 0;
    background: none;
    border: none;
    border-radius: 0;
    overflow: visible;
}

.article .references-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    font-family: inherit;
    font-size: 1.16rem;
    font-weight: 600;
    margin: 2em 0 0.7em;
    padding: 0 0 6px;
    color: var(--ink);
    border-bottom: 2px solid var(--accent-soft);
    position: relative;
    line-height: 1.45;
    scroll-margin-top: 64px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: color 0.15s var(--ease);
}

.article .references-summary::-webkit-details-marker { display: none; }

.article .references-summary::marker {
    content: "";
    display: none;
}

.article .references-summary::before {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 38px;
    height: 2px;
    background: var(--gradient-accent);
}

.article .references-summary::after {
    content: "";
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--accent);
    border-bottom: 2px solid var(--accent);
    transform: rotate(45deg);
    margin-top: -3px;
    transition: transform 0.2s var(--ease);
}

.article .references-panel[open] .references-summary::after {
    transform: rotate(-135deg);
    margin-top: 3px;
}

.article .references-summary:hover {
    color: var(--accent-dark);
}

.article .references-panel .references {
    margin-top: 0;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    counter-reset: ref;
}

.article .references-panel[open] .references-summary {
    margin-bottom: 0.7em;
}

.references {
    margin-top: 1.4em;
    padding: 16px 20px;
    background: linear-gradient(180deg, #fbfdff 0%, var(--surface) 100%);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    counter-reset: ref;
}

.references p {
    font-family: var(--font-ui);
    font-size: 0.76rem;
    color: var(--ink-muted);
    line-height: 1.6;
    margin: 0 0 0.5em;
    padding-left: 1.6em;
    text-indent: -1.6em;
    text-align: left;
    max-width: none;
    word-break: break-word;
}

.references p:last-child { margin-bottom: 0; }

.references p:hover { color: var(--ink); }

.article hr {
    border: none;
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 24px 0;
}

.article a {
    color: var(--blue);
    text-decoration: underline;
    text-decoration-color: rgba(13, 124, 150, 0.3);
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: color 0.15s, text-decoration-color 0.15s;
}

.article a:hover {
    color: var(--accent-dark);
    text-decoration-color: var(--teal);
}

.article strong { font-weight: 600; color: #1a2433; }
.article em { font-style: italic; color: var(--ink-muted); }

/* ── Figures ── */
.paper-figure {
    margin: 1.8em 0;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.25s var(--ease), transform 0.25s var(--ease);
}

.paper-figure:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.paper-figure img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.paper-figure figcaption {
    font-family: var(--font-ui);
    margin-top: 10px;
    padding-left: 12px;
    font-size: 0.78rem;
    color: var(--ink-muted);
    line-height: 1.55;
    text-align: left;
    border-left: 2px solid var(--accent-light);
}

.figure-missing {
    font-family: var(--font-ui);
    color: #0369a1;
    background: #e0f2fe;
    border: 1px dashed var(--blue);
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
}

/* ── Section nav ── */
.section-nav {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 0;
    margin: 18px 0;
    border-top: 1px solid var(--border-soft);
    border-bottom: 1px solid var(--border-soft);
    font-family: var(--font-ui);
    font-size: 0.78rem;
}

.section-nav a,
.section-nav-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-dark);
    text-decoration: none;
    padding: 6px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    transition: all 0.2s;
}

.section-nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
}

.section-nav-spacer {
    display: block;
}

.section-nav a:hover,
.section-nav-link:hover {
    background: var(--gradient-primary);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 3px 10px var(--accent-glow);
}

.section-nav-link--prev .section-nav-icon {
    margin-left: -2px;
}

.section-nav-link--next .section-nav-icon {
    margin-right: -2px;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
    .toc-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 960px) {
    html { font-size: 14px; }

    .nav-toggle { display: inline-flex; }

    .content-topbar {
        display: flex;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 48px;
        z-index: 1150;
        padding: 0 12px 0 56px;
        background: rgba(242, 248, 248, 0.95);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border-soft);
    }

    .sidebar > .back-to-hub { display: none; }

    .back-to-hub--mobile {
        display: inline-flex;
        color: var(--accent-dark);
        border-bottom: none;
        padding: 6px 0;
        font-size: 0.74rem;
    }

    .back-to-hub--mobile:hover {
        background: transparent;
        color: var(--accent);
    }

    .back-to-hub--mobile .back-to-hub-arrow {
        background: var(--accent-soft);
        color: var(--accent);
    }

    .back-to-hub--mobile:hover .back-to-hub-arrow {
        background: rgba(13, 124, 150, 0.18);
    }

    .sidebar-shell {
        width: auto !important;
        min-width: 0;
        max-width: none;
        height: 0;
        flex: 0 0 auto;
        position: static;
    }

    .sidebar-resizer { display: none; }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        z-index: 1100;
        width: min(260px, 85vw);
        min-width: 0;
        height: 100vh;
        height: 100dvh;
        transform: translateX(-105%);
        transition: transform 0.25s var(--ease);
        box-shadow: 4px 0 24px rgba(12, 25, 41, 0.25);
    }

    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open { overflow: hidden; }

    .content {
        padding-top: 56px;
    }

    .content-pane {
        max-width: none;
        padding: 0 16px 24px;
    }

    .section-nav { flex-wrap: wrap; gap: 8px; }
    .section-nav a,
    .section-nav-link { flex: 1 1 auto; justify-content: center; min-width: 100px; }

    .chapter-title-zh { font-size: 1.2rem; }
    .article h2 { font-size: 1.02rem; }

    .article table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

@media (max-width: 640px) {
    .sidebar-header { padding: 14px 12px 10px; }
    .sidebar .toc li.nav-l3 > a { padding: 6px 12px 6px 18px; }
    .content { padding-top: 52px; }
    .content-pane { padding: 0 14px 20px; }
    .welcome h2 { font-size: 1.2rem; }
    .toc-grid { grid-template-columns: 1fr; }
    .paper-figure { margin: 14px 0; padding: 8px; }
}

@media (min-width: 1400px) {
    .content-pane {
        max-width: calc(var(--reading-width) + 100px);
    }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .toc-card, .section-nav a, .section-nav-link, .sidebar { transition: none; }
}
