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

  * {
    margin: 0;
  }

  html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    scroll-behavior: smooth;
    scroll-padding-top: calc(var(--header-h) + var(--space-md));
    -moz-tab-size: 2;
    tab-size: 2;
    background-color: var(--bg-base);
  }

  body {
    min-height: 100svh;
    background-color: transparent;
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-regular);
    line-height: var(--leading-relaxed);
    font-synthesis-weight: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-variant-numeric: proportional-nums;
  }

  html::before,
  body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
  }

  html::before {
    z-index: -2;
    background-image: var(--bg-wash);
  }

  body::before {
    z-index: -1;
    background-image: radial-gradient(var(--grid-dot) 1px, transparent 1px);
    background-size: var(--bg-grid) var(--bg-grid);
    background-repeat: repeat;
    -webkit-mask-image: var(--bg-grid-mask);
    mask-image: var(--bg-grid-mask);
  }

  @media print {
    html::before,
    body::before { display: none; }
    html { background-color: #ffffff; }
  }

  h1, h2, h3, h4, h5, h6 {
    color: var(--ink);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-heading);
    line-height: var(--leading-snug);
    text-wrap: balance;
  }

  h1 {
    font-size: var(--text-4xl);
    font-weight: var(--weight-bold);
    letter-spacing: var(--tracking-display);
    line-height: var(--leading-tight);
  }

  h2 {
    font-size: var(--text-2xl);
    letter-spacing: var(--tracking-display);
  }

  h3 { font-size: var(--text-xl); }
  h4 { font-size: var(--text-lg); }
  h5 { font-size: var(--text-md); }

  h6 {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    letter-spacing: var(--tracking-label);
    text-transform: uppercase;
  }

  p, li, dd, dt, blockquote, figcaption {
    text-wrap: pretty;
  }

  p {
    max-width: var(--measure);
  }

  strong, b { font-weight: var(--weight-semibold); }

  small {
    font-size: var(--text-sm);
    color: var(--ink-muted);
  }

  ul, ol {
    padding-left: 1.25em;
  }

  li::marker {
    color: var(--ink-faint);
  }

  blockquote {
    border-left: 2px solid var(--line-strong);
    padding-left: var(--space-md);
    color: var(--ink);
  }

  hr {
    height: 1px;
    border: 0;
    background-color: var(--line);
  }

  abbr[title] {
    text-decoration: underline dotted;
    text-underline-offset: 0.2em;
    cursor: help;
  }

  a {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    text-decoration-color: color-mix(in oklab, var(--accent) 40%, transparent);
    transition: color var(--dur-fast) var(--ease-out),
                text-decoration-color var(--dur-fast) var(--ease-out);
  }

  a:hover {
    color: var(--accent-hover);
    text-decoration-color: currentColor;
  }

  a:active {
    color: var(--accent-active);
  }

  code, kbd, samp, pre {
    font-family: var(--font-mono);
    font-size: 0.9em;
    font-variant-ligatures: none;
  }

  :not(pre) > code {
    padding: 0.15em 0.4em;
    border-radius: var(--radius-inline);
    background-color: var(--paper-sunken);
    color: var(--ink);
    white-space: nowrap;
  }

  pre {
    overflow-x: auto;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--line);
    border-radius: var(--radius-surface);
    background-color: var(--paper-sunken);
    line-height: var(--leading-normal);
  }

  pre code {
    padding: 0;
    background: none;
    white-space: pre;
  }

  kbd {
    display: inline-block;
    min-width: 1.9em;
    padding: 0.15em 0.45em;
    border: 1px solid var(--line-strong);
    border-bottom-width: 2px;
    border-radius: var(--radius-inline);
    background-color: var(--surface);
    color: var(--ink);
    font-size: 0.8em;
    line-height: 1.5;
    text-align: center;
  }

  img, picture, svg, video, canvas, iframe {
    display: block;
    max-width: 100%;
  }

  img, video {
    height: auto;
  }

  img:not([width]):not([height]) {
    aspect-ratio: 16 / 10;
    object-fit: cover;
  }

  svg {
    fill: currentColor;
  }

  input, button, textarea, select {
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
  }

  textarea {
    resize: vertical;
    field-sizing: content;
  }

  button {
    cursor: pointer;
  }

  :disabled {
    cursor: not-allowed;
  }

  ::placeholder {
    color: var(--ink-faint);
    opacity: 1;
  }

  fieldset {
    padding: 0;
    border: 0;
  }

  legend {
    padding: 0;
  }

  table {
    width: 100%;
    border-collapse: collapse;
    font-variant-numeric: tabular-nums;
  }

  th {
    color: var(--ink);
    font-weight: var(--weight-semibold);
    text-align: left;
  }

  th, td {
    padding: var(--space-xs) var(--space-sm);
    border-bottom: 1px solid var(--line);
    vertical-align: top;
  }

  caption {
    margin-bottom: var(--space-xs);
    color: var(--ink-muted);
    font-size: var(--text-sm);
    text-align: left;
  }

  :focus-visible {
    outline: var(--focus-width) solid var(--accent);
    outline-offset: var(--focus-offset);
    border-radius: var(--radius-inline);
  }

  ::-moz-focus-inner {
    border: 0;
  }

  ::selection {
    background-color: var(--selection-bg);
    color: var(--selection-ink);
  }

  :target {
    scroll-margin-top: calc(var(--header-h) + var(--space-md));
  }

  .skip-link {
    position: fixed;
    top: var(--space-2xs);
    left: var(--space-2xs);
    z-index: var(--z-skip);
    padding: var(--space-2xs) var(--space-sm);
    border-radius: var(--radius-control);
    background-color: var(--accent);
    color: var(--accent-contrast);
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    text-decoration: none;
    transform: translateY(calc(-100% - var(--space-md)));
    transition: transform var(--dur-base) var(--ease-out);
  }

  .skip-link:focus-visible {
    transform: translateY(0);
    box-shadow: var(--shadow-md);
    outline-offset: 3px;
  }

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

    *,
    *::before,
    *::after {
      animation-duration: 0.01ms !important;
      animation-iteration-count: 1 !important;
      transition-duration: 0.01ms !important;
      scroll-behavior: auto !important;
    }
  }
}
