:root {
  color-scheme: light;
  --paper: #fff;
  --green: #3a7734;
  --heading: #2d5a27;
  --ink: #1a3d16;
  --tint: #f5f9f4;
  --pressed: #e8f3e6;
  --nav-rule: #d4b59e;
  --card-gradient: linear-gradient(135deg, #f5f9f4, #fff);
  --button-gradient: linear-gradient(135deg, #3a7734, #2d5a27);
  --header-height: calc(64px + env(safe-area-inset-top, 0px));
  --footer-height: calc(37px + env(safe-area-inset-bottom, 0px));
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  scrollbar-color: var(--green) var(--tint);
  scrollbar-width: thin;
}
* { box-sizing: border-box; }
body, h1, h2, h3, p { margin: 0; }
body.panel-open { overflow: hidden; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; text-underline-offset: .2em; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
button:disabled { cursor: default; }
img { display: block; width: 1rem; height: 1rem; }
::selection { color: var(--ink); background: var(--pressed); }
:focus-visible { outline: 2px solid var(--green); outline-offset: 4px; }
main:focus { outline: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: fixed; top: -100px; left: 1rem; z-index: 200; padding: .75rem; background: var(--paper); }
.skip-link:focus { top: .5rem; }
.header { position: fixed; z-index: 100; inset: 0 0 auto; padding-top: env(safe-area-inset-top, 0px); background: var(--paper); border-bottom: 1px solid var(--green); }
.header-inner { height: 64px; max-width: 1152px; padding: 0 16px; margin: auto; display: flex; align-items: center; }
.directory-trigger { display: flex; align-items: center; gap: 4px; min-height: 44px; padding: 8px 16px; border-radius: 6px; color: var(--green); flex-shrink: 0; }
.chevron { transition: transform 180ms ease-out; }
[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.brand { margin-left: 16px; margin-right: auto; white-space: nowrap; font-size: 1.25rem; line-height: 1.4; font-weight: 700; color: var(--heading); }
.menu-trigger { width: 44px; height: 44px; margin-right: -8px; display: grid; place-items: center; flex-shrink: 0; border-radius: 6px; }
.menu-trigger img { width: 24px; height: 24px; }
.directory-trigger:hover, .menu-trigger:hover, [aria-expanded="true"], .catalog-item:hover, .mobile-menu a:hover, .catalog-item[aria-current] { background: var(--pressed); }
.panel-dismiss { position: fixed; inset: 0; z-index: 90; }
.catalog, .mobile-menu { position: fixed; z-index: 110; background: var(--paper); border: 1px solid var(--green); border-radius: 6px; overflow-y: auto; overscroll-behavior: contain; }
.catalog { left: max(16px, calc((100% - 1120px) / 2)); top: calc(var(--header-height) - 8px); width: 192px; max-height: min(60vh, 480px); padding: 4px 0; }
.catalog-item { display: block; padding: 10px 16px; min-height: 44px; font-size: .875rem; color: var(--heading); }
.mobile-menu { top: calc(var(--header-height) + 4px); right: max(16px, calc((100% - 1120px) / 2)); width: 160px; padding: 4px 0; }
.mobile-menu a { display: block; padding: 12px 16px; }
.home-content { min-height: 100vh; padding: var(--header-height) 16px calc(var(--footer-height) + 24px); }
.chapter-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 24px; padding: 24px; max-width: 1152px; margin: auto; }
.chapter-card { display: block; min-height: 120px; padding: 24px; border: 1px solid var(--green); border-radius: 8px; background: var(--card-gradient); }
.chapter-card:hover { background: var(--pressed); border-color: var(--heading); }
.chapter-title { color: var(--heading); font-weight: 600; font-size: 1.125rem; line-height: 1.56; }
.chapter-excerpt { margin-top: 8px; color: var(--green); font-size: .875rem; line-height: 1.43; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.reading-content { padding: var(--header-height) 24px calc(var(--footer-height) + 88px); max-width: 896px; min-height: 100vh; margin: auto; }
.page-title { padding-top: 24px; margin-bottom: 32px; color: var(--heading); font-size: 1.875rem; line-height: 1.2; text-align: center; font-weight: 700; }
.section-stack { display: flex; flex-direction: column; gap: 32px; }
.reading-section { position: relative; padding: 32px; border: 1px solid var(--green); border-radius: 8px; background: var(--paper); }
.reading-section::before, .reading-section::after { content: ''; position: absolute; height: 100%; width: 10px; top: 0; background: #3a773433; border-radius: 0 6px 6px 0; pointer-events: none; }
.reading-section::before { left: -15px; }
.reading-section::after { right: -15px; transform: rotate(180deg); }
.section-title { margin-bottom: 24px; padding-bottom: 8px; border-bottom: 1px solid var(--green); color: var(--heading); font-size: 1.25rem; line-height: 1.4; font-weight: 600; }
.paragraph { font-size: 1.125rem; line-height: 1.625; white-space: pre-wrap; overflow-wrap: break-word; }
.paragraph + .paragraph { margin-top: 16px; }
.original-version + .original-version { margin-top: 24px; }
.version-label { color: var(--heading); font-size: 1rem; font-weight: 600; margin-bottom: 8px; }
.reading-nav { position: fixed; z-index: 40; bottom: var(--footer-height); left: 0; right: 0; display: flex; align-items: center; justify-content: center; gap: 16px; min-height: 57px; border-top: 1px solid var(--nav-rule); background: var(--paper); padding: 6px 12px; }
.nav-button { display: flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; padding: 6px 16px; border-radius: 24px; color: var(--tint); background: var(--button-gradient); font-size: .875rem; white-space: nowrap; }
.nav-button:hover { background: var(--heading); }
.nav-button:disabled { opacity: .5; }
.footer { position: fixed; z-index: 50; bottom: 0; left: 0; right: 0; border-top: 1px solid var(--green); background: var(--paper); padding: 8px 16px calc(8px + env(safe-area-inset-bottom, 0px)); color: var(--green); font-size: .875rem; line-height: 20px; text-align: center; }
.empty-state { padding: 72px 8px; text-align: center; }
.empty-state h1 { font-size: 1.5rem; color: var(--heading); }
.empty-state p { margin-top: 16px; }
.recovery-button { display: inline-block; padding: 10px 24px; margin-top: 24px; border-radius: 24px; color: var(--tint); background: var(--button-gradient); }
.no-script { position: fixed; top: 100px; padding: 24px; }
@media (min-width: 768px) { .chapter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 360px) {
  .header-inner { padding: 0 12px; }
  .directory-trigger { padding: 8px; }
  .brand { margin-left: 8px; font-size: 1.125rem; }
  .reading-nav { gap: 12px; }
  .nav-button { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) { .chevron { transition: none; } }
