/* developers.povito.com — Povito V2 (platform/packages/brand/docs/design.md), developer-console register.

   Light-first: Cloud White canvas, white surfaces, Midnight Navy chrome, Povito Purple for every action,
   Smile Coral as a deliberate highlight only. Dark is an explicit toggle (data-theme) on the console
   palette (§1.5). Logical properties throughout so `dir="rtl"` just works. Type: Plus Jakarta Sans,
   IBM Plex Sans Arabic for `ar`, JetBrains Mono for code. Docs body reads at 15/1.6 (a step above the
   marketplace's 14/1.5, for long-form reading); everything else is on the §2.1 scale.

   Every colour literal lives between @tokens and @end-tokens; the rules below only ever use var().
   Radius is the closed scale 6 · 8 · 10 · 12 · 16 · 20 · 9999 (§3). */

/* @tokens */
:root {
  /* brand ramps */
  --purple-50: #f4f0ff;
  --purple-100: #e9e1ff;
  --purple-200: #d6c7ff;
  --purple-300: #b9a0ff;
  --purple-500: #6c3bff;
  --purple-600: #5a2be6;
  --purple-700: #4a20bf;
  --purple-800: #3a1a94;
  --coral-100: #ffe1e1;
  --coral-300: #ffa3a3;
  --coral-500: #ff5c5c;
  --coral-700: #c23333;
  --neutral-0: #ffffff;
  --neutral-50: #f8f7fc;
  --neutral-100: #f1eff7;
  --neutral-200: #e4e1ee;
  --neutral-300: #cfcbdd;
  --neutral-400: #a9a4bd;
  --neutral-600: #605a76;
  --neutral-700: #454057;
  --neutral-800: #2c283c;
  --neutral-900: #17152b;
  --neutral-950: #0f0e1c;
  /* semantic — two steps each: the fill value fails as text (§1.3) */
  --success-700: #0b6c36;
  --success-soft: #e6f7ee;
  --warning-700: #8a5a08;
  --warning-soft: #fef6e7;
  --danger: #d92d20;
  --danger-soft: #fdecea;
  /* console palette (§1.5) — the code surface uses it in both themes */
  --console-bg: #17152b;
  --console-surface: #201d36;
  --console-raised: #2a2642;
  --console-border: rgba(248, 247, 252, 0.09);
  --console-border-strong: rgba(248, 247, 252, 0.18);
  --console-text: #f8f7fc;
  --console-muted: #a9a4bd;
  --console-purple: #8c63ff;
  --console-purple-hover: #9d7aff;
  --console-coral: #ff7878;
  --console-lilac: rgba(108, 59, 255, 0.18);
  --console-success: #3ecf7c;
  --console-success-soft: #12291d;
  --console-warning: #ffc453;
  --console-warning-soft: #2e2412;
  --console-danger: #ff6a5e;
  --console-danger-soft: #3a1a1a;
  --console-coral-soft: rgba(255, 92, 92, 0.18);
  /* code tokens — always on the dark code surface */
  --tok-str: #7fe0a8;
  --tok-num: #ffa3a3;
  --tok-kw: #b9a0ff;
  --tok-com: #a9a4bd;
  --tok-prop: #d6c7ff;
  --tok-var: #ffc453;
  /* elevation — cool navy, never black */
  --shadow-sm: 0 1px 2px rgba(23, 21, 43, 0.06);
  --shadow-md: 0 4px 14px -4px rgba(23, 21, 43, 0.1);
  --shadow-lg: 0 16px 40px -12px rgba(23, 21, 43, 0.18);
  --backdrop: rgba(23, 21, 43, 0.5);

  /* roles — light */
  --canvas: var(--neutral-50);
  --surface: var(--neutral-0);
  --sunken: var(--neutral-100);
  --chrome: var(--neutral-900);
  --footer-bg: var(--neutral-900);
  --hero-bg: var(--neutral-900);
  --ink: var(--neutral-900);
  --ink-2: var(--neutral-700);
  --muted: var(--neutral-600);
  --quiet: var(--neutral-400);
  --border: var(--neutral-200);
  --border-strong: var(--neutral-300);
  --accent: var(--purple-500);
  --accent-hover: var(--purple-600);
  --accent-active: var(--purple-700);
  --accent-text: var(--purple-700);
  --accent-ink: var(--purple-800);
  --accent-soft: var(--purple-100);
  --accent-soft-hover: var(--purple-200);
  --accent-ghost: var(--purple-50);
  --accent-border: var(--purple-300);
  --on-accent: var(--neutral-0);
  --coral-fill: var(--coral-500);
  --coral-fill-ink: var(--neutral-900);
  --coral-soft: var(--coral-100);
  --coral-ink: var(--coral-700);
  --success-text: var(--success-700);
  --success-fill: var(--success-soft);
  --warning-text: var(--warning-700);
  --warning-fill: var(--warning-soft);
  --danger-text: var(--danger);
  --danger-fill: var(--danger-soft);
  --code-bg: var(--console-surface);
  --code-head: var(--console-raised);
  --code-ink: var(--neutral-100);
  --code-muted: var(--console-muted);
  --code-border: var(--neutral-200);
  --code-accent: var(--console-purple);
  --code-success: var(--console-success);
  --inline-code-bg: var(--neutral-100);
  --inline-code-ink: var(--neutral-800);
  --table-head: var(--neutral-50);
  --row-hover: var(--purple-50);
  --on-navy: var(--neutral-0);
  --on-navy-muted: var(--neutral-300);
  --on-navy-quiet: var(--neutral-400);
  --logo-light: block;
  --logo-dark: none;

  /* shape, motion, type, layout */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius-md: 10px;
  --radius-card: 12px;
  --radius-panel: 16px;
  --radius-banner: 20px;
  --radius-pill: 9999px;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.32, 0.08, 0, 1);
  --fast: 150ms;
  --base: 250ms;
  --slow: 400ms;
  --font-latin: "Plus Jakarta Sans", Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-arabic: "IBM Plex Sans Arabic", "Noto Sans Arabic", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --topbar-h: 64px;
  --rail-w: 248px;
  --toc-w: 208px;
  --content-w: 760px;
  --page-w: 1440px;
}

[data-theme="dark"] {
  --canvas: var(--console-bg);
  --surface: var(--console-surface);
  --sunken: var(--console-raised);
  --chrome: var(--console-surface);
  --footer-bg: var(--neutral-950);
  --hero-bg: var(--console-surface);
  --ink: var(--console-text);
  --ink-2: var(--neutral-300);
  --muted: var(--console-muted);
  --quiet: var(--neutral-600);
  --border: var(--console-border);
  --border-strong: var(--console-border-strong);
  --accent: var(--console-purple);
  --accent-hover: var(--console-purple-hover);
  --accent-active: var(--purple-300);
  --accent-text: var(--purple-300);
  --accent-ink: var(--purple-200);
  --accent-soft: var(--console-lilac);
  --accent-soft-hover: rgba(108, 59, 255, 0.28);
  --accent-ghost: rgba(108, 59, 255, 0.1);
  --accent-border: var(--console-purple);
  --coral-fill: var(--console-coral);
  --coral-soft: var(--console-coral-soft);
  --coral-ink: var(--console-coral);
  --success-text: var(--console-success);
  --success-fill: var(--console-success-soft);
  --warning-text: var(--console-warning);
  --warning-fill: var(--console-warning-soft);
  --danger-text: var(--console-danger);
  --danger-fill: var(--console-danger-soft);
  --code-border: var(--console-border);
  --inline-code-bg: var(--console-raised);
  --inline-code-ink: var(--neutral-100);
  --table-head: var(--console-raised);
  --row-hover: rgba(108, 59, 255, 0.1);
  --shadow-sm: none;
  --shadow-md: 0 4px 14px -4px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.5);
  --logo-light: none;
  --logo-dark: block;
}

/* Without JavaScript nothing sets data-theme; follow the system preference. */
@media (prefers-color-scheme: dark) {
  html:not([data-theme]) {
    --canvas: var(--console-bg);
    --surface: var(--console-surface);
    --sunken: var(--console-raised);
    --chrome: var(--console-surface);
    --footer-bg: var(--neutral-950);
    --hero-bg: var(--console-surface);
    --ink: var(--console-text);
    --ink-2: var(--neutral-300);
    --muted: var(--console-muted);
    --quiet: var(--neutral-600);
    --border: var(--console-border);
    --border-strong: var(--console-border-strong);
    --accent: var(--console-purple);
    --accent-hover: var(--console-purple-hover);
    --accent-active: var(--purple-300);
    --accent-text: var(--purple-300);
    --accent-ink: var(--purple-200);
    --accent-soft: var(--console-lilac);
    --accent-soft-hover: rgba(108, 59, 255, 0.28);
    --accent-ghost: rgba(108, 59, 255, 0.1);
    --accent-border: var(--console-purple);
    --coral-fill: var(--console-coral);
    --coral-soft: var(--console-coral-soft);
    --coral-ink: var(--console-coral);
    --success-text: var(--console-success);
    --success-fill: var(--console-success-soft);
    --warning-text: var(--console-warning);
    --warning-fill: var(--console-warning-soft);
    --danger-text: var(--console-danger);
    --danger-fill: var(--console-danger-soft);
    --code-border: var(--console-border);
    --inline-code-bg: var(--console-raised);
    --inline-code-ink: var(--neutral-100);
    --table-head: var(--console-raised);
    --row-hover: rgba(108, 59, 255, 0.1);
    --shadow-sm: none;
    --shadow-md: 0 4px 14px -4px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, 0.5);
    --logo-light: none;
    --logo-dark: block;
  }
}
/* @end-tokens */

/* ---------------------------------------------------------------- base */
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  scroll-padding-top: calc(var(--topbar-h) + 20px);
  scroll-behavior: smooth;
  color-scheme: light;
}
html[data-theme="dark"] {
  color-scheme: dark;
}
body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-latin);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
html[lang="ar"] body {
  font-family: var(--font-arabic);
  line-height: 1.7;
}
html[lang="ar"] [lang="en"],
html[lang="ar"] code,
html[lang="ar"] pre {
  font-family: var(--font-latin);
}
html[lang="ar"] code,
html[lang="ar"] pre {
  font-family: var(--font-mono);
}
code,
kbd,
pre,
samp {
  font-family: var(--font-mono);
  font-size: 0.875em;
}
a {
  color: var(--accent-text);
  text-decoration: none;
  text-underline-offset: 0.18em;
}
a:hover {
  text-decoration: underline;
}
img {
  max-width: 100%;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-xs);
}
::selection {
  background: var(--purple-200);
  color: var(--neutral-900);
}
.skip {
  position: absolute;
  inset-inline-start: 12px;
  top: -48px;
  background: var(--accent);
  color: var(--on-accent);
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  z-index: 100;
}
.skip:focus {
  top: 12px;
}
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875em;
}
.eyebrow {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent-text);
}
html[lang="ar"] .eyebrow {
  letter-spacing: 0;
  text-transform: none;
}

/* ---------------------------------------------------------------- chips and badges */
.chip,
.badge {
  display: inline-block;
  font-family: var(--font-latin);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.3;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  background: var(--sunken);
  color: var(--muted);
  vertical-align: middle;
  white-space: nowrap;
  margin-inline-start: 6px;
}
.chip:first-child,
.badge:first-child,
.prose .chip,
.prose .badge {
  margin-inline-start: 0;
}
.prose .chip,
.prose .badge {
  margin-inline: 4px;
}
.chip-lang,
.badge-lang {
  font-family: var(--font-latin);
  letter-spacing: 0.04em;
}
.chip-auth {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
a.chip-auth:hover {
  text-decoration: none;
  background: var(--accent-soft-hover);
}
.chip-warn {
  background: var(--warning-fill);
  color: var(--warning-text);
}
/* Coral is a highlight: small coral text is coral-700, a coral fill takes navy text — never a button. */
.chip-coral {
  background: var(--coral-soft);
  color: var(--coral-ink);
}
.chip-coral-fill {
  background: var(--coral-fill);
  color: var(--coral-fill-ink);
  font-size: 12px;
  padding: 4px 10px;
}
.chip-version {
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 13px;
  padding: 4px 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  vertical-align: 6px;
}
td .chip {
  display: inline-block;
  margin: 2px 0 0;
}
td .chip-coral {
  display: block;
  width: max-content;
}
.phase-line {
  margin: 0 0 12px;
}
.phase-line .chip {
  font-size: 12px;
  margin-inline-start: 0;
}

/* ---------------------------------------------------------------- buttons (pills; coral has no button variant) */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 16px;
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font: 600 14px/1.3 var(--font-latin);
  cursor: pointer;
  transition:
    background-color var(--fast) var(--ease),
    border-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}
html[lang="ar"] .btn {
  font-family: var(--font-arabic);
}
.btn:hover {
  text-decoration: none;
}
.btn-lg {
  min-height: 44px;
  padding: 0 20px;
  font-size: 15px;
}
.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
}
.btn-primary:active {
  background: var(--accent-active);
}
.btn-outline {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--ink);
}
.btn-outline:hover {
  background: var(--sunken);
}
.btn-outline .muted {
  font-weight: 500;
  font-family: var(--font-mono);
  font-size: 12px;
}
.btn-ghost {
  background: transparent;
  color: var(--accent-text);
}
.btn-ghost:hover {
  background: var(--accent-ghost);
}
.btn-ghost:active {
  background: var(--accent-soft);
}
.btn .chip {
  margin-inline-start: 0;
}

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: var(--page-w);
  height: 64px;
  margin-inline: auto;
  padding-inline: 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  flex: 0 0 auto;
}
.brand:hover {
  text-decoration: none;
}
.brand .wordmark {
  display: block;
  height: 32px;
  width: auto;
}
.wordmark-light {
  display: var(--logo-light);
}
.wordmark-dark {
  display: var(--logo-dark);
}
.brand .wordmark-light {
  display: var(--logo-light);
}
.brand .wordmark-dark {
  display: var(--logo-dark);
}
.brand-sub {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  padding-inline-start: 12px;
  border-inline-start: 1px solid var(--border-strong);
  line-height: 1.3;
}
.tabs {
  display: flex;
  gap: 4px;
  align-self: stretch;
}
.tabs a {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  color: var(--ink-2);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  transition: color var(--fast) var(--ease);
}
.tabs a:hover {
  color: var(--accent-text);
  text-decoration: none;
}
.tabs a[aria-current] {
  color: var(--accent-text);
}
.tabs a[aria-current]::after {
  content: "";
  position: absolute;
  inset-inline: 12px;
  bottom: 0;
  height: 2px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}
.topbar-end {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.lang-switch {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  color: var(--ink);
  font-weight: 600;
  font-size: 14px;
  transition:
    border-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}
.lang-switch[lang="ar"] {
  font-family: var(--font-arabic);
}
.lang-switch[lang="en"] {
  font-family: var(--font-latin);
}
.lang-switch:hover {
  border-color: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
}
.theme-toggle,
.menu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-strong);
  background: transparent;
  color: var(--ink);
  border-radius: var(--radius-pill);
  cursor: pointer;
  padding: 0;
  transition:
    border-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}
.theme-toggle:hover,
.menu-toggle:hover {
  border-color: var(--accent);
  color: var(--accent-text);
}
.theme-toggle .icon {
  width: 18px;
  height: 18px;
}
.icon-moon {
  display: var(--logo-light);
}
.icon-sun {
  display: var(--logo-dark);
}
.menu-toggle {
  display: none;
  flex-direction: column;
  gap: 4px;
}
.menu-toggle span {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: var(--radius-pill);
}

/* ---------------------------------------------------------------- layout */
.layout {
  display: grid;
  grid-template-columns: var(--rail-w) minmax(0, 1fr) var(--toc-w);
  gap: 0 40px;
  max-width: var(--page-w);
  margin-inline: auto;
  padding-inline: 24px;
  min-height: calc(100vh - var(--topbar-h) - 200px);
}
body.wide .layout {
  grid-template-columns: var(--rail-w) minmax(0, 1fr);
}
body.bare .layout {
  display: block;
  max-width: none;
  padding: 0;
}
.content {
  min-width: 0;
  padding: 40px 0 72px;
}
.prose {
  max-width: var(--content-w);
}
body.wide .prose {
  max-width: none;
}

/* the left rail: the current section only */
.rail {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 32px 0 40px;
  padding-inline-end: 16px;
  border-inline-end: 1px solid var(--border);
  font-size: 13px;
}
.rail-group + .rail-group {
  margin-top: 24px;
}
.rail-title {
  margin: 0 0 6px;
  padding-inline: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
html[lang="ar"] .rail-title {
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
}
.rail ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.rail li a {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 6px 12px;
  color: var(--ink-2);
  border-radius: var(--radius-md);
  font-weight: 500;
  line-height: 1.4;
  transition:
    background-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}
.rail li a:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
  text-decoration: none;
}
.rail li a[aria-current="page"] {
  background: var(--accent-ghost);
  color: var(--accent-text);
  font-weight: 600;
}
.rail li a[aria-current="page"]::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: var(--radius-pill);
  background: var(--accent);
}
.rail-backdrop {
  display: none;
}

/* "On this page" */
.toc {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 40px 0;
  font-size: 13px;
}
.toc-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
html[lang="ar"] .toc-title {
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
}
.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-inline-start: 1px solid var(--border);
}
.toc li a {
  display: block;
  padding: 4px 12px;
  color: var(--muted);
  border-inline-start: 2px solid transparent;
  margin-inline-start: -1px;
  line-height: 1.45;
  transition: color var(--fast) var(--ease);
}
.toc li.toc-3 a {
  padding-inline-start: 24px;
}
.toc li a:hover {
  color: var(--ink);
  text-decoration: none;
}
.toc li a.active {
  color: var(--accent-text);
  border-color: var(--accent);
  font-weight: 600;
}

/* ---------------------------------------------------------------- prose */
.prose h1 {
  font-size: 32px;
  line-height: 1.15;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin: 0 0 12px;
}
.prose h2 {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 48px 0 12px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.prose h3 {
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
  margin: 32px 0 8px;
}
.prose h4 {
  font-size: 16px;
  line-height: 1.3;
  font-weight: 700;
  margin: 24px 0 6px;
}
.prose h5,
.prose h6 {
  font-size: 14px;
  line-height: 1.4;
  font-weight: 700;
  margin: 20px 0 6px;
}
html[lang="ar"] .prose h1,
html[lang="ar"] .prose h2,
html[lang="ar"] .prose h3,
html[lang="ar"] .hero h1 {
  letter-spacing: 0;
}
.prose p,
.prose ul,
.prose ol {
  margin: 0 0 14px;
}
.prose ul,
.prose ol {
  padding-inline-start: 24px;
}
.prose li + li {
  margin-top: 4px;
}
.prose .lead,
.prose > p:first-of-type:not(.phase-line):not(.eyebrow) {
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
}
.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}
.prose strong {
  font-weight: 700;
}
.prose :not(pre) > code {
  background: var(--inline-code-bg);
  color: var(--inline-code-ink);
  padding: 0.12em 0.4em;
  border-radius: var(--radius-xs);
  font-size: 0.86em;
  word-break: break-word;
}
.prose blockquote {
  margin: 0 0 14px;
  padding: 4px 16px;
  border-inline-start: 3px solid var(--border-strong);
  color: var(--muted);
}
.anchor {
  margin-inline-start: 8px;
  color: var(--quiet);
  font-weight: 400;
  opacity: 0;
  transition: opacity var(--fast) var(--ease);
}
h1:hover .anchor,
h2:hover .anchor,
h3:hover .anchor,
h4:hover .anchor,
h5:hover .anchor,
.anchor:focus {
  opacity: 1;
}
.anchor:hover {
  color: var(--accent-text);
  text-decoration: none;
}

/* tables: neutral-50 head, neutral-200 rules, 40px rows, scroll inside their wrapper */
.table-wrap {
  overflow-x: auto;
  margin: 0 0 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  min-width: 480px;
}
th,
td {
  text-align: start;
  vertical-align: top;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover td {
  background: var(--row-hover);
}
th {
  background: var(--table-head);
  padding-block: 11px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}
html[lang="ar"] th {
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
}
td code {
  white-space: nowrap;
}
td code.prop {
  font-weight: 600;
}
td p {
  margin: 0 0 6px;
}
td p:last-child {
  margin-bottom: 0;
}
td .table-wrap {
  margin: 8px 0 0;
}
td .table-wrap table {
  min-width: 360px;
}
td ul,
td ol {
  margin: 4px 0;
  padding-inline-start: 18px;
}
td figure.code {
  margin: 8px 0 0;
}

/* code figures: navy-tinted dark surface in both themes, header with the language and a copy button */
figure.code {
  margin: 0 0 18px;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-card);
  background: var(--code-bg);
  overflow: hidden;
  color-scheme: dark;
}
figure.code figcaption {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 36px;
  padding: 4px 8px 4px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--code-muted);
  background: var(--code-head);
  border-bottom: 1px solid var(--console-border);
}
html[dir="rtl"] figure.code figcaption {
  padding: 4px 14px 4px 8px;
}
figure.code .code-label {
  color: var(--console-text);
}
figure.code .code-lang {
  font-family: var(--font-mono);
  font-weight: 500;
  text-transform: lowercase;
  margin-inline-start: auto;
}
figure.code pre {
  margin: 0;
  padding: 14px 16px;
  overflow-x: auto;
  direction: ltr;
  text-align: left;
  font-size: 13px;
  line-height: 1.55;
  color: var(--code-ink);
  tab-size: 2;
}
figure.code code {
  font-size: inherit;
}
.copy {
  flex: 0 0 auto;
  font: 600 12px var(--font-latin);
  color: var(--code-muted);
  background: transparent;
  border: 1px solid var(--console-border-strong);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  cursor: pointer;
  transition:
    color var(--fast) var(--ease),
    border-color var(--fast) var(--ease);
}
.copy:hover {
  color: var(--code-accent);
  border-color: var(--code-accent);
}
.copy:focus-visible {
  outline-color: var(--code-accent);
}
.copy.done {
  color: var(--code-success);
  border-color: var(--code-success);
}
.tok-str {
  color: var(--tok-str);
}
.tok-num {
  color: var(--tok-num);
}
.tok-kw {
  color: var(--tok-kw);
  font-weight: 600;
}
.tok-com {
  color: var(--tok-com);
  font-style: italic;
}
.tok-prop {
  color: var(--tok-prop);
}
.tok-var,
.tok-flag {
  color: var(--tok-var);
}

/* tabbed code blocks */
.code-tabs {
  margin: 0 0 18px;
}
.code-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0 0 8px;
}
.code-tabs-bar [role="tab"] {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--sunken);
  color: var(--ink-2);
  font: 600 12px/1.3 var(--font-latin);
  cursor: pointer;
  transition:
    background-color var(--fast) var(--ease),
    color var(--fast) var(--ease);
}
.code-tabs-bar [role="tab"]:hover {
  color: var(--accent-text);
}
.code-tabs-bar [role="tab"][aria-selected="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-color: var(--accent-border);
}
.code-tabs figure.code {
  margin-bottom: 0;
}
html:not(.js) .code-tabs-bar {
  display: none;
}
html:not(.js) .code-tabs-panel[hidden] {
  display: block;
}
html:not(.js) .code-tabs figure.code {
  margin-bottom: 12px;
}

/* callouts: note = purple, warning = warning, important = the coral marker */
.callout {
  margin: 0 0 18px;
  padding: 12px 16px;
  border-radius: var(--radius-card);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--accent);
  background: var(--surface);
}
.callout > :last-child {
  margin-bottom: 0;
}
.callout-title {
  margin: 0 0 4px;
  font-weight: 700;
  font-size: 14px;
  color: var(--accent-ink);
}
.callout-note {
  background: var(--accent-ghost);
  border-inline-start-color: var(--accent);
}
.callout-note .callout-title {
  color: var(--accent-ink);
}
.callout-tip {
  background: var(--success-fill);
  border-inline-start-color: var(--success-text);
}
.callout-tip .callout-title {
  color: var(--success-text);
}
.callout-warning,
.callout-phase {
  background: var(--warning-fill);
  border-inline-start-color: var(--warning-text);
}
.callout-warning .callout-title,
.callout-phase .callout-title {
  color: var(--warning-text);
}
.callout-danger {
  background: var(--danger-fill);
  border-inline-start-color: var(--danger-text);
}
.callout-danger .callout-title {
  color: var(--danger-text);
}
.callout-important {
  background: var(--coral-soft);
  border-inline-start-color: var(--coral-fill);
  color: var(--ink);
}
.callout-important .callout-title {
  color: var(--coral-ink);
}

/* link cards in guides */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 16px 0 24px;
  padding: 0;
  list-style: none;
}
.cards li {
  margin: 0;
}
.cards a {
  display: block;
  height: 100%;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--fast) var(--ease);
}
.cards a:hover {
  border-color: var(--purple-200);
  text-decoration: none;
}
.cards a strong {
  display: block;
  margin-bottom: 4px;
  font-weight: 700;
  font-size: 15px;
}
.cards a span {
  display: block;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}
.cards a .chip {
  display: inline-block;
  color: var(--muted);
  font-size: 11px;
  margin-inline-start: 6px;
}
.cards.cards-api {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}
.cards.cards-api a {
  padding: 20px 22px;
}
.cards.cards-api a strong {
  font-size: 18px;
}
.steps {
  counter-reset: step;
  list-style: none;
  padding: 0;
}
.steps > li {
  position: relative;
  padding-inline-start: 40px;
  margin-bottom: 8px;
}
.steps > li::before {
  counter-increment: step;
  content: counter(step);
  position: absolute;
  inset-inline-start: 0;
  top: 0;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  font-size: 13px;
  display: grid;
  place-items: center;
}
.compare {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px 24px;
  margin: 0 0 18px;
}
.compare > div {
  min-width: 0;
}
.compare h3 {
  margin-top: 0;
}

/* pager */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  max-width: var(--content-w);
  margin: 56px 0 0;
}
.pager a {
  display: block;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  background: var(--surface);
  color: var(--ink);
  transition: border-color var(--fast) var(--ease);
}
.pager a:hover {
  border-color: var(--purple-200);
  text-decoration: none;
}
.pager-next {
  text-align: end;
}
.pager-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
}
.pager-title {
  font-weight: 700;
}

/* ---------------------------------------------------------------- footer (navy, reversed wordmark, no smile) */
.footer {
  background: var(--footer-bg);
  color: var(--on-navy-muted);
  font-size: 13px;
  margin-top: 40px;
}
.footer-inner {
  max-width: var(--page-w);
  margin-inline: auto;
  padding: 40px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 32px 56px;
  align-items: start;
}
.footer-brand {
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  gap: 0 12px;
}
.footer-brand img {
  height: 28px;
  width: auto;
}
.footer-brand span {
  font-weight: 600;
  color: var(--on-navy);
  padding-inline-start: 12px;
  border-inline-start: 1px solid var(--console-border-strong);
}
.footer-brand p {
  grid-column: 1 / -1;
  margin: 12px 0 0;
}
.footer ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.footer-links li + li,
.footer-contracts li + li {
  margin-top: 8px;
}
.footer a {
  color: var(--on-navy-muted);
  transition: color var(--fast) var(--ease);
}
.footer a:hover {
  color: var(--on-navy);
}
.footer a:focus-visible {
  outline-color: var(--console-purple);
}
.footer-title {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--on-navy-quiet);
}
.footer-contracts a {
  font-family: var(--font-mono);
  font-size: 12px;
}
.footer-version {
  color: var(--on-navy-quiet);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* ---------------------------------------------------------------- home */
.hero {
  position: relative;
  background: var(--hero-bg);
  color: var(--on-navy);
  padding: 64px 24px 72px;
}
.hero-inner {
  max-width: 1120px;
  margin-inline: auto;
}
.hero-chip {
  margin: 0 0 16px;
}
.hero-chip .chip {
  margin-inline-start: 0;
}
.hero h1 {
  margin: 0 0 12px;
  font-size: 44px;
  line-height: 1.05;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero-sub {
  margin: 0;
  max-width: 640px;
  font-size: 17px;
  line-height: 1.55;
  color: var(--on-navy-muted);
}
/* The band ends in one shallow smile curve (§4.3.6): the arc straddles the edge, only its belly shows. */
.hero-smile {
  position: absolute;
  left: 50%;
  bottom: -43px;
  width: 240px;
  height: 96px;
  transform: translateX(-50%);
  color: var(--hero-bg);
  pointer-events: none;
}
.home {
  max-width: 1120px;
  margin: 72px auto 0;
  padding-inline: 24px;
}
.api-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 24px;
}
.api-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  padding: 32px;
  display: flex;
  flex-direction: column;
  transition: border-color var(--fast) var(--ease);
}
.api-card:hover {
  border-color: var(--purple-200);
}
.api-card h2 {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.api-audience {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 15px;
}
.api-card ul {
  margin: 0 0 24px;
  padding-inline-start: 20px;
  font-size: 14px;
  color: var(--ink-2);
}
.api-card li + li {
  margin-top: 6px;
}
.api-actions {
  margin: auto 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.start-here {
  margin: 56px 0 0;
}
.start-here h2 {
  margin: 0 0 12px;
  font-size: 20px;
  line-height: 1.25;
  font-weight: 700;
}
.start-here .cards {
  margin: 0;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
.home .prose {
  margin-top: 40px;
}

/* ---------------------------------------------------------------- reference */
.reference-head {
  margin-bottom: 24px;
}
.reference-head h1 {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.reference-head .lead {
  max-width: var(--content-w);
}
.reference-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 16px 0 12px;
}
.reference h2 {
  margin-top: 56px;
}
.reference .prose,
.reference .lead {
  max-width: var(--content-w);
}
.reference > p,
.reference > ul,
.reference > ol,
.reference .scheme,
.reference .tag > p,
.reference .tag > ul {
  max-width: var(--content-w);
}
.reference .table-wrap.servers,
.reference > .table-wrap {
  max-width: 880px;
}
.op-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 16px;
  margin: 16px 0 8px;
}
.op-index-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 16px 20px;
}
.op-index-title {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 700;
}
.op-index-title a {
  color: var(--ink);
}
.op-index ul {
  list-style: none;
  margin: 0;
  padding: 0;
}
.op-index li a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  padding: 4px 0;
  color: var(--ink);
  font-size: 13px;
}
.op-index li a:hover {
  text-decoration: none;
}
.op-index li a:hover .path {
  color: var(--accent-text);
}
.op-index .path {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.op-index-summary {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.tag-title {
  margin-top: 48px;
}
.reference .tag > h3 {
  font-size: 24px;
  letter-spacing: -0.02em;
}
.anchor-heading {
  color: inherit;
}
.operation {
  margin: 24px 0 32px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  background: var(--surface);
}
.operation h3 {
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 18px;
}
.operation h4 {
  margin: 24px 0 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.operation h5,
.operation h6 {
  font-size: 14px;
  margin: 16px 0 6px;
}
.operation > p,
.operation > ul,
.operation > ol {
  max-width: var(--content-w);
}
.op-meta {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}
.op-summary {
  font-size: 16px;
  font-weight: 600;
  color: var(--ink);
}
.path {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  background: transparent !important;
  padding: 0 !important;
  unicode-bidi: isolate;
}
/* method badges — tinted fills with the -700 text step; never coral */
.method {
  display: inline-block;
  font: 700 11px/1.3 var(--font-mono);
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  background: var(--sunken);
  color: var(--muted);
  min-width: 52px;
  text-align: center;
  flex: 0 0 auto;
}
.method-get {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.method-post {
  background: var(--success-fill);
  color: var(--success-text);
}
.method-put,
.method-patch {
  background: var(--warning-fill);
  color: var(--warning-text);
}
.method-delete {
  background: var(--danger-fill);
  color: var(--danger-text);
}
.status {
  font-weight: 600;
}
.status-2xx {
  color: var(--success-text);
}
.status-3xx {
  color: var(--muted);
}
.status-4xx {
  color: var(--warning-text);
}
.status-5xx {
  color: var(--danger-text);
}
.nested summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent-text);
  margin-top: 4px;
}
.schema-def {
  margin: 32px 0;
  max-width: 960px;
}
.schema-def h3 {
  margin-top: 0;
}
.scheme {
  margin: 20px 0;
}
a.ref code {
  color: var(--accent-ink);
  background: var(--accent-soft);
}

/* explorer */
.explorer .reference-head {
  margin-bottom: 0;
}
.scalar-host {
  min-height: 70vh;
  margin-top: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-panel);
  overflow: hidden;
  background: var(--surface);
}
.scalar-host:empty {
  min-height: 0;
  border: 0;
  margin: 0;
}
.explorer-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 24px;
  color: var(--muted);
}
.explorer-status p {
  margin: 0;
}
.smile-loader {
  width: 56px;
  height: 56px;
  color: var(--accent);
  animation: smile-pulse 1.2s var(--ease) infinite;
}
@keyframes smile-pulse {
  0%,
  100% {
    opacity: 0.4;
  }
  50% {
    opacity: 1;
  }
}

/* 404: one 88px purple Smile Circle */
.not-found {
  text-align: center;
  padding: 72px 24px;
  max-width: 560px;
  margin-inline: auto;
}
.smile-404 {
  color: var(--accent);
  margin-bottom: 24px;
}
.not-found .reference-actions {
  justify-content: center;
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1199px) {
  .layout {
    grid-template-columns: var(--rail-w) minmax(0, 1fr);
  }
  .toc {
    display: none;
  }
}
@media (max-width: 899px) {
  :root {
    --topbar-h: 108px;
  }
  .topbar-inner {
    gap: 12px;
    padding-inline: 16px;
  }
  .menu-toggle {
    display: inline-flex;
  }
  body.bare .menu-toggle {
    display: none;
  }
  .brand-sub {
    display: none;
  }
  .tabs {
    position: absolute;
    top: 64px;
    inset-inline: 0;
    height: 44px;
    padding-inline: 12px;
    gap: 0;
    overflow-x: auto;
    background: var(--surface);
    border-top: 1px solid var(--border);
    scrollbar-width: none;
  }
  .tabs::-webkit-scrollbar {
    display: none;
  }
  .tabs a {
    white-space: nowrap;
  }
  .tabs a[aria-current]::after {
    inset-inline: 8px;
  }
  .layout,
  body.wide .layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding-inline: 16px;
  }
  body.bare .layout {
    padding: 0;
  }
  .rail {
    display: none;
    position: fixed;
    inset-inline-start: 0;
    top: var(--topbar-h);
    width: min(320px, 88vw);
    height: calc(100vh - var(--topbar-h));
    background: var(--surface);
    border-inline-end: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    padding: 16px 12px 40px;
    z-index: 40;
  }
  .rail-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    top: var(--topbar-h);
    background: var(--backdrop);
    z-index: 30;
  }
  .rail-backdrop[hidden] {
    display: none;
  }
  body.nav-open .rail {
    display: block;
  }
  body.nav-open {
    overflow: hidden;
  }
  .content {
    padding: 24px 0 56px;
  }
  .prose h1 {
    font-size: 28px;
  }
  .hero {
    padding: 40px 16px 56px;
  }
  .hero h1 {
    font-size: 32px;
    line-height: 1.1;
  }
  .hero-smile {
    width: 180px;
    height: 72px;
    bottom: -32px;
  }
  .home {
    margin-top: 56px;
    padding-inline: 16px;
  }
  .api-card {
    padding: 24px;
  }
  .pager {
    grid-template-columns: 1fr;
  }
  .anchor {
    display: none;
  }
  .operation {
    padding: 16px;
  }
  .op-index {
    grid-template-columns: minmax(0, 1fr);
  }
  .footer-inner {
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    padding: 32px 16px;
  }
}
/* 48px targets on coarse pointers (§5.1) */
@media (pointer: coarse) {
  .rail li a,
  .tabs a,
  .btn,
  .lang-switch,
  .theme-toggle,
  .menu-toggle,
  .code-tabs-bar [role="tab"],
  .cards a,
  .op-index li a,
  .pager a {
    min-height: 48px;
  }
  .theme-toggle,
  .menu-toggle {
    width: 48px;
  }
  .copy {
    min-height: 40px;
    padding-inline: 14px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .smile-loader {
    opacity: 1;
  }
}
@media print {
  .topbar,
  .rail,
  .toc,
  .copy,
  .pager,
  .footer,
  .code-tabs-bar {
    display: none !important;
  }
  .code-tabs-panel[hidden] {
    display: block;
  }
  .layout {
    display: block;
  }
  figure.code {
    break-inside: avoid;
  }
}
