:root {
  --bg: #fcfcfd;
  --panel: #ffffff;
  --line: #e4e4e7;
  --line-strong: #d4d4d8;
  --text: #0f172a;
  --muted: #334155;
  --subtle: #64748b;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --code-bg: #0b1220;
  --code-fg: #dbe7ff;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 10px 26px rgba(15, 23, 42, 0.05);
}

html[data-theme="dark"] {
  --bg: #090d18;
  --panel: #0f172a;
  --line: #1f2d44;
  --line-strong: #2a3d5a;
  --text: #e6edf8;
  --muted: #9fb1cb;
  --subtle: #8ea1bd;
  --accent: #60a5fa;
  --accent-soft: rgba(96, 165, 250, 0.14);
  --code-bg: #050b17;
  --code-fg: #dbe8ff;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 14px 34px rgba(0, 0, 0, 0.26);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "Inter", "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 18% -8%, rgba(37, 99, 235, 0.08), transparent 30%),
    radial-gradient(circle at 82% -20%, rgba(14, 165, 233, 0.07), transparent 32%);
  background-attachment: fixed;
  font-size: 15px;
  line-height: 1.6;
  text-rendering: optimizeLegibility;
}

html[data-theme="dark"] body {
  background-image:
    radial-gradient(circle at 18% -8%, rgba(59, 130, 246, 0.14), transparent 34%),
    radial-gradient(circle at 82% -20%, rgba(14, 165, 233, 0.12), transparent 36%);
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 12px;
  z-index: 100;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 600;
}

.skip-link:focus {
  top: 10px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(10px);
}

.topbar-inner {
  width: min(1360px, 96vw);
  min-height: 64px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 1fr minmax(180px, 260px) auto auto;
  align-items: center;
  gap: 10px;
}

.brand {
  text-decoration: none;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.top-nav a {
  text-decoration: none;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 8px;
  padding: 7px 8px;
  transition: background-color 130ms ease, color 130ms ease;
}

.top-nav a:hover {
  background: color-mix(in srgb, var(--accent-soft) 75%, transparent);
  color: var(--text);
}

.top-nav a.active {
  color: var(--text);
  background: color-mix(in srgb, var(--accent-soft) 100%, transparent);
  font-weight: 600;
}

.top-search {
  position: relative;
}

.top-search::after {
  content: "/";
  position: absolute;
  right: 9px;
  top: 50%;
  transform: translateY(-50%);
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  color: var(--subtle);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 1px 5px;
  background: var(--panel);
  pointer-events: none;
}

.top-search input {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  padding: 0 38px 0 11px;
  font-size: 13px;
  color: var(--text);
  background: var(--panel);
}

.top-search input::placeholder {
  color: var(--subtle);
}

.top-search input:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.search-results {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  left: 0;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
  display: none;
  overflow: hidden;
}

.search-results.visible {
  display: block;
}

.search-item {
  display: block;
  text-decoration: none;
  color: var(--text);
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
}

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

.search-item:hover {
  background: color-mix(in srgb, var(--accent-soft) 80%, transparent);
}

.search-title {
  font-size: 12px;
  font-weight: 600;
}

.search-desc {
  margin-top: 2px;
  font-size: 11px;
  color: var(--subtle);
}

.search-empty {
  padding: 10px 11px;
  font-size: 11px;
  color: var(--subtle);
}

.theme-toggle,
.lang-switch {
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.theme-toggle {
  width: 32px;
  cursor: pointer;
}

.lang-switch {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 11px;
}

.theme-toggle:hover,
.lang-switch:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line-strong));
}

.docs-shell {
  width: min(1360px, 96vw);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 220px;
  gap: 26px;
  padding: 24px 0 52px;
}

.sidebar,
.toc {
  position: sticky;
  top: 82px;
  align-self: start;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 14px;
}

.sidebar-title,
.toc-title {
  margin: 10px 0 8px;
  color: var(--subtle);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.sidebar-title:first-child,
.toc-title:first-child {
  margin-top: 0;
}

.side-link,
.toc-link {
  display: block;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  border-radius: 8px;
  padding: 7px 9px;
  margin-bottom: 2px;
}

.side-link:hover,
.toc-link:hover {
  background: color-mix(in srgb, var(--accent-soft) 82%, transparent);
}

.side-link.active {
  background: color-mix(in srgb, var(--accent-soft) 100%, transparent);
  color: var(--accent);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent);
}

.toc-link.active {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent-soft) 80%, transparent);
}

.toc-link.toc-sub {
  padding-left: 17px;
  color: var(--muted);
}

.content {
  min-width: 0;
}

.doc {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 34px;
}

.breadcrumb {
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--subtle);
}

.breadcrumb a {
  color: inherit;
  text-decoration: none;
}

.kicker {
  margin: 0;
  color: var(--subtle);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
}

h1 {
  margin: 10px 0 12px;
  font-size: clamp(30px, 3.8vw, 42px);
  line-height: 1.12;
  letter-spacing: -0.02em;
}

.lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 16.5px;
  line-height: 1.72;
  max-width: 72ch;
}

h2 {
  margin: 28px 0 10px;
  font-size: 22px;
  line-height: 1.3;
  scroll-margin-top: 92px;
  position: relative;
}

h3 {
  margin: 20px 0 8px;
  font-size: 17px;
  line-height: 1.35;
  scroll-margin-top: 92px;
  position: relative;
}

.heading-anchor {
  position: absolute;
  left: -1.15em;
  top: 0.03em;
  text-decoration: none;
  color: var(--subtle);
  font-size: 0.84em;
  opacity: 0;
  transition: opacity 140ms ease;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor {
  opacity: 1;
}

p,
li {
  color: color-mix(in srgb, var(--text) 92%, var(--muted));
  line-height: 1.78;
}

ul,
ol {
  margin: 8px 0 0;
  padding-left: 22px;
}

pre {
  margin: 10px 0 0;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #1f2f4a;
  background: linear-gradient(180deg, #101a31 0%, var(--code-bg) 100%);
  overflow-x: auto;
  position: relative;
}

pre.has-copy {
  padding-top: 42px;
}

.copy-btn {
  position: absolute;
  top: 9px;
  right: 10px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid rgba(148, 163, 184, 0.5);
  background: rgba(15, 23, 42, 0.65);
  color: #d0e2ff;
  font-size: 11px;
  font-weight: 700;
  padding: 0 9px;
  cursor: pointer;
}

.copy-btn:hover {
  border-color: rgba(147, 197, 253, 0.8);
  color: #fff;
}

code {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  color: var(--code-fg);
  font-size: 12.5px;
}

.callout {
  margin: 14px 0;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  background: color-mix(in srgb, var(--accent-soft) 85%, transparent);
  border-radius: 10px;
  padding: 10px 12px;
}

.callout strong {
  color: var(--accent);
}

.callout.warn {
  border-color: #f2dfc0;
  background: #fff8ee;
}

html[data-theme="dark"] .callout.warn {
  background: #2a2113;
  border-color: #5a4521;
}

.callout.warn strong {
  color: #a16207;
}

.card-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.doc-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: var(--panel);
  transition: transform 130ms ease, border-color 130ms ease;
}

.doc-card:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}

.doc-card h3 {
  margin: 0 0 8px;
}

.doc-card p {
  margin: 0 0 10px;
  font-size: 14px;
}

.doc-card a {
  text-decoration: none;
  color: var(--accent);
  font-size: 12.5px;
  font-weight: 700;
}

.meta-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 13.5px;
}

.meta-table th,
.meta-table td {
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  padding: 9px 10px;
}

.meta-table th {
  background: color-mix(in srgb, var(--accent-soft) 80%, transparent);
  font-weight: 700;
}

.quick-links {
  margin-top: 18px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-links a {
  text-decoration: none;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 700;
}

.quick-links a:hover {
  border-color: color-mix(in srgb, var(--accent) 36%, var(--line-strong));
  color: var(--text);
}

.footer {
  width: min(1360px, 96vw);
  margin: 0 auto;
  border-top: 1px solid var(--line);
  padding: 16px 0 28px;
  color: var(--subtle);
  font-size: 12px;
}

.footer a {
  color: inherit;
}

@media (max-width: 1240px) {
  .docs-shell {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

@media (max-width: 980px) {
  .topbar-inner {
    grid-template-columns: 1fr;
    padding: 10px 0;
    gap: 9px;
  }

  .top-nav {
    order: 2;
  }

  .top-search {
    order: 3;
  }

  .theme-toggle {
    order: 4;
    justify-self: start;
  }

  .lang-switch {
    order: 5;
    justify-self: start;
  }

  .docs-shell {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .sidebar {
    position: static;
  }

  .doc {
    padding: 22px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }
}
