:root {
  --ink: #18312d;
  --ink-soft: #42625b;
  --pine: #153c37;
  --pine-light: #1f544d;
  --mint: #dfeee7;
  --paper: #f6f3ed;
  --paper-deep: #ece7dd;
  --line: #d6d1c6;
  --coral: #cf6c57;
  --gold: #ba8c47;
  --white: #fffdf9;
  --shadow: 0 16px 45px rgba(27, 47, 42, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--paper);
  scroll-behavior: smooth;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--paper); }
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 30; top: 0.5rem; left: 0.5rem; transform: translateY(-160%); background: var(--white); padding: 0.75rem 1rem; border-radius: 0.5rem; box-shadow: var(--shadow); }
.skip-link:focus { transform: translateY(0); }

.topbar { height: 4.8rem; display: flex; align-items: center; gap: 0.9rem; padding: 0 1.4rem; position: sticky; top: 0; z-index: 20; color: var(--white); background: var(--pine); border-bottom: 1px solid rgba(255,255,255,.14); }
.brand { display: inline-flex; align-items: center; gap: 0.65rem; text-decoration: none; letter-spacing: .01em; }
.brand strong { display: block; font-family: Georgia, "Times New Roman", serif; font-size: 1.08rem; font-weight: 600; }
.brand small { display: block; margin-top: .06rem; color: #bcd2c8; font-size: .67rem; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark { display: grid; width: 2.25rem; height: 2.25rem; place-items: center; border: 1px solid #8eb3a2; border-radius: 50%; color: #e9f5ef; font-family: Georgia, serif; font-size: 1.25rem; }
.topbar-meta { margin-left: auto; display: flex; gap: .42rem; align-items: center; font-size: .78rem; }
.read-only-badge { padding: .32rem .58rem; border: 1px solid rgba(255,255,255,.28); border-radius: 999px; color: #d6eadf; }
.text-control, .icon-button { border: 0; background: transparent; cursor: pointer; }
.text-control { min-width: 2rem; color: #d6eadf; font-size: .8rem; }
.topbar output { min-width: 2.45rem; text-align: center; color: #d6eadf; font-variant-numeric: tabular-nums; }
.menu-button { display: none; color: var(--white); font-size: 1.3rem; }

.app-shell { display: grid; grid-template-columns: minmax(17rem, 22rem) minmax(0, 1fr) minmax(13rem, 17rem); max-width: 1660px; min-height: calc(100vh - 4.8rem); margin: 0 auto; }
.navigation { position: sticky; top: 4.8rem; align-self: start; height: calc(100vh - 4.8rem); overflow-y: auto; padding: 1.75rem 1.25rem 1.1rem; border-right: 1px solid var(--line); background: #f1eee7; }
.navigation-head { display: flex; align-items: flex-start; justify-content: space-between; }
.navigation h2 { margin: .1rem 0 1.3rem; font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; }
.eyebrow, .chapter-eyebrow, .source-id, .gap-id { margin: 0; color: var(--ink-soft); font-size: .67rem; font-weight: 700; letter-spacing: .11em; text-transform: uppercase; }
.close-button { display: none; font-size: 1.8rem; }
.search-field { display: flex; align-items: center; gap: .45rem; padding: .55rem .62rem; background: var(--white); border: 1px solid var(--line); border-radius: .55rem; color: var(--ink-soft); }
.search-field:focus-within { border-color: var(--pine-light); outline: 3px solid rgba(31,84,77,.12); }
.search-field input { width: 100%; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: .84rem; }
.search-field kbd { padding: .12rem .25rem; border: 1px solid var(--line); border-radius: .25rem; color: var(--ink-soft); font-size: .62rem; white-space: nowrap; }
.search-status { min-height: 2.5em; margin: .65rem 0 .9rem; color: var(--ink-soft); font-size: .72rem; line-height: 1.35; }
.tree-list, .tree-nested { margin: 0; padding: 0; list-style: none; }
.tree-nested { margin: .18rem 0 .18rem .62rem; padding-left: .53rem; border-left: 1px solid #cbc8bf; }
.tree-item { margin: .08rem 0; }
.tree-link { display: flex; width: 100%; align-items: center; justify-content: space-between; gap: .4rem; padding: .34rem .42rem; border: 0; border-radius: .36rem; background: transparent; text-align: left; cursor: pointer; color: #315149; font-size: .77rem; line-height: 1.28; }
.tree-link:hover { background: #e1e8e1; }
.tree-link.is-active { color: var(--pine); background: var(--mint); font-weight: 700; }
.tree-count { flex: 0 0 auto; color: #78948a; font-size: .63rem; font-variant-numeric: tabular-nums; }
.navigation-footer { display: flex; justify-content: space-between; gap: .4rem; margin-top: 1.3rem; padding-top: .85rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .72rem; }
.navigation-footer a { color: var(--pine); }

.document { min-width: 0; padding-bottom: 3rem; font-size: 100%; background: var(--paper); }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(15rem, 20rem); gap: 2.5rem; padding: clamp(2.6rem, 7vw, 6.4rem) clamp(1.5rem, 6vw, 7.2rem) 3.6rem; color: var(--white); background: radial-gradient(circle at 87% 12%, #3f766a 0, transparent 30%), linear-gradient(135deg, #163b36 0%, #235b50 100%); }
.hero h1 { max-width: 11ch; margin: .5rem 0 1.1rem; font-family: Georgia, "Times New Roman", serif; font-size: clamp(3rem, 6vw, 5.5rem); font-weight: 500; line-height: .9; letter-spacing: -.055em; }
.hero h1 em { color: #d9eae0; font-weight: 400; }
.hero .eyebrow { color: #b9d0c3; }
.lede { max-width: 35rem; margin: 0; color: #d9e8df; font-size: 1.05rem; line-height: 1.62; }
.hero-card { align-self: end; padding: 1.2rem 1.15rem; border: 1px solid rgba(255,255,255,.22); border-radius: .85rem; background: rgba(6, 32, 28, .24); backdrop-filter: blur(7px); }
.hero-card p { margin: .25rem 0 .65rem; color: #d6e8de; font-size: .84rem; line-height: 1.5; }
.hero-card p strong { color: var(--white); }
.status-dot { display: inline-block; width: .52rem; height: .52rem; margin-right: .35rem; border-radius: 50%; background: #b6da8f; box-shadow: 0 0 0 3px rgba(182,218,143,.14); }
.hero-card dl { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin: .9rem 0 0; padding-top: .8rem; border-top: 1px solid rgba(255,255,255,.18); }
.hero-card dt { color: #aec9bb; font-size: .6rem; letter-spacing: .06em; text-transform: uppercase; }
.hero-card dd { margin: .13rem 0 0; color: var(--white); font-size: 1.05rem; font-variant-numeric: tabular-nums; }

.orientation, .sources-section, .gaps-section { padding: 2.8rem clamp(1.5rem, 6vw, 7.2rem); }
.orientation { display: grid; grid-template-columns: minmax(12rem, .75fr) minmax(0, 1.5fr); gap: 2.1rem; border-bottom: 1px solid var(--line); background: var(--white); }
.orientation h2, .section-heading h2 { margin: .25rem 0 0; font-family: Georgia, serif; font-size: 1.8rem; font-weight: 500; letter-spacing: -.025em; }
.orientation-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .8rem; }
.orientation-grid article { padding: .8rem; border-left: 2px solid var(--line); }
.orientation-grid p { margin: .55rem 0 0; color: var(--ink-soft); font-size: .81rem; line-height: 1.45; }
.legend, .state-pill, .confidence { display: inline-flex; align-items: center; width: max-content; padding: .2rem .43rem; border-radius: 999px; font-size: .61rem; font-weight: 750; letter-spacing: .055em; text-transform: uppercase; }
.legend-fact, .state-fact { color: #1b6559; background: #d9eee5; }
.legend-scope, .state-scope { color: #7d6025; background: #f3e5c8; }
.legend-gap, .state-gap { color: #9a4e42; background: #f6ddd7; }

.chapters { padding: 1.4rem clamp(1.5rem, 6vw, 7.2rem) 0; }
.chapter { position: relative; scroll-margin-top: 5.7rem; padding: 2.6rem 0 2.55rem; border-bottom: 1px solid var(--line); }
.chapter.depth-1 { margin-top: 1.9rem; padding-top: 3rem; border-top: 4px solid var(--pine); }
.chapter.depth-1 + .chapter.depth-2 { margin-top: 0; }
.chapter-head { max-width: 47rem; }
.chapter-eyebrow { display: flex; align-items: center; gap: .55rem; margin-bottom: .65rem; }
.chapter h2, .chapter h3, .chapter h4, .chapter h5 { margin: 0; color: var(--pine); font-family: Georgia, serif; font-weight: 500; letter-spacing: -.03em; }
.chapter h2 { font-size: clamp(2rem, 3.3vw, 3rem); line-height: 1.02; }
.chapter h3 { font-size: clamp(1.55rem, 2.2vw, 2.05rem); line-height: 1.08; }
.chapter h4 { font-size: 1.22rem; line-height: 1.18; }
.chapter h5 { font-size: 1.06rem; }
.chapter-summary { max-width: 44rem; margin: .8rem 0 0; color: #395850; font-size: 1.05em; line-height: 1.62; }
.chapter-section { max-width: 44rem; margin-top: 1.4rem; }
.chapter-section h4 { margin-bottom: .45rem; color: var(--ink); font-family: inherit; font-size: .77rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; }
.chapter-section p { margin: 0; color: var(--ink-soft); font-size: .93em; line-height: 1.65; }
.chapter-bullets { margin: .75rem 0 0; padding-left: 1.1rem; color: var(--ink-soft); font-size: .9em; line-height: 1.55; }
.chapter-bullets li + li { margin-top: .32rem; }
.reference-list { display: flex; flex-wrap: wrap; gap: .38rem; max-width: 48rem; margin-top: 1rem; }
.reference-chip, .related-link, .chapter-id-link { border: 1px solid transparent; border-radius: 999px; cursor: pointer; }
.reference-chip { padding: .28rem .48rem; background: var(--white); font-size: .66rem; line-height: 1.3; text-align: left; }
.source-chip { border-color: #bdd7cd; color: #216457; }
.gap-chip { border-color: #edc3b9; color: #985041; }
.reference-chip:hover, .related-link:hover, .chapter-id-link:hover { filter: brightness(.95); text-decoration: underline; }
.related-links { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; max-width: 48rem; margin-top: 1rem; }
.related-label { color: var(--ink-soft); font-size: .69rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.related-link { padding: .28rem .5rem; background: #e3ece7; color: #24584e; font-size: .68rem; }

.sources-section { background: var(--white); }
.section-heading { max-width: 43rem; }
.section-heading > p:last-child { margin: .75rem 0 0; color: var(--ink-soft); line-height: 1.55; }
.source-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-top: 1.5rem; }
.source-card { padding: 1.05rem; border: 1px solid var(--line); border-radius: .7rem; background: #faf9f5; }
.source-card h3, .gap-card h3 { margin: .38rem 0 .45rem; font-size: 1rem; }
.source-card > p:not(.source-id) { min-height: 3.7em; margin: 0; color: var(--ink-soft); font-size: .82rem; line-height: 1.52; }
.confidence { margin-top: .85rem; color: #23584d; background: #dcebe4; }
.gaps-section { background: #f0e8df; }
.gap-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .8rem; margin-top: 1.5rem; }
.gap-card { padding: 1.05rem; border-top: 3px solid var(--coral); border-radius: .3rem; background: var(--white); box-shadow: 0 5px 18px rgba(91,54,43,.05); }
.gap-question { margin: .5rem 0 1rem; color: #475b55; font-size: .86rem; line-height: 1.5; }
.gap-meta { display: grid; gap: .58rem; margin: 0; }
.gap-meta dt { color: var(--ink-soft); font-size: .62rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.gap-meta dd { margin: .13rem 0 0; font-size: .76rem; line-height: 1.45; }
.gap-chapter-links { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem; margin-top: 1rem; color: var(--ink-soft); font-size: .67rem; }
.chapter-id-link { padding: .22rem .34rem; background: #f5eee8; color: #805244; font-size: .64rem; }
.muted { color: #778880; font-size: .78rem; }
.document-footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin: 2.7rem clamp(1.5rem, 6vw, 7.2rem) 0; padding-top: 1.3rem; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: .78rem; line-height: 1.5; }
.document-footer p { max-width: 48rem; margin: 0; }
.document-footer a { color: var(--pine); white-space: nowrap; }

.context-panel { position: sticky; top: 4.8rem; align-self: start; height: calc(100vh - 4.8rem); padding: 1.6rem 1.1rem; overflow-y: auto; border-left: 1px solid var(--line); background: #eeece5; }
.context-panel-inner { padding: .9rem .8rem; border-radius: .6rem; background: #f7f6f1; }
.active-path { margin: .45rem 0 0; color: var(--pine); font-family: Georgia, serif; font-size: 1.05rem; line-height: 1.35; }
.context-panel hr { margin: 1.15rem 0; border: 0; border-top: 1px solid var(--line); }
.context-panel p:not(.eyebrow):not(.active-path) { margin: .45rem 0 0; color: var(--ink-soft); font-size: .78rem; line-height: 1.55; }
.active-related { display: flex; flex-wrap: wrap; gap: .34rem; margin-top: .45rem; }
.related-links-compact { margin-top: 0; }
.related-links-compact .related-link { font-size: .65rem; }

@media (max-width: 1160px) {
  .app-shell { grid-template-columns: minmax(16rem, 20rem) minmax(0, 1fr); }
  .context-panel { display: none; }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(14rem, 18rem); }
}
@media (max-width: 820px) {
  .topbar { height: 4.25rem; padding: 0 .85rem; }
  .menu-button { display: inline-grid; place-items: center; width: 2rem; height: 2rem; }
  .topbar-meta .read-only-badge, .topbar-meta output, .topbar-meta .text-control { display: none; }
  .app-shell { display: block; min-height: calc(100vh - 4.25rem); }
  .navigation { position: fixed; z-index: 25; inset: 4.25rem auto 0 0; width: min(88vw, 23rem); height: auto; transform: translateX(-102%); transition: transform .18s ease; box-shadow: var(--shadow); border-right: 1px solid var(--line); }
  body.nav-open .navigation { transform: translateX(0); }
  body.nav-open::after { position: fixed; z-index: 24; inset: 4.25rem 0 0; content: ""; background: rgba(16, 39, 34, .25); }
  .close-button { display: block; }
  .hero { grid-template-columns: 1fr; gap: 1.8rem; padding: 3.1rem 1.3rem 2.7rem; }
  .orientation, .sources-section, .gaps-section { padding: 2.2rem 1.3rem; }
  .orientation { grid-template-columns: 1fr; gap: 1.25rem; }
  .orientation-grid { grid-template-columns: 1fr; }
  .orientation-grid article { padding: .55rem .75rem; }
  .chapters { padding: .7rem 1.3rem 0; }
  .chapter.depth-1 { margin-top: 1.35rem; }
  .source-list, .gap-list { grid-template-columns: 1fr; }
  .document-footer { margin: 2.2rem 1.3rem 0; }
}
@media (max-width: 480px) {
  .brand small { display: none; }
  .hero h1 { font-size: 3.25rem; }
  .hero-card dl { gap: .45rem; }
  .document-footer { flex-direction: column; }
}
@media (prefers-reduced-motion: reduce) {
  :root { scroll-behavior: auto; }
  .navigation { transition: none; }
}
