/* Dark is this site's default identity; light is an explicit opt-in via the
   header toggle (persisted in localStorage, applied before paint — see
   scripts/build.mjs THEME_INIT). Header/tabs chrome and the hero band stay
   a fixed dark gradient in both themes, matching docs.engineeringruntime.com's
   own header-stays-dark / content-toggles pattern. */
:root,
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #07152e;
  --panel: #0c1e3d;
  --line: #26466f;
  --text: #f5f8ff;
  --muted: #a9bad5;
  --accent: #5b8ff9;
  --code-bg: #020711;
  --code-text: #dce6ff;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #ffffff;
  --panel: #f4f7fc;
  --line: #dbe4f3;
  --text: #0b1220;
  --muted: #55627a;
  --accent: #2563eb;
  --code-bg: #f1f5fb;
  --code-text: #0b1220;
}

* { box-sizing: border-box }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.55 system-ui, sans-serif; transition: background-color 140ms ease, color 140ms ease }
a { color: inherit }
.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 }

/* ---------------------------------------------------------------------
   Brand header — fixed blue→black gradient in both themes, matching
   docs.engineeringruntime.com's header chrome exactly.
   --------------------------------------------------------------------- */
:root {
  --header-grad: linear-gradient(90deg, #0b3d91 0%, #041530 42%, #000000 100%);
}
.site-header, .tabs-bar {
  background: var(--header-grad);
}
.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
}
.site-header__inner {
  display: flex;
  align-items: center;
  gap: 18px;
  min-height: 64px;
  padding: 10px max(20px, calc((100vw - 1180px) / 2));
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.mark { display: inline-flex; width: 30px; height: 30px }
.brand__text { display: flex; flex-direction: column; gap: 3px; line-height: 1.15 }
.brand__topic { font-size: .68rem; font-weight: 600; letter-spacing: .04em; color: #a9caff; text-transform: uppercase }

.header-links { display: inline-flex; align-items: center; gap: 2px; margin-left: auto }
.header-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  min-width: 104px;
  padding: 0 10px;
  border-radius: 6px;
  color: #fff;
  font-size: .74rem;
  font-weight: 600;
  text-decoration: none;
  opacity: .92;
  transition: background-color 140ms ease, opacity 140ms ease;
}
.header-link:hover, .header-link:focus-visible { background: rgba(255,255,255,.14); opacity: 1 }
.header-link .icon { flex: 0 0 auto }

/* Header search trigger — same white pill as demo.engineeringruntime.com. */
.er-header-search {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  height: 36px;
  margin: 0 2px;
  padding: 0 .7rem;
  border: 1px solid rgba(255,255,255,.9);
  border-radius: 6px;
  background: #ffffff;
  color: #041530;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 140ms ease, color 140ms ease;
}
.er-header-search:hover, .er-header-search:focus-visible {
  background: #e8eef9;
  color: #0b3d91;
  outline: none;
}
.er-header-search__icon { width: 1.05rem; height: 1.05rem; flex-shrink: 0 }
.er-header-search__label { line-height: 1; color: inherit }

.er-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  justify-content: center;
  padding: 12vh 1rem 1rem;
  background: rgba(2, 10, 29, .55);
  backdrop-filter: blur(2px);
}
.er-search-overlay.hidden { display: none }
.er-search-dialog {
  width: min(32rem, 100%);
  max-height: min(28rem, 70vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: .75rem;
  background: #061428;
  color: #e8eef9;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
}
.er-search-dialog__bar {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .85rem 1rem;
  border-bottom: 1px solid rgba(147, 197, 253, .14);
}
.er-search-dialog__icon { width: 1.15rem; height: 1.15rem; color: #8b9bb8; flex-shrink: 0 }
.er-search-dialog__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: #e8eef9;
  font: inherit;
  font-size: .95rem;
  outline: none;
}
.er-search-dialog__input::placeholder { color: #8b9bb8 }
.er-search-dialog__kbd {
  font-family: ui-monospace, monospace;
  font-size: .68rem;
  padding: .15rem .4rem;
  border: 1px solid rgba(147, 197, 253, .22);
  border-radius: .3rem;
  color: #8b9bb8;
}
.er-search-dialog__list { list-style: none; margin: 0; padding: .4rem; overflow-y: auto }
.er-search-dialog__item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: .5rem;
  padding: .65rem .75rem;
  border: 0;
  border-radius: .45rem;
  background: transparent;
  color: #e8eef9;
  font: inherit;
  font-size: .9rem;
  text-align: left;
  cursor: pointer;
}
.er-search-dialog__item:hover, .er-search-dialog__item.is-active { background: rgba(59, 130, 246, .18) }
.er-search-dialog__item .method { min-width: 46px; padding: 2px 6px; font-size: .68rem }
.er-search-dialog__empty { padding: 1rem .75rem; color: #8b9bb8; font-size: .85rem }

#theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: background-color 140ms ease, border-color 140ms ease;
}
#theme-toggle:hover, #theme-toggle:focus-visible { background: rgba(255,255,255,.12); border-color: rgba(255,255,255,.5) }

.tabs-bar__inner {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 max(20px, calc((100vw - 1180px) / 2));
}
.tabs-bar a {
  display: inline-block;
  padding: 11px 14px;
  color: #b9cdf0;
  font-size: .82rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
}
.tabs-bar a:hover { color: #fff }
.tabs-bar a[aria-current="page"] { color: #fff; border-bottom-color: #5b8ff9 }

/* ---------------------------------------------------------------------
   Hero — always the dark "docs landing page" gradient, in both themes.
   --------------------------------------------------------------------- */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(2.4rem, 6vw, 4.2rem) max(20px, calc((100vw - 1180px) / 2)) 2.6rem;
  background-color: #041530;
  background-image:
    radial-gradient(70rem 28rem at 12% -18%, rgba(59,130,246,.32), transparent 62%),
    radial-gradient(46rem 24rem at 96% 6%, rgba(11,61,145,.5), transparent 60%),
    linear-gradient(160deg, #06203f 0%, #041530 46%, #01070f 100%);
  color: #f5f8ff;
}
/* Repeating hexagon-outline texture — the same technique and asset shape
   docs.engineeringruntime.com's and engineeringruntime.com's own hero bands
   use, so this site's landing hero reads as the same product family. */
.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='96' viewBox='0 0 56 96'%3E%3Cpath d='M28 1 54 16v32L28 63 2 48V16z' fill='none' stroke='%233b82f6' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 56px 96px;
  opacity: .14;
  -webkit-mask-image: linear-gradient(105deg, #000 0%, transparent 46%);
  mask-image: linear-gradient(105deg, #000 0%, transparent 46%);
}
.hero > * { position: relative; max-width: 900px; margin-left: auto; margin-right: auto }
.eyebrow {
  display: inline-block;
  padding: .38em .85em;
  border: 1px solid rgba(126,176,255,.5);
  border-radius: 999px;
  color: #a9caff;
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: .68rem;
  font-weight: 700;
  margin: 0 0 1em;
}
.hero h1 { font-size: clamp(2.2rem, 5.4vw, 3.6rem); line-height: 1.05; margin: 0 0 .4em; color: #fff }
.hero > p:not(.eyebrow) { color: #c2cde0; font-size: 1.08rem; line-height: 1.6 }
.hero code { background: rgba(255,255,255,.1); color: #d8e6ff; padding: 2px 6px; border-radius: 4px; font-size: .85em }

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: .82em 1.3em;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 140ms ease, border-color 140ms ease, transform 140ms ease;
}
.btn:hover { transform: translateY(-1px) }
.btn--primary { background: #fff; color: #041530 }
.btn--primary:hover { background: #cfe0ff }
.btn--ghost { border-color: rgba(255,255,255,.4); color: #fff }
.btn--ghost:hover { border-color: #fff; background: rgba(255,255,255,.08) }


.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 40px }
.info-card { padding: 20px 22px; border: 1px solid rgba(126,176,255,.22); border-radius: 12px; background: rgba(2,9,21,.5) }
.info-card h3 { margin: 0; font-size: .92rem; font-weight: 700; color: #fff }
.info-card p { margin: 10px 0 0; font-size: .87rem; line-height: 1.6; color: #c2cde0 }
@media (max-width: 760px) { .info-grid { grid-template-columns: minmax(0, 1fr) } }

/* ---------------------------------------------------------------------
   Content — theme-aware. This is the "white in light mode" surface.
   --------------------------------------------------------------------- */
main { max-width: 1180px; margin: 0 auto; padding: 0 24px 56px }

/* Compact page title for every non-landing page — theme-aware, no hero band.
   Lighter weight and looser tracking, matching docs.engineeringruntime.com's
   own minimal page-title style rather than a heavy display weight. */
.page-header { max-width: 760px; margin: 40px 0 4px }
.page-header .eyebrow { color: var(--accent) }
.page-header h1 { font-size: clamp(1.9rem, 3.8vw, 2.7rem); font-weight: 600; line-height: 1.15; margin: .25em 0 .35em; color: var(--text); letter-spacing: -.01em }
.page-header > p:not(.eyebrow) { color: var(--muted); font-size: 1rem; line-height: 1.55; margin: 0 }

/* Content + sticky right-rail table of contents, generated per page from its
   own headings. Collapses to a single column with no TOC below the
   breakpoint — there isn't room for a third visual column on a phone. */
.page-body { display: grid; grid-template-columns: minmax(0, 1fr) 200px; gap: 48px; align-items: start; max-width: 1000px }
.page-body .prose { max-width: none }
.toc { position: sticky; top: 84px; padding-left: 22px; border-left: 1px solid var(--line) }
.toc__title { margin: 0 0 10px; font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted) }
.toc ul { list-style: none; margin: 0; padding: 0 }
.toc__item a { display: block; padding: 4px 0; color: var(--muted); font-size: .82rem; text-decoration: none; line-height: 1.4 }
.toc__item a:hover, .toc__item a:focus-visible { color: var(--accent) }
.toc__item--h3 a { padding-left: 14px; font-size: .78rem }
@media (max-width: 900px) {
  .page-body { grid-template-columns: minmax(0, 1fr) }
  .toc { display: none }
}

.summary { margin: 28px 0 8px; color: var(--muted); font-size: .92rem }

.operation { margin: 16px 0; padding: 22px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel) }
.op-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap }
.op-head code { font-size: .95rem }
.method { min-width: 62px; padding: 3px 8px; border-radius: 5px; text-align: center; text-transform: uppercase; font-weight: 800; font-size: .78rem; background: #315a91; color: #fff }
.method.post { background: #24755b }
.method.delete { background: #9b3f4a }
.auth { margin-left: auto; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-size: .7rem }
.operation h2 { margin: 14px 0 4px; font-size: 1.1rem }
.operation p { color: var(--muted); margin: 0 }
.contracts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px }
.contracts span { padding: 3px 8px; background: var(--code-bg); border-radius: 5px; color: var(--muted); font-size: .76rem }
.operation details { margin-top: 14px }
.operation summary { cursor: pointer; color: var(--accent); font-size: .85rem }
.operation pre { margin-top: 10px }
.empty { color: var(--muted) }

.prose { max-width: 760px; margin: 40px 0 0 }
.prose h2 { margin: 40px 0 12px; font-size: 1.4rem; font-weight: 650; letter-spacing: -.005em }
.prose h2:first-child { margin-top: 0 }
.prose h3 { margin: 26px 0 8px; font-size: 1.02rem; font-weight: 650; color: var(--accent) }
.prose p { color: var(--muted); margin: 10px 0; line-height: 1.6 }
.prose ul, .prose ol { margin: 10px 0; padding-left: 22px; color: var(--muted) }
.prose li { margin: 6px 0 }
.prose code { background: var(--code-bg); color: var(--code-text); padding: 2px 6px; border-radius: 4px; font-size: .85em }
.prose table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: .9rem }
.prose th, .prose td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top }
.prose th { color: var(--accent); text-transform: uppercase; font-size: .7rem; letter-spacing: .08em }
.prose a { color: var(--accent); text-decoration: underline }
.prose a:hover { text-decoration-thickness: 2px }

pre, .prose pre { overflow: auto; padding: 16px; background: var(--code-bg); color: var(--code-text); border-radius: 8px; font-size: .82rem; margin: 14px 0; border: 1px solid var(--line) }
pre code, .prose pre code { background: none; padding: 0; color: inherit; font-size: inherit }

footer { padding: 30px; text-align: center; border-top: 1px solid var(--line); color: var(--muted) }

@media (max-width: 760px) {
  .site-header__inner { flex-wrap: wrap; gap: 10px }
  .header-link__label { display: none }
  .header-link { padding: 0; width: 36px; min-width: 36px; justify-content: center }
  .er-header-search__label { display: none }
  .er-header-search { width: 36px; padding: 0; justify-content: center }
}
