:root {
  color-scheme: light;
  --paper: #f7f5f0;
  --surface: #fffefa;
  --ink: #20201e;
  --muted: #67645e;
  --line: #d9d5cc;
  --line-strong: #b9b4aa;
  --accent: #145f58;
  --accent-soft: #e6f0ed;
  --reader-size: 18px;
  --ui-font: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --reading-font: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --topbar-height: 58px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--topbar-height) + 20px);
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--ui-font);
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration-thickness: .08em;
  text-underline-offset: .18em;
}

a:hover {
  text-decoration-thickness: .12em;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid #0b766d;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--ink);
  color: #fff;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.reading-progress {
  position: fixed;
  z-index: 60;
  inset: 0 0 auto;
  height: 3px;
  background: transparent;
}

.reading-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--accent);
}

.site-bar {
  position: sticky;
  z-index: 50;
  top: 0;
  min-height: var(--topbar-height);
  border-bottom: 1px solid var(--line);
  background: rgba(247, 245, 240, .96);
  backdrop-filter: blur(10px);
}

.site-bar-inner {
  display: flex;
  align-items: center;
  gap: 18px;
  width: min(100% - 32px, 1240px);
  min-height: var(--topbar-height);
  margin: 0 auto;
}

.site-title {
  flex: 0 0 auto;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  letter-spacing: .01em;
  text-decoration: none;
}

.primary-nav {
  display: flex;
  align-self: stretch;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.primary-nav a {
  display: grid;
  align-items: center;
  min-height: 38px;
  padding: 7px 9px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
}

.primary-nav a:hover,
.primary-nav a[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--ink);
}

.reader-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 4px;
  margin-left: 2px;
}

.reader-actions button {
  min-width: 36px;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 700 13px/1 var(--ui-font);
  cursor: pointer;
}

.reader-actions button:hover {
  border-color: var(--accent);
}

[data-js-only] {
  display: none;
}

.js [data-js-only] {
  display: flex;
}

.mobile-reader-menu {
  display: none;
}

.page-hero {
  width: min(100% - 32px, 1240px);
  margin: 0 auto;
  padding: 34px 0 28px;
  border-bottom: 1px solid var(--line);
}

.page-kicker {
  margin: 0 0 8px;
  color: var(--accent);
  font: 750 12px/1.3 var(--ui-font);
  letter-spacing: .09em;
  text-transform: uppercase;
}

.page-hero h1 {
  max-width: 900px;
  margin: 0;
  font-family: var(--reading-font);
  font-size: clamp(31px, 4.3vw, 52px);
  font-weight: 650;
  line-height: 1.08;
  letter-spacing: -.025em;
}

.reader-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 790px);
  gap: 52px;
  justify-content: center;
  width: min(100% - 32px, 1240px);
  margin: 0 auto;
  padding: 34px 0 76px;
}

.desktop-toc-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 24px);
  align-self: start;
  max-height: calc(100vh - var(--topbar-height) - 48px);
  padding-right: 14px;
  overflow: auto;
  scrollbar-width: thin;
}

.desktop-toc-title {
  margin: 0 0 12px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 750;
}

.toc-filter {
  display: none;
}

.js .toc-filter {
  display: block;
}

.toc-search-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.toc-search {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  font: 14px/1.3 var(--ui-font);
}

.toc-nav ol {
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}

.toc-nav li {
  margin: 0;
}

.toc-nav a {
  display: block;
  padding: 6px 8px;
  border-left: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.32;
  text-decoration: none;
}

.toc-nav .toc-level-3 a {
  padding-left: 19px;
  font-size: 12px;
}

.toc-nav a:hover,
.toc-nav a[aria-current="location"] {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--ink);
}

.toc-empty {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.article-source {
  min-width: 0;
  max-width: 72ch;
  font-family: var(--reading-font);
  font-size: var(--reader-size);
  line-height: 1.72;
  overflow-wrap: anywhere;
}

.article-source > :first-child {
  margin-top: 0;
}

.article-source h2,
.article-source h3,
.article-source h4,
.article-source h5,
.article-source h6 {
  scroll-margin-top: calc(var(--topbar-height) + 20px);
  color: var(--ink);
  font-family: var(--ui-font);
  line-height: 1.24;
}

.article-source h2 {
  margin: 2.7em 0 .72em;
  padding-top: .78em;
  border-top: 1px solid var(--line);
  font-size: 1.46em;
  font-weight: 760;
  letter-spacing: -.015em;
}

.article-source h3 {
  margin: 2em 0 .58em;
  font-size: 1.13em;
  font-weight: 760;
}

.article-source h4,
.article-source h5,
.article-source h6 {
  margin: 1.7em 0 .5em;
  font-size: 1em;
}

.article-source p {
  margin: 0 0 1.08em;
}

.article-source ul,
.article-source ol {
  margin: .2em 0 1.2em;
  padding-left: 1.35em;
}

.article-source li {
  margin: .42em 0;
  padding-left: .15em;
}

.article-source code {
  padding: .08em .28em;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #efede7;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84em;
}

.article-source hr {
  margin: 2.5em 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.table-frame {
  width: 100%;
  margin: 1.5em 0 2.1em;
}

.table-frame table {
  width: 100%;
  border-collapse: collapse;
  border-top: 1px solid var(--line-strong);
  border-bottom: 1px solid var(--line-strong);
  font-family: var(--ui-font);
  font-size: .79em;
  line-height: 1.46;
  table-layout: auto;
}

.table-frame th,
.table-frame td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  overflow-wrap: anywhere;
}

.table-frame th {
  background: #efede7;
  color: var(--ink);
  font-size: .92em;
  font-weight: 760;
}

.table-frame tbody tr:last-child td {
  border-bottom: 0;
}

.table-frame tbody tr:nth-child(even) td {
  background: rgba(255, 254, 250, .6);
}

.page-turn {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  width: min(100% - 32px, 790px);
  margin: 0 auto 72px;
}

.page-turn > a {
  display: flex;
  flex-direction: column;
  min-height: 92px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  text-decoration: none;
}

.page-turn > a:hover {
  border-color: var(--accent);
}

.page-turn-next {
  text-align: right;
}

.page-turn span {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.page-turn strong {
  font-size: 16px;
  line-height: 1.35;
}

.site-footer {
  padding: 25px 16px 32px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.site-footer p {
  margin: 0;
}

@media (max-width: 1050px) {
  .site-title {
    max-width: 150px;
  }

  .primary-nav a {
    padding-inline: 6px;
    font-size: 12px;
  }

  .reader-layout {
    grid-template-columns: 220px minmax(0, 720px);
    gap: 34px;
  }
}

@media (max-width: 860px) {
  :root {
    --topbar-height: 54px;
  }

  .site-bar-inner {
    width: min(100% - 24px, 760px);
    gap: 10px;
  }

  .site-title {
    max-width: none;
    margin-right: auto;
  }

  .primary-nav,
  .desktop-toc-panel {
    display: none;
  }

  .reader-actions {
    display: none !important;
  }

  .mobile-reader-menu {
    position: relative;
    display: block;
    order: 3;
  }

  .mobile-reader-menu summary {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 9px 10px;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font-size: 13px;
    font-weight: 720;
    cursor: pointer;
    list-style: none;
  }

  .mobile-reader-menu summary::-webkit-details-marker {
    display: none;
  }

  .mobile-reader-menu summary::after {
    content: " +";
    color: var(--muted);
  }

  .mobile-reader-menu[open] summary::after {
    content: " −";
  }

  .mobile-reader-menu-panel {
    position: absolute;
    top: calc(100% + 7px);
    right: 0;
    width: min(88vw, 420px);
    max-height: calc(100vh - var(--topbar-height) - 24px);
    padding: 14px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 12px 30px rgba(30, 30, 28, .14);
    overflow: auto;
  }

  .mobile-reader-settings {
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 13px;
    font-weight: 650;
  }

  .mobile-font-actions {
    display: flex;
    gap: 6px;
  }

  .mobile-font-actions button {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--line-strong);
    border-radius: 6px;
    background: var(--surface);
    color: var(--ink);
    font: 700 14px/1 var(--ui-font);
    cursor: pointer;
  }

  .mobile-font-actions button:hover {
    border-color: var(--accent);
  }

  .mobile-pages {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-bottom: 15px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--line);
  }

  .mobile-pages a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 8px 9px;
    border-radius: 5px;
    color: var(--ink);
    font-size: 13px;
    text-decoration: none;
  }

  .mobile-pages a:hover,
  .mobile-pages a[aria-current="page"] {
    background: var(--accent-soft);
  }

  .mobile-reader-menu .toc-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding-block: 8px;
    font-size: 14px;
  }

  .mobile-reader-menu .toc-search {
    min-height: 44px;
    font-size: 16px;
  }

  .page-hero {
    width: min(100% - 32px, 760px);
    padding: 25px 0 23px;
  }

  .reader-layout {
    display: block;
    width: min(100% - 32px, 760px);
    padding: 28px 0 58px;
  }

  .article-source {
    max-width: 100%;
  }
}

@media (max-width: 720px) {
  :root {
    --reader-size: 17px;
  }

  .page-hero h1 {
    font-size: clamp(29px, 9vw, 40px);
  }

  .table-frame {
    margin: 1.35em 0 1.9em;
  }

  .table-frame table,
  .table-frame tbody,
  .table-frame tr,
  .table-frame td {
    display: block;
    width: 100%;
  }

  .table-frame table {
    border: 0;
    font-size: .85em;
  }

  .table-frame thead {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    overflow: hidden;
    white-space: nowrap;
  }

  .table-frame tr {
    margin-bottom: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
    background: var(--surface);
    overflow: hidden;
  }

  .table-frame td {
    display: grid;
    grid-template-columns: minmax(92px, 34%) minmax(0, 1fr);
    gap: 10px;
    padding: 9px 11px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: transparent !important;
    text-align: left !important;
  }

  .table-frame td::before {
    content: attr(data-label);
    color: var(--muted);
    font-family: var(--ui-font);
    font-size: clamp(13px, .82em, 14px);
    font-weight: 650;
    line-height: 1.4;
  }

  .table-frame td.cell-primary {
    display: block;
    padding: 12px 11px;
    background: #efede7 !important;
    font-weight: 750;
  }

  .table-frame td.cell-primary::before {
    display: block;
    margin-bottom: 3px;
    font-size: clamp(13px, .78em, 14px);
  }

  .table-frame tr td:last-child {
    border-bottom: 0;
  }

  .page-turn {
    grid-template-columns: 1fr;
    width: min(100% - 32px, 760px);
    margin-bottom: 48px;
  }

  .page-turn > span:empty {
    display: none;
  }

  .page-turn-next {
    text-align: left;
  }
}

@media (max-width: 520px) {
  .site-title {
    display: flex;
    align-items: center;
    min-height: 44px;
    max-width: 180px;
    font-size: 13px;
    line-height: 1.15;
  }

  .mobile-reader-menu summary {
    padding-inline: 8px;
  }

  .page-hero,
  .reader-layout {
    width: calc(100% - 28px);
  }

  .article-source h2 {
    margin-top: 2.35em;
  }
}

@media print {
  .site-bar,
  .reading-progress,
  .desktop-toc-panel,
  .page-turn,
  .site-footer,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
  }

  .page-hero,
  .reader-layout {
    width: 100%;
    max-width: none;
  }

  .reader-layout {
    display: block;
  }

  .article-source {
    max-width: none;
    font-size: 11pt;
  }

  a {
    color: inherit;
  }
}
