/* Unser Zuhause – warm & gemütlich, Handy zuerst */

:root {
  --bg: #f6efe6;
  --bg-2: #efe5d8;
  --card: #fffaf4;
  --ink: #3b2f28;
  --ink-2: #7a6a5e;
  --ink-3: #a8998c;
  --line: #e6d9c9;
  --accent: #d0704f;
  --accent-ink: #fff;
  --accent-soft: #f6dccf;
  --lv1: #9fb7a0;
  --lv2: #d9b26a;
  --lv3: #e48a45;
  --lv4: #d6453d;
  --lv4-soft: #fbe1dc;
  --ok: #5f9c6c;
  --shadow: 0 1px 2px rgba(80, 50, 30, .06), 0 4px 14px rgba(80, 50, 30, .07);
  --radius: 18px;
  --font: ui-rounded, "SF Pro Rounded", "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --nav-h: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #221c18;
    --bg-2: #2b231e;
    --card: #322923;
    --ink: #f3e9df;
    --ink-2: #c3b2a4;
    --ink-3: #8f7f72;
    --line: #43372f;
    --accent: #e8866a;
    --accent-ink: #2a1a12;
    --accent-soft: #4a3229;
    --lv4-soft: #4a2622;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
input, select, textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
.hidden { display: none !important; }

/* ---------- Grundgerüst ---------- */

.splash { height: 100vh; display: grid; place-items: center; }
.splash-icon { font-size: 64px; animation: bob 1.4s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }

.shell { min-height: 100vh; padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 24px); }

.top {
  position: sticky; top: 0; z-index: 5;
  padding: calc(env(safe-area-inset-top) + 14px) 16px 10px;
  background: linear-gradient(var(--bg) 75%, transparent);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top h1 { margin: 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; }
.top .sub { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: inline-grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 15px; flex: none;
}
.avatar.sm { width: 20px; height: 20px; font-size: 11px; }
.avatar.both { background: linear-gradient(135deg, #4f8a8b 50%, #d9777f 50%); }

main { padding: 0 16px; max-width: 640px; margin: 0 auto; }

.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: space-around;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--card);
  border-top: 1px solid var(--line);
}
.nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); font-size: 12px; font-weight: 700;
}
.nav button .ico { font-size: 22px; filter: grayscale(1) opacity(.6); transition: transform .15s; }
.nav button.active { color: var(--accent); }
.nav button.active .ico { filter: none; transform: scale(1.1); }
.nav .badge {
  position: absolute; margin: -26px 0 0 26px;
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--lv4); color: #fff; font-size: 11px; line-height: 18px;
}
.nav button { position: relative; }

.fab {
  position: fixed; z-index: 9;
  right: 18px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px);
  width: 58px; height: 58px; border-radius: 20px;
  background: var(--accent); color: var(--accent-ink);
  font-size: 30px; font-weight: 700; line-height: 1;
  box-shadow: 0 6px 18px rgba(208, 112, 79, .4);
  transition: transform .12s;
}
.fab:active { transform: scale(.92); }

/* ---------- Filter-Chips ---------- */

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px;
  background: var(--card); border: 1.5px solid var(--line);
  font-size: 14px; font-weight: 700; color: var(--ink-2); white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .n { opacity: .7; font-weight: 600; }

/* ---------- Abschnitte & Karten ---------- */

.section { margin: 14px 0 6px; display: flex; align-items: baseline; justify-content: space-between; }
.section h2 { margin: 0; font-size: 15px; font-weight: 800; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; }
.section h2 .n { color: var(--ink-3); margin-left: 4px; }
.section.late h2 { color: var(--lv4); }
.section button { color: var(--accent); font-weight: 700; font-size: 14px; }

.card {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--radius);
  padding: 12px 14px 12px 12px; margin-bottom: 8px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--lv2);
  transition: transform .25s, opacity .25s;
}
.card.lv1 { border-left-color: var(--lv1); }
.card.lv3 { border-left-color: var(--lv3); }
.card.lv4 { border-left-color: var(--lv4); background: linear-gradient(90deg, var(--lv4-soft), var(--card) 60%); }
.card.leaving { transform: translateX(40px); opacity: 0; }
.card.done { opacity: .55; border-left-color: var(--line); }
.card.done .title { text-decoration: line-through; }

.check {
  flex: none; width: 30px; height: 30px; border-radius: 50%;
  border: 2.5px solid var(--ink-3);
  display: grid; place-items: center; color: transparent; font-size: 16px; font-weight: 900;
  transition: background .15s, border-color .15s;
}
.check:active, .check.on { background: var(--ok); border-color: var(--ok); color: #fff; }

.card .body { flex: 1; min-width: 0; }
.card .title { font-weight: 700; font-size: 16px; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 3px; font-size: 13px; color: var(--ink-2); }
.meta .late { color: var(--lv4); font-weight: 700; }
.meta .today { color: var(--lv3); font-weight: 700; }
.pill {
  flex: none; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .03em;
  padding: 3px 8px; border-radius: 999px; color: #fff;
}
.pill.lv3 { background: var(--lv3); }
.pill.lv4 { background: var(--lv4); }

.empty { text-align: center; color: var(--ink-2); padding: 40px 20px; }
.empty .big { font-size: 48px; margin-bottom: 8px; }
.empty b { color: var(--ink); display: block; font-size: 18px; margin-bottom: 4px; }

details.fold { margin-top: 12px; }
details.fold summary { list-style: none; cursor: pointer; color: var(--ink-2); font-weight: 800; font-size: 14px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 0; }
details.fold summary::-webkit-details-marker { display: none; }
details.fold summary::before { content: '▸ '; }
details.fold[open] summary::before { content: '▾ '; }

.area-head { display: flex; align-items: center; gap: 10px; margin: 18px 0 8px; }
.area-head .dot { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; font-size: 18px; }
.area-head h3 { margin: 0; font-size: 18px; font-weight: 800; flex: 1; }
.area-head .n { color: var(--ink-3); font-weight: 700; }

/* ---------- Einkauf ---------- */

.add-bar { position: relative; margin-bottom: 8px; }
.add-bar input { padding-right: 56px; font-size: 17px; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); border-color: transparent; }
.add-bar input:focus { border-color: var(--accent); }
.add-bar button {
  position: absolute; right: 6px; top: 6px; bottom: 6px; width: 42px; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); font-size: 24px; font-weight: 700;
}
.suggest { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.suggest button {
  padding: 6px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--ink);
  font-size: 14px; font-weight: 700;
}
.suggest button::before { content: '+ '; color: var(--accent); }

.cat-head { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; font-weight: 800; color: var(--ink-2); font-size: 14px; }
.item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: 14px; padding: 10px 12px; margin-bottom: 6px; box-shadow: var(--shadow);
}
.item .check { width: 26px; height: 26px; border-radius: 9px; }
.item .body { flex: 1; min-width: 0; }
.item .name { font-weight: 700; }
.item .note { font-size: 13px; color: var(--ink-2); }
.item .qty { flex: none; background: var(--bg-2); border-radius: 8px; padding: 2px 8px; font-weight: 800; font-size: 14px; }
.item.checked { opacity: .5; }
.item.checked .name { text-decoration: line-through; }

/* ---------- Sheet (Bearbeiten) ---------- */

.sheet {
  border: 0; padding: 0; margin: auto 0 0; width: 100%; max-width: 100%;
  max-height: 92vh; background: var(--bg); color: var(--ink);
  border-radius: 24px 24px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .2);
}
@media (min-width: 700px) {
  .sheet { margin: auto; max-width: 560px; border-radius: 24px; }
}
.sheet::backdrop { background: rgba(40, 25, 15, .4); backdrop-filter: blur(2px); }
.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
.sheet-inner { padding: 10px 18px calc(18px + env(safe-area-inset-bottom)); overflow-y: auto; max-height: 92vh; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 12px; }
.sheet h2 { margin: 0 0 14px; font-size: 21px; font-weight: 800; }
.field { margin-bottom: 16px; }
.field > label, .field > .label { display: block; font-size: 13px; font-weight: 800; color: var(--ink-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 7px; }
.field .hint { font-size: 13px; color: var(--ink-3); margin-top: 6px; }

.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  padding: 9px 13px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line);
  font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; gap: 6px;
}
.seg button.on { border-color: var(--accent); background: var(--accent-soft); }
.seg.prio button.on[data-v="1"] { border-color: var(--lv1); background: color-mix(in srgb, var(--lv1) 25%, var(--card)); }
.seg.prio button.on[data-v="2"] { border-color: var(--lv2); background: color-mix(in srgb, var(--lv2) 25%, var(--card)); }
.seg.prio button.on[data-v="3"] { border-color: var(--lv3); background: color-mix(in srgb, var(--lv3) 25%, var(--card)); }
.seg.prio button.on[data-v="4"] { border-color: var(--lv4); background: color-mix(in srgb, var(--lv4) 25%, var(--card)); }
.row { display: flex; gap: 8px; align-items: center; }
.row > * { flex: 1; }
.row .narrow { flex: 0 0 90px; }

.actions { display: flex; gap: 10px; margin-top: 8px; }
.btn {
  flex: 1; padding: 14px; border-radius: 16px; font-weight: 800; font-size: 16px;
  background: var(--accent); color: var(--accent-ink);
}
.btn.ghost { background: var(--bg-2); color: var(--ink); }
.btn.danger { background: transparent; color: var(--lv4); flex: 0 0 auto; padding: 14px 10px; }
.btn:disabled { opacity: .5; }
.last-done { background: var(--bg-2); border-radius: 12px; padding: 10px 12px; font-size: 14px; color: var(--ink-2); margin-bottom: 16px; }

/* ---------- Mehr ---------- */

.panel { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel h3 { margin: 0 0 8px; font-size: 17px; font-weight: 800; }
.panel p { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }
.panel .btn { width: 100%; }
.panel .list-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--line); }
.panel .list-row:first-of-type { border-top: 0; }
.panel .list-row .ic { font-size: 20px; width: 28px; text-align: center; }
.panel .list-row .nm { flex: 1; font-weight: 700; }
.panel .list-row button { color: var(--ink-3); font-size: 18px; padding: 4px 8px; }
.ios-hint { background: var(--accent-soft); border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 10px; }

/* ---------- Login ---------- */

.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 420px; margin: 0 auto; }
.login .logo { font-size: 64px; text-align: center; }
.login h1 { text-align: center; margin: 6px 0 4px; font-size: 30px; font-weight: 800; }
.login p { text-align: center; color: var(--ink-2); margin: 0 0 28px; }
.who { display: flex; gap: 12px; margin-bottom: 20px; }
.who button {
  flex: 1; padding: 18px 10px; border-radius: 20px; background: var(--card); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 8px; font-weight: 800; font-size: 17px;
  border: 2px solid transparent;
}
.who button.on { border-color: var(--accent); }
.who .avatar { width: 52px; height: 52px; font-size: 22px; }
.login form .field { margin-bottom: 12px; }
.error { color: var(--lv4); font-weight: 700; text-align: center; min-height: 22px; margin: 6px 0; }

/* ---------- Toasts ---------- */

.toasts { position: fixed; left: 12px; right: 12px; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 86px); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 14px;
  background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 14px;
  font-weight: 700; font-size: 15px; box-shadow: 0 8px 24px rgba(0, 0, 0, .25); animation: up .2s ease-out;
  max-width: 100%;
}
.toast button { color: var(--accent); font-weight: 800; flex: none; }
.toast.err { background: var(--lv4); color: #fff; }

.offline { background: var(--lv3); color: #fff; text-align: center; font-size: 13px; font-weight: 700; padding: 4px; }

@keyframes pop { 40% { transform: scale(1.25); } }
.pop { animation: pop .3s; }
