/* Reset, typography, form controls, buttons. */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* class display rules must never beat the hidden attribute */

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font: 700 30px/1.1 var(--font-display); letter-spacing: -0.025em; }
h2 { font: 650 17px/1.25 var(--font-display); letter-spacing: -0.015em; }
h3 { font: 600 13.5px/1.35 var(--font); }
a { color: var(--accent); text-underline-offset: 3px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.tnum { font-variant-numeric: tabular-nums; }
.eyebrow { font: 500 11px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0;
}

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
:focus:not(:focus-visible) { outline: none; }
::selection { background: var(--teal-5); color: var(--sand-12); }

.skip-link {
  position: absolute; left: 12px; top: -56px; z-index: 200; padding: 10px 14px;
  border-radius: var(--r); background: var(--accent); color: var(--accent-ink); font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; }

.icon { width: 16px; height: 16px; flex: none; }
.icon-lg { width: 20px; height: 20px; }
.icon-xl { width: 28px; height: 28px; }

/* ---------- forms ---------- */
label { display: grid; gap: 6px; font-weight: 550; font-size: 13px; }
label .hint { font-weight: 400; color: var(--muted); font-size: 12.5px; }
input, select, textarea {
  font: inherit; color: var(--text); min-width: 0; width: 100%; min-height: 40px; padding: 8px 12px;
  background: var(--surface); border: 1px solid var(--control-border); border-radius: var(--r);
  transition: border-color 120ms var(--ease), box-shadow 120ms var(--ease);
}
textarea { min-height: 84px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; }
input:hover, select:hover, textarea:hover { border-color: var(--text); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 24%, transparent);
}
input:disabled, select:disabled { opacity: 0.55; cursor: not-allowed; background: var(--surface-2); }
input:user-invalid, select:user-invalid { border-color: var(--danger); }
input[type="checkbox"], input[type="radio"] {
  appearance: none; width: 18px; height: 18px; min-height: 0; padding: 0; border-radius: 5px; flex: none;
  display: inline-grid; place-content: center; cursor: pointer; background: var(--surface);
}
input[type="radio"] { border-radius: 999px; }
input[type="checkbox"]::after {
  content: ""; width: 10px; height: 6px; border: solid var(--accent-ink); border-width: 0 0 2px 2px;
  transform: rotate(-45deg) translate(1px, -1px) scale(0); transition: transform 100ms var(--ease);
}
input[type="checkbox"]:checked, input[type="checkbox"]:indeterminate { background: var(--accent); border-color: var(--accent); }
input[type="checkbox"]:checked::after { transform: rotate(-45deg) translate(1px, -1px) scale(1); }
input[type="checkbox"]:indeterminate::after { width: 10px; height: 0; border-width: 0 0 2px 0; transform: none; }
input[type="search"]::-webkit-search-cancel-button { appearance: none; }
select { appearance: none; padding-right: 34px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238d8d86' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center; }
.field-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid > label { align-content: start; }
.field-grid .wide { grid-column: 1 / -1; }
.check { display: flex; align-items: flex-start; gap: 10px; font-weight: 450; }
.check input { margin-top: 1px; }
fieldset { border: 1px solid var(--border); border-radius: var(--r-lg); margin: 0; padding: 14px 16px; }
legend { padding: 0 6px; font-weight: 600; font-size: 13px; }

/* ---------- buttons ---------- */
button, .btn {
  font: 550 13.5px/1 var(--font); display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: var(--r); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: background-color 120ms var(--ease), border-color 120ms var(--ease), color 120ms var(--ease), transform 80ms var(--ease);
}
button:hover, .btn:hover { background: var(--surface-2); border-color: var(--sand-8); }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
button[aria-busy="true"] { cursor: progress; position: relative; color: transparent !important; }
button[aria-busy="true"]::after {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--text); border-right-color: transparent; animation: spin 700ms linear infinite;
}
button.primary[aria-busy="true"]::after, button.danger-solid[aria-busy="true"]::after { border-color: var(--accent-ink); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }
button.primary, .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 18%), var(--shadow-xs); }
button.primary:hover, .btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); box-shadow: none; }
button.ghost:hover { background: var(--surface-2); color: var(--text); }
button.danger { background: transparent; border-color: transparent; color: var(--danger); box-shadow: none; }
button.danger:hover { background: var(--danger-bg); }
button.danger-solid { background: var(--danger); border-color: var(--danger); color: var(--accent-ink); }
button.danger-solid:hover { background: var(--danger); filter: brightness(0.92); }
button.sm { min-height: 32px; padding: 0 12px; font-size: 13px; border-radius: var(--r-sm); }
button.icon-btn { width: 40px; padding: 0; }
button.icon-btn.sm { width: 32px; }

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