:root {
  color-scheme: light;
  --paper: #f4f1e8;
  --paper-deep: #e8e2d4;
  --ink: #1d201d;
  --muted: #6f706a;
  --line: #cbc5b8;
  --accent: #c54b30;
  --note-brown: #8b4513;
  --note-blue: #1d4ed8;
  --accent-soft: #ead0c7;
  --card: rgba(255, 253, 247, 0.72);
  --shadow: 0 24px 70px rgba(41, 34, 25, 0.12);
  --code-keyword: #963f63;
  --code-definition: #285b87;
  --code-function: #316f8b;
  --code-string: #3b704f;
  --code-docstring: #58724b;
  --code-comment: #737a70;
  --code-number: #945920;
  --code-decorator: #80569a;
  --code-variable: #80569a;
  --code-key: #285b87;
  --code-preprocessor: #80569a;
  --code-option: #945920;
}

[data-theme="dark"] {
  color-scheme: dark;
  --paper: #191b19;
  --paper-deep: #242724;
  --ink: #eeede6;
  --muted: #a9aaa3;
  --line: #3a3d39;
  --accent: #eb765a;
  --note-brown: #d9a46f;
  --note-blue: #93c5fd;
  --accent-soft: #55342c;
  --card: rgba(36, 39, 36, 0.75);
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.34);
  --code-keyword: #e997b9;
  --code-definition: #9cc9ec;
  --code-function: #8fc3d7;
  --code-string: #a6d59d;
  --code-docstring: #b4ce9d;
  --code-comment: #a1aaa0;
  --code-number: #e9bd7e;
  --code-decorator: #caa6e4;
  --code-variable: #caa6e4;
  --code-key: #9cc9ec;
  --code-preprocessor: #caa6e4;
  --code-option: #e9bd7e;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

html.restoring-scroll { scroll-behavior: auto !important; }

html.dialog-open { overflow: hidden; }

html.dialog-open body {
  position: fixed;
  right: 0;
  left: 0;
  width: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 83% 7%, rgba(197, 75, 48, 0.08), transparent 27rem),
    linear-gradient(90deg, transparent 49.8%, rgba(80, 73, 64, 0.035) 50%, transparent 50.2%),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.65;
  transition: background-color 180ms ease, color 180ms ease;
}

button, input, select { font: inherit; }
button, select { cursor: pointer; }
a { color: inherit; }

.site-header {
  width: min(1180px, calc(100% - 40px));
  height: 82px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 11px; font-weight: 700; text-decoration: none; letter-spacing: -0.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: var(--paper); background: var(--ink); font-family: Georgia, serif; font-style: italic; }
.header-actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 0.78rem; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: transparent; transition: transform 160ms ease, background 160ms ease; }
.icon-button:hover { transform: rotate(18deg); background: var(--paper-deep); }

main { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.hero { min-height: 545px; padding: 95px 0 70px; position: relative; display: grid; align-content: center; border-bottom: 1px solid var(--line); }
.eyebrow, .section-index { color: var(--accent); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.16em; }
h1 { max-width: 900px; margin: 17px 0 24px; font-family: Georgia, "Songti SC", "STSong", serif; font-size: clamp(3.2rem, 7.4vw, 6.8rem); font-weight: 400; letter-spacing: -0.062em; line-height: 0.98; }
h1 em { color: var(--accent); font-weight: 400; }
.hero-copy { max-width: 520px; margin: 0; color: var(--muted); font-size: 1.08rem; }
.stats { position: absolute; right: 0; bottom: 76px; display: flex; gap: 42px; margin: 0; }
.stats div { min-width: 88px; }
.stats dt { font-family: Georgia, serif; font-size: 2.2rem; line-height: 1; }
.stats dd { margin: 6px 0 0; color: var(--muted); font-size: 0.76rem; }

.library { padding: 72px 0 110px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; }
.section-heading h2 { margin: 5px 0 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(2.2rem, 4vw, 3.6rem); font-weight: 400; letter-spacing: -0.045em; }
.section-index { margin: 0; }
.search { width: min(430px, 44vw); display: flex; align-items: center; gap: 9px; padding: 11px 14px; border-bottom: 1px solid var(--ink); }
.search input { min-width: 0; flex: 1; border: 0; outline: 0; color: var(--ink); background: transparent; }
.search input::placeholder { color: var(--muted); }
kbd { padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 0.72rem; }

.filters { margin: 38px 0 0; padding: 18px 0 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.filter-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.filter-help { margin: 0; color: var(--muted); font-size: 0.78rem; }
.filter-actions { display: flex; align-items: center; gap: 20px; }
.tag-key-toggle { padding: 2px 0; border: 0; border-bottom: 1px solid currentColor; color: var(--ink); background: transparent; font-size: 0.76rem; white-space: nowrap; }
.tag-key-toggle:hover { color: var(--accent); }
.reset-filters { padding: 2px 0; border: 0; border-bottom: 1px solid currentColor; color: var(--accent); background: transparent; font-size: 0.76rem; white-space: nowrap; }
.reset-filters:disabled { color: var(--muted); opacity: 0.5; cursor: default; }
.tag-groups { display: grid; gap: 15px; }
.tag-group { display: grid; grid-template-columns: 90px minmax(0, 1fr); gap: 14px; align-items: start; }
.tag-group-label { padding-top: 8px; color: var(--ink); font-size: 0.76rem; font-weight: 650; }
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; }
.tag-button { padding: 6px 12px; border: 1px solid var(--line); border-radius: 99px; color: var(--muted); background: transparent; font-size: 0.78rem; transition: 140ms ease; }
.tag-button.key-visible { border-radius: 12px; text-align: left; line-height: 1.35; }
.tag-key { display: block; margin-top: 2px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.66rem; opacity: 0.8; }
.tag-count { margin-left: 5px; opacity: 0.7; font-size: 0.72rem; }
.tag-button:hover, .tag-button.active { border-color: var(--ink); color: var(--paper); background: var(--ink); }
.tag-authoring[hidden] { display: none; }
.tag-authoring { margin: 18px 0 0 104px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--card); }
.tag-authoring p { margin: 0; color: var(--muted); font-size: 0.76rem; }
.tag-authoring code { color: var(--ink); }
.tag-authoring-row { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.tag-authoring-row label { flex: 0 0 auto; color: var(--ink); font-size: 0.76rem; font-weight: 650; }
.tag-authoring-row input { min-width: 0; flex: 1; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: var(--paper); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.76rem; cursor: text; }
.copy-tags { flex: 0 0 auto; padding: 8px 12px; border: 1px solid var(--ink); border-radius: 6px; color: var(--paper); background: var(--ink); font-size: 0.76rem; }
.copy-tags:disabled { border-color: var(--line); color: var(--muted); background: transparent; cursor: default; }
.tag-authoring .tag-authoring-status { min-height: 1.2em; margin-top: 8px; color: var(--accent); }
button:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.search:focus-within { box-shadow: 0 2px 0 var(--accent); }
.sort-control { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.76rem; white-space: nowrap; }
.sort-control select { border: 0; outline: 0; color: var(--ink); background: transparent; font-weight: 650; }
.result-count { margin: 24px 0 16px; color: var(--muted); font-size: 0.76rem; }

.paper-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-top: 1px solid var(--line); }
.paper-card { min-height: 330px; padding: 30px; position: relative; display: flex; flex-direction: column; border-bottom: 1px solid var(--line); transition: background 160ms ease; }
.paper-card:nth-child(odd) { border-right: 1px solid var(--line); }
.paper-card:hover { background: var(--card); }
.card-button { width: 100%; flex: 1; padding: 0; display: flex; flex-direction: column; text-align: left; border: 0; color: inherit; background: transparent; }
.card-top { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 0.72rem; }
.status { color: var(--accent); font-weight: 700; letter-spacing: 0.04em; }
.paper-card h3 { margin: 29px 0 12px; font-family: Georgia, "Songti SC", serif; font-size: clamp(1.55rem, 2.5vw, 2.2rem); font-weight: 400; letter-spacing: -0.035em; line-height: 1.2; }
.authors { margin: 0 0 20px; color: var(--muted); font-size: 0.82rem; }
.one-liner { max-width: 90%; margin: 0; color: var(--ink); font-size: 0.92rem; }
.one-liner .katex { font-size: 1.05em; }
.card-bottom { width: 100%; margin-top: auto; padding-top: 25px; display: flex; align-items: end; justify-content: space-between; }
.card-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.card-tag { padding: 0; border: 0; text-align: left; color: var(--muted); background: transparent; font-size: 0.7rem; }
.card-tag:hover { color: var(--accent); text-decoration: underline; }
.arrow { width: 36px; height: 36px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: inherit; background: transparent; transition: 160ms ease; }
.paper-card:hover .arrow { transform: translate(2px, -2px); border-color: var(--accent); color: var(--accent); }

.empty-state { padding: 80px 20px; text-align: center; border-bottom: 1px solid var(--line); }
.empty-state span { font-family: Georgia, serif; font-size: 3rem; color: var(--accent); }
.empty-state h3 { margin: 12px 0 4px; font-family: Georgia, serif; font-size: 1.7rem; }
.empty-state p { margin: 0 0 18px; color: var(--muted); }
.empty-state button { padding: 8px 15px; border: 1px solid var(--ink); border-radius: 99px; color: var(--paper); background: var(--ink); }

footer { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 28px 0 40px; display: flex; gap: 18px; flex-wrap: wrap; justify-content: space-between; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.74rem; }
.footer-meta { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.visit-counter { display: inline-flex; opacity: 0.82; transition: opacity 150ms ease; }
.visit-counter:hover { opacity: 1; }
.visit-counter img { display: block; height: 20px; }

dialog { width: min(820px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 0; overflow-y: auto; overscroll-behavior: contain; border: 0; border-radius: 2px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(20, 19, 17, 0.65); backdrop-filter: blur(5px); }
.paper-detail { min-height: 70vh; padding: clamp(34px, 7vw, 76px); position: relative; }
.dialog-close { position: absolute; top: 22px; right: 24px; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; color: var(--ink); background: transparent; font-size: 1.45rem; line-height: 1; }
.detail-kicker { margin: 0 0 16px; color: var(--accent); font-size: 0.74rem; font-weight: 750; letter-spacing: 0.12em; }
.paper-detail h2 { max-width: 670px; margin: 0 0 18px; font-family: Georgia, "Songti SC", serif; font-size: clamp(2.2rem, 5vw, 4rem); font-weight: 400; line-height: 1.08; letter-spacing: -0.045em; }
.detail-full-title { max-width: 720px; margin: -4px 0 22px; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 20px; padding-bottom: 30px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 0.78rem; }
.detail-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.detail-summary { margin: 34px 0; padding: 20px 23px; border-left: 3px solid var(--accent); background: var(--accent-soft); font-family: Georgia, "Songti SC", serif; font-size: 1.15rem; }
.note-outline { margin: 28px 0 36px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper-deep); }
.note-outline summary { display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 12px 20px; list-style: none; cursor: pointer; }
.note-outline summary::-webkit-details-marker { display: none; }
.note-outline-title { flex: 1; font-size: 0.9rem; font-weight: 700; letter-spacing: 0.03em; }
.note-outline-count { color: var(--muted); font-size: 0.76rem; }
.note-outline summary::after { content: "⌄"; color: var(--accent); font-size: 1.1rem; line-height: 1; transition: transform 160ms ease; }
.note-outline[open] summary::after { transform: rotate(180deg); }
.note-outline-list { display: grid; grid-template-columns: 1fr; gap: 2px; max-height: 340px; margin: 0; padding: 8px 16px 16px; overflow-y: auto; border-top: 1px solid var(--line); list-style: none; }
.note-outline-list li { min-width: 0; }
.note-outline-list button { display: block; width: 100%; padding: 8px 10px; border: 0; border-radius: 4px; color: var(--ink); background: transparent; font: inherit; font-size: 0.82rem; line-height: 1.35; text-align: left; cursor: pointer; }
.note-outline-list button:hover, .note-outline-list button:focus-visible { color: var(--accent); background: var(--accent-soft); }
.note-outline-h2 button { font-weight: 700; }
.note-outline-h3 button { padding-left: 18px; }
.note-outline-h4 button, .note-outline-h5 button, .note-outline-h6 button { padding-left: 26px; color: var(--muted); font-size: 0.76rem; }
.detail-body h2 { margin: 42px 0 13px; padding-top: 15px; border-top: 1px solid var(--line); font-family: Georgia, "Songti SC", serif; font-size: 1.55rem; letter-spacing: -0.02em; }
.detail-body h3 { margin: 27px 0 8px; color: var(--accent); font-size: 1rem; }
.detail-body h4, .detail-body h5, .detail-body h6 { margin: 22px 0 8px; line-height: 1.45; }
.detail-body h5, .detail-body h6 { color: var(--muted); font-size: 0.94rem; }
.detail-body p, .detail-body li { color: var(--ink); font-size: 0.94rem; }
.detail-body .note-color-brown { color: var(--note-brown); }
.detail-body .note-color-blue { color: var(--note-blue); }
.detail-body ul, .detail-body ol { padding-left: 1.8rem; }
.detail-body li + li { margin-top: 0.7rem; }
.detail-body blockquote { margin: 24px 0; padding: 4px 0 4px 18px; border-left: 2px solid var(--accent); color: var(--muted); }
.detail-body blockquote blockquote { margin: 12px 0; }
.detail-body blockquote > :first-child { margin-top: 0; }
.detail-body blockquote > :last-child { margin-bottom: 0; }
.detail-body .markdown-alert { margin: 22px 0; padding: 14px 18px; border: 1px solid var(--alert-border); border-left: 3px solid var(--alert-accent); border-radius: 7px; background: var(--alert-fill); }
.detail-body .markdown-alert-note { --alert-accent: #346b9d; --alert-border: #bdcee0; --alert-fill: rgba(61, 121, 179, 0.07); --alert-icon: "ⓘ"; }
.detail-body .markdown-alert-tip { --alert-accent: #357451; --alert-border: #bfd4c5; --alert-fill: rgba(61, 136, 90, 0.07); --alert-icon: "✦"; }
.detail-body .markdown-alert-important { --alert-accent: #7853a1; --alert-border: #d0c3df; --alert-fill: rgba(127, 86, 171, 0.07); --alert-icon: "◆"; }
.detail-body .markdown-alert-warning { --alert-accent: #9a6b19; --alert-border: #dfd0a8; --alert-fill: rgba(176, 127, 30, 0.08); --alert-icon: "⚠"; }
.detail-body .markdown-alert-caution { --alert-accent: #b44743; --alert-border: #e0c0bb; --alert-fill: rgba(183, 75, 65, 0.07); --alert-icon: "⊗"; }
[data-theme="dark"] .detail-body .markdown-alert-note { --alert-accent: #88b9e5; --alert-border: #40556c; --alert-fill: rgba(70, 133, 191, 0.1); }
[data-theme="dark"] .detail-body .markdown-alert-tip { --alert-accent: #8ecba6; --alert-border: #3c5948; --alert-fill: rgba(80, 160, 108, 0.1); }
[data-theme="dark"] .detail-body .markdown-alert-important { --alert-accent: #c3a2e6; --alert-border: #594869; --alert-fill: rgba(144, 100, 192, 0.1); }
[data-theme="dark"] .detail-body .markdown-alert-warning { --alert-accent: #e5c37a; --alert-border: #645638; --alert-fill: rgba(180, 135, 48, 0.11); }
[data-theme="dark"] .detail-body .markdown-alert-caution { --alert-accent: #e9a19a; --alert-border: #674541; --alert-fill: rgba(188, 83, 76, 0.1); }
.detail-body .markdown-alert-title { display: flex; align-items: center; gap: 0.5em; margin-bottom: 9px; color: var(--alert-accent); font-size: 0.88rem; font-weight: 700; line-height: 1.3; letter-spacing: 0.02em; }
.detail-body .markdown-alert-title::before { content: var(--alert-icon); font-size: 1.1em; line-height: 1; }
.detail-body .markdown-alert-body > :first-child { margin-top: 0; }
.detail-body .markdown-alert-body > :last-child { margin-bottom: 0; }
.detail-body li > p { margin: 10px 0 14px 1.5rem; line-height: 1.7; }
.detail-body li > p:last-child { margin-bottom: 0; }
.detail-body hr { margin: 24px 0; border: 0; border-top: 1px solid var(--line); }
.detail-body code { padding: 2px 5px; border-radius: 4px; background: var(--paper-deep); font-size: 0.88em; }
.detail-body pre.code-block { max-width: 100%; margin: 18px 0; padding: 14px; overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--paper-deep); font-size: 0.86rem; line-height: 1.55; tab-size: 4; }
.detail-body pre.code-highlighted { position: relative; padding-top: 34px; }
.detail-body pre.code-highlighted::before { content: attr(data-language); position: absolute; top: 8px; right: 13px; color: var(--muted); font-family: Inter, ui-sans-serif, sans-serif; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; }
.detail-body pre.code-block code { padding: 0; background: transparent; font-size: inherit; }
.mermaid-figure { max-width: 100%; margin: 26px 0; padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); }
.mermaid-diagram { max-width: 100%; overflow-x: auto; text-align: center; font-size: 0.88rem; }
.mermaid-diagram > svg { display: block; width: 100%; height: auto; margin: 0 auto; }
.mermaid-figure.is-expanded .mermaid-diagram > svg { width: var(--mermaid-width, 100%); max-width: none !important; }
.mermaid-expand { margin-top: 12px; padding: 3px 0; border: 0; border-bottom: 1px solid var(--line); color: var(--muted); background: transparent; font: inherit; font-size: 0.78rem; cursor: pointer; }
.mermaid-source { margin-top: 12px; color: var(--muted); font-size: 0.78rem; }
.mermaid-source summary { cursor: pointer; }
.mermaid-source .code-block { margin-bottom: 0; text-align: left; }
.mermaid-error { padding: 12px 0; color: var(--muted); text-align: left; }
.detail-body .syntax-keyword { color: var(--code-keyword); font-weight: 600; }
.detail-body .syntax-definition { color: var(--code-definition); font-weight: 600; }
.detail-body .syntax-function { color: var(--code-function); }
.detail-body .syntax-string { color: var(--code-string); }
.detail-body .syntax-docstring { color: var(--code-docstring); font-style: italic; }
.detail-body .syntax-comment { color: var(--code-comment); font-style: italic; }
.detail-body .syntax-number, .detail-body .syntax-constant { color: var(--code-number); }
.detail-body .syntax-decorator { color: var(--code-decorator); }
.detail-body .syntax-variable { color: var(--code-variable); }
.detail-body .syntax-key { color: var(--code-key); font-weight: 600; }
.detail-body .syntax-preprocessor { color: var(--code-preprocessor); font-weight: 600; }
.detail-body .syntax-option { color: var(--code-option); }
.detail-body .math-block { max-width: 100%; margin: 26px 0; padding: 15px 0; overflow-x: auto; overflow-y: hidden; text-align: center; }
.detail-body .katex-display { margin: 0; overflow-x: auto; overflow-y: hidden; }
.detail-body .katex { font-size: 1.08em; }
.detail-body .table-scroll { max-width: 100%; margin: 26px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }
.detail-body table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 0.86rem; line-height: 1.5; }
.detail-body th, .detail-body td { padding: 11px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); vertical-align: top; }
.detail-body th { background: var(--paper-deep); font-weight: 700; white-space: nowrap; }
.detail-body th:last-child, .detail-body td:last-child { border-right: 0; }
.detail-body tbody tr:last-child td { border-bottom: 0; }
.detail-body .align-left { text-align: left; }
.detail-body .align-center { text-align: center; }
.detail-body .align-right { text-align: right; }
.paper-figure { margin: 30px 0; }
.paper-image-button { display: block; width: 100%; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; background: var(--paper-deep); cursor: zoom-in; }
.paper-image-button img { display: block; width: 100%; height: auto; max-height: 620px; object-fit: contain; transition: transform 180ms ease; }
.paper-image-button:hover img { transform: scale(1.012); }
.paper-figure figcaption { margin-top: 10px; color: var(--muted); font-size: 0.78rem; line-height: 1.55; text-align: center; }
.tweet-embed { width: min(100%, 550px); margin: 26px auto; }
.tweet-embed iframe { display: block; width: 100%; height: 650px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper-deep); }
.tweet-embed figcaption { margin-top: 8px; color: var(--muted); font-size: 0.78rem; text-align: center; }
.tweet-embed figcaption a { color: var(--accent); }
.image-dialog { width: min(1280px, calc(100% - 28px)); max-height: calc(100vh - 28px); padding: 0; overflow: visible; background: #111; }
.image-dialog::backdrop { background: rgba(10, 10, 10, 0.88); backdrop-filter: blur(6px); }
.image-dialog figure { max-height: calc(100vh - 28px); margin: 0; overflow: auto; overscroll-behavior: contain; }
.image-dialog img { display: block; width: 100%; height: auto; max-height: calc(100vh - 90px); object-fit: contain; }
.image-dialog figcaption { padding: 14px 54px 16px 20px; color: #f4f1e8; font-size: 0.78rem; line-height: 1.5; }
.image-dialog-close { z-index: 1; top: 14px; right: 14px; color: #f4f1e8; border-color: rgba(255,255,255,0.42); background: rgba(0,0,0,0.48); }
.math-error { padding: 14px; overflow-x: auto; border: 1px solid var(--accent); color: var(--accent); background: var(--paper-deep); }
.paper-link { display: inline-flex; margin-top: 40px; padding: 10px 16px; border: 1px solid var(--ink); border-radius: 99px; text-decoration: none; font-size: 0.8rem; }
.paper-link:hover { color: var(--paper); background: var(--ink); }

@media (max-width: 760px) {
  .site-header, main, footer { width: min(100% - 28px, 1180px); }
  .last-updated { display: none; }
  .hero { min-height: 520px; padding: 70px 0 130px; }
  h1 { font-size: clamp(3rem, 14vw, 4.8rem); }
  .stats { left: 0; right: auto; bottom: 40px; gap: 25px; }
  .stats div { min-width: 0; }
  .stats dt { font-size: 1.8rem; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .search { width: 100%; }
  .filter-toolbar { align-items: flex-start; flex-direction: column; gap: 14px; }
  .filter-actions { width: 100%; justify-content: space-between; }
  .tag-authoring { margin-left: 0; }
  .tag-authoring-row { align-items: stretch; flex-wrap: wrap; }
  .tag-authoring-row label { width: 100%; }
  .tag-authoring-row input { flex-basis: 100%; }
  .tag-group { grid-template-columns: 1fr; gap: 8px; }
  .tag-group-label { padding-top: 0; }
  .paper-grid { grid-template-columns: 1fr; }
  .paper-card:nth-child(odd) { border-right: 0; }
  .paper-card { min-height: 300px; padding: 26px 8px; }
  footer { gap: 14px; flex-direction: column; }
  footer p { margin: 0; }
  .paper-detail { padding: 56px 24px 40px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
