/* Bausteine der Oberflaeche. */

/* --- Kopfleiste ------------------------------------------------------- */

.kopfleiste {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 40;
  height: calc(var(--kopf-hoehe) + var(--sicher-oben));
  padding: var(--sicher-oben) var(--abstand-4) 0;
  display: flex;
  align-items: center;
  gap: var(--abstand-3);
  background: rgba(0, 0, 0, 0.86);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--rand);
}
.kopfleiste .marke {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  font-style: italic;
}
.kopfleiste .titel { font-size: 17px; font-weight: 600; }
.kopfleiste .rechts { margin-left: auto; display: flex; gap: var(--abstand-4); align-items: center; }
.kopfleiste a, .kopfleiste button {
  background: none; border: 0; padding: 0; cursor: pointer; display: flex;
}
.zurueck { display: flex; align-items: center; margin-left: -4px; }

/* --- Navigation unten ------------------------------------------------- */

.navleiste {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 40;
  height: calc(var(--nav-hoehe) + var(--sicher-unten));
  padding-bottom: var(--sicher-unten);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: center;
  background: rgba(0, 0, 0, 0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid var(--rand);
}
.navleiste a {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-3);
  transition: color .15s;
}
.navleiste a.aktiv { color: var(--text); }
.navleiste a.aktiv .ikon { stroke-width: 2.4; }
.navleiste .erstellen .ikon {
  width: 27px; height: 27px;
  padding: 3px;
  border-radius: 9px;
  color: var(--text);
  box-shadow: inset 0 0 0 1.8px currentColor;
  stroke-width: 2.4;
}

/* --- Seitenraster ----------------------------------------------------- */

.inhalt { max-width: 620px; margin: 0 auto; padding: 0 0 var(--abstand-5); }
.polster { padding-left: var(--abstand-4); padding-right: var(--abstand-4); }

.abschnitt { margin-top: var(--abstand-5); }
.abschnitt-kopf {
  display: flex; align-items: baseline; gap: var(--abstand-3);
  padding: 0 var(--abstand-4) var(--abstand-3);
}
.abschnitt-kopf h2 { flex: 1; }
.abschnitt-kopf a { color: var(--blau); font-size: 14px; font-weight: 600; }

/* --- Story-Ringe ------------------------------------------------------ */

.story-reihe {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: var(--abstand-4) var(--abstand-4) var(--abstand-4);
  border-bottom: 1px solid var(--rand);
  scroll-snap-type: x proximity;
}
.story-reihe::-webkit-scrollbar { display: none; }

.story {
  flex: none;
  width: 68px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  scroll-snap-align: start;
}
.story-ring {
  width: 66px; height: 66px;
  border-radius: 50%;
  padding: 2.5px;
  background: var(--flaeche-3);
  display: grid;
  place-items: center;
  transition: transform .12s ease;
}
.story:active .story-ring { transform: scale(0.93); }
.story-ring.erledigt { background: var(--verlauf); }
.story-ring.teilweise { background: conic-gradient(var(--f-routinen) var(--anteil, 50%), var(--flaeche-3) 0); }
.story-innen {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--bg);
  padding: 2.5px;
  display: grid;
  place-items: center;
}
.story-kern {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: var(--flaeche-2);
  display: grid;
  place-items: center;
  color: var(--text);
}
.story-ring.erledigt .story-kern { background: var(--flaeche-3); }
.story-name {
  font-size: 11.5px;
  line-height: 1.25;
  color: var(--text-2);
  text-align: center;
  max-width: 68px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
.story.ist-erledigt .story-name { color: var(--text); }
.story-abzeichen {
  position: relative;
  font-size: 10px;
  font-weight: 700;
  color: var(--f-nutrition);
}

/* --- Karten ----------------------------------------------------------- */

.karte {
  background: var(--flaeche);
  border: 1px solid var(--rand);
  border-radius: var(--r-mittel);
  margin: 0 var(--abstand-4) var(--abstand-3);
  overflow: hidden;
}
.karte.flach { background: none; border: 0; margin-left: 0; margin-right: 0; }

.karte-kopf {
  display: flex;
  align-items: center;
  gap: var(--abstand-3);
  padding: var(--abstand-3) var(--abstand-4);
}
.karte-kopf .avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--flaeche-2);
  color: var(--text);
  flex: none;
}
.karte-kopf .avatar.verlauf { background: var(--verlauf); }
.karte-kopf .text { flex: 1; min-width: 0; }
.karte-kopf .text b { display: block; font-size: 14px; font-weight: 600; }
.karte-kopf .text span { font-size: 12px; color: var(--text-2); }
.karte-kopf .aktion { color: var(--blau); font-size: 14px; font-weight: 600; }

.karte-koerper { padding: 0 var(--abstand-4) var(--abstand-4); }
.karte-fuss {
  display: flex; gap: var(--abstand-4);
  padding: var(--abstand-3) var(--abstand-4);
  border-top: 1px solid var(--rand);
}

/* --- Ringe ------------------------------------------------------------ */

.ring-reihe {
  display: grid;
  /* Passt sich der Anzahl an: drei Ringe werden breit, vier ruecken zusammen. */
  grid-template-columns: repeat(auto-fit, minmax(72px, 1fr));
  gap: var(--abstand-3) var(--abstand-2);
  padding: var(--abstand-4);
}
.ring-kachel svg { max-width: 100%; height: auto; }
.ring-kachel {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
  min-width: 0; /* sonst zieht der Resttext die Spalte auseinander */
}
.ring-kachel > [data-ring] { width: 100%; display: flex; justify-content: center; }
.ring-kachel .name, .ring-kachel .rest {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ring-kachel .wert { font-size: 17px; font-weight: 700; letter-spacing: -0.3px; }
.ring-kachel .name { font-size: 12px; color: var(--text-2); }
.ring-kachel .rest { font-size: 11px; color: var(--text-3); }
.ring-kachel.ueberzogen .wert { color: var(--rot); }

/* --- Balken (Makros) -------------------------------------------------- */

.balken-gruppe { display: grid; gap: var(--abstand-3); }
.balken-zeile { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; }
.balken-zeile .beschriftung { font-size: 12px; color: var(--text-2); }
.balken-zeile .zahlen { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.balken {
  grid-column: 1 / -1;
  height: 5px;
  border-radius: var(--r-rund);
  background: var(--flaeche-3);
  overflow: hidden;
}
.balken i {
  display: block; height: 100%;
  border-radius: var(--r-rund);
  background: var(--farbe, var(--blau));
  transition: width .35s ease;
}
.balken i.ueber { background: var(--rot); }

/* --- Heatmap ---------------------------------------------------------- */

.heatmap { display: flex; gap: 3px; padding: var(--abstand-4); overflow-x: auto; scrollbar-width: none; }
.heatmap::-webkit-scrollbar { display: none; }
.heatmap .woche { display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; }
.heatmap .tag {
  width: 13px; height: 13px;
  border-radius: 3px;
  background: var(--flaeche-2);
}
.heatmap .tag[data-stufe="1"] { background: rgba(188, 24, 136, .3); }
.heatmap .tag[data-stufe="2"] { background: rgba(188, 24, 136, .5); }
.heatmap .tag[data-stufe="3"] { background: rgba(220, 39, 67, .72); }
.heatmap .tag[data-stufe="4"] { background: #f09433; }
.heatmap .tag.zukunft { background: transparent; box-shadow: inset 0 0 0 1px var(--flaeche-2); }
.heatmap .tag.heute { box-shadow: 0 0 0 1.5px var(--text); }
.heatmap-legende {
  display: flex; align-items: center; gap: 6px;
  padding: 0 var(--abstand-4) var(--abstand-4);
  font-size: 11px; color: var(--text-3);
}

/* --- Listen ----------------------------------------------------------- */

.liste { display: flex; flex-direction: column; }
.zeile {
  display: flex;
  align-items: center;
  gap: var(--abstand-3);
  padding: var(--abstand-3) var(--abstand-4);
  border-bottom: 1px solid var(--rand);
  background: none;
  border-left: 0; border-right: 0; border-top: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
}
.zeile:last-child { border-bottom: 0; }
.zeile .haupt { flex: 1; min-width: 0; }
.zeile .haupt b { display: block; font-weight: 500; font-size: 14.5px; }
.zeile .haupt span { font-size: 12.5px; color: var(--text-2); }
.zeile .zusatz { font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; text-align: right; }
.zeile .symbol {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--flaeche-2); flex: none;
}
.zeile.erledigt .haupt b { color: var(--text-3); text-decoration: line-through; }

/* Abhak-Kreis */
.haken-kreis {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 1.8px solid var(--rand-hell);
  display: grid; place-items: center;
  color: transparent;
  flex: none;
  transition: all .15s;
}
.erledigt .haken-kreis,
.haken-kreis.an {
  background: var(--verlauf);
  border-color: transparent;
  color: #fff;
}

/* --- Knoepfe ---------------------------------------------------------- */

.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px;
  padding: 0 var(--abstand-4);
  border-radius: var(--r-klein);
  border: 1px solid var(--rand-hell);
  background: var(--flaeche-2);
  color: var(--text);
  font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: opacity .12s, transform .08s;
}
.knopf:active { transform: scale(.985); opacity: .85; }
.knopf.primaer { background: var(--blau); border-color: var(--blau); color: #fff; }
.knopf.verlauf { background: var(--verlauf); border-color: transparent; color: #fff; }
.knopf.geist { background: none; border-color: var(--rand-hell); }
.knopf.gefahr { color: var(--rot); border-color: var(--rand-hell); }
.knopf.breit { width: 100%; }
.knopf.schmal { min-height: 34px; padding: 0 12px; font-size: 13px; }
.knopf[disabled] { opacity: .45; pointer-events: none; }

.knopf-reihe { display: flex; gap: var(--abstand-2); padding: 0 var(--abstand-4); }
.knopf-reihe .knopf { flex: 1; }

/* --- Formulare -------------------------------------------------------- */

.feldgruppe { display: grid; gap: var(--abstand-3); padding: var(--abstand-4); }
.feld { display: grid; gap: 6px; }
.feld > label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.feld input, .feld select, .feld textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  background: var(--flaeche-2);
  border: 1px solid var(--rand);
  border-radius: var(--r-klein);
  color: var(--text);
  font-size: 16px; /* verhindert Zoom auf iOS */
  appearance: none;
}
.feld textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.feld input:focus, .feld select:focus, .feld textarea:focus {
  outline: none; border-color: var(--rand-hell); background: var(--flaeche-3);
}
.feld select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23a8a8a8' stroke-width='2' stroke-linecap='round'><path d='M6 9l6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.feld-paar { display: grid; grid-template-columns: 1fr 1fr; gap: var(--abstand-3); }
.feld-drei { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--abstand-2); }
.hinweis { font-size: 12px; color: var(--text-3); }

.schalter-reihe {
  display: flex; align-items: center; gap: var(--abstand-3);
  padding: var(--abstand-3) var(--abstand-4);
  border-bottom: 1px solid var(--rand);
}
.schalter-reihe .haupt { flex: 1; }
.schalter { position: relative; width: 46px; height: 28px; flex: none; }
.schalter input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.schalter i {
  position: absolute; inset: 0;
  background: var(--flaeche-3);
  border-radius: var(--r-rund);
  transition: background .18s;
  pointer-events: none;
}
.schalter i::after {
  content: ""; position: absolute;
  top: 3px; left: 3px; width: 22px; height: 22px;
  background: #fff; border-radius: 50%;
  transition: transform .18s;
}
.schalter input:checked + i { background: var(--blau); }
.schalter input:checked + i::after { transform: translateX(18px); }

/* Auswahl-Chips */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  min-height: 34px;
  padding: 0 12px;
  border-radius: var(--r-rund);
  border: 1px solid var(--rand-hell);
  background: none;
  color: var(--text-2);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.chip.an { background: var(--text); border-color: var(--text); color: #000; font-weight: 600; }
.chip.klein { min-height: 28px; font-size: 12px; padding: 0 10px; }

/* --- Blatt (Modal von unten) ----------------------------------------- */

.blatt-hintergrund {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0, 0, 0, .6);
  backdrop-filter: blur(2px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: einblenden .18s ease;
}
.blatt {
  width: 100%; max-width: 620px;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--flaeche);
  border-radius: var(--r-gross) var(--r-gross) 0 0;
  border-top: 1px solid var(--rand-hell);
  padding-bottom: calc(var(--sicher-unten) + var(--abstand-4));
  animation: hochschieben .24s cubic-bezier(.2, .8, .3, 1);
}
.blatt-griff {
  width: 38px; height: 4px; border-radius: 2px;
  background: var(--rand-hell);
  margin: 8px auto 4px;
}
.blatt-kopf {
  display: flex; align-items: center; gap: var(--abstand-3);
  padding: var(--abstand-3) var(--abstand-4);
  border-bottom: 1px solid var(--rand);
  position: sticky; top: 0; background: var(--flaeche); z-index: 1;
}
.blatt-kopf h2 { flex: 1; font-size: 16px; }
.blatt-kopf button { background: none; border: 0; cursor: pointer; display: flex; color: var(--text-2); }

@keyframes einblenden { from { opacity: 0 } to { opacity: 1 } }
@keyframes hochschieben { from { transform: translateY(100%) } to { transform: none } }

/* --- Meldungen -------------------------------------------------------- */

.meldung {
  position: fixed;
  left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-hoehe) + var(--sicher-unten) + 16px);
  z-index: 80;
  background: var(--flaeche-3);
  border: 1px solid var(--rand-hell);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--r-rund);
  font-size: 13.5px; font-weight: 500;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  animation: einblenden .16s ease;
  max-width: calc(100vw - 32px);
}

.banner {
  margin: 0 var(--abstand-4) var(--abstand-3);
  padding: var(--abstand-3) var(--abstand-4);
  border-radius: var(--r-mittel);
  background: rgba(255, 183, 0, .12);
  border: 1px solid rgba(255, 183, 0, .3);
  font-size: 13px; color: #ffd67a;
  display: flex; gap: 10px; align-items: flex-start;
}
.banner.info { background: rgba(0, 149, 246, .12); border-color: rgba(0, 149, 246, .3); color: #8ecbff; }
.banner a { text-decoration: underline; }

.leer {
  text-align: center;
  padding: var(--abstand-6) var(--abstand-4);
  color: var(--text-3);
}
.leer .ikon { margin-bottom: var(--abstand-3); color: var(--rand-hell); }
.leer b { display: block; color: var(--text-2); font-weight: 600; margin-bottom: 4px; }

/* --- Reiter ----------------------------------------------------------- */

.reiter {
  display: flex;
  border-bottom: 1px solid var(--rand);
  position: sticky;
  top: calc(var(--kopf-hoehe) + var(--sicher-oben));
  background: var(--bg);
  z-index: 30;
}
.reiter a {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  font-size: 13px; font-weight: 600;
  color: var(--text-3);
  border-bottom: 1.5px solid transparent;
  margin-bottom: -1px;
}
.reiter a.aktiv { color: var(--text); border-bottom-color: var(--text); }

/* --- Kennzahlen ------------------------------------------------------- */

.kennzahlen {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 1px;
  background: var(--rand);
  border-top: 1px solid var(--rand);
  border-bottom: 1px solid var(--rand);
}
.kennzahl { background: var(--flaeche); padding: var(--abstand-3) var(--abstand-2); text-align: center; }
.kennzahl b { display: block; font-size: 18px; font-weight: 700; letter-spacing: -0.4px; }
.kennzahl span { font-size: 11.5px; color: var(--text-2); }

/* --- Diagramme -------------------------------------------------------- */

.diagramm { width: 100%; display: block; }
.diagramm-rahmen { padding: var(--abstand-3) var(--abstand-4) var(--abstand-4); }

/* --- Timer ------------------------------------------------------------ */

.timer-leiste {
  position: fixed;
  left: 0; right: 0;
  bottom: calc(var(--nav-hoehe) + var(--sicher-unten));
  z-index: 45;
  background: var(--flaeche-3);
  border-top: 1px solid var(--rand-hell);
  padding: 10px var(--abstand-4);
  display: flex; align-items: center; gap: var(--abstand-3);
  animation: hochschieben .2s ease;
}
.timer-leiste .zeit {
  font-size: 26px; font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  min-width: 84px;
}
.timer-leiste .info { flex: 1; font-size: 12.5px; color: var(--text-2); }
.timer-fortschritt {
  position: absolute; left: 0; bottom: 0; height: 2px;
  background: var(--verlauf);
  transition: width 1s linear;
}
.timer-gross {
  font-size: 68px; font-weight: 200;
  font-variant-numeric: tabular-nums;
  letter-spacing: -3px;
  text-align: center;
  margin: var(--abstand-5) 0 var(--abstand-3);
}

/* --- Satztabelle ------------------------------------------------------ */

.satz-zeile {
  display: grid;
  grid-template-columns: 28px 1fr 1fr 44px;
  gap: var(--abstand-2);
  align-items: center;
  padding: 6px var(--abstand-4);
}
.satz-zeile .nr { font-size: 13px; color: var(--text-3); font-weight: 600; text-align: center; }
.satz-zeile input {
  min-height: 40px;
  text-align: center;
  padding: 8px 4px;
  background: var(--flaeche-2);
  border: 1px solid var(--rand);
  border-radius: var(--r-klein);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.satz-zeile.fertig input { background: rgba(46, 204, 113, .08); border-color: rgba(46, 204, 113, .25); }
.satz-zeile .kopf-text { font-size: 11px; color: var(--text-3); text-align: center; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.satz-knopf {
  width: 40px; height: 40px;
  border-radius: var(--r-klein);
  border: 1px solid var(--rand-hell);
  background: var(--flaeche-2);
  display: grid; place-items: center;
  cursor: pointer; color: var(--text-2);
}
.satz-knopf.fertig { background: var(--verlauf); border-color: transparent; color: #fff; }

.pr-abzeichen {
  font-size: 10px; font-weight: 700;
  background: var(--verlauf);
  color: #fff;
  padding: 1px 6px;
  border-radius: var(--r-rund);
  margin-left: 6px;
  vertical-align: middle;
}

/* --- Suche ------------------------------------------------------------ */

.suchleiste { padding: var(--abstand-3) var(--abstand-4); position: relative; }
.suchleiste input {
  width: 100%; min-height: 40px;
  padding: 8px 12px 8px 36px;
  background: var(--flaeche-2);
  border: 1px solid var(--rand);
  border-radius: var(--r-klein);
  font-size: 16px;
}
.suchleiste .lupe {
  position: absolute; left: calc(var(--abstand-4) + 10px); top: 50%;
  transform: translateY(-50%);
  color: var(--text-3); pointer-events: none;
}
.lade-punkte { display: inline-flex; gap: 3px; }
.lade-punkte i {
  width: 5px; height: 5px; border-radius: 50%; background: var(--text-3);
  animation: pulsieren 1.1s infinite;
}
.lade-punkte i:nth-child(2) { animation-delay: .18s; }
.lade-punkte i:nth-child(3) { animation-delay: .36s; }
@keyframes pulsieren { 0%, 60%, 100% { opacity: .25 } 30% { opacity: 1 } }

/* --- Schnell-Erfassen ------------------------------------------------- */

.erstellen-liste { padding: var(--abstand-2) 0 var(--abstand-4); }
.erstellen-liste .zeile { border-bottom: 0; padding: var(--abstand-3) var(--abstand-4); }
.erstellen-liste .symbol { background: var(--verlauf); color: #fff; }
