/*
 * Farben und Schriften nach dem AORA-Styleguide:
 * Marine als Basis, Bronze als einziger, sparsamer Akzent, Stahlblau für Icons und Nebentext,
 * Sand und Silber für Flächen und Linien. Fraunces für Überschriften, Inter für Text.
 */
:root {
  --bg: #f7f6f2;          /* Sand */
  --card: #ffffff;        /* Weiß */
  --soft: #f7f6f2;        /* Sand, helle Kästen */
  --text: #22323f;        /* Marine */
  --muted: #57697a;
  --steel: #3f5b6b;       /* Stahlblau: Icons, Unterzeilen */
  --line: #e1dacb;        /* Linie zu Sand */
  --silver: #c4cbd0;      /* Trennlinien, Rahmen */
  --primary: #22323f;     /* Marine */
  --primary-ink: #ffffff;
  --bronze: #a97d45;      /* Akzent auf hellem Grund */
  --bronze-ink: #7a5a33;
  --dark: #1a2732;        /* Marine dunkel */
  --shadow: 0 1px 2px rgba(34, 50, 63, .05), 0 6px 18px rgba(34, 50, 63, .06);
  --radius: 14px;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141b21;
    --card: #1b242c;
    --soft: #222d36;
    --text: #edeae2;
    --muted: #b7c0c6;
    --steel: #9cb2be;
    --line: #2c3841;
    --silver: #3e4a52;
    --primary: #edeae2;
    --primary-ink: #1a2732;
    --bronze: #c9a468;    /* Bronze hell: Akzent auf dunklem Grund */
    --bronze-ink: #f4e6cc;
    --shadow: none;
    color-scheme: dark;
  }
}

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

html, body { margin: 0; background: var(--bg); color: var(--text); }

body {
  font: 400 17px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }

.icon { flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Bildschirme ---------- */

.screen {
  max-width: 640px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 12px) 16px calc(env(safe-area-inset-bottom) + 40px);
}

.screen-center {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.splash-icon { width: 72px; height: 72px; border-radius: 18px; }

.auth { width: 100%; max-width: 380px; text-align: center; }
.auth h1 { font: 600 30px/1.15 var(--serif); margin: 16px 0 8px; }
.auth form { text-align: left; margin-top: 24px; }
.auth-icon { width: 80px; height: 80px; border-radius: 20px; box-shadow: var(--shadow); }
.problem-icon { color: var(--steel); }
.problem-list { text-align: left; padding-left: 20px; margin: 18px 0 24px; }
.problem-list li { margin-bottom: 10px; }

.field { display: block; margin-bottom: 14px; min-width: 0; }
.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--steel); margin: 0 0 6px 2px; }
.field input, .field select, .field textarea {
  width: 100%;
  font-size: 17px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}
.field textarea { resize: none; line-height: 1.4; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--steel); }
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.error { color: #b5482f; font-size: 15px; margin: 4px 2px 14px; }

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  transition: transform .1s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); opacity: .85; }
.btn-block { display: flex; width: 100%; }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-soft { background: var(--soft); color: var(--text); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--muted); border-color: var(--line); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn:disabled { opacity: .4; }

.icon-btn {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--card);
  color: var(--steel);
  cursor: pointer;
}

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

.top { padding: 8px 2px 12px; }
.top-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.top h1 { font: 600 34px/1.1 var(--serif); margin: 0; letter-spacing: -.01em; }
.summary { margin: 6px 0 0; color: var(--steel); font-size: 15px; }
.summary::before {
  content: "";
  display: inline-block;
  width: 18px; height: 2px;
  background: var(--bronze);
  vertical-align: middle;
  margin: -2px 8px 0 0;
}

.offline {
  margin-top: 10px;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--bronze-ink);
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 12px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--bronze);
  font-size: 15px;
  line-height: 1.4;
}
.banner .banner-text { flex: 1; }
.banner .btn { padding: 9px 14px; font-size: 15px; white-space: nowrap; }
.banner .close { border: 0; background: none; color: var(--muted); font-size: 22px; padding: 0 4px; cursor: pointer; }

/* ---------- Eingabe ---------- */

.add {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -16px 10px;
  padding: 0 16px 10px;
  background: linear-gradient(var(--bg) 88%, transparent);
}
.add-main {
  display: flex;
  gap: 8px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  padding: 6px 6px 6px 16px;
}
.add-main input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 18px;
  padding: 8px 0;
}
.add-btn {
  width: 44px; height: 44px;
  flex: none;
  border: 0;
  border-radius: 10px;
  background: var(--bronze);
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
}
.add-btn .icon { stroke-width: 2.2; }
.add-btn:active { transform: scale(.94); }

.add-more { display: none; }
.add.open .add-more { display: block; animation: fade-in .18s ease-out; }
@keyframes fade-in { from { opacity: 0; transform: translateY(-4px); } }

.add-extra { display: flex; gap: 8px; margin-top: 8px; }
.add-extra input, .cat-select, .add-note {
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 16px;
}
.add-extra input { flex: 1; min-width: 0; padding: 0 12px; outline: none; }
.add-note { display: block; width: 100%; margin-top: 8px; padding: 0 12px; outline: none; }
.add-extra input:focus, .add-note:focus { border-color: var(--steel); }

.cat-select { position: relative; display: flex; align-items: center; padding: 0 12px; flex: 0 1 52%; min-width: 0; }
.cat-select select {
  border: 0;
  background: transparent;
  font-size: 16px;
  outline: none;
  min-width: 0;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  padding-right: 14px;
}
.cat-select::after {
  content: "";
  position: absolute;
  right: 13px; top: 50%;
  width: 6px; height: 6px;
  border-right: 1.6px solid var(--steel);
  border-bottom: 1.6px solid var(--steel);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

/* Läden-Auswahl und Filter */
.chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin-top: 0; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}
.chip.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.chip .count { color: var(--steel); margin-left: 6px; font-weight: 600; font-size: 13px; }
.chip.on .count { color: var(--bronze); }

.attach-row { display: flex; gap: 6px; margin-top: 8px; }
.attach {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  border-radius: 10px;
  border: 1px dashed var(--silver);
  background: transparent;
  color: var(--steel);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
}
.attach.has { border-style: solid; border-color: var(--steel); background: var(--card); color: var(--text); }
.attach img { width: 26px; height: 26px; border-radius: 5px; object-fit: cover; flex: none; }

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 -16px 18px;
  padding: 0 16px;
}
.filters::-webkit-scrollbar { display: none; }

/* ---------- Liste ---------- */

.group { margin-bottom: 22px; }
.group-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 0 4px 8px;
  font: 600 20px/1.2 var(--serif);
}
.group-title .n { font: 600 13px var(--sans); color: var(--steel); }
.items {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}
.item {
  display: grid;
  grid-template-columns: 52px 1fr;
  border-top: 1px solid var(--line);
  transition: opacity .35s ease;
}
.item:first-child { border-top: 0; }
.item.pending .name::after {
  content: "";
  display: inline-block;
  width: 6px; height: 6px;
  margin-left: 8px;
  border-radius: 50%;
  background: var(--silver);
  vertical-align: middle;
}

.check {
  border: 0;
  background: none;
  display: flex;
  justify-content: center;
  padding: 17px 0 0;
  cursor: pointer;
}
.check .ring {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 1.6px solid var(--silver);
  display: grid;
  place-items: center;
  transition: border-color .2s ease, transform .2s ease;
}
.check .icon { color: var(--bronze); stroke-width: 2.4; opacity: 0; transform: scale(.5); transition: opacity .2s ease, transform .2s ease; }
.item.done .check .ring { border-color: var(--bronze); transform: scale(1.06); }
.item.done .check .icon { opacity: 1; transform: scale(1); }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item.done { opacity: .55; }

.content { min-width: 0; padding: 0 12px 0 0; }
.body {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 0;
  background: none;
  text-align: left;
  padding: 14px 0 12px;
  cursor: pointer;
}
.body-text { flex: 1; min-width: 0; }
.name { display: block; font-size: 17px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.by { display: block; font-size: 13px; color: var(--steel); margin-top: 2px; }
.qty {
  flex: none;
  max-width: 38%;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--soft);
  border: 1px solid var(--line);
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Anhänge eines Artikels: eigene Zeile unter dem Namen */
.extras { display: flex; flex-direction: column; gap: 8px; padding: 0 0 14px; }
.note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 14px;
  line-height: 1.4;
  color: var(--text);
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  text-align: left;
  width: 100%;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.note .icon { color: var(--steel); margin-top: 1px; }
.media-row { display: flex; gap: 8px; align-items: stretch; }
.thumb {
  width: 64px; height: 64px;
  flex: none;
  border-radius: 10px;
  border: 1px solid var(--line);
  padding: 0;
  overflow: hidden;
  background: var(--soft);
  cursor: pointer;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.voice {
  position: relative;
  flex: 1;
  max-width: 240px;
  min-height: 44px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--soft);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  overflow: hidden;
  text-align: left;
}
.media-row .thumb + .voice { align-self: center; }
.voice .play-ic {
  width: 30px; height: 30px;
  flex: none;
  border-radius: 50%;
  border: 1.6px solid var(--steel);
  color: var(--steel);
  display: grid;
  place-items: center;
}
.voice .label { flex: 1; }
.voice .dur { color: var(--steel); font-weight: 500; font-variant-numeric: tabular-nums; }
.voice .bar {
  position: absolute;
  left: 0; bottom: 0;
  height: 3px;
  width: calc(var(--p, 0) * 100%);
  background: var(--bronze);
  transition: width .2s linear;
}
.voice.playing { border-color: var(--steel); }
.voice.playing .play-ic { border-color: var(--bronze); color: var(--bronze); }

.empty { text-align: center; padding: 50px 20px; color: var(--steel); }
.empty-title { font: 600 22px var(--serif); margin: 12px 0 4px; color: var(--text); }

/* ---------- Bottom-Sheets ---------- */

.sheet {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 640px;
  max-height: 92vh;
  background: transparent;
  color: var(--text);
}
.sheet::backdrop { background: rgba(26, 39, 50, .45); }
.sheet[open] { animation: sheet-in .25s ease-out; }
@keyframes sheet-in { from { transform: translateY(40px); opacity: 0; } }

.sheet-inner {
  background: var(--bg);
  border-radius: 20px 20px 0 0;
  padding: 10px 18px calc(env(safe-area-inset-bottom) + 18px);
  max-height: 92vh;
  overflow-y: auto;
}
.sheet-handle { width: 40px; height: 4px; border-radius: 2px; background: var(--silver); margin: 0 auto 12px; }
.sheet h2 { font: 600 24px/1.2 var(--serif); margin: 4px 0 18px; }
.sheet h3 { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet-actions .btn { flex: 1; }

.media-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.media-box img { width: 72px; height: 72px; border-radius: 10px; object-fit: cover; cursor: pointer; border: 1px solid var(--line); }
.media-box .btn { padding: 10px 14px; font-size: 15px; }
.media-box .voice { flex: 0 1 200px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card .btn + .btn { margin-top: 8px; }
.card p { margin: 0 0 10px; }
.card p:last-child { margin-bottom: 0; }

/* Aufnahme */
.rec { text-align: center; }
.rec-time { font: 400 44px var(--serif); font-variant-numeric: tabular-nums; margin: 8px 0 18px; }
.rec-btn {
  width: 84px; height: 84px;
  border-radius: 50%;
  border: 1.6px solid var(--steel);
  background: var(--card);
  color: var(--steel);
  display: grid;
  place-items: center;
  margin: 0 auto;
  cursor: pointer;
}
.rec-btn .icon { width: 34px; height: 34px; }
.rec-btn.recording { background: var(--bronze); border-color: var(--bronze); color: #fff; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(169, 125, 69, .18); } }

/* Foto groß */
.viewer {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: 100vw;
  max-height: 100vh;
  width: 100vw;
  height: 100vh;
  margin: 0;
}
.viewer::backdrop { background: rgba(20, 27, 33, .95); }
.viewer img { width: 100%; height: 100%; object-fit: contain; display: block; }
.viewer-close {
  position: fixed;
  top: calc(env(safe-area-inset-top) + 12px);
  right: 16px;
  width: 40px; height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(196, 203, 208, .4);
  background: transparent;
  color: #c4cbd0;
  display: grid;
  place-items: center;
  cursor: pointer;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom) + 18px);
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 460px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 12px 18px;
  border-radius: 12px;
  background: #1a2732;
  color: #edeae2;
  font-size: 15px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
  z-index: 50;
  animation: toast-in .2s ease-out;
}
#toast-text { flex: 1; }
#toast-undo {
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  background: transparent;
  color: #c9a468;
  font-weight: 700;
  cursor: pointer;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* Sprachsteuerung: Adresse + Kopieren */
.copy-field > span:first-child { margin-bottom: 6px; }
.field > .copy-row { display: flex; gap: 8px; margin: 0; color: inherit; font-size: inherit; font-weight: inherit; }
.copy-row input { flex: 1; width: auto !important; min-width: 0; font-size: 14px !important; padding: 10px 12px !important; color: var(--steel); text-overflow: ellipsis; }
.copy-row .btn { padding: 10px 14px; font-size: 15px; flex: none; }
#voice-renew { font-size: 14px; padding: 8px; }
