:root {
  color-scheme: light dark;
  --grund: #f6f6f4;
  --flaeche: #ffffff;
  --text: #1c1c1a;
  --leise: #6b6b66;
  --rand: #deded9;
  --ich: #dfe9f5;
  --knopf: #23507f;
  --knopftext: #ffffff;
  --warnung: #9b2c1f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --grund: #161615;
    --flaeche: #222220;
    --text: #ececea;
    --leise: #a3a39d;
    --rand: #3a3a36;
    --ich: #24384f;
    --knopf: #8db8e8;
    --knopftext: #10223a;
    --warnung: #ff9b8c;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font: 1rem/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
.karte, #chat { max-width: 40rem; margin: 0 auto; }
.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 0.75rem;
  padding: 1.25rem;
}
#start, #meldung { margin: 2rem auto; width: calc(100% - 2rem); }
h1 { font-size: 1.25rem; margin: 0 0 0.75rem; }
.klein { color: var(--leise); font-size: 0.875rem; }
.knoepfe { display: flex; gap: 0.75rem; flex-wrap: wrap; justify-content: center; padding: 0.5rem 0; }
button {
  font: inherit;
  min-height: 2.75rem;
  padding: 0.5rem 1.25rem;
  border: 1px solid var(--knopf);
  border-radius: 0.5rem;
  background: var(--knopf);
  color: var(--knopftext);
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.zweitrangig { background: transparent; color: var(--text); border-color: var(--rand); }
button.text {
  min-height: 2rem;
  padding: 0.25rem 0.5rem;
  background: none;
  border: none;
  color: var(--leise);
  text-decoration: underline;
}
a { color: inherit; }

#chat { display: flex; flex-direction: column; min-height: 100dvh; padding: 0 1rem; }
header {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  background: var(--grund);
  border-bottom: 1px solid var(--rand);
  color: var(--leise);
  font-size: 0.875rem;
}
/* Die Rückfrage zum Abbrechen braucht am Handy eine eigene Zeile. */
header { flex-wrap: wrap; }
.abbruch:has(#sicher:not([hidden])) { flex-basis: 100%; text-align: right; }
#verlauf { list-style: none; margin: 0; padding: 1rem 0 0; flex: 1; }
#verlauf li { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 0.75rem; scroll-margin-top: 3.5rem; }
#verlauf li.teilnehmerin { align-items: flex-end; }
#verlauf p {
  margin: 0;
  max-width: 85%;
  padding: 0.6rem 0.85rem;
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
#verlauf li.teilnehmerin p { background: var(--ich); }
figure { width: 100%; margin: 0 0 0.5rem; }
figcaption { color: var(--leise); font-size: 0.875rem; margin-bottom: 0.25rem; }
figure img, figure video { display: block; max-width: 100%; max-height: 70dvh; border-radius: 0.5rem; }
figure iframe {
  display: block;
  width: 100%;
  height: 55dvh;
  border: 1px solid var(--rand);
  border-radius: 0.5rem;
  background: #fff;
}
figure a { font-size: 0.875rem; color: var(--leise); }
#tippt { color: var(--leise); font-size: 0.875rem; margin: 0 0 0.5rem; }
#fehler { color: var(--warnung); margin: 0 0 0.5rem; }
#eingabe {
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  padding: 0.5rem 0 max(0.75rem, env(safe-area-inset-bottom));
  background: var(--grund);
}
.diktat { flex-basis: 100%; margin: 0; }
/* Mit Maus und Tastatur braucht es den Diktier-Hinweis beim Schreiben nicht. */
@media (pointer: fine) { .diktat { display: none; } }
textarea {
  flex: 1;
  min-width: 0;
  /* Wächst mit längeren (diktierten) Antworten mit, wo der Browser das kann. */
  field-sizing: content;
  max-height: 35dvh;
  resize: vertical;
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rand);
  border-radius: 0.5rem;
  background: var(--flaeche);
  color: inherit;
}
#ende { margin: 0 0 1.5rem; text-align: center; }
.code { font: 600 1.5rem/1.3 ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all; overflow-wrap: anywhere; }
.unsichtbar { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
/* Bei Bildern wird an den Anfang gescrollt; der Weiter-Knopf muss trotzdem sichtbar bleiben. */
#weiter-leiste { position: sticky; bottom: 0; background: var(--grund); padding-bottom: max(0.75rem, env(safe-area-inset-bottom)); }

/* Hörtest zu App-Namen */
.hoertest #frage, .hoertest #ende { margin: 1rem auto; width: calc(100% - 2rem); }
.hoertest #ende { text-align: center; }
.hoertest .frage { margin: 1.25rem 0 0.5rem; font-weight: 600; }
.hoertest .player { margin-bottom: 0.5rem; }
.hoertest audio { display: block; width: 100%; margin-top: 0.5rem; }
.hoertest .feld { display: block; margin-bottom: 0.5rem; }
.hoertest .feld span { display: block; color: var(--leise); font-size: 0.875rem; margin-bottom: 0.25rem; }
.hoertest .feld span.frage { color: var(--text); font-size: 1rem; }
.hoertest input[type=text] {
  width: 100%;
  font: inherit;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rand);
  border-radius: 0.5rem;
  background: var(--flaeche);
  color: inherit;
}
.hoertest fieldset { border: 0; margin: 1.25rem 0 0; padding: 0; min-width: 0; }
.hoertest legend { padding: 0; font-weight: 600; margin-bottom: 0.5rem; }
.hoertest .optionen { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.hoertest .optionen legend { grid-column: 1 / -1; }
.hoertest .wahl { display: flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; padding: 0 0.75rem; border: 1px solid var(--rand); border-radius: 0.5rem; background: var(--flaeche); cursor: pointer; }
.hoertest .wahl:has(input:checked) { border-color: var(--knopf); box-shadow: inset 0 0 0 1px var(--knopf); }
/* Feste Spaltenzahl: Bei auto-fit zählen die über alle Spalten reichenden Endbeschriftungen als Inhalt, dann bleiben leere Spalten stehen. */
.hoertest .skala { display: grid; grid-template-columns: repeat(var(--stufen, 7), minmax(0, 1fr)); gap: 0.25rem; }
.hoertest .skala legend, .hoertest .skala .enden { grid-column: 1 / -1; }
.hoertest .enden { display: flex; justify-content: space-between; gap: 1rem; }
.hoertest .skala .wahl { justify-content: center; padding: 0; }
.hoertest .skala .wahl input { position: absolute; opacity: 0; pointer-events: none; }
.hoertest .namen { font-size: 1.1rem; font-weight: 600; text-align: center; margin: 0 0 1rem; }
.hoertest textarea { width: 100%; field-sizing: content; }
