/* Health OS — Interface
 *
 * Leitgedanke: Der Inhalt ist nicht "HRV = 59", sondern "wo steht der Wert im
 * Korridor des Normalen". Das Baseline-Band ist deshalb die Hauptfigur; alles
 * andere bleibt still.
 *
 * Farbe ist reserviert fuer Signal. Taucht im Interface Farbe auf, bedeutet
 * sie etwas -- sonst Schiefer-Graustufen.
 */

:root {
  /* Grund: kuehles Schiefer, kein Schwarz. Die Daten entstehen nachts, und
     eine dunkle Flaeche laesst gedaempfte Signalfarben wirken, ohne dass sie
     leuchten muessen. */
  --grund:      #11171c;
  --flaeche:    #171f26;
  --flaeche-2:  #1d262e;
  --linie:      #2a343d;
  --linie-hell: #3a464f;

  --text:       #e6ebef;
  --text-leise: #97a4ae;
  /* Kontraste gegen --grund gemessen: alle >= 4,5:1 (WCAG AA fuer
     normalen Text). Vorher lagen still/grau/rot bei 3,7 / 3,2 / 4,4 --
     zu wenig fuer Skalenbeschriftung, Einheiten und Delta-Angaben. */
  --text-still: #76828c;

  /* Signal. Gedaempft, klinisch -- Messgeraet, nicht Spielkonsole. */
  --gruen:      #6fa88a;
  --gelb:       #c2a03c;
  --rot:        #c3635c;
  --grau:       #77828b;

  --gruen-weich: #6fa88a26;
  --gelb-weich:  #c2a03c26;
  --rot-weich:   #c3635c26;
  --grau-weich:  #77828b26;

  --schrift: "Barlow", ui-sans-serif, system-ui, sans-serif;
  --schrift-eng: "Barlow Condensed", "Barlow", ui-sans-serif, sans-serif;

  --rand: 20px;
  --tableiste: 60px;
}

* { box-sizing: border-box; }

/* Ein eigener display-Wert schlaegt sonst das hidden-Attribut: die
   Tableiste blieb dadurch auf der Anmeldeseite sichtbar. */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--grund);
  color: var(--text);
  font-family: var(--schrift);
  font-size: 16px;
  line-height: 1.5;
  /* Ziffern in Tabellen und Baendern muessen untereinander stehen. */
  font-variant-numeric: tabular-nums;
  padding-bottom: calc(var(--tableiste) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-weight: 600; margin: 0; line-height: 1.2; }

a { color: inherit; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--text);
  outline-offset: 2px;
  border-radius: 2px;
}

/* ------------------------------------------------------------------ Bahnen */
/* Durchgehende Baender mit Trennlinien statt Karten-Raster -- angelehnt an
   einen Laborausdruck, und es spart auf schmalen Schirmen den Rahmenrand. */
.bahn {
  padding: 22px var(--rand);
  border-bottom: 1px solid var(--linie);
}
.bahn:last-child { border-bottom: none; }

.listenkopf { display: flex; justify-content: space-between; }

.bahn-titel {
  font-family: var(--schrift-eng);
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .04em;
  color: var(--text-leise);
  margin-bottom: 14px;
}

/* -------------------------------------------------------------------- Kopf */
.kopf {
  padding: max(18px, env(safe-area-inset-top)) var(--rand) 16px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.kopf-datum {
  font-family: var(--schrift-eng);
  font-size: 19px;
  color: var(--text-leise);
  font-weight: 400;
}
.kopf-aktion {
  font-size: 14px;
  color: var(--text-still);
  padding: 4px;
}

/* ------------------------------------------------------------------ Urteil */
/* Der Statusbalken sitzt links als schmale Kante, nicht als farbige Flaeche:
   die Farbe soll das Auge fuehren, nicht den Bildschirm fluten. */
.urteil {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.urteil-kante {
  width: 4px;
  align-self: stretch;
  min-height: 54px;
  border-radius: 2px;
  background: var(--grau);
  flex: none;
}
.urteil-text { min-width: 0; }
.urteil-wort {
  font-size: 31px;
  font-weight: 600;
  letter-spacing: -.015em;
  line-height: 1.1;
}
.urteil-grund {
  margin-top: 6px;
  color: var(--text-leise);
  font-size: 16px;
  max-width: 46ch;
}
.st-gruen .urteil-kante { background: var(--gruen); }
.st-gelb  .urteil-kante { background: var(--gelb); }
.st-rot   .urteil-kante { background: var(--rot); }
.st-grau  .urteil-kante { background: var(--grau); }
.st-gruen .urteil-wort { color: var(--gruen); }
.st-gelb  .urteil-wort { color: var(--gelb); }
.st-rot   .urteil-wort { color: var(--rot); }
.st-grau  .urteil-wort { color: var(--text-leise); }

/* ------------------------------------------------------------------- Band */
/* Die Hauptfigur. Der graue Korridor ist die persoenliche Normale
   (Median +/- Schwelle), der weisse Marker der heutige Stand. Links ist
   unguenstig, rechts guenstig -- unabhaengig davon, ob bei der Metrik hohe
   oder niedrige Werte besser sind. */
.kanal { margin-bottom: 22px; }
.kanal:last-child { margin-bottom: 0; }

.kanal-kopf {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 7px;
}
.kanal-name { font-size: 16px; font-weight: 500; }
.kanal-wert {
  font-family: var(--schrift-eng);
  font-size: 16px;
  color: var(--text-leise);
}
.kanal-wert b { color: var(--text); font-weight: 600; }

.band {
  position: relative;
  height: 32px;
  /* Die Achse laeuft durch, bleibt aber hinter dem Korridor zurueck. */
  background: linear-gradient(var(--linie), var(--linie)) center / 100% 1px no-repeat;
}
.band-korridor {
  position: absolute;
  top: 4px;
  bottom: 4px;
  background: var(--flaeche-2);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1px var(--linie-hell);
}
.band-mitte {
  position: absolute;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: var(--linie-hell);
}
.band-marker {
  position: absolute;
  top: 50%;
  width: 13px;
  height: 13px;
  margin: -6.5px 0 0 -6.5px;
  border-radius: 50%;
  background: var(--text);
  /* Der Ring trennt den Marker vom Korridor, auch wenn er darin liegt. */
  box-shadow: 0 0 0 3.5px var(--grund);
}
.k-gruen .band-marker { background: var(--gruen); }
.k-gelb  .band-marker { background: var(--gelb); }
.k-rot   .band-marker { background: var(--rot); }
.k-grau  .band-marker { background: var(--grau); }

.band-leer {
  height: 26px;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: var(--text-still);
}
.band-skala {
  display: flex;
  justify-content: space-between;
  font-family: var(--schrift-eng);
  font-size: 12px;
  color: var(--text-still);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--linie);
}

/* ---------------------------------------------------------------- Kennzahl */
.werte {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 18px 14px;
}
.wert-zahl {
  font-family: var(--schrift-eng);
  font-size: 27px;
  font-weight: 600;
  line-height: 1.05;
}
.wert-einheit { font-size: 15px; color: var(--text-still); font-weight: 400; }
.wert-name { font-size: 13.5px; color: var(--text-leise); margin-top: 1px; }
.wert-delta { font-size: 13px; margin-top: 2px; }
.d-gut { color: var(--gruen); }
.d-schlecht { color: var(--rot); }
.d-neutral { color: var(--text-still); }

/* ------------------------------------------------------------------ Grafik */
.verlauf { width: 100%; height: 96px; display: block; overflow: visible; }
.verlauf .korridor { fill: var(--flaeche-2); }
.verlauf .mittellinie { stroke: var(--linie-hell); stroke-width: 1; stroke-dasharray: 3 3; }
.verlauf .linie { fill: none; stroke: var(--text); stroke-width: 2;
                  stroke-linejoin: round; stroke-linecap: round; }
/* Die Tageswerte bleiben sichtbar, treten aber zurueck -- das Urteil faellt
   ueber das gleitende Mittel, nicht ueber den einzelnen Tag. */
.verlauf .roh   { fill: none; stroke: var(--text-still); stroke-width: 1;
                  stroke-linejoin: round; opacity: .55; }
.verlauf .punkt { fill: var(--text-still); }
.verlauf .achse { stroke: var(--linie); stroke-width: 1; }
.verlauf-fuss {
  display: flex; justify-content: space-between;
  font-family: var(--schrift-eng); font-size: 12px;
  color: var(--text-still); margin-top: 4px;
}

/* ------------------------------------------------------------------- Liste */
.zeile {
  display: flex;
  gap: 14px;
  align-items: baseline;
  padding: 11px 0;
  border-bottom: 1px solid var(--linie);
}
.zeile:last-child { border-bottom: none; }
.zeile-tag {
  font-family: var(--schrift-eng);
  font-size: 14px;
  color: var(--text-still);
  width: 52px;
  flex: none;
}
.zeile-haupt { flex: 1; min-width: 0; }
.zeile-name {
  font-size: 15.5px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.zeile-unter { font-size: 13.5px; color: var(--text-leise); margin-top: 1px; }
.zeile-zahl {
  font-family: var(--schrift-eng);
  font-size: 16px;
  color: var(--text-leise);
  flex: none;
}

/* Statuspunkt in Listen */
.punkt-status {
  width: 8px; height: 8px; border-radius: 50%;
  flex: none; align-self: center;
  background: var(--grau);
}
.p-erledigt     { background: var(--gruen); }
.p-offen        { background: var(--linie-hell); }
.p-verpasst     { background: var(--rot); }
.p-uebersprungen{ background: var(--grau); }
.p-verschoben   { background: var(--gelb); }

/* Antippbare Planzeile */
.plan-zeile { cursor: pointer; }
.plan-zeile:hover .zeile-name { color: #fff; }

.plan-aktionen {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 12px 0 14px;
  border-bottom: 1px solid var(--linie);
}
.aktion {
  padding: 9px 13px;
  background: var(--flaeche-2);
  border: 1px solid var(--linie-hell);
  border-radius: 6px;
  font-size: 14px;
  min-height: 40px;
}
.aktion:hover { border-color: var(--text-leise); }
.aktion-weg { color: var(--rot); border-color: transparent; }
.aktion-weg:hover { border-color: var(--rot); }

/* ----------------------------------------------------------------- Wochen */
.woche-kopf {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 8px;
}
.woche-name { font-size: 15px; font-weight: 500; }
.woche-zahl { font-family: var(--schrift-eng); font-size: 15px; color: var(--text-leise); }
.fortschritt {
  height: 5px; background: var(--flaeche-2); border-radius: 3px;
  overflow: hidden; display: flex;
}
.fortschritt i { display: block; height: 100%; }
.f-erledigt { background: var(--gruen); }
.f-verpasst { background: var(--rot); }

/* --------------------------------------------------------------- Formular */
.feld { margin-bottom: 20px; }
.feld-frage { font-size: 15.5px; margin-bottom: 9px; }
.skala { display: flex; gap: 6px; }
.skala button {
  flex: 1;
  padding: 11px 4px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 6px;
  font-family: var(--schrift-eng);
  font-size: 14px;
  color: var(--text-leise);
  transition: background .12s, border-color .12s, color .12s;
  min-height: 44px;
}
.skala button[aria-pressed="true"] {
  background: var(--flaeche-2);
  border-color: var(--text-leise);
  color: var(--text);
  font-weight: 600;
}
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], textarea, select {
  width: 100%;
  padding: 11px 12px;
  background: var(--flaeche);
  border: 1px solid var(--linie);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
  min-height: 44px;
}
textarea { min-height: 76px; resize: vertical; }

.knopf {
  width: 100%;
  padding: 13px;
  background: var(--text);
  color: var(--grund);
  border-radius: 6px;
  font-weight: 600;
  font-size: 16px;
  min-height: 48px;
}
.knopf:disabled { opacity: .45; }
.knopf-leise {
  background: none;
  border: 1px solid var(--linie-hell);
  color: var(--text);
}

/* --------------------------------------------------------------- Tableiste */
.tableiste {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tableiste) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: flex;
  background: color-mix(in srgb, var(--grund) 92%, transparent);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--linie);
  z-index: 20;
}
.tableiste button {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-family: var(--schrift-eng);
  font-size: 12.5px;
  color: var(--text-still);
  letter-spacing: .02em;
}
.tableiste button[aria-current="page"] { color: var(--text); }
.tableiste svg { width: 21px; height: 21px; stroke-width: 1.6; }

/* -------------------------------------------------------------- Zustaende */
.leer {
  padding: 34px var(--rand);
  color: var(--text-leise);
  font-size: 15.5px;
  max-width: 42ch;
}
.leer b { display: block; color: var(--text); font-weight: 600; margin-bottom: 5px; }

.hinweis {
  margin: 14px var(--rand);
  padding: 13px 15px;
  background: var(--flaeche);
  border-left: 3px solid var(--gelb);
  border-radius: 0 6px 6px 0;
  font-size: 14.5px;
  color: var(--text-leise);
}
.hinweis b { color: var(--text); font-weight: 600; }

.laedt { padding: 40px var(--rand); color: var(--text-still); }

/* ------------------------------------------------------------------ Anmeldung */
.anmeldung {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--rand);
  max-width: 380px;
  margin: 0 auto;
}
.anmeldung h1 { font-size: 25px; margin-bottom: 6px; }
.anmeldung p { color: var(--text-leise); margin: 0 0 26px; }
.fehler { color: var(--rot); font-size: 14.5px; margin-top: 12px; }

/* ------------------------------------------------------------------ Breite */
/* Ab Tablet bekommt der Inhalt eine Spaltenbreite statt sich zu dehnen --
   eine Zeile mit 120 Zeichen liest niemand gern. */
@media (min-width: 720px) {
  :root { --rand: 28px; }
  .app { max-width: 720px; margin: 0 auto; }
  .tableiste { max-width: 720px; margin: 0 auto; border-radius: 0; }
  .werte { grid-template-columns: repeat(auto-fit, minmax(108px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
