:root {
  color-scheme: light;
  --ink: #182739;
  --muted: #526174;
  --blue: #245684;
  --blue-dark: #153858;
  --line: #dce3eb;
  --surface: #f1f4f7;
  --topbar-height: 64px;
  --sidebar-width: 266px;
  --toolbar-height: 54px;
  font-family: 'Microsoft YaHei', 'PingFang SC', 'Noto Sans CJK SC', system-ui, sans-serif;
  color: var(--ink);
  background: var(--surface);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid #3676ae; outline-offset: 3px; }
html { scroll-padding-top: calc(var(--topbar-height) + var(--toolbar-height) + 18px); }

.skip-link {
  position: fixed;
  top: 8px;
  left: 12px;
  z-index: 20;
  padding: 10px 14px;
  background: #fff;
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: #fff;
  border-bottom: 1px solid var(--line);
}
.topbar-content {
  min-height: calc(var(--topbar-height) - 1px);
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.identity, .brand, .copy-button, .directory-toggle, .page-tools {
  display: flex;
  align-items: center;
}
.identity { min-width: 0; gap: 17px; }
.brand { flex: none; gap: 11px; font-size: 16px; font-weight: 700; }
.paper-icon {
  position: relative;
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: #1e456b;
}
.paper-icon::before {
  content: '';
  width: 13px;
  height: 16px;
  border: 1.5px solid #fff;
  border-radius: 2px;
}
.paper-icon::after {
  content: '';
  position: absolute;
  top: 13px;
  left: 12px;
  width: 8px;
  height: 5px;
  border-block: 1px solid #fff;
}
.file-title {
  padding-left: 17px;
  border-left: 1px solid var(--line);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 14px;
}
.copy-button, .directory-toggle {
  justify-content: center;
  gap: 7px;
  flex: none;
  border: 1px solid #cdd9e5;
  border-radius: 6px;
  background: #fff;
  color: var(--blue-dark);
  padding: 0 13px;
  min-height: 37px;
  font-size: 13px;
  font-weight: 600;
}
.copy-button:hover, .directory-toggle:hover, .page-button:not(:disabled):hover { background: #edf4fb; }
.link-icon { position: relative; width: 15px; height: 15px; transform: rotate(-43deg); }
.link-icon::before, .link-icon::after {
  content: '';
  position: absolute;
  left: 4px;
  width: 7px;
  height: 9px;
  border: 1.4px solid currentColor;
  border-radius: 6px;
}
.link-icon::before { top: 0; border-bottom-color: transparent; }
.link-icon::after { bottom: 0; border-top-color: transparent; }

.workspace { display: grid; grid-template-columns: var(--sidebar-width) minmax(0, 1fr); min-height: calc(100dvh - var(--topbar-height)); }
.sidebar {
  position: sticky;
  top: var(--topbar-height);
  align-self: start;
  display: flex;
  flex-direction: column;
  min-height: calc(100dvh - var(--topbar-height));
  max-height: calc(100dvh - var(--topbar-height));
  background: #fbfcfe;
  border-right: 1px solid var(--line);
  padding: 29px 19px 28px;
  font-size: 13px;
}
.sidebar > nav:first-child { display: flex; flex-direction: column; min-height: 0; }
.side-heading { margin: 0 10px 13px; font-size: 14px; font-weight: 700; }
.outline { list-style: none; margin: 0; padding: 3px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.outline li + li { margin-top: 2px; }
.outline a, .resource {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 37px;
  padding: 8px 10px;
  border-radius: 5px;
  text-decoration: none;
  line-height: 1.5;
}
.outline a { border-left: 3px solid transparent; color: #3d4d60; }
.outline a:hover, .resource:hover { background: #eef2f7; }
.outline a[aria-current] { border-left-color: #346b9c; background: #e8f0fa; color: #214e76; font-weight: 700; }
.outline .subsection a { padding-left: 24px; }
.related { flex: none; margin-top: 18px; padding-top: 17px; border-top: 1px solid var(--line); }
.resource { justify-content: space-between; color: var(--blue-dark); }
.resource-offsite { font-size: 15px; flex: none; line-height: 1; color: var(--muted); }

.reader { min-width: 0; }
.reader-toolbar {
  position: sticky;
  top: var(--topbar-height);
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--toolbar-height);
  padding: 0 max(25px, calc((100% - 796px) / 2));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.view-label { font-weight: 700; font-size: 13px; color: var(--muted); }
.directory-toggle { display: none; }
.menu-icon { width: 12px; height: 10px; border-block: 1px solid currentColor; }
.menu-icon::after { content: ''; display: block; margin-top: 3px; border-top: 1px solid currentColor; }
.page-tools { gap: 5px; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.pagination { margin-right: 6px; white-space: nowrap; }
#current-page { color: var(--ink); font-weight: 700; }
.pagination-divider { margin: 0 3px; color: #78889a; }
.page-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid #ccd7e3;
  border-radius: 5px;
  background: #fff;
  color: var(--blue-dark);
}
.page-button:disabled { color: #778597; background: #f7f9fb; cursor: default; }
.chevron { width: 7px; height: 7px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; }
.chevron.prev { transform: rotate(135deg); }
.chevron.next { transform: rotate(-45deg); }

.pages { width: min(calc(100% - 50px), 796px); margin: 23px auto 48px; }
.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 920px;
  background: #fff;
  border: 1px solid #dae2eb;
  box-shadow: 0 2px 6px rgb(27 53 81 / 6%);
  padding: 58px clamp(28px, 5.2vw, 74px) 24px;
}
.sheet + .sheet { margin-top: 17px; }
.sheet-content {
  flex: 1;
  color: #24282c;
  font-family: 'Noto Serif CJK SC', 'Source Han Serif SC', 'Songti SC', SimSun, 'Microsoft YaHei', serif;
  font-size: 16px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}
.sheet-content h1 { margin: 0 0 29px; text-align: center; font-size: 28px; line-height: 1.35; }
.sheet-content h2, .sheet-content h3 { margin: 17px 0 7px; line-height: 1.55; }
.sheet-content h2 { font-size: 18px; }
.sheet-content h3 { font-size: 16px; }
.sheet-content p { margin: 0 0 9px; text-indent: 2em; }
.sheet-content p.continuation { text-indent: 0; }
.sheet-content p:last-child { margin-bottom: 0; }
.sheet-content :target { color: var(--blue-dark); }
.page-footer { margin: 32px 0 0; color: #657284; text-align: center; font: 12px system-ui, sans-serif; }

.share-dialog { width: min(440px, calc(100% - 32px)); padding: 22px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.share-dialog::backdrop { background: rgb(21 44 67 / 36%); }
.share-dialog h2 { margin: 0 0 15px; font-size: 18px; }
.share-dialog label { display: block; margin-bottom: 7px; font-size: 13px; }
.share-dialog input { width: 100%; margin-bottom: 14px; padding: 9px; border: 1px solid #ccd7e3; border-radius: 4px; }
.copy-feedback { position: fixed; z-index: 8; right: 22px; bottom: 20px; margin: 0; padding: 10px 16px; border-radius: 6px; color: #fff; background: var(--blue-dark); font-size: 14px; }

@media (max-width: 800px) {
  :root { --topbar-height: 56px; }
  .topbar-content { padding: 0 15px; }
  .identity { gap: 9px; }
  .brand { gap: 7px; font-size: 14px; }
  .paper-icon { width: 28px; height: 28px; }
  .paper-icon::after { left: 10px; top: 11px; }
  .file-title { padding-left: 9px; font-size: 13px; }
  .copy-button { min-height: 40px; padding: 0 9px; }
  .workspace { display: block; }
  .sidebar { position: static; min-height: 0; max-height: none; padding: 21px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .outline a, .resource { min-height: 43px; }
  .related { margin-top: 12px; padding-top: 14px; }
  .enhanced .sidebar {
    visibility: hidden;
    position: fixed;
    z-index: 4;
    inset: calc(var(--topbar-height) + var(--toolbar-height)) 0 auto 0;
    max-height: calc(100dvh - var(--topbar-height) - var(--toolbar-height));
    box-shadow: 0 5px 13px rgb(27 53 81 / 14%);
  }
  .enhanced .workspace.directory-open .sidebar { visibility: visible; }
  .enhanced .view-label { display: none; }
  .enhanced .directory-toggle { display: flex; min-height: 42px; }
  .reader-toolbar { padding: 0 14px; }
  .page-button { width: 42px; height: 42px; }
  .pages { width: calc(100% - 20px); margin: 10px auto 25px; }
  .sheet { min-height: 0; padding: 31px clamp(16px, 5vw, 47px) 18px; }
  .sheet + .sheet { margin-top: 11px; }
  .sheet-content { font-size: 16px; line-height: 1.8; }
  .sheet-content h1 { font-size: 24px; margin-bottom: 23px; }
  .page-footer { margin-top: 23px; }
}

@media (max-width: 370px) {
  .brand { font-size: 0; gap: 0; }
}

@media print {
  :root { background: #fff; }
  .topbar, .sidebar, .reader-toolbar, .skip-link, .copy-feedback { display: none !important; }
  .workspace { display: block; }
  .pages { width: auto; margin: 0; }
  .sheet { min-height: auto; border: 0; box-shadow: none; padding: 0; }
  .sheet + .sheet { break-before: page; margin-top: 0; }
}
