/* ============================================================
   Einkauf — Design-Tokens
   Leitbild: Werkzeug für den Supermarkt. Daumen, schlechtes Licht, Eile.
   Ein Akzent (Indigo, der Textilfarbstoff) auf ungebleichtem Leinen.
   Keine Web-Fonts: muss offline sofort laden.
   ============================================================ */
:root {
  --paper:        #E9E4D8;  /* Leinen, Hintergrund */
  --paper-raised: #F4F0E7;  /* Karten, Zeilen */
  --ink:          #23211C;  /* Fast-Schwarz, warm */
  --ink-soft:     #6E6858;  /* gedämpfte Labels */
  --indigo:       #2C3E63;  /* Akzent: Aktionen, Gang-Bänder */
  --indigo-deep:  #1E2B47;
  --indigo-tint:  #E3E4EC;  /* heller Indigo-Schleier */
  --line:         #D4CDBD;  /* Haarlinien */
  --danger:       #8C3B2E;

  --tap: 56px;              /* Mindest-Tipphöhe */
  --radius: 14px;
  --shadow: 0 1px 2px rgba(35,33,28,.06), 0 6px 20px rgba(35,33,28,.06);

  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden muss display-Regeln schlagen — sonst zeigt der Browser
   .login/.app trotz hidden-Attribut an (display gewinnt gegen hidden). */
[hidden] { display: none !important; }

/* <dialog> ist nur sichtbar, wenn per showModal() geöffnet.
   Ohne diese Regel rendern manche Browser den Inhalt trotzdem im Fluss. */
dialog:not([open]) { display: none !important; }

html, body {
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, input, select { font-family: inherit; font-size: inherit; }

/* ---------- Bausteine ---------- */
.eyebrow {
  font-size: .72rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-soft);
  font-weight: 600;
}

.btn-primary {
  min-height: var(--tap);
  padding: 0 1.25rem;
  background: var(--indigo);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 650;
  font-size: 1.02rem;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:active { background: var(--indigo-deep); }

.btn-ghost {
  min-height: 44px;
  padding: 0 .9rem;
  background: transparent;
  color: var(--ink-soft);
  border: none;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
}
.btn-ghost:active { background: rgba(35,33,28,.06); }

.btn-danger {
  min-height: 44px;
  padding: 0 .9rem;
  background: transparent;
  color: var(--danger);
  border: none;
  border-radius: 10px;
  font-weight: 650;
  cursor: pointer;
  margin-right: auto;   /* schiebt Löschen nach links, weg von Speichern */
}
.btn-danger:active { background: rgba(140,59,46,.08); }

.field { display: flex; flex-direction: column; gap: .4rem; }
.field > span {
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink-soft);
}
.field > span em { font-weight: 400; font-style: normal; opacity: .7; }
.field input, .field select {
  min-height: var(--tap);
  padding: 0 .9rem;
  background: var(--paper-raised);
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--indigo);
}

.error { color: var(--danger); font-size: .88rem; font-weight: 600; }

/* ============================================================
   Login
   ============================================================ */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}
.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--paper-raised);
  padding: 2rem 1.5rem;
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.login-title {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -.02em;
  margin-bottom: .5rem;
}

/* ============================================================
   App-Grundgerüst
   ============================================================ */
.app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .75rem 1rem .4rem;
}
.brand {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -.01em;
}

/* Listen-Tabs */
.list-tabs {
  display: flex;
  gap: .4rem;
  padding: 0 1rem .6rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.list-tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0 1rem;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: .95rem;
  cursor: pointer;
  white-space: nowrap;
}
.tab.active {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
}
.tab-add {
  flex: 0 0 auto;
  min-height: 40px;
  width: 40px;
  border: 1.5px dashed var(--line);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

/* ============================================================
   Inhalt: Gänge + Artikel
   ============================================================ */
.content {
  flex: 1;
  padding-bottom: calc(var(--tap) + 2.5rem);
}

/* Signatur: das Gang-Band. Bleibt beim Scrollen oben kleben —
   wie ein Gangschild im Markt. Die Reihenfolge ist der Laufweg. */
.aisle-band {
  position: sticky;
  top: calc(env(safe-area-inset-top) + 0px);
  z-index: 10;
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .55rem 1rem;
  background: var(--indigo);
  color: #fff;
}
.aisle-index {
  font-size: .72rem;
  font-weight: 700;
  opacity: .6;
  font-variant-numeric: tabular-nums;
}
.aisle-name {
  font-size: .82rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.aisle-empty {
  padding: 1rem;
  color: var(--ink-soft);
  font-size: .9rem;
}

/* Artikelzeile */
.item {
  display: flex;
  align-items: center;
  gap: .9rem;
  min-height: var(--tap);
  padding: .5rem 1rem;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
  cursor: pointer;
  user-select: none;
}
.item:active { background: var(--paper-raised); }

/* Abhak-Knopf: großes Tippziel */
.item-check {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  border: 2px solid var(--indigo);
  border-radius: 8px;
  background: transparent;
}
.item-body { flex: 1; min-width: 0; }
.item-name {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
}
.item-qty {
  font-size: .82rem;
  color: var(--ink-soft);
  font-weight: 500;
}
.item-by {
  flex: 0 0 auto;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink-soft);
  text-transform: uppercase;
  opacity: .55;
}

/* Verschwinde-Animation beim Abhaken */
.item.checking {
  animation: strike .28s ease forwards;
  pointer-events: none;
}
@keyframes strike {
  to { opacity: 0; transform: translateX(12px); max-height: 0; padding-top: 0; padding-bottom: 0; }
}

/* Leerzustand */
.empty {
  padding: 4rem 1.5rem;
  text-align: center;
  color: var(--ink-soft);
}
.empty h2 { font-size: 1.1rem; margin-bottom: .4rem; color: var(--ink); }
.empty p { font-size: .95rem; }

/* ============================================================
   Eingabeleiste (Daumenbereich)
   ============================================================ */
.composer {
  position: fixed;
  left: 0; right: 0;
  bottom: 0;
  padding: .8rem 1rem calc(.8rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--paper) 70%, transparent);
}
.composer-add { width: 100%; }

/* ============================================================
   Sheets (Dialoge)
   ============================================================ */
.sheet {
  border: none;
  padding: 0;
  background: transparent;
  max-width: 480px;
  width: 100%;
}
.sheet::backdrop { background: rgba(35,33,28,.4); }
.sheet[open] { animation: sheet-in .2s ease; }
@keyframes sheet-in { from { transform: translateY(-16px); opacity: 0; } }

/* Aktiver Gang: das Band, in das neue Artikel wandern. Deutlich, aber ruhig. */
.aisle-band.active-aisle {
  background: var(--indigo-deep);
  box-shadow: inset 4px 0 0 var(--paper);
}
.aisle-band { cursor: pointer; }
.aisle-hint {
  margin-left: auto;
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .08em;
  opacity: .7;
  text-transform: uppercase;
}

/* Stift rechts im Band: eigene Trefferfläche zum Bearbeiten. */
.aisle-edit {
  margin-left: auto;         /* schiebt sich nach rechts, wenn kein "aktiv" da ist */
  width: 40px;
  height: 32px;
  border: none;
  background: rgba(255,255,255,.12);
  color: #fff;
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
}
.aisle-edit:active { background: rgba(255,255,255,.25); }
/* Wenn "aktiv" da ist, hat das schon margin-left:auto — dann Stift knapp daneben */
.aisle-hint + .aisle-edit { margin-left: .5rem; }

.sheet-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: var(--paper-raised);
  padding: 1.5rem;
  border-radius: 20px;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow);
}
.sheet-title { font-size: 1.25rem; font-weight: 750; }
.sheet-actions {
  display: flex;
  gap: .6rem;
  align-items: center;
  justify-content: flex-end;
  margin-top: .3rem;
}

/* Dialog oben andocken statt unten: die Bildschirmtastatur kommt von
   unten hoch und würde ein unten angedocktes Formular verdecken. Oben
   mit etwas Abstand bleibt das Eingabefeld über der Tastatur sichtbar. */
dialog.sheet {
  margin: 0;
  position: fixed;
  inset: 0;
  height: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(2rem, env(safe-area-inset-top)) 1rem 1rem;
}

/* ============================================================
   Toast
   ============================================================ */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tap) + 3rem);
  transform: translateX(-50%);
  z-index: 40;
  background: var(--ink);
  color: var(--paper);
  padding: .7rem 1.1rem;
  border-radius: 12px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
}

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