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

html {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s var(--ease);
}

a:hover {
  color: var(--color-primary-dark);
}

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

button {
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  color: var(--color-text-strong);
  font-weight: 700;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.75rem, 3vw, 2.5rem);
}

h2 {
  font-size: clamp(1.35rem, 2.4vw, 1.85rem);
}

h3 {
  font-size: 1.125rem;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

input,
select,
textarea {
  font-size: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: #fff;
  padding: 12px 14px;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

/* appearance:none + width:100% ламає чекбокси/радіо (порожній квадрат без галочки).
   iOS Safari також погано малює accent-color на «обнулених» checkbox. */
input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-width: 1.15rem;
  height: 1.15rem;
  padding: 0;
  margin: 0;
  border: none;
  background: transparent;
  -webkit-appearance: auto;
  appearance: auto;
  flex-shrink: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
  outline: none;
}

input[type="checkbox"]:focus,
input[type="radio"]:focus {
  box-shadow: none;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--color-text-strong);
}

.field {
  margin-bottom: var(--space-4);
}

.field-hint {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.field-error {
  margin-top: 4px;
  font-size: 0.8rem;
  color: var(--color-danger);
  display: none;
}

.field.is-invalid input,
.field.is-invalid select,
.field.is-invalid textarea {
  border-color: var(--color-danger);
}

.field.is-invalid .field-error {
  display: block;
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator {
  display: inline;
}

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

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms;
    transition-duration: 0.01ms;
  }
}
