:root {
  color-scheme: light;
  --canvas: #f2f2f2;
  --sidebar: #fafafa;
  --paper: #fff;
  --ink: #1a1a1a;
  --muted: #5f5f5f;
  --line: #e3e3e3;
  --line-strong: #bdbdbd;
  --accent: #242424;
  --accent-tint: #ebebeb;
  --accent-dark: #080808;
  --focus: #505050;
  --sidebar-width: 292px;
  --header-height: 60px;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box }
body { margin: 0; background: var(--canvas); color: var(--ink); font-size: 14px }
strong { font-weight: 650 }
a { color: var(--accent); text-decoration-color: var(--muted); text-underline-offset: 3px }
button, input { font: inherit }
button:not(:disabled) { cursor: pointer }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px }
[hidden] { display: none !important }
.sr-only, .skip:not(:focus) { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap }
.skip:focus { position: fixed; z-index: 10; top: 8px; left: 8px; padding: 10px; background: var(--paper) }
.icon { display: inline-block; width: 17px; height: 17px; flex: none; vertical-align: middle }
.icon-button { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; border-radius: 7px; background: transparent; color: var(--ink) }
.icon-button:hover { background: var(--accent-tint) }

.topbar {
  height: var(--header-height); display: flex; align-items: center; gap: 22px;
  padding: 0 24px; background: var(--paper); border-bottom: 1px solid var(--line);
  position: relative; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 780; letter-spacing: .055em; font-size: 21px }
.brand-symbol { width: 29px; height: 29px; position: relative; display: grid; place-items: center; border-radius: 8px; background: var(--accent); overflow: hidden }
.brand-symbol::before, .brand-symbol::after, .brand-symbol span { content: ""; display: block; border: 1px solid var(--paper); position: absolute }
.brand-symbol::before { width: 16px; height: 16px; border-radius: 50%; transform: rotate(-36deg) scaleY(.56) }
.brand-symbol::after { width: 16px; height: 16px; border-radius: 50%; transform: rotate(36deg) scaleY(.56) }
.brand-symbol span { width: 4px; height: 4px; border-radius: 50%; background: var(--paper) }
.version { margin-left: auto; flex: none; padding: 4px 8px; border: 1px solid var(--line); color: var(--muted); border-radius: 5px; font: 600 11px ui-monospace, monospace }
.menu-toggle, .drawer-close { display: none }

.layout { display: grid; grid-template-columns: var(--sidebar-width) 8px minmax(0, 1fr); min-height: 0; height: calc(100dvh - var(--header-height)) }
.sidebar { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--sidebar) }
.sidebar-head { padding: 23px 18px 10px }
.sidebar-label { margin: 0 0 13px; color: var(--ink); font-weight: 700; letter-spacing: .03em }
.search { height: 37px; display: flex; align-items: center; gap: 9px; padding: 0 10px; border: 1px solid var(--line-strong); color: var(--muted); background: var(--paper); border-radius: 8px }
.search:focus-within { border-color: var(--focus); outline: 1px solid var(--focus) }
.search .icon { width: 15px; height: 15px }
.search input { width: 100%; min-width: 0; border: none; background: transparent; outline: none; color: var(--ink); font-size: 13px }
.search input::placeholder { color: var(--muted) }
.search-status { margin: 9px 0 0; font-size: 12px; color: var(--muted) }
.tree { min-height: 0; overflow: auto; padding: 3px 12px 26px; scrollbar-width: thin; scrollbar-gutter: stable; overflow-anchor: none }
.tree details { min-width: 0 }
.tree details > summary { list-style: none }
.tree details > summary::-webkit-details-marker { display: none }
.tree-row { display: flex; align-items: center; gap: 7px; min-height: 34px; border-radius: 7px; color: var(--ink); text-decoration: none; padding: 5px 7px; line-height: 1.35 }
.tree-row:hover { background: var(--canvas) }
.tree-summary { cursor: pointer; user-select: none }
.tree-top > .tree-summary { font-weight: 650 }
.tree-summary .chevron { width: 13px; height: 13px; color: var(--muted); transition: transform 140ms ease }
.tree details[open] > summary .chevron { transform: rotate(90deg) }
.tree-row > .node-icon { color: var(--muted); width: 16px; height: 16px }
.tree-row > span, .tree-node-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.tree-node-link { flex: 1; color: inherit; text-decoration: none }
.tree-node-link:focus-visible { outline-offset: 1px }
.tree-row[aria-current="page"], .tree-summary:has(> [aria-current="page"]) { color: var(--accent-dark); background: var(--accent-tint); box-shadow: inset 2px 0 var(--accent); font-weight: 700 }
.tree-children { margin: 0 0 1px 13px; padding-left: 8px; border-left: 1px solid var(--line) }
.tree-children .tree-row { font-size: 13px }
.tree-leaf > .icon { width: 14px; height: 14px; opacity: .88 }
.tree-secondary { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line) }
.tree-results-label { margin: 0 7px 5px; color: var(--muted); font-weight: 650; font-size: 12px }
.resize { cursor: col-resize; touch-action: none; border-left: 1px solid var(--line); background: linear-gradient(90deg, var(--sidebar), var(--canvas)) }
.resize:hover, .resize.dragging, .resize:focus-visible { background: var(--line-strong) }
.backdrop { display: none }

.reading { min-width: 0; overflow: auto; padding: 44px clamp(24px, 4.7vw, 72px) 75px; scrollbar-width: thin; scrollbar-gutter: stable }
.reading-inner { max-width: 894px; margin: 0 auto }
.breadcrumb { margin-bottom: 14px; color: var(--muted); font-size: 13px; line-height: 1.6 }
.breadcrumb ol { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; margin: 0; padding: 0; list-style: none }
.breadcrumb li { display: flex; align-items: baseline; gap: 8px; min-width: 0; max-width: 100%; overflow-wrap: anywhere }
.breadcrumb a { color: inherit; text-decoration: none }
.breadcrumb a:hover, .breadcrumb a:focus-visible { text-decoration: underline }
.breadcrumb [aria-current="page"] { color: var(--ink); font-weight: 600 }
.breadcrumb svg { align-self: center; width: 12px; height: 12px }
.paper { padding: clamp(26px, 5vw, 58px); background: var(--paper); border: 1px solid var(--line); border-radius: 14px }
.work-header { margin-bottom: 25px }
.work-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-bottom: 25px }
.work-title { margin: 0; overflow-wrap: anywhere; font: 650 clamp(24px, 3.5vw, 41px)/1.38 "Songti SC", "Noto Serif SC", "Noto Serif CJK SC", Georgia, serif; letter-spacing: -.035em }
.work-header .work-subtitle { margin: 11px 0 0; line-height: 1.8; color: var(--muted) }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 11px; min-height: 33px; font-size: 12px; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 7px; text-decoration: none; white-space: nowrap }
.button:hover { background: var(--accent-tint) }
.button .icon { width: 13px; height: 13px }
.button.primary { color: white; background: var(--accent); border-color: var(--accent) }
.button.primary:hover { background: var(--accent-dark) }
.button:disabled { opacity: .55 }
.status { padding: 8px 11px; margin: -7px 0 16px; border-radius: 6px; background: var(--accent-tint); color: var(--accent-dark); font-size: 13px }
.status.error { box-shadow: inset 0 0 0 1px var(--muted); font-weight: 650 }
.quiet { color: var(--muted); line-height: 1.75 }
.work-body { color: var(--ink); font-size: 16px; line-height: 1.8; min-width: 0; overflow-wrap: anywhere }
.work-body p { margin: 0 0 12px }
.work-body ul, .work-body ol { padding-inline-start: 24px }
.work-body figure { margin: 18px 0 }
.work-body table { width: 100%; border-collapse: collapse; overflow-wrap: anywhere }
.work-body :is(th,td) { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top }
.work-body th { background: var(--canvas) }
.work-body img { max-width: 100%; vertical-align: middle; border-radius: 7px }
.work-body img.img-real { object-fit: cover }
.work-body pre { white-space: pre-wrap; overflow: auto }
.work-body .original-prose { margin: 14px 0 }
.work-body .original-prose>.title { margin: 24px 0 8px }
.work-body .original-prose>table { margin: 12px 0 }
.work-body :is(.original-prose,.card-static) .t { line-height: 1.7 }
.work-body :is(.original-prose,.card-static) p { margin: 8px 0 }
.work-body .dil-root.live { color: inherit }
.work-body [data-duplicate-title] { display: none }
.work-body .source-options, .work-body .chart-data { border: 1px solid var(--line); margin: 16px 0; border-radius: 7px; padding: 8px 12px }
.work-body .source-options summary { font-weight: 650; cursor: pointer }
.work-body .option-content { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 7px }
.work-body .gallery { display: flex; flex-wrap: wrap; gap: 9px; margin: 12px 0 }
.work-body .gallery img { width: min(34vw, 210px); height: auto }
.work-body .card-host { position: relative; margin: 16px 0 }
/* Keep the frame in the viewport while Chromium measures it, even for tall placeholders. */
.work-body .card-frame { display: block; position: absolute; opacity: 0; pointer-events: none; border: 0; width: 100%; height: 100%; min-height: 1px; top: 0; left: 0 }
.work-body .card-host.live .card-static { display: none }
.work-body .card-host.live .card-frame { position: static; opacity: 1; pointer-events: auto }
.work-body .ab-frame { display: block; width: 100%; height: 450px; border: 1px solid var(--line); border-radius: 8px }
.work-body .appblock figcaption { display: flex; gap: 12px; align-items: center; margin-bottom: 6px }
.work-body .appblock .ab-open { border: 1px solid var(--line-strong); background: var(--paper); color: var(--ink); border-radius: 6px }
.work-footer { display: flex; flex-wrap: wrap; gap: 10px 15px; align-items: center; margin-top: 25px; padding-top: 15px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted) }
.archive-prompt { margin: 23px 0; padding: 15px 18px; background: var(--canvas); border-radius: 9px; line-height: 1.7; white-space: pre-wrap }
.archive-prompt h2 { margin: 0 0 7px; font-size: 13px; color: var(--accent-dark) }
.archive-prompt .attachments { display: flex; flex-wrap: wrap; gap: 6px }
.chip { border: 1px solid var(--line-strong); padding: 2px 7px; font-size: 12px; border-radius: 5px }
.archive-list { padding: 0; margin: 20px 0 0; list-style: none }
.archive-list a { display: flex; align-items: baseline; gap: 15px; padding: 11px 3px; text-decoration: none; border-bottom: 1px solid var(--line); color: var(--ink) }
.archive-list a:hover { color: var(--accent); text-decoration: underline }
.archive-list .turn-no { color: var(--muted); font: 12px ui-monospace, monospace }
.overview-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 24px 0 0 }
.overview-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; color: var(--ink); background: var(--sidebar); text-decoration: none }
.overview-card:hover { border-color: var(--focus) }
.overview-card .icon { color: var(--accent); margin-right: 5px }
.overview-card small { display: block; color: var(--muted); line-height: 1.7; margin-top: 6px }
.omissions { margin: 0; padding-left: 20px; line-height: 1.7 }
.omissions li { margin-bottom: 11px; overflow-wrap: anywhere }

@media (max-width: 820px) {
  :root { --header-height: 54px }
  .topbar { padding: 0 12px; gap: 12px }
  .brand { font-size: 18px; gap: 7px }
  .brand-symbol { width: 25px; height: 25px }
  .menu-toggle, .drawer-close { display: inline-grid }
  .menu-toggle { width: 31px }
  .layout { display: block }
  .reading { height: 100%; padding: 14px 11px 40px }
  .breadcrumb { margin-bottom: 10px; font-size: 12px }
  .paper { border-radius: 11px; padding: 20px 17px 24px }
  .work-header { margin-bottom: 17px }
  .work-actions { margin-bottom: 17px }
  .sidebar { position: fixed; z-index: 6; left: 0; top: var(--header-height); bottom: 0; width: min(87vw, 332px); transform: translateX(-100%); visibility: hidden; transition: transform 160ms ease, visibility 160ms; border-right: 1px solid var(--line) }
  .sidebar-head { padding: 18px 15px 10px; position: relative }
  .drawer-close { position: absolute; right: 10px; top: 9px }
  .layout.drawer-open .sidebar { transform: translateX(0); visibility: visible }
  .backdrop { display: block; position: fixed; z-index: 5; inset: var(--header-height) 0 0; border: 0; background: #0006 }
  .resize { display: none }
  .work-body { font-size: 15px }
  .work-body table { display: block; overflow-x: auto; white-space: normal }
}
@media (max-width: 380px) {
  .overview-grid { grid-template-columns: 1fr }
  .button { padding-inline: 8px }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important }
}
@media print {
  .topbar, .sidebar, .resize, .breadcrumb, .work-actions, .card-frame, .work-footer, .work-outline, .backdrop { display: none !important }
  .layout, .reading { height: auto; display: block; overflow: visible; padding: 0 }
  .paper { padding: 0; border: 0 }
  .work-body .card-host.live .card-static { display: block }
}
.work-outline { margin: 0 0 20px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 7px; line-height: 1.65 }
.work-outline > summary { cursor: pointer; font-weight: 650 }
.work-outline ol { margin: 2px 0; padding-inline-start: 16px; list-style: none }
.work-outline > ol { margin-top: 6px }
.entry-related { margin-top: 25px }
.entry-related h2 { margin: 0; font-size: 15px }
.entry-related .archive-list { margin-top: 5px }
.work-body [id^="section-"] { scroll-margin-top: 18px }
/* Citation labels and flyouts need to wrap inside the reading column. */
.work-body .cite { display: inline; white-space: normal; overflow-wrap: anywhere }
.work-body .cite-list { width: max-content; max-width: min(230px, 65vw); left: auto; right: 0 }

.audit-filters { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-bottom: 12px }
.audit-filters label { display: grid; flex: 1 1 130px; gap: 5px; max-width: 250px; color: var(--muted); font-size: 13px }
.audit-filters :is(input,select) { width: 100%; min-height: 34px; padding: 5px 8px; color: var(--ink); background: var(--paper); border: 1px solid var(--line-strong); border-radius: 7px; font: inherit }
.audit-filters .button { min-height: 34px }
.audit-status:empty { display: none }
.audit-list { list-style: none; padding: 0; margin: 0 0 14px }
.audit-event { padding: 13px 0; border-bottom: 1px solid var(--line); line-height: 1.6; overflow-wrap: anywhere }
.audit-meta { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin-bottom: 5px }
.audit-event :is(time,small,.quiet) { color: var(--muted); font-size: 13px }
.audit-event .quiet { margin: 4px 0 0 }
