:root {
  --green: #1f7a4d;
  --green-dark: #155c39;
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #1c2420;
  --muted: #6b766f;
  --line: #e2e7e3;
  --red: #c0392b;
  --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #121614; --card: #1d2320; --text: #e8eee9; --muted: #95a199; --line: #2c3430; --green: #34a56c; --green-dark: #2a8a59; }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1rem; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--red); margin: 0; }

input, select, button { font: inherit; color: inherit; }
input, select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--card); font-size: 17px; /* >=16px verhindert Zoom auf iPhone */
}
input:focus, select:focus { outline: 2px solid var(--green); outline-offset: -1px; }
button { border: 0; border-radius: 12px; padding: 12px 16px; background: var(--line); cursor: pointer; }
button.primary { background: var(--green); color: #fff; font-weight: 600; }
button.primary:active { background: var(--green-dark); }
button.danger { background: transparent; color: var(--red); font-weight: 600; }

.screen { max-width: 640px; margin: 0 auto; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 90dvh; padding: 24px; text-align: center; }
.logo { width: 84px; height: 84px; }
.card { display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; background: var(--card); padding: 20px; border-radius: var(--radius); text-align: left; }

.topbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px 6px; }
.topbar h1 { flex: 1; }
.icon-btn { background: transparent; font-size: 1.5rem; padding: 4px 10px; line-height: 1; }
.sync { width: 10px; height: 10px; border-radius: 50%; background: var(--green); transition: background .3s; }
.sync.offline { background: var(--red); }
.sync.busy { background: #e0a800; }

.add-bar { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 16px 10px; display: flex; flex-direction: column; gap: 8px; }
.add-row { display: flex; gap: 8px; }
.add-btn { width: 52px; flex: none; font-size: 1.5rem; padding: 0; }
.add-row .qty { flex: 0 0 34%; }

#list { padding: 0 16px; }
.group { margin: 14px 0 0; }
.group h2 { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin: 0 4px 6px; }
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px; border-bottom: 1px solid var(--line); min-height: 56px; user-select: none; }
.item:last-child { border-bottom: 0; }
.check { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; font-size: 16px; color: #fff; background: transparent; padding: 0; }
.item.done .check { background: var(--green); border-color: var(--green); }
.body { flex: 1; min-width: 0; cursor: pointer; }
.name { overflow-wrap: anywhere; }
.qty-badge { display: inline-block; margin-left: 6px; font-size: .85rem; color: var(--green); font-weight: 600; }
.by { font-size: .78rem; color: var(--muted); }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.del { flex: none; background: transparent; color: var(--muted); font-size: 1.2rem; padding: 8px 10px; }
.item.pending { opacity: .55; }

#done-section { padding: 22px 16px 0; }
.done-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 6px; }
.done-head h2 { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.danger-link { background: transparent; color: var(--red); font-size: .9rem; font-weight: 600; padding: 6px 0; }
.empty { text-align: center; color: var(--muted); margin-top: 48px; }
#view-list { padding-bottom: 40px; }

dialog { border: 0; border-radius: 18px; padding: 20px; width: min(92vw, 420px); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
#edit-form { display: flex; flex-direction: column; gap: 12px; }
#edit-form label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
.dialog-buttons { display: flex; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.menu { display: flex; flex-direction: column; gap: 10px; }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: #222; color: #fff; padding: 10px 16px; border-radius: 999px; font-size: .9rem; display: flex; gap: 12px; align-items: center; z-index: 20; max-width: 92vw; }
.toast button { background: transparent; color: #7ee2a8; padding: 0; font-weight: 700; }
