:root {
  --blau: #1f4e79;
  --blau-hell: #e8f0f8;
  --text: #1d1d1f;
  --grau: #5f6368;
  --linie: #d0d7de;
  --hinter: #f4f6f8;
  --karte: #ffffff;
  --rot: #b3261e;
  --gruen: #1e7b34;
  --gruen-hell: #e6f4ea;
  --gelb-hell: #fff6dc;
  --gelb: #8a6100;
}

@media (prefers-color-scheme: dark) {
  :root {
    --blau: #8ab4f8;
    --blau-hell: #1c2b3d;
    --text: #e8eaed;
    --grau: #a5acb4;
    --linie: #3c4148;
    --hinter: #15171a;
    --karte: #202327;
    --rot: #f28b82;
    --gruen: #81c995;
    --gruen-hell: #1b3022;
    --gelb-hell: #3a3118;
    --gelb: #fdd663;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--hinter);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.kopf {
  background: var(--blau);
  color: #fff;
  padding: 20px 16px 24px;
}
@media (prefers-color-scheme: dark) { .kopf { color: #10131a; } }
.kopf h1 { margin: 0 auto 8px; max-width: 760px; font-size: 1.35rem; line-height: 1.25; }
.kopf p { margin: 0 auto; max-width: 760px; opacity: .92; font-size: .95rem; }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 48px; }

.karte {
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 12px;
  padding: 16px;
  margin: 0 0 16px;
  min-width: 0;
}

fieldset.karte { padding-top: 8px; }
legend {
  float: left;
  width: 100%;
  padding: 8px 0 4px;
  font-weight: 700;
  font-size: 1.1rem;
  line-height: 1.3;
  color: var(--blau);
}
legend + * { clear: both; }

.meldung { border-left: 5px solid var(--gelb); background: var(--gelb-hell); }
.meldung h2 { margin: 0 0 6px; font-size: 1.1rem; }
.meldung p { margin: 6px 0; }
.meldung.erfolg { border-left-color: var(--gruen); background: var(--gruen-hell); }

.frage { font-weight: 600; margin: 18px 0 8px; display: block; }
.frage:first-of-type { margin-top: 8px; }
u { text-decoration-thickness: 1px; text-underline-offset: 2px; }

label { display: block; margin: 0 0 12px; font-size: .95rem; }
label.frage { font-size: 1rem; }

input, select, textarea {
  display: block;
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  font: inherit;
  font-size: 16px; /* verhindert Zoom auf iOS */
  color: var(--text);
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: 8px;
  min-height: 44px;
  min-width: 0;
}
input[type="date"] { -webkit-appearance: none; appearance: none; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--blau);
  outline-offset: 1px;
  border-color: var(--blau);
}

input[type="checkbox"], input[type="radio"] {
  display: inline-block;
  width: 22px;
  height: 22px;
  min-height: 0;
  margin: 0 8px 0 0;
  vertical-align: middle;
  accent-color: var(--blau);
  flex: none;
}

label.wahl {
  display: flex;
  align-items: center;
  min-height: 44px;
  margin: 0;
  padding: 4px 0;
  cursor: pointer;
}

.gruppe { margin: 16px 0; }
.gruppe > span { display: block; font-weight: 600; margin-bottom: 4px; }

.zwei, .drei { display: grid; gap: 0 12px; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 560px) {
  .zwei { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .drei { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.raster { display: grid; grid-template-columns: 1fr; gap: 0 12px; }
@media (min-width: 480px) { .raster { grid-template-columns: 1fr 1fr; } }

/* Tätigkeitslisten */
.liste .zeile {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 4px 10px;
  padding: 6px 0;
  border-top: 1px solid var(--linie);
}
.liste .zeile:first-child { border-top: 0; }
.liste label.inline {
  display: flex;
  flex-direction: column;
  margin: 0;
  color: var(--grau);
  font-size: .75rem;
  line-height: 1.2;
}
.liste label.inline > span { white-space: nowrap; }
.liste label.inline input { margin-top: 2px; flex: none; }
.liste label.stunden input { width: 96px; }
.liste label.datum input { width: 168px; }
.liste label.inline.breit {
  grid-column: 1 / -1;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin-left: 30px;
  font-size: .9rem;
}
.liste label.inline.breit input { flex: 1 1 auto; width: auto; margin: 0; }
@media (min-width: 640px) {
  .liste label.stunden, .liste label.datum { flex-direction: row; align-items: center; gap: 10px; font-size: .9rem; }
  .liste label.stunden input, .liste label.datum input { margin-top: 0; }
  .liste label.stunden input { width: 110px; }
  .liste label.datum input { width: 180px; }
}

label.inline { display: block; }
.gruppe label.inline { margin-top: 8px; }

/* Staffeln */
.staffel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0 10px;
  padding: 12px;
  margin-bottom: 10px;
  background: var(--blau-hell);
  border-radius: 10px;
  position: relative;
}
.staffel label:nth-child(3) { grid-column: 1 / 2; margin-bottom: 0; }
.staffel .entfernen {
  position: absolute;
  right: 8px;
  bottom: 12px;
  width: 44px;
  height: 44px;
  border-radius: 22px;
  border: 1px solid var(--linie);
  background: var(--karte);
  color: var(--rot);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
@media (min-width: 640px) {
  .staffel { grid-template-columns: 1fr 1fr 1fr 48px; align-items: end; }
  .staffel label:nth-child(3) { grid-column: auto; }
  .staffel label { margin-bottom: 0; }
  .staffel .entfernen { position: static; }
}

button { font: inherit; cursor: pointer; }
button.neben {
  background: none;
  border: 1px dashed var(--blau);
  color: var(--blau);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 44px;
  width: 100%;
}
button.haupt {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  background: var(--blau);
  color: #fff;
  border: 0;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.05rem;
}
@media (prefers-color-scheme: dark) { button.haupt { color: #10131a; } }
button.haupt:disabled { opacity: .6; cursor: wait; }

.summe { margin: 12px 0 0; text-align: right; }
.klein { font-size: .85rem; color: var(--grau); }
.einwilligung { align-items: flex-start !important; gap: 0; }
.einwilligung input { margin-top: 2px; }
.einwilligung a { color: var(--blau); }

.fehler {
  border: 1px solid var(--rot);
  color: var(--rot);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 12px;
}
.fehler p { margin: 4px 0; }

/* Nur-Lesen-Ansicht (Fall B) */
.nur-lesen input:disabled, .nur-lesen select:disabled, .nur-lesen textarea:disabled {
  opacity: 1;
  color: var(--text);
  -webkit-text-fill-color: var(--text);
  background: var(--hinter);
}
.nur-lesen label.wahl { cursor: default; }

/* Datenschutzseite */
.text h2 { font-size: 1.05rem; margin: 20px 0 6px; }
.platzhalter { background: var(--gelb-hell); color: var(--gelb); padding: 0 4px; border-radius: 4px; }

/* Anmeldung, Kennung, Hinweise an Feldern (Schritt 6) */
#anmeldung h2 { margin: 0 0 8px; font-size: 1.15rem; color: var(--blau); }
#anmeldung p { margin: 0 0 12px; }
.kennung {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 12px;
  margin: 4px 0 12px;
  padding: 8px 12px;
  background: var(--blau-hell);
  border-radius: 8px;
  font-size: .95rem;
}
button.link {
  background: none;
  border: 0;
  padding: 8px 0;
  min-height: 44px;
  color: var(--blau);
  text-decoration: underline;
}
input.gesperrt, input[readonly] { background: var(--hinter); color: var(--grau); -webkit-text-fill-color: var(--grau); }
.feldfehler { color: var(--rot); font-size: .9rem; margin: 4px 0 8px; }
.staffel .feldfehler { grid-column: 1 / -1; margin: 8px 0 0; padding-right: 56px; }
@media (min-width: 640px) { .staffel .feldfehler { padding-right: 0; } }
.staffel.fehlerhaft { outline: 2px solid var(--rot); outline-offset: -2px; }
.liste .zeile.fehlerhaft { background: color-mix(in srgb, var(--rot) 8%, transparent); box-shadow: inset 4px 0 0 var(--rot); padding-left: 8px; }
.liste .zeile.fehlerhaft label.stunden input { border-color: var(--rot); outline: 1px solid var(--rot); }
.meldung button.neben { width: auto; margin: 8px 8px 0 0; }
