.docs-page {
  max-width: 76rem;
}

/* Author display rules must not override hidden landing/results views. */
.docs-page [hidden] {
  display: none !important;
}

.docs-entry-list {
  display: grid;
  gap: 1rem;
  padding-left: 1.25rem;
}

.docs-entry-list p,
.docs-entry-list code {
  display: block;
  margin: 0.3rem 0 0;
}

/* Compact search: label above, input and button sharing a row that wraps on narrow screens. */
.docs-search {
  margin-top: 1rem;
}

.docs-search label {
  font-family: var(--ui-font);
  font-weight: 700;
}

.docs-search__row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.docs-search__row input {
  flex: 1 1 14rem;
  min-width: 0;
  min-height: 2.75rem;
  box-sizing: border-box;
}

.docs-search__row button {
  flex: 0 0 auto;
  width: auto;
  min-height: 2.75rem;
  min-width: 2.75rem;
}

.docs-intro__browse {
  margin-bottom: 0;
}

/* Standalone links (not inside a sentence) get full-size targets. */
.docs-intro__browse a,
.docs-intro__home a,
.docs-empty a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* Curated topics: guides with several entries span the row; single-guide topics pair up. */
.docs-topics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 20rem), 1fr));
  gap: 1rem;
}

.stack > .docs-topics > * + * {
  margin-top: 0;
}

.docs-topic {
  min-width: 0;
}

.docs-topic--wide {
  grid-column: 1 / -1;
}

.docs-topic h2 {
  margin-top: 0;
}

.docs-entry-list:has(> .docs-entry) {
  padding-left: 0;
  list-style: none;
  gap: 1.25rem;
}

.docs-entry {
  min-width: 0;
}

.docs-entry__title {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font-family: var(--body-font);
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration-color: var(--line);
  text-underline-offset: 0.2em;
}

.docs-entry__title:hover,
.docs-entry__title:focus-visible {
  text-decoration-color: currentColor;
  text-decoration-thickness: 2px;
}

.docs-entry-list .docs-entry__description {
  margin: 0;
  font-family: var(--body-font);
}

.docs-entry-list .docs-entry__path {
  margin-top: 0.25rem;
  color: var(--ink-soft);
  font-family: var(--code-font);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

/* Collection quick links read as an inline list with visual separators. */
.docs-quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.25rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--ui-font);
}

.docs-quick-links li:not(:last-child)::after {
  content: "·";
  margin-inline-start: 0.25rem;
  color: var(--ink-soft);
}

.docs-quick-links a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* Concept blurbs: three columns only where each column gets at least 18rem. */
.docs-transparency {
  container-type: inline-size;
}

.docs-transparency-grid {
  display: grid;
  gap: 1rem;
}

@container (min-width: 58rem) {
  .docs-transparency-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

.docs-transparency-grid h3 {
  margin: 0 0 0.35rem;
}

.docs-transparency-grid p {
  margin-top: 0;
}

/*
 * How it works: an ordered list read as text, drawn as boxes and arrows.
 * Vertical by default (the shared shell, narrow screens, zoom); a row only in a wide panel.
 */
.docs-flow {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 1rem 0;
  padding: 1rem;
  list-style: none;
  border: 1px solid var(--line);
  background: var(--panel);
  font-family: var(--ui-font);
}

.docs-flow__node {
  width: min(100%, 22rem);
  margin-inline: auto;
  box-sizing: border-box;
}

.docs-flow__node {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  padding: 0.75rem;
  border: 2px solid var(--line);
  background: var(--input-bg);
  color: var(--ink);
  text-align: center;
}

.docs-flow__node--source {
  border: 4px solid var(--ink);
}

.docs-flow__node strong {
  font-size: 1rem;
}

.docs-flow__node span {
  color: var(--ink-soft);
  font-family: var(--body-font);
  font-size: 0.875rem;
}

.docs-flow__node code {
  font-family: var(--code-font);
  font-size: 0.875rem;
}

.docs-flow__node--views strong + strong {
  margin-top: 0.25rem;
  padding-top: 0.45rem;
  border-top: 2px solid var(--line);
  align-self: stretch;
}

.docs-flow__key {
  width: 2rem;
  height: 2rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
}

/* Edges: an arrow (line and head) with its label beside it, so the two never touch. */
.docs-flow__edge {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
  min-height: 3.5rem;
  padding-inline-start: calc(50% - 0.4rem);
  color: var(--ink);
  font-family: var(--body-font);
  font-size: 0.875rem;
  font-style: italic;
}

.docs-flow__edge > span:last-child {
  align-self: center;
}

.docs-flow__arrow {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: none;
  width: 0.8rem;
  padding-block: 0.25rem;
}

.docs-flow__arrow::before {
  content: "";
  flex: 1;
  width: 2px;
  background: var(--ink);
}

.docs-flow__arrow::after {
  content: "";
  border: 0.4rem solid transparent;
  border-top: 0.55rem solid var(--ink);
  border-bottom-width: 0;
}

/* A row needs room for unbroken code paths and edge labels; the shared shell stays vertical. */
@container (min-width: 52rem) {
  .docs-flow {
    flex-direction: row;
    align-items: center;
  }

  .docs-flow__node,
  .docs-flow__edge {
    width: auto;
    margin-inline: 0;
  }

  .docs-flow__node {
    flex: 1 1 0;
    min-width: 0;
  }

  .docs-flow__edge {
    flex: 0 0 auto;
    flex-direction: column-reverse;
    align-items: stretch;
    gap: 0.35rem;
    min-height: 0;
    min-width: 4.5rem;
    padding: 0 0.25rem;
    text-align: center;
  }

  .docs-flow__arrow {
    flex-direction: row;
    width: auto;
    height: 0.8rem;
    padding: 0;
  }

  .docs-flow__arrow::before {
    width: auto;
    height: 2px;
  }

  .docs-flow__arrow::after {
    border: 0.4rem solid transparent;
    border-left: 0.55rem solid var(--ink);
    border-right-width: 0;
  }
}

.docs-source {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  flex-wrap: wrap;
}

.docs-source p {
  margin: 0;
}

.docs-content {
  overflow-wrap: anywhere;
}

.docs-content > :first-child {
  margin-top: 0;
}

.docs-content pre {
  overflow: auto;
  padding: 1rem;
  border: 1px solid var(--line);
  background: var(--panel);
}

.docs-content code {
  font-family: var(--code-font);
}

.docs-content blockquote {
  margin-left: 0;
  padding-left: 1rem;
  border-left: 3px solid var(--line);
}

/* Keep overflow local to the document's keyboard-accessible regions. */
.docs-page,
.docs-content {
  min-width: 0;
  max-width: 100%;
}

.docs-content :is(ol, ul) {
  padding-inline-start: 1.25rem;
}

.docs-content li > p { margin: 0.35rem 0; }
.docs-content li > :is(ol, ul) { margin-block: 0.35rem; }

.docs-content .docs-task-item { list-style: none; }
.docs-content .docs-task-label {
  display: inline;
  font: inherit;
  font-weight: inherit;
}
.docs-content .docs-task-label > input[type="checkbox"] {
  /* Keep the native disabled semantics without the browser's faint disabled paint. */
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-items: center;
  width: 1.125rem;
  height: 1.125rem;
  margin: 0 0.125rem 0 -1.25rem;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 0.125rem;
  background: var(--panel);
  vertical-align: -0.1em;
  opacity: 1;
}
.docs-content .docs-task-label > input[type="checkbox"]:checked {
  background: var(--ink);
}
.docs-content .docs-task-label > input[type="checkbox"]:checked::before {
  content: "";
  width: 0.75rem;
  height: 0.75rem;
  /* Page color stays opaque even in themes with transparent panels. */
  background: var(--page-bg);
  clip-path: polygon(14% 44%, 0 59%, 40% 100%, 100% 17%, 84% 0, 37% 69%);
}

@media (forced-colors: active) {
  .docs-content .docs-task-label > input[type="checkbox"] {
    forced-color-adjust: none;
    border-color: CanvasText;
    background: Canvas;
  }
  .docs-content .docs-task-label > input[type="checkbox"]:checked { background: CanvasText; }
  .docs-content .docs-task-label > input[type="checkbox"]:checked::before { background: Canvas; }
}

.docs-content .docs-list-scroll {
  max-width: 100%;
  overflow-x: auto;
  margin-block: 1rem;
}

.docs-content .docs-list-scroll > :is(ol, ul) { min-width: 28rem; }

.docs-content .docs-table-scroll {
  overflow-x: auto;
  max-width: 100%;
  margin: 1rem 0;
}

.docs-content table {
  border-collapse: collapse;
  width: 100%;
  min-width: 38rem;
}

.docs-content th,
.docs-content td {
  border: 1px solid var(--line);
  padding: 0.6rem;
  text-align: left;
  vertical-align: top;
  min-width: 8rem;
  overflow-wrap: normal;
  word-break: normal;
}

.docs-content .docs-align-left { text-align: left; }
.docs-content .docs-align-center { text-align: center; }
.docs-content .docs-align-right { text-align: right; }

.docs-content th {
  background: var(--panel);
}

.docs-content .docs-code {
  margin: 1rem 0;
  min-width: 0;
}

.docs-content figcaption {
  color: var(--ink-soft);
  font-family: var(--code-font);
  font-size: 0.85em;
}

.docs-content pre {
  max-width: 100%;
  white-space: pre;
  overflow-wrap: normal;
}

.docs-content pre code,
.docs-content table code {
  white-space: pre;
  overflow-wrap: normal;
}

.docs-content .docs-table-scroll:focus-visible,
.docs-content .docs-list-scroll:focus-visible,
.docs-content pre:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.docs-content .docs-metadata {
  margin-bottom: 1rem;
}

.docs-intro__home {
  margin-bottom: 0;
}

/* Active filters: removable chips, identified by text and the × rather than color. */
.docs-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  padding: 0;
  list-style: none;
  font-family: var(--ui-font);
}

.docs-chips a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

/* Scoped above themes' `:root[data-theme] a` link colors so chips keep the active pair. */
.docs-page .docs-chips a.docs-chip {
  gap: 0.4rem;
  padding: 0 0.75rem;
  border: 2px solid var(--active-line);
  border-radius: 1.4rem;
  background: var(--active-bg);
  color: var(--active-ink);
  overflow-wrap: anywhere;
}

/* Filters: link lists with counts; the current one is bold with a bar, not color alone. */
.docs-filters {
  margin: 0.75rem 0 1rem;
}

.docs-filters > summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  font-family: var(--ui-font);
  font-weight: 700;
  cursor: pointer;
}

.docs-filters__groups {
  display: grid;
  gap: 1rem;
}

.docs-filters__groups h3 {
  margin: 0 0 0.25rem;
  font-family: var(--ui-font);
  font-size: 1rem;
}

.docs-filter-list,
.docs-filter-tree {
  margin: 0;
  padding: 0;
  list-style: none;
  font-family: var(--ui-font);
}

.docs-filter-tree .docs-filter-tree {
  padding-inline-start: 1rem;
}

/* Flex summaries lose the native marker; draw one so open/closed state stays visible. */
.docs-filters > summary::before,
.docs-filter-tree summary::before {
  content: "▸";
  content: "▸" / "";
  display: inline-block;
  width: 1em;
  margin-inline-end: 0.35rem;
}

.docs-filters[open] > summary::before,
.docs-filter-tree details[open] > summary::before {
  content: "▾";
  content: "▾" / "";
}

.docs-filter-tree summary {
  display: flex;
  align-items: center;
  gap: 0 0.5rem;
  padding-inline: 0.5rem;
  min-height: 2.75rem;
  cursor: pointer;
}

/* Filter links: name, then count; markup stays minimal because every browse page repeats it. */
.docs-filter-list a,
.docs-filter-tree a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 2.75rem;
  padding-inline: 0.5rem;
  border-inline-start: 4px solid transparent;
  overflow-wrap: anywhere;
}

.docs-page .docs-filter-list a[aria-current],
.docs-page .docs-filter-tree a[aria-current] {
  border-inline-start-color: var(--active-line);
  background: var(--active-bg);
  color: var(--active-ink);
  font-weight: 700;
}

.docs-filter-list a > span + span,
.docs-filter-tree a > span + span,
.docs-filter-tree summary > span {
  font-variant-numeric: tabular-nums;
}

.docs-filter-tree summary > span {
  margin-inline-start: auto;
}

/* Result rows: one compact block per document, separated by a divider rather than boxes. */
.docs-results {
  margin: 0;
  padding: 0;
  list-style: none;
}

.docs-result {
  padding-block: 0.75rem;
  border-top: 1px solid var(--line);
  min-width: 0;
}

.docs-result:last-child {
  border-bottom: 1px solid var(--line);
}

.docs-result__title {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  font-family: var(--body-font);
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.docs-result__summary,
.docs-result__meta {
  margin: 0.1rem 0 0;
}

.docs-result__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
}

.docs-result__path {
  color: var(--ink-soft);
  font-family: var(--code-font);
  font-size: 0.875rem;
  overflow-wrap: anywhere;
}

.docs-badge {
  padding: 0.05rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 0.25rem;
  color: var(--ink);
  font-family: var(--ui-font);
  font-size: 0.875rem;
}

.docs-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  margin-top: 1rem;
  font-family: var(--ui-font);
}

.docs-pages a {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
}

.docs-notice {
  padding: 0.75rem;
  border: 2px solid var(--ink);
  background: var(--input-bg);
}

.docs-empty p {
  margin: 0.5rem 0;
}

/*
 * Keyboard focus: a thick ring in the theme's ink, offset so it never hides in a border.
 * !important outranks themes' thin retro rings (Word97, Midnight: 1px dotted) on this page only.
 */
.docs-page :is(a, button, input, summary):focus-visible,
.docs-page [tabindex="-1"]:focus {
  outline: 3px solid var(--ink) !important;
  outline-offset: 2px !important;
}

.docs-page [tabindex="-1"]:focus:not(:focus-visible) {
  outline: none !important;
}

@media (prefers-contrast: more) {
  .docs-entry__title,
  .docs-result__title {
    text-decoration-color: currentColor;
    text-decoration-thickness: 2px;
  }

  .docs-entry-list .docs-entry__path,
  .docs-result__path,
  .docs-flow__node span,
  .docs-quick-links li:not(:last-child)::after {
    color: var(--ink);
  }

  .docs-result,
  .docs-result:last-child,
  .docs-flow,
  .docs-flow__node,
  .docs-badge {
    border-color: var(--ink);
  }
}
