@import url("./style/fonts.css");
@import url("./style/tokens.css");
@import url("./style/base.css");

/*
 * Documentation /ui portal — layout and components.
 * SPINEsim design system (documentation/Design/02-design-system-rules.md): --ds-* tokens only.
 * Buttons follow shared/ui/button/Button.css, the release tabs NavigationTab.css, the top bar TopBar.css.
 */

:root {
  /* Secondary text on dark surfaces; same color-mix pattern as NavigationTab.css (no ds token for it). */
  --docs-color-text-secondary: color-mix(in srgb, var(--ds-color-text-primary) 72%, transparent);
  /* One page width everywhere, so the breadcrumb, tabs and content never shift between pages. */
  --docs-content-max-width: 76rem;
  --docs-toc-width: 16rem;
  --docs-rail-width: 12rem;
  /* Reading measure: about 70 characters per line of body text */
  --docs-measure: 42rem;
}

* {
  box-sizing: border-box;
}

/* Components below set display; the hidden attribute must still win. */
[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-size: var(--ds-font-size-body-16);
  line-height: var(--ds-line-height-body-16);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

a {
  color: var(--ds-color-primary-selected);
}

:focus-visible {
  outline: var(--ds-border-width-md) solid var(--ds-color-primary-selected);
  outline-offset: var(--ds-border-width-md);
}

/* ---------- top bar ---------- */
.app-header {
  height: var(--ds-size-topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ds-space-md);
  padding: 0 var(--ds-space-lg);
  background-color: var(--ds-color-surface-overlay);
  box-shadow: var(--ds-shadow-topbar);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--ds-space-md);
  min-width: 0;
  color: var(--ds-color-text-primary);
  text-decoration: none;
}

/* Same height as .App-logo-spinesim (AppLogos.css --navbar-logo-height) */
.brand-logo {
  display: block;
  height: 15px; /* ds:intentional — SPINEsim logo height in the app top bar */
  width: auto;
}

/* Vertical divider between top-bar sections (TopBar.css .App-top-bar-divider) */
.brand-divider {
  width: var(--ds-border-width-thin);
  height: 20px; /* ds:intentional — Figma divider height, no token equivalent */
  background-color: var(--ds-color-primary-light);
  opacity: 0.4;
}

.brand-section {
  font-size: var(--ds-font-size-body-16);
  font-weight: var(--ds-font-weight-medium);
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: var(--ds-space-md);
  align-items: center;
}

.app-header .hint {
  font-size: var(--ds-font-size-body-14);
  color: var(--docs-color-text-secondary);
}

/* ---------- buttons (Button.css: tertiary by default, .primary = primary, size M) ---------- */
button,
a.button,
a.button-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px; /* ds:intentional — Button.css size M */
  padding: 0 var(--ds-space-md);
  border: var(--ds-border-width-thin) solid var(--ds-color-primary-lightest);
  border-radius: var(--ds-radius-2xl);
  background-color: transparent;
  color: var(--ds-color-primary-lightest);
  font-size: var(--ds-font-size-body-16);
  font-weight: var(--ds-font-weight-regular);
  line-height: var(--ds-line-height-body-16);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  filter: drop-shadow(var(--ds-shadow-ui));
  transition: var(--ds-transition-all);
}

button:hover,
a.button:hover,
a.button-link:hover {
  border-color: var(--ds-color-primary-lighter);
  color: var(--ds-color-primary-lighter);
}

button:active,
a.button:active {
  background-color: color-mix(in srgb, var(--ds-color-primary-lighter) 16%, transparent);
}

button.primary,
a.button-link {
  border-color: var(--ds-color-primary);
  background-color: var(--ds-color-primary);
  color: var(--ds-color-text-primary);
  filter: none;
  box-shadow: var(--ds-shadow-ui);
}

button.primary:hover,
a.button-link:hover {
  border-color: var(--ds-color-surface-raised);
  background-color: var(--ds-color-surface-raised);
  color: var(--ds-color-text-primary);
}

button.primary:active,
a.button-link:active {
  background-color: var(--ds-color-primary-selected);
  color: var(--ds-color-surface-overlay);
  box-shadow: none;
}

/* Ghost: no border (Button.css .ds-btn--ghost) */
a.button.ghost {
  border-color: transparent;
}

/* ---------- page ---------- */
main {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--docs-content-max-width);
  margin: 0 auto;
  padding: var(--ds-space-xl);
}

/* ---------- context bar: breadcrumb (back link on phones) + version switcher ---------- */
.context-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ds-space-sm) var(--ds-space-md);
  margin-bottom: var(--ds-space-md);
}

.context-bar:has(> .breadcrumb:empty):has(> .version-switch[hidden]) {
  display: none;
}

.crumb-back {
  display: none;
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
}

.crumb-back a {
  text-decoration: none;
}

.version-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--ds-space-sm);
  margin-left: auto;
  font-size: var(--ds-font-size-body-14);
  color: var(--docs-color-text-secondary);
}

/* Native select (keyboard and phone pickers for free), styled as a tertiary pill (Button.css). */
.version-switch select {
  appearance: none;
  height: 32px; /* ds:intentional — Button.css size M */
  padding: 0 var(--ds-space-xl) 0 var(--ds-space-md);
  border: var(--ds-border-width-thin) solid var(--ds-color-primary-lightest);
  border-radius: var(--ds-radius-2xl);
  background-color: transparent;
  color: var(--ds-color-primary-lightest);
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
  cursor: pointer;
  transition: var(--ds-transition-border);
}

.version-switch select:hover {
  border-color: var(--ds-color-primary-lighter);
}

.version-switch select option {
  background-color: var(--ds-color-surface-overlay);
  color: var(--ds-color-text-primary);
}

.version-switch::after {
  content: "▾";
  position: absolute;
  right: var(--ds-space-md);
  color: var(--ds-color-primary-lightest);
  pointer-events: none;
}

.docs-page-header {
  margin-bottom: var(--ds-space-lg);
}

.docs-page-header[hidden] {
  display: none;
}

.docs-page-title {
  margin: 0;
  font-size: var(--ds-font-size-h1);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-h1);
  letter-spacing: var(--ds-letter-spacing-snug);
}

.docs-page-subtitle {
  margin: var(--ds-space-sm) 0 0;
  color: var(--docs-color-text-secondary);
}

/* Sign in below the subtitle — shown only after an explicit Sign out (otherwise /ui redirects to the IdP). */
.docs-page-auth {
  margin-top: var(--ds-space-lg);
}

html.docs-ui-signed-in .docs-page-auth {
  display: none;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--ds-space-xs) var(--ds-space-sm);
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
  color: var(--docs-color-text-secondary);
}

.breadcrumb:empty {
  display: none;
}

.breadcrumb a {
  text-decoration: none;
  transition: var(--ds-transition-colors);
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.breadcrumb .here {
  color: var(--ds-color-text-primary);
}

/* ---------- release tabs (NavigationTab.css segment control) ---------- */
.release-tabs {
  position: relative;
  display: flex;
  width: max-content;
  max-width: 100%;
  margin-bottom: var(--ds-space-lg);
  overflow-x: auto;
  isolation: isolate;
  border-radius: var(--ds-radius-xl);
  scrollbar-width: none;
}

.release-tabs::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: var(--ds-radius-lg);
  background: var(--ds-color-primary);
  opacity: 0.32;
  box-shadow: var(--ds-shadow-thumbnail);
}

.release-tabs[hidden] {
  display: none;
}

.release-tab {
  display: flex;
  align-items: center;
  height: 32px; /* ds:intentional — NavigationTab.css --nav-tab-height */
  padding: var(--ds-space-xs) var(--ds-space-md);
  border-radius: var(--ds-radius-xl);
  color: color-mix(in srgb, var(--ds-color-text-primary) 60%, transparent);
  font-size: var(--ds-font-size-body-16);
  line-height: var(--ds-line-height-body-16);
  text-decoration: none;
  white-space: nowrap;
  transition: var(--ds-transition-all);
}

.release-tab:hover:not([aria-current="page"]) {
  background: color-mix(in srgb, var(--ds-color-primary-selected) 20%, transparent);
  color: var(--ds-color-text-primary);
}

.release-tab[aria-current="page"] {
  background: var(--ds-color-primary-selected);
  color: var(--ds-color-surface-overlay);
  box-shadow: var(--ds-shadow-thumbnail);
}

/* ---------- navigation cards ---------- */
ul.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-md);
}

a.card {
  display: flex;
  align-items: center;
  gap: var(--ds-space-md);
  padding: var(--ds-space-md) var(--ds-space-lg);
  border: var(--ds-border-width-thin) solid transparent;
  border-radius: var(--ds-radius-md);
  background-color: var(--ds-color-surface-raised);
  box-shadow: var(--ds-shadow-ui);
  color: var(--ds-color-text-primary);
  text-decoration: none;
  transition: var(--ds-transition-border), var(--ds-transition-bg);
}

a.card:hover {
  border-color: var(--ds-color-primary-selected);
  background-color: color-mix(in srgb, var(--ds-color-primary-selected) 10%, var(--ds-color-surface-raised));
}

a.card .t {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-xs);
}

a.card .label {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--ds-space-sm);
  font-size: var(--ds-font-size-h4);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-h4);
}

a.card.mini .label {
  font-size: var(--ds-font-size-body-16);
  line-height: var(--ds-line-height-body-16);
}

a.card .meta {
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
  color: var(--docs-color-text-secondary);
  overflow-wrap: anywhere;
}

/* Summaries (tutorial goals, search snippets) stay two lines at most. */
a.card.mini .meta {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
}

.card-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px; /* ds:intentional — icon tile, Button.css size L */
  height: 40px;
  border-radius: var(--ds-radius-sm);
  background-color: color-mix(in srgb, var(--ds-color-primary) 32%, transparent);
}

.card-icon .stroke-path {
  stroke: var(--ds-color-primary-selected);
}

/* Card grids on wide screens (cardList cols / tiles); one column on phones and tablets. */
@media (min-width: 769px) {
  ul.cards-cols-2,
  ul.cards-cols-3 {
    display: grid;
    gap: var(--ds-space-md);
  }

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

  ul.cards-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  ul.cards-tiles {
    gap: var(--ds-space-lg);
  }

  ul.cards-cols-2 a.card,
  ul.cards-cols-3 a.card {
    height: 100%;
  }

  ul.cards-tiles a.card {
    flex-direction: column;
    align-items: flex-start;
    padding: var(--ds-space-lg);
  }

  ul.cards-tiles a.card .chev {
    display: none;
  }
}

a.card .chev {
  flex-shrink: 0;
  color: var(--ds-color-primary-selected);
  font-size: var(--ds-font-size-h2);
  line-height: 1;
  transition: var(--ds-transition-all);
}

a.card:hover .chev {
  transform: translateX(var(--ds-space-xs));
}

/* Subtle status badge (Chips & Badge.png, success) */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--ds-space-sm);
  border-radius: var(--ds-radius-xs);
  background-color: color-mix(in srgb, var(--ds-color-status-success) 20%, var(--ds-color-surface));
  color: var(--ds-color-status-success);
  font-size: var(--ds-font-size-caption);
  font-weight: var(--ds-font-weight-medium);
  line-height: var(--ds-line-height-caption);
}

/* ---------- notes, states ---------- */
.hint,
.loading,
.empty {
  color: var(--docs-color-text-secondary);
}

.pagenote,
.footnote {
  margin: var(--ds-space-lg) 0 0;
  padding-top: var(--ds-space-md);
  border-top: var(--ds-border-width-thin) solid var(--ds-color-surface-subtle);
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
  color: var(--docs-color-text-secondary);
}

.error {
  margin-top: var(--ds-space-md);
  color: var(--ds-color-status-error);
}

.failure {
  margin-top: var(--ds-space-md);
  padding: var(--ds-space-lg);
  border: var(--ds-border-width-thin) solid var(--ds-color-status-error);
  border-radius: var(--ds-radius-md);
  background-color: color-mix(in srgb, var(--ds-color-status-error) 10%, var(--ds-color-surface));
}

.failure p {
  margin: 0 0 var(--ds-space-md);
}

.failure-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-md);
  align-items: center;
}

.not-found h2 {
  margin: 0 0 var(--ds-space-sm);
  font-size: var(--ds-font-size-h3);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-h3);
}

.notice-missing {
  margin: 0 0 var(--ds-space-md);
  padding: var(--ds-space-sm) var(--ds-space-md);
  border-left: var(--ds-border-width-thick) solid var(--ds-color-primary-selected);
  border-radius: var(--ds-radius-xs);
  background-color: var(--ds-color-surface-overlay);
}

/* ---------- PDF preview ---------- */
.doc-preview {
  display: flex;
  flex-direction: column;
  /* Reader fills the window below the top bar, breadcrumb and tabs (~15rem). */
  height: max(32rem, calc(100vh - var(--ds-size-topbar-height) - 15rem)); /* ds:intentional — viewer height */
  overflow: hidden;
  border-radius: var(--ds-radius-md);
  background-color: var(--ds-color-surface-overlay);
  box-shadow: var(--ds-shadow-thumbnail);
}

.doc-preview[hidden] {
  display: none !important;
}

.doc-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--ds-space-sm) var(--ds-space-md);
  padding: var(--ds-space-sm) var(--ds-space-md);
  border-bottom: var(--ds-border-width-thin) solid var(--ds-color-surface-subtle);
}

.doc-preview-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--ds-font-size-body-14);
  color: var(--docs-color-text-secondary);
}

.doc-preview-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-sm);
}

.doc-preview iframe {
  flex: 1;
  width: 100%;
  border: none;
  background-color: var(--ds-color-surface-subtle);
}

.doc-preview .failure {
  margin: var(--ds-space-md);
}

/* ---------- training ---------- */
.section-intro {
  margin: 0 0 var(--ds-space-lg);
  color: var(--docs-color-text-secondary);
}

.doc {
  padding: var(--ds-space-xl);
  border-radius: var(--ds-radius-md);
  background-color: var(--ds-color-surface-overlay);
  box-shadow: var(--ds-shadow-thumbnail);
}

.doc .eyebrow {
  font-size: var(--ds-font-size-body-14);
  font-weight: var(--ds-font-weight-medium);
  line-height: var(--ds-line-height-body-14);
  color: var(--ds-color-primary-selected);
}

.doc h2 {
  margin: var(--ds-space-xs) 0 0;
  font-size: var(--ds-font-size-h2);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-h2);
}

.doc h3 {
  margin: var(--ds-space-xl) 0 var(--ds-space-md);
  padding-bottom: var(--ds-space-sm);
  border-bottom: var(--ds-border-width-thin) solid var(--ds-color-surface-subtle);
  font-size: var(--ds-font-size-h4);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-h4);
}

.doc p {
  margin: 0 0 var(--ds-space-md);
}

.doc .lede {
  font-size: var(--ds-font-size-h4);
  line-height: var(--ds-line-height-h4);
}

.doc .bullets {
  margin: 0;
  padding-left: var(--ds-space-lg);
}

.doc .bullets li {
  margin-bottom: var(--ds-space-sm);
}

.player {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: var(--ds-radius-sm);
  background-color: var(--ds-color-black);
}

.notice {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-xs) var(--ds-space-md);
  align-items: baseline;
  margin-top: var(--ds-space-sm);
  padding: var(--ds-space-md);
  border: var(--ds-border-width-thin) solid var(--ds-color-surface-raised);
  border-left-width: var(--ds-border-width-xl);
  border-radius: var(--ds-radius-sm);
  background-color: var(--ds-color-surface);
}

.doc .notice p {
  flex: 1 1 16rem;
  margin: 0;
}

.notice-kind {
  font-size: var(--ds-font-size-caption);
  font-weight: var(--ds-font-weight-bold);
  line-height: var(--ds-line-height-caption);
  letter-spacing: var(--ds-letter-spacing-wide);
}

.notice-caution {
  border-color: var(--ds-color-status-warning);
  background-color: color-mix(in srgb, var(--ds-color-status-warning) 10%, var(--ds-color-surface));
}

.notice-caution .notice-kind {
  color: var(--ds-color-status-warning);
}

.notice-warning {
  border-color: var(--ds-color-status-error);
  background-color: color-mix(in srgb, var(--ds-color-status-error) 10%, var(--ds-color-surface));
}

.notice-warning .notice-kind {
  color: var(--ds-color-status-error);
}

.notice-disclaimer {
  border-color: var(--ds-color-primary-selected);
}

.notice-disclaimer .notice-kind {
  color: var(--ds-color-primary-selected);
}

.gallery-group {
  margin-bottom: var(--ds-space-md);
  padding: var(--ds-space-md);
  border-radius: var(--ds-radius-sm);
  background-color: var(--ds-color-surface);
}

.gallery-label {
  margin-bottom: var(--ds-space-sm);
  font-weight: var(--ds-font-weight-semibold);
}

.gallery-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));
  gap: var(--ds-space-md);
}

.gallery-items figure {
  margin: 0;
}

.gallery-items img {
  width: 100%;
  height: auto;
  border-radius: var(--ds-radius-xs);
  background-color: var(--ds-color-text-primary);
}

.gallery-items figcaption {
  margin-top: var(--ds-space-xs);
  font-size: var(--ds-font-size-caption);
  line-height: var(--ds-line-height-caption);
  color: var(--docs-color-text-secondary);
}

.rel {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--ds-space-md);
  margin-top: var(--ds-space-xl);
}

.relbtn {
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-xs);
  padding: var(--ds-space-md) var(--ds-space-lg);
  border: var(--ds-border-width-thin) solid var(--ds-color-surface-raised);
  border-radius: var(--ds-radius-md);
  background-color: var(--ds-color-surface-raised);
  color: var(--ds-color-text-primary);
  text-decoration: none;
  transition: var(--ds-transition-border), var(--ds-transition-bg);
}

a.relbtn[data-testid="rel-next"] {
  text-align: right;
}

a.relbtn:hover {
  border-color: var(--ds-color-primary-selected);
  background-color: color-mix(in srgb, var(--ds-color-primary-selected) 10%, var(--ds-color-surface-raised));
}

.relbtn[aria-disabled="true"] {
  border-style: dashed;
  border-color: var(--ds-color-surface-subtle);
  background-color: transparent;
  color: var(--docs-color-text-secondary);
}

.relbtn .k {
  font-size: var(--ds-font-size-caption);
  line-height: var(--ds-line-height-caption);
  color: var(--docs-color-text-secondary);
}

.relbtn .v {
  font-weight: var(--ds-font-weight-semibold);
}

.relbtn[aria-disabled="true"] .v {
  font-weight: var(--ds-font-weight-regular);
}

.relbtn .s {
  font-size: var(--ds-font-size-caption);
  line-height: var(--ds-line-height-caption);
  color: var(--docs-color-text-secondary);
}

.doc .footnote {
  margin-top: var(--ds-space-xl);
}

.footnote-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-xs) var(--ds-space-md);
  margin: 0;
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
}

.footnote-links [aria-hidden="true"] {
  display: none;
}

/* ---------- responsive (values = --ds-breakpoint-*; custom properties cannot be used in media queries) ---------- */
/* Phones and tablets: a file card instead of the embedded reader (see preview.js canEmbedPdf). */
.doc-preview.doc-file {
  height: auto;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--ds-space-md);
  padding: var(--ds-space-lg);
}

.doc-file-text {
  flex: 1 1 12rem;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--ds-space-xs);
}

.doc-file .doc-preview-title {
  white-space: normal;
  overflow-wrap: anywhere;
  color: var(--ds-color-text-primary);
  font-weight: var(--ds-font-weight-semibold);
}

.doc-file .meta {
  font-size: var(--ds-font-size-body-14);
  color: var(--docs-color-text-secondary);
}

.doc-file .doc-preview-actions {
  flex: 1 1 100%;
}

.doc-file .doc-preview-actions button {
  flex: 1;
  height: 40px; /* ds:intentional — touch target, Button.css size L */
}

.doc-file .failure {
  flex: 1 1 100%;
  margin: 0;
}

button:disabled,
button:disabled:hover {
  cursor: not-allowed;
  border-color: var(--ds-color-neutral-medium);
  background-color: transparent;
  color: var(--ds-color-neutral-medium);
  box-shadow: none;
}

button.primary:disabled,
button.primary:disabled:hover {
  border-color: var(--ds-color-surface-raised);
  background-color: var(--ds-color-surface-raised);
  color: color-mix(in srgb, var(--ds-color-primary-lightest) 40%, transparent);
}

/* ---------- training: search, outline, contents ---------- */
.training-search {
  max-width: var(--docs-measure);
  margin-bottom: var(--ds-space-lg);
}

.training-search input {
  width: 100%;
  height: 40px; /* ds:intentional — Button.css size L */
  padding: 0 var(--ds-space-md);
  border: var(--ds-border-width-thin) solid var(--ds-color-surface-raised);
  border-radius: var(--ds-radius-2xl);
  background-color: var(--ds-color-surface-overlay);
  color: var(--ds-color-text-primary);
  font-size: var(--ds-font-size-body-16);
  transition: var(--ds-transition-border);
}

.training-search input::placeholder {
  color: var(--docs-color-text-secondary);
}

.training-search input:focus {
  border-color: var(--ds-color-primary-selected);
}

.search-summary {
  margin: 0 0 var(--ds-space-md);
  color: var(--docs-color-text-secondary);
  font-size: var(--ds-font-size-body-14);
}

.outline-section + .outline-section {
  margin-top: var(--ds-space-xl);
}

.outline-title {
  margin: 0;
  font-size: var(--ds-font-size-h3);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-h3);
}

.outline-title a {
  color: var(--ds-color-text-primary);
  text-decoration: none;
}

.outline-title a:hover {
  color: var(--ds-color-primary-selected);
}

.outline-meta {
  margin: var(--ds-space-xs) 0 var(--ds-space-md);
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
  color: var(--docs-color-text-secondary);
}

.page-header {
  margin-bottom: var(--ds-space-md);
}

.page-header .eyebrow {
  margin: 0;
  font-size: var(--ds-font-size-body-14);
  font-weight: var(--ds-font-weight-medium);
  line-height: var(--ds-line-height-body-14);
  color: var(--ds-color-primary-selected);
}

.page-header h2 {
  margin: var(--ds-space-xs) 0 0;
  font-size: var(--ds-font-size-h2);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-h2);
}

.training-layout {
  display: grid;
  grid-template-columns: var(--docs-toc-width) minmax(0, 1fr);
  gap: var(--ds-space-xl);
  align-items: start;
}

.toc-panel {
  position: sticky;
  top: var(--ds-space-lg);
  max-height: calc(100vh - 2 * var(--ds-space-lg));
  overflow-y: auto;
}

.toc-toggle {
  display: none;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-home {
  display: block;
  margin-bottom: var(--ds-space-md);
  font-size: var(--ds-font-size-body-14);
  text-decoration: none;
}

.toc-section + .toc-section {
  margin-top: var(--ds-space-md);
}

.toc-section-link {
  display: block;
  padding: var(--ds-space-xs) var(--ds-space-sm);
  border-radius: var(--ds-radius-xs);
  color: var(--ds-color-text-primary);
  font-size: var(--ds-font-size-body-14);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-body-14);
  text-decoration: none;
}

.toc-link {
  display: block;
  margin-top: var(--ds-space-xs);
  padding: var(--ds-space-xs) var(--ds-space-sm) var(--ds-space-xs) var(--ds-space-md);
  border-left: var(--ds-border-width-md) solid var(--ds-color-surface-raised);
  color: var(--docs-color-text-secondary);
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
  text-decoration: none;
  transition: var(--ds-transition-colors);
}

.toc-section-link:hover,
.toc-link:hover {
  color: var(--ds-color-primary-selected);
}

.toc-link[aria-current="page"],
.toc-section-link[aria-current="page"] {
  border-left-color: var(--ds-color-primary-selected);
  background-color: color-mix(in srgb, var(--ds-color-primary-selected) 12%, transparent);
  color: var(--ds-color-primary-selected);
  font-weight: var(--ds-font-weight-medium);
}

/* ---------- tutorial reading width + "On this page" rail ---------- */
.doc > .eyebrow,
.doc > h2,
.doc > h3,
.doc > p,
.doc > ul,
.doc > .notice {
  max-width: var(--docs-measure);
}

.doc h3[id] {
  scroll-margin-top: var(--ds-space-lg);
}

.doc h3[id]:focus {
  outline: none;
}

.page-rail {
  display: none;
}

/* = --ds-breakpoint-wide */
@media (min-width: 1440px) {
  .training-layout:has(> .page-rail) {
    grid-template-columns: var(--docs-toc-width) minmax(0, 1fr) var(--docs-rail-width);
  }

  .page-rail {
    display: block;
    position: sticky;
    top: var(--ds-space-lg);
  }
}

.page-rail-title {
  margin: 0 0 var(--ds-space-sm);
  font-size: var(--ds-font-size-body-14);
  font-weight: var(--ds-font-weight-semibold);
  line-height: var(--ds-line-height-body-14);
}

.page-rail ol {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-rail a {
  display: block;
  padding: var(--ds-space-xs) var(--ds-space-sm) var(--ds-space-xs) var(--ds-space-md);
  border-left: var(--ds-border-width-md) solid var(--ds-color-surface-raised);
  color: var(--docs-color-text-secondary);
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
  text-decoration: none;
  transition: var(--ds-transition-colors);
}

.page-rail a:hover {
  color: var(--ds-color-primary-selected);
}

.page-rail a[aria-current="true"] {
  border-left-color: var(--ds-color-primary-selected);
  color: var(--ds-color-primary-selected);
}

/* ---------- footer ---------- */
.app-footer {
  border-top: var(--ds-border-width-thin) solid var(--ds-color-surface-subtle);
  background-color: var(--ds-color-surface-overlay);
  font-size: var(--ds-font-size-body-14);
  line-height: var(--ds-line-height-body-14);
  color: var(--docs-color-text-secondary);
}

.app-footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--ds-space-sm) var(--ds-space-lg);
  max-width: var(--docs-content-max-width);
  margin: 0 auto;
  padding: var(--ds-space-lg) var(--ds-space-xl);
}

.app-footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--ds-space-sm) var(--ds-space-lg);
}

@media (max-width: 768px) {
  .rel {
    grid-template-columns: 1fr;
  }

  /* Contents become a drawer above the page */
  .training-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--ds-space-md);
  }

  .toc-panel {
    position: static;
    max-height: none;
    overflow: visible;
  }

  .toc-toggle {
    display: flex;
    justify-content: space-between;
    width: 100%;
    height: 40px; /* ds:intentional — touch target, Button.css size L */
  }

  .toc-toggle[aria-expanded="true"] .toc-toggle-chev {
    transform: rotate(180deg);
  }

  .toc-toggle[aria-expanded="false"] + .toc-body {
    display: none;
  }

  .toc-body {
    margin-top: var(--ds-space-md);
    padding: var(--ds-space-md);
    border-radius: var(--ds-radius-md);
    background-color: var(--ds-color-surface-overlay);
  }

  .training-layout.is-searching .toc {
    display: none;
  }

  .training-layout .training-search {
    margin-bottom: var(--ds-space-md);
  }

  a.relbtn[data-testid="rel-next"] {
    text-align: left;
  }
}

@media (max-width: 479px) {
  .app-header {
    padding: 0 var(--ds-space-md);
  }

  .app-header .hint,
  .brand-divider,
  .brand-section {
    display: none;
  }

  main {
    padding: var(--ds-space-lg) var(--ds-space-md);
  }

  .breadcrumb {
    display: none;
  }

  .crumb-back {
    display: block;
  }

  .version-switch-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .app-footer-inner {
    padding: var(--ds-space-lg) var(--ds-space-md);
  }

  .doc {
    padding: var(--ds-space-lg) var(--ds-space-md);
  }

  a.card {
    padding: var(--ds-space-md);
  }

  /* Phone: three equal segments with short labels and a 40px touch target (Button.css size L height). */
  .release-tabs {
    width: 100%;
  }

  .release-tab {
    position: relative;
    flex: 1 1 0;
    justify-content: center;
    height: 40px; /* ds:intentional — touch target, Button.css size L */
    padding: 0 var(--ds-space-sm);
  }

  /* Full label stays in the DOM for assistive technology; the short one is visual only. */
  .release-tab-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .release-tab::after {
    content: attr(data-short);
    content: attr(data-short) / "";
  }
}
