/* ==========================================================================
   Basis: Reset, Typografie, Formulare, Buttons
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: var(--lh-normal);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -0.015em;
  margin: 0;
  text-wrap: balance;
}

p { margin: 0; }
a { color: inherit; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }

::selection { background: var(--accent-soft); }

:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent-ring);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

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

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  stroke-width: 1.85;
}
.icon--sm { width: 15px; height: 15px; }
.icon--lg { width: 22px; height: 22px; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 40px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--btn-border);
  border-radius: var(--r-md);
  background: var(--btn-bg);
  color: var(--btn-fg);
  font-weight: 550;
  font-size: var(--fs-md);
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--dur-1) var(--ease-out), border-color var(--dur-1), transform var(--dur-1) var(--ease-out), box-shadow var(--dur-1);
  user-select: none;
}
.btn:hover { --btn-bg: var(--surface-2); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn--primary {
  --btn-bg: var(--accent-solid);
  --btn-fg: var(--text-on-accent);
  --btn-border: transparent;
  box-shadow: var(--shadow-1), inset 0 1px 0 rgb(255 255 255 / 0.12);
}
.btn--primary:hover { --btn-bg: var(--accent-solid-hover); }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; }
.btn--ghost:hover { --btn-bg: var(--surface-2); }
.btn--danger { --btn-bg: var(--danger-solid); --btn-fg: #fff; --btn-border: transparent; }
/* eigener Hover – sonst greift .btn:hover (hellgrau) und die weiße Schrift steht auf Hellgrau */
.btn--danger:hover { --btn-bg: var(--danger-solid-hover); }
.btn--block { width: 100%; }
.btn--sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); border-radius: var(--r-sm); }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: var(--r-md);
  background: transparent;
  color: var(--text-2);
  transition: background-color var(--dur-1), color var(--dur-1), transform var(--dur-1) var(--ease-out);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:active { transform: scale(0.92); }
.icon-btn--sm { width: 28px; height: 28px; border-radius: var(--r-sm); }
@media (pointer: coarse) {
  .icon-btn { width: var(--touch); height: var(--touch); }
  .icon-btn--sm { width: 36px; height: 36px; }
}

/* ---------- Formulare ---------- */
.form { display: grid; gap: var(--sp-4); }
.form__row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.field { display: grid; gap: 6px; align-content: start; }
.field__label { font-size: var(--fs-sm); font-weight: 550; color: var(--text-2); }
.field__label small { font-weight: 400; color: var(--text-3); }

.input, .select, .textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: 16px; /* verhindert Zoom auf iOS */
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
@media (min-width: 900px) {
  .input, .select, .textarea { font-size: var(--fs-md); }
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.55; }

.checkbox { display: inline-flex; align-items: center; gap: var(--sp-2); cursor: pointer; font-size: var(--fs-md); min-height: var(--touch); }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }

.link { color: var(--accent); text-decoration: none; font-weight: 500; font-size: var(--fs-sm); }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }
.link--center { justify-self: center; }

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-xs);
  background: var(--surface);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--text-2);
}
