/* Hausschrift Newson */
@font-face { font-family: "Newson"; font-weight: 300; font-style: normal; font-display: swap; src: url("/fonts/Newson-Light.ttf") format("truetype"); }
@font-face { font-family: "Newson"; font-weight: 400; font-style: normal; font-display: swap; src: url("/fonts/Newson-Regular.ttf") format("truetype"); }
@font-face { font-family: "Newson"; font-weight: 500; font-style: normal; font-display: swap; src: url("/fonts/Newson-Medium.ttf") format("truetype"); }
@font-face { font-family: "Newson"; font-weight: 600; font-style: normal; font-display: swap; src: url("/fonts/Newson-SemiBold.ttf") format("truetype"); }
@font-face { font-family: "Newson"; font-weight: 700; font-style: normal; font-display: swap; src: url("/fonts/Newson-Bold.ttf") format("truetype"); }

/* Farben aus dem Starklar-Logo */
:root {
  --navy: #0b3c55;
  --blue-d: #0f6a91;
  --blue: #1c8bb7;
  --sky: #02a7e5;
  --tint: #e8f4fa;
  --tint-2: #d2eaf6;
  --paper: #f1f6f9;
  --card: #ffffff;
  --ink: #1d2a33;
  --muted: #586873;
  --line: #d3e0e7;
  --danger: #b3261e;
  --shadow: 0 1px 2px rgba(11, 60, 85, .06), 0 12px 32px rgba(11, 60, 85, .09);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.5 "Newson", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, textarea, select { font-family: inherit; }
svg { display: block; }

/* ---------- Kopfbereich mit Welle ---------- */
.hero {
  position: relative;
  overflow: hidden;
  color: #fff;
  background:
    radial-gradient(120% 90% at 100% 0%, rgba(2, 167, 229, .55) 0%, rgba(2, 167, 229, 0) 60%),
    linear-gradient(160deg, var(--navy) 0%, var(--blue-d) 58%, var(--blue) 100%);
  padding: calc(env(safe-area-inset-top) + 16px) 20px 84px;
}
.hero::before { /* Wassertropfen als Wasserzeichen */
  content: "";
  position: absolute; right: -36px; top: -24px; width: 280px; height: 336px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 120'%3E%3Cpath fill='white' d='M50 4C50 4 8 52 8 80a42 42 0 0 0 84 0C92 52 50 4 50 4z'/%3E%3C/svg%3E") no-repeat center / contain;
  opacity: .1;
  pointer-events: none;
}
.hero-inner { position: relative; z-index: 1; max-width: 760px; margin: 0 auto; }
.hero h1 { margin: 22px 0 4px; font-size: 2rem; line-height: 1.15; font-weight: 700; letter-spacing: -.01em; }
.hero p { margin: 0; color: rgba(255, 255, 255, .86); }
.hero.compact { padding-bottom: 76px; }
.hero.compact h1 { margin-top: 18px; }

.wave { position: absolute; left: 0; bottom: -1px; width: 100%; height: 62px; }
.wave .w1 { fill: var(--paper); }
.wave .w2 { fill: var(--sky); opacity: .32; }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.bar form { margin: 0; }
.badge {
  display: grid; place-items: center; width: 64px; height: 64px;
  background: #fff; border-radius: 18px; box-shadow: 0 8px 20px rgba(0, 0, 0, .18);
}
.badge img { width: 44px; height: auto; }
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border-radius: 999px; border: 1px solid rgba(255, 255, 255, .28);
  background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; font-size: .95rem;
  text-decoration: none; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.pill svg { width: 18px; height: 18px; margin-left: -4px; }
.pill:active { background: rgba(255, 255, 255, .26); }

.progress { margin-top: 20px; }
.progress-text { font-size: .9rem; font-weight: 600; margin-bottom: 8px; color: rgba(255, 255, 255, .92); }
.progress-track { height: 8px; border-radius: 99px; background: rgba(255, 255, 255, .22); overflow: hidden; }
.progress-bar {
  height: 100%; width: 0; border-radius: 99px;
  background: linear-gradient(90deg, #fff, #9fdcf6);
  transition: width .35s ease;
}

/* ---------- Inhalt ---------- */
.wrap { max-width: 760px; margin: 0 auto; padding: 8px 16px 48px; }
.wrap.pull { margin-top: -34px; position: relative; z-index: 2; padding-top: 0; }
.wrap.has-dock { padding-bottom: calc(130px + env(safe-area-inset-bottom)); }

.card {
  background: var(--card); border-radius: 22px; padding: 22px 20px 20px;
  margin-bottom: 18px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head h2 { margin: 0; font-size: 1.25rem; font-weight: 700; letter-spacing: -.005em; }
.card-icon {
  display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: 13px;
  background: linear-gradient(135deg, var(--tint), var(--tint-2)); color: var(--blue-d);
}
.card-icon svg { width: 22px; height: 22px; }

/* Startseite: Formular-Kacheln */
.tiles { display: grid; gap: 14px; margin-top: -30px; position: relative; z-index: 2; }
.tile {
  display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 22px;
  background: var(--card); color: var(--ink); text-decoration: none; box-shadow: var(--shadow);
}
.tile:active { transform: scale(.99); }
.tile-icon {
  display: grid; place-items: center; flex: none; width: 58px; height: 58px; border-radius: 17px;
  background: linear-gradient(135deg, var(--blue-d), var(--sky)); color: #fff;
}
.tile-icon svg { width: 28px; height: 28px; }
.tile-text { display: block; min-width: 0; }
.tile-text strong { display: block; font-size: 1.3rem; font-weight: 700; }
.tile-text span { color: var(--muted); font-size: .95rem; }
.tile .go { margin-left: auto; color: var(--blue); flex: none; }
.tile .go svg { width: 24px; height: 24px; }

/* ---------- Formularfelder ---------- */
label, legend, .sig-label { display: block; margin: 14px 0 6px; font-weight: 600; font-size: .95rem; color: var(--navy); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.field { grid-column: 1 / -1; }
.field.half { grid-column: span 1; }
.field > label:first-child, .field > .sig > .sig-label { margin-top: 12px; }
@media (max-width: 620px) { .field.half { grid-column: 1 / -1; } }
.req { color: var(--danger); }

input[type="text"], input[type="email"], input[type="password"], input[type="tel"],
input[type="number"], input[type="date"], textarea, select {
  width: 100%; min-height: 50px; padding: 12px 14px;
  font-size: 16px; /* verhindert Zoom auf iOS */
  color: var(--ink); background: #fff;
  border: 1.5px solid var(--line); border-radius: 14px;
  -webkit-appearance: none; appearance: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 0; line-height: 1.45; }
input[type="date"] { display: block; text-align: left; }
select {
  padding-right: 44px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231479a2' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 14px center / 18px;
}
input::placeholder, textarea::placeholder { color: #8fa2ad; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--blue); box-shadow: 0 0 0 4px rgba(28, 139, 183, .2);
}

/* Gesperrtes Feld (z. B. Vertriebler = angemeldete Person) */
input[readonly] {
  background: var(--paper); color: var(--muted); -webkit-text-fill-color: var(--muted);
  border-style: dashed; cursor: not-allowed;
}
input[readonly]:focus { border-color: var(--line); box-shadow: none; }

/* Auswahl-Chips (Schmerzpunkte) */
fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.checks { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 620px) { .checks { grid-template-columns: 1fr; } }
label.check {
  position: relative; display: flex; align-items: center; margin: 0; min-height: 54px;
  padding: 10px 14px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff;
  font-weight: 500; font-size: .98rem; color: var(--ink); cursor: pointer;
  transition: border-color .15s, background .15s;
}
label.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
label.check span { display: flex; align-items: center; gap: 12px; }
label.check span::before {
  content: ""; flex: none; width: 24px; height: 24px; border-radius: 8px;
  border: 2px solid #a9c3d1; background: #fff center / 16px no-repeat;
  transition: background-color .15s, border-color .15s;
}
label.check input:checked + span::before {
  border-color: var(--blue); background-color: var(--blue);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E");
}
label.check:has(input:checked) { border-color: var(--blue); background: var(--tint); color: var(--navy); font-weight: 600; }
label.check:has(input:focus-visible) { box-shadow: 0 0 0 4px rgba(28, 139, 183, .25); }

/* ---------- Unterschrift ---------- */
.sig-box { position: relative; background: #fff; border: 2px dashed #8fb4c6; border-radius: 16px; overflow: hidden; }
.sig-canvas {
  display: block; width: 100%; aspect-ratio: 3 / 1; cursor: crosshair;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.sig-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 0 16px; text-align: center; color: #7d93a0; pointer-events: none;
}
.sig-line { position: absolute; left: 6%; right: 6%; bottom: 24%; border-bottom: 1.5px solid #c5d6df; pointer-events: none; }
.sig-clear { display: block; margin: 8px 0 0 auto; }

/* Optionale Unterschrift (Kunde): Schalter über dem Feld */
.sig-toggle { margin: 22px 0 0; }
.sig-toggle + .sig .sig-label { margin-top: 14px; }

/* ---------- Empfänger: Chips + Auswahlliste ---------- */
.rcpt { position: relative; }
.rcpt-box {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 54px;
  padding: 7px 8px 7px 12px; background: #fff; border: 1.5px solid var(--line); border-radius: 14px;
  transition: border-color .15s, box-shadow .15s;
}
.rcpt.open .rcpt-box, .rcpt-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(28, 139, 183, .2); }
.rcpt-chips { display: contents; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; max-width: 100%;
  padding: 6px 6px 6px 12px; border-radius: 999px; background: var(--tint-2); color: var(--navy);
  font-weight: 600; font-size: .95rem; line-height: 1.2;
}
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x {
  display: grid; place-items: center; flex: none; width: 26px; height: 26px; padding: 0;
  border: 0; border-radius: 50%; background: rgba(11, 60, 85, .12); color: var(--navy);
  font-size: 1.2rem; line-height: 1;
}
.chip-x:active { background: rgba(11, 60, 85, .26); }
input.rcpt-input {
  flex: 1 1 160px; width: auto; min-width: 140px; min-height: 40px; padding: 6px 4px;
  border: 0; border-radius: 0; box-shadow: none !important; background: transparent;
}
.rcpt-toggle {
  flex: none; display: grid; place-items: center; width: 40px; height: 40px; margin-left: auto; padding: 0;
  border: 0; border-radius: 12px; background: var(--tint); color: var(--blue-d);
}
.rcpt-toggle svg { width: 20px; height: 20px; transition: transform .15s; }
.rcpt.open .rcpt-toggle svg { transform: rotate(180deg); }
.rcpt-menu {
  margin-top: 8px; padding: 10px; display: grid; gap: 8px; background: #fff;
  border: 1.5px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.rcpt-opt { min-height: 52px; }
.rcpt-opt span { flex: 1; flex-wrap: wrap; row-gap: 0; }
.rcpt-name { font-style: normal; font-weight: 600; }
.rcpt-mail { font-style: normal; margin-left: auto; color: var(--muted); font-size: .88rem; font-weight: 400; }
.rcpt-hint { margin: 2px 4px 0; color: var(--muted); font-size: .88rem; }

/* ---------- Bestätigungsdialog ---------- */
.modal-open { overflow: hidden; }
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; display: grid; place-items: center;
  padding: 20px; background: rgba(11, 40, 58, .5);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
  animation: fade .15s ease-out;
}
.modal-overlay.closing { opacity: 0; transition: opacity .15s; }
.modal {
  width: 100%; max-width: 380px; padding: 28px 24px 22px; text-align: center;
  background: #fff; border-radius: 26px; box-shadow: 0 24px 60px rgba(4, 30, 45, .4);
  animation: rise .2s ease-out;
}
.modal-icon {
  display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 16px;
  border-radius: 50%; background: #fdecec; color: var(--danger);
}
.modal-icon svg { width: 30px; height: 30px; }
.modal h2 { margin: 0 0 8px; font-size: 1.35rem; font-weight: 700; color: var(--navy); }
.modal p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.modal-actions { display: flex; gap: 10px; margin-top: 24px; }
.modal-actions button { flex: 1 1 0; }
button.danger {
  border: 0; border-radius: 16px; padding: 14px 20px; color: #fff; font-size: 1.02rem; font-weight: 700;
  background: linear-gradient(135deg, #a8211a, var(--danger)); box-shadow: 0 8px 18px rgba(179, 38, 30, .3);
}
button.danger:active { transform: scale(.98); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }

/* Versand: mehr Luft unter der Empfängerauswahl und vor Hinweisen */
.rcpt { margin-bottom: 22px; }
.card > .error { margin-top: 18px; }

/* ---------- Entwürfe ---------- */
.save-state { margin-top: 8px; min-height: 1.2em; font-size: .85rem; color: rgba(255, 255, 255, .8); }
.drafts { margin-top: 22px; }
.draft-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.draft { display: flex; align-items: stretch; gap: 8px; }
.draft form { margin: 0; display: flex; }
.draft-link {
  flex: 1; min-width: 0; display: block; padding: 14px 16px; border: 1.5px solid var(--line);
  border-radius: 14px; color: var(--ink); text-decoration: none; background: #fff;
}
.draft-link:active { background: var(--tint); }
.draft-link strong { display: block; font-size: 1.05rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.draft-link span { color: var(--muted); font-size: .88rem; }
.draft-del {
  width: 52px; border: 1.5px solid var(--line); border-radius: 14px; background: #fff;
  color: var(--danger); font-size: 1.5rem; line-height: 1;
}
.draft-del:active { background: #fdecec; }

/* ---------- Buttons ---------- */
button { font: inherit; cursor: pointer; }
button.primary {
  border: 0; border-radius: 16px; padding: 15px 22px; color: #fff;
  font-size: 1.1rem; font-weight: 700; letter-spacing: .005em;
  background: linear-gradient(135deg, var(--blue-d), var(--blue));
  box-shadow: 0 8px 18px rgba(15, 106, 145, .32);
}
button.ghost {
  border: 1.5px solid var(--line); border-radius: 16px; padding: 14px 20px;
  background: #fff; color: var(--blue-d); font-size: 1.02rem; font-weight: 600;
}
button.primary:active, button.ghost:active { transform: scale(.98); }
button.primary.full { width: 100%; margin-top: 22px; }
button:disabled { opacity: .6; cursor: wait; }
button.link {
  background: none; border: none; padding: 8px 2px; color: var(--blue-d);
  font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}
.reset-link { display: block; margin: 14px 0 0; color: var(--muted); font-weight: 500; }
button:focus-visible, a:focus-visible { outline: 3px solid rgba(28, 139, 183, .5); outline-offset: 2px; }

/* Fest am unteren Rand: immer erreichbar, auch bei langem Formular */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, .86);
  -webkit-backdrop-filter: saturate(1.5) blur(16px); backdrop-filter: saturate(1.5) blur(16px);
  border-top: 1px solid rgba(15, 106, 145, .14);
}
.dock-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 12px; }
.dock .ghost { flex: 1 1 0; }
.dock .primary { flex: 2 1 0; }

/* ---------- Meldungen ---------- */
.error {
  margin: 0 0 12px; padding: 12px 14px; border-radius: 12px;
  background: #fdecec; color: #8a1c1c; border: 1px solid #f3c4c4; font-size: .95rem;
}
.toast {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  max-width: min(92vw, 520px); padding: 14px 20px; border-radius: 14px;
  color: #fff; font-weight: 600; z-index: 30; box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
  animation: pop .22s ease-out;
}
.toast.ok { background: var(--blue-d); }
.toast.err { background: var(--danger); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- Anmeldung ---------- */
.auth {
  position: relative; overflow: hidden; min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + 24px) 20px calc(110px + env(safe-area-inset-bottom));
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(2, 167, 229, .55) 0%, rgba(2, 167, 229, 0) 60%),
    linear-gradient(160deg, var(--navy) 0%, var(--blue-d) 58%, var(--blue) 100%);
}
.auth::before {
  content: ""; position: absolute; left: -60px; top: -40px; width: 320px; height: 384px; opacity: .08;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 120'%3E%3Cpath fill='white' d='M50 4C50 4 8 52 8 80a42 42 0 0 0 84 0C92 52 50 4 50 4z'/%3E%3C/svg%3E") no-repeat center / contain;
}
.auth .wave { height: 90px; }
.auth-card {
  position: relative; z-index: 1; width: 100%; max-width: 420px; padding: 30px 26px 28px;
  background: #fff; border-radius: 26px; box-shadow: 0 24px 60px rgba(4, 30, 45, .35);
}
.auth-logo { display: block; width: 110px; height: auto; margin: 0 auto 14px; }
.auth-card h1 { margin: 0; text-align: center; font-size: 1.6rem; font-weight: 700; }
.auth-card .sub { margin: 4px 0 8px; text-align: center; color: var(--muted); }

@media (min-width: 900px) {
  .hero h1 { font-size: 2.4rem; }
  .wrap { padding-left: 0; padding-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
