:root {
  --violett: #5b21b6;
  --violett-hell: #7c3aed;
  --violett-blass: #ede9fe;
  --hintergrund: #f6f4fb;
  --karte: #ffffff;
  --text: #1f1a2e;
  --text-leise: #6b6482;
  --linie: #e4e0f0;
  --fehler: #b91c1c;
  --ok: #15803d;
  --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--hintergrund); color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Kopfzeile ---------- */
.kopf { position: sticky; top: 0; z-index: 10; background: var(--violett); color: #fff;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px; display: flex; align-items: center; gap: 6px; }
.kopf h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf button, .kopf a { background: rgba(255,255,255,.16); color: #fff; border: 0; border-radius: 10px;
  min-height: 40px; min-width: 38px; padding: 0 9px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.kopf .zurueck { font-size: 20px; padding: 0 14px; }
.inhalt { padding: 14px 16px calc(env(safe-area-inset-bottom) + 90px); max-width: 640px; margin: 0 auto; }

/* ---------- Banner / Hinweise ---------- */
.banner { padding: 10px 16px; font-size: 14px; text-align: center; }
.banner.offline { background: #fef3c7; color: #78350f; }
.meldung { padding: 12px 14px; border-radius: 10px; margin: 12px 0; font-size: 15px; }
.meldung.fehler { background: #fee2e2; color: var(--fehler); }
.meldung.ok { background: #dcfce7; color: var(--ok); }
.meldung.info { background: var(--violett-blass); color: var(--violett); }

/* ---------- Karten und Listen ---------- */
.karte { background: var(--karte); border-radius: var(--radius); padding: 14px; margin: 10px 0;
  box-shadow: 0 1px 2px rgba(60,30,120,.08); border: 1px solid var(--linie); }
a.karte { display: block; color: inherit; text-decoration: none; }
a.karte:active { background: var(--violett-blass); }
.karte h2 { font-size: 15px; margin: 0 0 8px; color: var(--violett); text-transform: uppercase; letter-spacing: .04em; }
.tag { font-size: 13px; font-weight: 700; color: var(--text-leise); margin: 18px 4px 4px; text-transform: capitalize; }
.zeile { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.zeile + .zeile { margin-top: 6px; }
.gross { font-size: 17px; font-weight: 650; }
.leise { color: var(--text-leise); font-size: 14px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 99px;
  font-size: 13px; font-weight: 600; color: #fff; background: var(--text-leise); }
.chip.status { background: #fff; border: 2px solid currentColor; }
.leer { text-align: center; color: var(--text-leise); padding: 40px 10px; }

/* ---------- Formulare ---------- */
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; color: var(--text-leise); }
input[type=text], input[type=number], input[type=email], input[type=tel], input[type=password], input[type=search], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 12px; font-size: 16px; /* 16px verhindert Zoom auf dem iPhone */
  background: #fff; border: 1.5px solid var(--linie); border-radius: 10px; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #c4b5fd; border-color: var(--violett-hell); }
.raster2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.raster2 > div > label:first-child { margin-top: 12px; }
.auswahl { display: flex; flex-wrap: wrap; gap: 8px; }
.auswahl label { display: inline-flex; align-items: center; gap: 8px; margin: 0; padding: 10px 14px; min-height: 48px;
  background: #fff; border: 1.5px solid var(--linie); border-radius: 10px; color: var(--text); font-weight: 500; font-size: 16px; }
.auswahl input { width: 22px; height: 22px; accent-color: var(--violett); margin: 0; }
.auswahl label:has(input:checked) { border-color: var(--violett-hell); background: var(--violett-blass); }

.knopf { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 52px; border: 0; border-radius: 12px;
  background: var(--violett); color: #fff; font-size: 17px; font-weight: 650; cursor: pointer; text-decoration: none; margin-top: 14px; }
.knopf:active { background: var(--violett-hell); }
.knopf.zweit { background: var(--violett-blass); color: var(--violett); }
.knopf.klein { width: auto; min-height: 40px; padding: 0 14px; font-size: 15px; margin: 0; }
.knopf[disabled] { opacity: .55; }

/* ---------- Zeichenflächen ---------- */
.pad { position: relative; background: #fff; border: 1.5px dashed #a78bfa; border-radius: 10px; overflow: hidden; }
.pad canvas { display: block; width: 100%; height: auto; touch-action: none; }
.pad .leerhinweis { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #b4aacb; pointer-events: none; font-size: 15px; }
.pad .linie { position: absolute; left: 6%; right: 6%; bottom: 28%; border-bottom: 1px solid #d8d2ea; pointer-events: none; }
.padleiste { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

/* ---------- Anmeldung ---------- */
.login { max-width: 380px; margin: 0 auto; padding: calc(env(safe-area-inset-top) + 60px) 20px 20px; }
.login .logo { width: 84px; height: 84px; border-radius: 20px; display: block; margin: 0 auto 14px; }
.login h1 { text-align: center; margin: 0 0 22px; color: var(--violett); font-size: 24px; }

/* ---------- Verlauf ---------- */
.verlauf { list-style: none; margin: 0; padding: 0; }
.verlauf li { padding: 8px 0 8px 14px; border-left: 3px solid var(--violett-blass); font-size: 14px; }
.verlauf time { display: block; color: var(--text-leise); font-size: 12px; }
.dateilink { display: flex; align-items: center; gap: 8px; padding: 10px 0; color: var(--violett); font-weight: 600; text-decoration: none; border-top: 1px solid var(--linie); }
.dateilink:first-of-type { border-top: 0; }

/* ---------- Fußleiste im Formular ---------- */
.fuss { position: fixed; left: 0; right: 0; bottom: 0; background: rgba(255,255,255,.96); backdrop-filter: blur(6px);
  border-top: 1px solid var(--linie); padding: 10px 16px calc(env(safe-area-inset-bottom) + 10px); z-index: 9; }
.fuss .knopf { margin: 0; max-width: 608px; margin-inline: auto; }

/* ---------- Chat ---------- */
.zaehler { background: #ef4444; color: #fff; border-radius: 99px; font-size: 12px; font-weight: 700; min-width: 20px; padding: 0 6px; line-height: 20px; text-align: center; margin-left: 6px; }
.chatliste { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.blase { max-width: 82%; padding: 8px 12px; border-radius: 16px; box-shadow: 0 1px 1px rgba(60,30,120,.08); }
.blase.eigene { align-self: flex-end; background: var(--violett); color: #fff; border-bottom-right-radius: 4px; }
.blase.fremde { align-self: flex-start; background: #fff; border: 1px solid var(--linie); border-bottom-left-radius: 4px; }
.blase .absender { font-size: 12px; font-weight: 700; color: var(--violett-hell); margin-bottom: 2px; }
.blase .nachrichtentext { white-space: pre-wrap; overflow-wrap: anywhere; }
.blase .zeit { font-size: 11px; opacity: .7; text-align: right; margin-top: 2px; }
.chatleiste { display: flex; gap: 8px; align-items: flex-end; }
.chatleiste textarea { min-height: 48px; max-height: 140px; height: 48px; padding: 12px; flex: 1; resize: none; }
.chatsenden { width: 52px; height: 48px; border: 0; border-radius: 12px; background: var(--violett); color: #fff; font-size: 20px; cursor: pointer; }
.chatsenden[disabled] { opacity: .5; }

/* ---------- Fotos ---------- */
.fotoraster { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 4px; }
.fotokachel { min-width: 0; }
.fotounter { font-size: .78rem; color: var(--leise, #6b6482); margin-top: 2px; overflow-wrap: anywhere; }
.fotoknoepfe { display: flex; gap: 4px; margin-top: 2px; }
.klein-icon { border: 0; background: transparent; font-size: 1rem; padding: 2px 6px; cursor: pointer; }
.fotoraster img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; display: block; background: var(--violett-blass); }
.chatbild { display: block; max-width: 100%; max-height: 260px; border-radius: 10px; margin: 2px 0 4px; background: var(--violett-blass); }
.chatfoto { width: 48px; height: 48px; flex: none; border-radius: 12px; background: var(--violett-blass); display: flex; align-items: center; justify-content: center; font-size: 22px; cursor: pointer; }

/* ---------- Zeiterfassung ---------- */
.zeitstatus { text-align: center; border-left: 6px solid var(--linie); }
.zeitstatus.laeuft-arbeit { border-left-color: #16a34a; } .zeitstatus.laeuft-fahrt { border-left-color: #2563eb; } .zeitstatus.laeuft-pause { border-left-color: #d97706; }
.zeitart { font-size: 18px; font-weight: 700; }
.timer { font-size: 44px; font-weight: 700; font-variant-numeric: tabular-nums; margin: 4px 0; color: var(--violett); }
.zeit-offen { border: 2px solid #f59e0b; background: #fffbeb; }
.knopfraster { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.knopfraster .knopf { margin-top: 10px; }
.knopf.gefahr { background: #1f1a2e; }
.summenraster { display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; gap: 4px; margin-bottom: 8px; }
.summenwert { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hinweis { display: flex; gap: 8px; padding: 8px 10px; border-radius: 10px; font-size: 14px; margin-top: 6px; }
.hinweis.verstoss { background: #fee2e2; color: #991b1b; } .hinweis.warnung { background: #fef3c7; color: #78350f; } .hinweis.info { background: var(--violett-blass); color: var(--violett); }
.hinweisicon { font-weight: 800; width: 18px; flex: none; text-align: center; }
.eintraege { margin-top: 10px; border-top: 1px solid var(--linie); }
.eintrag { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--linie); font-size: 15px; }
.monatswahl { display: flex; align-items: center; justify-content: space-between; margin: 4px 0; }

/* ---------- Schwebender Knopf (Neuer Auftrag) ---------- */
.fab { position: fixed; right: 18px; bottom: calc(env(safe-area-inset-bottom) + 18px); width: 58px; height: 58px; border-radius: 50%; background: var(--violett); color: #fff;
  font-size: 30px; display: flex; align-items: center; justify-content: center; text-decoration: none; box-shadow: 0 4px 14px rgba(91,33,182,.4); z-index: 9; }
.knopf.aktiv { background: #dc2626; color: #fff; }
