/* Familienkorb – ruhig, hell, Salbei */
:root {
  --bg: #F5F6F1;
  --surface: #FFFFFF;
  --surface-2: #EEF1EA;
  --line: #DFE4DA;
  --text: #1F2A22;
  --muted: #5E6B61;
  --faint: #8A958C;
  --sage: #5E8A6B;
  --sage-strong: #4A7356;
  --sage-soft: #E3ECE2;
  --danger: #B3402F;
  --warn: #A86A12;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(31, 42, 34, .06), 0 4px 16px rgba(31, 42, 34, .06);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --vvh: 100dvh;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100dvh;
}
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
input, textarea { font-size: 17px; } /* >= 16px: kein Auto-Zoom in iOS */
img { max-width: 100%; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.boot { padding: 40vh 16px 0; text-align: center; color: var(--muted); }

/* ---------- Kopfbereich ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 12px) 6px calc(var(--safe-left) + 12px);
  border-bottom: 1px solid transparent;
}
.top.scrolled { border-bottom-color: var(--line); }
.top-row { display: flex; align-items: center; gap: 4px; min-height: 44px; }
.brand { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 0 auto 0 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 0 auto; max-width: 52vw; }
.brand small { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.icon-btn {
  width: 44px; height: 44px; flex: none; border: 0; border-radius: 12px; background: transparent;
  display: inline-grid; place-items: center; color: var(--text);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 22px; height: 22px; }

.sync {
  display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 9px; flex: 0 1 auto; min-width: 0;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface);
  font-size: 12.5px; color: var(--muted); white-space: nowrap; max-width: 46vw; overflow: hidden;
}
.sync span:last-child { overflow: hidden; text-overflow: ellipsis; }
.sync .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.sync--ok .dot { background: var(--sage); }
.sync--pending .dot { background: #D3A13A; animation: pulse 1.2s ease-in-out infinite; }
.sync--connecting .dot { background: #C9B98F; animation: pulse 1.2s ease-in-out infinite; }
.sync--offline { color: var(--warn); border-color: #EBD9B8; background: #FBF5EA; }
.sync--offline .dot { background: var(--warn); }
.sync--error { color: var(--danger); border-color: #EBC5BE; background: #FCF0EE; }
.sync--error .dot { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

.search { padding: 4px 0 6px; }
.search input {
  width: 100%; height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  padding: 0 14px; outline: none;
}
.search input:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }

.tabs {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 2px 4px;
  margin: 0 -12px; padding-left: 12px; padding-right: 12px; scroll-padding: 12px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 12px 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-size: 15px; font-weight: 500;
}
.tab .count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tab[aria-selected="true"] { background: var(--text); color: #fff; border-color: var(--text); }
.tab[aria-selected="true"] .count { color: rgba(255,255,255,.75); }
.swatch { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* ---------- Liste ---------- */
.main { padding: 4px calc(var(--safe-right) + 12px) calc(var(--safe-bottom) + 110px) calc(var(--safe-left) + 12px); max-width: 720px; margin: 0 auto; }
.group { margin: 14px 0 6px; }
.group-head { display: flex; align-items: center; gap: 10px; padding: 0 4px 8px; }
.group-head h2 { font-size: 15px; margin: 0; font-weight: 650; }
.group-head .count { margin-left: auto; color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.badge {
  width: 26px; height: 26px; border-radius: 8px; display: inline-grid; place-items: center;
  font-weight: 800; font-size: 15px; flex: none; letter-spacing: -.02em;
}
.cards { list-style: none; margin: 0; padding: 0; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.item { display: flex; align-items: center; gap: 4px; min-height: 64px; padding: 6px 8px 6px 4px; position: relative; border-left: 3px solid var(--accent, transparent); }
.item + .item { border-top: 1px solid var(--line); }
.check {
  width: 48px; height: 48px; flex: none; border: 0; background: transparent; display: grid; place-items: center; border-radius: 50%;
}
.check .ring {
  width: 28px; height: 28px; border-radius: 50%; border: 2px solid #A9B5AB; display: grid; place-items: center;
  transition: background .15s, border-color .15s; background: var(--surface);
}
.check svg { width: 16px; height: 16px; opacity: 0; color: #fff; transition: opacity .15s; }
.check:active .ring { transform: scale(.94); }
.item.bought .check .ring { background: var(--sage); border-color: var(--sage); }
.item.bought .check svg { opacity: 1; }
.thumb {
  width: 56px; height: 56px; flex: none; border-radius: 10px; border: 1px solid var(--line); padding: 0; overflow: hidden;
  background: var(--surface-2); margin: 0 2px 0 6px; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .prog { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--sage); }
.body { flex: 1; min-width: 0; padding: 6px 4px; border: 0; background: transparent; text-align: left; align-self: stretch; display: flex; flex-direction: column; justify-content: center; }
.name { font-size: 17px; font-weight: 600; line-height: 1.25; overflow-wrap: anywhere; }
.qty { font-weight: 500; color: var(--sage-strong); white-space: nowrap; }
.note { font-size: 15px; color: var(--muted); overflow-wrap: anywhere; margin-top: 1px; }
.meta { font-size: 13px; color: var(--faint); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 0 8px; }
.meta .pend { color: var(--warn); }
.meta .fail { color: var(--danger); }
.store-pill { font-size: 12px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.item.bought .name { text-decoration: line-through; text-decoration-color: rgba(31,42,34,.35); color: var(--muted); font-weight: 500; }
.item.bought .thumb { opacity: .7; }
.chev { width: 20px; height: 20px; color: #B8C1B9; flex: none; }

.bought-wrap { margin: 22px 0 8px; }
.bought-toggle {
  width: 100%; min-height: 48px; display: flex; align-items: center; gap: 10px; border: 0; background: transparent;
  padding: 0 6px; font-weight: 600; color: var(--muted); font-size: 15px;
}
.bought-toggle svg { width: 18px; height: 18px; transition: transform .2s; }
.bought-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.bought-toggle .count { margin-left: auto; font-weight: 500; }
.link-btn { border: 0; background: transparent; color: var(--sage-strong); font-weight: 600; min-height: 44px; padding: 0 8px; font-size: 15px; }
.link-btn.danger { color: var(--danger); }

.empty { text-align: center; padding: 48px 20px 24px; color: var(--muted); }
.empty .big { font-size: 18px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.empty svg { width: 52px; height: 52px; color: #B9C7B9; margin-bottom: 10px; }

/* ---------- Hinzufügen-Button ---------- */
.fab-wrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; pointer-events: none;
  padding: 12px calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 14px) calc(var(--safe-left) + 16px);
  background: linear-gradient(to top, var(--bg) 55%, transparent);
  display: flex; justify-content: center;
}
.fab {
  pointer-events: auto; height: 54px; padding: 0 26px; border-radius: 999px; border: 0;
  background: var(--sage); color: #fff; font-size: 17px; font-weight: 650; display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 6px 20px rgba(74,115,86,.35); width: 100%; max-width: 420px; justify-content: center;
}
.fab:active { background: var(--sage-strong); transform: translateY(1px); }
.fab svg { width: 22px; height: 22px; }

/* ---------- Buttons & Formulare ---------- */
.btn {
  min-height: 48px; padding: 0 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-size: 16px;
}
.btn:disabled { opacity: .5; }
.btn.primary { background: var(--sage); border-color: var(--sage); color: #fff; }
.btn.primary:active { background: var(--sage-strong); }
.btn.danger { color: var(--danger); }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.field { display: block; margin: 0 0 14px; }
.field > span { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin: 0 0 6px 2px; }
.input, .textarea {
  width: 100%; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  padding: 11px 14px; outline: none; font-size: 17px;
}
.textarea { min-height: 76px; resize: vertical; }
.input:focus, .textarea:focus { border-color: var(--sage); box-shadow: 0 0 0 3px var(--sage-soft); }
.input.code { font-size: 22px; letter-spacing: .12em; text-transform: uppercase; font-variant-numeric: tabular-nums; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.hint { font-size: 14px; color: var(--muted); margin: 6px 2px 0; }
.error { color: var(--danger); font-size: 15px; margin: 8px 2px; }

.store-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.store-pick label { position: relative; }
.store-pick input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.store-pick .opt {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; font-size: 16px;
}
.store-pick input:checked + .opt { border-color: var(--text); background: var(--text); color: #fff; }
.store-pick input:focus-visible + .opt { box-shadow: 0 0 0 3px var(--sage-soft); }

/* ---------- Dialoge (oben verankert, damit die Tastatur nichts verdeckt) ---------- */
dialog { color: var(--text); }
.sheet {
  border: 0; padding: 0; margin: calc(var(--safe-top) + 8px) auto auto; width: min(560px, calc(100vw - 16px));
  max-height: calc(var(--vvh) - var(--safe-top) - 16px); border-radius: 18px; background: var(--bg);
  box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden;
}
.sheet[open] { display: flex; flex-direction: column; animation: sheetIn .18s ease-out; }
.sheet::backdrop { background: rgba(24, 32, 26, .38); }
@keyframes sheetIn { from { transform: translateY(-8px); opacity: 0; } }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 8px 6px 18px; }
.sheet-head h2 { font-size: 18px; margin: 0 auto 0 0; }
.sheet-body { padding: 6px 16px 12px; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; flex: 1; }
.sheet-foot { display: flex; gap: 8px; padding: 10px 16px calc(12px); border-top: 1px solid var(--line); background: var(--bg); align-items: center; flex-wrap: wrap; }
.sheet-foot .spacer { flex: 1; }
.details-toggle { margin: 2px 0 12px; }
.img-row { display: flex; gap: 8px; flex-wrap: wrap; }
.img-row .btn { flex: 1 1 120px; padding: 0 12px; white-space: nowrap; }
.preview { position: relative; margin-top: 10px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.preview img { display: block; width: 100%; max-height: 260px; object-fit: contain; background: #fff; }
.preview .preview-actions { display: flex; gap: 8px; padding: 8px; }
.sec { background: var(--surface); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.sec h3 { margin: 0 0 10px; font-size: 16px; }
.row { display: flex; align-items: center; gap: 10px; min-height: 48px; }
.row + .row { border-top: 1px solid var(--line); }
.row .grow { flex: 1; min-width: 0; }
.row .sub { font-size: 13px; color: var(--muted); }
.code-box { font: 600 26px/1.2 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; text-align: center; padding: 14px; border-radius: 12px; background: var(--sage-soft); margin: 6px 0 10px; user-select: all; -webkit-user-select: all; }
.inline-form { display: flex; gap: 8px; }
.inline-form .input { flex: 1; min-width: 0; }

/* ---------- Bildansicht ---------- */
.viewer { border: 0; padding: 0; margin: 0; width: 100vw; height: 100dvh; max-width: none; max-height: none; background: #0f1310; color: #fff; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: #0f1310; }
.viewer-head { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-top) + 6px) 8px 6px 16px; }
.viewer-head .t { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer .icon-btn { color: #fff; }
.viewer .icon-btn:active { background: rgba(255,255,255,.12); }
.viewer-img { flex: 1; display: grid; place-items: center; padding: 8px 8px calc(var(--safe-bottom) + 8px); overflow: auto; touch-action: pinch-zoom pan-x pan-y; }
.viewer-img img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 6px; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(var(--safe-bottom) + 84px); z-index: 1000; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 0 12px;
}
.toast {
  pointer-events: auto; max-width: 520px; width: 100%; display: flex; align-items: center; gap: 10px;
  background: #24302A; color: #fff; border-radius: 14px; padding: 10px 10px 10px 16px; min-height: 52px;
  box-shadow: 0 10px 30px rgba(0,0,0,.2); font-size: 15px; animation: toastIn .2s ease-out;
}
.toast.warn { background: #5B4313; }
.toast.error { background: #7A2A1F; }
.toast .t { flex: 1; }
.toast button { border: 0; background: rgba(255,255,255,.14); color: #fff; font-weight: 700; min-height: 40px; min-width: 44px; padding: 0 12px; border-radius: 10px; font-size: 15px; }
@keyframes toastIn { from { transform: translateY(8px); opacity: 0; } }
dialog .toasts { bottom: 16px; }

/* ---------- Onboarding ---------- */
.onb { max-width: 520px; margin: 0 auto; padding: calc(var(--safe-top) + 28px) calc(var(--safe-right) + 16px) calc(var(--safe-bottom) + 28px) calc(var(--safe-left) + 16px); }
.onb .logo { width: 64px; height: 64px; border-radius: 16px; display: block; margin-bottom: 14px; }
.onb h1 { font-size: 26px; margin: 0 0 6px; }
.onb p.lead { color: var(--muted); margin: 0 0 20px; }
.callout { background: #FBF5EA; border: 1px solid #EBD9B8; border-radius: 12px; padding: 12px 14px; font-size: 15px; margin-bottom: 16px; }
.callout.info { background: var(--sage-soft); border-color: #CCDCCB; }
.seg { display: grid; grid-template-columns: 1fr 1fr; background: var(--surface-2); border-radius: 12px; padding: 4px; margin-bottom: 16px; }
.seg button { min-height: 44px; border: 0; background: transparent; border-radius: 9px; font-weight: 600; color: var(--muted); font-size: 15px; }
.seg button[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.demo-bar { background: #FBF5EA; color: var(--warn); text-align: center; font-size: 13px; padding: calc(var(--safe-top) + 4px) 12px 4px; }
.demo-bar + .top { padding-top: 6px; }
.demo-bar button { border: 0; background: transparent; color: inherit; text-decoration: underline; font-size: 13px; min-height: 28px; }
.setup pre { white-space: pre-wrap; background: var(--surface); padding: 12px; border-radius: 10px; font-size: 14px; overflow-x: auto; }

/* ---------- Feuerwerk ---------- */
.fw-layer { position: fixed; width: 0; height: 0; pointer-events: none; z-index: 2000; }
.fw-p { position: absolute; left: 0; top: 0; border-radius: 50%; }

@media (max-width: 359px) {
  .brand { font-size: 17px; }
  .icon-btn { width: 40px; }
  .code-box { font-size: 21px; letter-spacing: .04em; }
  .tab { padding: 0 10px 0 9px; }
}
.code-box { white-space: nowrap; }
@media (min-width: 700px) {
  .fab-wrap { justify-content: flex-end; padding-right: max(24px, calc((100vw - 720px) / 2)); }
  .fab { width: auto; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Wer hat's erfasst ---------- */
.who { display: inline-flex; align-items: center; gap: 5px; }
.avatar {
  width: 18px; height: 18px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.meta { align-items: center; }
.name-pick { display: flex; flex-wrap: wrap; gap: 8px; margin: -6px 0 14px; }
.name-chip {
  display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 14px 0 10px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 16px;
}
.name-chip .avatar { width: 24px; height: 24px; font-size: 13px; }
.name-chip[aria-pressed="true"] { border-color: var(--sage); background: var(--sage-soft); }
