:root {
  --brand: #2e8555;
  --brand-contrast: #ffffff;
  --bg: #ffffff;
  --bg-raised: #f6f8fa;
  --bg-sunken: #f0f2f5;
  --text: #1c1e21;
  --text-muted: #4f5561;
  --border: #dadde1;
  --note: #4b6b8a;
  --tip: #2e8555;
  --warning: #b8860b;
  --code-add: #1a7f37;
  --code-del: #c1373d;
  --sidebar-width: 17rem;
  --navbar-height: 3.75rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --brand: #25c2a0;
    --brand-contrast: #10151b;
    --bg: #1b1b1d;
    --bg-raised: #242526;
    --bg-sunken: #18191a;
    --text: #e3e3e3;
    --text-muted: #b0b3b8;
    --border: #3a3c3f;
    --note: #8fb2d4;
    --tip: #25c2a0;
    --warning: #e0b341;
    --code-add: #5ed47e;
    --code-del: #f2777a;
  }
}

:root[data-theme="dark"] {
  --brand: #25c2a0;
  --brand-contrast: #10151b;
  --bg: #1b1b1d;
  --bg-raised: #242526;
  --bg-sunken: #18191a;
  --text: #e3e3e3;
  --text-muted: #b0b3b8;
  --border: #3a3c3f;
  --note: #8fb2d4;
  --tip: #25c2a0;
  --warning: #e0b341;
  --code-add: #5ed47e;
  --code-del: #f2777a;
}

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

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a {
  color: var(--brand);
}

img {
  max-width: 100%;
}

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -4rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  border-radius: 0.4rem;
  background: var(--brand);
  color: var(--brand-contrast);
  font-weight: 600;
  text-decoration: none;
  transition: top 0.15s ease-in-out;
}

.skip-link:focus {
  top: 0.5rem;
}

/* Navbar */
.navbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: var(--navbar-height);
  padding: 0 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.navbar__brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
}

.navbar__logo {
  height: 2rem;
  width: auto;
}

.navbar__links {
  display: flex;
  gap: 1rem;
  margin-right: auto;
}

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

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

.theme-toggle {
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  padding: 0.3rem 0.6rem;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
}

/* Layout */
.page {
  display: flex;
  flex: 1;
  align-items: flex-start;
}

.sidebar {
  flex: 0 0 var(--sidebar-width);
  position: sticky;
  top: var(--navbar-height);
  max-height: calc(100vh - var(--navbar-height));
  overflow-y: auto;
  padding: 1.5rem 1rem;
  border-right: 1px solid var(--border);
}

.sidebar__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.sidebar__list .sidebar__list {
  padding-left: 0.75rem;
}

.sidebar__link {
  display: block;
  padding: 0.35rem 0.75rem;
  border-radius: 0.4rem;
  color: var(--text);
  text-decoration: none;
}

.sidebar__link:hover {
  background: var(--bg-sunken);
}

.sidebar__link[aria-current="page"] {
  background: var(--bg-sunken);
  color: var(--brand);
  font-weight: 700;
}

.sidebar__group {
  margin: 0.5rem 0 0.25rem;
  padding: 0.35rem 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 1.5rem max(1rem, 4vw) 4rem;
  scroll-margin-top: var(--navbar-height);
}

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

.footer {
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  color: var(--text-muted);
  text-align: center;
  font-size: 0.9rem;
}

/* Mobile drawer */
.drawer {
  appearance: none;
  margin: 0.75rem 1rem 0;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: 0.4rem;
  background: var(--bg-raised);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 2.4rem;
  text-align: center;
  cursor: pointer;
}

.drawer::before {
  content: "\2630";
}

.drawer:checked::before {
  content: "\2715";
}

@media (max-width: 996px) {
  .page {
    flex-wrap: wrap;
  }

  .sidebar {
    display: none;
    flex-basis: 100%;
    position: static;
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .drawer:checked ~ .sidebar {
    display: block;
  }

  .main {
    flex-basis: 100%;
  }
}

@media (min-width: 997px) {
  .drawer {
    display: none;
  }
}

/* Content */
h1,
h2,
h3 {
  line-height: 1.25;
  scroll-margin-top: calc(var(--navbar-height) + 1rem);
}

h2 {
  margin-top: 2.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}

.heading__anchor {
  margin-left: 0.4rem;
  opacity: 0;
  text-decoration: none;
}

h1:hover .heading__anchor,
h2:hover .heading__anchor,
h3:hover .heading__anchor,
.heading__anchor:focus {
  opacity: 1;
}

code {
  padding: 0.1rem 0.3rem;
  border: 1px solid var(--border);
  border-radius: 0.3rem;
  background: var(--bg-raised);
  font-size: 0.9em;
}

.code {
  margin: 1rem 0;
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--bg-raised);
  font-size: 0.875rem;
  line-height: 1.5;
}

.code code {
  padding: 0;
  border: 0;
  background: none;
  font-size: inherit;
}

.code__line {
  display: block;
}

.code__line--add {
  color: var(--code-add);
}

.code__line--del {
  color: var(--code-del);
}

/* Admonitions */
.admonition {
  margin: 1.25rem 0;
  padding: 0.75rem 1rem;
  border-left: 0.35rem solid var(--note);
  border-radius: 0.4rem;
  background: var(--bg-raised);
}

.admonition--tip {
  border-left-color: var(--tip);
}

.admonition--warning {
  border-left-color: var(--warning);
}

.admonition__heading {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.25rem;
  color: var(--note);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.admonition--tip .admonition__heading {
  color: var(--tip);
}

.admonition--warning .admonition__heading {
  color: var(--warning);
}

.admonition__icon {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

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

.admonition__body > :last-child {
  margin-bottom: 0;
}

/* Widget embeds */
.embed {
  max-width: 100%;
  border: 1px solid #1b1b1d;
}

.embed-fluid {
  margin: 1rem 0;
}

/* Homepage */
.hero {
  padding: 4rem 1rem;
  background: var(--brand);
  color: var(--brand-contrast);
  text-align: center;
}

.hero__title {
  margin: 0;
  font-size: 3rem;
}

.hero__tagline {
  margin: 0.5rem 0 0;
}

.button {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.8rem 1.5rem;
  border-radius: 0.4rem;
  background: var(--bg);
  color: var(--brand);
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
}

.home__embed {
  flex-grow: 1;
  display: flex;
  place-items: center;
  padding: 2rem max(1rem, 4vw);
}

.home__embed > * {
  flex: 1;
  max-width: 75rem;
  margin: 0 auto;
}

.home .page {
  display: block;
}

.home .main {
  display: flex;
  flex-direction: column;
  padding: 0;
}

@media screen and (max-width: 996px) {
  .hero {
    padding: 2rem;
  }

  .hero__title {
    font-size: 2.25rem;
  }
}

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

:root {
  color-scheme: light dark;
  --ink: light-dark(#102b3a, #eef7f7);
  --surface: light-dark(#f8faf8, #10242c);
  --surface-raised: light-dark(#ffffff, #16323a);
  --rule: light-dark(#c9d6d5, #35535b);
  --signal: light-dark(#006e71, #53d4c8);
  --signal-ink: light-dark(#ffffff, #062d30);
  --warm: light-dark(#cf5b2d, #ffaf85);
  --display: Georgia, "Iowan Old Style", "Palatino Linotype", serif;
  --body: "Avenir Next", Avenir, "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, monospace;
}

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

body {
  background: linear-gradient(120deg, var(--surface), color-mix(in oklab, var(--surface) 88%, var(--signal)));
  color: var(--ink);
  font-family: var(--body);
}

.navbar {
  gap: 1rem;
  padding-inline: clamp(1rem, 4vw, 4rem);
  border-color: var(--rule);
  background: color-mix(in oklab, var(--surface-raised) 90%, transparent);
  backdrop-filter: blur(14px);
}

.navbar__brand { font-family: var(--display); font-size: 1.15rem; }
.navbar__links a, .sidebar__link { color: var(--ink); }
.theme-toggle, .menu-toggle, .code-heading button {
  border: 1px solid var(--rule);
  border-radius: 0.25rem;
  background: var(--surface-raised);
  color: var(--ink);
  cursor: pointer;
  font: inherit;
}

.menu-toggle { display: none; padding: 0.35rem 0.65rem; }
.navigation-menu { inset: 4.25rem 1rem auto auto; width: min(18rem, calc(100vw - 2rem)); border: 1px solid var(--rule); border-radius: 0.4rem; background: var(--surface-raised); box-shadow: 0 1rem 2.5rem color-mix(in srgb, #001c24 25%, transparent); }
.navigation-menu a { display: block; padding: 0.8rem 1rem; color: var(--ink); text-decoration: none; }
.navigation-menu a:hover { background: color-mix(in oklab, var(--signal) 12%, var(--surface-raised)); }

.sidebar { border-color: var(--rule); background: color-mix(in oklab, var(--surface-raised) 70%, transparent); }
.sidebar__overview { display: block; margin: 0.25rem 0.75rem 0.8rem; color: var(--signal); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.08em; text-decoration: none; text-transform: uppercase; }
.sidebar__group { margin-top: 1.25rem; padding: 0.25rem 0.75rem; color: var(--ink); font-size: 0.9rem; font-weight: 700; }
.sidebar__group summary { cursor: pointer; }
.sidebar__group .sidebar__list { margin-top: 0.45rem; }
.sidebar__link[aria-current="page"] { background: color-mix(in oklab, var(--signal) 14%, var(--surface-raised)); color: var(--signal); }

.main { max-width: 78rem; padding: clamp(2rem, 5vw, 5rem); }
.main > h1, .home-intro h1 { font-family: var(--display); font-weight: 500; letter-spacing: 0; }
.main > h1 { font-size: clamp(2.4rem, 5vw, 4.7rem); max-width: 12ch; }
.main h2 { border-color: var(--rule); color: var(--signal); font-family: var(--display); font-size: clamp(1.55rem, 3vw, 2.35rem); font-weight: 500; }
.main h3 { font-size: 1.1rem; letter-spacing: 0.04em; text-transform: uppercase; }
.main p, .main li { max-width: 72ch; }
.main a { color: var(--signal); text-decoration-thickness: 0.08em; text-underline-offset: 0.15em; }
.code, code { border-color: var(--rule); background: color-mix(in oklab, var(--surface-raised) 85%, var(--signal)); font-family: var(--mono); }
.code { border-radius: 0.4rem; }
.example { container-type: inline-size; margin-block: 3.5rem; }
.example h2 { margin-top: 0; }
.admonition { border-color: var(--warm); background: color-mix(in oklab, var(--warm) 10%, var(--surface-raised)); }
.admonition__heading { color: var(--warm); }
.embed { border: 1px solid var(--rule); background: var(--surface-raised); }
.embed-fluid { aspect-ratio: var(--embed-ratio); margin-block: 1rem; }
.embed-fluid .embed { width: 100%; height: 100%; }

.home .page { display: block; }
.home .main { display: block; max-width: 84rem; margin: 0 auto; padding: clamp(2rem, 7vw, 7rem) clamp(1rem, 5vw, 4rem) 4rem; }
.home-intro { max-width: 49rem; margin-bottom: clamp(2rem, 5vw, 4rem); }
.eyebrow { margin: 0 0 0.8rem; color: var(--warm); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.home-intro h1 { margin: 0; font-size: clamp(3rem, 7vw, 6.5rem); line-height: 0.95; }
.home-intro p:last-child { max-width: 46ch; color: color-mix(in oklab, var(--ink) 68%, var(--surface)); font-size: 1.15rem; }
.workbench { display: grid; grid-template-columns: minmax(18rem, 0.7fr) minmax(0, 1.3fr); gap: 1px; overflow: clip; border: 1px solid var(--rule); border-radius: 0.5rem; background: var(--rule); container-type: inline-size; }
.workbench__controls, .workbench__preview, .workbench__code { padding: clamp(1rem, 3vw, 2rem); background: var(--surface-raised); }
.workbench__controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.workbench__controls label { display: grid; gap: 0.4rem; color: color-mix(in oklab, var(--ink) 72%, var(--surface)); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.workbench__controls select { min-width: 0; border: 1px solid var(--rule); border-radius: 0.2rem; padding: 0.65rem; background: var(--surface); color: var(--ink); font: inherit; text-transform: none; }
.workbench__preview { grid-row: span 2; display: grid; place-items: center; min-height: 25rem; container-type: inline-size; background: repeating-linear-gradient(45deg, color-mix(in oklab, var(--surface) 94%, var(--signal)) 0 1px, var(--surface-raised) 1px 12px); }
.workbench__preview .embed { width: min(100%, var(--preview-width)); height: auto; aspect-ratio: var(--preview-ratio); }
.workbench__code { min-width: 0; }
.code-heading { display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--signal); font-size: 0.8rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.code-heading button { padding: 0.4rem 0.75rem; font-size: 0.75rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.workbench__code .code { margin-bottom: 0; font-size: 0.78rem; }
.home-links { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin-top: 3rem; border: 1px solid var(--rule); background: var(--rule); }
.home-links a { display: grid; gap: 0.45rem; padding: 1.25rem; background: var(--surface-raised); color: var(--ink); text-decoration: none; }
.home-links a:hover { background: color-mix(in oklab, var(--signal) 8%, var(--surface-raised)); }
.home-links strong { color: var(--signal); font-family: var(--display); font-size: 1.3rem; font-weight: 500; }
.home-links span { color: color-mix(in oklab, var(--ink) 65%, var(--surface)); font-size: 0.9rem; }

@media (width < 52rem) {
  .workbench { grid-template-columns: 1fr; }
  .workbench__preview { grid-row: auto; min-height: 20rem; }
}

@container (width < 400px) {
  .workbench__preview .embed[data-variant="plugport"] {
    width: min(100%, 400px);
    aspect-ratio: 2 / 1;
  }
}

@media (width <= 60rem) {
  .menu-toggle { display: inline-block; }
  .navbar__links { display: none; }
  .sidebar { display: none; }
  .drawer { display: none; }
  .page { display: block; }
  .main { max-width: none; }
}

@media (width <= 40rem) {
  .workbench__controls, .home-links { grid-template-columns: 1fr; }
  .home-intro h1 { font-size: clamp(2.8rem, 16vw, 4.5rem); }
}

@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  ::view-transition-old(root) { animation: 150ms ease-out both fade-out; }
  ::view-transition-new(root) { animation: 220ms ease-out both fade-in; }
  @keyframes fade-out { to { opacity: 0; } }
  @keyframes fade-in { from { opacity: 0; } }
}
