:root {
  color-scheme: light;
  --accent: #d75837;
  --progress: #6acb97;
  --translation-marker: #75412d;
  --toc-link: #246ba0;
  --note-ink: #244b69;
  --ink: #24211e;
  --muted: #77716b;
  --surface: #f4f1eb;
  --paper: #fffefa;
  --toolbar-surface: #e8e6e2;
  --reader-gutter: #454744;
  --reading-surface: #f7f3eb;
  --line: rgba(55, 48, 41, 0.1);
  --reader-font-size: 20px;
  --desktop-page-width: 50vw;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Noto Sans CJK SC", sans-serif;
}

* { box-sizing: border-box; }
html, body, #app { min-height: 100%; margin: 0; }
body { background: var(--reader-gutter); color: var(--ink); }
button, input { font: inherit; }
button { color: inherit; }
[hidden] { display: none !important; }

.library-view, .notes-view { width: var(--desktop-page-width); min-height: 100vh; margin: 0 auto; background: var(--surface); box-shadow: 0 0 36px rgba(55, 48, 41, .045); }
.library-view, .notes-view { padding: 16px 20px 96px; }
.notes-header { display: flex; min-height: 44px; margin-bottom: 12px; align-items: center; gap: 12px; border-bottom: 1px solid var(--line); }
.notes-header h1 { min-width: 0; margin: 0 0 12px; overflow: hidden; font-family: Georgia, "Songti SC", serif; font-size: 22px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.notes-header > span { margin: 0 0 12px auto; flex: none; color: var(--muted); font-size: 13px; }
.notes-back { width: 30px; height: 30px; margin: 0 0 12px; flex: none; border: 0; border-radius: 8px; background: transparent; color: var(--accent); font-size: 30px; line-height: 1; cursor: pointer; }
.notes-back:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.saved-note-list { display: flex; flex-direction: column; gap: 12px; }
.saved-note { padding: 17px 18px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: 0 2px 9px rgba(55, 48, 41, .035); }
.saved-note-chapter { margin-bottom: 10px; color: var(--accent); font-size: 12px; font-weight: 700; line-height: 1.5; }
.saved-note blockquote { margin: 0; overflow-wrap: anywhere; color: var(--ink); font-size: 16px; line-height: 1.75; white-space: pre-wrap; }
.saved-note-actions { display: flex; margin-top: 12px; justify-content: flex-end; gap: 12px; }
.saved-note-actions button { padding: 5px 7px; border: 0; border-radius: 7px; background: transparent; color: var(--accent); font-size: 12px; cursor: pointer; }
.saved-note-actions button:last-child { color: var(--muted); }
.saved-note-actions button:hover { background: color-mix(in srgb, var(--accent) 9%, transparent); }
.home-tabs { position: fixed; z-index: 10; right: 25vw; bottom: 0; left: 25vw; display: flex; height: 64px; padding: 6px 20px max(6px, env(safe-area-inset-bottom)); gap: 8px; border-top: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(16px); }
.home-tab { flex: 1; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 14px; font-weight: 600; cursor: pointer; }
.home-tab.active { background: var(--paper); color: var(--accent); box-shadow: 0 1px 4px rgba(55, 48, 41, .08); }
.home-tab:not(.active):hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.home-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.library-header { display: flex; align-items: center; margin-bottom: 12px; }
.search-box { display: flex; align-items: center; width: min(100%, 420px); height: 44px; padding: 0 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.65); box-shadow: 0 1px 0 rgba(255,255,255,.8) inset; }
.search-box svg { width: 19px; fill: none; stroke: var(--muted); stroke-linecap: round; stroke-width: 1.8; }
.search-box input, .toc-search input { width: 100%; border: 0; outline: 0; background: transparent; color: var(--ink); }
.search-box input { padding: 0 10px; font-size: 16px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; border-bottom: 1px solid var(--line); }
.section-heading h1 { margin: 0 0 12px; font-family: Georgia, "Songti SC", serif; font-size: 22px; font-weight: 600; }
.section-heading span { color: var(--muted); font-size: 14px; }
.book-grid { display: flex; padding-top: 0; flex-direction: column; }
.book-card { display: flex; width: 100%; min-width: 0; padding: 18px 0; align-items: center; gap: 22px; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; }
.book-card:hover { background: color-mix(in srgb, var(--ink) 3%, transparent); }
.book-card:hover .book-cover { transform: translateY(-3px); box-shadow: 0 16px 30px rgba(57, 42, 31, .2), 0 3px 8px rgba(57, 42, 31, .12); }
.book-card:focus-visible { border-radius: 10px; outline: 2px solid var(--accent); outline-offset: -2px; }
.book-cover { position: relative; width: 88px; aspect-ratio: 2 / 3; overflow: hidden; flex: none; border-radius: 4px 7px 7px 4px; background: linear-gradient(145deg, #772f24, #c16b4e); box-shadow: 0 8px 16px rgba(57, 42, 31, .14), 0 2px 5px rgba(57, 42, 31, .1); color: white; transition: transform .25s ease, box-shadow .25s ease; }
.book-cover::after { position: absolute; inset: 0 auto 0 0; width: 7px; content: ""; background: linear-gradient(90deg, rgba(0,0,0,.24), transparent); }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-fallback { display: flex; padding: 12px 9px; align-items: center; overflow-wrap: anywhere; font-size: 12px; line-height: 1.4; }
.cover-progress { position: absolute; right: 0; bottom: 0; left: 0; height: 4px; background: rgba(0,0,0,.18); }
.cover-progress i { display: block; height: 100%; background: var(--progress); }
.book-info { display: flex; min-width: 0; flex-direction: column; }
.book-info > strong { margin-bottom: 8px; font-size: 18px; line-height: 1.4; }
.book-title > span { display: block; }
.book-title-original { margin-bottom: 2px; }
.book-info > span, .book-info > small { overflow: hidden; color: var(--muted); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.book-info > .book-author { white-space: normal; }
.book-info > small { margin-top: 12px; color: #9a938c; }
.book-skeleton { display: flex; min-width: 0; padding: 18px 0; align-items: center; gap: 22px; border-bottom: 1px solid var(--line); }
.book-skeleton-info { display: flex; width: min(100% - 110px, 420px); flex-direction: column; }
.book-skeleton > i, .book-skeleton-info > * { display: block; overflow: hidden; border-radius: 5px; background: linear-gradient(100deg, rgba(55,48,41,.065) 25%, rgba(255,255,255,.62) 42%, rgba(55,48,41,.065) 60%); background-size: 260% 100%; animation: skeleton-shimmer 1.35s ease-in-out infinite; }
.book-skeleton > i { width: 88px; aspect-ratio: 2 / 3; flex: none; border-radius: 4px 7px 7px 4px; }
.book-skeleton-info > b { width: 86%; height: 18px; margin-bottom: 12px; }
.book-skeleton-info > span { width: 58%; height: 13px; }
.book-skeleton-info > small { width: 42%; height: 12px; margin-top: 14px; }
@keyframes skeleton-shimmer { to { background-position-x: -180%; } }
.empty-state, .error-state { padding: 72px 20px; text-align: center; color: var(--muted); }
.empty-icon { display: grid; width: 72px; height: 72px; margin: 0 auto 18px; place-items: center; border-radius: 22px; background: white; box-shadow: 0 12px 24px rgba(0,0,0,.08); color: var(--accent); font-family: Georgia, serif; font-size: 28px; }

.reader-view { --reader-shell-width: var(--desktop-page-width); position: fixed; inset: 0; background: var(--reader-gutter); }
.reader-toolbar { position: relative; z-index: 20; display: grid; width: var(--reader-shell-width); height: 60px; margin: 0 auto; padding: 0 18px; align-items: center; grid-template-columns: 1fr auto; border-bottom: 1px solid var(--line); background: var(--toolbar-surface); }
.icon-button, .appearance-button { display: inline-flex; align-items: center; border: 0; background: transparent; cursor: pointer; }
.icon-button svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.8; }
.back-button { width: 40px; height: 40px; padding: 0; justify-content: center; border-radius: 12px; background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--accent); }
.reader-book-meta { display: flex; max-width: 440px; text-align: center; flex-direction: column; }
.reader-book-meta strong { overflow: hidden; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.reader-book-meta span { margin-top: 2px; color: var(--muted); font-size: 11px; }
.toolbar-actions { display: flex; justify-content: flex-end; gap: 4px; }
.toolbar-actions .icon-button { padding: 8px; border-radius: 10px; }
.language-select { max-width: 116px; border: 1px solid var(--line); border-radius: 9px; padding: 6px 24px 6px 8px; background: color-mix(in srgb, var(--toolbar-surface) 75%, var(--paper)); color: var(--ink); font: inherit; font-size: 12px; }
.appearance-button { padding: 8px 9px; border-radius: 10px; color: var(--accent); font-family: Georgia, serif; font-size: 17px; font-weight: 700; }
.appearance-button:hover, .icon-button:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.reading-progress { position: absolute; z-index: 21; top: 59px; left: 50%; width: var(--reader-shell-width); height: 2px; transform: translateX(-50%); }
.reading-progress span { display: block; width: 0; height: 100%; background: var(--progress); transition: width .35s ease; }
.reader-layout { position: relative; height: calc(100vh - 60px); }
.reader-layout::before { position: absolute; z-index: 0; top: 0; bottom: 0; left: 50%; width: var(--reader-shell-width); content: ""; background: var(--reading-surface); box-shadow: 0 0 42px rgba(38, 32, 25, .055); pointer-events: none; transform: translateX(-50%); }
.toc-panel { position: fixed; z-index: 30; top: calc(50% + 30px); left: max(12px, calc((100vw - var(--reader-shell-width)) / 2 - 322px)); width: min(306px, calc((100vw - var(--reader-shell-width)) / 2 - 24px)); height: min(680px, calc(100vh - 92px)); overflow: hidden; visibility: hidden; border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--surface) 88%, var(--paper)); box-shadow: 0 22px 60px rgba(43, 36, 30, .16); opacity: 0; pointer-events: none; transform: translateY(calc(-50% - 8px)) scale(.985); transform-origin: center right; transition: opacity .18s ease, transform .18s ease, visibility .18s; }
.toc-panel.open { visibility: visible; opacity: 1; pointer-events: auto; transform: translateY(-50%) scale(1); }
.toc-header { display: flex; height: 54px; padding: 0 22px; align-items: center; justify-content: space-between; font-size: 18px; font-weight: 700; }
.toc-search { display: block; margin: 0 16px 12px; padding: 9px 12px; border-radius: 10px; background: color-mix(in srgb, var(--ink) 5%, transparent); }
.toc-search input { font-size: 13px; }
.toc-list { height: calc(100% - 110px); padding: 3px 12px 32px; overflow-y: auto; }
.toc-group + .toc-group { margin-top: 7px; }
.toc-group-row { display: grid; min-height: 38px; align-items: center; grid-template-columns: 28px minmax(0, 1fr); }
.toc-toggle { display: grid; width: 28px; height: 32px; padding: 0; place-items: center; border: 0; border-radius: 7px; background: transparent; color: var(--muted); cursor: pointer; }
.toc-toggle:hover { background: color-mix(in srgb, var(--ink) 6%, transparent); }
.toc-toggle svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; transition: transform .18s ease; }
.toc-toggle[aria-expanded="false"] svg { transform: rotate(-90deg); }
.toc-group-link, .toc-group-label { display: flex; width: 100%; padding: 8px 8px 8px 3px; overflow: hidden; border: 0; border-radius: 8px; background: transparent; color: var(--ink); font-size: 13px; font-weight: 700; line-height: 1.42; text-align: left; text-overflow: ellipsis; cursor: pointer; flex-direction: column; }
.toc-group-link:hover, .toc-group-label:hover { color: var(--accent); }
.toc-group-link.active { color: var(--accent); }
.toc-group-children { position: relative; margin: 0 0 3px 13px; padding: 0 0 2px 10px; border-left: 1px solid color-mix(in srgb, var(--ink) 14%, transparent); }
.toc-item { border: 0; background: transparent; cursor: pointer; }
.toc-leaf { position: relative; display: block; width: 100%; padding: 5px 8px; border-radius: 8px; color: var(--ink); text-align: left; }
.toc-leaf.has-marker { display: grid; grid-template-columns: 27px minmax(0, 1fr); align-items: center; gap: 3px; }
.toc-leaf-marker { color: var(--muted); font-size: 11px; line-height: 1.35; font-variant-numeric: tabular-nums; }
.toc-leaf::before { position: absolute; top: 15px; left: -10px; width: 8px; height: 1px; content: ""; background: color-mix(in srgb, var(--ink) 14%, transparent); }
.toc-leaf-titles { display: flex; min-width: 0; flex-direction: column; }
.toc-leaf-titles strong { font-size: 12.5px; font-weight: 500; line-height: 1.35; }
.toc-translated-title { margin-top: 2px; color: var(--muted); font-size: 11px; line-height: 1.3; }
.toc-source-title { overflow: hidden; color: var(--muted); font-family: Georgia, "Times New Roman", serif; font-size: 10.5px; font-weight: 400; line-height: 1.35; text-overflow: ellipsis; white-space: nowrap; }
.toc-leaf-titles .toc-source-title { margin-bottom: 1px; padding: 0; }
.toc-leaf:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.toc-leaf.active { background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--accent); }
.toc-leaf.active::before { background: color-mix(in srgb, var(--accent) 55%, transparent); }
.reading-scroll { position: relative; z-index: 1; height: 100%; overflow-x: hidden; overflow-y: auto; background: transparent; scroll-behavior: smooth; }
.chapter-content, .chapter-navigation { position: relative; left: 50vw; width: calc(var(--reader-shell-width) - 40px); margin-right: 0; margin-left: 0; transform: translateX(-50%); }
.chapter-content { min-height: 0; padding: clamp(62px, 9vh, 112px) 0 16px; overflow-wrap: anywhere; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif; font-size: var(--reader-font-size); line-height: 1.92; letter-spacing: .01em; }
.chapter-content.loading { opacity: .42; }
.reader-loading, .reader-error { display: grid; min-height: 42vh; place-items: center; color: var(--muted); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; font-size: 14px; }
.reader-loading::before { width: 22px; height: 22px; border: 2px solid color-mix(in srgb, var(--accent) 18%, transparent); border-top-color: var(--accent); border-radius: 50%; content: ""; animation: reader-spin .8s linear infinite; }
.reader-error { color: var(--accent); }
.save-selection { position: fixed; z-index: 80; display: inline-flex; min-height: 38px; padding: 7px 13px; align-items: center; gap: 6px; border: 1px solid color-mix(in srgb, var(--accent) 75%, white); border-radius: 9px; background: var(--accent); box-shadow: 0 7px 24px rgba(24, 17, 12, .22); color: white; font-size: 13px; font-weight: 700; cursor: pointer; touch-action: manipulation; transform: translateX(-50%); }
.save-selection svg { width: 15px; height: 15px; flex: none; fill: currentColor; }
.bookmark-status { position: fixed; z-index: 80; right: 50%; bottom: 34px; max-width: calc(100vw - 32px); padding: 9px 14px; border-radius: 9px; background: var(--ink); box-shadow: 0 8px 28px rgba(0, 0, 0, .18); color: var(--paper); font-size: 13px; transform: translateX(50%); }
.bookmark-highlight { animation: bookmark-flash 2.2s ease-out; }
@keyframes bookmark-flash { 0%, 40% { background: color-mix(in srgb, var(--accent) 18%, transparent); } 100% { background: transparent; } }
@keyframes reader-spin { to { transform: rotate(1turn); } }
.chapter-label { margin-bottom: 12px; color: var(--accent); font-family: -apple-system, "PingFang SC", sans-serif; font-size: 12px; font-weight: 700; letter-spacing: .12em; }
.chapter-content h1 { margin: 0 0 .8em; font-size: clamp(34px, 5vw, 52px); line-height: 1.25; letter-spacing: -.035em; }
.chapter-title-source { font-family: Georgia, "Times New Roman", serif; font-weight: 600; letter-spacing: 0; }
.chapter-content[data-layout="cover"] { padding-bottom: 12px; text-align: center; }
.chapter-content[data-layout="cover"] h1 { margin-bottom: .4em; }
.chapter-content[data-layout="cover"] figure { margin: .6em 0 .6em; }
.chapter-content[data-layout="cover"] figure img { max-height: 58vh; }
.chapter-content[data-layout="toc"] h1 { margin-bottom: .65em; }
.chapter-content[data-layout="toc-tree"] { font-size: clamp(15px, .78em, 18px); line-height: 1.4; }
.chapter-content[data-layout="toc-tree"] h1 { margin-bottom: .55em; }
.contents-tree { max-width: 100%; overflow-x: auto; }
.chapter-content .contents-tree ul { margin: 0; padding: 0 0 0 1.15em; list-style: none; border-left: 1px solid var(--line); }
.chapter-content .contents-tree > ul { padding-left: 0; border-left: 0; }
.chapter-content .contents-tree li { margin: 0; padding: 0; }
.contents-tree li > span, .contents-tree li > button { display: block; width: 100%; min-width: max-content; padding: .2em .45em; border: 0; border-radius: 5px; background: transparent; color: var(--toc-link); font: inherit; text-align: left; white-space: nowrap; }
.contents-tree-source { color: var(--toc-link); font-size: .86em; }
.contents-tree-translated { color: var(--toc-link); }
.contents-tree-source + .contents-tree-translated { margin-left: 0; }
.contents-tree li > button { cursor: pointer; }
.contents-tree li > button:hover { background: color-mix(in srgb, var(--toc-link) 9%, transparent); text-decoration: underline; }
.contents-tree-level-0 > span, .contents-tree-level-0 > button { font-weight: 700 !important; }
.contents-tree-level-1 > span, .contents-tree-level-1 > button { font-weight: 600 !important; }
.chapter-content h2, .chapter-content h3, .chapter-content h4 { margin: 1.2em 0 .6em; padding-top: .7em; border-top: 1px solid var(--line); line-height: 1.45; }
.chapter-content h2 { font-size: 1.35em; }
.chapter-content h3, .chapter-content h4 { font-size: 1.1em; }
.chapter-content p { margin: 0 0 1.25em; text-align: justify; }
.chapter-content > :last-child { margin-bottom: 0; }
.chapter-content ol, .chapter-content ul { margin: .6em 0 1.2em; padding-left: 2em; }
.chapter-content li { margin: 0 0 .8em; }
.chapter-content ol.parenthesized > li::marker { content: "(" counter(list-item) ") "; }
.chapter-content .list-group { margin: .6em 0 1.2em; }
.chapter-content .list-group > ol, .chapter-content .list-group > ul { margin: 0; }
.list-group .source-original, .table-group .source-original { white-space: pre-line; }
.table-group { margin: 1.1em 0 1.4em; overflow-x: auto; }
.reading-table { width: 100%; border-collapse: collapse; font-size: .88em; line-height: 1.55; }
.reading-table th, .reading-table td { padding: .45em .65em; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.reading-table th { background: color-mix(in srgb, var(--ink) 5%, var(--paper)); font-weight: 700; }
.reading-table td:not(:first-child), .reading-table th:not(:first-child) { width: 18%; text-align: center; }
.table-group > .source-toggle { margin-top: .45em; }
.chapter-content blockquote { margin: 1.8em 0; padding: .25em 0 .25em 1.3em; border-left: 3px solid var(--accent); color: var(--muted); }
.meditation-entry { margin: 0 0 1.2em; }
.chapter-content .meditation-entry p { margin: 0 0 .3em; }
.chapter-content .meditation-entry ol, .chapter-content .meditation-entry ul { margin: .2em 0 .4em; }
.chapter-content .meditation-entry li { margin-bottom: .15em; }
.meditation-entry .source-original { white-space: pre-line; }
.quote-group .quote-line { display: block; }
.quote-group .source-toggle { display: inline-grid; margin-top: .45em; }
.quote-group .source-original { white-space: pre-line; }
.chapter-content pre { padding: 18px; overflow-x: auto; border-radius: 8px; background: color-mix(in srgb, var(--ink) 6%, transparent); font-size: .8em; }
.chapter-content figure { margin: 1.2em 0; text-align: center; }
.chapter-content h1 + figure { margin-top: .5em; }
.chapter-content figure img { max-width: 100%; max-height: 72vh; border-radius: 3px; }
.illustrated-dialogue { display: flex; margin: 0 0 1.25em; align-items: flex-start; gap: .65em; }
.illustrated-dialogue > img { width: 3em; height: 3em; flex: none; object-fit: contain; }
.chapter-content .illustrated-dialogue > p { min-width: 0; margin: 0; }
.chapter-content figcaption { max-width: 92%; margin: 8px auto 0; color: var(--muted); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif; font-size: clamp(11px, .6em, 13px); line-height: 1.55; text-align: center; }
.note-reference { padding: 0 .08em; border: 0; border-radius: .18em; background: color-mix(in srgb, var(--toc-link) 22%, transparent); color: var(--note-ink); font: inherit; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--note-ink) 50%, transparent); text-underline-offset: .15em; cursor: pointer; }
.note-reference:hover, .note-reference:focus-visible { background: color-mix(in srgb, var(--toc-link) 36%, transparent); outline: 2px solid var(--note-ink); }
.notes-panel { position: fixed; z-index: 90; width: min(360px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow-y: auto; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", sans-serif; }
.note-card { position: relative; padding: 18px 42px 18px 18px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); box-shadow: 0 12px 36px rgba(24, 17, 12, .2); }
.note-close { position: absolute; top: 7px; right: 9px; width: 30px; height: 30px; border: 0; border-radius: 7px; background: transparent; color: var(--muted); font-size: 25px; line-height: 1; cursor: pointer; }
.note-close:hover, .note-close:focus-visible { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.note-card p { margin: 0; color: var(--note-ink); font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif; font-size: 15px; line-height: 1.65; text-align: left; }
.note-card p + p { margin-top: .8em; }
.note-card a { color: var(--toc-link); font-weight: 700; text-decoration: underline; text-underline-offset: .14em; }
.note-card a:hover, .note-card a:focus-visible { color: var(--accent); }
.note-card .source-toggle { width: 20px; height: 20px; margin-top: .45em; }
.note-card .source-original { font-size: 13px; }
.source-toggle { display: inline-grid; width: 1.25em; height: 1.25em; margin-left: .12em; padding: 0; vertical-align: .08em; place-items: center; border: 0; border-radius: 4px; background: transparent; color: var(--translation-marker); line-height: 1; cursor: pointer; }
.source-toggle:hover, .source-toggle:focus-visible { background: color-mix(in srgb, var(--translation-marker) 12%, transparent); color: var(--translation-marker); outline: none; }
.source-toggle:disabled { opacity: .55; cursor: wait; }
.source-toggle svg { width: .82em; height: .82em; fill: currentColor; transition: transform .18s ease; }
.source-toggle.loading svg { animation: source-toggle-pulse .8s ease-in-out infinite alternate; }
.source-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
@keyframes source-toggle-pulse { to { opacity: .35; } }
.source-original { display: block; margin: .7em 0 .25em; padding: .75em 1em; border-left: 2px solid color-mix(in srgb, var(--accent) 36%, transparent); background: color-mix(in srgb, var(--ink) 3.5%, transparent); color: var(--ink); font-family: Georgia, "Times New Roman", serif; font-size: .82em; line-height: 1.65; text-align: left; }
.inline-toc-item { margin: .5em 0; }
.inline-toc-link { display: flex; width: 100%; padding: .72em .85em; border: 0; border-radius: 9px; background: color-mix(in srgb, var(--ink) 4%, transparent); color: var(--ink); text-align: left; cursor: pointer; flex-direction: column; }
.inline-toc-link:hover { background: color-mix(in srgb, var(--accent) 10%, transparent); color: var(--accent); }
.inline-toc-link .toc-source-title { margin-bottom: .2em; font-size: .7em; }
.chapter-navigation { display: grid; width: min(calc(var(--reader-shell-width) - 40px), 980px); padding: 14px 0 90px; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; border-top: 1px solid var(--line); }
.chapter-navigation-top { padding: 18px 0 0; border-top: 0; }
.chapter-navigation-top + .chapter-content { padding-top: 28px; }
.chapter-nav-button { display: flex; min-width: 0; min-height: 76px; padding: 10px 14px; align-items: center; gap: 10px; border: 1px solid var(--line); border-radius: 12px; background: transparent; text-align: left; cursor: pointer; }
.chapter-nav-button.next { text-align: right; }
.chapter-nav-button > span { flex: none; align-self: center; color: var(--accent); font-size: 16px; font-weight: 700; }
.chapter-nav-button strong { display: flex; min-width: 0; min-height: 2.8em; overflow: hidden; flex: 1; justify-content: center; flex-direction: column; gap: 2px; font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", sans-serif; font-size: 16px; font-weight: 500; line-height: 1.3; }
.chapter-nav-button strong > span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chapter-nav-source { color: var(--muted); font-size: .82em; }
.chapter-nav-translated { color: var(--ink); font-weight: 600; }
.chapter-nav-button.next { justify-content: flex-end; }
.chapter-nav-button:hover:not(:disabled) { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.chapter-nav-button:disabled { opacity: .4; cursor: default; }
.appearance-panel { position: fixed; z-index: 50; top: 53px; right: calc(25vw + 18px); width: 220px; padding: 13px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--paper) 94%, transparent); box-shadow: 0 18px 48px rgba(0,0,0,.18); backdrop-filter: blur(22px); }
.font-controls { display: grid; margin-bottom: 12px; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; }
.font-controls button { height: 40px; border: 0; background: transparent; cursor: pointer; }
.font-controls button:first-child { border-right: 1px solid var(--line); font-size: 13px; }
.font-controls button:last-child { font-size: 20px; }
.theme-controls { display: flex; justify-content: space-around; }
.theme-swatch { width: 36px; height: 36px; border: 2px solid transparent; border-radius: 50%; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.theme-swatch.paper { background: #fffefa; }
.theme-swatch.sepia { background: #f2e7cf; }
.theme-swatch.night { background: #202124; }
.mobile-only { display: none; }

body[data-theme="sepia"] { --ink: #3f3327; --muted: #807161; --surface: #e7d8ba; --paper: #f2e7cf; --toolbar-surface: #ded3c0; --reading-surface: #f2e7cf; --line: rgba(76,58,39,.13); }
body[data-theme="night"] { color-scheme: dark; --accent: #ff7656; --progress: #84dea9; --translation-marker: #d3a282; --toc-link: #8dc5f1; --note-ink: #a8d0ee; --muted: #a6a39d; --surface: #17181a; --paper: #202124; --toolbar-surface: #303134; --reader-gutter: #141517; --reading-surface: #202124; --line: rgba(255,255,255,.1); }
.scrim { position: fixed; z-index: 28; inset: 60px 0 0; background: rgba(0,0,0,.28); backdrop-filter: blur(2px); }

@media (max-width: 1240px), (min-width: 761px) and (max-width: 1440px) and (any-pointer: coarse) {
}

@media (min-width: 761px) and (max-width: 1440px) and (any-pointer: coarse) {
  .reader-view { --reader-shell-width: 100%; background: var(--reading-surface); }
  .reader-layout::before { width: 100%; box-shadow: none; }
  .library-view, .notes-view { width: 100%; margin: 0; box-shadow: none; }
  .home-tabs { right: 0; left: 0; }
  .chapter-content, .chapter-navigation { width: min(calc(100% - 48px), 900px); }
  .toc-panel { top: calc(50% + 30px); left: 12px; width: min(88vw, 340px); height: min(680px, calc(100vh - 92px)); border-radius: 16px; transform: translate(-12px, -50%) scale(.985); transform-origin: center left; }
  .toc-panel.open { transform: translate(0, -50%) scale(1); }
  .appearance-panel { right: 18px; }
}

@media (max-width: 760px) {
  body { background: var(--surface); }
  .reader-view { --reader-shell-width: 100%; background: var(--reading-surface); }
  .reader-layout::before { width: 100%; box-shadow: none; }
  .library-view, .notes-view { width: 100%; margin: 0; padding: 12px 16px 96px; box-shadow: none; }
  .home-tabs { right: 0; left: 0; padding-right: 16px; padding-left: 16px; }
  .library-header { margin-bottom: 10px; }
  .search-box { width: 100%; }
  .book-card, .book-skeleton { padding: 15px 0; gap: 16px; }
  .book-cover, .book-skeleton > i { width: 72px; }
  .book-info > strong { font-size: 16px; }
  .book-info > span, .book-info > small { font-size: 13px; }
  .book-skeleton-info { width: min(100% - 88px, 420px); }
  .reader-toolbar { grid-template-columns: 1fr minmax(0, 1.4fr) 1fr; padding: 0 10px; }
  .appearance-panel { right: 10px; }
  .back-button span { display: none; }
  .mobile-only { display: inline-flex; }
  .toc-panel { top: calc(50% + 30px); left: 12px; width: min(88vw, 340px); height: min(680px, calc(100vh - 92px)); border-radius: 16px; transform: translate(-12px, -50%) scale(.985); transform-origin: center left; }
  .toc-panel.open { transform: translate(0, -50%) scale(1); }
  .reading-scroll { height: calc(100vh - 60px); }
  .chapter-content, .chapter-navigation { width: calc(100% - 32px); }
  .chapter-content { padding-top: 52px; line-height: 1.85; }
  .chapter-navigation-top + .chapter-content { padding-top: 24px; }
  .chapter-content h1 { margin-bottom: 1.5em; font-size: 34px; }
  .chapter-navigation { padding-bottom: 55px; gap: 8px; }
  .chapter-navigation-top { padding-bottom: 0; }
  .chapter-nav-button { min-height: 52px; padding: 8px; gap: 5px; }
  .chapter-nav-button span { font-size: 12px; }
  .chapter-nav-button strong { font-size: 13px; }
}

@media (prefers-reduced-motion: reduce) {
  .book-skeleton > i, .book-skeleton-info > *, .reader-loading::before { animation: none; }
}
