:root,
html[data-theme="sepia"] {
    color-scheme: only light;
    --background: #f5f0e6;
    --surface: #faf7f0;
    --surface-soft: #ece5d7;
    --text: #2e2923;
    --text-secondary: #5c5347;
    --muted: #83796b;
    --line: #e2d8c7;
    --accent: #8f3d28;
    --accent-soft: rgba(143, 61, 40, 0.1);
    --shadow: 0 12px 36px rgba(42, 32, 20, 0.08);
    --surface-translucent: rgba(250, 247, 240, 0.88);
    --toolbar-translucent: rgba(245, 240, 230, 0.9);
    --note-bg: rgba(236, 229, 215, 0.42);
    --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    --font-symbol: "Segoe UI Symbol", "Apple Symbols", "Noto Sans Symbols 2", "Noto Sans Symbols", sans-serif;
    --font-body-en: "Literata", "Charter", "Georgia", serif;
    --font-body-zh: "Literata Mixed", "LXGW WenKai GB", "Kaiti SC", "STKaiti", "PingFang SC", "Microsoft YaHei", serif;
    --body-weight: 400;
    --heading-weight: 600;
    --max-reading-width: 680px;
    --max-parallel-width: 1220px;
    --transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    --base-font-size: 19px;
}

html[data-theme="light"] {
    color-scheme: only light;
    --background: #fafafb;
    --surface: #ffffff;
    --surface-soft: #f0f0f3;
    --text: #222326;
    --text-secondary: #505259;
    --muted: #767880;
    --line: #e3e4e8;
    --accent: #9a3721;
    --accent-soft: rgba(154, 55, 33, 0.09);
    --shadow: 0 12px 36px rgba(0, 0, 0, 0.06);
    --surface-translucent: rgba(255, 255, 255, 0.9);
    --toolbar-translucent: rgba(250, 250, 251, 0.9);
    --note-bg: #f4f4f7;
}

html[data-theme="dark"] {
    color-scheme: dark;
    --background: #1c1b19;
    --surface: #23221f;
    --surface-soft: #2c2a26;
    --text: #d6d0c6;
    --text-secondary: #a59e92;
    --muted: #7f796e;
    --line: #34312c;
    --accent: #d48368;
    --accent-soft: rgba(212, 131, 104, 0.14);
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.35);
    --surface-translucent: rgba(35, 34, 31, 0.9);
    --toolbar-translucent: rgba(28, 27, 25, 0.9);
    --note-bg: rgba(44, 42, 38, 0.65);
}

html[data-font="wenkai"] {
    --font-body-en: "Literata", "Charter", "Georgia", serif;
    --font-body-zh: "Literata Mixed", "LXGW WenKai GB", "Kaiti SC", "STKaiti", "PingFang SC", "Microsoft YaHei", serif;
    --body-weight: 400;
    --heading-weight: 600;
}

html[data-font="serif"] {
    --font-body-en: "Literata", "Charter", "Georgia", serif;
    --font-body-zh: "Literata Mixed", "Noto Serif SC Book", "Songti SC", "Source Han Serif SC", "STSong", "Noto Serif CJK SC", serif;
    --body-weight: 420;
    --heading-weight: 600;
}

html[data-theme="dark"][data-font="serif"] {
    --body-weight: 390;
}

html[data-font="sans"] {
    --font-body-en: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    --font-body-zh: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    --body-weight: 400;
    --heading-weight: 600;
}

html[data-measure="narrow"] {
    --max-reading-width: 620px;
}

html[data-measure="medium"] {
    --max-reading-width: 680px;
}

html[data-measure="wide"] {
    --max-reading-width: 780px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    overflow-x: clip;
    background-color: var(--background);
    color: var(--text);
    font-family: var(--font-body-en);
    font-weight: var(--body-weight);
    transition: background-color 0.25s ease, color 0.25s ease;
    -webkit-tap-highlight-color: transparent;
}

body:lang(zh-CN) {
    font-family: var(--font-body-zh);
}

html[data-theme="dark"] body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

html[data-font="wenkai"] .reader-article,
html[data-font="serif"] .reader-article {
    font-synthesis-weight: none;
}

button,
input {
    font: inherit;
}

a {
    color: inherit;
    transition: var(--transition);
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 2.5px;
    background: var(--accent);
    z-index: 120;
    transition: width 0.1s ease-out;
    pointer-events: none;
}

:target,
.anchor-flash {
    animation: targetHighlight 1.8s ease-out;
}

@keyframes targetHighlight {
    0% {
        background-color: var(--accent-soft);
    }
    100% {
        background-color: transparent;
    }
}

.reader-shell {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 0.24s cubic-bezier(0.4, 0, 0.2, 1);
}

html[data-sidebar="collapsed"] .reader-shell {
    grid-template-columns: 0 minmax(0, 1fr);
}

.reader-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 24px 16px;
    overflow-y: auto;
    border-right: 1px solid var(--line);
    background: var(--surface-translucent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: background-color 0.25s ease, border-color 0.25s ease, opacity 0.2s ease;
}

html[data-sidebar="collapsed"] .reader-sidebar {
    width: 0;
    padding: 0;
    overflow: hidden;
    border-right: 0;
    opacity: 0;
    pointer-events: none;
}

.reader-sidebar::-webkit-scrollbar {
    width: 5px;
}

.reader-sidebar::-webkit-scrollbar-track {
    background: transparent;
}

.reader-sidebar::-webkit-scrollbar-thumb {
    background: var(--line);
    border-radius: 4px;
}

.sidebar-backdrop {
    display: none;
}

.reader-back-link {
    display: inline-flex;
    align-items: center;
    margin: 0 8px 16px;
    padding: 5px 11px;
    border: 1px solid var(--line);
    border-radius: 9999px;
    background: var(--surface);
    color: var(--muted);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 500;
}

.reader-back-link:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.reader-brand {
    display: block;
    margin-bottom: 20px;
    padding: 0 8px 16px;
    border-bottom: 1px solid var(--line);
    text-decoration: none;
}

.reader-brand:hover .reader-brand-title {
    color: var(--accent);
}

.reader-brand-title,
.reader-brand-subtitle {
    display: block;
}

.reader-brand-title {
    font-size: 19px;
    line-height: 1.35;
    font-weight: var(--heading-weight);
    transition: var(--transition);
}

.reader-brand-subtitle {
    margin-top: 5px;
    color: var(--muted);
    font-size: 12.5px;
    font-family: var(--font-ui);
}

.toc {
    display: grid;
    gap: 2px;
}

.toc-group-label {
    margin: 14px 10px 4px;
    color: var(--accent);
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.toc-group-label:first-child {
    margin-top: 2px;
}

.toc a {
    display: block;
    padding: 8px 10px;
    border-radius: 7px;
    color: var(--text-secondary);
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.45;
    transition: var(--transition);
}

.toc a:hover {
    background: var(--surface-soft);
    color: var(--text);
}

.toc a.active {
    background: var(--accent-soft);
    color: var(--accent);
    font-weight: 600;
}

.reader-main {
    min-width: 0;
}

.reader-toolbar {
    position: sticky;
    top: 0;
    z-index: 40;
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 10px clamp(16px, 4vw, 40px);
    border-bottom: 1px solid var(--line);
    background: var(--toolbar-translucent);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.25s ease, border-color 0.25s ease;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.toolbar-chapter-title {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    opacity: 0;
    transform: translateY(2px);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.toolbar-chapter-title.visible {
    opacity: 1;
    transform: translateY(0);
}

.toolbar-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

.toolbar-icon-btn,
.toolbar-pill-btn {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text-secondary);
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: var(--font-ui);
    transition: var(--transition);
    flex-shrink: 0;
}

.toolbar-icon-btn {
    width: 34px;
    padding: 0;
    border-radius: 9999px;
}

.toolbar-pill-btn {
    padding: 0 12px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.toolbar-icon-btn svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toolbar-icon-btn:hover,
.toolbar-pill-btn:hover,
.toolbar-pill-btn[aria-expanded="true"] {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface-soft);
}

.segmented-control {
    display: inline-flex;
    align-items: center;
    background: var(--surface-soft);
    padding: 3px;
    border-radius: 9999px;
    border: 1px solid var(--line);
}

.segment-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 500;
    padding: 5px 11px;
    border-radius: 9999px;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    line-height: 1.2;
}

.segment-btn:hover {
    color: var(--text);
}

.segment-btn.active {
    background: var(--surface);
    color: var(--accent);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.typography-control {
    position: relative;
}

.typography-popover {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 60;
    width: 284px;
    padding: 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: var(--shadow);
    display: grid;
    gap: 12px;
    font-family: var(--font-ui);
}

.typography-popover[hidden] {
    display: none;
}

.popover-row {
    display: grid;
    gap: 6px;
}

.popover-row-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.popover-label-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.popover-label {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.popover-hint {
    font-size: 10.5px;
    font-weight: 400;
    color: var(--muted);
    opacity: 0.8;
}

.popover-segmented {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    background: var(--surface-soft);
    padding: 3px;
    border-radius: 10px;
    border: 1px solid var(--line);
}

.popover-choice {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 7px;
    padding: 6px 4px;
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    transition: var(--transition);
}

.popover-choice svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    flex-shrink: 0;
}

.popover-choice:hover {
    color: var(--text);
}

.popover-choice.active {
    background: var(--surface);
    color: var(--accent);
    border-color: var(--line);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.stepper-group {
    display: inline-flex;
    align-items: center;
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 9999px;
    padding: 2px 4px;
}

.stepper-btn {
    border: none;
    background: transparent;
    color: var(--text-secondary);
    width: 30px;
    height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 9999px;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.stepper-btn:hover:not(:disabled) {
    background: var(--surface);
    color: var(--accent);
}

.stepper-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.stepper-value {
    font-family: var(--font-ui);
    font-size: 12.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text);
    min-width: 30px;
    text-align: center;
    user-select: none;
}

.search-control {
    display: flex;
    align-items: center;
    gap: 6px;
}

.search-toggle-btn {
    display: none;
}

.search-label {
    display: flex;
    align-items: center;
    position: relative;
    width: 210px;
}

.search-label input {
    width: 100%;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 9999px;
    background: var(--surface);
    padding: 0 30px 0 13px;
    color: var(--text);
    transition: var(--transition);
    font-family: var(--font-ui);
    font-size: 13px;
}

.search-label input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-label input::placeholder {
    color: var(--muted);
    opacity: 0.75;
}

.search-clear-btn {
    position: absolute;
    right: 6px;
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
}

.search-clear-btn[hidden] {
    display: none;
}

.search-clear-btn svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.search-results {
    max-width: var(--max-reading-width);
    margin: 20px auto 0;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    box-shadow: var(--shadow);
    font-family: var(--font-ui);
}

.search-status {
    padding: 10px 12px;
    color: var(--muted);
    font-size: 13.5px;
}

.search-result {
    display: block;
    padding: 11px 12px;
    border-radius: 8px;
    text-decoration: none;
    transition: var(--transition);
}

.search-result:hover {
    background: var(--surface-soft);
}

.search-result strong {
    display: block;
    color: var(--accent);
    font-size: 14px;
    margin-bottom: 4px;
}

.search-result span {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
    line-height: 1.5;
}

.reader-article {
    width: 100%;
    max-width: calc(var(--max-reading-width) + 56px);
    margin: 0 auto;
    padding: 52px 28px 64px;
    transition: max-width 0.25s ease;
}

body.is-parallel .reader-article {
    max-width: var(--max-parallel-width);
}

.eyebrow {
    margin: 0 0 12px;
    color: var(--accent);
    font-family: var(--font-ui);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

#page-title {
    margin: 0;
    font-size: clamp(26px, 3.2vw, 38px);
    line-height: 1.28;
    letter-spacing: 0.01em;
    font-weight: var(--heading-weight);
    text-wrap: balance;
}

html[lang="en"] #page-title {
    letter-spacing: -0.01em;
}

.page-meta {
    margin-top: 14px;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 13.5px;
    line-height: 1.5;
}

.translation-notice {
    margin: 24px 0 0;
    border-left: 2px solid var(--accent);
    background: var(--accent-soft);
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-family: var(--font-ui);
    font-size: 13.5px;
    line-height: 1.6;
}

.loading-state {
    color: var(--muted);
    font-family: var(--font-ui);
    font-style: italic;
}

.content {
    margin-top: 36px;
    line-break: strict;
    text-autospace: normal;
    overflow-wrap: break-word;
}

.content > :first-child {
    margin-top: 0;
}

.content [id] {
    scroll-margin-top: 84px;
}

.content h1,
.content h2,
.content h3,
.content h4 {
    font-weight: var(--heading-weight);
    color: var(--text);
    text-wrap: balance;
}

.content h1 {
    font-size: calc(var(--base-font-size) * 1.42);
    line-height: 1.35;
    margin: 2em 0 0.85em;
}

.content h2 {
    font-size: calc(var(--base-font-size) * 1.24);
    line-height: 1.38;
    margin: 1.85em 0 0.75em;
    border-bottom: 1px solid var(--line);
    padding-bottom: 6px;
}

.content h3,
.content h4 {
    font-size: calc(var(--base-font-size) * 1.1);
    line-height: 1.42;
    margin: 1.6em 0 0.65em;
}

.content .content-kicker {
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    line-height: 1.45;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0 1.4em;
    padding-bottom: 0;
    border-bottom: 0;
}

.content p {
    margin: 0 0 1.3em;
    font-size: var(--base-font-size);
    line-height: 1.9;
    letter-spacing: 0.02em;
}

body:lang(en) .content p,
.content [lang="en"],
.content .is-source-fallback,
.content .is-source-fallback p,
.content .source-column,
.content .source-column p {
    font-family: var(--font-body-en);
    letter-spacing: 0;
    hyphens: auto;
    font-kerning: normal;
}

body:lang(en) .content p,
.content .is-source-fallback p {
    line-height: 1.72;
    margin: 0 0 1.15em;
}

.content blockquote {
    margin: 1.4em 0;
    padding: 8px 18px;
    border-left: 2px solid var(--line);
    color: var(--text-secondary);
}

.content .parallel-block {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.14fr);
    gap: 40px;
    max-width: 100%;
    margin: 0 0 1.45em;
    padding: 2px 0 1.25em;
    border-bottom: 1px solid color-mix(in srgb, var(--line) 55%, transparent);
}

.content .parallel-column > * {
    margin-top: 0;
}

.content .parallel-column > :last-child {
    margin-bottom: 0;
}

.content .source-column {
    padding-left: 20px;
    border-left: 1px solid color-mix(in srgb, var(--line) 65%, transparent);
    color: var(--text-secondary);
}

.content .source-column p {
    font-size: calc(var(--base-font-size) * 0.94);
    line-height: 1.72;
    color: var(--text-secondary);
    margin: 0 0 1.05em;
}

.content .source-column h1,
.content .source-column h2,
.content .source-column h3,
.content .source-column h4 {
    color: var(--text-secondary);
    font-family: var(--font-body-en);
}

.content .note {
    margin: 1.25em 0;
    padding: 12px 16px;
    border-left: 2px solid var(--line);
    background: var(--note-bg);
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-size: calc(var(--base-font-size) * 0.86);
    line-height: 1.72;
    letter-spacing: 0.01em;
}

.content .note-label {
    margin-right: 6px;
    color: var(--accent);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 0.9em;
    letter-spacing: 0.03em;
}

.marginal-ref {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 0.66em;
    font-weight: 500;
    line-height: 1.3;
    letter-spacing: 0.02em;
    color: var(--muted);
    background: var(--surface-soft);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 6px;
    margin-right: 0.55em;
    vertical-align: 0.12em;
    user-select: none;
}

.content sup {
    line-height: 0;
}

.footnote-ref {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    padding: 0 4px;
    margin: 0 1px;
    border-radius: 4px;
    color: var(--accent);
    font-family: var(--font-ui);
    font-size: 0.72em;
    font-weight: 600;
    text-decoration: none;
}

.footnote-ref:hover {
    background: var(--accent-soft);
}

.note-return-btn {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--muted);
    border-radius: 9999px;
    font-family: var(--font-ui);
    font-size: 12px;
    padding: 2px 9px;
    margin-left: 6px;
    cursor: pointer;
    vertical-align: baseline;
    transition: var(--transition);
}

.note-return-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.note-return-btn[hidden] {
    display: none;
}

.content .separator {
    position: relative;
    height: 18px;
    width: 180px;
    margin: 2.6em auto;
    border: 0;
    background: transparent;
}

.content .separator::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 1px;
    transform: translateY(-50%);
    background: linear-gradient(90deg, transparent, var(--line) 15%, var(--line) 38%, transparent 38%, transparent 62%, var(--line) 62%, var(--line) 85%, transparent);
}

.content .separator::after {
    content: "✦";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--muted);
    font-size: 13px;
    line-height: 1;
}

.table-wrap {
    max-width: 100%;
    margin: 1.8em 0;
    overflow-x: auto;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--surface);
}

.content table {
    border-collapse: collapse;
    width: 100%;
    min-width: 520px;
    background: var(--surface);
    font-family: var(--font-ui), var(--font-symbol);
    font-size: calc(var(--base-font-size) * 0.86);
    font-variant-numeric: tabular-nums;
    font-variant-emoji: text;
}

.content th,
.content td {
    border-bottom: 1px solid var(--line);
    padding: 11px 14px;
    vertical-align: top;
    line-height: 1.55;
    text-align: left;
}

.content th[scope="row"] {
    background: color-mix(in srgb, var(--surface-soft) 55%, transparent);
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
}

.content tr:last-child th,
.content tr:last-child td {
    border-bottom: 0;
}

.book-contents {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
    margin: 2em 0;
}

.book-contents-group {
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    padding: 18px 20px;
    transition: var(--transition);
}

.book-contents-group:hover {
    box-shadow: var(--shadow);
    border-color: color-mix(in srgb, var(--accent) 30%, var(--line));
}

.book-contents-header {
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
    margin-bottom: 12px;
}

.book-label-badge {
    display: inline-block;
    font-family: var(--font-ui);
    font-size: 11px;
    font-weight: 600;
    color: var(--accent);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.book-contents-title {
    margin: 0;
    color: var(--text);
    font-size: calc(var(--base-font-size) * 1.02);
    font-weight: var(--heading-weight);
}

.chapter-grid {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.chapter-link-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 9px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-family: var(--font-ui);
    font-size: 13.5px;
    line-height: 1.45;
    transition: var(--transition);
}

.chapter-number {
    font-size: 11px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
    background: var(--surface-soft);
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 26px;
    text-align: center;
    flex-shrink: 0;
}

.chapter-text {
    flex: 1;
}

.chapter-arrow {
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    color: var(--accent);
    font-size: 14px;
    flex-shrink: 0;
}

.chapter-link-card:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

.chapter-link-card:hover .chapter-arrow {
    opacity: 1;
    transform: translateX(0);
}

.page-nav {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin-top: 64px;
    padding-top: 28px;
    border-top: 1px solid var(--line);
}

.page-nav-link {
    flex: 1;
    max-width: 280px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    padding: 14px 18px;
    text-align: center;
    text-decoration: none;
    font-family: var(--font-ui);
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    transition: var(--transition);
}

.page-nav-link:hover {
    border-color: var(--accent);
    color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.page-nav-link[aria-disabled="true"] {
    pointer-events: none;
    opacity: 0.38;
    background: transparent;
}

.reader-footer {
    max-width: calc(var(--max-reading-width) + 56px);
    margin: 0 auto;
    padding: 0 28px 64px;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 13px;
    line-height: 1.65;
    text-align: center;
}

.back-to-top {
    position: fixed;
    right: max(20px, env(safe-area-inset-right));
    bottom: max(22px, env(safe-area-inset-bottom));
    z-index: 35;
    width: 38px;
    height: 38px;
    border-radius: 9999px;
    border: 1px solid var(--line);
    background: var(--surface-translucent);
    color: var(--text-secondary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.back-to-top[hidden] {
    display: none;
}

.back-to-top svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.back-to-top:hover {
    color: var(--accent);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.reader-toast {
    position: fixed;
    left: 50%;
    bottom: max(28px, env(safe-area-inset-bottom));
    z-index: 130;
    transform: translate(-50%, 8px);
    opacity: 0;
    padding: 7px 15px;
    border-radius: 9999px;
    border: 1px solid var(--line);
    background: var(--surface-translucent);
    color: var(--text);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow: var(--shadow);
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    letter-spacing: 0.01em;
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.reader-toast.visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.reader-toast[hidden] {
    display: none;
}

@media (hover: none) {
    .popover-hint {
        display: none;
    }
}

@media (max-width: 860px) {
    .reader-shell,
    html[data-sidebar="collapsed"] .reader-shell {
        display: block;
    }

    .reader-sidebar,
    html[data-sidebar="collapsed"] .reader-sidebar {
        position: fixed;
        inset: var(--toolbar-height, 56px) 0 0 0;
        z-index: 50;
        display: none;
        width: auto;
        height: auto;
        max-height: calc(100dvh - var(--toolbar-height, 56px));
        padding: 20px 16px 32px;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        background: var(--surface);
        opacity: 1;
        pointer-events: auto;
    }

    .reader-sidebar.open,
    html[data-sidebar="collapsed"] .reader-sidebar.open {
        display: block;
        animation: slideDown 0.24s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .sidebar-backdrop.visible {
        display: block;
        position: fixed;
        inset: var(--toolbar-height, 56px) 0 0 0;
        z-index: 45;
        background: rgba(0, 0, 0, 0.25);
        backdrop-filter: blur(2px);
    }

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

    .reader-toolbar {
        padding: 9px 14px;
        gap: 8px;
    }

    .reader-toolbar.toolbar-hidden {
        transform: translateY(-100%);
    }

    .toolbar-chapter-title {
        display: none;
    }

    .search-toggle-btn {
        display: inline-flex;
    }

    .search-label {
        display: none;
    }

    .reader-toolbar.search-open .toolbar-left,
    .reader-toolbar.search-open .segmented-control,
    .reader-toolbar.search-open .typography-control {
        display: none;
    }

    .reader-toolbar.search-open .toolbar-controls {
        flex: 1;
    }

    .reader-toolbar.search-open .search-control {
        flex: 1;
    }

    .reader-toolbar.search-open .search-label {
        display: flex;
        flex: 1;
        width: auto;
    }

    .search-results {
        margin: 14px 16px 0;
    }

    .reader-article {
        padding: 32px 20px 44px;
    }

    .content p {
        line-height: 1.85;
    }

    .content .parallel-block {
        grid-template-columns: minmax(0, 1fr);
        gap: 14px;
    }

    .content .source-column {
        padding-left: 12px;
    }

    .book-contents {
        grid-template-columns: minmax(0, 1fr);
    }

    .typography-popover {
        right: -42px;
        width: min(296px, calc(100vw - 28px));
    }

    .popover-hint {
        display: none;
    }
}

@media (max-width: 560px) {
    .segment-btn {
        padding: 5px 9px;
        font-size: 12px;
    }

    .page-nav {
        flex-direction: column;
    }

    .page-nav-link {
        max-width: 100%;
    }
}
