:root {
  color-scheme: dark;
  --sl-hue: 212;
  --bg: #0d1117;
  --bg-elevated: #161b22;
  --bg-subtle: #1c2128;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-faint: #6e7681;
  --border: #30363d;
  --border-subtle: #21262d;
  --accent: #2563eb;
  --accent-hover: #3b82f6;
  --accent-soft: rgba(37, 99, 235, 0.14);
  --accent-text: #60a5fa;
  --code-bg: #161b22;
  --link: #58a6ff;
  --link-hover: #79c0ff;
  --callout-bg: rgba(56, 139, 253, 0.1);
  --callout-border: rgba(56, 139, 253, 0.35);
  --header-h: 3.5rem;
  --mobile-bar-h: 0px;
  --header-offset: var(--header-h);
  --sidebar-w: 17.5rem;
  --radius: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-video: 0.875rem;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.24);
  --content-max: 46rem;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --bg-elevated: #f6f8fa;
  --bg-subtle: #f0f3f7;
  --text: #1f2328;
  --text-muted: #59636e;
  --text-faint: #818b98;
  --border: #d0d7de;
  --border-subtle: #e6eaef;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: rgba(37, 99, 235, 0.08);
  --accent-text: #2563eb;
  --code-bg: #f6f8fa;
  --link: #0969da;
  --link-hover: #0550ae;
  --callout-bg: rgba(9, 105, 218, 0.08);
  --callout-border: rgba(9, 105, 218, 0.28);
  --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.08);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #ffffff;
    --bg-elevated: #f6f8fa;
    --bg-subtle: #f0f3f7;
    --text: #1f2328;
    --text-muted: #59636e;
    --text-faint: #818b98;
    --border: #d0d7de;
    --border-subtle: #e6eaef;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.08);
    --accent-text: #2563eb;
    --code-bg: #f6f8fa;
    --link: #0969da;
    --link-hover: #0550ae;
    --callout-bg: rgba(9, 105, 218, 0.08);
    --callout-border: rgba(9, 105, 218, 0.28);
    --shadow-sm: 0 1px 2px rgba(31, 35, 40, 0.08);
  }
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.6;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.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;
}

/* Header — Astro / Starlight style */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
  max-width: 100%;
  padding: 0 1rem 0 1.25rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.brand-logo {
  display: block;
  height: 1.75rem;
  width: auto;
  max-width: 10rem;
  object-fit: contain;
}

.brand-logo--light {
  display: none;
}

:root[data-theme="light"] .brand-logo--dark {
  display: none;
}

:root[data-theme="light"] .brand-logo--light {
  display: block;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .brand-logo--dark {
    display: none;
  }

  :root:not([data-theme="dark"]) .brand-logo--light {
    display: block;
  }
}

.brand-mark {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 0.35rem;
  background: linear-gradient(135deg, var(--accent) 0%, #0ea5e9 100%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 40%, var(--border));
}

.header-search {
  position: relative;
  flex: 1 1 16rem;
  max-width: 16rem;
}

.search-input {
  width: 100%;
  height: 2.25rem;
  padding: 0 2rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

.search-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}

.search-clear {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.5rem;
  height: 1.5rem;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}

.header-nav {
  display: none;
  gap: 1.25rem;
}

.header-nav a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.header-nav a:hover {
  color: var(--text);
}

.theme-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  flex-shrink: 0;
}

.theme-btn {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}

.theme-btn:hover {
  color: var(--text);
  background: var(--bg-subtle);
}

.theme-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.mobile-nav-bar {
  display: none;
}

/* Docs shell — Vue / Starlight sidebar layout */
.docs-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: calc(100vh - var(--header-offset));
}

.sidebar {
  position: sticky;
  top: var(--header-offset);
  height: calc(100vh - var(--header-offset));
  border-right: 1px solid var(--border);
  background: var(--bg-elevated);
  overflow: hidden;
}

.sidebar-scroll {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.25rem 0.75rem 2rem;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.sidebar-kicker,
.sidebar-group-title {
  margin: 0 0.5rem 0.5rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.sidebar-group-title {
  margin-top: 1.25rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar-link {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: var(--radius);
  padding: 0.45rem 0.65rem;
  background: transparent;
  color: var(--text-muted);
  text-decoration: none;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.35;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}

.sidebar-link:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.sidebar-link.active,
.sidebar-link--module.active {
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 600;
}

.sidebar-link-title {
  display: block;
}

.sidebar-link-desc {
  display: none;
}

.sidebar-link.hidden {
  display: none;
}

.card-thumb {
  display: none;
}

.sidebar-toggle,
.sidebar-backdrop {
  display: none;
}

.sidebar-toggle {
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  width: 100%;
  border: 0;
  border-radius: var(--radius);
  padding: 0.55rem 1rem;
  background: var(--bg-subtle);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: var(--bg-elevated);
  color: var(--accent-text);
}

body.sidebar-open {
  overflow: hidden;
}

/* Main content */
.docs-main {
  min-width: 0;
  padding: 2rem 1.5rem 4rem;
}

.doc-page {
  max-width: var(--content-max);
  margin: 0 auto 3.5rem;
  scroll-margin-top: calc(var(--header-offset) + 1rem);
}

.doc-page[hidden] {
  display: none !important;
}

.page-eyebrow {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent-text);
}

.page-title {
  margin: 0 0 0.75rem;
  font-size: clamp(2rem, 4vw, 2.75rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-heading {
  margin: 0 0 0.65rem;
  font-size: 1.75rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: -0.02em;
  scroll-margin-top: calc(var(--header-offset) + 1rem);
}

.page-lead,
.module-hint {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 42rem;
}

/* Callout — Starlight aside style */
.callout {
  margin-top: 1.5rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--callout-border);
  background: var(--callout-bg);
}

.callout-title {
  margin: 0 0 0.35rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.callout p:last-child {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.92rem;
}

/* Video player — rounded corners */
.video-player {
  position: relative;
  width: 100%;
  max-width: 42rem;
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-video);
  overflow: hidden;
  border: 1px solid var(--border);
  background: #000;
  box-shadow: var(--shadow-sm);
}

.video-player iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Module doc area */
.module-doc {
  margin-top: 1.5rem;
}

.module-screenshot {
  float: right;
  width: min(11rem, 38%);
  margin: 0 0 1rem 1.25rem;
  text-align: center;
}

.module-screenshot-btn {
  display: block;
  width: 100%;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-subtle);
  cursor: zoom-in;
}

.module-screenshot-btn img {
  display: block;
  width: 100%;
  height: auto;
}

.module-screenshot-caption {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.module-doc::after {
  content: "";
  display: table;
  clear: both;
}

/* Prose — docs typography */
.prose {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.7;
}

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

.prose :last-child {
  margin-bottom: 0;
}

.prose h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.3;
  scroll-margin-top: calc(var(--header-offset) + 1rem);
}

.prose h3 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.1rem;
  font-weight: 600;
  scroll-margin-top: calc(var(--header-offset) + 1rem);
}

.prose p,
.prose ul,
.prose ol {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.35rem;
}

.prose li {
  margin: 0.25rem 0;
}

.prose a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.prose a:hover {
  color: var(--link-hover);
}

.prose code {
  font-family: var(--font-mono);
  font-size: 0.875em;
  padding: 0.15em 0.35em;
  border-radius: 0.25rem;
  background: var(--code-bg);
  border: 1px solid var(--border-subtle);
}

.prose pre {
  margin: 1rem 0;
  padding: 1rem;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  background: var(--code-bg);
  border: 1px solid var(--border);
}

.prose pre code {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 0.85rem;
}

.prose table {
  width: 100%;
  margin: 1rem 0 1.25rem;
  border-collapse: collapse;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

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

.prose th {
  background: var(--bg-subtle);
  font-weight: 600;
}

.prose blockquote {
  margin: 1rem 0;
  padding: 0.5rem 0 0.5rem 1rem;
  border-left: 3px solid var(--accent);
  color: var(--text-muted);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.readme-error {
  padding: 1rem;
  border-radius: var(--radius-lg);
  border: 1px solid var(--callout-border);
  background: var(--callout-bg);
}

/* Download link cards */
.link-cards {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
}

.link-card {
  display: block;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  text-decoration: none;
  color: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.link-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.link-card-title {
  display: block;
  font-weight: 600;
  color: var(--text);
}

.link-card-desc {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Footer */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1.5rem 2rem;
  text-align: center;
  color: var(--text-faint);
  font-size: 0.875rem;
}

.site-footer p {
  margin: 0.35rem 0 0;
}

.footer-logo {
  display: inline-block;
  width: min(9.5rem, 100%);
  height: auto;
  object-fit: contain;
  margin-bottom: 0.5rem;
  opacity: 0.9;
}

.footer-logo--light {
  display: none;
}

:root[data-theme="light"] .footer-logo--dark {
  display: none;
}

:root[data-theme="light"] .footer-logo--light {
  display: inline-block;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) .footer-logo--dark {
    display: none;
  }

  :root:not([data-theme="dark"]) .footer-logo--light {
    display: inline-block;
  }
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.footer-links a {
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 500;
}

.footer-links a:hover {
  text-decoration: underline;
}

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
}

.lightbox[hidden] {
  display: none;
}

.lightbox-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
}

.lightbox-inner {
  position: relative;
  z-index: 1;
  max-width: min(92vw, 1100px);
  max-height: 90vh;
  padding: 1rem;
}

.lightbox-close {
  position: absolute;
  top: -0.25rem;
  right: 0;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.lightbox-img {
  display: block;
  max-width: 100%;
  max-height: calc(90vh - 3rem);
  border-radius: var(--radius-lg);
}

.lightbox-caption {
  margin: 0.75rem 0 0;
  text-align: center;
  color: #fff;
  font-size: 0.9rem;
}

body.lightbox-open {
  overflow: hidden;
}

/* Responsive */
@media (min-width: 900px) {
  .header-nav {
    display: flex;
  }
}

@media (max-width: 899px) {
  :root {
    --mobile-bar-h: 2.85rem;
    --header-offset: calc(var(--header-h) + var(--mobile-bar-h));
  }

  .site-header {
    height: auto;
  }

  .mobile-nav-bar {
    display: block;
    padding: 0.45rem 1rem 0.55rem;
    border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--bg) 92%, transparent);
  }

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

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

  .sidebar {
    position: fixed;
    top: var(--header-offset);
    left: 0;
    bottom: 0;
    width: min(var(--sidebar-w), 100%);
    max-width: 100%;
    height: auto;
    z-index: 60;
    transform: translateX(-100%);
    visibility: hidden;
    pointer-events: none;
    transition: transform 0.22s ease, visibility 0.22s ease;
    box-shadow: var(--shadow-sm);
  }

  .sidebar.is-open {
    transform: translateX(0);
    visibility: visible;
    pointer-events: auto;
  }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: var(--header-offset) 0 0 0;
    z-index: 55;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
  }

  .sidebar-backdrop[hidden] {
    display: none;
  }

  .module-screenshot {
    float: none;
    width: 100%;
    max-width: 16rem;
    margin: 0 0 1rem;
  }
}

@media (max-width: 640px) {
  .header-search {
    max-width: none;
  }

  .theme-switch .theme-btn {
    padding: 0.35rem 0.4rem;
    font-size: 0.7rem;
  }
}
