:root {
  --bg: #f6f5f2; --fl: #ffffff; --text: #1d1d1b; --leise: #6b6a66; --rand: #e3e1dc;
  --akzent: #1f6f5c; --akzent-text: #ffffff; --ich: #1f6f5c; --ich-text: #ffffff; --fehler: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --fl: #1e1e1c; --text: #ecebe7; --leise: #9d9b95; --rand: #2f2f2c;
    --akzent: #4fb89a; --akzent-text: #0d1f1a; --ich: #2a5d50; --ich-text: #ecebe7; --fehler: #f2b8b5;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, textarea { font: inherit; color: inherit; }
button {
  background: var(--akzent); color: var(--akzent-text); border: 0; border-radius: 10px;
  padding: 10px 16px; cursor: pointer; font-weight: 600;
}
button:disabled { opacity: .5; cursor: default; }
button.leise { background: transparent; color: var(--leise); font-weight: 500; padding: 6px 10px; }
a { color: var(--akzent); }

/* Anmelden / einfache Seiten */
.karte { max-width: 420px; margin: 12vh auto 0; padding: 24px 16px; }
.karte h1 { margin: 0 0 8px; font-size: 28px; }
.karte p { color: var(--leise); }
.karte input {
  width: 100%; padding: 12px; border: 1px solid var(--rand); border-radius: 10px;
  background: var(--fl); margin: 8px 0 12px;
}
.karte button { width: 100%; }
.hinweis { padding: 10px 12px; border-radius: 10px; background: var(--fl); border: 1px solid var(--rand); }

/* Chat */
.app { display: flex; flex-direction: column; height: 100%; height: 100dvh; max-width: 760px; margin: 0 auto; }
header {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px;
  padding-top: max(10px, env(safe-area-inset-top)); border-bottom: 1px solid var(--rand);
}
header .titel { font-weight: 700; font-size: 18px; flex: 1; }
header .wer { color: var(--leise); font-size: 14px; }
#verlauf { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.n { max-width: 88%; padding: 10px 14px; border-radius: 16px; overflow-wrap: anywhere; }
.n.ich { align-self: flex-end; background: var(--ich); color: var(--ich-text); white-space: pre-wrap; border-bottom-right-radius: 4px; }
.n.udo { align-self: flex-start; background: var(--fl); border: 1px solid var(--rand); border-bottom-left-radius: 4px; }
.n.udo p:first-child { margin-top: 0; } .n.udo p:last-child { margin-bottom: 0; }
.n.udo table { border-collapse: collapse; font-size: 14px; display: block; overflow-x: auto; }
.n.udo th, .n.udo td { border: 1px solid var(--rand); padding: 4px 8px; text-align: left; }
.n.udo pre { overflow-x: auto; background: var(--bg); padding: 8px; border-radius: 8px; }
.n.fehler { color: var(--fehler); }
.status { color: var(--leise); font-size: 14px; align-self: flex-start; }
.status::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--akzent); margin-right: 8px; animation: puls 1s infinite alternate; }
@keyframes puls { from { opacity: .25 } to { opacity: 1 } }
.leer { color: var(--leise); text-align: center; margin: auto; padding: 24px; }
form.eingabe {
  display: flex; gap: 8px; padding: 10px 16px; padding-bottom: max(10px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--rand); background: var(--bg);
}
form.eingabe textarea {
  flex: 1; resize: none; max-height: 40vh; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--rand); background: var(--fl);
}

/* Anhänge */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 16px; }
.chips:not(:empty) { padding-top: 8px; }
.chip { display: inline-flex; align-items: center; gap: 2px; font-size: 14px; background: var(--fl);
  border: 1px solid var(--rand); border-radius: 999px; padding: 2px 4px 2px 10px; max-width: 100%; overflow-wrap: anywhere; }
.chip.fehler { color: var(--fehler); }
.chip button { padding: 2px 8px; }
.klammer { font-size: 20px; padding: 6px 8px; }
.dateien { display: flex; flex-direction: column; gap: 4px; margin-bottom: 6px; }
.n.ich .dateien a { color: var(--ich-text); text-decoration: underline; }
.n.udo a[href^="/datei/"] { font-weight: 600; }
.chip img.mini { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; margin: 0 6px 0 -6px; }
img.vorschau { max-width: 220px; max-height: 220px; border-radius: 10px; display: block; }
.klammer + .klammer { margin-left: -6px; }
