:root {
  --nord0: #2e3440;
  --nord1: #3b4252;
  --nord2: #434c5e;
  --nord3: #4c566a;
  --nord4: #d8dee9;
  --nord5: #e5e9f0;
  --nord6: #eceff4;
  --nord7: #8fbcbb;
  --nord8: #88c0d0;
  --nord9: #81a1c1;
  --nord10: #5e81ac;
  --nord11: #bf616a;
  --nord12: #d08770;
  --nord13: #ebcb8b;
  --nord14: #a3be8c;
  --nord15: #b48ead;
  --bg: var(--nord6);
  --bg-2: var(--nord5);
  --ink: var(--nord0);
  --muted: var(--nord3);
  --line: var(--nord4);
  --card: #ffffff;
  --accent: var(--nord10);
  --accent-2: #4a6b91; /* nord10 darkened to clear 4.5:1 on --bg */
  --btn: #4a6b91;
  --btn-ink: #ffffff;
  --finder: var(--nord6);
  --finder-bar: var(--nord5);
  --finder-side: var(--nord5);
  --finder-pane: #ffffff;
  --scroll: var(--nord4);
  --veil: rgba(236, 239, 244, 0.82);
  --ok: var(--nord14);
  --warn: var(--nord13);
  --stop: var(--nord11);
  --tok-kw: var(--nord10);
  --tok-str: #4c7a3e;
  --tok-cmt: var(--nord3);
  --tok-fn: var(--nord9);
  --tok-num: var(--nord15);
  --sans: system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, monospace;
  --pad: clamp(1.25rem, 5vw, 3.5rem);
  --maxw: 70rem;
  --top-h: 3.5rem;
}

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

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: var(--nord0);
    --bg-2: var(--nord1);
    --ink: var(--nord6);
    --muted: #a9b3c4;
    --line: var(--nord2);
    --card: var(--nord1);
    --accent: var(--nord8);
    --accent-2: var(--nord8);
    --btn: var(--nord8);
    --btn-ink: var(--nord0);
    --finder: var(--nord1);
    --finder-bar: var(--nord2);
    --finder-side: var(--nord0);
    --finder-pane: #242933;
    --scroll: var(--nord3);
    --veil: rgba(46, 52, 64, 0.82);
    --tok-kw: var(--nord9);
    --tok-str: var(--nord14);
    --tok-cmt: #7b869a;
    --tok-fn: var(--nord8);
    --tok-num: var(--nord15);
  }
}

:root[data-theme="dark"] {
  --bg: var(--nord0);
  --bg-2: var(--nord1);
  --ink: var(--nord6);
  --muted: #a9b3c4;
  --line: var(--nord2);
  --card: var(--nord1);
  --accent: var(--nord8);
  --accent-2: var(--nord8);
  --btn: var(--nord8);
  --btn-ink: var(--nord0);
  --finder: var(--nord1);
  --finder-bar: var(--nord2);
  --finder-side: var(--nord0);
  --finder-pane: #242933;
  --scroll: var(--nord3);
  --veil: rgba(46, 52, 64, 0.82);
  --tok-kw: var(--nord9);
  --tok-str: var(--nord14);
  --tok-cmt: #7b869a;
  --tok-fn: var(--nord8);
  --tok-num: var(--nord15);
}

* { box-sizing: border-box; }
html {
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent-2); text-underline-offset: 3px; }
code, .code, pre, .api-grid h3 { font-family: var(--mono); }
code { font-size: 0.86em; }
h1, h2, h3 { text-wrap: balance; }

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

main > section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad);
  scroll-margin-top: calc(var(--top-h) + 1.5rem);
}

/* --- header --- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 1.5rem;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 var(--pad);
  background: var(--veil);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
.mark {
  color: var(--ink);
  text-decoration: none;
  font-weight: 620;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}
.top nav {
  display: flex;
  gap: 1.4rem;
  font-size: 0.875rem;
  margin-left: auto;
}
.top nav a {
  color: var(--muted);
  text-decoration: none;
  transition: color 0.12s ease;
}
.top nav a:hover { color: var(--ink); }

.theme {
  display: flex;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
.theme button {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 2rem;
  height: 1.75rem;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.theme button:hover { color: var(--ink); }
.theme button svg { width: 14px; height: 14px; display: block; }
.theme button + button { border-left: 1px solid var(--line); }
.theme button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--bg);
}
.theme button[aria-pressed="true"]:hover { color: var(--bg); }

/* --- hero --- */

.hero {
  padding-top: 3.5rem;
  padding-bottom: 4.5rem;
  text-align: center;
}
.hero-copy { max-width: 38rem; margin: 0 auto; }
.hero-icon {
  display: block;
  width: 7rem;
  height: 7rem;
  margin: 0 auto 1.4rem;
}
.hero h1 {
  font-size: clamp(2.4rem, 6vw, 3.5rem);
  font-weight: 640;
  letter-spacing: -0.035em;
  line-height: 1.05;
  margin: 0 0 0.9rem;
}
.byline {
  margin: 0 auto 1.75rem;
  font-size: 1.075rem;
  line-height: 1.55;
  color: var(--muted);
  max-width: 33rem;
  text-wrap: pretty;
}
.cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.9rem 1.6rem;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--btn);
  color: var(--btn-ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding: 0.7rem 1.35rem;
  border-radius: 9px;
  transition: filter 0.12s ease;
}
.btn:hover { filter: brightness(1.08); }
.ghost {
  color: var(--ink);
  font-size: 0.95rem;
  text-decoration-color: var(--line);
}
.ghost:hover { text-decoration-color: currentColor; }
.fineprint {
  margin: 1.5rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.hero-code {
  margin: 3rem auto 0;
  max-width: 40rem;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
}
.hero-code pre {
  margin: 0;
  padding: 1.15rem 1.35rem;
  font-size: 0.8rem;
  line-height: 1.7;
  overflow-x: auto;
}
.hero-code figcaption {
  border-top: 1px solid var(--line);
  padding: 0.55rem 1.35rem;
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--bg-2);
}

/* --- capabilities --- */

.can { padding-bottom: 3.5rem; }
.can-head {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.5rem;
  align-items: baseline;
  justify-content: space-between;
  position: sticky;
  top: var(--top-h);
  z-index: 5;
  margin: 0 calc(var(--pad) * -1);
  padding: 0.9rem var(--pad);
  background: var(--veil);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}
h2 {
  font-size: 1.3rem;
  font-weight: 620;
  letter-spacing: -0.02em;
  margin: 0;
}
.search input {
  width: min(16rem, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  font: 400 0.875rem/1.4 var(--sans);
  padding: 0.45rem 0.7rem;
  border-radius: 8px;
}
.search input::placeholder { color: var(--muted); }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.group {
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0 2.5rem;
  padding: 1.4rem 0;
  border-top: 1px solid var(--line);
}
.group h3 {
  margin: 0.1rem 0 0;
  font-family: var(--sans);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}
.group-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr));
  gap: 1rem 1.75rem;
}
.card b {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.005em;
}
.card span {
  display: block;
  margin-top: 0.1rem;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--muted);
  text-wrap: pretty;
}
.cards.empty-msg::after {
  content: "No matches.";
  display: block;
  padding: 1.4rem 0;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
}

/* --- plugins / finder --- */

.source { padding-bottom: 3.5rem; }
.source-copy { max-width: 36rem; margin-bottom: 1.4rem; }
.source-copy p { color: var(--muted); margin: 0.5rem 0 0; }
.finder {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--finder);
  height: min(34rem, 75vh);
  display: flex;
  flex-direction: column;
}
.finder-chrome {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  height: 2.35rem;
  padding: 0 0.85rem;
  background: var(--finder-bar);
  border-bottom: 1px solid var(--line);
  flex: none;
}
.traffic { display: flex; gap: 7px; }
.traffic i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: block;
}
.traffic i:nth-child(1) { background: var(--stop); }
.traffic i:nth-child(2) { background: var(--warn); }
.traffic i:nth-child(3) { background: var(--ok); }
.finder-title {
  font-size: 0.78rem;
  color: var(--muted);
  flex: 1;
  text-align: center;
  margin-right: 3rem;
}
.finder-body {
  display: grid;
  grid-template-columns: 15rem 1fr;
  min-height: 0;
  flex: 1;
}
.sidebar {
  background: var(--finder-side);
  border-right: 1px solid var(--line);
  padding: 0.5rem 0.4rem;
  overflow: auto;
  font-size: 0.78rem;
}
.side-label {
  font-size: 0.63rem;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
  padding: 0.55rem 0.55rem 0.25rem;
}
.side-btn {
  display: flex;
  width: 100%;
  text-align: left;
  gap: 0.45rem;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 0.26rem 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}
.side-btn::before {
  content: "";
  color: var(--muted);
  font-size: 0.62rem;
  width: 0.7rem;
  font-family: var(--mono);
}
.side-btn[data-kind="md"]::before { content: "#"; }
.side-btn[data-kind="js"]::before { content: "{}"; font-size: 0.58rem; }
.side-btn:hover { background: var(--line); }
.side-btn[aria-current="true"] {
  background: var(--btn);
  color: var(--btn-ink);
}
.side-btn[aria-current="true"]::before { color: var(--btn-ink); }
.pane { overflow: auto; background: var(--finder-pane); }
.sidebar, .pane {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll) transparent;
}
.sidebar::-webkit-scrollbar,
.pane::-webkit-scrollbar { width: 8px; height: 8px; }
.sidebar::-webkit-scrollbar-track,
.pane::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb,
.pane::-webkit-scrollbar-thumb {
  background: var(--scroll);
  border-radius: 8px;
}
.code {
  margin: 0;
  padding: 1.1rem 1.25rem 2rem;
  font-size: 0.73rem;
  line-height: 1.6;
  color: var(--ink);
  white-space: pre;
}
.tok-kw { color: var(--tok-kw); }
.tok-str { color: var(--tok-str); }
.tok-cmt { color: var(--tok-cmt); font-style: italic; }
.tok-fn { color: var(--tok-fn); }
.tok-num { color: var(--tok-num); }

/* --- api --- */

.api { padding-bottom: 4rem; }
.api-head { margin-bottom: 1.6rem; }
.lede {
  color: var(--muted);
  max-width: 36rem;
  margin: 0.5rem 0 0;
}
.api-grid {
  columns: 4 14rem;
  column-gap: 2rem;
}
.api-grid article {
  break-inside: avoid;
  margin: 0 0 1.5rem;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}
.api-grid h3 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--accent-2);
}
.api-grid ul {
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}
.api-grid li { margin: 0 0 0.35rem; }

footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.4rem var(--pad) 3rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
footer p { margin: 0; }
footer a { color: var(--muted); }
footer a:hover { color: var(--ink); }

.glossary-page { padding-top: 1.5rem; padding-bottom: 4rem; }
.glossary-page h1 {
  font-size: 1.3rem;
  font-weight: 620;
  letter-spacing: -0.02em;
  margin: 0;
}
.glossary-page .lede { margin: 0 0 0.4rem; }

@media (max-width: 800px) {
  .group { grid-template-columns: 1fr; gap: 0.8rem; }
  .finder-body { grid-template-columns: 1fr; }
  .sidebar { max-height: 9rem; border-right: 0; border-bottom: 1px solid var(--line); }
  .top nav { display: none; }
  .mark { margin-right: auto; }
  .hero { padding-top: 2.5rem; }
  .search input { width: 100%; }
  .search { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
