:root {
  color-scheme: light;
  --canvas: #f5f7fa;
  --surface: #ffffff;
  --surface-muted: #eef3f7;
  --surface-hover: #e6f1f5;
  --text: #182536;
  --text-soft: #586777;
  --heading: #102a43;
  --border: #d8e0e8;
  --border-strong: #bbc7d2;
  --brand: #12364d;
  --brand-deep: #0b2638;
  --brand-text: #f5fbfd;
  --accent: #087b9f;
  --accent-hover: #056580;
  --code: #edf2f6;
  --table-head: #e4eef3;
  --table-stripe: #f8fafc;
  --focus: #24a4cf;
  --header-height: 4rem;
  --content-width: 94rem;
  --reading-width: 76ch;
  --radius-sm: 0.375rem;
  --radius-md: 0.625rem;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #0d151d;
  --surface: #121d27;
  --surface-muted: #192732;
  --surface-hover: #203542;
  --text: #dce7ee;
  --text-soft: #9fb0bc;
  --heading: #f1f7fa;
  --border: #2a3b47;
  --border-strong: #415867;
  --brand: #0d293b;
  --brand-deep: #081d2a;
  --brand-text: #f5fbfd;
  --accent: #68c4e1;
  --accent-hover: #91d5ea;
  --code: #192630;
  --table-head: #1a3442;
  --table-stripe: #15232d;
  --focus: #55c5e8;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #0d151d;
    --surface: #121d27;
    --surface-muted: #192732;
    --surface-hover: #203542;
    --text: #dce7ee;
    --text-soft: #9fb0bc;
    --heading: #f1f7fa;
    --border: #2a3b47;
    --border-strong: #415867;
    --brand: #0d293b;
    --brand-deep: #081d2a;
    --brand-text: #f5fbfd;
    --accent: #68c4e1;
    --accent-hover: #91d5ea;
    --code: #192630;
    --table-head: #1a3442;
    --table-stripe: #15232d;
    --focus: #55c5e8;
  }
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 1.5rem);
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--text);
  font: 16px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  text-rendering: optimizeLegibility;
}

a {
  color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

a:hover {
  color: var(--accent-hover);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
summary:focus-visible,
.table-wrap:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.6rem 0.9rem;
  transform: translateY(-150%);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-weight: 700;
}

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

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  min-height: var(--header-height);
  border-bottom: 1px solid #ffffff1f;
  background: var(--brand);
  color: var(--brand-text);
}

.topbar {
  display: flex;
  min-height: var(--header-height);
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 1.5rem;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.6rem;
  color: var(--brand-text);
  font-weight: 750;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.brand:hover {
  color: #ffffff;
}

.brand-mark {
  display: grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border: 1px solid #93d8ec80;
  border-radius: var(--radius-sm);
  background: #ffffff12;
  color: #8fdef4;
  font-family: Georgia, serif;
  font-size: 1.35rem;
}

.brand-version {
  color: #b8d6e1;
  font-size: 0.78rem;
  font-weight: 650;
}

.search-box {
  position: relative;
  flex: 1 1 26rem;
  max-width: 32rem;
}

.search-box label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.search-box input {
  width: 100%;
  min-height: 2.5rem;
  padding: 0.5rem 2.75rem 0.5rem 0.85rem;
  border: 1px solid #9bb5c180;
  border-radius: var(--radius-sm);
  background: #ffffff12;
  color: #ffffff;
  font: inherit;
}

.search-box input::placeholder {
  color: #c3d5dc;
}

.search-box input:focus {
  border-color: #8dd8ed;
  background: #ffffff1c;
}

.search-box kbd {
  position: absolute;
  top: 50%;
  right: 0.7rem;
  padding: 0.05rem 0.42rem;
  transform: translateY(-50%);
  border: 1px solid #ffffff38;
  border-radius: 0.25rem;
  color: #c9dce3;
  font: 0.75rem/1.4 ui-monospace, monospace;
}

.header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.75rem;
}

.header-actions nav {
  color: #c7dbe3;
  font-size: 0.78rem;
  white-space: nowrap;
}

.header-actions nav a {
  color: #d7edf4;
}

.header-actions nav strong {
  color: #ffffff;
}

#theme-toggle {
  display: inline-flex;
  min-height: 2.25rem;
  padding: 0.35rem 0.65rem;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid #ffffff38;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--brand-text);
  cursor: pointer;
  font: 600 0.8rem/1 ui-sans-serif, system-ui, sans-serif;
}

#theme-toggle:hover {
  background: #ffffff16;
}

.search-results {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 50%;
  width: min(42rem, calc(100vw - 2rem));
  max-height: min(32rem, 70vh);
  overflow: auto;
  transform: translateX(-50%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 1rem 2.5rem #06131c33;
  color: var(--text);
}

.search-results[hidden] {
  display: none;
}

.search-result-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-result-list li {
  margin: 0;
}

.search-results a {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
}

.search-results a:last-child {
  border-bottom: 0;
}

.search-results a:hover {
  background: var(--surface-hover);
}

.search-empty {
  margin: 0;
  padding: 1rem;
  color: var(--text-soft);
}

.doc-layout {
  display: grid;
  min-height: calc(100vh - var(--header-height));
  max-width: var(--content-width);
  margin: 0 auto;
  grid-template-columns: 16rem minmax(0, 1fr);
}

.doc-sidebar {
  border-right: 1px solid var(--border);
  background: var(--canvas);
}

.sidebar-sticky {
  position: sticky;
  top: var(--header-height);
  max-height: calc(100vh - var(--header-height));
  overflow: auto;
  padding: 2rem 1.5rem;
}

.sidebar-home {
  display: block;
  margin-bottom: 1.5rem;
  color: var(--heading);
  font-size: 0.82rem;
  font-weight: 750;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.toc-title {
  margin: 0 0 0.6rem;
  color: var(--text-soft);
  font-size: 0.72rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 0.32rem 0.6rem;
  border-left: 2px solid transparent;
  color: var(--text-soft);
  font-size: 0.84rem;
  line-height: 1.4;
  text-decoration: none;
}

.toc a:hover {
  border-left-color: var(--accent);
  color: var(--accent);
  background: var(--surface-hover);
}

.toc-level-3 a {
  padding-left: 1.35rem;
  font-size: 0.79rem;
}

.doc-content {
  min-width: 0;
  padding: clamp(2rem, 5vw, 4.5rem) clamp(1.5rem, 6vw, 6rem) 6rem;
  background: var(--surface);
}

.doc-content:focus {
  outline: none;
}

.doc-prose {
  max-width: 78rem;
}

.mobile-toc {
  display: none;
}

h1,
h2,
h3,
h4 {
  color: var(--heading);
  line-height: 1.2;
  text-wrap: balance;
}

h1 {
  max-width: 24ch;
  margin: 0 0 1.5rem;
  font-size: clamp(2.35rem, 5vw, 3.5rem);
  letter-spacing: -0.04em;
}

h2 {
  margin: 3.5rem 0 1rem;
  padding-top: 0.5rem;
  font-size: clamp(1.55rem, 3vw, 2rem);
  letter-spacing: -0.025em;
}

h3 {
  margin: 2.25rem 0 0.75rem;
  font-size: 1.25rem;
  letter-spacing: -0.015em;
}

p,
.doc-prose > ul,
.doc-prose > ol {
  max-width: var(--reading-width);
}

p {
  margin: 0 0 1rem;
}

ul,
ol {
  padding-left: 1.4rem;
}

li + li {
  margin-top: 0.35rem;
}

.release-list {
  max-width: var(--reading-width);
  margin: 0.75rem 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  list-style: none;
}

.release-list li {
  margin: 0;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}

.release-list li:last-child {
  border-bottom: 0;
}

.release-list li:hover {
  background: var(--surface-hover);
}

code {
  padding: 0.12em 0.32em;
  border-radius: 0.25rem;
  background: var(--code);
  font-family: "Cascadia Code", "SFMono-Regular", Consolas, monospace;
  font-size: 0.9em;
}

pre {
  max-width: 100%;
  overflow: auto;
  padding: 1rem 1.2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--code);
  line-height: 1.55;
}

pre code {
  padding: 0;
  background: transparent;
}

blockquote {
  max-width: var(--reading-width);
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  border-left: 4px solid var(--accent);
  background: var(--surface-muted);
  color: var(--text-soft);
}

.table-wrap {
  max-width: 100%;
  margin: 1.5rem 0;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 42rem;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--table-head);
  color: var(--heading);
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

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

@media (max-width: 76rem) {
  .header-actions nav {
    display: none;
  }
}

@media (max-width: 56rem) {
  :root {
    --header-height: auto;
  }

  .site-header {
    position: relative;
  }

  .topbar {
    min-height: auto;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }

  .search-box {
    flex-basis: calc(100% - 4rem);
    max-width: none;
    order: 3;
  }

  .header-actions {
    margin-left: auto;
  }

  #theme-toggle span:last-child,
  .brand-version {
    display: none;
  }

  .doc-layout {
    display: block;
  }

  .doc-sidebar {
    display: none;
  }

  .doc-content {
    padding: 2rem 1.25rem 4rem;
  }

  .mobile-toc {
    display: block;
    max-width: var(--reading-width);
    margin: 0 0 2rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface-muted);
  }

  .mobile-toc summary {
    padding: 0.75rem 1rem;
    color: var(--heading);
    cursor: pointer;
    font-weight: 700;
  }

  .mobile-toc .toc {
    padding: 0 0.75rem 0.75rem;
  }

  .mobile-toc .toc-title {
    display: none;
  }
}

@media (max-width: 30rem) {
  .brand-name {
    font-size: 0.95rem;
  }

  .doc-content {
    padding-inline: 1rem;
  }

  h1 {
    font-size: 2.2rem;
  }

  table {
    min-width: 34rem;
  }
}

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