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

  body,
  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    margin: 0;
  }

  /* Break a word only when it genuinely can't fit (a long URL, a token).
     NOT `word-break: break-word` — that one is defined as `overflow-wrap:
     anywhere`, which also drops the element's min-content width to a single
     character. Every flex and grid item then "fits" at any width, so card
     columns and table cells crush into vertical letter stacks instead of
     pushing their container wide enough to scroll. */
  p,
  li,
  h1,
  h2,
  h3,
  h4 {
    overflow-wrap: break-word;
  }

  html,
  body {
    overflow-x: clip;
  }

  body {
    min-height: 100dvh;
    font-family: sans-serif;
    font-size: 100%;
    line-height: 1.5;
    text-rendering: optimizeSpeed;
  }

  img {
    display: block;
    max-inline-size: 100%;
  }

  input,
  button,
  textarea,
  select {
    font: inherit;
  }

  button {
    cursor: pointer;
  }

  summary {
    &::-webkit-details-marker {
      display: none;
    }

    &::marker {
      content: "";
    }
  }

  @media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }

    html {
      scroll-behavior: initial;
    }
  }

  /* The UA sheet gives <dialog> and [popover] their own `color: CanvasText`,
     so without this their text ignores our ink and renders black in dark mode. */
  [popover] {
    color: inherit;
  }

  dialog {
    border: 0;
    color: inherit;
    padding: 0;

    &:where(:focus-visible):focus,
    &:where(:focus-visible):active {
      outline: 0;
    }
  }

  /* Lock background scrolling while a modal dialog is open. */
  body:has(dialog:modal) {
    overflow: hidden;
  }
}
