/* Vault design tokens — mirrors lib/shared/vault_colors.dart (dark + light)
   and lib/shared/vault_text.dart. Sizes used: 34/22/15/13/11. Weights: 400/700.
   Both token blocks are pinned hex-for-hex to the Dart palettes by
   scripts/tests/test_vault_css_tokens.py (Phase 31 D-14 (2)); every other
   rule must use var(--token) only. */
:root {
  --bg:#070B14;
  --surface:#0D1422;
  --surface-alt:#131B2C;
  --ink:#D5E1F2;
  --muted:#8B9BB8;
  --line:#1F293D;
  --accent:#39E0C4;
  --accent-soft:#79EDD9;
  --on-accent:#03100C;
  --burn:#FF6A4A;
  --glow:rgba(57,224,196,.22);
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --sans: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}
/* Light token set (D-11): selected by the no-flash boot snippet and the
   theme toggle through html[data-theme="light"]; dark is the default (D-10). */
html[data-theme="light"] {
  --bg:#EEF2F7;
  --surface:#FFFFFF;
  --surface-alt:#DDE4EE;
  --ink:#0A1426;
  --muted:#54637C;
  --line:#C5CFDE;
  --accent:#0B6E62;
  --accent-soft:#0E7A6C;
  --on-accent:#FFFFFF;
  --burn:#B33A1B;
  --glow:rgba(11,110,98,.18);
  color-scheme: light;
}
/* Grid = line at 40% on dark / 60% on light, mirrors GridBackground. */
html[data-theme="light"] body::before {
  opacity: .4;
}

* {
  border-radius: 0;
  box-shadow: none;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(to right, var(--line) 1px, transparent 1px),
    linear-gradient(to bottom, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
  background-blend-mode: normal;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg);
  opacity: .6;
  z-index: -1;
  pointer-events: none;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Auth visibility (D-02 / Pattern 3): both nav sets are in the HTML; the
   root attribute set by docs.js from the vault.auth hint picks one. Without
   the attribute (no hint, unparsable hint, no JS) the signed-out set shows. */
html:not([data-auth="in"]) [data-auth="in"] {
  display: none !important;
}
html[data-auth="in"] [data-auth="out"] {
  display: none !important;
}

/* Header — single 64px row, sticky (UI-SPEC Surface 1, R-06) */
.vault-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0 48px;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 64px;
  white-space: nowrap;
}
.vault-header .logo {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
}
.vault-header .logo svg {
  display: block;
  width: 30px;
  height: 30px;
}
.wordmark {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .4px;
  color: var(--ink);
}
.wordmark:hover {
  text-decoration: none;
}
.wordmark .accent {
  color: var(--accent);
}
.tag {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
/* The theme control opens the right cluster (Surface 1 / Surface 2): the
   pill on desktop, the icon on the collapsed bar. */
.theme-pill,
.theme-icon {
  margin-left: auto;
}
.vault-nav {
  display: flex;
  align-items: center;
  gap: 16px;
}
.vault-nav a {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}
.vault-nav a:hover {
  color: var(--ink);
  text-decoration: none;
}
.vault-nav a.active {
  color: var(--accent);
}
.vault-nav a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Dense buttons (R-06): 8px 16px, 13px/700, 8px chamfer */
.btn-primary {
  display: inline-block;
  background: var(--accent);
  color: var(--on-accent);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1;
  padding: 8px 16px;
  flex: 0 0 auto;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
.btn-primary:hover {
  background: var(--accent-soft);
  text-decoration: none;
}
/* Phase 31 D-01: the primary CTA is rendered inside .vault-nav from the
   manifest; keep the button label on-accent despite the .vault-nav a rule. */
.vault-nav a.btn-primary,
.vault-nav a.btn-primary:hover {
  color: var(--on-accent);
  font-size: 13px;
  letter-spacing: .04em;
}

/* Ghost button (A-7): surface fill, 1px line, ink label, hover surfaceAlt;
   `$ ` prefix is in the text. Used by $ DASH in the bar and the docs CTAs. */
.btn-ghost {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1;
  padding: 8px 16px;
  margin: 0;
  flex: 0 0 auto;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
.btn-ghost:hover {
  background: var(--surface-alt);
  color: var(--ink);
  text-decoration: none;
}
.reading .btn-ghost {
  margin: 16px 0 0;
}

/* Collapsed-bar controls (Surface 2) — hidden on desktop, shown < 720px */
.theme-icon {
  display: none;
  appearance: none;
  width: 36px;
  height: 36px;
  padding: 8px;
  margin: 0 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.theme-icon svg {
  display: block;
  width: 18px;
  height: 18px;
}
.theme-icon:hover {
  color: var(--ink);
}
.theme-icon .icon-moon {
  display: none;
}
html[data-theme="light"] .theme-icon .icon-sun {
  display: none;
}
html[data-theme="light"] .theme-icon .icon-moon {
  display: block;
}
.btn-bar {
  display: none;
  align-items: center;
}
.menu-btn {
  display: none;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  line-height: 1;
  padding: 8px 16px;
  margin: 0;
  cursor: pointer;
  align-items: center;
  flex: 0 0 auto;
  clip-path: polygon(0 0, calc(100% - 8px) 0, 100% 8px, 100% 100%, 8px 100%, 0 calc(100% - 8px));
}
.menu-btn:hover {
  background: var(--surface-alt);
}

/* Account disclosure trigger `$ user` (Surface 4, R-16) */
.account-btn {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  cursor: pointer;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-btn:hover {
  color: var(--ink);
}
.account-btn[aria-expanded="true"] {
  color: var(--accent);
}

/* Drop-down nav panel (Surface 3, D-05..D-08): overlay under the header, no
   animation. No `display` on .vault-panel itself so the UA [hidden] rule
   applies with JS and the <noscript> rule (display:block; position:static)
   can still win without it. */
.vault-panel {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  z-index: 20;
  white-space: normal;
}
.vault-panel a {
  display: block;
  height: 48px;
  padding: 0 20px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 48px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.vault-panel a:hover {
  color: var(--ink);
  text-decoration: none;
}
.vault-panel a:active {
  background: var(--surface-alt);
}
.vault-panel a.active {
  background: var(--accent);
  color: var(--on-accent);
}
.vault-panel a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.vault-panel a.active:focus-visible {
  outline-color: var(--on-accent);
}
.vault-panel .email {
  display: block;
  padding: 12px 20px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  text-transform: none;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.vault-panel .divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.vault-panel-backdrop {
  position: fixed;
  inset: 64px 0 0 0;
  background: transparent;
  z-index: 15;
}

/* Account disclosure panel under `$ user` (Surface 4) */
.vault-account {
  position: absolute;
  top: 100%;
  right: 48px;
  min-width: 240px;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--line);
  z-index: 20;
  white-space: normal;
}
.vault-account .email {
  display: block;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.5;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.vault-account .divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0;
}
.vault-account a {
  display: block;
  height: 44px;
  padding: 0 16px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  line-height: 44px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink);
}
.vault-account a:hover {
  background: var(--surface-alt);
  text-decoration: none;
}
.vault-account a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
/* Safety: the two overlays must never paint while hidden, whatever display
   they inherit. (.vault-panel is deliberately excluded — see above.) */
.vault-panel-backdrop[hidden],
.vault-account[hidden] {
  display: none !important;
}

/* Main */
.vault-main {
  flex: 1 0 auto;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 48px;
}
.reading {
  max-width: 760px;
  overflow-wrap: anywhere;
}

h1, h2, h3 {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--ink);
}
h1 {
  font-size: clamp(22px, 8vw, 34px);
  line-height: 1.1;
  letter-spacing: -0.5px;
  margin: 8px 0 24px;
}
h2 {
  font-size: 22px;
  line-height: 1.2;
  margin: 48px 0 16px;
}
h3 {
  font-size: 15px;
  line-height: 1.4;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-top: 1px solid var(--line);
  padding-top: 32px;
  margin: 32px 0 16px;
}
.pretitle {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  margin: 0;
}

p {
  margin: 0;
}
p + p {
  margin-top: 16px;
}
h2 + p, h3 + p, ul + p, ol + p, pre + p, .table-wrap + p {
  margin-top: 16px;
}
ul, ol {
  padding-left: 24px;
  margin: 16px 0;
}
li + li {
  margin-top: 8px;
}

code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  padding: 1px 6px;
}
pre {
  background: var(--surface-alt);
  border: 1px solid var(--line);
  padding: 16px;
  overflow-x: auto;
  white-space: pre;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.7;
  margin: 16px 0;
}
pre code {
  background: none;
  border: 0;
  padding: 0;
}

.table-wrap {
  overflow-x: auto;
  margin: 16px 0;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 13px;
}
th, td {
  border: 1px solid var(--line);
  padding: 8px 12px;
  text-align: left;
  vertical-align: top;
}
th {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: var(--surface);
}

.on-this-page {
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
  margin: 0 0 32px;
  font-family: var(--mono);
  font-size: 13px;
}
.on-this-page ul {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
}
.on-this-page li + li {
  margin-top: 4px;
}

/* Footer (Surface 8: three inline links at every width) */
.vault-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 16px 48px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
}
.vault-footer a {
  color: var(--muted);
}
.vault-footer a:hover {
  color: var(--ink);
  text-decoration: none;
}

/* Breakpoints (R-05, R-14) — aligned with Flutter: < 960 hides the wordmark
   cluster, < 720 is the collapsed bar (Flutter treats exactly 720 as desktop). */
@media (max-width: 959.98px) {
  .wordmark, .tag {
    display: none;
  }
}
@media (max-width: 719.98px) {
  .vault-header, .vault-main, .vault-footer {
    padding-left: 20px;
    padding-right: 20px;
  }
  .vault-header {
    gap: 8px;
  }
  .vault-nav, .theme-pill, .account-btn, .vault-account {
    display: none !important;
  }
  .theme-icon, .menu-btn, .btn-bar {
    display: inline-flex;
  }
}

/* /docs/api — wide reading column so the Redoc host can use the full 1200px */
.reading.wide {
  max-width: none;
}
.reading.wide > p, .reading.wide > ul, .reading.wide > ol, .reading.wide > h2,
.reading.wide > h3, .reading.wide > .on-this-page, .reading.wide > .vault-segmented,
.reading.wide > .tabpanel, .reading.wide > .sdk-links, .reading.wide > .btn-ghost,
.reading.wide > noscript {
  max-width: 760px;
}

.sdk-links {
  margin-top: 32px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.sdk-links .btn-ghost {
  margin: 0;
}

/* Shared segmented control (D-12 / D-13, UI-SPEC Surface 5): selected cell =
   accent fill + on-accent text; unselected = surfaceAlt + muted; hover ink.
   Used by the header theme pill (.compact) and the SDK tabs (.fill). */
.vault-segmented {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--line);
}
.vault-segmented.fill {
  display: flex;
}
.vault-segmented.fill > * {
  flex: 1;
}
.vault-segmented > * {
  appearance: none;
  margin: 0;
  background: var(--surface-alt);
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--muted);
  font: 700 11px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  height: 40px;
  padding: 0 12px;
  cursor: pointer;
}
.vault-segmented > :first-child {
  border-left: 0;
}
.vault-segmented > :hover {
  color: var(--ink);
}
.vault-segmented > :active {
  background: var(--surface);
}
.vault-segmented > [aria-selected="true"],
.vault-segmented > [aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}
.vault-segmented > :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}
.vault-segmented > [aria-selected="true"]:focus-visible,
.vault-segmented > [aria-pressed="true"]:focus-visible {
  outline-color: var(--on-accent);
}
.vault-segmented > :disabled,
.vault-segmented[aria-disabled="true"] > * {
  color: var(--muted);
  cursor: default;
}
.vault-segmented.compact > * {
  height: 32px;
  padding: 0 8px;
}
.vault-segmented.tall > * {
  height: 48px;
}
/* The SDK tablists sit under an h3 in the reading column. */
.reading .vault-segmented.fill {
  margin-top: 16px;
}
.tabpanel {
  position: relative;
  background: var(--surface-alt);
  border: 1px solid var(--line);
  border-top: 0;
  padding: 24px;
}
.tabpanel pre {
  margin: 0;
  overflow-x: auto;
  white-space: pre;
}
.tabpanel[hidden] {
  display: none;
}
.copy {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  cursor: pointer;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 6px 10px;
}
.copy:hover {
  color: var(--accent);
  border-color: var(--accent);
}
.caption {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  margin-top: 8px;
}

/* Redoc host (read-only reference, D-06) */
.reference-gap {
  margin-top: 64px;
}
.redoc-host {
  min-height: 512px;
  margin-top: 16px;
}
#redoc * {
  border-radius: 0 !important;
  box-shadow: none !important;
}
#redoc .redoc-wrap {
  background: var(--bg);
}
#redoc .menu-content {
  background: var(--surface);
  position: sticky;
  top: 64px;
}
/* Redoc overrides (UI-SPEC Surface 6, R-15) — the actual fix for the two
   observed defects in BOTH themes. Redoc hard-codes white on the method
   badges and paints the selected sample tab text.primary on
   rightPanel.textColor (ink on ink with our theme); only a #redoc-scoped
   override reaches them, and it is theme-agnostic through the tokens. */
#redoc .http-verb, #redoc .operation-type {
  color: var(--on-accent) !important;
  font-family: var(--mono) !important;
  font-weight: 700;
  letter-spacing: .04em;
}
#redoc .operation-type {
  width: auto;
  padding: 0 4px;
}
#redoc .react-tabs__tab {
  background: var(--surface-alt) !important;
  color: var(--muted) !important;
  border: 1px solid var(--line) !important;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  line-height: 30px;
  padding: 0 12px;
  min-width: 0;
  margin: 0 8px 8px 0;
}
#redoc .react-tabs__tab:hover {
  color: var(--ink) !important;
}
#redoc .react-tabs__tab--selected {
  background: var(--accent) !important;
  color: var(--on-accent) !important;
  border-color: var(--accent) !important;
}
#redoc .react-tabs__tab:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
#redoc .react-tabs__tab--selected:focus-visible {
  outline-color: var(--on-accent);
  outline-offset: -3px;
}
#redoc .react-tabs__tab-panel {
  background: var(--bg) !important;
}
