:root {
  --grund: #f6f7f9;
  --flaeche: #fff;
  --linie: #e2e5ea;
  --text: #1c2024;
  --still: #6b7480;
  --akzent: #2f6f4f;
  --warn: #a4552a;
  --fehler: #a32c2c;
  --rein: #fff;
  --raus: #dcf3e4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --grund: #14171a; --flaeche: #1c2024; --linie: #2c3238; --text: #e8eaed;
    --still: #98a1ac; --akzent: #63b98c; --rein: #22272c; --raus: #1f3a2c;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--grund);
  color: var(--text);
}

.mitte { display: grid; place-items: center; min-height: 100vh; padding: 2rem; }
.still { color: var(--still); }
.fehler { color: var(--fehler); }

input, textarea, button { font: inherit; }

input[type=password], input[type=search], textarea, .namensfeld {
  width: 100%;
  padding: .6rem .7rem;
  border: 1px solid var(--linie);
  border-radius: 8px;
  background: var(--flaeche);
  color: var(--text);
}

textarea { resize: vertical; }

button {
  padding: .5rem .9rem;
  border: 0;
  border-radius: 8px;
  background: var(--akzent);
  color: #fff;
  cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }
button.schlicht { background: transparent; color: var(--still); border: 1px solid var(--linie); }

/* ── Anmeldung ─────────────────────────────────────────────────────────── */
#anmeldeform {
  background: var(--flaeche);
  padding: 2rem;
  border: 1px solid var(--linie);
  border-radius: 12px;
  width: min(360px, 100%);
  display: grid;
  gap: .8rem;
}
#anmeldeform h1 { margin: 0; font-size: 1.3rem; }

/* ── Aufbau ────────────────────────────────────────────────────────────── */
#app { display: grid; grid-template-columns: 320px 1fr; height: 100vh; }

aside {
  border-right: 1px solid var(--linie);
  background: var(--flaeche);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  min-height: 0;
}
aside > header, aside > footer { padding: .8rem 1rem; display: flex; justify-content: space-between; align-items: center; }
aside > input { margin: 0 1rem .6rem; width: calc(100% - 2rem); }

#chatliste { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.chatzeile { padding: .7rem 1rem; border-top: 1px solid var(--linie); cursor: pointer; }
.chatzeile:hover { background: var(--grund); }
.chatzeile.aktiv { background: var(--grund); box-shadow: inset 3px 0 0 var(--akzent); }
.chattitel { display: flex; gap: .5rem; align-items: center; font-weight: 600; }
.vorschau { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .88rem; }
.leerhinweis { padding: 1rem; font-size: .9rem; }

.marke { font-size: .72rem; padding: .1rem .45rem; border-radius: 99px; border: 1px solid var(--linie); font-weight: 500; }
.marke.gut { color: var(--akzent); border-color: var(--akzent); }
.marke.warnung { color: var(--warn); border-color: var(--warn); }
.marke.entwurf { color: var(--warn); border-color: var(--warn); }

main { min-height: 0; overflow: hidden; }
#chat { display: grid; grid-template-rows: auto auto 1fr auto; height: 100vh; }
#chat > header { padding: .8rem 1.2rem; border-bottom: 1px solid var(--linie); display: flex; gap: 1rem; align-items: center; justify-content: space-between; background: var(--flaeche); }
.namensfeld { border: 0; background: transparent; font-weight: 600; padding: 0; }
#notizfeld { padding: .8rem 1.2rem; background: var(--flaeche); border-bottom: 1px solid var(--linie); display: grid; gap: .5rem; justify-items: start; }

/* ── Verlauf ───────────────────────────────────────────────────────────── */
#verlauf { overflow-y: auto; padding: 1.2rem; display: flex; flex-direction: column; gap: .6rem; min-height: 0; }
.blase { max-width: min(60ch, 80%); padding: .55rem .8rem; border-radius: 12px; border: 1px solid var(--linie); }
.blase p { margin: 0 0 .2rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.blase time { font-size: .72rem; color: var(--still); }
.blase img { max-width: 100%; border-radius: 8px; display: block; margin-bottom: .3rem; }
.blase audio { width: 100%; margin-bottom: .3rem; }
.blase.rein { background: var(--rein); align-self: flex-start; }
.blase.raus { background: var(--raus); align-self: flex-end; }

/* ── Entwurfskasten ────────────────────────────────────────────────────── */
#entwurfskasten { border-top: 1px solid var(--linie); padding: .8rem 1.2rem 1.2rem; background: var(--flaeche); display: grid; gap: .6rem; }
.entwurfskarte { border: 1px solid var(--warn); border-radius: 10px; padding: .7rem .9rem; display: grid; gap: .4rem; }
.entwurfskarte p { margin: 0; white-space: pre-wrap; }
.zeile { display: flex; gap: .5rem; align-items: center; }
.hinweis { font-size: .85rem; }

@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; }
  aside { display: none; }
}
