/* Base layer: reset, document typography and accessibility primitives. */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  scroll-padding-top: calc(var(--header) + var(--s4));
}

body {
  margin: 0;
  min-height: calc(100vh * var(--vz));
  min-height: calc(100dvh * var(--vz));
  background: linear-gradient(to bottom, var(--mode-wash), transparent 440px) no-repeat, var(--canvas);
  transition: background-color var(--t-med) var(--ease);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-base);
  font-weight: var(--fw-regular);
  line-height: var(--lh);
  font-feature-settings: "ss01", "cv11";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: anywhere;
}

h1, h2, h3, h4, p, ul, ol, dl, dd, figure, blockquote, pre { margin: 0; }
ul, ol { padding: 0; }
ul[role="list"], ol[role="list"], .plain-list { list-style: none; }

h1, h2, h3, h4 {
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  text-wrap: balance;
}
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); font-weight: var(--fw-semibold); }
h4 { font-size: var(--fs-md); font-weight: var(--fw-semibold); }
p { text-wrap: pretty; }

a {
  color: var(--mode);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}
a:hover { color: var(--mode-hover); }

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
textarea { resize: vertical; }

code, kbd, samp, pre { font-family: var(--font-mono); font-size: 0.92em; }
kbd {
  padding: 0 0.35em;
  border: var(--border) solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  background: var(--surface);
  font-size: 0.82em;
}

hr { border: 0; border-top: var(--border) solid var(--line); margin: var(--s6) 0; }

::selection { background: var(--brand-tint-strong); color: var(--ink); }

/* Focus: always visible for keyboard users, never removed. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline-offset: 0; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: calc(var(--safe-top) + var(--s2));
  left: var(--s2);
  padding: var(--s2) var(--s4);
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--canvas);
  font-weight: var(--fw-semibold);
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus { transform: none; color: var(--canvas); }

.icon {
  width: var(--icon);
  height: var(--icon);
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.icon-sm { width: var(--icon-sm); height: var(--icon-sm); }
.icon-lg { width: 24px; height: 24px; }

.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.tabular { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

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

@media (forced-colors: active) {
  .btn, .field-control, .segmented, .panel, .dialog-surface, .menu { border: 1px solid CanvasText; }
  .btn-primary { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  :focus-visible { outline-color: Highlight; }
}

@media print {
  .app-header, .app-nav-mobile, .toast-region, .drop-overlay { display: none !important; }
  body { background: #fff; color: #000; }
}
