@layer components {
  .docs {
    background: var(--surface);
  }

  .docs__bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    height: var(--header-height);
    padding-inline: var(--space-lg);
    background: var(--navy);
  }

  .docs__brand {
    font-size: var(--text-md);
    font-weight: var(--weight-display);
    color: var(--on-navy);
  }

  .docs__brand-dim {
    margin-left: var(--space-xs);
    font-weight: var(--weight-text);
    color: var(--on-navy-dim);
  }

  .docs__body {
    display: grid;
    grid-template-columns: 16rem minmax(0, 1fr);
    gap: var(--space-xl);
    max-width: 90rem;
    margin-inline: auto;
    padding: var(--space-xl) var(--space-lg) 6rem;
  }

  .docs__nav {
    position: sticky;
    top: calc(var(--header-height) + var(--space-xl));
    align-self: start;
    max-height: calc(100vh - var(--header-height) - 2 * var(--space-xl));
    overflow-y: auto;
  }

  .docs__pages {
    display: grid;
    gap: var(--space-xs);
  }

  .docs__page {
    display: block;
    padding: var(--space-xs) var(--space-sm);
    font-weight: var(--weight-emphasis);
    color: var(--ink-body);
    border-radius: var(--radius-sm);

    &:hover {
      color: var(--navy);
      background: var(--sheet-head);
    }

    &[aria-current="page"] {
      color: var(--navy);
      background: var(--sheet-head);
    }
  }

  .docs__sections {
    display: grid;
    gap: 2px;
    margin: var(--space-xs) 0 var(--space-sm) var(--space-md);
    padding-left: var(--space-sm);
    border-left: 1px solid var(--hairline);
  }

  .docs__section {
    display: block;
    padding: 2px var(--space-sm);
    font-size: var(--text-sm);
    color: var(--ink-muted);

    &:hover {
      color: var(--navy);
    }
  }

  .docs__title {
    font-size: var(--text-title);
    font-weight: var(--weight-display);
    letter-spacing: var(--tracking-display);
    color: var(--ink);
  }

  .prose {
    max-width: 52rem;
    line-height: 1.6;
    color: var(--ink-body);

    & > * + * {
      margin-top: var(--space-md);
    }

    & h2 {
      margin-top: var(--space-xl);
      padding-bottom: var(--space-xs);
      font-size: var(--text-heading);
      font-weight: var(--weight-display);
      color: var(--ink);
      border-bottom: 1px solid var(--hairline);
      scroll-margin-top: calc(var(--header-height) + var(--space-md));
    }

    & h3 {
      margin-top: var(--space-lg);
      font-size: var(--text-md);
      font-weight: var(--weight-display);
      color: var(--ink);
      scroll-margin-top: calc(var(--header-height) + var(--space-md));
    }

    & .anchor {
      display: none;
    }

    & a {
      color: var(--blue);
      text-decoration: underline;
      text-underline-offset: 3px;
    }

    & strong {
      font-weight: var(--weight-display);
      color: var(--ink);
    }

    & ul,
    & ol {
      display: grid;
      gap: var(--space-xs);
      padding-left: var(--space-lg);
    }

    & ul {
      list-style: disc;
    }

    & ol {
      list-style: decimal;
    }

    & li > ul,
    & li > ol {
      margin-top: var(--space-xs);
    }

    & code {
      padding: 1px 4px;
      font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
      font-size: 0.875em;
      background: var(--sheet-head);
      border-radius: 4px;
    }

    & pre {
      padding: var(--space-md);
      overflow-x: auto;
      font-size: var(--text-sm);
      line-height: 1.5;
      background: var(--sheet-head);
      border: 1px solid var(--hairline);
      border-radius: var(--radius-md);

      & code {
        padding: 0;
        background: none;
      }
    }

    & pre.mermaid {
      text-align: center;
      background: var(--surface);
    }

    & table {
      width: 100%;
      font-size: var(--text-sm);
      border-collapse: collapse;
    }

    & th,
    & td {
      padding: var(--space-sm);
      text-align: left;
      vertical-align: top;
      border-bottom: 1px solid var(--hairline);
    }

    & th {
      font-size: var(--text-label);
      font-weight: var(--weight-emphasis);
      letter-spacing: var(--tracking-label);
      text-transform: uppercase;
      color: var(--ink-muted);
      background: var(--sheet-head);
    }

    & blockquote {
      padding: var(--space-sm) var(--space-md);
      color: var(--ink-body);
      background: var(--sheet-head);
      border-left: 3px solid var(--periwinkle);
      border-radius: 0 var(--radius-md) var(--radius-md) 0;
    }
  }

  .prose__status {
    font-family: var(--font-sans);
    font-size: var(--text-label);
    font-weight: var(--weight-emphasis);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
  }

  .prose .prose__status--built {
    color: var(--navy);
    background: var(--periwinkle-soft);
  }

  .prose .prose__status--planned {
    color: var(--ink-muted);
    background: var(--surface);
    border: 1px dashed var(--border);
  }

  @media (max-width: 720px) {
    .docs__body {
      grid-template-columns: 1fr;
      padding-inline: var(--space-md);
    }

    .docs__nav {
      position: static;
      max-height: none;
    }
  }
}
