:root {
  --brand: #1f9d55;
  --brand-strong: #17804a;
  --brand-soft: rgba(31, 157, 85, 0.12);
  --bg: #ffffff;
  --bg-alt: #f6f7f9;
  --bg-elv: #ffffff;
  --text: #1f2328;
  --text-2: #4b5563;
  --text-3: #6b7280;
  --border: #e3e6ea;
  --code-bg: #f3f4f6;
  --pre-bg: #161b22;
  --pre-text: #e6edf3;
  --warning-bg: #fff8e6;
  --warning-border: #f0c36d;
  --shadow: 0 6px 24px rgba(15, 23, 42, 0.08);
  --radius: 12px;
  --topbar-h: 64px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #34d27b;
    --brand-strong: #5ee09a;
    --brand-soft: rgba(52, 210, 123, 0.14);
    --bg: #1b1b1f;
    --bg-alt: #161618;
    --bg-elv: #202127;
    --text: #e6e8eb;
    --text-2: #b4b9c1;
    --text-3: #8b929c;
    --border: #2e2f36;
    --code-bg: #2a2b31;
    --pre-bg: #111214;
    --warning-bg: #2d2617;
    --warning-border: #8a6d2b;
    --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  }
}

* { box-sizing: border-box; }

html { scroll-padding-top: var(--topbar-h); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

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

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-strong); text-decoration: underline; }

img { max-width: 100%; height: auto; }

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 6px;
}

pre {
  position: relative;
  margin: 1.25rem 0;
  padding: 1rem 1.25rem;
  background: var(--pre-bg);
  color: var(--pre-text);
  border-radius: 10px;
  overflow-x: auto;
  line-height: 1.55;
}
pre code { background: none; padding: 0; color: inherit; font-size: 0.85rem; }

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 10px;
  font: 500 12px var(--font);
  color: #c9d1d9;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
}
pre:hover .copy-btn, .copy-btn:focus { opacity: 1; }
.copy-btn.copied { color: #7ee2a8; border-color: #7ee2a8; }

.container { max-width: 1152px; margin: 0 auto; padding: 0 24px; }
.muted { color: var(--text-3); }

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 100;
  padding: 8px 12px;
  background: var(--brand);
  color: #fff;
  border-radius: 6px;
}
.skip-link:focus { left: 8px; }

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 17px; color: var(--text); }
.brand:hover { color: var(--text); text-decoration: none; }

.site-nav { display: flex; align-items: center; gap: 4px; }
.site-nav a {
  padding: 6px 12px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  border-radius: 8px;
}
.site-nav a:hover, .site-nav a.active { color: var(--brand); text-decoration: none; }
.site-nav .github { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; border: 1px solid var(--border); }
.site-nav .stars { font-size: 13px; color: var(--text-2); }

.nav-toggle { display: none; background: none; border: 0; padding: 8px; cursor: pointer; }
.nav-toggle span { display: block; width: 20px; height: 2px; margin: 4px 0; background: var(--text); border-radius: 2px; transition: transform 0.2s, opacity 0.2s; }
.nav-open .nav-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-open .nav-toggle span:nth-child(2) { opacity: 0; }
.nav-open .nav-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Buttons */
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 28px; }
.btn {
  display: inline-block;
  padding: 0 22px;
  line-height: 42px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 21px;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { text-decoration: none; }
.btn-brand { background: var(--brand); color: #fff; }
.btn-brand:hover { background: var(--brand-strong); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-brand, .btn-brand:hover { color: #0b1d12; } }
.btn-alt { background: var(--bg-alt); color: var(--text); border-color: var(--border); }
.btn-alt:hover { color: var(--brand); border-color: var(--brand); }

/* Hero */
.hero { padding: 72px 0 56px; position: relative; overflow: hidden; }
.hero::before {
  content: "";
  position: absolute;
  inset: -40% -10% auto auto;
  width: 640px;
  height: 640px;
  background: radial-gradient(circle, var(--brand-soft) 0%, transparent 65%);
  pointer-events: none;
}
.hero-inner { display: grid; grid-template-columns: 1fr 1.1fr; gap: 48px; align-items: center; position: relative; }
.hero h1 { margin: 0; font-size: clamp(40px, 6vw, 60px); line-height: 1.08; letter-spacing: -0.02em; font-weight: 800; }
.gradient {
  background: linear-gradient(120deg, #22c55e 10%, #0ea5a4 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.tagline { margin: 16px 0 0; font-size: clamp(22px, 3vw, 30px); line-height: 1.3; font-weight: 700; color: var(--text); }
.lead { margin: 16px 0 0; font-size: 18px; color: var(--text-2); max-width: 560px; }
.hero-image img {
  display: block;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

/* Features */
.features { padding: 40px 0 72px; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 40px 48px; }
.feature .icon {
  display: block;
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  padding: 8px;
  fill: none;
  stroke: var(--brand);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  background: var(--brand-soft);
  border-radius: 10px;
}
.feature h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.feature p { margin: 0; font-size: 15px; color: var(--text-2); }

/* Sections */
.how, .quickstart, .gallery-section { padding: 64px 0; }
.how, .gallery-section { background: var(--bg-alt); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.section-title { margin: 0 0 8px; font-size: 30px; letter-spacing: -0.01em; text-align: center; }
.section-lead { max-width: 720px; margin: 0 auto 36px; text-align: center; color: var(--text-2); }
.more { text-align: center; margin: 28px 0 0; font-weight: 600; }

.steps { counter-reset: step; list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; }
.steps li {
  counter-increment: step;
  position: relative;
  padding: 16px 18px 20px;
  background: var(--bg-elv);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.steps li::before {
  content: counter(step);
  position: absolute;
  top: 16px;
  left: 18px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--brand);
  border-radius: 50%;
}
.steps strong { display: flex; align-items: center; min-height: 28px; margin-bottom: 8px; padding-left: 40px; font-size: 15px; line-height: 1.3; }
.steps span { font-size: 14px; color: var(--text-2); }

.steps.animate { position: relative; margin-bottom: 24px; }
.steps.animate li { transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s; }
.steps.animate:not(.in-view) li { opacity: 0; }
.steps.in-view li { animation: step-in 0.5s ease-out backwards; }
.steps.in-view li:nth-child(2) { animation-delay: 0.1s; }
.steps.in-view li:nth-child(3) { animation-delay: 0.2s; }
.steps.in-view li:nth-child(4) { animation-delay: 0.3s; }
.steps.in-view li:nth-child(5) { animation-delay: 0.4s; }
@keyframes step-in { from { opacity: 0; transform: translateY(16px); } }

.steps li.active { border-color: var(--brand); box-shadow: var(--shadow); transform: translateY(-4px); }
.steps li.active::before { animation: step-pulse 1.2s ease-out infinite; }
.steps li.done::before { content: "\2713"; }
@keyframes step-pulse { from { box-shadow: 0 0 0 0 var(--brand); } to { box-shadow: 0 0 0 10px transparent; } }

.steps.animate::before, .steps.animate::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -20px;
  height: 3px;
  border-radius: 3px;
}
.steps.animate::before { right: 0; background: var(--border); }
.steps.animate::after { width: 0; background: var(--brand); transition: width 0.6s ease; }
.steps[data-step="1"]::after { width: 10%; }
.steps[data-step="2"]::after { width: 30%; }
.steps[data-step="3"]::after { width: 50%; }
.steps[data-step="4"]::after { width: 70%; }
.steps[data-step="5"]::after { width: 90%; }
.steps[data-step="6"]::after { width: 100%; }

.tabs { max-width: 860px; margin: 0 auto; }
.tab-list { display: flex; gap: 8px; border-bottom: 1px solid var(--border); }
.tab-list button {
  padding: 10px 16px;
  font: 600 15px var(--font);
  color: var(--text-2);
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab-list button small { display: block; font-weight: 400; font-size: 12px; font-family: var(--mono); color: var(--text-3); }
.tab-list button[aria-selected="true"] { color: var(--brand); border-bottom-color: var(--brand); }
.tab-panel p { color: var(--text-2); }

/* Gallery */
.screencast { max-width: 960px; margin: 0 auto 40px; }
.screencast img { display: block; width: 100%; border-radius: var(--radius); border: 1px solid var(--border); box-shadow: var(--shadow); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.shot {
  display: block;
  overflow: hidden;
  background: var(--bg-elv);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.shot:hover { border-color: var(--brand); box-shadow: var(--shadow); text-decoration: none; color: var(--text); }
.shot img { display: block; width: 100%; aspect-ratio: 16 / 10; object-fit: cover; object-position: top left; border-bottom: 1px solid var(--border); }
.shot span { display: block; padding: 10px 14px; font-size: 14px; font-weight: 500; }

.page-header { padding: 56px 0 8px; text-align: center; }
.page-header h1 { margin: 0 0 8px; font-size: 40px; letter-spacing: -0.02em; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 72px;
  background: rgba(0, 0, 0, 0.88);
}
.lightbox[hidden] { display: none; }
.lightbox figure { margin: 0; max-width: 100%; max-height: 100%; text-align: center; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 140px); border-radius: 8px; }
.lightbox figcaption { margin-top: 12px; color: #e5e7eb; font-size: 15px; }
.lightbox button {
  position: absolute;
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
  border: 0;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.lightbox button:hover { background: rgba(255, 255, 255, 0.22); }
.lightbox-close { top: 16px; right: 16px; }
.lightbox-prev { left: 16px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 16px; top: 50%; transform: translateY(-50%); }
.lightbox.single .lightbox-prev, .lightbox.single .lightbox-next { display: none; }

/* Docs */
.docs-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 220px;
  gap: 40px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}
.docs-sidebar, .docs-toc {
  position: sticky;
  top: var(--topbar-h);
  align-self: start;
  max-height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 32px 0;
}
.docs-sidebar { border-right: 1px solid var(--border); padding-right: 16px; }
.sidebar-title { margin: 0 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text); }
.docs-sidebar ul, .docs-toc ul { list-style: none; margin: 0 0 24px; padding: 0; }
.docs-sidebar a { display: block; padding: 5px 10px; font-size: 14px; color: var(--text-2); border-radius: 6px; }
.docs-sidebar a:hover { color: var(--brand); text-decoration: none; }
.docs-sidebar a.active { color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.docs-toc { border-left: 1px solid var(--border); padding-left: 16px; }
.docs-toc a { display: block; padding: 3px 0; font-size: 13px; color: var(--text-2); }
.docs-toc a:hover, .docs-toc a.active { color: var(--brand); text-decoration: none; }
.docs-toc .toc-h3 a { padding-left: 14px; }

.docs-content { padding: 40px 0 64px; min-width: 0; max-width: 820px; }

.markdown h1 { margin: 0 0 24px; font-size: 34px; line-height: 1.2; letter-spacing: -0.02em; }
.markdown h2 { margin: 48px 0 16px; padding-top: 24px; font-size: 24px; line-height: 1.3; border-top: 1px solid var(--border); }
.markdown h3 { margin: 32px 0 8px; font-size: 19px; }
.markdown h4 { margin: 24px 0 8px; font-size: 16px; }
.markdown h2, .markdown h3, .markdown h4 { position: relative; }
.markdown .anchor {
  position: absolute;
  left: -0.9em;
  padding-right: 0.2em;
  color: var(--brand);
  opacity: 0;
  font-weight: 500;
  transition: opacity 0.15s;
}
.markdown h2 .anchor { top: 24px; }
.markdown :is(h2, h3, h4):hover .anchor, .markdown .anchor:focus { opacity: 1; text-decoration: none; }
.markdown p, .markdown ul, .markdown ol { margin: 16px 0; }
.markdown li + li { margin-top: 6px; }
.markdown ul:has(input[type="checkbox"]) { padding-left: 0; }
.markdown li:has(> input[type="checkbox"], > label > input[type="checkbox"]) { list-style: none; padding-left: 26px; }
.markdown li input[type="checkbox"] { margin: 0 10px 0 -26px; width: 16px; height: 16px; vertical-align: -2px; accent-color: var(--brand); cursor: pointer; }
.markdown li > label { cursor: pointer; }
.markdown li > label:has(input:checked) { color: var(--text-3); }
.markdown blockquote {
  margin: 16px 0;
  padding: 10px 16px;
  color: var(--text-2);
  background: var(--brand-soft);
  border-left: 4px solid var(--brand);
  border-radius: 0 8px 8px 0;
}
.markdown blockquote p { margin: 6px 0; }
.markdown table {
  display: block;
  width: 100%;
  overflow-x: auto;
  margin: 20px 0;
  border-collapse: collapse;
  font-size: 14px;
}
.markdown th, .markdown td { padding: 9px 14px; border: 1px solid var(--border); text-align: left; vertical-align: top; }
.markdown th { background: var(--bg-alt); font-weight: 600; }
.markdown tr:nth-child(2n) td { background: color-mix(in srgb, var(--bg-alt) 50%, transparent); }
.markdown img { border: 1px solid var(--border); border-radius: 8px; }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 40px 0 24px; }

.callout { padding: 16px 20px; border-radius: var(--radius); border: 1px solid var(--border); }
.callout-warning { background: var(--warning-bg); border-color: var(--warning-border); }
.callout h1 { margin-top: 0; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 56px; }
.pager a {
  display: block;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-weight: 600;
}
.pager a:hover { border-color: var(--brand); text-decoration: none; }
.pager small { display: block; font-size: 12px; font-weight: 500; color: var(--text-3); }
.pager .next { text-align: right; grid-column: 2; }
.edit-link { margin-top: 24px; font-size: 14px; }

/* 404 */
.not-found { padding: 120px 0; text-align: center; }
.not-found .code { margin: 0; font-size: 72px; font-weight: 800; color: var(--brand); line-height: 1; }
.not-found h1 { margin: 12px 0 8px; }
.not-found .actions { justify-content: center; }

/* Footer */
.footer { border-top: 1px solid var(--border); padding: 32px 0; text-align: center; font-size: 14px; color: var(--text-2); }
.section-docs .footer { margin-top: 0; }
.footer-inner { max-width: 900px; margin: 0 auto; padding: 0 24px; }
.footer p { margin: 4px 0; }

/* Seasonal events (SITE_EVENT) */
.brand, .site-nav .github { position: relative; }
.santa-hat { position: absolute; pointer-events: none; filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3)); }
.brand .santa-hat { top: -12px; left: -11px; width: 30px; transform: scaleX(-1) rotate(22deg); }
.site-nav .github .santa-hat { top: -15px; right: -15px; width: 32px; transform: rotate(26deg); }

.xmas-lights { position: absolute; left: 0; right: 0; bottom: -9px; height: 12px; pointer-events: none; }
.xmas-lights::before, .xmas-lights::after {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: repeat-x;
  background-size: 96px 12px;
  filter: drop-shadow(0 0 3px rgba(255, 220, 120, 0.7));
  animation: twinkle 1.6s ease-in-out infinite;
}
.xmas-lights::before {
  background-image: radial-gradient(circle, #ff4d4d 0 3.5px, transparent 4.5px), radial-gradient(circle, #ffd166 0 3.5px, transparent 4.5px);
  background-position: 0 0, 48px 0;
}
.xmas-lights::after {
  background-image: radial-gradient(circle, #4cc9f0 0 3.5px, transparent 4.5px), radial-gradient(circle, #ff70a6 0 3.5px, transparent 4.5px);
  background-position: 24px 0, 72px 0;
  animation-delay: 0.8s;
}
@keyframes twinkle { 50% { opacity: 0.3; } }

.event-banner { padding: 8px 24px; text-align: center; font-size: 14px; font-weight: 600; color: #fff; background: linear-gradient(90deg, #b91c1c, #15803d 50%, #b91c1c); }
.event-newyear .event-banner { background: linear-gradient(90deg, #1e1b4b, #6d28d9 50%, #1e1b4b); }

.event-sky { position: fixed; top: var(--topbar-h); left: 0; right: 0; z-index: 40; height: 180px; overflow: hidden; pointer-events: none; }
.firework { position: absolute; width: 110px; opacity: 0; animation: burst 3.6s ease-out infinite; }
.firework.f1 { top: 10px; left: 5%; color: #ffd166; }
.firework.f2 { top: 50px; right: 6%; width: 90px; color: #ff70a6; animation-delay: 1.2s; }
.firework.f3 { top: 0; left: 62%; width: 70px; color: #4cc9f0; animation-delay: 2.4s; }
@keyframes burst {
  0% { opacity: 0; transform: scale(0.2); }
  12% { opacity: 1; }
  55%, 100% { opacity: 0; transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .event-sky { display: none; }
  .xmas-lights::before, .xmas-lights::after { animation: none; }
}

/* Responsive */
@media (max-width: 1200px) {
  .docs-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .docs-toc { display: none; }
}

@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; }
  .hero { padding-top: 48px; }
  .steps { grid-template-columns: 1fr 1fr; }
  .steps.animate { margin-bottom: 0; }
  .steps.animate::before, .steps.animate::after { display: none; }
  .feature-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .feature-grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width: 768px) {
  .nav-toggle { display: block; }
  .site-nav {
    position: absolute;
    top: var(--topbar-h);
    left: 0;
    right: 0;
    display: none;
    flex-direction: column;
    align-items: stretch;
    padding: 12px 24px 20px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .nav-open .site-nav { display: flex; }
  .site-nav .github { margin: 8px 0 0; justify-content: center; }
  .docs-layout { grid-template-columns: 1fr; gap: 0; }
  .docs-sidebar { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); padding: 16px 0; }
  .docs-sidebar ul { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
  .docs-content { padding-top: 24px; }
  .steps { grid-template-columns: 1fr; }
  .gallery { grid-template-columns: 1fr; }
  .lightbox { padding: 56px 12px; }
  .markdown .anchor { display: none; }
}
