/* =====================================================================
   Einkauf · vorläufige Optik (Christian gestaltet nach Abschnitt 1)
   Alles in rem: Die Schriftgröße-Einstellung skaliert die ganze Oberfläche.
   Groß = 20 px, Sehr groß = 23 px, Riesig = 26 px Grundschrift.
   ===================================================================== */

:root {
  --hg: #f2f8fd;
  --karte: #ffffff;
  --text: #16002d;
  --text2: #4b4466;
  --linie: #d3e3f1;
  --primaer: #0098ff;          /* Lightblue Azure – Flächen */
  --auf-primaer: #16002d;      /* Text auf Azure */
  --primaer-text: #0067ad;     /* Azure als Schrift auf Weiß (Kontrast ≥ 4.5) */
  --hell: #eef8fe;             /* Lightblue hell */
  --gefahr: #b3261e;
  --erledigt: #6f6a80;
  --schatten: 0 0.1rem 0.6rem rgba(22, 0, 45, 0.08);
  --radius: 0.8rem;
  --tipp: 2.8rem;              /* Mindest-Tippfläche: 56 px bei "Groß" */
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --hg: #0e001d;
    --karte: #1c003c;
    --text: #eef8fe;
    --text2: #c4d2e0;
    --linie: #3a1a66;
    --primaer: #0098ff;
    --auf-primaer: #16002d;
    --primaer-text: #75deff;
    --hell: #241046;
    --gefahr: #ff8a80;
    --erledigt: #a49fb8;
    --schatten: 0 0.1rem 0.6rem rgba(0, 0, 0, 0.4);
  }
}

html { font-size: 20px; -webkit-text-size-adjust: 100%; }
html[data-schrift="sehr"] { font-size: 23px; }
html[data-schrift="riesig"] { font-size: 26px; }

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100dvh;
  font: 1rem/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif;
  background: var(--hg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 0.15rem solid var(--primaer); outline-offset: 0.1rem; }
.versteckt { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

svg.icon { width: 1.4rem; height: 1.4rem; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------------------------------------------------------------------
   Grundgerüst
   --------------------------------------------------------------------- */
.seite {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding-bottom: calc(4.2rem + env(safe-area-inset-bottom));
}

.kopf {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--hg);
  padding: calc(env(safe-area-inset-top) + 0.3rem) 0.6rem 0.4rem;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}
.kopf h1 {
  flex: 1;
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kopf-knopf {
  min-width: var(--tipp);
  min-height: var(--tipp);
  border: 0;
  background: none;
  border-radius: 50%;
  display: grid;
  place-items: center;
}
.kopf-knopf:active { background: var(--hell); }
.kopf-titel {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-height: var(--tipp);
  border: 0;
  background: none;
  text-align: left;
  padding: 0;
  overflow: hidden;
}

.hinweis {
  margin: 0 0.8rem 0.4rem;
  padding: 0.35rem 0.8rem;
  border-radius: 2rem;
  background: var(--hell);
  color: var(--text2);
  font-size: 0.8rem;
  text-align: center;
}
.hinweis.offline { background: #fff3cd; color: #5c4400; }
@media (prefers-color-scheme: dark) { .hinweis.offline { background: #4a3a00; color: #ffe8a3; } }
.hinweis.update { background: var(--primaer); color: var(--auf-primaer); font-weight: 600; border: 0; display: block; width: calc(100% - 1.6rem); min-height: var(--tipp); }

.inhalt { flex: 1; padding: 0 0.6rem 1rem; }

/* Untere Navigation */
.unten {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 30;
  display: flex;
  background: var(--karte);
  border-top: 1px solid var(--linie);
  padding-bottom: env(safe-area-inset-bottom);
}
.unten a {
  flex: 1;
  min-height: 3.6rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  color: var(--text2);
  text-decoration: none;
  font-size: 0.75rem;
}
.unten a[aria-current="page"] { color: var(--primaer-text); font-weight: 700; }

/* ---------------------------------------------------------------------
   Eingabe "Wir brauchen …"
   --------------------------------------------------------------------- */
.eingabe {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 3.4rem);
  z-index: 15;
  background: var(--hg);
  padding: 0 0.6rem 0.5rem;
}
.eingabe form { display: flex; gap: 0.4rem; }
.eingabe input {
  flex: 1;
  min-width: 0;
  min-height: var(--tipp);
  padding: 0 0.9rem;
  border: 0.12rem solid var(--linie);
  border-radius: var(--radius);
  background: var(--karte);
  font-size: 1.1rem;
}
.eingabe input:focus { border-color: var(--primaer); outline: none; }
.eingabe input::placeholder { color: var(--text2); opacity: 0.8; }

.knopf-plus {
  width: var(--tipp);
  min-height: var(--tipp);
  border: 0;
  border-radius: var(--radius);
  background: var(--primaer);
  color: var(--auf-primaer);
  display: grid;
  place-items: center;
}

.vorschlaege {
  list-style: none;
  margin: 0.3rem 0 0;
  padding: 0;
  background: var(--karte);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  overflow: hidden;
}
.vorschlaege:empty { display: none; }
.vorschlaege button {
  width: 100%;
  min-height: var(--tipp);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.8rem;
  border: 0;
  border-bottom: 1px solid var(--linie);
  background: none;
  text-align: left;
  font-size: 1.05rem;
}
.vorschlaege li:last-child button { border-bottom: 0; }
.vorschlaege .klein { margin-left: auto; color: var(--text2); font-size: 0.85rem; }

/* ---------------------------------------------------------------------
   Liste
   --------------------------------------------------------------------- */
.gruppe { margin: 0.6rem 0 0.2rem; }
.gruppe-kopf {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0.3rem 0.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.gruppe ul, .erledigt ul { list-style: none; margin: 0; padding: 0; }

.eintrag {
  display: flex;
  align-items: stretch;
  background: var(--karte);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  margin-bottom: 0.35rem;
}
.eintrag-text {
  flex: 1;
  min-width: 0;
  min-height: 3.2rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.4rem 0.4rem 0.6rem;
  border: 0;
  background: none;
  text-align: left;
}
.eintrag-text .woerter { min-width: 0; display: flex; flex-direction: column; }
.eintrag .name { font-size: 1.15rem; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.eintrag .zusatz { font-size: 0.85rem; color: var(--text2); overflow-wrap: anywhere; }
.eintrag .menge { font-weight: 700; color: var(--primaer-text); }

.punkt {
  flex: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--farbe, #90a4ae);
  font-size: 1.15rem;
  line-height: 1;
}
.punkt.klein { width: 1.6rem; height: 1.6rem; font-size: 0.85rem; }

/* Der große Haken */
.haken {
  flex: none;
  width: 3.4rem;
  min-height: 3.2rem;
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  padding: 0;
}
.haken::before {
  content: "";
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  border: 0.17rem solid var(--primaer);
  background: var(--karte);
}
.haken:active::before { background: var(--primaer); }

/* Linkshänder: Haken links */
html[data-hand="links"] .eintrag { flex-direction: row-reverse; }
html[data-hand="links"] .eintrag-text { padding: 0.4rem 0.6rem 0.4rem 0.4rem; }

/* Zuletzt abgehakt */
.erledigt { margin-top: 1.4rem; }
.erledigt-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 0 0.3rem 0.3rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text2);
  text-transform: uppercase;
}
.erledigt .eintrag { background: transparent; box-shadow: none; border: 1px solid var(--linie); }
.erledigt .name { text-decoration: line-through; color: var(--erledigt); font-weight: 500; }
.erledigt .punkt { opacity: 0.5; }
.knopf-wieder {
  flex: none;
  width: 3.4rem;
  min-height: 3rem;
  border: 0;
  background: none;
  color: var(--primaer-text);
  display: grid;
  place-items: center;
}

.leer {
  text-align: center;
  color: var(--text2);
  padding: 2.5rem 1rem;
  font-size: 1.05rem;
}

/* ---------------------------------------------------------------------
   Knöpfe allgemein
   --------------------------------------------------------------------- */
.knopf {
  min-height: var(--tipp);
  padding: 0.4rem 1.1rem;
  border-radius: var(--radius);
  border: 0.1rem solid var(--linie);
  background: var(--karte);
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}
.knopf.primaer { background: var(--primaer); border-color: var(--primaer); color: var(--auf-primaer); }
.knopf.gefahr { color: var(--gefahr); border-color: currentColor; background: transparent; }
.knopf.breit { width: 100%; }
.knopf.text { border: 0; background: none; color: var(--primaer-text); padding: 0.3rem 0.6rem; min-height: 2.4rem; }
.knopf:disabled { opacity: 0.5; }

/* ---------------------------------------------------------------------
   Toast (kurze Meldung unten, z. B. "Rückgängig")
   --------------------------------------------------------------------- */
#toast {
  position: fixed;
  left: 0.6rem; right: 0.6rem;
  bottom: calc(4.2rem + env(safe-area-inset-bottom));
  z-index: 40;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 30rem;
  width: 100%;
  padding: 0.3rem 0.4rem 0.3rem 1rem;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--hg);
  box-shadow: var(--schatten);
}
.toast span {
  flex: 1;
  padding: 0.3rem 0;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.25;
}
.toast button { min-height: var(--tipp); border: 0; background: none; color: #75deff; font-weight: 700; padding: 0 0.8rem; }
@media (prefers-color-scheme: dark) { .toast button { color: #0067ad; } }

/* ---------------------------------------------------------------------
   Blatt von unten (Bearbeiten) und Dialoge
   --------------------------------------------------------------------- */
.schleier {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(22, 0, 45, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.blatt {
  width: 100%;
  max-width: 40rem;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--karte);
  border-radius: 1.2rem 1.2rem 0 0;
  padding: 0.8rem 1rem calc(1rem + env(safe-area-inset-bottom));
  animation: hoch 0.18s ease-out;
}
.schleier.mitte { align-items: center; padding: 1rem; }
.schleier.mitte .blatt { border-radius: 1.2rem; animation: none; }
@keyframes hoch { from { transform: translateY(30%); opacity: 0.4; } }
.blatt h2 { margin: 0.2rem 0 0.8rem; font-size: 1.25rem; }
.blatt p { margin: 0 0 1rem; color: var(--text2); }
.blatt-griff { width: 2.6rem; height: 0.3rem; border-radius: 1rem; background: var(--linie); margin: 0 auto 0.6rem; }

.feld { display: block; margin-bottom: 0.8rem; }
.feld > span { display: block; font-size: 0.85rem; font-weight: 600; color: var(--text2); margin-bottom: 0.2rem; }
.feld input, .feld select, .feld textarea {
  width: 100%;
  min-height: var(--tipp);
  padding: 0.3rem 0.8rem;
  border: 0.1rem solid var(--linie);
  border-radius: var(--radius);
  background: var(--hg);
  font-size: 1.05rem;
}
.feld-reihe { display: flex; gap: 0.6rem; }
.feld-reihe .feld { flex: 1; min-width: 0; }

.knopf-reihe { display: flex; gap: 0.6rem; margin-top: 1rem; }
.knopf-reihe .knopf { flex: 1; }

.abteilungs-wahl {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(6.8rem, 1fr));
  gap: 0.35rem;
}
.abteilungs-wahl button {
  min-height: var(--tipp);
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.5rem;
  border: 0.12rem solid var(--linie);
  border-radius: var(--radius);
  background: var(--hg);
  text-align: left;
  font-size: 0.8rem;
  line-height: 1.15;
}
.abteilungs-wahl button[aria-pressed="true"] { border-color: var(--primaer); background: var(--hell); font-weight: 700; }

/* Schalter (an/aus) */
.schalter {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  min-height: var(--tipp);
  padding: 0.2rem 0;
}
.schalter .beschriftung { flex: 1; }
.schalter .beschriftung small { display: block; color: var(--text2); font-size: 0.8rem; }
.schalter input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 3rem;
  height: 1.7rem;
  border-radius: 1rem;
  background: var(--linie);
  position: relative;
  transition: background 0.15s;
}
.schalter input::after {
  content: "";
  position: absolute;
  top: 0.15rem; left: 0.15rem;
  width: 1.4rem; height: 1.4rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  transition: transform 0.15s;
}
.schalter input:checked { background: var(--primaer); }
.schalter input:checked::after { transform: translateX(1.3rem); }

/* ---------------------------------------------------------------------
   Seitenmenü mit allen Listen
   --------------------------------------------------------------------- */
.menue-schleier { align-items: stretch; justify-content: flex-start; }
.menue {
  width: min(22rem, 88vw);
  height: 100%;
  overflow-y: auto;
  background: var(--karte);
  padding: calc(env(safe-area-inset-top) + 0.6rem) 0.6rem calc(1rem + env(safe-area-inset-bottom));
  animation: rein 0.18s ease-out;
}
@keyframes rein { from { transform: translateX(-30%); opacity: 0.4; } }
.menue h2 { margin: 0.3rem 0.4rem 0.6rem; font-size: 1.1rem; color: var(--text2); text-transform: uppercase; letter-spacing: 0.03em; }
.menue ul { list-style: none; margin: 0 0 0.8rem; padding: 0; }
.menue-zeile { display: flex; align-items: center; gap: 0.2rem; }
.menue-liste {
  flex: 1;
  min-width: 0;
  min-height: var(--tipp);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.6rem;
  border: 0;
  border-radius: var(--radius);
  background: none;
  text-align: left;
  font-size: 1.05rem;
}
.menue-liste[aria-current="true"] { background: var(--hell); font-weight: 700; }
.menue-liste .titel { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.zahl {
  min-width: 1.8rem;
  padding: 0 0.4rem;
  border-radius: 1rem;
  background: var(--primaer);
  color: var(--auf-primaer);
  font-size: 0.8rem;
  font-weight: 700;
  text-align: center;
}
.zahl.null { background: var(--linie); color: var(--text2); }

/* Sortieren per Ziehen */
.sortier-liste { list-style: none; margin: 0; padding: 0; }
.sortier-liste li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--tipp);
  padding: 0.2rem 0.2rem 0.2rem 0.6rem;
  margin-bottom: 0.3rem;
  background: var(--karte);
  border: 1px solid var(--linie);
  border-radius: var(--radius);
}
.sortier-liste li .titel { flex: 1; }
.sortier-liste li.zieht { box-shadow: 0 0.4rem 1.2rem rgba(22,0,45,0.25); position: relative; z-index: 2; border-color: var(--primaer); }
.griff {
  width: var(--tipp);
  min-height: var(--tipp);
  border: 0;
  background: none;
  display: grid;
  place-items: center;
  color: var(--text2);
  touch-action: none;
  cursor: grab;
}

/* ---------------------------------------------------------------------
   Einstellungen, Verlauf, Anmeldung
   --------------------------------------------------------------------- */
.abschnitt {
  background: var(--karte);
  border-radius: var(--radius);
  box-shadow: var(--schatten);
  padding: 0.6rem 0.9rem;
  margin-bottom: 0.9rem;
}
.abschnitt h2 { font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text2); margin: 0.2rem 0 0.5rem; }
.wahl { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.wahl button {
  flex: 1;
  min-height: var(--tipp);
  border-radius: var(--radius);
  border: 0.12rem solid var(--linie);
  background: var(--hg);
  font-weight: 600;
}
.wahl button[aria-pressed="true"] { border-color: var(--primaer); background: var(--hell); }
.klein-text { color: var(--text2); font-size: 0.8rem; }

.verlauf-zeile {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--tipp);
  border-bottom: 1px solid var(--linie);
}
.verlauf-zeile:last-child { border-bottom: 0; }
.verlauf-zeile .woerter { flex: 1; min-width: 0; }
.verlauf-zeile .name { font-size: 1.05rem; font-weight: 600; }
.verlauf-zeile .zusatz { color: var(--text2); font-size: 0.8rem; }
.verlauf-zeile .knopf-wieder[disabled] { color: var(--erledigt); }

.anmeldung {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(env(safe-area-inset-top) + 1rem) 1.2rem calc(env(safe-area-inset-bottom) + 1rem);
  max-width: 30rem;
  margin: 0 auto;
}
.anmeldung h1 { font-size: 2rem; margin: 0 0 0.4rem; color: var(--primaer-text); }
.anmeldung p { color: var(--text2); margin: 0 0 1.2rem; }
.anmeldung .code { font-size: 1.8rem; letter-spacing: 0.4em; text-align: center; font-variant-numeric: tabular-nums; }
.fehler { color: var(--gefahr); font-weight: 600; margin: 0.6rem 0; }
.verlauf-text { border: 0; background: none; padding: 0.3rem 0; text-align: left; display: flex; flex-direction: column; min-height: var(--tipp); justify-content: center; }
