:root {
  color-scheme: dark;
  --night: #101923;
  --paper: #d9e1e7;
  --bright: #f2eee4;
  --muted: #acbbc7;
  --gold: #dbc591;
  --rule: #405164;
  --serif: 'Noto Serif SC', 'Songti SC', 'STSong', 'SimSun', serif;
  --sans: system-ui, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { background: var(--night); scroll-padding-top: 30px; }
body { margin: 0; color: var(--paper); font: 17px/1.9 var(--sans); }
a { color: inherit; }
a:focus-visible, summary:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
.skip { position: fixed; left: 1rem; top: -5rem; z-index: 20; padding: .45rem .8rem; background: var(--night); }
.skip:focus { top: 1rem; }

.cover { position: relative; display: flex; align-items: end; min-height: 340px; isolation: isolate; border-bottom: 1px solid #8f7950; background: #172735; }
.cover-art { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center 16%; z-index: -2; }
.cover::after { content: ''; position: absolute; inset: 0; z-index: -1; background: linear-gradient(90deg, #0c1625e8, #0c16258a 57%, #0c162528), linear-gradient(0deg, #0b1422df, transparent 73%); }
.cover-inner { width: min(1200px, 100%); margin: 0 auto; padding: 78px 48px 54px; }
h1 { max-width: 19em; margin: 0; color: var(--bright); font: 700 clamp(2.25rem, 5vw, 4.1rem)/1.18 var(--serif); letter-spacing: .035em; text-wrap: balance; }
.cover-inner p { margin: 19px 0 0; color: var(--gold); font-size: 15px; }

.reading-layout { display: grid; grid-template-columns: 210px minmax(0, 790px); column-gap: clamp(36px, 6vw, 90px); width: min(1200px, 100%); margin: auto; padding: 44px 48px 85px; }
.side-contents { align-self: start; position: sticky; top: 28px; max-height: calc(100dvh - 56px); overflow: auto; padding-right: 19px; border-right: 1px solid var(--rule); }
.contents-title, summary { color: var(--gold); font-weight: 700; }
.contents-title { margin: 0 0 14px; font-size: 17px; }
.contents { list-style: none; padding: 0; margin: 0; }
.contents a { display: block; text-decoration: none; color: var(--muted); font-size: 14px; line-height: 1.55; padding: .47rem .3rem; }
.contents a:hover, .contents a:focus-visible, .contents a[aria-current] { color: var(--gold); background: #dbc59112; }
.mobile-contents { display: none; }

.chapter { padding: 31px 0 37px; border-bottom: 1px solid var(--rule); }
.chapter:first-child { padding-top: 0; }
.chapter:last-child { border: 0; padding-bottom: 0; }
h2 { color: var(--gold); font: 700 clamp(1.55rem, 3vw, 2.18rem)/1.45 var(--serif); letter-spacing: .025em; margin: 0 0 18px; text-wrap: balance; }
h3 { margin: 1.6em 0 .62em; color: var(--bright); font-size: 1.12em; line-height: 1.55; }
p { margin: .78em 0; overflow-wrap: anywhere; }
.chapter > :last-child { margin-bottom: 0; }
strong { color: var(--bright); font-weight: 700; }
table { border-collapse: collapse; width: 100%; margin: 1.15em 0 1.3em; font-size: .94em; line-height: 1.6; }
th, td { text-align: left; vertical-align: top; padding: .65rem .78rem; border-bottom: 1px solid var(--rule); overflow-wrap: anywhere; }
th { background: #223242; color: var(--gold); }
td:first-child, th:first-child { width: 22%; }
tbody tr:nth-child(even) { background: #1a2632; }

@media (max-width: 800px) {
  html { scroll-padding-top: 68px; }
  body { font-size: 16px; line-height: 1.86; }
  .cover { min-height: 252px; }
  .cover-art { object-position: 55% 49%; }
  .cover-inner { padding: 61px 22px 31px; }
  .cover-inner p { margin-top: 13px; font-size: 14px; }
  h1 { max-width: 12em; font-size: clamp(1.94rem, 6.7vw, 3.15rem); }
  .reading-layout { display: block; padding: 28px 22px 58px; }
  .side-contents { display: none; }
  .mobile-contents { display: block; position: sticky; top: 0; z-index: 3; background: #182533; border-bottom: 1px solid var(--rule); }
  summary { cursor: pointer; padding: .6rem 22px; }
  .mobile-contents nav { position: absolute; inset-inline: 0; top: 100%; background: #182533; padding: 5px 16px 12px; border-bottom: 1px solid #8f7950; max-height: min(78dvh, calc(100dvh - 72px)); overflow: auto; }
  .contents a { font-size: 16px; padding: .6rem; min-height: 44px; }
  .chapter { padding: 26px 0 30px; }
  h2 { font-size: 1.57rem; margin-bottom: 14px; }
  th, td { padding: .55rem .46rem; }
  table { font-size: .92em; }
}

@media print {
  :root { color-scheme: light; --paper: #111; --bright: #111; --gold: #352615; --rule: #aaa; }
  html, .cover, th, tbody tr:nth-child(even) { background: white; }
  .cover-art, .cover::after, .side-contents, .mobile-contents, .skip { display: none; }
  .cover { min-height: 0; }
  .cover-inner, .reading-layout { display: block; padding: 18px 0; }
  .chapter { break-inside: auto; }
  h2, h3 { break-after: avoid; }
  tr { break-inside: avoid; }
}
