/* ==========================================================================
   Chartizer docs — design tokens
   Dark is the primary theme; light is a full re-map of the same tokens.
   ========================================================================== */

:root {
  --bg: #0b0c0e;
  --bg-soft: #121317;
  --bg-card: #141519;
  --bg-card-hover: #191b20;
  --bg-code: #0f1013;
  --bg-inline: rgba(255, 255, 255, 0.07);

  --border: #24262c;
  --border-soft: #1b1d22;
  --border-strong: #33363e;

  --text: #e7e9ec;
  --text-dim: #a6adb8;
  --text-faint: #767d88;

  --accent: #4d9fe8;
  --accent-hover: #6bb0ee;
  --accent-soft: rgba(77, 159, 232, 0.14);
  --accent-border: rgba(77, 159, 232, 0.35);

  --green: #33b17c;
  --green-soft: rgba(51, 177, 124, 0.13);
  --amber: #dda01c;
  --amber-soft: rgba(221, 160, 28, 0.13);
  --orange: #f58233;
  --orange-soft: rgba(245, 130, 51, 0.13);
  --red: #e5534b;
  --red-soft: rgba(229, 83, 75, 0.13);
  --purple: #8b7cf6;
  --purple-soft: rgba(139, 124, 246, 0.15);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.55);

  --radius: 10px;
  --radius-lg: 14px;

  --navbar-h: 60px;
  --sidebar-w: 270px;
  --toc-w: 232px;
  --content-max: 780px;

  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;

  color-scheme: dark;
}

[data-theme="light"] {
  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-card: #ffffff;
  --bg-card-hover: #f7f8fa;
  --bg-code: #f8f9fb;
  --bg-inline: rgba(16, 18, 22, 0.06);

  --border: #e4e7ec;
  --border-soft: #eef0f3;
  --border-strong: #d3d8df;

  --text: #16181d;
  --text-dim: #59616e;
  --text-faint: #858d9a;

  --accent: #1a7ed1;
  --accent-hover: #1569b0;
  --accent-soft: rgba(26, 126, 209, 0.09);
  --accent-border: rgba(26, 126, 209, 0.28);

  --green: #17805a;
  --green-soft: rgba(23, 128, 90, 0.09);
  --amber: #9a6f05;
  --amber-soft: rgba(154, 111, 5, 0.1);
  --orange: #c65a12;
  --orange-soft: rgba(198, 90, 18, 0.09);
  --red: #c73a32;
  --red-soft: rgba(199, 58, 50, 0.08);
  --purple: #6146d8;
  --purple-soft: rgba(97, 70, 216, 0.1);

  --shadow-sm: 0 1px 2px rgba(16, 18, 22, 0.06);
  --shadow-lg: 0 24px 60px rgba(16, 18, 22, 0.18);

  color-scheme: light;
}

/* ==========================================================================
   base
   ========================================================================== */

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

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--navbar-h) + 24px);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--accent);
  text-decoration: none;
}

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

.icon {
  width: 16px;
  height: 16px;
  flex: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius) 0;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: var(--accent-soft);
}

/* scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

*::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}

*::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 99px;
  border: 2px solid transparent;
  background-clip: content-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: var(--text-faint);
  background-clip: content-box;
}

/* ==========================================================================
   navbar
   ========================================================================== */

.navbar {
  position: sticky;
  top: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.navbar.scrolled {
  border-bottom-color: var(--border);
  box-shadow: 0 1px 14px rgba(0, 0, 0, 0.25);
}

[data-theme="light"] .navbar.scrolled {
  box-shadow: 0 1px 14px rgba(16, 18, 22, 0.06);
}

.navbar-inner {
  height: var(--navbar-h);
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
}

.brand:hover {
  color: var(--text);
}

.brand-logo {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: block;
}

/* Wordmark: the real vector mark, inheriting --text so it themes with the page */
.brand-wordmark {
  height: 17px;
  width: auto;
  display: block;
  color: var(--text);
  flex: none;
}

.navbar-spacer {
  flex: 1;
}

.navbar-links {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-right: 6px;
}

.navbar-links a {
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 450;
}

.navbar-links a:hover {
  color: var(--text);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--bg-inline);
  color: var(--text);
}

.icon-btn .icon {
  width: 18px;
  height: 18px;
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: block;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  margin-left: 6px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, transform 0.15s;
}

.cta:hover {
  background: var(--accent-hover);
  color: #fff;
}

.cta-arrow {
  width: 14px;
  height: 14px;
  transition: transform 0.15s;
}

.cta:hover .cta-arrow {
  transform: translateX(2px);
}

.nav-toggle {
  display: none;
  margin-left: -6px;
}

/* ==========================================================================
   shell / sidebar
   ========================================================================== */

.shell {
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 40px;
  align-items: start;
}

/* The sidebar itself must not clip, so the search dropdown can overlay the
   nav below it. Scrolling moves to .sidebar-scroll instead. */
.sidebar {
  position: sticky;
  top: var(--navbar-h);
  height: calc(100vh - var(--navbar-h));
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px 8px 0 0;
  overflow: visible;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 48px;
}

.kbd-hint,
kbd {
  font-family: var(--font);
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text-faint);
}

.kbd-mod {
  font-size: 12px;
}

.nav-groups {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-group-head {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 7px 8px;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  border-radius: 7px;
  text-align: left;
}

.nav-group-head:hover {
  background: var(--bg-inline);
}

.group-icon {
  color: var(--text-faint);
  width: 15px;
  height: 15px;
}

.nav-group-head span {
  flex: 1;
}

.group-caret {
  width: 14px;
  height: 14px;
  color: var(--text-faint);
  transition: transform 0.18s;
  transform: rotate(-90deg);
}

.nav-group.open .group-caret {
  transform: rotate(0deg);
}

.nav-list {
  list-style: none;
  margin: 2px 0 8px;
  padding: 0 0 0 16px;
  border-left: 1px solid var(--border-soft);
  display: none;
}

.nav-group.open .nav-list {
  display: block;
}

.nav-link {
  display: block;
  position: relative;
  padding: 6px 10px;
  margin: 1px 0;
  border-radius: 7px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.45;
  transition: color 0.13s, background 0.13s;
}

.nav-link:hover {
  color: var(--text);
  background: var(--bg-inline);
}

.nav-link.active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: 550;
}

.nav-link.active::before {
  content: "";
  position: absolute;
  left: -17px;
  top: 6px;
  bottom: 6px;
  width: 2px;
  border-radius: 2px;
  background: var(--accent);
}

/* ==========================================================================
   content
   ========================================================================== */

.content {
  min-width: 0;
  padding: 40px 0 80px;
}

.article {
  max-width: var(--content-max);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.crumb-sep {
  width: 13px;
  height: 13px;
}

.page-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.2;
  font-weight: 650;
  letter-spacing: -0.02em;
}

/* status label — set `status:` in a page's frontmatter.
   Plain text, no chip or pill: it is a note about the page, not a button. */
.badge {
  display: inline-block;
  vertical-align: middle;
  margin-left: 12px;
  color: var(--amber);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  line-height: 1.3;
  white-space: nowrap;
}

.badge-sm {
  margin-left: 8px;
  font-size: 11.5px;
  font-weight: 400;
  vertical-align: baseline;
}

.page-description {
  margin: 12px 0 0;
  font-size: 17px;
  line-height: 1.6;
  color: var(--text-dim);
}

.prose {
  margin-top: 36px;
}

.prose > *:first-child {
  margin-top: 0;
}

.prose h2,
.prose h3,
.prose h4 {
  scroll-margin-top: calc(var(--navbar-h) + 24px);
  font-weight: 620;
  letter-spacing: -0.01em;
  position: relative;
}

.prose h2 {
  margin: 48px 0 16px;
  padding-top: 24px;
  border-top: 1px solid var(--border-soft);
  font-size: 23px;
  line-height: 1.35;
}

.prose h3 {
  margin: 32px 0 12px;
  font-size: 17.5px;
}

.prose h4 {
  margin: 26px 0 10px;
  font-size: 15.5px;
}

.prose p {
  margin: 16px 0;
}

.prose ul,
.prose ol {
  margin: 16px 0;
  padding-left: 22px;
}

.prose li {
  margin: 7px 0;
}

.prose li::marker {
  color: var(--text-faint);
}

.prose strong {
  font-weight: 620;
  color: var(--text);
}

.prose hr {
  margin: 40px 0;
  border: none;
  border-top: 1px solid var(--border-soft);
}

.prose blockquote {
  margin: 20px 0;
  padding: 2px 0 2px 18px;
  border-left: 3px solid var(--border-strong);
  color: var(--text-dim);
}

.prose blockquote p {
  margin: 8px 0;
}

/* inline code */
.prose :not(pre) > code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.15em 0.4em;
  border-radius: 5px;
  background: var(--bg-inline);
  color: var(--text);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
}

.prose a:not(.card-link):not(.header-anchor) {
  text-decoration: underline;
  text-decoration-color: var(--accent-border);
  text-underline-offset: 3px;
}

.external-link::after {
  content: "↗";
  display: inline-block;
  margin-left: 2px;
  font-size: 0.85em;
  opacity: 0.7;
}

/* heading anchors */
.header-anchor {
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  color: var(--text-faint);
  transition: opacity 0.15s;
}

.prose h2 .header-anchor {
  top: calc(50% + 12px);
}

.prose h2:hover .header-anchor,
.prose h3:hover .header-anchor,
.prose h4:hover .header-anchor,
.header-anchor:focus-visible {
  opacity: 1;
}

.anchor-icon {
  width: 15px;
  height: 15px;
}

/* images */
.md-image {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
  display: block;
  margin: 20px 0;
  cursor: zoom-in;
}

/* ==========================================================================
   video
   ========================================================================== */

.video-frame {
  margin: 28px 0;
  padding: 0;
}

.video-media,
.video-placeholder {
  display: block;
  width: 100%;
  aspect-ratio: var(--video-ratio, 16 / 9);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--bg-card);
  overflow: hidden;
}

.video-media {
  object-fit: cover;
}

.video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border-style: dashed;
  border-color: var(--border-strong);
  background: linear-gradient(
    180deg,
    var(--bg-card) 0%,
    color-mix(in srgb, var(--accent) 5%, var(--bg-card)) 100%
  );
  text-align: center;
  padding: 20px;
}

.video-play {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1px solid var(--accent-border);
  color: var(--accent);
}

.video-play .icon {
  width: 20px;
  height: 20px;
  fill: currentColor;
  margin-left: 3px; /* optical centring of the triangle */
}

.video-placeholder-label {
  font-size: 15px;
  font-weight: 550;
  color: var(--text);
  max-width: 34ch;
  line-height: 1.45;
}

.video-placeholder-hint {
  font-size: 12.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.video-caption {
  padding: 10px 4px 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-dim);
  text-align: center;
}

.video-caption:empty {
  display: none;
}

.video-caption > *:first-child {
  margin-top: 0;
}

.video-caption > *:last-child {
  margin-bottom: 0;
}

.frame {
  margin: 24px 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
}

.frame .md-image {
  margin: 0;
  border-radius: 8px;
  width: 100%;
}

.frame[data-caption]::after {
  content: attr(data-caption);
  display: block;
  padding: 10px 6px 4px;
  font-size: 13px;
  color: var(--text-faint);
  text-align: center;
}

/* tables */
.table-wrap {
  margin: 22px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.prose th {
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-soft);
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.prose td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}

.prose tr:last-child td {
  border-bottom: none;
}

/* ==========================================================================
   callouts
   ========================================================================== */

.callout {
  display: flex;
  gap: 12px;
  margin: 22px 0;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--bg-card);
}

.callout-icon {
  flex: none;
  padding-top: 2px;
}

.callout-icon .icon {
  width: 17px;
  height: 17px;
}

.callout-body {
  min-width: 0;
  flex: 1;
}

.callout-title {
  margin: 0 0 4px;
  font-weight: 600;
  font-size: 14px;
}

.callout-body > *:last-child {
  margin-bottom: 0;
}

.callout-body p {
  margin: 6px 0;
  font-size: 14.5px;
  color: var(--text-dim);
}

.callout-body ul,
.callout-body ol {
  margin: 8px 0;
  font-size: 14.5px;
  color: var(--text-dim);
}

.callout-note,
.callout-info {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}

.callout-note .callout-icon,
.callout-note .callout-title,
.callout-info .callout-icon,
.callout-info .callout-title {
  color: var(--accent);
}

.callout-tip {
  border-left-color: var(--green);
  background: var(--green-soft);
}

.callout-tip .callout-icon,
.callout-tip .callout-title {
  color: var(--green);
}

.callout-check {
  border-left-color: var(--green);
  background: var(--green-soft);
}

.callout-check .callout-icon,
.callout-check .callout-title {
  color: var(--green);
}

.callout-warning {
  border-left-color: var(--amber);
  background: var(--amber-soft);
}

.callout-warning .callout-icon,
.callout-warning .callout-title {
  color: var(--amber);
}

.callout-danger {
  border-left-color: var(--red);
  background: var(--red-soft);
}

.callout-danger .callout-icon,
.callout-danger .callout-title {
  color: var(--red);
}

/* ==========================================================================
   cards
   ========================================================================== */

.card-grid {
  display: grid;
  gap: 14px;
  margin: 24px 0;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card-grid[data-cols="1"] {
  grid-template-columns: minmax(0, 1fr);
}

.card-grid[data-cols="3"] {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.card {
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.card-link:hover {
  border-color: var(--accent-border);
  background: var(--bg-card-hover);
  transform: translateY(-1px);
}

.card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-bottom: 12px;
  border-radius: 9px;
  background: var(--accent-soft);
  color: var(--accent);
}

.card-icon .icon {
  width: 18px;
  height: 18px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.card-arrow {
  display: inline-flex;
  opacity: 0;
  color: var(--accent);
  transition: opacity 0.15s, transform 0.15s;
}

.card-arrow .icon {
  width: 15px;
  height: 15px;
}

.card-link:hover .card-arrow {
  opacity: 1;
  transform: translateX(2px);
}

.card-body {
  color: var(--text-dim);
  font-size: 14px;
}

.card-body > *:first-child {
  margin-top: 0;
}

.card-body > *:last-child {
  margin-bottom: 0;
}

.card-body p {
  margin: 0;
}

/* ==========================================================================
   code blocks
   ========================================================================== */

.code-block {
  margin: 22px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-code);
  overflow: hidden;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px 8px 14px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--bg-soft);
}

.code-title {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-lang {
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

.copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.copy-btn:hover {
  color: var(--text);
  background: var(--bg-inline);
  border-color: var(--border);
}

.copy-btn .icon {
  width: 13px;
  height: 13px;
}

.copy-done {
  display: none;
  color: var(--green);
}

.copy-btn.copied .copy-idle {
  display: none;
}

.copy-btn.copied .copy-done {
  display: block;
}

.copy-btn.copied {
  color: var(--green);
}

.code-body {
  display: flex;
  overflow-x: auto;
}

.code-block pre {
  margin: 0;
  padding: 14px 16px;
  flex: 1;
  min-width: 0;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  tab-size: 2;
}

.code-lines {
  flex: none;
  padding: 14px 0 14px 14px;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--text-faint);
  user-select: none;
  border-right: 1px solid var(--border-soft);
}

.code-lines span {
  display: block;
  padding-right: 12px;
}

/* code groups + tabs share the panel-switching pattern */
.code-group,
.tabs {
  margin: 22px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.code-group > .code-block,
.tabs > .tab-panel {
  margin: 0;
  border: none;
  border-radius: 0;
}

.code-group > .code-block:not(:first-of-type),
.tabs > .tab-panel:not(:first-of-type) {
  display: none;
}

.code-group[data-ready] > .code-block,
.tabs[data-ready] > .tab-panel {
  display: none;
}

.code-group[data-ready] > .code-block.active,
.tabs[data-ready] > .tab-panel.active {
  display: block;
}

.code-group[data-ready] .code-head {
  border-radius: 0;
}

.panel-tabs {
  display: flex;
  gap: 2px;
  padding: 6px 8px 0;
  background: var(--bg-soft);
  border-bottom: 1px solid var(--border-soft);
  overflow-x: auto;
  scrollbar-width: none;
}

.panel-tabs::-webkit-scrollbar {
  display: none;
}

.panel-tab {
  padding: 7px 12px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-faint);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.panel-tab:hover {
  color: var(--text);
}

.panel-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.code-group[data-ready] .code-head {
  display: none;
}

.code-group[data-ready] .code-block .copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background: var(--bg-soft);
  border-color: var(--border);
}

.code-group[data-ready] .code-block {
  position: relative;
}

.tab-panel {
  padding: 16px 18px;
  background: var(--bg-card);
}

.tab-panel > *:first-child {
  margin-top: 0;
}

.tab-panel > *:last-child {
  margin-bottom: 0;
}

.tab-panel .code-block {
  background: var(--bg-code);
}

/* ==========================================================================
   steps
   ========================================================================== */

.steps {
  margin: 24px 0;
  counter-reset: step;
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 16px;
  padding-bottom: 26px;
}

.step:last-child {
  padding-bottom: 0;
}

.step-marker {
  counter-increment: step;
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-marker::before {
  content: counter(step);
}

/* connector line spans the whole step, so tall steps stay connected */
.step:not(:last-child)::before {
  content: "";
  position: absolute;
  top: 32px;
  left: 14px;
  bottom: -4px;
  width: 1px;
  background: var(--border-soft);
}

.step-content {
  min-width: 0;
  padding-top: 2px;
}

.step-content > *:first-child {
  margin-top: 0;
}

.step-content > *:last-child {
  margin-bottom: 0;
}

.step-title {
  margin: 0 0 8px;
  font-size: 16px;
  font-weight: 600;
  line-height: 1.5;
}

/* ==========================================================================
   accordion
   ========================================================================== */

.accordion {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  overflow: hidden;
}

.accordion-head {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 13px 16px;
  font-size: 14.5px;
  font-weight: 550;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.accordion-head::-webkit-details-marker {
  display: none;
}

.accordion-head:hover {
  background: var(--bg-card-hover);
}

.accordion-caret {
  color: var(--text-faint);
  transition: transform 0.18s;
  width: 15px;
  height: 15px;
}

.accordion[open] .accordion-caret {
  transform: rotate(90deg);
}

.accordion-body {
  padding: 2px 16px 16px 40px;
  color: var(--text-dim);
  font-size: 14.5px;
}

.accordion-body > *:first-child {
  margin-top: 0;
}

.accordion-body > *:last-child {
  margin-bottom: 0;
}

/* ==========================================================================
   pagination + footer
   ========================================================================== */

.pagination {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 64px;
}

.page-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--bg-card);
  transition: border-color 0.15s, background 0.15s;
}

.page-nav:hover {
  border-color: var(--accent-border);
  background: var(--bg-card-hover);
  color: var(--text);
}

.page-nav .icon {
  color: var(--text-faint);
  flex: none;
}

.page-nav.next {
  justify-content: flex-end;
  text-align: right;
}

.page-nav span {
  display: block;
  min-width: 0;
}

.page-nav-label {
  font-size: 12.5px;
  color: var(--text-faint);
  margin-bottom: 2px;
}

.page-nav-title {
  font-size: 14.5px;
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--border-soft);
  font-size: 13px;
  color: var(--text-faint);
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.footer-links a {
  color: var(--text-dim);
}

.footer-meta {
  display: flex;
  gap: 16px;
}

/* ==========================================================================
   table of contents
   ========================================================================== */

.toc {
  position: sticky;
  top: var(--navbar-h);
  max-height: calc(100vh - var(--navbar-h));
  overflow-y: auto;
  padding: 44px 0 48px;
}

.toc-title {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border-soft);
}

.toc-list a {
  display: block;
  padding: 5px 0 5px 14px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-faint);
  font-size: 13.5px;
  line-height: 1.5;
  transition: color 0.13s, border-color 0.13s;
}

.toc-list a:hover {
  color: var(--text);
}

.toc-list a.active {
  color: var(--accent);
  border-left-color: var(--accent);
}

.toc-h3 a {
  padding-left: 26px;
  font-size: 13px;
}

/* ==========================================================================
   inline search — a field in the sidebar with results dropping beneath it
   ========================================================================== */

/* centred in the navbar, taking the space left between brand and actions */
.search-box {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  max-width: 460px;
  margin: 0 auto;
  z-index: 70;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.search-field:hover {
  border-color: var(--border-strong);
}

.search-box.focused .search-field {
  border-color: var(--accent-border);
  background: var(--bg);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-field .search-icon {
  color: var(--text-faint);
  flex: none;
}

.search-box.focused .search-field .search-icon {
  color: var(--accent);
}

#search-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  padding: 0;
}

#search-input::placeholder {
  color: var(--text-faint);
}

#search-input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.search-box.focused .kbd-hint {
  display: none;
}

/* hangs beneath the field, widening past it when there is room */
.search-dropdown {
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  max-height: min(66vh, 560px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-soft);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 50;
  animation: drop 0.13s ease;
}

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

@keyframes drop {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(-4px);
  }
  to {
    transform: translateX(-50%) translateY(0);
  }
}

.search-results {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 6px;
}

.result-group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 10px 6px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.result-count {
  color: var(--text-faint);
  font-size: 11.5px;
  font-weight: 400;
  letter-spacing: 0;
}

.result {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  color: var(--text);
}

.result:hover,
.result.selected {
  background: var(--bg-card);
  border-color: var(--border);
  color: var(--text);
}

.result.selected {
  border-color: var(--accent-border);
}

.result-chip {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
}

.result-chip .icon {
  width: 16px;
  height: 16px;
}

/* the three lines are spans, so they need to be blocks or they run together */
.result-text {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.result-crumb,
.result-title,
.result-snippet {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-crumb {
  font-size: 11.5px;
  line-height: 1.4;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}

.result-title {
  font-size: 14px;
  font-weight: 550;
  line-height: 1.45;
  color: var(--text);
}

.result-snippet {
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-dim);
}

.result mark {
  background: transparent;
  color: var(--accent);
  font-weight: 600;
}

.search-empty {
  padding: 26px 18px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13.5px;
}

.search-foot {
  display: flex;
  gap: 16px;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
  font-size: 11.5px;
  color: var(--text-faint);
}

.search-foot span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.search-foot .icon {
  width: 13px;
  height: 13px;
}

/* ==========================================================================
   image lightbox
   ========================================================================== */

@keyframes fade {
  from {
    opacity: 0;
  }
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: rgba(0, 0, 0, 0.85);
  cursor: zoom-out;
  animation: fade 0.15s ease;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* ==========================================================================
   responsive
   ========================================================================== */

.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(0, 0, 0, 0.5);
}

.backdrop.show {
  display: block;
}

@media (max-width: 1200px) {
  .shell {
    grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
    gap: 32px;
  }

  .toc {
    display: none;
  }
}

@media (max-width: 960px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    padding: 0 20px;
  }

  .nav-toggle {
    display: inline-flex;
  }

  .search-trigger-sm {
    display: inline-flex;
  }

  .navbar-links {
    display: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 58;
    width: 290px;
    height: 100vh;
    padding: 20px 16px 40px;
    background: var(--bg-soft);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform 0.22s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .search-box {
    max-width: none;
  }

  .content {
    padding-top: 28px;
  }

  .page-title {
    font-size: 29px;
  }

  .card-grid,
  .card-grid[data-cols="3"] {
    grid-template-columns: minmax(0, 1fr);
  }

  .pagination {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .navbar-inner {
    padding: 0 16px;
  }

  .cta {
    display: none;
  }

  /* the search field gets the width the wordmark gives up */
  .brand-wordmark {
    display: none;
  }

  .search-field .kbd-hint {
    display: none;
  }

  .shell {
    padding: 0 16px;
  }

  .search-foot {
    display: none;
  }

  .page-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ==========================================================================
   syntax highlighting (highlight.js token classes)
   ========================================================================== */

.hljs {
  color: var(--text);
  background: transparent;
}

.hljs-comment,
.hljs-quote {
  color: #6b7280;
  font-style: italic;
}

.hljs-keyword,
.hljs-selector-tag,
.hljs-literal,
.hljs-type {
  color: #c792ea;
}

.hljs-string,
.hljs-regexp,
.hljs-addition,
.hljs-attribute,
.hljs-meta .hljs-string {
  color: #8bd49c;
}

.hljs-number,
.hljs-variable,
.hljs-template-variable,
.hljs-selector-attr,
.hljs-selector-pseudo {
  color: #f5a97f;
}

.hljs-title,
.hljs-section,
.hljs-title.function_,
.hljs-name {
  color: #7cb7f0;
}

.hljs-attr,
.hljs-property,
.hljs-selector-class,
.hljs-selector-id {
  color: #ffd479;
}

.hljs-built_in,
.hljs-class .hljs-title,
.hljs-symbol,
.hljs-bullet,
.hljs-link {
  color: #67d5c4;
}

.hljs-meta,
.hljs-doctag,
.hljs-tag {
  color: #9aa0a6;
}

.hljs-deletion {
  color: #e5534b;
}

.hljs-emphasis {
  font-style: italic;
}

.hljs-strong {
  font-weight: 600;
}

[data-theme="light"] .hljs-comment,
[data-theme="light"] .hljs-quote {
  color: #7a828e;
}

[data-theme="light"] .hljs-keyword,
[data-theme="light"] .hljs-selector-tag,
[data-theme="light"] .hljs-literal,
[data-theme="light"] .hljs-type {
  color: #8250df;
}

[data-theme="light"] .hljs-string,
[data-theme="light"] .hljs-regexp,
[data-theme="light"] .hljs-addition,
[data-theme="light"] .hljs-attribute {
  color: #0a7a45;
}

[data-theme="light"] .hljs-number,
[data-theme="light"] .hljs-variable,
[data-theme="light"] .hljs-template-variable {
  color: #b8500f;
}

[data-theme="light"] .hljs-title,
[data-theme="light"] .hljs-section,
[data-theme="light"] .hljs-name {
  color: #0a5fbd;
}

[data-theme="light"] .hljs-attr,
[data-theme="light"] .hljs-property,
[data-theme="light"] .hljs-selector-class {
  color: #96590b;
}

[data-theme="light"] .hljs-built_in,
[data-theme="light"] .hljs-symbol,
[data-theme="light"] .hljs-bullet {
  color: #0b7285;
}
