/* Einkauf – neutral, ruhig, ein einziger Akzent. Farbe ändern: nur --accent anpassen. */

:root {
  --bg: #F4F4F5;
  --surface: #FFFFFF;
  --ink: #18181B;
  --muted: #71717A;
  --line: #E4E4E7;
  --accent: #2F5BEA;
  --on-accent: #FFFFFF;
  --primary: #18181B;
  --on-primary: #FFFFFF;
  --cart: #EBEBED;
  --mark: #F59E0B;
  --danger: #DC2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 1px 1px rgba(0, 0, 0, .02);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: var(--font);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #09090B;
    --surface: #18181B;
    --ink: #FAFAFA;
    --muted: #A1A1AA;
    --line: #27272A;
    --accent: #6D8DFF;
    --on-accent: #09090B;
    --primary: #FAFAFA;
    --on-primary: #09090B;
    --cart: #111113;
    --mark: #FBBF24;
    --danger: #F87171;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- Kopfbereich ---------- */

.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  backdrop-filter: saturate(180%) blur(16px);
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 16px 12px;
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.top.scrolled { border-bottom-color: var(--line); }

.bar, .add, .suggest, .list { max-width: 640px; margin-left: auto; margin-right: auto; }

.bar { display: flex; align-items: center; gap: 2px; }

.tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent);
  padding-right: 24px;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: none;
  background: none;
  border: 0;
  border-radius: 999px;
  padding: 7px 14px;
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: -0.01em;
  color: var(--muted);
  white-space: nowrap;
  transition: background-color .15s, color .15s;
}
.tab[aria-current="true"] { background: var(--primary); color: var(--on-primary); }
.tab-add { font-size: 1.15rem; line-height: 1; padding: 6px 12px; }

.sync { flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--line); margin: 0 8px; }
.sync.ok { background: #22C55E; }
.sync.pending { background: var(--mark); }
.sync.offline { background: var(--danger); }

.icon-btn {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  border-radius: 10px;
  color: var(--muted);
}
.icon-btn:active { background: var(--line); }
.icon-btn[disabled] { opacity: .25; cursor: default; }
.icon-btn.sm { width: 34px; }

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

.add { display: flex; gap: 8px; margin-top: 10px; }
.add input {
  flex: 1;
  min-width: 0;
  font-size: 1rem;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.add input::placeholder { color: var(--muted); }
.add input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.add-btn {
  flex: none;
  width: 48px;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: var(--on-primary);
  font-size: 1.5rem;
  font-weight: 300;
  line-height: 1;
}
.add-btn:active { opacity: .85; }

.suggest { margin-top: 8px; max-height: 42dvh; overflow-y: auto; padding-bottom: 4px; }
.suggest h3 {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  margin: 12px 0 8px;
}
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: .92rem;
}
.chip:active { border-color: var(--ink); }
.chip small { color: var(--muted); font-size: .85rem; }

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

.list { padding: 4px 16px calc(env(safe-area-inset-bottom, 0px) + 48px); }

.group { margin-top: 22px; }
.group h2, .cart h2 { display: flex; gap: 6px; align-items: baseline; margin: 0 0 8px; }
.group h2 {
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
  padding-left: 4px;
}
.n { font-weight: 500; opacity: .7; }

.items { list-style: none; margin: 0; padding: 0; }
.group > .items:not(.grid) {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  overflow: hidden;
}
.item { display: flex; align-items: center; border-bottom: 1px solid var(--line); padding: 0 6px 0 14px; }
.item:last-child { border-bottom: 0; }
.row {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 8px 0;
  background: none;
  border: 0;
  text-align: left;
}
.box {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--muted) 70%, transparent);
  display: grid;
  place-items: center;
  color: var(--on-accent);
  transition: background-color .15s, border-color .15s, transform .15s;
}
.box svg { opacity: 0; width: 13px; height: 13px; }
.item.done .box { background: var(--accent); border-color: var(--accent); }
.item.done .box svg { opacity: 1; }
.row:active .box { transform: scale(.88); }
.label { min-width: 0; font-size: 1rem; font-weight: 500; overflow-wrap: anywhere; }
.qty { color: var(--muted); font-size: .9rem; white-space: nowrap; margin-left: 4px; font-variant-numeric: tabular-nums; }
.item.done .label { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }
.item .icon-btn { color: color-mix(in srgb, var(--muted) 70%, transparent); }

.cart { margin-top: 32px; background: var(--cart); border-radius: calc(var(--radius) + 4px); padding: 4px 12px 8px; }
.cart .items:not(.grid) .item { padding-left: 2px; border-bottom-color: color-mix(in srgb, var(--muted) 18%, transparent); }
.cart-head { display: flex; align-items: center; justify-content: space-between; }
.cart h2 { font-size: .95rem; font-weight: 600; letter-spacing: -0.01em; margin: 6px 0 6px 2px; }
.link { background: none; border: 0; color: var(--muted); font-weight: 500; font-size: .9rem; padding: 12px 2px 12px 12px; }
.link:active { color: var(--ink); }

.empty { padding: 56px 4px; color: var(--muted); max-width: 30em; }
.empty-big { font-weight: 700; font-size: 1.6rem; letter-spacing: -0.03em; color: var(--ink); margin: 0 0 6px; line-height: 1.15; }
.all-done { font-weight: 600; font-size: 1.05rem; margin: 28px 0 0 4px; color: var(--muted); }

/* ---------- Icons ---------- */

.ico { flex: none; width: 28px; height: 28px; object-fit: contain; }
.item { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.item.done .ico { filter: grayscale(1); opacity: .4; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding-left: 7px; }
.chip-ico { width: 20px; height: 20px; }

/* ---------- Kacheln ---------- */

.items.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 8px;
}
.items.grid .item { border-bottom: 0; padding: 0; }
.tile .row {
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 104px;
  height: 100%;
  padding: 12px 6px 10px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform .12s, background-color .15s;
}
.tile .row:active { transform: scale(.96); }
.tile .ico { width: 40px; height: 40px; }
.t-name {
  font-size: .85rem;
  font-weight: 500;
  line-height: 1.2;
  overflow-wrap: break-word;
  hyphens: auto;
  -webkit-hyphens: auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile .qty { margin: 0; font-size: .78rem; }
.tile.done .row { background: transparent; box-shadow: none; border-style: dashed; border-color: color-mix(in srgb, var(--muted) 35%, transparent); }
.tile.done .t-name { color: var(--muted); text-decoration: line-through; }

/* ---------- Bild-Auswahl ---------- */

.edit-icon {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-align: left;
  font-weight: 600;
}
.edit-icon span { display: flex; flex-direction: column; }
.edit-icon small { font-weight: 500; color: var(--accent); }
.ico-big { width: 48px; height: 48px; }
.picker { margin-top: 10px; }
.picker input {
  width: 100%;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
}
.picker input:focus { outline: none; border-color: var(--accent); }
.pick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
  margin-top: 8px;
  padding: 2px;
}
.pick {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  background: none;
  border: 1.5px solid transparent;
  border-radius: 10px;
}
.pick .ico { width: 32px; height: 32px; }
.pick.sel { border-color: var(--accent); background: var(--bg); }
.pick.auto { grid-column: span 2; aspect-ratio: auto; font-size: .85rem; font-weight: 600; color: var(--accent); border-color: var(--line); }

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

dialog.sheet {
  border: 0;
  padding: 0;
  margin: auto auto 0;
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  border-radius: 18px 18px 0 0;
  background: var(--surface);
  color: var(--ink);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow-y: auto;
  overscroll-behavior: contain;
}
dialog.sheet::backdrop { background: rgba(9, 9, 11, .4); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px); }
dialog.sheet.tall { height: 90dvh; }
@media (min-width: 700px) {
  dialog.sheet { margin: auto; border-radius: 18px; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.sheet[open] { animation: rise .2s cubic-bezier(.2, .8, .2, 1); }
  @keyframes rise { from { transform: translateY(24px); opacity: .4; } }
}

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 10px 8px 20px;
  background: var(--surface);
}
.sheet-head h2 { font-weight: 650; font-size: 1.15rem; letter-spacing: -0.015em; margin: 0; }
.sheet-body { padding: 0 20px 20px; }

.field { display: block; font-weight: 500; font-size: .85rem; color: var(--muted); margin-top: 14px; }
.field input, .field select, .add-row input, .login input {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .add-row input:focus, .login input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.sheet-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 24px; }

.btn {
  display: inline-block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 600;
  font-size: .95rem;
}
.btn:active { opacity: .85; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.danger { background: none; border-color: transparent; color: var(--danger); padding-left: 0; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; }

.set { padding: 6px 20px 18px; border-top: 1px solid var(--line); }
.set:first-child { border-top: 0; }
.set h3 { font-weight: 600; font-size: 1rem; letter-spacing: -0.01em; margin: 14px 0 6px; }
.hint { color: var(--muted); font-size: .9rem; margin: 0 0 8px; }

.edit-rows { list-style: none; margin: 0; padding: 0; }
.edit-rows li { display: flex; align-items: center; gap: 2px; min-height: 46px; }
.edit-rows.compact li { min-height: 40px; }
.inline {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 10px;
}
.inline:hover { border-color: var(--line); }
.inline:focus { outline: none; border-color: var(--accent); background: var(--bg); }
.cat-name { flex: 1; padding-left: 2px; }
.add-row { display: flex; gap: 8px; margin-top: 8px; }
.add-row input { margin-top: 0; flex: 1; min-width: 0; }

details summary { font-weight: 600; font-size: 1rem; padding: 14px 0 8px; cursor: pointer; }

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

.toast {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18px);
  z-index: 50;
  width: max-content;
  max-width: calc(100% - 32px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 10px 10px 16px;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-size: .92rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .2);
}
.toast button { background: none; border: 0; color: var(--bg); opacity: .9; font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 6px 8px; }

/* ---------- Anmeldung ---------- */

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login form { width: 100%; max-width: 340px; }
.login h1 { font-weight: 700; font-size: 2rem; letter-spacing: -0.035em; line-height: 1.1; margin: 0 0 8px; }
.login p { color: var(--muted); }
.err { color: var(--danger) !important; min-height: 1.4em; margin: 8px 0; }

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