/* Kundenbesuche – Gestaltung nach docs/DESIGN.md
   Helles und dunkles Schema; die App folgt der Einstellung des Handys. */

:root {
  --bg: #f4f2ee;
  --page: #e9e6e0;
  --surface: #ffffff;
  --ink: #1d232a;
  --muted: #5b6570;
  --line: #d6d1c8;
  --accent: #1f4e79;
  --accent-soft: #e4ecf4;
  --on-accent: #ffffff;
  --warn-bg: #fff3d1;
  --warn-line: #d9a93a;
  --warn-ink: #6e4600;
  --ok-bg: #e2f0e5;
  --ok-ink: #1b5a2c;
  --danger: #a3261b;
  --danger-bg: #fbe3df;
  --danger-ink: #7d1b12;
  --scrim: rgba(20, 24, 28, .45);
  --shadow: 0 6px 20px rgba(0, 0, 0, .15);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15191d;
    --page: #0d1013;
    --surface: #1f252b;
    --ink: #eef1f4;
    --muted: #a3adb8;
    --line: #36404a;
    --accent: #8ab8e6;
    --accent-soft: #1d3247;
    --on-accent: #0b1724;
    --warn-bg: #3a2d0c;
    --warn-line: #c99a2c;
    --warn-ink: #f4d88e;
    --ok-bg: #173322;
    --ok-ink: #a3dcb2;
    --danger: #f0907f;
    --danger-bg: #3d1915;
    --danger-ink: #f6b3a8;
    --scrim: rgba(0, 0, 0, .6);
    --shadow: 0 6px 20px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.app {
  max-width: 560px;
  margin: 0 auto;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
@media (min-width: 600px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}
.laden { padding: 24px 16px; color: var(--muted); }

/* Kopfzeile, Inhalt, Fußzeile */
.appbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  min-height: 64px;
}
.appbar h1 { font-size: 22px; margin: 0; flex: 1; line-height: 1.2; }
.content { flex: 1; overflow-y: auto; padding: 0 14px 24px; overscroll-behavior: contain; }
.bottom {
  flex: none;
  display: grid;
  gap: 8px;
  padding: 10px 14px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--bg);
}

/* Knöpfe */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; min-height: 56px; padding: 6px 16px;
  border-radius: 12px; border: 2px solid transparent;
  font-size: 18px; font-weight: 600; text-align: center; line-height: 1.2;
}
.btn:active { transform: scale(.99); }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.big { min-height: 64px; font-size: 19px; }
.btn.ghost { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn.quiet { background: transparent; color: var(--accent); min-height: 48px; }
.btn.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn small { display: block; font-size: 14px; font-weight: 500; opacity: .9; margin-top: 2px; }
.btn .icon { width: 24px; height: 24px; flex: none; }
.icon { width: 20px; height: 20px; flex: none; }

.icon-btn {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink);
}
.icon-btn .icon { width: 24px; height: 24px; }
.back-btn {
  min-height: 48px; padding: 0 8px 0 0; margin-left: -4px;
  display: flex; align-items: center; gap: 2px;
  border: 0; background: none; color: var(--accent);
  font-size: 17px; font-weight: 600;
}
.back-btn .icon { width: 22px; height: 22px; }
.link {
  min-height: 44px; padding: 0 4px;
  border: 0; background: none; color: var(--accent);
  font-size: 15px; font-weight: 600; text-decoration: underline; text-underline-offset: 3px;
}

/* Umschalter Monat / Woche */
.seg {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 3px; margin-bottom: 8px;
}
.seg button {
  min-height: 44px; border: 0; border-radius: 9px; background: transparent;
  font-weight: 600; font-size: 16px; color: var(--muted);
}
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Monats-/Wochennavigation */
.zeitnav { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.zeitnav .pfeil {
  width: 48px; height: 48px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.zeitnav h2 { flex: 1; margin: 0; text-align: center; font-size: 18px; line-height: 1.2; }
.zeitnav .heute-btn {
  height: 48px; padding: 0 12px; flex: none;
  border-radius: 10px; border: 2px solid var(--accent); background: transparent;
  color: var(--accent); font-weight: 600; font-size: 16px;
}

/* Monatsraster */
.raster { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; text-align: center; }
.wt { font-size: 13px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.tag {
  position: relative; height: 46px; padding: 0;
  border: 0; border-radius: 10px; background: var(--surface); color: var(--ink);
  font-size: 17px;
}
.tag.leer { background: transparent; }
.tag.heute { box-shadow: inset 0 0 0 2px var(--accent); font-weight: 700; }
.tag[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.tag.heute[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent), inset 0 0 0 4px var(--on-accent); }
.tag .punkt {
  position: absolute; bottom: 5px; left: 50%;
  width: 7px; height: 7px; margin-left: -3.5px; border-radius: 50%;
  background: var(--accent);
}
.tag[aria-pressed="true"] .punkt { background: var(--on-accent); }
.tag .punkt.warn { background: var(--warn-line); }
.legende { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 2px 0; font-size: 13px; color: var(--muted); }
.legende span { display: inline-flex; align-items: center; gap: 5px; }
.lg-ring { width: 14px; height: 14px; border-radius: 4px; box-shadow: inset 0 0 0 2px var(--accent); }
.lg-voll { width: 14px; height: 14px; border-radius: 4px; background: var(--accent); }
.lg-punkt { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.lg-punkt.warn { background: var(--warn-line); }

/* Tagesliste */
.tagkopf { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 16px 2px 8px; }
.tagkopf h2 { margin: 0; font-size: 18px; }
.tagkopf small { font-weight: 600; font-size: 14px; color: var(--accent); white-space: nowrap; }
.leerhinweis {
  padding: 18px 14px; border: 1px dashed var(--line); border-radius: 12px;
  background: var(--surface); color: var(--muted); font-size: 16px; text-align: center;
}
.liste { display: grid; gap: 8px; }
.karte {
  display: grid; gap: 6px; width: 100%; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--ink); text-align: left;
}
.karte .name { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 18px; }
.karte .name .icon { color: var(--muted); }
.zeile { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 16px; }
.zeile .icon { color: var(--muted); }
.zeile .klein { color: var(--muted); font-size: 14px; }
.marke {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--page); color: var(--muted); font-size: 13px; font-weight: 600;
}
.marke.warn { background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); }

/* Wochenansicht */
.woche { display: grid; gap: 6px; }
.wzeile {
  display: grid; grid-template-columns: 56px 1fr; gap: 8px; align-items: stretch;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); min-height: 56px;
}
.wzeile.heute { box-shadow: inset 0 0 0 2px var(--accent); }
.wzeile.gewaehlt { border-color: var(--accent); background: var(--accent-soft); }
.wtag {
  display: grid; place-content: center; padding: 6px 0;
  border: 0; border-radius: 12px 0 0 12px; background: transparent; color: var(--ink);
  line-height: 1.1; text-align: center;
}
.wtag span { font-size: 13px; color: var(--muted); font-weight: 600; }
.wtag b { font-size: 20px; }
.wzeile.heute .wtag b { color: var(--accent); }
.wbesuche { display: grid; gap: 2px; align-content: center; padding: 4px 6px 4px 0; }
.wbesuch {
  min-height: 44px; padding: 4px 6px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); text-align: left; font-size: 16px;
}
.wbesuch .zeit { color: var(--muted); }
.wleer {
  min-height: 44px; padding: 4px 6px; border: 0; background: transparent;
  color: var(--muted); font-size: 15px; text-align: left;
}

/* Tages-Fenster */
.unterzeile { margin: -6px 2px 12px; color: var(--muted); font-size: 16px; }
.unterzeile b { color: var(--accent); }
.uebersicht {
  margin-bottom: 18px; padding: 14px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--line);
}
.gesamt { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding-bottom: 10px; border-bottom: 2px solid var(--accent); }
.gesamt span { font-size: 18px; font-weight: 700; }
.gesamt b { font-size: 30px; color: var(--accent); line-height: 1.1; }
.aufstellung .r { display: flex; align-items: center; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
.aufstellung .r:last-child { border-bottom: 0; padding-bottom: 0; }
.aufstellung .r > span:first-of-type { flex: 1; }
.aufstellung .r > span:last-child { font-weight: 700; white-space: nowrap; }
.aufstellung .r small { display: block; color: var(--muted); font-size: 13px; font-weight: 500; }
.aufstellung .r.info { color: var(--muted); }
.aufstellung .r.info > span:last-child { font-weight: 600; }
.uebersicht-hinweis {
  margin: 10px 0 0; padding: 8px 10px; border-radius: 8px;
  background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-line); font-size: 15px;
}
.bereich { margin-bottom: 20px; }
.bereich h2 { margin: 0 2px 8px; font-size: 18px; }
.pausen { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pausen li {
  display: flex; align-items: center; gap: 2px; padding-left: 14px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-weight: 600; font-size: 17px;
}
.chip-weg {
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--muted); font-size: 24px; line-height: 1;
}
.pause-zeile { display: flex; gap: 8px; }
.pause-zeile .eingabe { flex: 1; min-width: 0; }
.pause-zeile .btn { width: auto; flex: none; padding: 6px 14px; }

/* Sprechen */
.anleitung ol { margin: 0; padding-left: 22px; display: grid; gap: 6px; }
.anleitung .icon { width: 18px; height: 18px; vertical-align: -3px; color: var(--accent); }
.anleitung i { color: var(--muted); }
textarea.diktat { min-height: 170px; font-size: 19px; border: 2px solid var(--accent); }
.mikro-bereich { margin-bottom: 14px; }
.btn.aufnahme { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.aufnahme::before {
  content: ""; width: 12px; height: 12px; border-radius: 50%; background: #fff;
  animation: blinken 1s ease-in-out infinite;
}
@keyframes blinken { 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .btn.aufnahme::before { animation: none; } }
.hilfe { margin: 4px 2px 0; font-size: 15px; color: var(--muted); }
.hilfe summary { min-height: 44px; display: flex; align-items: center; color: var(--accent); font-weight: 600; cursor: pointer; }
.hilfe p { margin: 0 0 8px; }

/* Angaben prüfen (Spracheintrag) */
.gehoert {
  margin-bottom: 6px; padding: 10px 12px; border-radius: 10px;
  background: var(--surface); border-left: 4px solid var(--muted);
}
.gehoert b { display: block; font-size: 13px; letter-spacing: .04em; text-transform: uppercase; }
.gehoert p { margin: 4px 0 0; color: var(--muted); font-size: 16px; overflow-wrap: anywhere; }
.gehoert .link { margin-left: -4px; }
.kopf-hinweis { margin: 0 2px 12px; }
.frage {
  margin-bottom: 12px; padding: 12px 14px; border-radius: 12px;
  background: var(--warn-bg); border: 2px solid var(--warn-line); color: var(--warn-ink);
}
.frage p { margin: 0 0 10px; font-weight: 600; font-size: 17px; }
.frage-knoepfe { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.frage-knoepfe.drei { grid-template-columns: 1fr 1fr; }
.frage-knoepfe.drei .quiet { grid-column: 1 / -1; }
.frage .btn { min-height: 52px; font-size: 17px; }
.frage .btn.ghost { background: var(--surface); }
.nicht-erkannt { margin: 6px 2px 0; color: var(--warn-ink); font-size: 14px; font-weight: 600; }
.eingabe.fehlt { border: 2px solid var(--warn-line); background: var(--warn-bg); }
.hinweisliste { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 15px; }

/* Formular */
.formular { display: grid; gap: 4px; }
.feld { margin-bottom: 10px; }
.feld > label, .feld > .label {
  display: block; margin: 0 2px 4px;
  font-size: 15px; font-weight: 600; color: var(--muted);
}
.eingabe {
  width: 100%; min-height: 54px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--ink); font-size: 18px;
}
textarea.eingabe { min-height: 90px; padding: 12px; resize: vertical; line-height: 1.4; }
.eingabe[aria-invalid="true"] { border: 2px solid var(--danger); }
.paar { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.berechnet {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 54px; padding: 4px 6px 4px 12px; border-radius: 10px;
  background: var(--accent-soft); font-weight: 700;
}
.berechnet.warn { background: var(--warn-bg); color: var(--warn-ink); border: 2px solid var(--warn-line); }
.berechnet.offen { font-weight: 500; font-style: italic; color: var(--muted); font-size: 16px; }
.manuell-zeile { display: flex; gap: 8px; align-items: center; }
.manuell-zeile .eingabe { flex: 1; }
.hinweis { margin: 4px 2px 0; color: var(--muted); font-size: 14px; }
.feldfehler { margin: 6px 2px 0; color: var(--danger); font-size: 15px; font-weight: 600; }
.kasten {
  margin: 0 0 12px; padding: 12px 14px; border-radius: 12px; font-size: 16px;
}
.kasten.fehler { background: var(--danger-bg); color: var(--danger-ink); border: 2px solid var(--danger); font-weight: 600; }
.kasten.warn { background: var(--warn-bg); color: var(--warn-ink); border: 2px solid var(--warn-line); }
.kasten.info { background: var(--surface); border: 1px solid var(--line); }
.kasten p { margin: 0 0 6px; }
.kasten p:last-child { margin-bottom: 0; }

/* Detailansicht */
.details { padding: 4px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 14px; }
.details .r { display: flex; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 17px; }
.details .r:last-child { border-bottom: 0; }
.details .r > span:first-child { color: var(--muted); flex: none; }
.details .r > span:last-child { font-weight: 600; text-align: right; overflow-wrap: anywhere; white-space: pre-wrap; }
.details .r small { display: block; font-weight: 500; color: var(--muted); font-size: 14px; }
.knopfreihe { display: grid; gap: 8px; }
.zeitstempel { margin: 14px 2px 0; color: var(--muted); font-size: 14px; }

/* Sicherung */
.abschnitt { margin-bottom: 18px; }
.abschnitt h2 { font-size: 18px; margin: 0 0 6px; }
.abschnitt p { margin: 0 0 10px; font-size: 16px; }

/* Rückfrage (unten einfahrendes Fenster) */
dialog.sheet {
  width: 100%; max-width: 560px; margin: auto auto 0;
  padding: 20px 16px calc(18px + env(safe-area-inset-bottom));
  border: 0; border-radius: 18px 18px 0 0;
  background: var(--surface); color: var(--ink);
}
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet h2 { margin: 0 0 8px; font-size: 21px; }
dialog.sheet p { margin: 0 0 8px; font-size: 16px; color: var(--muted); }
dialog.sheet p.was { color: var(--ink); font-weight: 600; font-size: 17px; }
dialog.sheet .knoepfe { display: grid; gap: 8px; margin-top: 12px; }

/* Kurze Meldung oben */
.meldung {
  position: fixed; z-index: 10; top: calc(10px + env(safe-area-inset-top)); left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px); max-width: 528px;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 14px; border-radius: 12px; box-shadow: var(--shadow);
  font-weight: 700; font-size: 17px;
}
.meldung.ok { background: var(--ok-bg); color: var(--ok-ink); }
.meldung.fehler { background: var(--danger-bg); color: var(--danger-ink); border: 2px solid var(--danger); }
