@import url("./app.css");

.library-shell { padding-top: 20px; }
.library-tools { display: flex; justify-content: flex-end; }
.library-contact { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 8px; color: var(--ink-soft); font-size: 13px; white-space: nowrap; }
.library-contact:hover { color: var(--accent); }
.library-contact:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.library-hero { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr); align-items: center; gap: 48px; padding: 8px 0 24px; border-bottom: 1px solid var(--line); }
.library-hero h1 { max-width: 650px; margin: 12px 0; font-family: var(--serif); font-size: clamp(32px, 4vw, 48px); font-weight: 500; letter-spacing: -0.02em; line-height: 1.2; }
.library-greeting { margin: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.library-activate { margin-top: 20px; }
.library-hero__note { max-width: 560px; margin: 0; color: var(--ink-soft); font-family: var(--serif); font-size: 16px; line-height: 1.8; }

.continue-reading { position: relative; padding: 22px 26px; border: 1px solid var(--line); background: var(--paper-warm); }
.continue-reading::before { position: absolute; top: -1px; left: -1px; width: 3px; height: calc(100% + 2px); background: var(--accent); content: ""; }
.continue-reading h2 { margin: 14px 0 8px; font-family: var(--serif); font-size: 24px; line-height: 1.4; text-wrap: balance; }
.continue-reading p { margin: 0; color: var(--ink-soft); font-size: 13px; }
.progress-track { height: 2px; margin: 24px 0 12px; overflow: hidden; background: var(--line-strong); }
.progress-track span { display: block; width: var(--progress, 0%); height: 100%; background: var(--accent); }
.continue-reading__footer { display: flex; align-items: center; justify-content: space-between; color: var(--ink-faint); font-size: 12px; }

.library-grid { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 56px; padding-top: 24px; }
.library-catalog { min-width: 0; }
.library-catalog > .section-label { gap: 16px; margin-bottom: 12px; }
.library-catalog .catalog-count { flex-shrink: 0; color: var(--ink-faint); font-size: 12px; font-variant-numeric: tabular-nums; }
.catalog-nav-label { margin: 0 0 6px; color: var(--ink-faint); font-size: 12px; line-height: 1.6; letter-spacing: .06em; }
.catalog-jump { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0 0 24px; padding-bottom: 16px; border-bottom: 1px solid var(--line); }
.catalog-jump a { display: inline-flex; align-items: center; min-width: 44px; min-height: 44px; max-width: 100%; padding: 6px 0; border-bottom: 1px solid transparent; color: var(--ink-soft); font-family: var(--sans); font-size: 14px; line-height: 1.6; overflow-wrap: anywhere; transition: color 150ms ease, border-color 150ms ease; }
.catalog-jump a:hover, .catalog-jump a[aria-current="location"] { color: var(--accent); border-bottom-color: var(--accent); }
.catalog-jump a:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.catalog-group { padding: 24px 0; border-top: 1px solid var(--line); scroll-margin-top: 140px; }
.catalog-group:target { border-top-color: var(--accent); }
.catalog-group:first-child { border-top-color: var(--line-strong); }
.catalog-group h3 { margin: 0 0 16px; color: var(--ink); font-family: var(--serif); font-size: 21px; font-weight: 600; }
.catalog-module { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 650; letter-spacing: .14em; }
.catalog-chapter + .catalog-chapter { margin-top: 24px; }
.catalog-chapter h4 { margin: 0 0 6px; color: var(--ink-faint); font-size: 12px; font-weight: 600; letter-spacing: .04em; }
.catalog-list { display: grid; gap: 2px; }
.catalog-link { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; min-height: 44px; padding: 11px 8px; color: var(--ink-soft); font-family: var(--serif); font-size: 17px; line-height: 1.6; overflow-wrap: anywhere; transition: color 150ms ease, background 150ms ease; }
.catalog-link > span { min-width: 0; flex: 1; }
.catalog-link::after { color: var(--line-strong); content: "→"; font-family: var(--sans); }
.catalog-link:hover { color: var(--accent); background: var(--paper-soft); }
.catalog-link--reading { background: var(--accent-pale); }
.catalog-link--read { color: var(--ink-faint); }
.catalog-status { flex: 0 0 auto; font-family: var(--sans); font-size: 12px; font-weight: 600; }
.catalog-status--reading { color: var(--accent); }
.library-catalog .catalog-group { padding: 30px 0 34px; }
.library-catalog .catalog-group h3 { margin-bottom: 24px; font-size: 22px; line-height: 1.5; }
.library-catalog .catalog-module { margin-bottom: 6px; font-size: 12px; letter-spacing: .04em; }
.library-catalog .catalog-chapter + .catalog-chapter { margin-top: 30px; }
.library-catalog .catalog-chapter h4 { display: flex; align-items: baseline; gap: 16px; margin-bottom: 10px; color: var(--ink-soft); font-size: 14px; line-height: 1.7; letter-spacing: 0; }
.library-catalog .catalog-chapter h4::after { content: ""; flex: 1; min-width: 24px; border-bottom: 1px solid var(--line); }
.library-catalog .catalog-link { gap: 16px; padding: 12px 0; }
.library-catalog .catalog-link::after { color: var(--ink-faint); font-size: 13px; }
.library-aside { padding-top: 4px; }
.update-item { padding: 18px 0; border-top: 1px solid var(--line); }
.update-item time { display: block; margin-bottom: 8px; color: var(--ink-faint); font-size: 11px; letter-spacing: 0.08em; }
.update-item a { font-family: var(--serif); font-size: 16px; line-height: 1.6; }
.update-item > span { font-family: var(--serif); font-size: 16px; line-height: 1.6; }
.update-item p { margin: 7px 0 0; color: var(--ink-faint); font-size: 12px; line-height: 1.65; }

.reader-page { min-height: 100vh; background: #fff; }
.reader-progress { position: fixed; z-index: 80; top: 0; left: 0; width: var(--reading-progress, 0%); height: 2px; background: var(--accent); transition: width 120ms linear; }
.reader-header { position: sticky; z-index: 60; top: 0; display: grid; height: 68px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.95); grid-template-columns: 280px 1fr 280px; align-items: center; backdrop-filter: blur(14px); }
.reader-brand { display: flex; align-items: center; gap: 14px; }
.reader-brand .wordmark, .reader-tool { white-space: nowrap; }
.reader-home-button { flex-shrink: 0; }
.reader-home-button { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--accent); font-family: var(--sans); font-size: 20px; line-height: 1; transition: border-color 150ms ease, background 150ms ease, transform 150ms ease; }
.reader-home-button:hover { border-color: var(--accent); background: var(--accent-pale); transform: translateX(-2px); }
.reader-home-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.reader-header__center { overflow: hidden; color: var(--ink-soft); font-family: var(--serif); font-size: 14px; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.reader-tools { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.reader-tool { display: grid; min-width: 36px; height: 36px; padding: 0 10px; place-items: center; border: 1px solid transparent; border-radius: 3px; color: var(--ink-soft); background: transparent; cursor: pointer; font-size: 13px; }
.reader-tool:hover { border-color: var(--line); color: var(--ink); background: var(--paper-soft); }
.toc-toggle, .toc-close { display: none; }

.reader-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.reader-sidebar { position: sticky; top: 68px; height: calc(100vh - 68px); padding: 36px 26px 60px 34px; overflow-y: auto; border-right: 1px solid var(--line); background: var(--paper); }
.reader-sidebar[hidden], .toc-backdrop[hidden] { display: none; }
.toc-backdrop { position: fixed; z-index: 65; inset: 0; background: rgba(0, 0, 0, .35); }
.reader-sidebar__label { margin: 0 0 18px; color: var(--ink-faint); font-size: 11px; font-weight: 650; letter-spacing: .14em; }
.reader-toc { display: grid; gap: 2px; }
.reader-toc__volume + .reader-toc__volume { margin-top: 28px; }
.reader-toc__volume h2 { margin: 0 0 14px; color: var(--ink); font-family: var(--serif); font-size: 16px; font-weight: 600; line-height: 1.5; }
.reader-toc__chapter + .reader-toc__chapter { margin-top: 18px; }
.reader-toc__chapter h3 { margin: 0 0 7px; color: var(--ink-faint); font-size: 10px; font-weight: 650; letter-spacing: .04em; line-height: 1.5; }
.reader-toc a { display: flex; justify-content: space-between; gap: 12px; padding: 9px 12px; border-left: 1px solid var(--line); color: var(--ink-soft); font-family: var(--serif); font-size: 14px; line-height: 1.45; }
.reader-toc a:hover { color: var(--accent); }
.reader-toc a.catalog-link--read { color: var(--ink-faint); }
.reader-toc a[aria-current="page"] { border-left: 2px solid var(--accent); color: var(--ink); background: var(--accent-pale); }

.article-stage { position: relative; min-width: 0; padding: 48px 40px 90px; }
.article-wrap { position: relative; z-index: 2; width: min(100%, var(--article-width)); margin: 0 auto; }
.article-kicker { margin-bottom: 20px; color: var(--accent); font-size: 12px; letter-spacing: .12em; }
.article-title { margin: 0; font-family: var(--serif); font-size: clamp(28px, 3.2vw, 36px); font-weight: 600; letter-spacing: -.025em; line-height: 1.3; }
.article-meta { display: flex; flex-wrap: wrap; gap: 10px 18px; margin: 18px 0 36px; color: var(--ink-faint); font-size: 12px; overflow-wrap: anywhere; }
.article-body { color: #252525; font-family: var(--serif); font-size: var(--article-font-size); line-height: 2; letter-spacing: .015em; }
.article-body p { margin: 0 0 1.1em; }
.article-body h2 { margin: 2em 0 .7em; color: var(--ink); font-family: var(--sans); font-size: 1.2em; font-weight: 700; line-height: 1.5; }
.article-body h3 { margin: 1.7em 0 .6em; color: var(--ink); font-family: var(--sans); font-size: 1.1em; font-weight: 700; line-height: 1.5; }
.article-body strong { font-weight: 700; }
.article-body :is(ul, ol) { margin: .8em 0 1.3em; padding-inline-start: 1.6em; }
.article-body li { margin: 0 0 .45em; }
.article-body > :is(h2, h3):first-child { margin-top: 0; }
.article-body > :last-child { margin-bottom: 0; }
.article-body blockquote { margin: 2em 0; padding: 4px 0 4px 24px; border-left: 2px solid var(--accent); color: var(--ink-soft); }
.article-body img { max-width: 100%; height: auto; margin: 28px auto; }
.article-body table { width: 100%; margin: 32px 0; border-collapse: collapse; font-family: var(--sans); font-size: 14px; }
.article-body th, .article-body td { padding: 12px 14px; border: 1px solid var(--line-strong); text-align: left; }
.article-body th { background: var(--paper-soft); }
.article-body :is(th, td) :is(p, h2, h3) { margin: 0 0 .5em; font-size: inherit; line-height: 1.65; }
.article-body :is(th, td) > :last-child { margin-bottom: 0; }
.article-table-scroll { max-width: 100%; overflow-x: auto; margin: 32px 0; }
.article-table-scroll > table { margin: 0; }

.watermark-layer { position: fixed; z-index: 5; inset: 68px 0 0 300px; display: grid; grid-template: repeat(4, 1fr) / repeat(2, minmax(0, 1fr)); align-items: center; justify-items: center; pointer-events: none; user-select: none; overflow: hidden; }
.watermark-layer span { color: rgba(70, 37, 40, .09); font-family: var(--sans); font-size: 12px; letter-spacing: .06em; transform: rotate(-22deg); white-space: nowrap; animation: watermark-drift 37s ease-in-out infinite alternate; }
.watermark-layer span:nth-child(even) { animation-delay: -19s; }
@keyframes watermark-drift { from { transform: translate(-7px, -4px) rotate(-22deg); } to { transform: translate(7px, 4px) rotate(-22deg); } }
.reader-copyright { margin-top: 32px; color: var(--ink-soft); font-size: 12px; }
.article-body .reading-trace-mark { display: inline; margin-inline-start: .8em; font: 9px/1.2 var(--sans); letter-spacing: .04em; color: rgba(70, 37, 40, .23); white-space: nowrap; vertical-align: baseline; user-select: none; }
.reading-protection-notice { padding: 12px 16px; border-left: 2px solid var(--line-strong); color: var(--ink-soft); font: 13px/1.7 var(--sans); }
[data-theme="night"] .article-body .reading-trace-mark { color: rgba(230, 222, 216, .23); }
.reader-status { min-height: 1.6em; color: var(--accent); font-size: 13px; }
.reader-status:not(:empty) { position: fixed; z-index: 85; bottom: 20px; right: 20px; width: min(320px, calc(100vw - 40px)); margin: 0; padding: 12px 16px; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--ink); background: var(--paper); box-shadow: 0 6px 24px rgba(0,0,0,.08); font-family: var(--sans); line-height: 1.6; }
.reader-print-notice { display: none; }
.reader-tool:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.reader-tool:disabled { opacity: .55; cursor: wait; }
.article-body { overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .watermark-layer span { animation: none; } }
@media print {
  .reader-page .article-body, .reader-header, .reader-sidebar, .article-footer { display: none !important; }
  .reader-print-notice { display: block; }
}

.article-footer { display: grid; margin-top: 80px; padding-top: 28px; border-top: 1px solid var(--line); grid-template-columns: 1fr 1fr; gap: 40px; }
.article-footer a { color: var(--ink-soft); font-family: var(--serif); font-size: 15px; line-height: 1.6; }
.article-footer a:last-child { text-align: right; }
.article-footer small { display: block; margin-bottom: 6px; color: var(--ink-faint); font-family: var(--sans); font-size: 10px; letter-spacing: .1em; }

[data-theme="night"] { --paper: #171819; --paper-soft: #202123; --paper-warm: #1c1d1f; --ink: #ecebea; --ink-soft: #b3b2ae; --ink-faint: #a3a59f; --accent: #e69ba6; --accent-pale: #322528; --line: #2d2e30; --line-strong: #3a3b3d; }
[data-theme="night"] ::selection { color: var(--ink); background: #59353c; }
[data-theme="night"] body, [data-theme="night"] .reader-page, [data-theme="night"] .reader-sidebar { background: var(--paper); }
[data-theme="night"] .reader-header { background: rgba(23,24,25,.94); }
[data-theme="night"] .article-body { color: #d8d6d2; }
[data-theme="night"] .watermark-layer span { color: rgba(230, 222, 216, .09); }

@media (max-width: 980px) {
  .library-hero { grid-template-columns: 1fr; gap: 28px; }
  .library-grid { grid-template-columns: 1fr; gap: 54px; }
  .reader-header { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
  .reader-header__center { display: none; }
  .reader-layout { display: block; }
  .watermark-layer { left: 0; }
  .reader-sidebar { position: fixed; z-index: 70; top: 0; left: 0; width: min(86vw, 340px); height: 100dvh; padding-top: 84px; padding-bottom: max(32px, env(safe-area-inset-bottom)); box-shadow: 24px 0 70px rgba(0,0,0,.12); overscroll-behavior: contain; }
  .reader-tool { min-width: 44px; height: 44px; padding: 0 6px; }
  .reader-home-button { width: 44px; height: 44px; }
  .toc-toggle { display: grid; }
  .toc-close { display: grid; position: absolute; top: 20px; right: 20px; }
}

@media (max-width: 760px) {
  .library-shell { padding-top: 8px; }
  .library-hero h1 { font-size: 32px; }
  .article-table-scroll--wide > table { min-width: 600px; }
  .article-table-scroll--wide::before { content: "左右滑动查看完整表格"; position: sticky; left: 0; display: block; margin-bottom: 8px; color: var(--ink-faint); font-family: var(--sans); font-size: 12px; line-height: 1.6; }
}

@media (max-width: 640px) {
  :root { --article-font-size: 19px; }
  .library-hero { padding: 4px 0 20px; }
  .continue-reading { padding: 26px 24px 22px; }
  .continue-reading h2 { font-size: 20px; line-height: 1.6; }
  .library-grid { padding-top: 28px; }
  .catalog-jump { gap: 4px 20px; padding-bottom: 16px; }
  .catalog-jump a { font-size: 13px; }
  .library-catalog .catalog-group { padding: 24px 0 28px; }
  .library-catalog .catalog-group h3 { font-size: 20px; margin-bottom: 20px; }
  .library-catalog .catalog-link { font-size: 16px; gap: 10px; }
  .reader-header { height: 60px; padding: 0 16px; }
  .watermark-layer { top: 60px; }
  .watermark-layer span { font-size: 10px; }
  .reader-brand { gap: 10px; }
  .reader-header .wordmark { font-size: 28px; }
  .reader-sidebar { top: 0; }
  .article-stage { padding: 40px 22px 80px; }
  .article-title { font-size: 28px; }
  .article-meta { margin-bottom: 30px; }
  .article-body { line-height: 1.95; }
  .article-footer { grid-template-columns: 1fr; gap: 22px; }
  .article-footer a:last-child { text-align: left; }
}

@media (max-width: 420px) {
  .reader-header { padding: 0 10px; }
  .reader-header .wordmark { display: none; }
  .reader-brand { gap: 6px; }
  .reader-tools { gap: 2px; }
}
