/* Home – Stil. Warmes Papier, dunkle Tinte, ein tiefes Grün als Akzent; Antworten in Serifenschrift wie ein gedruckter Text,
 * Bedienelemente in der Systemschrift. Farbe nur für Handlung (Senden, Fokus, Termin) und Fehler. */
:root {
  --bg: #f4f1ea;
  --flaeche: #fdfbf7;
  --flaeche-2: #ebe7dc;
  --nutzer: #1f1e1b;
  --nutzer-tinte: #f7f4ee;
  --tinte: #1f1e1b;
  --tinte-2: #6a655a;
  --linie: #e0dbcf;
  --akzent: #1f5c4a;
  --akzent-tinte: #f7f4ee;
  --akzent-weich: #dfece5;
  --fehler: #a8321f;
  --fehler-weich: #f8e4de;
  --ok: #1f7a55;
  --schatten: 0 1px 2px rgba(31, 30, 27, .05), 0 8px 24px rgba(31, 30, 27, .07);
  --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, Cambria, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --rand: max(18px, env(safe-area-inset-left));
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151412; --flaeche: #1d1b18; --flaeche-2: #262421; --nutzer: #efe9dc; --nutzer-tinte: #1b1a17; --tinte: #efe9dc; --tinte-2: #a29b8c;
    --linie: #2e2b26; --akzent: #79c4a5; --akzent-tinte: #12201a; --akzent-weich: #1c2d26;
    --fehler: #ff9c88; --fehler-weich: #3a211c; --ok: #6fd0a4; --schatten: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; overflow: hidden; overscroll-behavior: none; }
body {
  background: var(--bg); color: var(--tinte);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
}
button, textarea, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { display: block; }
.sym { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Rahmen: feste Höhe = sichtbares Fenster (iPhone-Tastatur), Raster statt Flex ── */
#app {
  position: fixed; left: 0; top: 0; width: 100%; height: var(--h, 100dvh);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  max-width: 760px; margin: 0 auto; right: 0; background: var(--bg);
}

/* ── Kopf: Zeichen, Name, Datum; Trennlinie erst beim Scrollen ── */
.kopf {
  display: flex; align-items: center; gap: 11px;
  padding: calc(10px + env(safe-area-inset-top)) calc(var(--rand) - 4px) 10px var(--rand);
  background: var(--bg); border-bottom: 1px solid transparent; transition: border-color .2s;
}
.kopf.linie { border-bottom-color: var(--linie); }
.marke { width: 34px; height: 34px; border-radius: 10px; flex: none; background: var(--akzent); color: var(--akzent-tinte); display: grid; place-items: center; }
.marke .sym { width: 21px; height: 21px; stroke-width: 1.9; }
.titel { flex: 1; min-width: 0; }
.titel b { display: block; font: 600 19px/1.15 var(--serif); letter-spacing: -.01em; }
.titel small { display: block; margin-top: 2px; color: var(--tinte-2); font-size: 12.5px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.knopf {
  position: relative; width: 42px; height: 42px; border-radius: 12px; border: 0; background: transparent;
  color: var(--tinte-2); display: grid; place-items: center; transition: background .15s, color .15s;
}
.knopf:hover, .knopf:focus-visible { background: var(--flaeche-2); color: var(--tinte); outline: none; }
.knopf:active { background: var(--flaeche-2); }
.knopf .zahl {
  position: absolute; top: 5px; right: 4px; min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
  background: var(--akzent); color: var(--akzent-tinte); font-size: 10px; font-weight: 700; line-height: 15px; text-align: center;
}

/* ── Verlauf: Lesespalte; eigene Nachrichten als dunkle Tafel, Antworten als gesetzter Text ── */
#verlauf { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; padding: 14px var(--rand) 14px; scroll-behavior: smooth; }
.reihe { display: flex; width: 100%; max-width: 660px; margin: 0 auto 26px; animation: ein .22s ease-out; }
.reihe.ich { justify-content: flex-end; }
@keyframes ein { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.blase { overflow-wrap: anywhere; min-width: 0; }
.ich .blase { max-width: 84%; padding: 10px 15px; background: var(--nutzer); color: var(--nutzer-tinte); border-radius: 18px 18px 4px 18px; white-space: pre-wrap; line-height: 1.45; }
.er .blase { max-width: 100%; font: 17.5px/1.62 var(--serif); letter-spacing: .002em; hyphens: auto; -webkit-hyphens: auto; }
.er .blase.fehler { padding: 11px 14px; background: var(--fehler-weich); border-radius: 12px; color: var(--fehler); font: 15px/1.5 var(--sans); }
.blase p { margin: 0 0 .8em; } .blase p:last-child { margin-bottom: 0; }
.blase ul, .blase ol { margin: 0 0 .8em; padding-left: 1.3em; } .blase li { margin: .3em 0; padding-left: .1em; }
.blase li::marker { color: var(--akzent); }
.blase strong { font-weight: 650; }
.blase code { font: .88em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; background: var(--flaeche-2); padding: .12em .4em; border-radius: 5px; }
.blase pre { margin: .2em 0 .9em; padding: 12px 14px; background: var(--flaeche-2); border-radius: 10px; overflow-x: auto; font-size: 13.5px; line-height: 1.55; }
.blase pre code { background: none; padding: 0; font-size: inherit; }
.blase a { color: var(--akzent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.hinweis { display: block; margin-top: 8px; font: 13px/1.4 var(--sans); color: var(--tinte-2); }

.werkzeug {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 6px 10px 0; padding: 3px 9px 3px 7px; border-radius: 6px;
  border: 1px solid var(--linie); color: var(--tinte-2); font: 600 11px/1.3 var(--sans); letter-spacing: .06em; text-transform: uppercase;
}
.werkzeug .sym { width: 13px; height: 13px; color: var(--akzent); }

.tippt { display: inline-flex; gap: 5px; padding: 10px 2px; }
.tippt i { width: 6px; height: 6px; border-radius: 50%; background: var(--akzent); opacity: .4; animation: puls 1.1s infinite ease-in-out; }
.tippt i:nth-child(2) { animation-delay: .15s; } .tippt i:nth-child(3) { animation-delay: .3s; }
@keyframes puls { 0%, 80%, 100% { opacity: .2; transform: scale(.8); } 40% { opacity: .9; transform: scale(1); } }

/* ── Start: Begrüßung nach Tageszeit, Vorschläge als gesetzte Liste ── */
.leer { min-height: 100%; max-width: 560px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; align-items: stretch; padding: 0 0 6vh; }
.leer .marke { display: none; }
.leer h1 { margin: 0 0 8px; font: 500 38px/1.08 var(--serif); letter-spacing: -.025em; }
.leer p { margin: 0 0 30px; color: var(--tinte-2); font-size: 16px; line-height: 1.5; max-width: 34ch; }
.vorschlaege { display: flex; flex-direction: column; border-top: 1px solid var(--linie); }
.vorschlag {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; padding: 16px 2px; border: 0;
  border-bottom: 1px solid var(--linie); border-radius: 0; background: none; text-align: left; font: 17px/1.35 var(--serif);
  transition: padding .15s, color .15s;
}
.vorschlag i { font: normal 15px var(--sans); color: var(--tinte-2); transition: transform .15s, color .15s; }
.vorschlag:hover i, .vorschlag:active i { color: var(--akzent); transform: translateX(3px); }
.vorschlag:active { color: var(--akzent); }

/* ── Eingabe ── */
.eingabe { padding: 8px var(--rand) calc(12px + env(safe-area-inset-bottom)); background: var(--bg); }
.feld {
  max-width: 660px; margin: 0 auto; display: flex; align-items: flex-end; gap: 6px; padding: 6px 6px 6px 16px;
  background: var(--flaeche); border: 1px solid var(--linie); border-radius: 20px; box-shadow: var(--schatten); transition: border-color .15s;
}
.feld:focus-within { border-color: var(--akzent); }
#text {
  flex: 1; min-width: 0; border: 0; outline: 0; resize: none; background: transparent; padding: 8px 0; max-height: 132px;
  line-height: 1.45; font-size: 16px;       /* 16 px: iOS zoomt sonst beim Antippen */
}
#text::placeholder { color: var(--tinte-2); opacity: .85; }
.senden {
  flex: none; width: 40px; height: 40px; border-radius: 13px; border: 0; background: var(--akzent); color: var(--akzent-tinte);
  display: grid; place-items: center; transition: background .15s, color .15s, transform .1s;
}
.senden:disabled { background: var(--flaeche-2); color: var(--tinte-2); cursor: default; }
.senden:not(:disabled):active { transform: scale(.94); }
.senden .sym { width: 20px; height: 20px; stroke-width: 2.2; }

/* ── Blatt (Konnektoren) ── */
.schleier { position: fixed; inset: 0; background: rgba(8, 10, 16, .42); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 10; }
.schleier.offen { opacity: 1; pointer-events: auto; }
.blatt {
  position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; max-width: 560px; z-index: 11;
  max-height: calc(var(--h, 100dvh) * .82); overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--flaeche); border-radius: 22px 22px 0 0; padding: 8px 20px calc(22px + env(safe-area-inset-bottom));
  transform: translateY(105%); transition: transform .26s cubic-bezier(.2, .8, .2, 1); box-shadow: 0 -8px 32px rgba(0, 0, 0, .18);
}
.blatt.offen { transform: none; }
.griff { width: 38px; height: 4px; border-radius: 2px; background: var(--linie); margin: 4px auto 14px; }
.blatt h2 { margin: 0 0 4px; font-size: 18px; letter-spacing: -.01em; }
.blatt > p { margin: 0 0 14px; color: var(--tinte-2); font-size: 14.5px; }
.zeile { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--linie); }
.zeile .name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.zeile .name small { display: block; font-weight: 400; color: var(--tinte-2); font-size: 12.5px; }
.schalter { position: relative; width: 46px; height: 28px; flex: none; }
.schalter input { position: absolute; inset: 0; opacity: 0; margin: 0; width: 100%; height: 100%; cursor: pointer; }
.schalter span { position: absolute; inset: 0; border-radius: 14px; background: var(--linie); transition: background .18s; pointer-events: none; }
.schalter span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .18s; }
.schalter input:checked + span { background: var(--akzent); } .schalter input:checked + span::after { transform: translateX(18px); }
.schalter input:focus-visible + span { outline: 2px solid var(--akzent); outline-offset: 2px; }
.leerblatt { padding: 14px; border-radius: 14px; background: var(--flaeche-2); color: var(--tinte-2); font-size: 14.5px; }
.leerblatt code { font: .9em ui-monospace, Menlo, Consolas, monospace; color: var(--tinte); }
.abmelden { margin-top: 16px; width: 100%; padding: 12px; border-radius: 14px; border: 1px solid var(--linie); background: transparent; color: var(--tinte-2); }

/* ── Anmeldeseite ── */
.anmeldung { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.karte { width: 100%; max-width: 380px; background: var(--flaeche); border: 1px solid var(--linie); border-radius: 24px; padding: 28px 24px; box-shadow: var(--schatten); text-align: center; }
.karte .marke { width: 56px; height: 56px; border-radius: 17px; margin: 0 auto 16px; } .karte .marke .sym { width: 30px; height: 30px; }
.karte h1 { margin: 0 0 4px; font-size: 22px; letter-spacing: -.02em; }
.karte p { margin: 0 0 20px; color: var(--tinte-2); font-size: 14.5px; }
.karte input { width: 100%; padding: 13px 14px; border-radius: 14px; border: 1px solid var(--linie); background: var(--bg); outline: 0; font-size: 16px; text-align: center; letter-spacing: .04em; }
.karte input:focus { border-color: var(--akzent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--akzent) 18%, transparent); }
.karte button { width: 100%; margin-top: 12px; padding: 13px; border: 0; border-radius: 14px; background: var(--akzent); color: var(--akzent-tinte); font-weight: 600; }
.karte button:disabled { opacity: .5; }
.karte .meldung { min-height: 1.4em; margin: 12px 0 0; color: var(--fehler); font-size: 14px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }

/* ── Nächster Termin: kleine Vorschau unter dem Eingabefeld, großes Blatt beim Antippen ── */
.termin {
  width: 100%; max-width: 680px; margin: 8px auto 0; padding: 8px 12px; display: flex; align-items: center; gap: 9px;
  border: 0; border-radius: 12px; background: var(--flaeche-2); color: var(--tinte-2); font-size: 13px; line-height: 1.3; text-align: left;
  transition: background .15s;
}
.termin[hidden] { display: none; }
.termin:active { background: var(--linie); }
.termin:focus-visible { outline: 2px solid var(--akzent); outline-offset: 2px; }
.termin .sym { width: 16px; height: 16px; flex: none; }
.termin-text { flex: 1; min-width: 0; color: var(--tinte); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.termin-text i { font-style: normal; color: var(--tinte-2); font-weight: 400; }
.termin-rel { flex: none; font-variant-numeric: tabular-nums; }
.termin.leise .termin-text { color: var(--tinte-2); font-weight: 400; }
.eingabe.fokus .termin { display: none; }                  /* bei offener Tastatur Platz sparen */

.tb-kopf { display: flex; align-items: center; gap: 10px; margin: 0 0 10px; }
.tb-label { font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tinte-2); }
.tb-rel { margin-left: auto; padding: 3px 10px; border-radius: 999px; background: var(--akzent-weich); color: var(--akzent); font-size: 13px; font-weight: 600; white-space: nowrap; }
.tb-rel.jetzt { background: var(--akzent); color: var(--akzent-tinte); }
.tb-titel { margin: 0 0 14px; font-size: 25px; line-height: 1.2; font-weight: 650; letter-spacing: -.015em; overflow-wrap: anywhere; }
.tb-zeile { display: flex; align-items: flex-start; gap: 12px; padding: 11px 0; border-top: 1px solid var(--linie); font-size: 16px; line-height: 1.4; overflow-wrap: anywhere; }
.tb-zeile .sym { width: 20px; height: 20px; flex: none; margin-top: 1px; color: var(--tinte-2); }
.tb-zeile small { display: block; color: var(--tinte-2); font-size: 13.5px; }
.tb-danach { margin: 18px 0 4px; font-size: 12.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--tinte-2); }
.tb-folge { display: flex; gap: 12px; padding: 9px 0; border-top: 1px solid var(--linie); font-size: 15px; line-height: 1.35; }
.tb-folge b { flex: none; width: 7.5em; font-weight: 500; color: var(--tinte-2); font-variant-numeric: tabular-nums; }
.tb-folge span { min-width: 0; overflow-wrap: anywhere; }
.tb-leer { padding: 14px; border-radius: 14px; background: var(--flaeche-2); color: var(--tinte-2); font-size: 15px; }

/* ── Feinschliff im Home-Stil: Blätter, Terminzeile, Anmeldung ── */
.blatt { border-radius: 20px 20px 0 0; }
.blatt h2 { font: 600 21px/1.2 var(--serif); letter-spacing: -.01em; }
.termin { background: var(--flaeche); border: 1px solid var(--linie); border-left: 3px solid var(--akzent); border-radius: 4px 12px 12px 4px; padding: 8px 12px 8px 11px; }
.termin:active { background: var(--flaeche-2); }
.termin .sym { color: var(--akzent); }
.termin-text b { font-weight: 650; font-variant-numeric: tabular-nums; }
.termin-text i { margin: 0 6px; }
.tb-label { color: var(--akzent); }
.tb-titel { font: 600 28px/1.15 var(--serif); letter-spacing: -.02em; }
.tb-rel { background: var(--akzent-weich); color: var(--akzent); }
.tb-rel.jetzt { background: var(--akzent); color: var(--akzent-tinte); }
.tb-folge { font: 16px/1.35 var(--serif); }
.tb-folge b { font: 500 13.5px/1.5 var(--sans); }
.anmeldung { place-items: center start; }
.karte { max-width: 360px; margin: 0 auto; background: transparent; border: 0; box-shadow: none; text-align: left; padding: 0; }
.karte .marke { width: 48px; height: 48px; margin: 0 0 24px; border-radius: 14px; }
.karte .marke .sym { width: 28px; height: 28px; }
.karte h1 { margin: 0 0 8px; font: 500 38px/1.08 var(--serif); letter-spacing: -.025em; }
.karte p { margin: 0 0 26px; font-size: 16px; }
.karte input { text-align: left; padding: 14px 16px; background: var(--flaeche); letter-spacing: .02em; }
.karte button { padding: 14px; }
