/* ==========================================================================
   DOCS PAGE
   Documentation page specific styles.
   ========================================================================== */

/* -------------------------------------------------------------------------
   Layout
   The sidebar and the article sit directly on the page, separated by a
   line; "On this page" joins them on wide screens.
   ------------------------------------------------------------------------- */
.docs-layout {
  flex: 1 0 auto;
  background: var(--color-bg);
}

/* -------------------------------------------------------------------------
   Ownership colours
   Kept faint: a dot beside each collection and page header, and the tint
   of the page being read. Engine green, review application navy and the
   shared overview purple, as in the system diagrams.
   ------------------------------------------------------------------------- */
[data-owner] {
  --docs-owner: var(--color-primary);
  --docs-owner-fg: var(--color-primary);
  --docs-owner-subtle: var(--color-primary-subtle);
}

[data-owner="engine"] {
  --docs-owner: var(--color-success);
  --docs-owner-fg: var(--color-success-fg);
  --docs-owner-subtle: var(--color-success-subtle);
}

[data-owner="shared"] {
  --docs-owner: var(--color-docs-shared);
  --docs-owner-fg: var(--color-docs-shared);
  --docs-owner-subtle: var(--color-docs-shared-subtle);
}

.docs-owner-dot {
  display: inline-block;
  flex: none;
  width: 0.5rem;
  height: 0.5rem;
  margin-right: 0.5em;
  border-radius: var(--radius-full);
  background: var(--docs-owner);
  vertical-align: 0.05em;
}

/* -------------------------------------------------------------------------
   Sidebar Navigation
   One treatment per level: muted capitals for collections, plain rows for
   pages, and colour only for the page being read.
   ------------------------------------------------------------------------- */
.docs-sidebar {
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}

.docs-sidebar-filter {
  position: relative;
  flex: none;
  margin: 0 var(--space-1) var(--space-4) 0;
}

.docs-sidebar-filter input {
  padding-right: var(--space-8);
  font-size: var(--text-sm);
}

.docs-sidebar-filter kbd {
  position: absolute;
  top: 50%;
  right: var(--space-2);
  padding: 0 0.35rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
  line-height: 1.4;
  pointer-events: none;
  transform: translateY(-50%);
}

.docs-sidebar-filter input:focus + kbd,
.docs-sidebar-filter input:not(:placeholder-shown) + kbd {
  display: none;
}

#docs-sections {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
  padding-right: var(--space-1);
}

#docs-sections::-webkit-scrollbar {
  width: 4px;
}

#docs-sections::-webkit-scrollbar-track {
  background: transparent;
}

#docs-sections::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

#docs-sections::-webkit-scrollbar-thumb:hover {
  background: var(--color-fg-subtle);
}

.docs-collection + .docs-collection {
  margin-top: var(--space-6);
}

/* "For users", "For developers": name the collections below them. */
.docs-audience-heading {
  margin: var(--space-8) var(--space-2) var(--space-3);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
  color: var(--color-fg);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.docs-audience-heading:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.docs-collection-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-1);
  padding: 0 var(--space-2);
}

.docs-collection-label {
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.docs-collection-version {
  flex: none;
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.docs-section-header {
  display: flex;
  align-items: flex-start;
  border-radius: var(--radius-sm);
}

/* Long titles wrap under themselves instead of being cut off. */
.docs-sidebar .docs-nav-link,
.docs-sidebar .docs-section-link {
  display: flex;
  gap: 0.4em;
  min-width: 0;
  padding: 0.375rem var(--space-2);
  color: var(--color-fg);
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  text-decoration: none;
}

.docs-sidebar .docs-section-link {
  flex: 1 1 auto;
}

.docs-nav-number {
  flex: none;
  color: var(--color-fg-muted);
  font-variant-numeric: tabular-nums;
}

.docs-nav-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.docs-section-header:hover,
.docs-subitems .docs-nav-link:hover {
  background: var(--color-bg-subtle);
}

/* The section that holds the page being read. */
.docs-section-header.is-current .docs-section-link {
  font-weight: var(--font-semibold);
}

/* The page being read, tinted with its owner's colour. */
.docs-section-header.active,
.docs-sidebar .docs-subitems .docs-nav-link.active {
  background: var(--docs-owner-subtle);
}

.docs-sidebar .docs-nav-link.active,
.docs-sidebar .docs-nav-link.active .docs-nav-number {
  color: var(--docs-owner-fg);
  font-weight: var(--font-semibold);
}

.docs-toggle {
  flex: none;
  padding: 0.375rem var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-fg-muted);
  font-size: var(--text-xs);
  line-height: calc(var(--text-sm) * var(--leading-snug));
}

.docs-toggle:hover {
  color: var(--color-fg);
}

.docs-toggle i {
  transition: transform var(--transition-fast);
}

.docs-toggle[aria-expanded="true"] i {
  transform: rotate(90deg);
}

.docs-subitems {
  padding: 0.125rem 0 var(--space-2) var(--space-4);
}

.docs-subitems .docs-nav-link {
  border-radius: var(--radius-sm);
}

.docs-filter-empty {
  margin: var(--space-2);
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
}

.docs-sidebar-footer {
  flex: none;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.docs-sidebar-action {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  padding: 0.375rem var(--space-2);
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
  text-align: left;
  text-decoration: none;
}

.docs-sidebar-action:hover {
  background: var(--color-bg-subtle);
  color: var(--color-fg);
}

@media (prefers-reduced-motion: reduce) {
  .docs-toggle i {
    transition: none;
  }
}

/* -------------------------------------------------------------------------
   Content Area
   ------------------------------------------------------------------------- */
.docs-content {
  min-width: 0;
  padding: var(--space-8) clamp(var(--space-4), 4vw, var(--space-12)) var(--space-12);
}

/* Wide enough for the 960px diagrams; running text keeps a narrower
   measure (see below). */
.docs-article {
  width: 100%;
  max-width: 1020px;
  min-width: 0;
  margin-inline: auto;
}

.docs-page-header {
  margin-bottom: var(--space-6);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.docs-page-eyebrow {
  display: flex;
  align-items: center;
  gap: 0.25em;
  margin: 0 0 var(--space-2);
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.docs-page-header h1 {
  margin-bottom: var(--space-3);
}

.docs-page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
}

.docs-page-action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0;
  border: 0;
  background: none;
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
  text-decoration: none;
}

.docs-page-action:hover,
.docs-page-action:focus-visible {
  color: var(--color-fg);
  text-decoration: underline;
}

/* -------------------------------------------------------------------------
   On this page
   A collapsed list above the article on narrow screens; a sticky column
   beside it on wide ones. docs.js fills both and marks the current section.
   ------------------------------------------------------------------------- */
.docs-toc-list {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
}

.docs-toc-list a {
  display: block;
  padding: var(--space-1) 0;
  color: var(--color-fg-muted);
  text-decoration: none;
}

.docs-toc-list a:hover {
  color: var(--color-fg);
}

.docs-toc-list a.active {
  color: var(--color-primary);
  font-weight: var(--font-semibold);
}

.docs-toc-item--h3 a {
  padding-left: var(--space-4);
}

.docs-toc--inline {
  margin-bottom: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.docs-toc--inline > summary {
  padding: var(--space-2) var(--space-3);
  color: var(--color-fg);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
  cursor: pointer;
}

.docs-toc--inline .docs-toc-list {
  padding: 0 var(--space-3) var(--space-2);
}

.docs-toc--rail {
  display: none;
}

.docs-toc-title {
  margin-bottom: var(--space-2);
  color: var(--color-fg);
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

@media (min-width: 1400px) {
  .docs-content {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-10);
  }

  .docs-article {
    flex: 1 1 auto;
    margin-inline: 0;
  }

  .docs-toc--inline {
    display: none;
  }

  .docs-toc--rail {
    position: sticky;
    top: calc(var(--navbar-height) + var(--space-8));
    display: block;
    flex: 0 0 220px;
    max-height: calc(100vh - var(--navbar-height) - var(--space-12));
    overflow-y: auto;
  }
}

.docs-content h1,
.docs-content h2,
.docs-content h3 {
  scroll-margin-top: calc(var(--navbar-height) + var(--space-4));
}

.docs-content img,
.docs-content .docs-diagram {
  display: block;
  max-width: 100%;
  height: auto;
  /* Left-aligned so figures share the text's left edge. */
  margin: var(--space-4) 0;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

/* Inlined SVG diagrams (see 2.8 Documentation portal), so their
   links work. The wrapper takes the image frame; the SVG scales inside it. */
.docs-content .docs-diagram {
  width: fit-content;
  overflow: hidden;
}

.docs-content .docs-diagram svg {
  display: block;
  max-width: 100%;
  height: auto;
}

.docs-content .docs-diagram a:hover text,
.docs-content .docs-diagram a:focus-visible text {
  text-decoration: underline;
}

.docs-content p {
  margin-bottom: 1.25rem;
  line-height: var(--leading-relaxed, 1.6);
}

.docs-content p:last-child {
  margin-bottom: 0;
}

/* Keep running text to roughly 100 characters per line (76ch with the
   16px system font; the actual count varies by text). Diagrams (960px),
   tables and code keep the full article width, so paragraphs that wrap an
   image are left uncapped. */
#docs-content-html > p:not(:has(img, .docs-diagram)),
#docs-content-html > ul,
#docs-content-html > ol,
#docs-content-html > .github-alert {
  max-width: 76ch;
}

/* -------------------------------------------------------------------------
   Cards
   A list of "icon **Tag** · [Title](page) — sentence" items, rendered by
   _render_card_lists in docs.py. Two columns, one on narrow screens.
   ------------------------------------------------------------------------- */
#docs-content-html > .docs-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(18rem, 1fr));
  gap: var(--space-3);
  margin: var(--space-4) 0 var(--space-8);
}

.docs-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-fg);
  text-decoration: none;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.docs-card:hover,
.docs-card:focus-visible {
  border-color: var(--color-border-emphasis);
  background: var(--color-bg-subtle);
  color: var(--color-fg);
  text-decoration: none;
}

.docs-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.docs-card-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-subtle);
  color: var(--color-fg-muted);
}

.docs-card-tag {
  color: var(--color-fg-muted);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.docs-card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  line-height: var(--leading-snug);
}

.docs-card-text {
  color: var(--color-fg-muted);
  line-height: var(--leading-normal);
}

.docs-card-more {
  margin-top: auto;
  padding-top: var(--space-3);
  color: var(--color-fg-muted);
  font-size: var(--text-sm);
}

.docs-card-more .fa-arrow-right {
  margin-left: var(--space-1);
  transition: transform var(--transition-fast);
}

.docs-card:hover .docs-card-more,
.docs-card:focus-visible .docs-card-more {
  color: var(--color-fg);
}

.docs-card:hover .fa-arrow-right,
.docs-card:focus-visible .fa-arrow-right {
  transform: translateX(3px);
}

@media (prefers-reduced-motion: reduce) {
  .docs-card,
  .docs-card-more .fa-arrow-right {
    transition: none;
  }
}

/* Separate explanations while keeping nested lists more compact. */
#docs-content-html li + li {
  margin-top: 0.75em;
}

#docs-content-html li li + li {
  margin-top: 0.5em;
}

.docs-content pre {
  background: var(--color-bg-subtle);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  overflow: auto;
  font-size: var(--text-sm);
}

.docs-content table {
  display: block;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  /* Columns get a <colgroup> sized to their content server-side (see
     _add_table_colgroups in docs.py); fixed layout makes that sizing
     authoritative instead of letting one long prose column get squeezed
     down to a sliver by the browser's automatic column sizing. */
  table-layout: fixed;
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
}

.docs-content th,
.docs-content td {
  border: var(--border-width) solid var(--color-border);
  padding: var(--space-2) var(--space-3);
  overflow-wrap: break-word;
}

.docs-content thead th {
  background-color: var(--color-bg-subtle);
  font-weight: var(--font-semibold);
}

.docs-content tbody tr:nth-child(odd) {
  background-color: var(--color-bg);
}

.docs-content tbody tr:nth-child(even) {
  background-color: var(--color-bg-subtle);
}

/* -------------------------------------------------------------------------
   PDF Export Dialog
   ------------------------------------------------------------------------- */
.docs-pdf-modal .modal-content {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.docs-pdf-modal .modal-header {
  padding: var(--space-5) var(--space-5) var(--space-2);
  border-bottom: 0;
}

.docs-pdf-modal .modal-title {
  margin: 0;
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
}

.docs-pdf-modal .modal-body {
  padding: var(--space-2) var(--space-5);
}

.docs-pdf-modal .modal-footer {
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5) var(--space-5);
  border-top: 0;
}

.docs-pdf-modal .modal-footer > * {
  margin: 0;
}

.docs-pdf-cancel {
  color: var(--color-fg-muted);
  text-decoration: none;
}

.docs-pdf-cancel:hover {
  color: var(--color-fg);
}

.docs-pdf-scopes {
  display: grid;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  border: 0;
}

.docs-pdf-scope {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
}

.docs-pdf-scope:hover {
  background: var(--color-bg-subtle);
}

.docs-pdf-scope:has(input:checked) {
  border-color: var(--color-primary-border);
  background: var(--color-primary-subtle);
}

.docs-pdf-scope:has(input:disabled) {
  display: none;
}

.docs-pdf-scope .form-check-input {
  flex: none;
  margin: 0.2rem 0 0;
}

.docs-pdf-scope-title,
.docs-pdf-scope-detail {
  display: block;
  font-size: var(--text-sm);
}

.docs-pdf-scope-title {
  font-weight: var(--font-semibold);
}

.docs-pdf-scope-detail {
  color: var(--color-fg-muted);
}

.docs-pdf-sections {
  margin-top: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.docs-pdf-group {
  margin: 0;
  padding: 0;
  border: 0;
}

.docs-pdf-group + .docs-pdf-group {
  margin-top: var(--space-4);
}

.docs-pdf-group legend {
  float: none;
  width: auto;
  margin-bottom: var(--space-1);
  font-size: var(--text-xs);
}

.docs-pdf-section {
  display: flex;
  align-items: baseline;
  gap: 0.4em;
  padding: var(--space-1) 0;
  font-size: var(--text-sm);
  line-height: var(--leading-snug);
  cursor: pointer;
}

.docs-pdf-section .form-check-input {
  flex: none;
  margin: 0 0.35em 0 0;
  align-self: center;
}

.docs-pdf-error {
  margin: var(--space-2) 0 0;
  color: var(--color-danger);
  font-size: var(--text-sm);
}

/* -------------------------------------------------------------------------
   Prev/Next Navigation Buttons
   ------------------------------------------------------------------------- */
.docs-nav {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-10);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border);
}

.docs-nav-btn {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  background: var(--color-bg);
  padding: var(--space-3) var(--space-4);
  text-decoration: none;
  transition: background-color var(--transition-fast);
}

.docs-nav-btn:hover {
  background: var(--color-bg-subtle);
  text-decoration: none;
}

.docs-nav-btn .nav-label,
.docs-nav-btn .nav-title {
  display: block;
}

.docs-nav-btn .nav-label {
  font-weight: var(--font-bold);
  font-size: var(--text-base);
}

.docs-nav-btn .nav-title {
  font-size: var(--text-sm);
  color: var(--color-fg-muted);
}

/* -------------------------------------------------------------------------
   Dynamic Statistics Styling
   ------------------------------------------------------------------------- */
.dynamic-stat {
  font-weight: var(--font-semibold);
  color: var(--color-primary);
  background: var(--color-bg-subtle);
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.dynamic-stat.stat-unavailable {
  color: var(--color-fg-muted);
  font-style: italic;
}

/* Tooltip for dynamic stats */
.dynamic-stat[title] {
  cursor: help;
  border-bottom: 1px dotted var(--color-border);
}

/* -------------------------------------------------------------------------
   Mermaid Diagrams
   ------------------------------------------------------------------------- */
.mermaid {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  margin: var(--space-4) 0;
  padding: var(--space-4);
  background: var(--color-bg);
  border-radius: var(--radius-md);
  border: var(--border-width) solid var(--color-border);
  overflow-x: auto;
}

.mermaid svg {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: auto;
}

/* Center mermaid diagrams */
.docs-content .mermaid {
  display: flex;
  justify-content: center;
}

/* Apply rounded corners to Mermaid diagram elements */
.mermaid .node rect,
.mermaid .node polygon,
.mermaid .cluster rect {
  rx: var(--radius-sm) !important;
  ry: var(--radius-sm) !important;
}

.mermaid .edgeLabel rect {
  rx: var(--radius-sm) !important;
  ry: var(--radius-sm) !important;
}

/* -------------------------------------------------------------------------
   GitHub-style Alerts
   Styled blockquote alerts like [!NOTE], [!IMPORTANT], etc.
   ------------------------------------------------------------------------- */
.github-alert {
  margin: var(--space-4) 0;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.github-alert .alert-title {
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.github-alert .alert-title i {
  font-size: var(--text-base);
}

.github-alert .alert-content {
  font-size: var(--text-sm);
}

.github-alert .alert-content p {
  margin: 0;
}

.github-alert .alert-content p+p {
  margin-top: var(--space-2);
}

/* Note - Blue/Info */
.github-alert.alert-note {
  background-color: var(--color-primary-subtle);
  border-color: var(--color-primary-border);
}

.github-alert.alert-note .alert-title {
  color: var(--color-primary);
}

/* Tip - Green */
.github-alert.alert-tip {
  background-color: var(--color-success-subtle);
  border-color: var(--color-success-border);
}

.github-alert.alert-tip .alert-title {
  color: var(--color-success);
}

/* Important - Red (matches app danger color) */
.github-alert.alert-important {
  background-color: var(--color-danger-subtle);
  border-color: var(--color-danger-border);
}

.github-alert.alert-important .alert-title {
  color: var(--color-danger);
}

/* Warning - Yellow/Orange */
.github-alert.alert-warning {
  background-color: var(--color-warning-subtle);
  border-color: var(--color-warning-border);
}

.github-alert.alert-warning .alert-title {
  color: var(--color-warning);
}

/* Caution - Red */
.github-alert.alert-caution {
  background-color: var(--color-danger-subtle);
  border-color: var(--color-danger-border);
}

.github-alert.alert-caution .alert-title {
  color: var(--color-danger);
}

/* -------------------------------------------------------------------------
   Canonical Palette Grid
   Beautiful grid of color cards for the brand palette
   ------------------------------------------------------------------------- */
.palette-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-6);
}

.palette-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
  height: 100%;
}

.palette-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
  border-color: var(--color-primary-border);
}

.palette-swatch {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
  border: 1px solid var(--color-border);
}

.palette-details {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.palette-name {
  font-weight: var(--font-bold);
  font-size: var(--text-base);
  color: var(--color-fg);
}

.palette-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.palette-hex, 
.palette-token {
  font-size: var(--text-xs);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  background: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  color: var(--color-fg-muted);
}

.palette-token {
  color: var(--color-primary);
  border-color: var(--color-primary-subtle);
}

.palette-desc {
  font-size: var(--text-xs);
  color: var(--color-fg-muted);
  line-height: var(--leading-normal);
  margin-top: var(--space-2);
}

/* -------------------------------------------------------------------------
   Mobile Responsiveness
   ------------------------------------------------------------------------- */

/* Floating toggle button for mobile */
.mobile-sidebar-toggle {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 1050;
  width: 56px;
  height: 56px;
  border-radius: 28px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  transition: transform var(--transition-fast), background-color var(--transition-fast), box-shadow var(--transition-fast);
  padding: 0;
  background-color: var(--color-primary) !important;
  color: var(--color-on-accent) !important;
  border: none !important;
  box-shadow: var(--shadow-lg) !important;
}

.mobile-sidebar-toggle:active {
  transform: scale(0.9);
}

.mobile-sidebar-toggle i {
  font-size: 1.25rem;
}

@media (max-width: 767.98px) {
  .docs-content {
    padding: var(--space-6) var(--space-4) var(--space-12);
  }

  .docs-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 300px;
    z-index: 1060;
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    border-radius: 0;
    border: none;
    border-right: 1px solid var(--color-border);
    overflow-y: auto;
    background: var(--color-bg);
    margin: 0 !important;
    display: flex !important;
    flex-direction: column;
    padding: 0 var(--space-3) var(--space-4);
  }

  /* The shadow only while open: closed, it would show at the screen edge. */
  .docs-sidebar.mobile-expanded {
    transform: translateX(0);
    box-shadow: var(--shadow-xl);
  }

  /* Overlay when sidebar is open */
  .docs-sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay);
    backdrop-filter: blur(2px);
    z-index: 1055;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base), visibility var(--transition-base);
  }

  .docs-sidebar-backdrop.active {
    opacity: 1;
    visibility: visible;
  }

  /* Sidebar header on mobile */
  .mobile-sidebar-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-4);
    border-bottom: 1px solid var(--color-border);
    margin: 0 calc(-1 * var(--space-3)) var(--space-4);
  }

  .mobile-sidebar-header h5 {
    margin: 0;
    font-weight: var(--font-bold);
  }
}

@media (min-width: 768px) {
  .docs-layout {
    display: flex;
    align-items: flex-start;
  }

  /* The sidebar stays in view; its page list scrolls on its own. */
  .docs-sidebar {
    position: sticky;
    top: var(--navbar-height);
    flex: 0 0 clamp(220px, 24vw, 290px);
    height: calc(100vh - var(--navbar-height));
    padding: var(--space-4) var(--space-3);
    border-right: 1px solid var(--color-border);
    overflow: hidden;
  }

  .docs-content {
    flex: 1 1 0;
  }

  .mobile-sidebar-toggle,
  .mobile-sidebar-header,
  .docs-sidebar-backdrop {
    display: none !important;
  }
}
