/* NoteApp — Einkaufen-Modul. Gedacht fuer eine Hand am Wagen, die andere
   am Telefon. Keine externen Schriften oder Bilder: die Seite laeuft ohne
   Internet. */

:root {
  --papier: #ffffff;
  --tinte: #000000;
  --grau: #6b6b6b;
  --linie: #e2e2e2;
  --zeile-hoehe: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--papier);
  color: var(--tinte);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-text-size-adjust: 100%;
}

body {
  padding-bottom: 40px;
  max-width: 620px;
  margin: 0 auto;
}

/* --- Kopf ---------------------------------------------------------------- */

.kopf {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--papier);
  border-bottom: 2px solid var(--tinte);
  padding: calc(14px + env(safe-area-inset-top)) 0 0;
}

.kopf-zeile {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 16px;
}

h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.reiter { display: flex; gap: 4px; }

.reiter-knopf {
  appearance: none;
  border: 1.5px solid var(--linie);
  background: var(--papier);
  color: var(--grau);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 999px;
  min-height: 36px;
}

.reiter-knopf[aria-selected="true"] {
  border-color: var(--tinte);
  background: var(--tinte);
  color: var(--papier);
}

.zaehler {
  margin: 4px 16px 6px;
  font-size: 14px;
  color: var(--grau);
}

.wer-knopf {
  appearance: none;
  border: 0;
  background: none;
  color: var(--grau);
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  padding: 0 16px 10px;
  margin: 0;
  min-height: 32px;
}

/* --- Ortsauswahl: Dropdown statt Badge-Reihe ------------------------------ */

.orte { position: relative; padding: 0 16px 12px; }

.ort-knopf {
  appearance: none;
  border: 1.5px solid var(--tinte);
  background: var(--papier);
  color: var(--tinte);
  font: inherit;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  min-height: 48px;
}

.ort-knopf .punkt { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.ort-knopf .ort-knopf-name { font-size: 16px; font-weight: 700; }
.ort-knopf .ort-knopf-zahl { font-size: 13px; color: var(--grau); }
.ort-knopf .ort-knopf-pfeil {
  margin-left: auto;
  flex: none;
  color: var(--grau);
  transition: transform 0.15s ease;
}
.ort-knopf[aria-expanded="true"] .ort-knopf-pfeil { transform: rotate(180deg); }

.ort-liste {
  position: absolute;
  left: 16px;
  right: 16px;
  top: calc(100% - 6px);
  z-index: 25;
  background: var(--papier);
  border: 1.5px solid var(--tinte);
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
  padding: 6px;
}

.ort-option {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 16px;
  padding: 4px 4px 4px 10px;
  border-radius: 8px;
  text-align: left;
}
.ort-option .punkt { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.ort-option .ort-option-name { flex: 1; padding: 7px 0; min-width: 0; overflow-wrap: anywhere; }
.ort-option .ort-option-zahl { font-size: 13px; color: var(--grau); flex: none; }
.ort-option[aria-selected="true"] .ort-option-name { font-weight: 700; }
.ort-option:hover, .ort-option:active { background: #f4f4f4; }

.ort-loeschen {
  appearance: none;
  border: 0;
  background: none;
  color: var(--grau);
  flex: none;
  min-width: 36px;
  min-height: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.ort-loeschen svg { width: 16px; height: 16px; }
.ort-loeschen.papierkorb-scharf { color: #fff; background: #b3261e; }

.ort-verwalten {
  border-top: 1px solid var(--linie);
  margin-top: 4px;
  padding-top: 6px;
  display: flex;
  gap: 8px;
  padding-left: 4px;
  padding-right: 4px;
}
.ort-verwalten-feld {
  flex: 1;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1.5px solid var(--linie);
  border-radius: 8px;
  min-width: 0;
}
.ort-verwalten-knopf {
  appearance: none;
  border: 0;
  background: var(--tinte);
  color: var(--papier);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 0 12px;
  border-radius: 8px;
  flex: none;
}

.deckel { position: fixed; inset: 0; z-index: 24; background: transparent; border: 0; padding: 0; }

.abschnitt-leer {
  padding: 40px 16px;
  font-size: 16px;
  color: var(--grau);
  text-align: center;
}

/* --- Zeilen -------------------------------------------------------------- */

.zeile {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--zeile-hoehe);
  padding: 6px 4px 6px 16px;
  border-top: 1px solid var(--linie);
  background: var(--papier);
  position: relative;
}
main .zeile:first-child { border-top: none; }

.zeile-tippen {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1 1 auto;
  min-width: 0;
  min-height: calc(var(--zeile-hoehe) - 12px);
  padding: 0;
}

.kasten {
  flex: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--tinte);
  border-radius: 5px;
  display: grid;
  place-items: center;
}

.zeile.erledigt .kasten { background: var(--tinte); }
.kasten svg { display: none; }
.zeile.erledigt .kasten svg { display: block; }

.zeile-text { font-size: 17px; font-weight: 500; overflow-wrap: anywhere; min-width: 0; }
.zeile.erledigt .zeile-text { color: var(--grau); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.zeile-quelle { font-size: 12px; color: var(--grau); margin-left: 4px; white-space: nowrap; }
.zeile-wer { font-size: 12px; color: var(--grau); margin-left: 4px; white-space: nowrap; }

.zeile-aktionen { display: flex; align-items: center; gap: 2px; flex: none; }

.icon-knopf {
  appearance: none;
  border: 0;
  background: none;
  color: var(--grau);
  font: inherit;
  min-width: 42px;
  min-height: 42px;
  flex: none;
  border-radius: 8px;
  display: grid;
  place-items: center;
}
.icon-knopf svg { width: 20px; height: 20px; }
.icon-knopf.aktiv { background: #f0f0f0; color: var(--tinte); }
.icon-knopf.papierkorb-scharf { color: #fff; background: #b3261e; }

.verschiebe-menue {
  position: absolute;
  right: 8px;
  top: calc(var(--zeile-hoehe) - 4px);
  z-index: 15;
  background: var(--papier);
  border: 1.5px solid var(--tinte);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.15);
  min-width: 180px;
}
.verschiebe-titel { font-size: 12px; color: var(--grau); padding: 4px 8px 6px; }
.verschiebe-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 15px;
  padding: 9px 8px;
  border-radius: 6px;
  text-align: left;
}
.verschiebe-option .punkt { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.verschiebe-option:active { background: #f0f0f0; }

/* --- Artikel hinzufuegen --------------------------------------------------- */

.neu {
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid var(--linie);
  padding: 6px 16px;
  min-height: var(--zeile-hoehe);
}

.neu-knopf {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--grau);
  padding: 12px 0;
  min-height: 44px;
  text-align: left;
  flex: 1;
}

.neu-feld {
  flex: 1;
  font: inherit;
  font-size: 16px;
  padding: 10px 12px;
  border: 2px solid var(--tinte);
  border-radius: 8px;
  min-width: 0;
  background: var(--papier);
  color: var(--tinte);
}

.neu-sichern {
  appearance: none;
  border: 0;
  background: var(--tinte);
  color: var(--papier);
  font: inherit;
  font-weight: 700;
  padding: 0 14px;
  min-height: 42px;
  border-radius: 8px;
  flex: none;
}

/* --- Abschluss, jetzt inline statt fixer Leiste --------------------------- */

.abschluss { margin: 20px 16px 0; border: 1.5px solid var(--linie); border-radius: 12px; padding: 12px 14px; }
.abschluss-inhalt { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.abschluss-text { font-size: 14px; color: var(--grau); flex: 1 1 auto; min-width: 100px; }
.knopf-paar { display: flex; gap: 8px; flex: none; }
.knopf-haupt {
  appearance: none;
  border: 0;
  background: var(--tinte);
  color: var(--papier);
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 0 16px;
  min-height: 46px;
  border-radius: 10px;
  flex: none;
}
.knopf-leise {
  appearance: none;
  border: 2px solid var(--linie);
  background: var(--papier);
  color: var(--tinte);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 0 14px;
  min-height: 46px;
  border-radius: 10px;
}

/* --- Historie -------------------------------------------------------------- */

.einkauf { margin-top: 26px; }

.einkauf-kopf {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 0 16px 8px;
  border-bottom: 2px solid var(--tinte);
}
.einkauf-datum { font-size: 16px; font-weight: 700; }
.einkauf-zahl { margin-left: auto; font-size: 14px; color: var(--grau); }

.einkauf-zeile {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--linie);
  padding: 0 8px 0 16px;
  min-height: 52px;
}
.einkauf-text { flex: 1; font-size: 16px; overflow-wrap: anywhere; }
.einkauf-wo { font-size: 13px; color: var(--grau); white-space: nowrap; }
.einkauf-wer { font-size: 13px; color: var(--grau); white-space: nowrap; }

.herunterladen-zeile { padding: 0 16px 4px; }
.herunterladen-knopf {
  appearance: none;
  border: 1.5px solid var(--linie);
  background: var(--papier);
  color: var(--tinte);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 10px;
}

.einkauf-nochmal {
  appearance: none;
  border: 1.5px solid var(--linie);
  background: var(--papier);
  color: var(--tinte);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  flex: none;
}

/* --- Hinweis --------------------------------------------------------------- */

.hinweis {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--tinte);
  color: var(--papier);
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 15px;
  max-width: 596px;
  margin: 0 auto;
}

.hinweis-knopf {
  appearance: none;
  border: 1.5px solid rgba(255,255,255,0.5);
  background: none;
  color: var(--papier);
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 999px;
  margin-left: auto;
  flex: none;
}

.fehler { background: #b3261e; }
.getrennt .kopf { border-bottom-color: #b3261e; }

button:focus-visible, input:focus-visible {
  outline: 3px solid #0b57d0;
  outline-offset: 2px;
}

@media (prefers-reduced-motion: no-preference) {
  .hinweis { transition: opacity 0.15s ease; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --papier: #0c0c0c;
    --tinte: #ffffff;
    --grau: #9a9a9a;
    --linie: #2c2c2c;
  }
  .hinweis { background: #ffffff; color: #0c0c0c; }
  .hinweis-knopf { border-color: rgba(0,0,0,0.4); color: #0c0c0c; }
  .neu-sichern, .knopf-haupt { color: #0c0c0c; }
}
