:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #2563eb;
  --code-bg: #f3f4f6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161a;
    --fg: #e5e7eb;
    --muted: #9ca3af;
    --border: #2a2e37;
    --accent: #60a5fa;
    --code-bg: #1d2026;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  line-height: 1.6;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.5rem 0.75rem;
  background: var(--bg);
  color: var(--accent);
  border: 2px solid var(--accent);
  border-radius: 4px;
  transform: translateY(-200%);
}

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

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

header .brand {
  font-weight: 600;
  color: var(--fg);
  text-decoration: none;
  white-space: nowrap;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 2rem;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
}

@media (max-width: 760px) {
  .layout {
    grid-template-columns: 1fr;
  }
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.layout > nav {
  position: sticky;
  top: 4rem;
  align-self: start;
  max-height: calc(100vh - 5rem);
  overflow-y: auto;
}

@media (max-width: 760px) {
  .layout > nav {
    position: static;
    max-height: none;
  }
}

.nav-section + .nav-section {
  margin-top: 1rem;
}

.nav-section h2 {
  margin: 0 0 0.3rem;
  color: var(--fg);
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

nav li {
  margin-bottom: 0.25rem;
}

nav a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  display: block;
  padding: 0.15rem 0;
}

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

main {
  min-width: 0;
}

main h1 {
  margin-top: 0;
}

main :is(h1, h2, h3, h4, h5, h6)[id] {
  scroll-margin-top: 5rem;
}

main pre {
  background: var(--code-bg);
  padding: 1rem;
  border-radius: 6px;
  overflow-x: auto;
}

main code {
  background: var(--code-bg);
  padding: 0.15em 0.35em;
  border-radius: 4px;
  font-size: 0.9em;
}

main pre code {
  background: none;
  padding: 0;
}

main table {
  border-collapse: collapse;
  width: 100%;
  overflow-x: auto;
  display: block;
}

main th,
main td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  text-align: left;
  font-size: 0.9rem;
}

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

.page-navigation {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.page-navigation a {
  text-decoration: none;
}

.page-navigation a.next {
  grid-column: 2;
  text-align: right;
}

.page-navigation span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal {
  color: #8250df;
}

.hljs-string,
.hljs-attr {
  color: #0a3069;
}

.hljs-comment {
  color: var(--muted);
}

.hljs-number,
.hljs-built_in,
.hljs-title.function_ {
  color: #953800;
}

@media (prefers-color-scheme: dark) {
  .hljs-keyword,
  .hljs-selector-tag,
  .hljs-literal {
    color: #d2a8ff;
  }

  .hljs-string,
  .hljs-attr {
    color: #a5d6ff;
  }

  .hljs-number,
  .hljs-built_in,
  .hljs-title.function_ {
    color: #ffa657;
  }
}

/* Search widget (search-widget.ts) */
#search-root {
  position: relative;
  width: 100%;
  max-width: 320px;
}

/* Screen-reader-only (docs/reference/client-api.md): present
   in the accessibility tree for aria-live announcements, invisible and
   out of the flow for sighted users. */
.searchable-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;
}

.searchable-search-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--fg);
  font-size: 0.9rem;
}

.searchable-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  max-height: 60vh;
  overflow-y: auto;
  z-index: 20;
  display: none;
}

.searchable-search-results.is-open {
  display: block;
}

.searchable-search-results ul {
  list-style: none;
  margin: 0;
  padding: 0.25rem;
}

.searchable-search-results li a {
  display: block;
  padding: 0.5rem 0.6rem;
  border-radius: 4px;
  color: var(--fg);
  text-decoration: none;
}

.searchable-search-results li a:hover,
.searchable-search-results li a:focus {
  background: var(--code-bg);
}

.searchable-search-results .searchable-result-title {
  font-weight: 600;
  font-size: 0.9rem;
}

.searchable-search-results .searchable-result-excerpt {
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 0.15rem;
}

.searchable-search-results .searchable-empty {
  padding: 0.6rem;
  color: var(--muted);
  font-size: 0.85rem;
}
