@layer base {
  *,
  *::before,
  *::after {
    box-sizing: border-box;
  }

  html {
    /* Native anchor scrolling preserves URL/history and the measured header gap. */
    scroll-behavior: smooth;
    scroll-padding-top: var(--header-offset);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
  }

  body {
    margin: 0;
    background: var(--color-surface);
    color: var(--color-text);
    font: 400 var(--text-base) / var(--line-body) var(--font-body);
    overflow-wrap: anywhere;
  }

  :where(h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote) {
    margin: 0;
  }

  :where(h1, h2, h3, h4) {
    color: var(--color-primary);
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: var(--line-heading);
    letter-spacing: var(--tracking-heading);
    text-wrap: balance;
  }

  :where(ul, ol)[role="list"] {
    padding: 0;
    list-style: none;
  }

  :where(img, svg) {
    display: block;
    max-width: 100%;
  }

  img {
    height: auto;
  }

  :where(a) {
    color: inherit;
    text-underline-offset: 0.2em;
  }

  :where(button, input, select, textarea) {
    font: inherit;
  }

  :where(code, pre, kbd, samp) {
    font-family: var(--font-mono);
  }

  :where(button, select) {
    cursor: pointer;
  }

  :where(button:disabled, input:disabled, select:disabled, textarea:disabled) {
    cursor: not-allowed;
  }

  :where(address) {
    font-style: normal;
  }

  :where(:focus-visible) {
    outline: 2px solid var(--color-focus);
    outline-offset: 4px;
  }

  /* The semantic hidden attribute must win over component display declarations. */
  [hidden] {
    display: none !important;
  }

  ::selection {
    background: var(--color-accent-soft);
    color: var(--color-primary);
  }

  @media (prefers-reduced-motion: reduce) {
    html {
      scroll-behavior: auto;
    }
  }
}
