:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --ink: #1b2430;
  --muted: #5a6573;
  --line: #e3e7ee;
  --line-strong: #cfd6e0;
  --accent: #1d4f91;
  --accent-soft: #e8eef8;
  --ok: #1b7a4a;
  --warn: #8a5b00;
  --warn-soft: #f8f1e0;
  --code-bg: #1c2330;
  --code-ink: #e8edf4;
  --topbar-bg: rgba(255, 255, 255, 0.92);
  --shadow: rgba(16, 24, 40, 0.08);
  --sidebar: 16.5rem;
  --frame: 72rem;
  --radius: 8px;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #10141c;
    --surface: #171c26;
    --ink: #e8edf4;
    --muted: #9aa6b8;
    --line: #2c3545;
    --line-strong: #3d4a5e;
    --accent: #8bb4ff;
    --accent-soft: rgba(139, 180, 255, 0.14);
    --ok: #6dca96;
    --warn: #e6b35c;
    --warn-soft: #3a3018;
    --code-bg: #0f131a;
    --code-ink: #e8edf4;
    --topbar-bg: rgba(23, 28, 38, 0.92);
    --shadow: rgba(0, 0, 0, 0.35);
  }
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #10141c;
  --surface: #171c26;
  --ink: #e8edf4;
  --muted: #9aa6b8;
  --line: #2c3545;
  --line-strong: #3d4a5e;
  --accent: #8bb4ff;
  --accent-soft: rgba(139, 180, 255, 0.14);
  --ok: #6dca96;
  --warn: #e6b35c;
  --warn-soft: #3a3018;
  --code-bg: #0f131a;
  --code-ink: #e8edf4;
  --topbar-bg: rgba(23, 28, 38, 0.92);
  --shadow: rgba(0, 0, 0, 0.35);
}

html[data-theme="light"] {
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 4.75rem;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration: underline;
}

.skip {
  position: absolute;
  left: -999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 40;
  background: var(--accent);
  color: #fff;
  padding: 0.4rem 0.7rem;
}

.frame {
  width: min(var(--frame), 100%);
  margin-inline: auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  height: 3.6rem;
  padding: 0 1.5rem;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand small {
  color: var(--muted);
  font-weight: 500;
  font-size: 0.8rem;
}

.langs {
  display: flex;
  gap: 0.15rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.langs a {
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.75rem;
  font-weight: 600;
}

.langs a[aria-current="page"],
.theme-switch button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 0 0 1px var(--line);
}

.theme-switch {
  display: flex;
  gap: 0.15rem;
  padding: 0.15rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
}

.theme-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.85rem;
  height: 1.55rem;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-switch button:hover {
  color: var(--ink);
}

.theme-switch svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.topbar nav {
  margin-left: auto;
  display: flex;
  gap: 1rem;
  font-size: 0.92rem;
}

.topbar nav a {
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}

.topbar nav a:hover {
  color: var(--ink);
}

.menu-btn {
  display: none;
  margin-left: auto;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font: inherit;
  font-weight: 600;
}

.shell {
  display: grid;
  grid-template-columns: var(--sidebar) minmax(0, 1fr);
  min-height: calc(100vh - 3.6rem);
  background: var(--surface);
  border-inline: 1px solid var(--line);
}

.sidebar {
  position: sticky;
  top: 3.6rem;
  height: calc(100vh - 3.6rem);
  overflow: auto;
  padding: 1.5rem 1rem 2.5rem 1.15rem;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.sidebar h2 {
  margin: 1.35rem 0 0.35rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar h2:first-child {
  margin-top: 0;
}

.sidebar a {
  display: block;
  padding: 0.28rem 0.55rem;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.92rem;
  border-radius: 6px;
}

.sidebar a:hover,
.sidebar a.active {
  color: var(--accent);
  background: var(--accent-soft);
}

.content {
  min-width: 0;
  padding: 2.4rem 2.6rem 5rem;
}

.hero {
  margin-bottom: 2rem;
  padding-bottom: 1.6rem;
  border-bottom: 1px solid var(--line);
}

.kicker {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}

h1,
h2,
h3 {
  color: var(--ink);
  letter-spacing: -0.02em;
  line-height: 1.25;
}

h1 {
  margin: 0 0 0.7rem;
  font-size: 2.15rem;
  font-weight: 700;
}

h2 {
  margin: 2.6rem 0 0.75rem;
  padding-top: 0.4rem;
  font-size: 1.4rem;
  font-weight: 700;
}

h3 {
  margin: 1.5rem 0 0.45rem;
  font-size: 1.08rem;
}

.lede {
  max-width: 40rem;
  margin: 0;
  color: var(--muted);
  font-size: 1.05rem;
}

.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.1rem 0 0;
  padding: 0;
  list-style: none;
}

.pills li {
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
}

.note,
.warn {
  margin: 1.15rem 0;
  padding: 0.9rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 0.95rem;
}

.note {
  border-left: 3px solid var(--accent);
}

.warn {
  border-left: 3px solid var(--warn);
  background: var(--warn-soft);
}

table {
  width: 100%;
  margin: 1rem 0 1.35rem;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: auto;
  font-size: 0.92rem;
}

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

th {
  background: var(--bg);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

td.best {
  color: var(--ok);
  font-weight: 700;
}

.note p:last-child,
.warn p:last-child {
  margin-bottom: 0;
}

code,
kbd {
  font-family: var(--mono);
  font-size: 0.9em;
}

p code,
li code,
td code {
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
}

.prewrap {
  margin: 1rem 0 1.4rem;
  overflow: hidden;
  border: 1px solid #121722;
  border-radius: var(--radius);
  background: var(--code-bg);
}

.prewrap-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0.7rem;
  border-bottom: 1px solid #2a3344;
  color: #9aa7b8;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.copy {
  background: transparent;
  color: #c5d0dc;
  border: 1px solid #3a4558;
  border-radius: 4px;
  padding: 0.18rem 0.5rem;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}

.copy:hover {
  color: #fff;
  border-color: #6b7c94;
}

pre,
pre[class*="language-"] {
  margin: 0;
  overflow: auto;
  padding: 1rem 1.05rem 1.1rem !important;
  background: transparent !important;
  font-family: var(--mono);
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--code-ink);
}

code[class*="language-"],
pre[class*="language-"] {
  text-shadow: none;
}

.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
  color: #7d8a9a;
}

.token.punctuation {
  color: #b7c2d0;
}

.token.namespace {
  opacity: 1;
}

.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
  color: #7dc4ff;
}

.token.boolean,
.token.number {
  color: #d4a657;
}

.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
  color: #8bd49c;
}

.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string,
.token.variable {
  color: #c5d0dc;
}

.token.atrule,
.token.attr-value,
.token.function,
.token.class-name {
  color: #6cb6ff;
}

.token.keyword {
  color: #c792ea;
}

.token.regex,
.token.important {
  color: #e6b35c;
}

.tree {
  display: grid;
  gap: 0.45rem;
  margin: 1.15rem 0 1.5rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-family: var(--mono);
  font-size: 0.875rem;
}

.tree .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.7rem;
}

.tree .seg {
  color: var(--accent);
  font-weight: 600;
}

.tree .dim {
  color: var(--muted);
}

.playground {
  margin: 1.15rem 0 1.7rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.playground .paths {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.playground button {
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.28rem 0.65rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  cursor: pointer;
}

.playground button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.log {
  margin: 0;
  min-height: 7.2rem;
  padding: 0.85rem 0.95rem !important;
  border-radius: 6px;
  background: var(--code-bg) !important;
  color: #9aa7b8;
  white-space: pre-wrap;
}

.log .hit {
  color: #8bd49c;
}

.log .miss {
  color: #e6b35c;
}

.cap {
  margin: 1.15rem 0 0.4rem;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cap:first-child {
  margin-top: 0;
}

.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 0.5rem 0 1.4rem;
}

.pair .prewrap {
  margin: 0;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
}

.card {
  padding: 1rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.card h3 {
  margin-top: 0;
}

.card p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

footer {
  margin-top: 3.2rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 900px) {
  .menu-btn {
    display: inline-flex;
  }

  .topbar nav {
    display: none;
  }

  .shell {
    grid-template-columns: 1fr;
    border-inline: 0;
  }

  .sidebar {
    position: fixed;
    inset: 3.6rem auto 0 0;
    width: min(20rem, 88vw);
    transform: translateX(-105%);
    z-index: 15;
    box-shadow: 8px 0 24px var(--shadow);
    transition: transform 0.2s ease;
  }

  .sidebar.open {
    transform: none;
  }

  .content {
    padding: 1.4rem 1.05rem 4rem;
  }

  .grid-2,
  .pair {
    grid-template-columns: 1fr;
  }
}

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