/* Reset + element defaults + utilities. Logical properties only (never left/right). */
@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-block: var(--s-16); }
  img, svg, video, canvas { display: block; max-inline-size: 100%; }
  img, video { block-size: auto; }
  button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
  textarea { resize: vertical; }
  button { cursor: pointer; }
  ul[role="list"], ol[role="list"], ul.plain, ol.plain { list-style: none; padding: 0; }
  table { border-collapse: collapse; }
  summary { cursor: pointer; }
  dialog { margin: auto; } /* the universal margin reset would otherwise un-center modals */
  [hidden] { display: none !important; }
}

@layer base {
  html {
    font-family: var(--font-sans);
    font-size: 100%;
    line-height: var(--lh-base);
    background: var(--bg);
    color: var(--text);
    overflow-x: clip;
  }

  body {
    min-block-size: 100dvh;
    background: var(--bg);
    color: var(--text);
    font-size: var(--fs-base);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-wrap: break-word;
    overflow-x: clip;
  }

  h1, h2, h3, h4 { line-height: var(--lh-snug); font-weight: 750; letter-spacing: -0.02em; text-wrap: balance; }
  h1 { font-size: var(--fs-xl); line-height: var(--lh-tight); }
  h2 { font-size: var(--fs-lg); }
  h3 { font-size: var(--fs-md); }
  h4 { font-size: var(--fs-base); }
  p { text-wrap: pretty; }
  small { font-size: var(--fs-sm); }
  strong, b { font-weight: 700; }
  code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-2); padding: 0.1em 0.4em; border-radius: var(--r-xs); }

  a { color: var(--brand-text); text-decoration-thickness: 0.08em; text-underline-offset: 0.18em; }
  a:hover { text-decoration-thickness: 0.14em; }

  hr { border: 0; border-block-start: 1px solid var(--border); margin-block: var(--s-6); }

  ::selection { background: var(--brand); color: var(--on-brand); }

  :focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: var(--r-xs);
  }

  :focus:not(:focus-visible) { outline: none; }

  [tabindex="-1"]:focus { outline: none; }

  .icon {
    inline-size: 1.25rem;
    block-size: 1.25rem;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  .icon--sm { inline-size: 1rem; block-size: 1rem; }
  .icon--lg { inline-size: 1.5rem; block-size: 1.5rem; }
  .icon--xl { inline-size: 2rem; block-size: 2rem; }
  [dir="rtl"] .icon--dir { transform: scaleX(-1); }
  .icon--prev { transform: scaleX(-1); }
  [dir="rtl"] .icon--prev { transform: none; }

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

@layer utilities {
  .visually-hidden {
    position: absolute !important;
    inline-size: 1px; block-size: 1px;
    margin: -1px; padding: 0; border: 0;
    overflow: hidden; clip-path: inset(50%); white-space: nowrap;
  }
  .skip-link {
    position: fixed;
    inset-block-start: var(--s-2);
    inset-inline-start: var(--s-2);
    z-index: calc(var(--z-toast) + 1);
    padding: var(--s-3) var(--s-4);
    border-radius: var(--r-sm);
    background: var(--text);
    color: var(--bg);
    font-weight: 700;
    text-decoration: none;
    transform: translateY(-200%);
    transition: transform var(--dur) var(--ease);
  }
  .skip-link:focus { transform: none; }
  .stack, .stack-sm, .stack-lg { display: flex; flex-direction: column; gap: var(--s-4); } /* each class works alone; the gap is NOT inherited by nested stacks */
  .stack-sm { gap: var(--s-2); }
  .stack-lg { gap: var(--s-8); }
  .row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--row-gap, var(--s-3)); }
  .row-between { justify-content: space-between; }
  .grow { flex: 1 1 0; min-inline-size: 0; }
  .text-muted { color: var(--text-muted); }
  .text-center { text-align: center; }
  .text-start { text-align: start; }
  .num { font-variant-numeric: tabular-nums; }
  .nowrap { white-space: nowrap; }
  .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
