/* Bewusst einfach gehalten, damit Safari 12 (iOS 12) alles versteht. */
:root {
  --grund: #f6f4ef;
  --karte: #ffffff;
  --text: #1f2328;
  --leise: #6a6f76;
  --linie: #ddd8cc;
  --akzent: #b45a3c;
  --akzent-text: #ffffff;
  --nutzer: #e9e4d8;
  --code: #f0ede6;
  --fehler: #b42318;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--grund);
  color: var(--text);
  font-family: -apple-system, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.versteckt { display: none !important; }

.knopf {
  font: inherit; font-size: 16px;
  padding: 9px 14px;
  border: 1px solid var(--linie);
  border-radius: 10px;
  background: var(--karte);
  color: var(--text);
  -webkit-appearance: none;
}
.knopf.haupt { background: var(--akzent); color: var(--akzent-text); border-color: var(--akzent); }
.knopf.klein { padding: 5px 10px; font-size: 14px; }
.knopf:disabled { opacity: .5; }

/* Anmeldung */
.anmeldung { display: -webkit-box; display: flex; align-items: center; justify-content: center; height: 100%; padding: 16px; }
.karte { background: var(--karte); border: 1px solid var(--linie); border-radius: 16px; padding: 28px; width: 100%; max-width: 420px; }
.karte h1 { margin: 0 0 6px; font-size: 26px; }
.karte input { width: 100%; font: inherit; padding: 12px; margin: 12px 0; border: 1px solid var(--linie); border-radius: 10px; -webkit-appearance: none; }
.karte .knopf { width: 100%; }
.fehler { color: var(--fehler); min-height: 1.5em; }

/* Hauptansicht */
.app { display: flex; flex-direction: column; height: 100%; }
.kopf {
  display: flex; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top));
  border-bottom: 1px solid var(--linie);
  background: var(--karte);
}
.kopf .knopf, .kopf select { margin-right: 8px; }
.kopf select { font: inherit; font-size: 16px; padding: 8px; border: 1px solid var(--linie); border-radius: 10px; background: var(--karte); max-width: 290px; }
.kosten { margin-left: auto; color: var(--leise); font-size: 15px; white-space: nowrap; }

.liste {
  position: absolute; top: 62px; left: 0; bottom: 0; width: 340px; max-width: 90%;
  background: var(--karte); border-right: 1px solid var(--linie);
  overflow-y: auto; -webkit-overflow-scrolling: touch; z-index: 5;
  box-shadow: 4px 0 16px rgba(0,0,0,.08);
}
.liste-kopf { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--linie); }
.liste ul { list-style: none; margin: 0; padding: 0; }
.liste li { display: flex; align-items: center; border-bottom: 1px solid var(--linie); }
.liste li a { flex: 1; padding: 12px 14px; color: var(--text); text-decoration: none; font-size: 16px; }
.liste li a small { display: block; color: var(--leise); font-size: 13px; }
.liste li.aktiv { background: var(--nutzer); }
.liste li button { margin-right: 10px; }

.verlauf { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; }
.leer { text-align: center; color: var(--leise); margin-top: 18vh; }
.nachricht { max-width: 900px; margin: 0 auto 14px; padding: 12px 16px; border-radius: 14px; word-wrap: break-word; overflow-wrap: break-word; }
.nachricht.nutzer { background: var(--nutzer); white-space: pre-wrap; margin-right: 0; max-width: 80%; }
.nachricht.claude { background: var(--karte); border: 1px solid var(--linie); }
.nachricht.fehler-box { background: #fdecea; color: var(--fehler); border: 1px solid #f5c2bd; }
.nachricht .info { color: var(--leise); font-size: 13px; margin-top: 6px; }
.nachricht.denkt { color: var(--leise); font-style: italic; }

.nachricht h1, .nachricht h2, .nachricht h3, .nachricht h4 { margin: 12px 0 6px; line-height: 1.3; }
.nachricht h1 { font-size: 22px; } .nachricht h2 { font-size: 20px; } .nachricht h3, .nachricht h4 { font-size: 18px; }
.nachricht p { margin: 0 0 10px; }
.nachricht ul, .nachricht ol { margin: 0 0 10px; padding-left: 24px; }
.nachricht code { background: var(--code); padding: 1px 5px; border-radius: 5px; font-family: Menlo, Courier, monospace; font-size: 15px; }
.nachricht pre { background: var(--code); padding: 10px; border-radius: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.nachricht pre code { background: none; padding: 0; }
.nachricht table { border-collapse: collapse; margin: 6px 0 12px; display: block; overflow-x: auto; }
.nachricht th, .nachricht td { border: 1px solid var(--linie); padding: 5px 9px; text-align: left; font-size: 16px; }
.nachricht th { background: var(--code); }
.nachricht blockquote { margin: 0 0 10px; padding-left: 12px; border-left: 3px solid var(--linie); color: var(--leise); }
.nachricht a { color: var(--akzent); }

.eingabe {
  display: flex; align-items: flex-end;
  padding: 10px 14px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--linie); background: var(--karte);
}
.eingabe textarea {
  flex: 1; font: inherit; font-size: 18px; padding: 10px 12px; margin-right: 10px;
  border: 1px solid var(--linie); border-radius: 12px; resize: none; max-height: 40vh;
  -webkit-appearance: none;
}

/* ---- Version 2: Anhänge, Dateien, Protokoll ---- */
.eingabe-bereich { border-top: 1px solid var(--linie); background: var(--karte); }
.eingabe-bereich .eingabe { border-top: 0; }
#dateiwahl { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.anhang-knopf { margin-right: 8px; font-size: 20px; padding: 7px 11px; cursor: pointer; }
.auswahl { display: flex; flex-wrap: wrap; padding: 8px 14px 0; }
.chip {
  display: inline-flex; align-items: center; margin: 0 8px 6px 0; padding: 4px 6px 4px 10px;
  border: 1px solid var(--linie); border-radius: 16px; background: var(--grund); font-size: 14px; max-width: 100%;
}
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 230px; }
.chip button { border: 0; background: none; font-size: 18px; color: var(--leise); padding: 0 4px 0 8px; }
.chip.bereitet { opacity: .6; }
.leise { color: var(--leise); font-size: 13px; }

.anhaenge { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: flex-start; }
.anhaenge img { max-width: 160px; max-height: 160px; border-radius: 8px; margin: 0 8px 6px 0; border: 1px solid var(--linie); background: #fff; }
.anhang-name { display: inline-block; margin: 0 8px 6px 0; padding: 3px 9px; border-radius: 12px; background: rgba(255,255,255,.6); font-size: 14px; white-space: normal; }

.datei-karte { border: 1px solid var(--linie); border-radius: 10px; margin: 6px 0 12px; overflow: hidden; }
.datei-kopf { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px; background: var(--code); }
.datei-kopf span { font-weight: 600; font-size: 16px; overflow: hidden; text-overflow: ellipsis; margin-right: 8px; }
.datei-kopf a.knopf { text-decoration: none; color: var(--text); white-space: nowrap; }
.datei-karte details { padding: 6px 10px; }
.datei-karte summary { color: var(--leise); font-size: 14px; cursor: pointer; }
.datei-karte pre { margin: 8px 0 4px; max-height: 320px; overflow: auto; }

.liste-werkzeuge { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--linie); }
.protokoll { max-width: 900px; margin: 0 auto; background: var(--karte); border: 1px solid var(--linie); border-radius: 14px; padding: 12px 16px; }
.protokoll h2 { margin: 4px 0 10px; font-size: 20px; }
.protokoll table { border-collapse: collapse; width: 100%; font-size: 15px; }
.protokoll th, .protokoll td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--linie); vertical-align: top; }
.protokoll .gut { color: #2f7d4f; } .protokoll .schlecht { color: var(--fehler); font-weight: 600; }
.protokoll td.geraet { color: var(--leise); font-size: 13px; }

/* ---- Version 2.1: Ladeanzeige und sichtbare Fehler ---- */
.laedt { text-align: center; color: var(--leise); margin-top: 30vh; }
.ladefehler { display: none; white-space: pre-wrap; margin: 16px; padding: 12px 16px; border-radius: 12px;
  background: #fdecea; color: var(--fehler); border: 1px solid #f5c2bd; font-size: 15px; }
