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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overflow-x: clip;
  max-width: 100%;
}

[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: var(--fs-0);
  line-height: 1.6;
  overflow-x: clip;
  max-width: 100%;
}
button, input, select, textarea { font-family: inherit; }

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  line-height: 1.18;
  margin: 0 0 var(--sp-4);
  letter-spacing: -0.02em;
}
h1 { font-size: var(--fs-4); }
h2 { font-size: var(--fs-2); }
h3 { font-size: var(--fs-1); font-weight: 600; }
h4 { font-size: var(--fs-0); font-weight: 600; }
.display { font-family: var(--font-display); font-weight: 700; font-size: var(--fs-5); letter-spacing: -0.02em; }

p { margin: 0 0 var(--sp-4); }

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--teal-deep); }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.ic-lucide {
  display: inline-block;
  flex: none;
  vertical-align: middle;
}

.skip {
  position: absolute;
  left: var(--sp-4);
  top: -80px;
  z-index: 100;
  background: var(--ink);
  color: var(--on-ink);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-btn);
  font: 600 var(--fs-small)/1 var(--font-body);
}
.skip:focus { top: var(--sp-4); }

.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;
}

.noscript { padding: var(--sp-5); background: var(--surface); }

.lede { font-size: var(--fs-1); line-height: 1.45; color: var(--ink); max-width: 42ch; }
.muted { color: var(--muted); }
.error-text { color: var(--error); font-weight: 600; }
.success-text { color: #166534; font-weight: 600; }
.empty { color: var(--muted); }

/* Buttons: 44 px min touch target */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 44px;
  min-width: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  font: 600 0.9375rem/1 var(--font-body);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 120ms var(--ease), color 120ms var(--ease), border-color 120ms var(--ease);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1D4ED8; color: #fff; }
.btn-secondary { background: var(--card); border-color: var(--nav-border); color: var(--ink); padding: 0 14px; }
.btn-secondary:hover { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 30%, var(--nav-border)); text-decoration: none; }
.btn-danger { background: var(--error); color: var(--on-error); }
.btn-danger:hover { background: var(--error-deep); color: var(--on-error); }
.btn-small { min-height: 38px; padding: 0 12px; font-size: var(--fs-small); }
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.is-loading { cursor: progress; }
.btn.is-loading::before {
  content: "";
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Forms */
.form { display: grid; gap: var(--sp-5); max-width: 720px; }
.field { display: grid; gap: var(--sp-2); }
.field label, .field .label { font-weight: 600; font-family: var(--font-body); }
.hint { color: var(--muted); font-size: var(--fs-small); margin: 0; }
.field-error { color: var(--error); font-weight: 600; font-size: var(--fs-small); margin: 0; }

.input, .textarea, .select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--field-border);
  border-radius: var(--r-btn);
  font: 400 1rem/1.4 var(--font-body);
}
.textarea { min-height: 140px; resize: vertical; }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--error); border-width: 2px; }
.input:disabled, .textarea:disabled, .select:disabled { opacity: 0.6; }

.check { display: flex; align-items: center; gap: var(--sp-3); min-height: 44px; font-weight: 500; cursor: pointer; font-family: var(--font-body); }
.check input { width: 20px; height: 20px; accent-color: var(--accent); margin: 0; }

@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;
  }
  .btn.is-loading::before { animation: none; border-right-color: currentColor; }
}

h1, h2, h3 { text-wrap: balance; }
.prose p, .card-summary, .keep-text { text-wrap: pretty; }
::selection { background: color-mix(in srgb, var(--accent) 22%, transparent); }

a, button, summary, [role="button"], input, select, textarea, label { touch-action: manipulation; }
#main { overscroll-behavior: contain; }
dialog { overscroll-behavior: contain; }
body:has(dialog[open]) { overflow: hidden; }
img, video { max-width: 100%; }
