:root {
  --bg: #f5f6f8;
  --flaeche: #ffffff;
  --flaeche-2: #eef1f5;
  --text: #15181d;
  --text-2: #5b6370;
  --linie: #dde1e7;
  --akzent: #1f5fd1;
  --akzent-text: #ffffff;
  --rot: #d9412b;
  --warn-bg: #fff4dc;
  --warn-text: #7a4b00;
  --ok: #1d8a4e;
  --s0: #9aa3af; --s1: #2f9e5b; --s2: #6aa82d; --s3: #c9a100; --s4: #e08a00;
  --s5: #e0611b; --s6: #d43f2a; --s7: #b0231a; --s8: #6b0f0f;
  --radius: 14px;
  --schatten: 0 1px 2px rgba(15, 23, 42, .06), 0 2px 8px rgba(15, 23, 42, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --flaeche: #181c22; --flaeche-2: #212730; --text: #e9edf2; --text-2: #9aa4b1;
    --linie: #2b323c; --akzent: #5b8ff0; --akzent-text: #0b1220; --rot: #f06a54;
    --warn-bg: #3a2c0d; --warn-text: #f5d38a; --ok: #4cc386;
    --schatten: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --flaeche: #181c22; --flaeche-2: #212730; --text: #e9edf2; --text-2: #9aa4b1;
  --linie: #2b323c; --akzent: #5b8ff0; --akzent-text: #0b1220; --rot: #f06a54;
  --warn-bg: #3a2c0d; --warn-text: #f5d38a; --ok: #4cc386;
  --schatten: none; color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
button, input, select, textarea { font: inherit; color: inherit; }

/* Kopfzeile */
.kopf {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--flaeche); border-bottom: 1px solid var(--linie);
}
.kopf h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kopf-zurueck, .kopf-knopf {
  border: 0; background: transparent; font-size: 26px; line-height: 1; padding: 4px 8px; margin: -4px -8px;
  color: var(--akzent); cursor: pointer; min-width: 40px; min-height: 40px;
}
.kopf-knopf { font-size: 22px; }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 120px; }

/* Bausteine */
.karte { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); box-shadow: var(--schatten); padding: 14px 16px; margin-bottom: 12px; }
.abschnitt { margin: 22px 0 8px; font-size: 13px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .04em; }
.leise { color: var(--text-2); font-size: 14px; }
.zeile { display: flex; align-items: center; gap: 10px; }
.wachsen { flex: 1; min-width: 0; }
.stapel > * + * { margin-top: 10px; }
.trenner { height: 1px; background: var(--linie); margin: 12px 0; }

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--linie);
  background: var(--flaeche); cursor: pointer; font-weight: 550; color: var(--text); text-decoration: none;
}
.knopf.primaer { background: var(--akzent); border-color: var(--akzent); color: var(--akzent-text); }
.knopf.gefahr { color: var(--rot); }
.knopf.klein { min-height: 34px; padding: 0 12px; font-size: 14px; }
.knopf.breit { width: 100%; }
.knopf:disabled { opacity: .5; cursor: default; }
.knopf-reihe { display: flex; flex-wrap: wrap; gap: 8px; }

label.feld { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--linie); background: var(--flaeche); color: var(--text);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus, .knopf:focus-visible { outline: 2px solid var(--akzent); outline-offset: 1px; }

/* Stufen-Badge */
.stufe {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px;
  font-weight: 700; font-size: 14px; color: #fff; background: var(--s0); flex: none;
}
.stufe.gross { min-width: 44px; height: 44px; border-radius: 22px; font-size: 20px; }
.stufe[data-s="1"] { background: var(--s1); } .stufe[data-s="2"] { background: var(--s2); }
.stufe[data-s="3"] { background: var(--s3); color: #1b1600; } .stufe[data-s="4"] { background: var(--s4); color: #1f1300; }
.stufe[data-s="5"] { background: var(--s5); } .stufe[data-s="6"] { background: var(--s6); }
.stufe[data-s="7"] { background: var(--s7); } .stufe[data-s="8"] { background: var(--s8); }

.chip { white-space: nowrap; flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--flaeche-2); font-size: 13px; color: var(--text-2); }
.chip.warn { background: var(--warn-bg); color: var(--warn-text); }
.chip.ok { color: var(--ok); }

/* Liste */
.liste { background: var(--flaeche); border: 1px solid var(--linie); border-radius: var(--radius); overflow: hidden; box-shadow: var(--schatten); }
.liste-eintrag { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border: 0; border-bottom: 1px solid var(--linie); width: 100%; text-align: left; background: transparent; cursor: pointer; min-height: 60px; }
.liste-eintrag:last-child { border-bottom: 0; }
.liste-eintrag:hover { background: var(--flaeche-2); }
.liste-eintrag .titel { font-weight: 600; }
.liste-eintrag .pfeil { color: var(--text-2); font-size: 20px; }
.inaktiv { opacity: .55; }

/* Themen-Stand */
.themen { display: flex; flex-wrap: wrap; gap: 8px; }
.thema-stand { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; background: var(--flaeche); border: 1px solid var(--linie); font-size: 14px; cursor: pointer; }
.thema-stand.aktiv { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent) inset; }

/* Timeline */
.eintrag-karte .kopfzeile { display: flex; align-items: flex-start; gap: 10px; }
.eintrag-karte .datum { font-size: 13px; color: var(--text-2); }
.eintrag-karte .thema { font-weight: 600; }
.eintrag-karte p { margin: 8px 0 0; white-space: pre-wrap; }
.eintrag-karte .gespraech { margin-top: 10px; padding: 10px 12px; background: var(--flaeche-2); border-radius: 10px; font-size: 15px; }
.eintrag-karte .knopf-reihe { margin-top: 12px; }

/* Mikrofon */
.mikro-leiste {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  padding: 12px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex; justify-content: center; gap: 12px; align-items: center;
}
.mikro {
  width: 76px; height: 76px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--rot); color: #fff; box-shadow: 0 6px 18px rgba(217, 65, 43, .35);
  display: inline-flex; align-items: center; justify-content: center;
}
.mikro svg { width: 34px; height: 34px; }
.mikro.aufnahme { animation: puls 1.2s ease-in-out infinite; }
@keyframes puls { 0%,100% { box-shadow: 0 0 0 0 rgba(217,65,43,.5); } 50% { box-shadow: 0 0 0 16px rgba(217,65,43,0); } }
.tipp-knopf { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--linie); background: var(--flaeche); cursor: pointer; font-size: 20px; }

/* Dialog (Bottom-Sheet auf Handy) */
.dialog-huelle { position: fixed; inset: 0; z-index: 20; background: rgba(10, 14, 20, .45); display: flex; align-items: flex-end; justify-content: center; }
.dialog {
  background: var(--bg); width: 100%; max-width: 720px; max-height: 92vh; overflow: auto;
  border-radius: 18px 18px 0 0; padding: 18px 16px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 760px) { .dialog-huelle { align-items: center; } .dialog { border-radius: 18px; } }
.dialog h2 { margin: 0 0 12px; font-size: 20px; }
.dialog .schliessen { float: right; border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer; color: var(--text-2); padding: 0 4px; }

.aufnahme-anzeige { text-align: center; padding: 24px 0; }
.aufnahme-anzeige .zeit { font-size: 40px; font-variant-numeric: tabular-nums; font-weight: 300; margin: 12px 0 18px; }
.lade { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--linie); border-top-color: var(--akzent); border-radius: 50%; animation: drehen .8s linear infinite; vertical-align: middle; }
@keyframes drehen { to { transform: rotate(360deg); } }

.empfehlung { border-left: 4px solid var(--akzent); }
.empfehlung h3 { margin: 0; font-size: 17px; }
.empfehlung ul, .empfehlung ol { margin: 6px 0 0; padding-left: 20px; }
.empfehlung li { margin: 3px 0; }
.hinweis { background: var(--warn-bg); color: var(--warn-text); border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.historie-zeile { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--linie); font-size: 14px; }
.historie-zeile:last-child { border-bottom: 0; }

.wahl { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.wahl input { position: absolute; opacity: 0; pointer-events: none; }
.wahl label { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 48px; padding: 6px 10px; border: 1px solid var(--linie); border-radius: 10px; background: var(--flaeche); cursor: pointer; font-size: 14px; font-weight: 550; }
.wahl input:checked + label { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent) inset; color: var(--akzent); }

details summary { cursor: pointer; color: var(--text-2); font-size: 14px; }
details p { white-space: pre-wrap; }

.toast { position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30; background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px; max-width: calc(100% - 32px); }
.toast.fehler { background: var(--rot); color: #fff; }

.login { max-width: 360px; margin: 12vh auto 0; text-align: center; }
.login img { width: 72px; height: 72px; }
.leer { text-align: center; padding: 28px 12px; color: var(--text-2); }
.status-punkt { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--s0); margin-right: 6px; }
.status-punkt.ok { background: var(--ok); } .status-punkt.nein { background: var(--rot); }
