:root {
  color-scheme: light;
  --canvas: oklch(97% 0.012 85);
  --paper: oklch(99% 0.006 85);
  --ink: oklch(25% 0.018 55);
  --muted: oklch(48% 0.018 55);
  --line: oklch(86% 0.018 75);
  --accent: oklch(48% 0.15 30);
  --serif: Georgia, "Songti SC", STSong, "Noto Serif CJK SC", serif;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--canvas);
  font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 16px; line-height: 1.8; }
button, input, select { font: inherit; color: inherit; }
button, select, summary { cursor: pointer; }
button, select { min-height: 44px; border: 1px solid var(--line); border-radius: 4px; background: transparent; }
button { padding: 8px 16px; }
button:hover, select:hover { border-color: var(--accent); }
button:active { transform: scale(.97); }
button:disabled, input:disabled, select:disabled { opacity: .5; cursor: wait; }
a { color: var(--accent); text-underline-offset: 4px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
[hidden] { display: none !important; }
h1, h2, h3, p, blockquote, dl, dd { margin: 0; }
h2 { font-size: 16px; font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: -80px; left: 16px; z-index: 5; padding: 8px 16px; background: var(--paper); }
.skip-link:focus { top: 12px; }
.masthead, .app, .footer { width: min(1200px, calc(100% - 80px)); margin-inline: auto; }
.masthead { display: flex; align-items: center; justify-content: space-between; padding-block: 32px; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 14px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 48px; height: 48px; background: var(--accent); color: var(--paper); font: 32px/1 var(--serif); }
.brand strong { display: block; font: 600 24px/1.4 var(--serif); }
.brand small { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.edition { font: 15px/1.8 var(--serif); text-align: right; }
.edition span { display: block; color: var(--muted); font: 11px/1.8 -apple-system, BlinkMacSystemFont, sans-serif; letter-spacing: .1em; }
.search-bar { display: flex; align-items: center; gap: 12px; padding: 16px 0; border-block: 1px solid var(--line); }
.search-label { font-size: 14px; font-weight: 600; margin-right: 4px; white-space: nowrap; }
.search-bar input { flex: 1; min-width: 0; height: 48px; padding: 10px 14px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper); }
.search-bar input::placeholder { color: var(--muted); }
.search-bar select { max-width: 168px; padding: 8px 30px 8px 12px; background-color: var(--paper); }
.quiet { padding-inline: 12px; border-color: transparent; color: var(--muted); }
.random { margin-left: 12px; color: var(--accent); border-color: transparent; white-space: nowrap; }
.random span { margin-left: 12px; }
.workspace { display: grid; grid-template-columns: 304px minmax(0, 1fr); gap: 40px; align-items: start; padding-top: 32px; }
.catalog { padding-top: 4px; }
.catalog-filter { display: flex; align-items: center; gap: 8px; min-height: 44px; margin-block: -8px 12px; color: var(--muted); font-size: 13px; cursor: pointer; }
.catalog-filter input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section-heading > span, .section-number { color: var(--muted); font-size: 12px; font-weight: 400; white-space: nowrap; }
.section-number { margin-right: 14px; font-variant-numeric: tabular-nums; }
.character-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; max-height: 640px; overflow-y: auto; padding: 4px; margin: -4px; }
.character-tile { display: grid; place-items: center; padding: 0; min-height: 52px; border-color: var(--line); background: var(--paper); font: 25px/1.4 var(--serif); }
.character-tile[aria-current="true"] { color: var(--paper); background: var(--accent); border-color: var(--accent); }
.more { display: flex; width: 100%; align-items: center; justify-content: space-between; margin-top: 16px; font-size: 13px; }
.catalog-note { margin-top: 20px; color: var(--muted); font-size: 12px; }
.entry { min-width: 0; background: var(--paper); padding: 28px 40px 36px; scroll-margin-top: 16px; }
.entry-topline { display: flex; align-items: center; justify-content: space-between; padding-bottom: 18px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.entry-topline > :first-child { color: var(--accent); }
#previous:disabled { cursor: default; }
.entry-number { font-variant-numeric: tabular-nums; }
.character-intro { display: flex; align-items: center; gap: 40px; padding-block: 32px 36px; }
.writing-square { display: grid; place-items: center; flex: 0 0 180px; width: 180px; height: 180px; border: 1px solid var(--line); background-image: linear-gradient(to right, transparent calc(50% - .5px), var(--line) 50%, transparent calc(50% + .5px)), linear-gradient(to bottom, transparent calc(50% - .5px), var(--line) 50%, transparent calc(50% + .5px)); }
.writing-square h1 { color: var(--ink); font: 144px/1 var(--serif); }
.character-info { min-width: 0; }
.pinyin { margin-bottom: 12px; font: 28px/1.4 var(--serif); overflow-wrap: anywhere; }
.metadata { display: flex; flex-wrap: wrap; gap: 12px 24px; }
.metadata dt { color: var(--muted); font-size: 11px; }
.metadata dd { font-size: 16px; overflow-wrap: anywhere; }
.intro-note { margin-top: 20px; color: var(--muted); font: 13px/1.8 var(--serif); }
.reading-section { padding-block: 24px; border-top: 1px solid var(--line); }
.source-entry + .source-entry { margin-top: 28px; padding-top: 24px; border-top: 1px dashed var(--line); }
.source-head { display: flex; gap: 12px; align-items: baseline; margin-bottom: 12px; }
.source-head h3 { font: 24px/1.4 var(--serif); }
.source-head span { font-size: 12px; color: var(--muted); }
.source-entry blockquote { font: 21px/1.9 var(--serif); overflow-wrap: anywhere; }
.source-meta { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-top: 16px; font-size: 12px; color: var(--muted); }
.source-meta a { margin-left: auto; white-space: nowrap; }
.glossary { display: grid; gap: 12px; }
.glossary > div { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 16px; }
.glossary dt { color: var(--accent); font: 19px/1.6 var(--serif); }
.glossary dd { color: var(--muted); font-size: 14px; }
.historical-source { margin-top: 16px; padding-block: 12px; border-bottom: 1px solid var(--line); }
.historical-source > summary, .historical-more > summary { min-height: 44px; font-size: 14px; }
.posthumous-definitions, .historical-examples { padding: 0; margin: 8px 0 16px; list-style: none; }
.posthumous-definitions > li + li, .historical-examples > li + li { margin-top: 16px; }
.historical-quote { font: 20px/1.8 var(--serif); overflow-wrap: anywhere; }
.historical-notes { margin-top: 4px; color: var(--muted); font-size: 13px; }
.historical-notes summary { min-height: 44px; display: list-item; }
.historical-notes p { margin-block: 8px; overflow-wrap: anywhere; }
.historical-example-heading { margin-top: 24px; font-size: 14px; font-weight: 600; }
.historical-examples > li > p:first-child { font: 17px/1.8 var(--serif); }
.historical-examples .source-meta { margin-top: 4px; }
.historical-source .source-meta a, .historical-examples .source-meta a { margin-left: 0; white-space: normal; overflow-wrap: anywhere; }
.related { display: flex; flex-wrap: wrap; gap: 8px; }
.related a { display: grid; place-items: center; width: 48px; height: 48px; border: 1px solid var(--line); border-radius: 4px; text-decoration: none; font: 24px/1 var(--serif); color: var(--ink); }
.related a:hover { border-color: var(--accent); color: var(--accent); }
.related a:active { transform: scale(.97); }
.editorial-note { color: var(--muted); font-size: 12px; line-height: 1.8; }
.empty, .no-source { padding-block: 24px; }
.empty p + p, .no-source p + p { margin-top: 8px; color: var(--muted); font-size: 13px; }
.entry-loading { padding-block: 64px; color: var(--muted); }
.load-error { padding: 24px; margin-top: 24px; border: 1px solid var(--accent); }
.load-error button { margin-top: 12px; }
.footer { display: flex; justify-content: space-between; align-items: baseline; gap: 24px; margin-block: 40px 24px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.footer details { max-width: 680px; }
.footer summary { text-align: right; min-height: 44px; }
.footer details div { padding-top: 12px; }
.footer details p + p { margin-top: 8px; }
@media (max-width: 1100px) {
  .workspace { gap: 24px; grid-template-columns: 264px minmax(0, 1fr); }
  .entry { padding-inline: 24px; }
  .character-intro { gap: 24px; }
  .writing-square { flex-basis: 144px; width: 144px; height: 144px; }
  .writing-square h1 { font-size: 120px; }
  .random { margin-left: 0; }
}
@media (max-width: 760px) {
  .masthead, .app, .footer { width: calc(100% - 40px); }
  .masthead { padding-block: 24px; }
  .edition { display: none; }
  .search-bar { flex-wrap: wrap; gap: 8px; }
  .search-label { display: none; }
  .search-bar input { flex-basis: calc(100% - 68px); }
  .search-bar select { flex: 1; max-width: none; }
  .random { margin-left: auto; }
  .workspace { display: flex; flex-direction: column; gap: 32px; padding-top: 24px; }
  .entry { order: 0; width: 100%; padding: 20px; }
  .catalog { order: 1; width: 100%; }
  .searching .catalog { order: -1; }
  .character-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .character-intro { gap: 24px; padding-block: 28px; }
  .writing-square { flex-basis: 120px; width: 120px; height: 120px; }
  .writing-square h1 { font-size: 100px; }
  .pinyin { font-size: 25px; }
  .metadata { gap: 8px 16px; }
  .intro-note { margin-top: 12px; }
  .source-entry blockquote { font-size: 20px; }
  .footer { flex-direction: column; gap: 8px; }
  .footer summary { text-align: left; }
}
@media (max-width: 380px) {
  .masthead, .app, .footer { width: calc(100% - 24px); }
  .entry { padding-inline: 16px; }
  .character-intro { gap: 16px; }
  .writing-square { flex-basis: 104px; width: 104px; height: 104px; }
  .writing-square h1 { font-size: 88px; }
  .character-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .intro-note { display: none; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
