/* ==========================================================
   Deine Farben - im Kurs anpassen
   ========================================================== */
:root {
  --akzent: #7a5c3e;          /* Knoepfe, eigene Nachrichten, Avatar */
  --akzent-text: #ffffff;     /* Schrift auf Akzentfarbe */
  --akzent-zart: #efe4d6;     /* helle Flaechen in Akzentfarbe */
  --hintergrund: #faf6f0;
  --flaeche: #ffffff;
  --text: #2b2420;
  --text-leise: #7d716a;
  --linie: #e8dfd4;
  --warnung: #b4442f;
  --schrift: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --akzent: #c9a27c;
    --akzent-text: #221a14;
    --akzent-zart: #3a2f26;
    --hintergrund: #191512;
    --flaeche: #241f1b;
    --text: #f1e9e1;
    --text-leise: #a89a8f;
    --linie: #3a322b;
    --warnung: #ef8a74;
    color-scheme: dark;
  }
}

/* ========================================================== */

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--hintergrund);
  color: var(--text);
  font: 16px/1.45 var(--schrift);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app {
  height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  max-width: 720px;
  margin: 0 auto;
  background: var(--hintergrund);
}

/* Kopf */
.kopf {
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--flaeche);
  border-bottom: 1px solid var(--linie);
}
.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--akzent); color: var(--akzent-text);
  font-weight: 600; font-size: 18px; flex: none;
}
.avatar.gross { width: 64px; height: 64px; font-size: 28px; margin: 0 auto 8px; }
.kopf-text { flex: 1; min-width: 0; }
.kopf h1 { font-size: 17px; margin: 0; font-weight: 600; }
.status { margin: 0; font-size: 13px; color: var(--text-leise); }
.status.denkt::after { content: ""; animation: punkte 1.2s steps(4) infinite; }
@keyframes punkte { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.icon-knopf {
  border: 0; background: transparent; color: var(--text-leise);
  width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center;
}
.icon-knopf:hover { background: var(--akzent-zart); color: var(--text); }

/* Ansichten */
.ansicht { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }

/* Chat */
.verlauf { list-style: none; margin: 0; padding: 16px 16px 8px; display: flex; flex-direction: column; gap: 8px; }
.nachricht {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 18px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: rein .18s ease-out;
}
@keyframes rein { from { opacity: 0; transform: translateY(4px); } }
.nachricht.sie { align-self: flex-start; background: var(--flaeche); border: 1px solid var(--linie); border-bottom-left-radius: 6px; }
.nachricht.ich { align-self: flex-end; background: var(--akzent); color: var(--akzent-text); border-bottom-right-radius: 6px; }
.nachricht.fehler { align-self: center; background: transparent; color: var(--warnung); font-size: 14px; text-align: center; padding: 4px 8px; }
.nachricht a { color: inherit; text-decoration: underline; }
.nachricht .zeit { display: block; font-size: 11px; opacity: .6; margin-top: 4px; text-align: right; }
.nachricht.tippt { color: var(--text-leise); }
.nachricht.tippt span { display: inline-block; width: 6px; height: 6px; margin: 0 2px; border-radius: 50%; background: currentColor; animation: huepf 1s infinite; }
.nachricht.tippt span:nth-child(2) { animation-delay: .15s; }
.nachricht.tippt span:nth-child(3) { animation-delay: .3s; }
@keyframes huepf { 0%, 60%, 100% { transform: none; opacity: .4; } 30% { transform: translateY(-4px); opacity: 1; } }

.vorschlaege { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0 8px; list-style: none; }
.vorschlag {
  border: 1px solid var(--linie); background: var(--flaeche); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-size: 14px; text-align: left;
}
.vorschlag:hover { border-color: var(--akzent); }

/* Eingabe */
.eingabe {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 12px; background: var(--flaeche); border-top: 1px solid var(--linie);
}
.eingabe textarea {
  flex: 1; resize: none; max-height: 140px;
  font: inherit; color: var(--text);
  padding: 10px 14px; border-radius: 22px;
  border: 1px solid var(--linie); background: var(--hintergrund);
  outline: none;
}
.eingabe textarea:focus { border-color: var(--akzent); }
.senden {
  width: 44px; height: 44px; border-radius: 50%; border: 0; flex: none;
  background: var(--akzent); color: var(--akzent-text);
  display: grid; place-items: center;
}
.senden:disabled { opacity: .45; cursor: default; }
.senden svg { fill: currentColor; stroke: none; }

/* Reiter unten */
.reiter {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--flaeche); border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.reiter-knopf {
  border: 0; background: transparent; color: var(--text-leise);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 0 6px; font-size: 12px;
}
.reiter-knopf.aktiv { color: var(--akzent); font-weight: 600; }

/* Heute */
.heute { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.heute-kopf { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.heute-kopf h2 { margin: 0; font-size: 20px; }
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; padding: 14px 16px; }
.karte h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-leise); }
.zaehler { font-weight: 400; }
.liste { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: flex-start; gap: 12px; padding: 9px 0; border-top: 1px solid var(--linie); }
.liste li:first-child { border-top: 0; }
.liste .leer { color: var(--text-leise); }
.termin-zeit { flex: none; width: 76px; font-variant-numeric: tabular-nums; color: var(--akzent); font-weight: 600; }
.termin-tag { font-size: 12px; color: var(--text-leise); text-transform: uppercase; letter-spacing: .05em; padding: 10px 0 2px; border: 0 !important; }
.haken {
  flex: none; width: 24px; height: 24px; margin-top: 1px; border-radius: 50%;
  border: 2px solid var(--linie); background: transparent; display: grid; place-items: center; padding: 0;
}
.haken:hover { border-color: var(--akzent); }
.haken svg { width: 14px; height: 14px; stroke-width: 3; opacity: 0; }
.haken:hover svg { opacity: .35; }
.aufgabe-text { flex: 1; min-width: 0; }
.aufgabe-meta { display: block; font-size: 12px; color: var(--text-leise); }
.aufgabe-meta.ueberfaellig { color: var(--warnung); }
.prio { color: var(--warnung); font-weight: 700; margin-right: 4px; }
.mail-kopf { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.mail-kopf strong { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mail-zeit { flex: none; }
.mail-betreff { display: block; }
.mail-zusammenfassung {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 2px;
}
.mail-leiste { display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.mail-leiste .text-knopf { padding: 4px 0 0; font-size: 14px; }
.antippbar { cursor: pointer; }

/* Mail-Ansicht (Vollbild ueber der App) */
.mail-ansicht {
  position: fixed; inset: 0; z-index: 5;
  max-width: 720px; margin: 0 auto;
  display: grid; grid-template-rows: auto 1fr auto;
  height: 100dvh; background: var(--hintergrund);
}
.mail-ansicht .kopf h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-inhalt { overflow-y: auto; overscroll-behavior: contain; padding: 14px 16px 20px; }
.mail-meta {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 0 0 12px;
  font-size: 13px; color: var(--text-leise);
}
.mail-meta dt { font-weight: 600; }
.mail-meta dd { margin: 0; overflow-wrap: anywhere; color: var(--text); }
.mail-hinweis {
  font-size: 13px; color: var(--text-leise); background: var(--akzent-zart);
  border-radius: 10px; padding: 8px 12px; margin: 0 0 12px;
}
.mail-text {
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px;
  padding: 14px 16px; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5;
}
.mail-text a { color: var(--akzent); }
.mail-anhaenge { font-size: 14px; color: var(--text-leise); margin: 10px 2px 0; overflow-wrap: anywhere; }
.mail-entwurf-box { margin-top: 12px; }
.mail-entwurf-box summary { cursor: pointer; color: var(--akzent); font-weight: 600; padding: 6px 2px; }
.mail-antwort {
  background: var(--flaeche); border-top: 1px solid var(--linie);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
.mail-antwort textarea {
  font: inherit; color: var(--text); resize: vertical; min-height: 64px; max-height: 40vh;
  padding: 10px 14px; border-radius: 14px; border: 1px solid var(--linie); background: var(--hintergrund); outline: none;
}
.mail-antwort textarea:focus { border-color: var(--akzent); }
.mail-knoepfe { display: flex; gap: 8px; }
.knopf-haupt, .knopf-zweit { border-radius: 12px; padding: 11px 14px; font-weight: 600; }
.knopf-haupt { flex: 1; border: 0; background: var(--akzent); color: var(--akzent-text); }
.knopf-zweit { border: 1px solid var(--akzent); background: transparent; color: var(--akzent); }

.mail-entwurf { font-size: 12px; color: var(--akzent); background: var(--akzent-zart); border-radius: 999px; padding: 2px 8px; margin-right: auto; }
.hinweis { font-size: 13px; color: var(--text-leise); margin: 6px 0 0; }
.text-knopf { border: 0; background: transparent; color: var(--akzent); font-weight: 600; padding: 6px 0; }

/* Anmeldung */
.anmeldung {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 16px;
  background: var(--hintergrund);
}
.anmeldung-karte {
  width: 100%; max-width: 380px; text-align: center;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 18px; padding: 28px 22px;
}
.anmeldung-karte h2 { margin: 4px 0 8px; }
.anmeldung-karte p { margin: 0 0 12px; }
.klein { font-size: 14px; color: var(--text-leise); }
#anmeldung-form { display: flex; flex-direction: column; gap: 8px; }
#anmeldung-form input {
  font: inherit; padding: 11px 14px; border-radius: 10px;
  border: 1px solid var(--linie); background: var(--hintergrund); color: var(--text);
}
#anmeldung-form button {
  border: 0; border-radius: 10px; padding: 11px; font-weight: 600;
  background: var(--akzent); color: var(--akzent-text);
}
.fehler { color: var(--warnung); font-size: 14px; margin: 10px 0 0; }

/* Installieren-Hinweis (iPhone) */
.installieren {
  position: fixed; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom));
  max-width: 480px; margin: 0 auto;
  background: var(--text); color: var(--hintergrund);
  border-radius: 14px; padding: 14px 16px 8px;
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
  font-size: 14px;
}
.installieren p { margin: 0 0 6px; }
.installieren ol { margin: 0; padding-left: 20px; display: grid; gap: 6px; }
.installieren #installieren-kopieren {
  border: 0; border-radius: 8px; padding: 6px 12px; font-weight: 600;
  background: var(--akzent); color: var(--akzent-text);
}
.installieren input { width: 100%; margin-top: 8px; font: 13px/1.3 ui-monospace, Menlo, monospace; padding: 6px 8px; border-radius: 6px; border: 0; }
.installieren .text-knopf { color: var(--akzent-zart); display: block; margin-left: auto; }
.zweitrangig {
  border: 1px solid var(--akzent) !important; background: transparent !important; color: var(--akzent) !important;
}
#anmeldung-feld { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }

/* Toast */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(132px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--hintergrund);
  padding: 10px 16px; border-radius: 12px; font-size: 14px;
  display: flex; gap: 14px; align-items: center; max-width: calc(100% - 32px);
  box-shadow: 0 6px 24px rgba(0,0,0,.18);
}
.toast button { border: 0; background: transparent; color: var(--akzent-zart); font-weight: 700; padding: 0; }
