/*
 * Every rule lives here: the Content-Security-Policy (web.config, staticwebapp.config.json,
 * scripts/server.mjs) allows neither inline style attributes nor <style> blocks. Colours follow the
 * Oxygenius brand: navy #1c3775, cyan #00c1d4 (never as text on white: too little contrast).
 *
 * Themes. The light tokens are on :root. The dark tokens are written twice, identically (build.test.mjs
 * checks it), between the dark-tokens markers:
 * - under prefers-color-scheme: dark, unless the reader chose the light theme (data-theme="light");
 * - under data-theme="dark", when the reader chose the dark theme.
 * app.js sets data-theme from the reader's choice before the first paint; without JavaScript, or with no
 * choice, the site follows the system. Both dark blocks are for screens only: printing is always light.
 */

:root {
  color-scheme: light;
  --when-light: block;
  --when-dark: none;

  --page: #ffffff;
  --surface: #ffffff;
  --surface-2: #f6f7f9;
  --surface-3: #eef1f6;
  --border: #e4e7ec;
  --border-strong: #cfd5df;
  --border-input: #7d879a;
  --header-bg: rgba(255, 255, 255, 0.85);
  --text-strong: #0f1b33;
  --text: #384256;
  --muted: #5f6b80;
  --link: #1c4fb0;
  --link-underline: rgba(28, 79, 176, 0.35);
  --primary: #1c3775;
  --on-primary: #ffffff;
  --primary-hover: #152a5c;
  --accent: #00c1d4;
  --accent-strong: #00788a;
  --focus: #00788a;
  --accent-soft-bg: #e3f7fa;
  --accent-soft-text: #00616e;
  --accent-soft-border: #b4e9f0;
  --code-bg: #f1f3f7;
  --code-text: #1b2a4d;
  --code-border: #e4e7ec;
  --pre-bg: #0e1626;
  --pre-head: #152036;
  --pre-border: #0e1626;
  --pre-text: #e2e8f3;
  --pre-muted: #9aa7bf;
  --info-bg: #eef4fd;
  --info-border: #c9dbf6;
  --info-title: #173f85;
  --info-icon: #2459c2;
  --warn-bg: #fff8e6;
  --warn-border: #f5dc9a;
  --warn-title: #7a4b00;
  --warn-icon: #b26b00;
  --read-bg: #e7f6ec;
  --read-text: #18603a;
  --read-border: #bfe6cc;
  --write-bg: #fff4e0;
  --write-text: #8a4b00;
  --write-border: #f6d9a8;
  --danger-bg: #fdecec;
  --danger-text: #a12828;
  --danger-border: #f5c2c2;
  --badge-info-bg: #eaf2fd;
  --badge-info-text: #1d4f9e;
  --badge-info-border: #c6daf7;
  --glow-1: rgba(0, 193, 212, 0.12);
  --glow-2: rgba(28, 55, 117, 0.08);
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 4px 12px -2px rgba(16, 24, 40, 0.1);

  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --header-height: 64px;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    /* dark-tokens:start */
    color-scheme: dark;
    --when-light: none;
    --when-dark: block;
    --page: #0b1220;
    --surface: #111a2e;
    --surface-2: #151f36;
    --surface-3: #1c2843;
    --border: #23304b;
    --border-strong: #2f3e5e;
    --border-input: #64718e;
    --header-bg: rgba(11, 18, 32, 0.8);
    --text-strong: #f1f4fa;
    --text: #c5cede;
    --muted: #8d99b0;
    --link: #8ab4f8;
    --link-underline: rgba(138, 180, 248, 0.4);
    --primary: #00c1d4;
    --on-primary: #04151c;
    --primary-hover: #33cfdf;
    --accent: #00c1d4;
    --accent-strong: #00c1d4;
    --focus: #00c1d4;
    --accent-soft-bg: #0b2a33;
    --accent-soft-text: #5fdcea;
    --accent-soft-border: #12495a;
    --code-bg: #18223a;
    --code-text: #dbe4f5;
    --code-border: #26324d;
    --pre-bg: #080e1a;
    --pre-head: #0f1729;
    --pre-border: #23304b;
    --info-bg: #0f1d36;
    --info-border: #1f3a66;
    --info-title: #a9c8ff;
    --info-icon: #7fb0ff;
    --warn-bg: #221a08;
    --warn-border: #4d3a10;
    --warn-title: #f6d68b;
    --warn-icon: #f0b84a;
    --read-bg: #0f2a1c;
    --read-text: #7ddba3;
    --read-border: #1d4a31;
    --write-bg: #2b1f08;
    --write-text: #f5c46b;
    --write-border: #4f3a12;
    --danger-bg: #2e1214;
    --danger-text: #ff9d9d;
    --danger-border: #5a2328;
    --badge-info-bg: #0f1f3a;
    --badge-info-text: #9cc3ff;
    --badge-info-border: #234272;
    --glow-1: rgba(0, 193, 212, 0.16);
    --glow-2: rgba(143, 179, 242, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.5);
    /* dark-tokens:end */
  }
}

@media screen {
  :root[data-theme="dark"] {
    /* dark-tokens:start */
    color-scheme: dark;
    --when-light: none;
    --when-dark: block;
    --page: #0b1220;
    --surface: #111a2e;
    --surface-2: #151f36;
    --surface-3: #1c2843;
    --border: #23304b;
    --border-strong: #2f3e5e;
    --border-input: #64718e;
    --header-bg: rgba(11, 18, 32, 0.8);
    --text-strong: #f1f4fa;
    --text: #c5cede;
    --muted: #8d99b0;
    --link: #8ab4f8;
    --link-underline: rgba(138, 180, 248, 0.4);
    --primary: #00c1d4;
    --on-primary: #04151c;
    --primary-hover: #33cfdf;
    --accent: #00c1d4;
    --accent-strong: #00c1d4;
    --focus: #00c1d4;
    --accent-soft-bg: #0b2a33;
    --accent-soft-text: #5fdcea;
    --accent-soft-border: #12495a;
    --code-bg: #18223a;
    --code-text: #dbe4f5;
    --code-border: #26324d;
    --pre-bg: #080e1a;
    --pre-head: #0f1729;
    --pre-border: #23304b;
    --info-bg: #0f1d36;
    --info-border: #1f3a66;
    --info-title: #a9c8ff;
    --info-icon: #7fb0ff;
    --warn-bg: #221a08;
    --warn-border: #4d3a10;
    --warn-title: #f6d68b;
    --warn-icon: #f0b84a;
    --read-bg: #0f2a1c;
    --read-text: #7ddba3;
    --read-border: #1d4a31;
    --write-bg: #2b1f08;
    --write-text: #f5c46b;
    --write-border: #4f3a12;
    --danger-bg: #2e1214;
    --danger-text: #ff9d9d;
    --danger-border: #5a2328;
    --badge-info-bg: #0f1f3a;
    --badge-info-text: #9cc3ff;
    --badge-info-border: #234272;
    --glow-1: rgba(0, 193, 212, 0.16);
    --glow-2: rgba(143, 179, 242, 0.1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.5);
    /* dark-tokens:end */
  }
}

/* Base */

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

html {
  scroll-padding-top: 88px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.7;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

a {
  color: var(--link);
  text-decoration-color: var(--link-underline);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-color: currentColor;
}

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

.icon {
  display: block;
  flex: none;
  width: 18px;
  height: 18px;
}

h1,
h2,
h3,
h4 {
  color: var(--text-strong);
}

h1 {
  margin: 0 0 16px;
  font-size: 2.25rem;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.022em;
}

h2 {
  margin: 48px 0 12px;
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

h3 {
  margin: 32px 0 8px;
  font-size: 1.125rem;
  font-weight: 600;
  line-height: 1.4;
}

h4 {
  margin: 24px 0 6px;
  font-size: 1rem;
  font-weight: 600;
}

.heading-anchor {
  margin-left: 8px;
  color: var(--muted);
  font-weight: 400;
  text-decoration: none;
  opacity: 0;
}

h2:hover .heading-anchor,
h3:hover .heading-anchor,
.heading-anchor:focus {
  opacity: 1;
}

p,
ul,
ol {
  margin: 0 0 16px;
}

ul,
ol {
  padding-left: 24px;
}

li + li {
  margin-top: 4px;
}

strong {
  color: var(--text-strong);
  font-weight: 600;
}

code {
  padding: 1px 6px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 0.875em;
}

a code {
  color: var(--link);
}

pre {
  margin: 0;
  padding: 16px;
  overflow-x: auto;
  background: var(--pre-bg);
  color: var(--pre-text);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.65;
}

pre:focus-visible {
  outline-color: #00c1d4;
  outline-offset: -2px;
}

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

blockquote {
  margin: 12px 0 20px;
}

.skip-link {
  position: absolute;
  top: -100px;
  left: 12px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text-strong);
}

.skip-link:focus {
  top: 12px;
  box-shadow: var(--shadow-md);
}

/* Header */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  flex: none;
  border-bottom: 1px solid var(--border);
  background: var(--page);
}

@supports ((-webkit-backdrop-filter: blur(12px)) or (backdrop-filter: blur(12px))) {
  .site-header {
    background: var(--header-bg);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    backdrop-filter: saturate(180%) blur(12px);
  }
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  max-width: 1440px;
  height: var(--header-height);
  margin: 0 auto;
  padding: 0 24px;
}

.home-header {
  max-width: 1120px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
}

.brand img {
  width: 120px;
  height: auto;
}

.logo-light {
  display: var(--when-light);
}

.logo-dark {
  display: var(--when-dark);
}

.brand-badge {
  padding: 0 8px;
  border: 1px solid var(--accent-soft-border);
  border-radius: 999px;
  background: var(--accent-soft-bg);
  color: var(--accent-soft-text);
  font-size: 12px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: 0.04em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-right: 4px;
}

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

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

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.lang-switch {
  display: inline-flex;
  height: 32px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.lang-switch a,
.lang-switch span {
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}

.lang-switch a:hover {
  color: var(--text-strong);
}

.lang-switch [aria-current] {
  background: var(--surface-3);
  color: var(--text-strong);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--surface-2);
  color: var(--text-strong);
}

.theme-toggle .icon-sun {
  display: var(--when-light);
}

.theme-toggle .icon-moon {
  display: var(--when-dark);
}

.nav-toggle {
  display: none;
}

.nav-toggle .icon {
  width: 20px;
  height: 20px;
}

.nav-toggle .icon-close,
.nav-toggle[aria-expanded="true"] .icon-menu {
  display: none;
}

.nav-toggle[aria-expanded="true"] .icon-close {
  display: block;
}

.nav-toggle[aria-expanded="true"] {
  background: var(--surface-3);
  color: var(--text-strong);
}

/* Layout: sidebar, content, "On this page" */

.layout {
  display: grid;
  flex: 1 0 auto;
  grid-template-columns: 264px minmax(0, 1fr) 220px;
  gap: 48px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}

.layout.no-toc {
  grid-template-columns: 264px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  height: calc(100vh - var(--header-height));
  padding: 32px 16px 48px 0;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  font-size: 14px;
  line-height: 1.5;
}

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

.sidebar li + li {
  margin-top: 2px;
}

.sidebar-section {
  margin: 24px 0 8px;
  padding: 0 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.sidebar-section:first-child {
  margin-top: 0;
}

.sidebar a {
  display: block;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
}

.sidebar a:hover {
  background: var(--surface-2);
  color: var(--text-strong);
}

.sidebar a[aria-current="page"] {
  background: var(--surface-3);
  box-shadow: inset 2px 0 0 var(--accent);
  color: var(--text-strong);
  font-weight: 600;
}

.sidebar .subnav {
  margin: 4px 0 6px 10px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
  font-size: 13.5px;
}

.sidebar .subnav a {
  padding: 4px 10px;
}

.sidebar code {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.content {
  min-width: 0;
  max-width: 800px;
  padding: 40px 0 96px;
}

.toc {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  max-height: calc(100vh - var(--header-height));
  padding: 44px 0 40px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.5;
}

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

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

.toc li + li {
  margin-top: 0;
}

.toc a {
  display: block;
  margin-left: -1px;
  padding: 4px 0 4px 12px;
  border-left: 2px solid transparent;
  color: var(--muted);
  text-decoration: none;
}

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

.toc a[aria-current="location"] {
  border-left-color: var(--accent);
  color: var(--text-strong);
  font-weight: 500;
}

.lead {
  margin-bottom: 24px;
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.6;
}

.meta {
  color: var(--muted);
  font-size: 14px;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb li + li {
  margin-top: 0;
}

.breadcrumb li + li::before {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin: 0 8px 1px 0;
  border-top: 1.5px solid currentColor;
  border-right: 1.5px solid currentColor;
  transform: rotate(45deg);
  content: "";
}

.breadcrumb a {
  color: var(--muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--text-strong);
  text-decoration: underline;
}

.breadcrumb code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-strong);
}

/* Footer */

.site-footer {
  flex: none;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 32px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 32px 24px;
}

.footer-inner ul {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.footer-inner li + li {
  margin-top: 0;
}

.footer-inner a {
  color: var(--muted);
}

.footer-inner a:hover {
  color: var(--text-strong);
}

.version {
  margin-left: 6px;
  padding: 1px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 12px;
}

/* Buttons */

.button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-strong);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}

.button:hover {
  background: var(--surface-2);
}

.button.primary {
  border-color: var(--primary);
  background: var(--primary);
  color: var(--on-primary);
}

.button.primary:hover {
  border-color: var(--primary-hover);
  background: var(--primary-hover);
}

.button .icon {
  width: 16px;
  height: 16px;
}

/* Hero */

.hero {
  margin: 0 0 32px;
  padding: 48px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(520px 260px at 100% 0%, var(--glow-1), transparent 70%),
    radial-gradient(480px 260px at 0% 100%, var(--glow-2), transparent 70%),
    var(--surface);
}

.hero h1 {
  font-size: 2.75rem;
  line-height: 1.1;
}

.hero p {
  max-width: 640px;
  color: var(--muted);
  font-size: 1.125rem;
  line-height: 1.6;
}

.hero .eyebrow,
.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.hero .endpoint {
  margin-top: 24px;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}

/* Endpoint and copy buttons */

.endpoint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 48px;
  margin: 16px 0;
  padding: 6px 6px 6px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.endpoint-label {
  padding-right: 12px;
  border-right: 1px solid var(--border);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.endpoint code {
  padding: 0;
  border: 0;
  background: none;
  color: var(--text-strong);
  font-size: 15px;
  word-break: break-all;
}

.endpoint .copy-button {
  margin-left: auto;
}

.copy-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.copy-button:hover {
  color: var(--text-strong);
}

.copy-button .icon {
  width: 14px;
  height: 14px;
}

.copy-button .icon-check,
.copy-button.is-copied .icon-copy {
  display: none;
}

.copy-button.is-copied .icon-check {
  display: block;
}

/* Code blocks: dark in both themes */

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

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 0 6px 0 14px;
  background: var(--pre-head);
}

.code-label {
  overflow: hidden;
  color: var(--pre-muted);
  font-family: var(--mono);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code-head .copy-button {
  height: 28px;
  padding: 0 8px;
  border-color: rgba(255, 255, 255, 0.14);
  background: transparent;
  color: #c9d3e6;
}

.code-head .copy-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

.code-head .copy-button:focus-visible {
  outline-color: #00c1d4;
}

/* Cards, stats, steps, facts */

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 16px;
  margin: 16px 0 24px;
}

.card {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
}

.card p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

a.card {
  display: block;
  color: inherit;
  text-decoration: none;
}

a.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

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

.card-more {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  color: var(--link);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
}

.card-more .icon {
  width: 16px;
  height: 16px;
}

a.card:hover .card-more {
  text-decoration: underline;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
}

.stat {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.stat strong {
  display: block;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.stat span {
  color: var(--muted);
  font-size: 13px;
}

.steps {
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
  counter-reset: step;
}

.steps > li {
  position: relative;
  margin: 0;
  padding: 0 0 20px 44px;
  counter-increment: step;
}

.steps > li::before {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft-bg);
  color: var(--accent-soft-text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  content: counter(step);
}

.steps > li::after {
  position: absolute;
  top: 34px;
  bottom: 6px;
  left: 13.5px;
  width: 1px;
  background: var(--border);
  content: "";
}

.steps > li:last-child {
  padding-bottom: 0;
}

.steps > li:last-child::after {
  display: none;
}

dl.facts {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  margin: 24px 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

dl.facts dt,
dl.facts dd {
  margin: 0;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

dl.facts dt {
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 600;
}

dl.facts dd {
  font-size: 15px;
}

dl.facts dt:first-of-type,
dl.facts dt:first-of-type + dd {
  border-top: 0;
}

/* Callouts */

.callout {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 12px;
  margin: 24px 0;
  padding: 14px 16px;
  border: 1px solid var(--info-border);
  border-radius: var(--radius);
  background: var(--info-bg);
  color: var(--text);
}

.callout-icon {
  width: 20px;
  height: 20px;
  margin-top: 3px;
  color: var(--info-icon);
}

.callout-title {
  display: block;
  margin-bottom: 2px;
  color: var(--info-title);
}

.callout.warning {
  border-color: var(--warn-border);
  background: var(--warn-bg);
}

.callout.warning .callout-icon {
  color: var(--warn-icon);
}

.callout.warning .callout-title {
  color: var(--warn-title);
}

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

/* Tables */

.table-wrap {
  margin: 12px 0 24px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.55;
}

th,
td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td {
  font-variant-numeric: tabular-nums;
}

.tool-group tbody tr:hover {
  background: var(--surface-2);
}

td.nowrap,
th.nowrap,
.param-name code {
  white-space: nowrap;
}

.param-name .depth {
  color: var(--muted);
}

.required {
  color: var(--danger-text);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.optional {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.type {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  white-space: nowrap;
}

/* Badges */

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 8px 0 18px;
}

td .badges {
  margin: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}

.badge.read,
.badge.write,
.badge.destructive {
  padding-left: 7px;
}

.badge.read::before,
.badge.write::before,
.badge.destructive::before {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  content: "";
}

.badge.read {
  border-color: var(--read-border);
  background: var(--read-bg);
  color: var(--read-text);
}

.badge.write {
  border-color: var(--write-border);
  background: var(--write-bg);
  color: var(--write-text);
}

.badge.destructive {
  border-color: var(--danger-border);
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge.info {
  border-color: var(--badge-info-border);
  background: var(--badge-info-bg);
  color: var(--badge-info-text);
}

/* Collapsible sections */

details {
  margin: 12px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

details > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  color: var(--text-strong);
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  flex: none;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  content: "";
}

details[open] > summary::before {
  transform: rotate(45deg);
}

details > summary:hover {
  background: var(--surface-2);
}

details[open] > summary {
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
}

details > .details-body {
  padding: 12px 14px;
}

details .table-wrap {
  margin: 0;
  border: 0;
  border-radius: 0;
}

details .code-block {
  margin: 0;
}

/* Tool pages and index */

.tool-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 0 0 8px;
}

.tool-meta .endpoint,
.tool-meta .badges {
  margin: 0;
}

.description-quote {
  margin: 12px 0 20px;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.description-quote p {
  margin: 0;
}

.tool-filter {
  position: sticky;
  top: calc(var(--header-height) + 8px);
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 24px 0 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.search-field {
  position: relative;
  flex: 1 1 260px;
  min-width: 0;
}

.search-field .icon {
  position: absolute;
  top: 50%;
  left: 12px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.tool-filter input[type="search"] {
  width: 100%;
  height: 40px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border-input);
  border-radius: var(--radius);
  background: var(--page);
  color: var(--text-strong);
  font: inherit;
  font-size: 15px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
}

.filter-chip:has(:checked) {
  border-color: var(--accent-soft-border);
  background: var(--accent-soft-bg);
  color: var(--accent-soft-text);
}

.filter-chip input {
  margin: 0;
  accent-color: var(--primary);
}

.filter-count {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

/* Previous / next */

.pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 56px;
}

.pager a {
  display: block;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  text-decoration: none;
}

.pager a:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.pager .next {
  grid-column: 2;
  text-align: right;
}

.pager-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.pager-title {
  display: block;
  color: var(--link);
  font-size: 15px;
  font-weight: 600;
}

/* Examples and diagrams */

.example {
  margin: 20px 0 28px;
  padding: 20px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.example h3 {
  margin-top: 0;
}

.prompt {
  margin: 10px 0 14px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  background: var(--surface-2);
  color: var(--text-strong);
  font-style: italic;
}

.flow {
  margin: 0 0 12px;
  padding-left: 22px;
}

.diagram {
  margin: 12px 0 24px;
  padding: 16px 20px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
}

.diagram ol {
  margin: 0;
}

/* 404 */

.not-found {
  flex: 1 0 auto;
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 96px 24px;
  text-align: center;
}

.not-found h1 {
  font-size: 2rem;
}

.not-found p {
  margin-bottom: 8px;
}

.error-code {
  color: var(--accent-strong);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
}

.not-found-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 28px;
}

/* Documentation home (root of the Static Web App, content/home.mjs): no sidebar */

.home {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.home .hero {
  padding: 56px 48px;
}

.home h2 {
  margin: 48px 0 16px;
  font-size: 1.25rem;
}

.home .cards {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
}

.home .card {
  padding: 24px;
}

.home .card-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 16px;
  border-radius: 10px;
}

.home .card-icon .icon {
  width: 22px;
  height: 22px;
}

.home .card h3 {
  margin-bottom: 6px;
  font-size: 1.125rem;
}

.home .card p {
  font-size: 15px;
  line-height: 1.6;
}

/* Motion: colours and shadows only */

a,
.button,
.icon-button,
.copy-button,
.card,
.pager a,
.sidebar a,
.toc a,
details > summary::before {
  transition:
    color 0.12s,
    background-color 0.12s,
    border-color 0.12s,
    box-shadow 0.12s,
    transform 0.12s;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
  }
}

/* Medium screens: no "On this page" */

@media (max-width: 1279px) {
  .layout,
  .layout.no-toc {
    grid-template-columns: 248px minmax(0, 1fr);
  }

  .toc {
    display: none;
  }
}

/* Small screens: one column, the sidebar becomes a menu */

@media (max-width: 900px) {
  .layout,
  .layout.no-toc {
    display: block;
  }

  .header-nav,
  .header-divider {
    display: none;
  }

  .header-actions {
    gap: 8px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

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

  .sidebar {
    position: static;
    height: auto;
    padding: 16px 0;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .js .sidebar {
    position: fixed;
    inset: var(--header-height) 0 0 0;
    /* Browsers now align fixed boxes: "start" (kept from the grid) would size the menu to its content. */
    align-self: auto;
    z-index: 25;
    display: none;
    padding: 20px 16px 32px;
    border: 0;
    background: var(--page);
    font-size: 15px;
  }

  .js .sidebar.open {
    display: block;
  }

  .js .sidebar a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 12px;
  }

  .js .sidebar .subnav a {
    min-height: 40px;
  }

  .nav-open,
  .nav-open body {
    overflow: hidden;
  }

  .content {
    padding-top: 24px;
  }

  h1 {
    font-size: 1.875rem;
  }

  .hero,
  .home .hero {
    padding: 28px 20px;
  }

  .hero h1 {
    font-size: 2rem;
  }

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

  dl.facts dd {
    border-top: 0;
  }

  dl.facts dt:first-of-type + dd {
    border-top: 0;
  }

  .tool-filter {
    position: static;
  }
}

@media (max-width: 640px) {
  .endpoint {
    padding: 10px 6px 6px 12px;
  }

  .endpoint-label {
    flex-basis: 100%;
    padding-right: 0;
    border-right: 0;
  }

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

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

  .pager .next {
    grid-column: 1;
  }
}

@media (max-width: 520px) {
  .header-inner {
    gap: 8px;
    padding: 0 16px;
  }

  .layout,
  .home,
  .footer-inner {
    padding-right: 16px;
    padding-left: 16px;
  }

  .brand img {
    width: 104px;
  }

  .brand {
    gap: 8px;
  }

  .lang-switch a,
  .lang-switch span {
    padding: 0 8px;
  }
}

@media print {
  .site-header,
  .sidebar,
  .toc,
  .copy-button,
  .tool-filter,
  .pager {
    display: none;
  }

  .layout,
  .layout.no-toc {
    display: block;
  }
}
