:root {
  --bg: #f4f1ea;
  --card: #ffffff;
  --text: #1f2a24;
  --muted: #66716a;
  --border: #ddd8cc;
  --accent: #2f7d4f;
  --accent-text: #ffffff;
  --accent-soft: #e2f0e7;
  --danger: #b3261e;
  --warn-soft: #fff3d6;
  --radius: 14px;
  --tab-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14181a;
    --card: #1e2326;
    --text: #e9efe9;
    --muted: #94a09a;
    --border: #2f373a;
    --accent: #5fbf85;
    --accent-text: #0b1a12;
    --accent-soft: #1f3328;
    --danger: #f2877f;
    --warn-soft: #3a3320;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 17px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
body.no-tabs { padding-bottom: env(safe-area-inset-bottom); }
main { max-width: 640px; margin: 0 auto; padding: 16px 16px 24px; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1rem; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); }
small, .small { font-size: .85rem; }
.error { color: var(--danger); margin: 0; }
.center { text-align: center; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; margin-bottom: 16px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: block;
}
.card + .card, .stack > .card { margin-top: 0; }
a.card:active { background: var(--accent-soft); }
.banner { background: var(--warn-soft); border-radius: var(--radius); padding: 14px 16px; }

/* Buttons & Formulare */
.btn {
  font: inherit;
  min-height: 48px;
  padding: 0 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-align: center;
}
.btn:disabled { opacity: .55; }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.big { min-height: 56px; font-size: 1.1rem; width: 100%; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: .9rem; }
.btn.icon { min-width: 48px; padding: 0; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field > span { font-size: .9rem; color: var(--muted); }
input, select, textarea {
  font: inherit;
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}
textarea { min-height: 96px; resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 1px;
}
.hint { font-size: .85rem; color: var(--muted); margin: 0; }

.badge { font-size: .75rem; padding: 2px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.archived { background: var(--border); color: var(--muted); }
.badge.planning { background: var(--warn-soft); color: var(--text); }

.progress { height: 10px; border-radius: 99px; background: var(--border); overflow: hidden; margin: 10px 0 6px; }
.progress .bar { height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }

/* Tab-Leiste */
#tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
#tabs a {
  flex: 1; min-height: var(--tab-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: .75rem; color: var(--muted);
}
#tabs a span:first-child { font-size: 1.4rem; line-height: 1; }
#tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }

/* Auth */
.auth { padding-top: 8vh; display: flex; flex-direction: column; gap: 14px; }
.brand { font-size: 2rem; }
.seg { display: flex; background: var(--border); border-radius: 12px; padding: 3px; gap: 3px; }
.seg button { flex: 1; min-height: 44px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); color: var(--text); font-weight: 600; }

/* Wizard */
.wiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.dots { display: flex; gap: 5px; flex: 1; }
.dots i { flex: 1; height: 6px; border-radius: 99px; background: var(--border); }
.dots i.done { background: var(--accent); }
.wiz-q { font-size: 1.6rem; margin: 8px 0 24px; }
.opts { display: flex; flex-direction: column; gap: 12px; }
.opt { min-height: 64px; font-size: 1.15rem; border-radius: 16px; border: 2px solid var(--border); background: var(--card); color: var(--text); font-family: inherit; cursor: pointer; padding: 0 16px; }
.opt[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.stepper { display: flex; gap: 10px; align-items: center; }
.stepper .btn { min-width: 64px; min-height: 64px; font-size: 1.6rem; }
.stepper input { text-align: center; font-size: 1.8rem; min-height: 64px; }
.wiz-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 24px; }
.recap { list-style: none; padding: 0; margin: 0; }
.recap li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }

/* Packliste */
.sticky { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 4px; margin: 0 -16px; padding-left: 16px; padding-right: 16px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--border); background: var(--card); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.cat { margin-top: 18px; }
.cat > h3 { color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 6px; display: flex; justify-content: space-between; }
.items { list-style: none; margin: 0; padding: 0; background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.item { display: flex; align-items: stretch; border-bottom: 1px solid var(--border); }
.item:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 14px; padding: 8px 4px 8px 14px; min-height: 60px; background: none; border: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; }
.item-main:active { background: var(--accent-soft); }
.check { flex: none; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; color: transparent; font-weight: 700; }
.item.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item .name { display: block; overflow-wrap: anywhere; }
.item .sub { display: flex; gap: 8px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.qty { font-weight: 700; color: var(--accent); }
.more { flex: none; width: 52px; border: 0; background: none; color: var(--muted); font-size: 1.4rem; cursor: pointer; }
.add-row { display: flex; gap: 8px; flex-wrap: wrap; }
.add-row input[name="name"] { flex: 2 1 160px; }
.add-row input[name="category"] { flex: 1 1 110px; }

/* Dialoge (Bottom-Sheet) */
dialog.sheet { border: 0; padding: 0; background: var(--card); color: var(--text); width: min(560px, 100%); max-width: 100%; max-height: 90dvh; margin: auto auto 0; border-radius: 20px 20px 0 0; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, .45); }
dialog.sheet > .stack { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 640px) { dialog.sheet { margin: auto; border-radius: 20px; } }

.note { display: flex; gap: 8px; align-items: flex-start; padding: 8px 0; border-bottom: 1px solid var(--border); }
.note:last-child { border-bottom: 0; }

/* Katalog */
.cond { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; background: var(--bg); border-radius: 12px; }
.cond .full { grid-column: 1 / -1; }
.tag { font-size: .8rem; background: var(--accent-soft); color: var(--accent); border-radius: 8px; padding: 1px 8px; }
.checks { display: flex; flex-direction: column; gap: 6px; }
.check-opt { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; background: var(--card); border: 1px solid var(--border); border-radius: 12px; cursor: pointer; }
.check-opt input { width: 22px; height: 22px; min-height: 0; flex: none; accent-color: var(--accent); }
.cat-block + .cat-block { margin-top: 18px; }
.cards > .card + .card { margin-top: 8px; }

#toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + 16px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .2s;
  background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; max-width: 90vw; z-index: 50;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.err { background: var(--danger); color: #fff; }
body.no-tabs #toast { bottom: calc(16px + env(safe-area-inset-bottom)); }
