:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --text: #1d2321;
  --muted: #6b7470;
  --line: #e3e1da;
  --accent: #2f6f5e;
  --accent-text: #ffffff;
  --danger: #b3412e;
  --radius: 14px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --card: #1e2421;
    --text: #e8ece9;
    --muted: #9aa5a0;
    --line: #2e3632;
    --accent: #4f9c86;
    --danger: #e0735f;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

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

input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  font-size: 17px; /* >=16px verhindert Auto-Zoom auf iOS */
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

button { cursor: pointer; border: 0; background: none; }
button.primary {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 10px;
  padding: 12px 18px;
  font-weight: 600;
}
button.ghost { color: var(--muted); padding: 6px 8px; font-size: 15px; }
button.danger { color: var(--danger); }
button:disabled { opacity: .5; }

/* Login */
.login {
  max-width: 380px;
  margin: 0 auto;
  padding: calc(48px + env(safe-area-inset-top)) 16px 32px;
  text-align: center;
}
.login-logo { border-radius: 22px; }
.login h1 { margin: 12px 0 24px; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: grid;
  gap: 14px;
  text-align: left;
}
.card label { display: grid; gap: 6px; font-size: 15px; color: var(--muted); }
.error { color: var(--danger); margin: 0; font-size: 15px; }

/* App */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 22px; margin: 0; }

.content {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}

.add { display: grid; grid-template-columns: 1fr 88px auto; gap: 8px; margin-bottom: 16px; }
.add button { font-size: 22px; padding: 0 16px; }

.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  min-height: 56px;
}
.check {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  display: grid;
  place-items: center;
  color: var(--accent-text);
  font-size: 15px;
}
.done .check { background: var(--accent); }
.item-main { flex: 1; min-width: 0; text-align: left; }
.item-title { overflow-wrap: anywhere; }
.done .item-title { text-decoration: line-through; color: var(--muted); }
.item-meta { font-size: 13px; color: var(--muted); }
.qty-badge {
  flex: none;
  font-size: 14px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 10px;
}
.item .toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
  padding: 0;
}
.del { color: var(--muted); font-size: 20px; padding: 4px 8px; }

.empty { text-align: center; color: var(--muted); margin: 32px 0; }

.done-head { display: flex; align-items: center; justify-content: space-between; margin: 28px 0 8px; }
.done-head h2 { font-size: 16px; color: var(--muted); margin: 0; font-weight: 600; }

.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--danger);
  color: #fff;
  text-align: center;
  font-size: 14px;
  padding: calc(6px + env(safe-area-inset-top)) 12px 6px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 15px;
  max-width: calc(100% - 32px);
  z-index: 20;
}
