:root {
  --navy: #14243a;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --paper: #ffffff;
  --canvas: #f5f7fb;
  --line: #dfe5ee;
  --muted: #607086;
  --text: #1f2937;
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--canvas); color: var(--text); line-height: 1.65; }
a { color: var(--blue-dark); }
a:hover { color: var(--blue); }
button, input { font: 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;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 64px;
  padding: .7rem 1.25rem;
  color: white;
  background: var(--navy);
  box-shadow: 0 2px 10px rgb(15 23 42 / 18%);
}

.brand { color: white; text-decoration: none; font-size: 1.15rem; font-weight: 750; white-space: nowrap; }
.brand:hover { color: white; }
.brand span { margin-left: .4rem; color: #a9bdd7; font-size: .88rem; font-weight: 500; }
.menu-button { display: none; color: white; background: transparent; border: 0; font-size: 1.35rem; cursor: pointer; }
.header-search { display: flex; gap: .45rem; width: min(430px, 45vw); margin-left: auto; }
.header-search input, .search-form input { width: 100%; min-width: 0; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: .45rem; }
.header-search button, .search-form button { padding: .62rem 1rem; border: 0; border-radius: .45rem; color: white; background: var(--blue); cursor: pointer; font-weight: 650; }
.header-search button:hover, .search-form button:hover { background: var(--blue-dark); }

.layout { display: grid; grid-template-columns: 290px minmax(0, 1fr); min-height: calc(100vh - 64px); }
.sidebar { position: sticky; top: 64px; align-self: start; height: calc(100vh - 64px); overflow-y: auto; padding: 1rem .75rem 2rem; background: var(--paper); border-right: 1px solid var(--line); }
.nav-group { margin: .15rem 0; }
.nav-group summary { padding: .55rem .6rem; border-radius: .4rem; cursor: pointer; color: #334155; font-weight: 700; list-style-position: inside; }
.nav-group summary:hover { background: #eef3fa; }
.nav-group.nested { margin-left: .65rem; }
.nav-group.nested summary { font-size: .9rem; font-weight: 650; }
.nav-document { display: block; margin: .1rem 0 .1rem 1rem; padding: .43rem .62rem; border-radius: .35rem; color: #43536a; text-decoration: none; font-size: .9rem; line-height: 1.35; }
.nav-document:hover { color: var(--navy); background: #eef3fa; }
.nav-document.active { color: #123a76; background: #dceafe; font-weight: 700; }

.main-content { width: min(100%, 1100px); padding: clamp(1.25rem, 3vw, 3rem); }
.welcome, .featured, .document, .not-found { background: var(--paper); border: 1px solid var(--line); border-radius: .8rem; box-shadow: 0 10px 25px rgb(15 23 42 / 5%); }
.welcome, .featured, .not-found { padding: clamp(1.4rem, 4vw, 3rem); }
.welcome h1, .document h1, .not-found h1 { margin: .15rem 0 .7rem; color: var(--navy); line-height: 1.16; font-size: clamp(2rem, 4vw, 3.15rem); }
.eyebrow { margin: 0; color: var(--blue-dark); text-transform: uppercase; letter-spacing: .09em; font-size: .75rem; font-weight: 800; }
.search-form { margin-top: 2rem; }
.search-form label { display: block; margin-bottom: .4rem; font-weight: 700; }
.search-form > div { display: flex; gap: .55rem; }
.search-status { min-height: 1.5rem; color: var(--muted); }
.search-results { display: grid; gap: .75rem; }
.search-result { padding: .85rem 1rem; background: #f8fafc; border: 1px solid var(--line); border-radius: .5rem; }
.search-result a { display: inline-block; margin-right: .55rem; font-weight: 750; }
.search-result small { color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.search-result p { margin: .25rem 0 0; }
.featured { margin-top: 1.25rem; }
.featured h2 { margin-top: 0; color: var(--navy); }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .8rem; }
.card { display: flex; flex-direction: column; gap: .25rem; min-height: 155px; padding: 1rem; border: 1px solid var(--line); border-radius: .55rem; color: var(--text); text-decoration: none; }
.card:hover { border-color: #8cb4ef; box-shadow: 0 7px 18px rgb(37 99 235 / 10%); }
.card span { color: var(--blue-dark); text-transform: uppercase; letter-spacing: .05em; font-size: .7rem; font-weight: 750; }
.card strong { color: var(--navy); font-size: 1.03rem; }
.card small { color: var(--muted); }

.document { max-width: 900px; padding: clamp(1.5rem, 5vw, 4rem); }
.document header { padding-bottom: 1.25rem; border-bottom: 1px solid var(--line); }
.document h1 { font-size: clamp(2rem, 4vw, 3rem); }
.summary { color: #425168; font-size: 1.08rem; }
.source-link a { font-weight: 700; }
.document-body { overflow-wrap: anywhere; }
.document-body h2, .document-body h3, .document-body h4 { scroll-margin-top: 80px; color: var(--navy); line-height: 1.25; }
.document-body h2 { margin-top: 2.2rem; padding-bottom: .4rem; border-bottom: 1px solid var(--line); }
.document-body img { max-width: 100%; height: auto; }
.document-body table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; }
.document-body th, .document-body td { padding: .55rem .7rem; border: 1px solid var(--line); text-align: left; }
.document-body th { background: #eef3fa; }
.document-body blockquote { margin-left: 0; padding: .25rem 1rem; color: #44556d; border-left: 4px solid #8cb4ef; background: #f7faff; }
.document-body pre { overflow-x: auto; padding: 1rem; color: #eef2ff; background: #172033; border-radius: .5rem; }
.document-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.related { margin-top: 3rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.related h2 { font-size: 1.15rem; }

@media (max-width: 800px) {
  .topbar { flex-wrap: wrap; }
  .menu-button { display: inline-block; }
  .brand { flex: 1; }
  .header-search { order: 2; width: 100%; }
  .layout { display: block; }
  .sidebar { position: fixed; top: 112px; bottom: 0; left: 0; z-index: 15; width: min(88vw, 320px); height: auto; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 8px 0 25px rgb(15 23 42 / 16%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { padding: 1rem; }
  .search-form > div { align-items: stretch; flex-direction: column; }
}
