:root {
  --bg: #0E1116; --flaeche: #171C24; --flaeche2: #1F2630; --rand: #2A3340;
  --text: #E8EDF4; --leise: #93A1B5; --akzent: #4ADE80; --akzent-dunkel: #15803D;
  --du: #2563EB; --warn: #F87171;
  --rund: 16px; --kopf: 54px;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F6F8FB; --flaeche: #FFFFFF; --flaeche2: #EDF1F7; --rand: #DCE3ED;
    --text: #121923; --leise: #5B6B80; --akzent: #16A34A; --akzent-dunkel: #15803D;
    --du: #2563EB;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
#app { height: 100dvh; display: flex; flex-direction: column; }

/* ---------- Anmeldung ---------- */
.tor { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.tor-box { width: 100%; max-width: 380px; }
.marke { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.marke-kreis { width: 46px; height: 46px; border-radius: 14px; background: linear-gradient(145deg, var(--akzent), var(--akzent-dunkel)); display: grid; place-items: center; font-size: 24px; }
.marke h1 { font-size: 26px; margin: 0; letter-spacing: -0.5px; }
.tor p.unter { color: var(--leise); margin: 0 0 22px; font-size: 15px; }
.feld { margin-bottom: 12px; }
.feld label { display: block; font-size: 13px; color: var(--leise); margin-bottom: 5px; }
.eingabe {
  width: 100%; padding: 13px 14px; font-size: 16px; color: var(--text);
  background: var(--flaeche); border: 1px solid var(--rand); border-radius: 12px; outline: none;
}
.eingabe:focus { border-color: var(--akzent); }
.knopf {
  width: 100%; padding: 14px; font-size: 16px; font-weight: 650; border: none; border-radius: 12px;
  background: var(--akzent); color: #06240F; cursor: pointer;
}
.knopf:disabled { opacity: .55; }
.knopf.leise { background: transparent; color: var(--leise); font-weight: 500; padding: 10px; }
.fehler { color: var(--warn); font-size: 14px; min-height: 20px; margin: 8px 0 0; }

/* ---------- Kopf ---------- */
.kopf {
  height: calc(var(--kopf) + env(safe-area-inset-top)); padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 10px; flex: 0 0 auto;
  background: color-mix(in srgb, var(--bg) 86%, transparent); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--rand); position: sticky; top: 0; z-index: 10;
}
.kopf h1 { font-size: 17px; margin: 0; flex: 1; letter-spacing: -0.3px; }
.kopf .agent { font-size: 12px; color: var(--akzent); font-weight: 600; display: block; }
.ikon {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--rand);
  background: var(--flaeche); color: var(--text); font-size: 16px; display: grid; place-items: center; cursor: pointer;
}
.ikon.aktiv { border-color: var(--akzent); color: var(--akzent); }

/* ---------- Chat ---------- */
.verlauf { flex: 1 1 auto; overflow-y: auto; padding: 16px 12px 8px; -webkit-overflow-scrolling: touch; }
.blase { max-width: 86%; padding: 11px 14px; border-radius: 18px; margin-bottom: 10px; word-wrap: break-word; }
.blase.du { margin-left: auto; background: var(--du); color: #fff; border-bottom-right-radius: 5px; }
.blase.coach { background: var(--flaeche); border: 1px solid var(--rand); border-bottom-left-radius: 5px; }
.blase img { width: 100%; border-radius: 12px; margin-bottom: 8px; display: block; }
.blase p { margin: 0 0 8px; }
.blase p:last-child { margin-bottom: 0; }
.blase h3 { font-size: 15px; margin: 12px 0 6px; }
.blase ul, .blase ol { margin: 6px 0; padding-left: 20px; }
.blase li { margin-bottom: 3px; }
.blase table { width: 100%; border-collapse: collapse; font-size: 14px; margin: 8px 0; }
.blase th, .blase td { text-align: left; padding: 5px 7px; border-bottom: 1px solid var(--rand); }
.blase code { background: var(--flaeche2); padding: 1px 5px; border-radius: 5px; font-size: 14px; }
.agent-name { font-size: 12px; font-weight: 700; color: var(--akzent); display: block; margin-bottom: 4px; letter-spacing: .3px; }
.tippt span { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--leise); margin-right: 4px; animation: hopf 1.2s infinite; }
.tippt span:nth-child(2) { animation-delay: .2s; } .tippt span:nth-child(3) { animation-delay: .4s; }
@keyframes hopf { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
.hinweis { text-align: center; color: var(--leise); font-size: 13px; margin: 10px 0; }
.hinweis b { color: var(--akzent); }

/* ---------- Eingabe ---------- */
.leiste {
  flex: 0 0 auto; padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--rand); background: var(--bg);
  display: flex; gap: 8px; align-items: flex-end;
}
.leiste textarea {
  flex: 1; resize: none; max-height: 130px; padding: 11px 14px; font: inherit; font-size: 16px;
  color: var(--text); background: var(--flaeche); border: 1px solid var(--rand); border-radius: 20px; outline: none;
}
.leiste textarea:focus { border-color: var(--akzent); }
.rund {
  width: 42px; height: 42px; flex: 0 0 auto; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; font-size: 19px; background: var(--flaeche2); color: var(--text);
}
.rund.senden { background: var(--akzent); color: #06240F; }
.rund:disabled { opacity: .4; }
.vorschau { position: relative; margin: 0 10px 6px; }
.vorschau img { width: 76px; height: 76px; object-fit: cover; border-radius: 12px; border: 1px solid var(--rand); }
.vorschau button { position: absolute; top: -6px; left: 62px; width: 24px; height: 24px; border-radius: 50%; border: none; background: var(--warn); color: #fff; cursor: pointer; font-size: 13px; }

/* ---------- Seiten ---------- */
.seite { flex: 1 1 auto; overflow-y: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }
.karte { background: var(--flaeche); border: 1px solid var(--rand); border-radius: var(--rund); padding: 16px; margin-bottom: 14px; }
.karte h2 { font-size: 16px; margin: 0 0 10px; }
.akte-text { white-space: pre-wrap; font-size: 15px; line-height: 1.6; }
.akte-text h1, .akte-text h2, .akte-text h3 { font-size: 16px; margin: 14px 0 6px; color: var(--akzent); }
.leer { color: var(--leise); text-align: center; padding: 40px 20px; }
.wert-zeile { display: flex; justify-content: space-between; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--rand); font-size: 15px; }
.wert-zeile:last-child { border-bottom: none; }
.wert-zeile .d { color: var(--leise); font-size: 13px; }
.wert-zeile b { font-variant-numeric: tabular-nums; }
.menue { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 50; display: grid; place-items: end center; }
.menue-box { width: 100%; max-width: 440px; background: var(--flaeche); border-radius: 20px 20px 0 0; padding: 10px 10px calc(14px + env(safe-area-inset-bottom)); }
.menue-box button { width: 100%; text-align: left; padding: 15px; font-size: 16px; color: var(--text); background: none; border: none; border-radius: 12px; cursor: pointer; }
.menue-box button:active { background: var(--flaeche2); }
.menue-box button.rot { color: var(--warn); }
