:root {
  --grund: #f6f5f2;
  --flaeche: #ffffff;
  --flaeche-2: #eeece7;
  --text: #1b1c1f;
  --leise: #6d6f75;
  --linie: #e1ded7;
  --akzent: #d13a27;
  --akzent-text: #ffffff;
  --ich: #d13a27;
  --ich-text: #ffffff;
  --rot: #b42318;
  --gruen: #1d7a46;
  --schatten: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --grund: #16171a;
    --flaeche: #202226;
    --flaeche-2: #2a2c31;
    --text: #ececea;
    --leise: #9a9ca3;
    --linie: #33363c;
    --akzent: #ff6b50;
    --akzent-text: #1e0a06;
    --ich: #b8321f;
    --ich-text: #fff6f3;
    --rot: #ef6b61;
    --gruen: #5fd08f;
    --schatten: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --grund: #16171a; --flaeche: #202226; --flaeche-2: #2a2c31; --text: #ececea; --leise: #9a9ca3;
  --linie: #33363c; --akzent: #ff6b50; --akzent-text: #1e0a06; --ich: #b8321f; --ich-text: #fff6f3; --rot: #ef6b61; --gruen: #5fd08f;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--grund);
  color: var(--text);
  font: 17px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
.leise { color: var(--leise); font-size: 15px; }
.fehler { color: var(--rot); min-height: 1.4em; font-size: 15px; }

/* ── Anmeldung ── */
.tor { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.tor-karte { width: 100%; max-width: 380px; text-align: center; }
.tor-logo { border-radius: 18px; box-shadow: var(--schatten); }
.tor h1 { margin: 16px 0 4px; font-size: 28px; }
.einrichten { display: grid; gap: 12px; margin-top: 24px; }
.einrichten input {
  font: inherit; padding: 14px; border-radius: 12px; border: 1px solid var(--linie);
  background: var(--flaeche); color: var(--text); text-align: center; letter-spacing: .05em;
}
.knopf { border: 0; border-radius: 14px; padding: 15px 18px; width: 100%; margin-top: 20px; font-weight: 600; }
.knopf.haupt { background: var(--akzent); color: var(--akzent-text); }
.einrichten .knopf { margin-top: 0; }

/* ── App-Gerüst ── */
.app { height: 100%; display: flex; flex-direction: column; }
.kopf {
  position: relative; display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px; background: var(--grund);
  border-bottom: 1px solid var(--linie);
}
.kopf h1 { font-size: 20px; margin: 0; }
.symbol-knopf { background: none; border: 0; padding: 8px; font-size: 20px; line-height: 1; border-radius: 10px; }
.menue {
  position: absolute; right: 12px; top: calc(100% - 4px); z-index: 5; min-width: 250px;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 14px; box-shadow: var(--schatten);
  display: grid; overflow: hidden;
}
.menue button { background: none; border: 0; text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--linie); }
.menue button:last-child { border-bottom: 0; color: var(--rot); }
.hinweis {
  margin: 10px 16px 0; padding: 12px 40px 12px 14px; position: relative; border-radius: 12px;
  background: var(--flaeche-2); font-size: 15px;
}
.hinweis-zu { position: absolute; right: 6px; top: 6px; background: none; border: 0; padding: 6px; }

.ansicht { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ── Gespräch ── */
.verlauf { display: flex; flex-direction: column; gap: 10px; padding: 16px; max-width: 760px; margin: 0 auto; }
.blase {
  max-width: 85%; padding: 10px 14px; border-radius: 18px; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--flaeche); box-shadow: var(--schatten);
}
.blase.ich { align-self: flex-end; background: var(--ich); color: var(--ich-text); border-bottom-right-radius: 6px; }
.blase.er { align-self: flex-start; border-bottom-left-radius: 6px; }
.blase.wartet { color: var(--leise); font-style: italic; }
.blase.fehler-blase { color: var(--rot); }
.blase .zeit { display: block; font-size: 12px; opacity: .65; margin-top: 4px; }
.leer { text-align: center; color: var(--leise); padding: 40px 16px; }

/* ── Eingabe ── */
.fuss { background: var(--grund); border-top: 1px solid var(--linie); padding-bottom: env(safe-area-inset-bottom); }
.eingabe, .aufnahme { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; max-width: 760px; margin: 0 auto; }
.eingabe textarea {
  flex: 1; resize: none; max-height: 160px; font: inherit; padding: 10px 14px; border-radius: 20px;
  border: 1px solid var(--linie); background: var(--flaeche); color: var(--text);
}
.anhang { align-self: center; }
.rund { width: 44px; height: 44px; border-radius: 50%; border: 0; flex: none; font-size: 20px; display: grid; place-items: center; }
.senden, .mikro { background: var(--akzent); color: var(--akzent-text); }
.mikro.an { background: var(--rot); color: #fff; }
.aufnahme { align-items: center; }
.aufnahme .punkt { width: 12px; height: 12px; border-radius: 50%; background: var(--rot); animation: puls 1s infinite; }
.aufnahme .leise { flex: 1; }
#aufnahme-zeit { font-variant-numeric: tabular-nums; font-weight: 600; }
@keyframes puls { 50% { opacity: .3; } }

.reiter { display: flex; border-top: 1px solid var(--linie); }
.reiter button {
  flex: 1; background: none; border: 0; padding: 6px 0 4px; display: grid; justify-items: center;
  font-size: 20px; color: var(--leise); filter: grayscale(1); opacity: .7;
}
.reiter button span { font-size: 11px; }
.reiter button.an { color: var(--akzent); filter: none; opacity: 1; }

/* ── Listen ── */
.liste { padding: 8px 16px 24px; }
.liste > * { max-width: 760px; margin-left: auto; margin-right: auto; }
.liste h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--leise); margin: 22px 0 8px; }
.punkt-liste { list-style: none; margin: 0; padding: 0; background: var(--flaeche); border-radius: 14px; box-shadow: var(--schatten); }
.punkt-liste li { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--linie); align-items: flex-start; }
.punkt-liste li:last-child { border-bottom: 0; }
.punkt-liste .info { flex: 1; min-width: 0; }
.punkt-liste .meta { font-size: 13px; color: var(--leise); margin-top: 2px; }
.punkt-liste .meta.faellig { color: var(--rot); }
.haken {
  flex: none; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%; border: 2px solid var(--linie);
  background: none; padding: 0;
}
.haken:active, .haken.weg { background: var(--akzent); border-color: var(--akzent); }
.suche {
  display: block; width: 100%; font: inherit; padding: 10px 14px; margin: 8px auto 4px; border-radius: 12px;
  border: 1px solid var(--linie); background: var(--flaeche); color: var(--text);
}
.dok a { color: inherit; text-decoration: none; display: block; }
.dok .titel { font-weight: 600; }
.dok .zusammenfassung { font-size: 14px; color: var(--leise); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* ── Verbindungen ── */
.einleitung { margin: 14px auto 4px; }
.verbindung { display: grid; gap: 10px; background: var(--flaeche); border-radius: 14px; box-shadow: var(--schatten); padding: 4px 14px 14px; margin-top: 14px; }
.verbindung h2 { margin: 12px 0 0; text-transform: none; letter-spacing: 0; font-size: 17px; color: var(--text); display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.verbindung .leise { margin: 0; }
.verbindung input { font: inherit; padding: 12px; border-radius: 10px; border: 1px solid var(--linie); background: var(--grund); color: var(--text); width: 100%; }
.verbindung .knoepfe { display: flex; gap: 8px; }
.verbindung .knopf { margin-top: 0; }
.verbindung .knopf.trennen { background: none; border: 1px solid var(--linie); width: auto; color: var(--rot); font-weight: 500; }
.verbindung .meldung { margin: 0; font-size: 15px; min-height: 1.2em; }
.verbindung .meldung.fehler { color: var(--rot); }
.zustand { font-size: 13px; font-weight: 500; color: var(--leise); }
.zustand.an { color: var(--gruen); }
.geschafft { background: var(--flaeche-2); border-radius: 14px; padding: 12px 14px; margin-top: 14px; }
.geschafft strong { font-size: 17px; }
