:root {
  --bg: #f6f5f1; --card: #ffffff; --text: #1d1f21; --muted: #6b6f74; --line: #e6e3dc;
  --accent: #2f7d5c; --accent-soft: #e3f1ea; --danger: #c0392b; --danger-soft: #fbe9e7;
  --warn: #b7791f; --chip: #efede7; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --radius: 14px; --tab-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16181b; --card: #202327; --text: #eceae6; --muted: #9aa0a6; --line: #30343a;
    --accent: #5bbf91; --accent-soft: #1f3a2e; --danger: #ef6b5e; --danger-soft: #3b2220;
    --warn: #e0a643; --chip: #2a2e33; --shadow: none;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif; overscroll-behavior-y: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ---------- Layout */
.top { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: calc(var(--safe-t) + 14px) 18px 10px; display: flex; align-items: center; gap: 10px; }
.top h1 { font-size: 26px; margin: 0; letter-spacing: -.02em; flex: 1; }
.top .sub { font-size: 13px; color: var(--muted); font-weight: 500; }
.view { padding: 0 14px calc(var(--tab-h) + var(--safe-b) + 90px); max-width: 640px; margin: 0 auto; }
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; background: color-mix(in srgb, var(--card) 92%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); padding-bottom: var(--safe-b); }
.tabs button { flex: 1; height: var(--tab-h); border: 0; background: none; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 11.5px; font-weight: 600; position: relative; }
.tabs button svg { width: 25px; height: 25px; }
.tabs button.on { color: var(--accent); }
.tabs .dot { position: absolute; top: 8px; left: calc(50% + 8px); min-width: 18px; height: 18px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 18px; padding: 0 5px; }

/* ---------- Cards & rows */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.sec-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 6px 8px; display: flex; align-items: center; gap: 8px; }
.sec-title .grow { flex: 1; }
.sec-title.danger { color: var(--danger); }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); min-height: 54px; }
.row:last-child { border-bottom: 0; }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 550; word-break: break-word; }
.row .meta { font-size: 13px; color: var(--muted); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.row .meta .late { color: var(--danger); font-weight: 600; }
.row .meta .soon { color: var(--warn); font-weight: 600; }
.row.done .title { text-decoration: line-through; color: var(--muted); }
.row.tap { cursor: pointer; }
.check { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--line); background: none; flex: none; display: grid; place-items: center; padding: 0; transition: .15s; }
.check svg { width: 16px; height: 16px; opacity: 0; color: #fff; }
.check.on { background: var(--accent); border-color: var(--accent); }
.check.on svg { opacity: 1; }
.check:active { transform: scale(.9); }
.amount { background: var(--chip); border-radius: 8px; padding: 2px 8px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.avatar { width: 22px; height: 22px; border-radius: 50%; color: #fff; font-size: 11px; font-weight: 700; display: inline-grid; place-items: center; flex: none; }
.avatar.lg { width: 36px; height: 36px; font-size: 15px; }
.note { font-size: 13px; color: var(--muted); font-style: italic; }

/* ---------- Add bar & suggestions */
.addbar { position: sticky; top: calc(var(--safe-t) + 62px); z-index: 4; background: var(--bg); padding: 2px 0 10px; }
.addbar form { display: flex; gap: 8px; }
.addbar input { flex: 1; height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card); padding: 0 14px; font-size: 17px; outline: none; }
.addbar input:focus { border-color: var(--accent); }
.btn-round { width: 48px; height: 48px; border-radius: 12px; border: 0; background: var(--accent); color: #fff; display: grid; place-items: center; flex: none; }
.btn-round svg { width: 24px; height: 24px; }
.suggest { background: var(--card); border-radius: 12px; box-shadow: var(--shadow); margin-top: 6px; overflow: hidden; border: 1px solid var(--line); }
.suggest button { display: flex; width: 100%; align-items: center; gap: 10px; text-align: left; border: 0; background: none; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.suggest button:last-child { border-bottom: 0; }
.suggest .tag { margin-left: auto; font-size: 12px; color: var(--muted); }
.suggest b { color: var(--accent); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 2px 6px; }
.chip { border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 7px 13px; font-size: 14.5px; font-weight: 550; display: inline-flex; gap: 6px; align-items: center; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.chip.ghost { background: none; border-style: dashed; color: var(--muted); }
.chip small { color: var(--muted); font-weight: 500; }
.chips.select .chip { font-size: 14px; padding: 6px 12px; }

/* ---------- Buttons */
.btn { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 650; background: var(--chip); display: inline-flex; gap: 8px; align-items: center; justify-content: center; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.danger { background: var(--danger-soft); color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 14px; border-radius: 10px; }
.btn:disabled { opacity: .5; }
.link { border: 0; background: none; color: var(--accent); font-weight: 650; padding: 4px; font-size: 14px; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tab-h) + var(--safe-b) + 16px); width: 58px; height: 58px; border-radius: 18px; border: 0; background: var(--accent); color: #fff; box-shadow: 0 6px 20px rgba(0,0,0,.2); display: grid; place-items: center; z-index: 9; }
.fab svg { width: 28px; height: 28px; }

/* ---------- Segmented */
.seg { display: flex; background: var(--chip); border-radius: 11px; padding: 3px; gap: 3px; margin: 2px 0 6px; }
.seg button { flex: 1; border: 0; background: none; border-radius: 9px; padding: 7px 8px; font-weight: 600; font-size: 14px; color: var(--muted); }
.seg button.on { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

/* ---------- Forms */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 13px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.field input[type=text], .field input[type=date], .field input[type=time], .field input[type=number], .field select, .field textarea {
  width: 100%; min-height: 46px; border-radius: 11px; border: 1px solid var(--line); background: var(--bg); padding: 10px 12px; font-size: 16px; outline: none; }
.field textarea { min-height: 80px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.inline { display: flex; gap: 10px; align-items: center; }
.inline > * { flex: 1; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.switch-row:last-child { border-bottom: 0; }
.switch-row .main { flex: 1; }
.switch-row small { display: block; color: var(--muted); font-size: 13px; }
.switch { position: relative; width: 50px; height: 30px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; border-radius: 15px; background: var(--line); transition: .2s; }
.switch span::after { content: ''; position: absolute; width: 26px; height: 26px; left: 2px; top: 2px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

/* ---------- Sheet (Bottom Sheet) */
.backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 20; animation: fade .15s; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 21; background: var(--card); border-radius: 20px 20px 0 0; max-height: 92vh; max-height: 92dvh; overflow: auto;
  padding: 8px 18px calc(18px + var(--safe-b)); animation: up .2s ease-out; max-width: 640px; margin: 0 auto; }
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 12px; }
.sheet h2 { margin: 0 0 16px; font-size: 21px; display: flex; align-items: center; gap: 10px; }
.sheet h2 .x { margin-left: auto; border: 0; background: var(--chip); border-radius: 50%; width: 32px; height: 32px; font-size: 18px; line-height: 1; }
.sheet .actions { display: flex; gap: 10px; margin-top: 8px; }
.sheet .actions .btn { flex: 1; }
.sheet .hint { font-size: 13.5px; color: var(--muted); margin: -4px 0 14px; }
.wd { display: flex; gap: 6px; }
.wd button { flex: 1; height: 40px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); font-weight: 650; font-size: 14px; padding: 0; }
.wd button.on { background: var(--accent); border-color: var(--accent); color: #fff; }
@keyframes up { from { transform: translateY(100%); } to { transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + var(--safe-b) + 18px); transform: translate(-50%, 20px); background: #1d1f21; color: #fff; border-radius: 12px;
  padding: 11px 14px 11px 16px; font-size: 15px; display: flex; gap: 14px; align-items: center; opacity: 0; pointer-events: none; transition: .2s; z-index: 30;
  width: max-content; max-width: min(440px, calc(100vw - 32px)); box-shadow: 0 6px 24px rgba(0,0,0,.25); }
#toast span { flex: 1; }
#toast.show { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
#toast button { border: 0; background: none; color: #7fd8ab; font-weight: 700; padding: 2px 4px; }

/* ---------- Onboarding */
.welcome { max-width: 440px; margin: 0 auto; padding: calc(var(--safe-t) + 40px) 22px 40px; }
.welcome .logo { width: 76px; height: 76px; border-radius: 20px; display: block; margin-bottom: 18px; }
.welcome h1 { font-size: 30px; margin: 0 0 6px; letter-spacing: -.02em; }
.welcome p.lead { color: var(--muted); margin: 0 0 26px; }
.welcome .card { padding: 18px; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 8px; }
.code { font: 700 26px/1.2 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .12em; background: var(--chip); border-radius: 12px; padding: 12px; text-align: center; user-select: all; }
.empty { text-align: center; color: var(--muted); padding: 30px 20px; }
.empty .big { font-size: 40px; margin-bottom: 6px; }
.info { background: var(--accent-soft); color: var(--text); border-radius: 12px; padding: 12px 14px; font-size: 14px; margin-bottom: 14px; }
.info.warn { background: var(--danger-soft); }
.pad { padding: 14px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.history-list { font-size: 13.5px; color: var(--muted); margin: 0; padding-left: 18px; }

/* ---------- Version 1.1: Offline, Listen, Preise, Nachkauf, Essen */
#net { display: none; position: sticky; top: 0; z-index: 15; background: #8a6d1f; color: #fff; font-size: 13.5px; font-weight: 600; text-align: center; padding: calc(var(--safe-t) + 6px) 12px 6px; }
#net.show { display: block; }
#net.show ~ #app .top { padding-top: 10px; }
.listtabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.listtabs::-webkit-scrollbar { display: none; }
.listtabs .chip { flex: none; }
.chip small { font-weight: 600; }
.chip.restock { padding: 0; gap: 0; overflow: hidden; }
.chip.restock button { border: 0; background: none; padding: 7px 6px 7px 13px; font: inherit; color: inherit; }
.chip.restock .x { padding: 7px 12px 7px 6px; color: var(--muted); }
.chip.emoji { font-size: 20px; padding: 4px 10px; cursor: pointer; }
.chip.emoji input { display: none; }
.chip.emoji:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.pricebar { display: flex; gap: 0; width: 100%; border: 0; padding: 0; text-align: left; overflow-x: auto; }
.pricebar .pb { flex: 1; min-width: 110px; padding: 10px 14px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 1px; }
.pricebar .pb:last-child { border-right: 0; }
.pricebar .pb b { font-size: 13px; color: var(--muted); }
.pricebar .pb span { font-size: 18px; font-weight: 700; }
.pricebar .pb small { font-size: 12px; color: var(--muted); }
.offer { color: var(--accent); font-weight: 650; }
s { color: var(--muted); font-weight: 400; }
.offerbox { display: block; text-decoration: none; color: inherit; background: var(--accent-soft); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; }
.offerbox small { color: var(--muted); }
.prices { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.prices label small { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.prices input { width: 100%; min-height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); padding: 8px 10px; font-size: 16px; }
.prow { display: flex; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.prow:last-of-type { border-bottom: 0; }
.prow .pname { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.weeknav { display: flex; align-items: center; justify-content: space-between; margin: 2px 0 10px; }
.weeknav b { font-size: 16px; }
.row.day { align-items: center; min-height: 58px; }
.row.day .dayname { width: 46px; flex: none; font-weight: 700; display: flex; flex-direction: column; line-height: 1.15; }
.row.day .dayname small { font-weight: 500; color: var(--muted); font-size: 12px; }
.row.day.today { background: var(--accent-soft); }
.row.day.today .dayname { color: var(--accent); }
.row.day.past { opacity: .55; }
.row.day .chips .chip { font-size: 14px; padding: 5px 11px; }
.update-bar { display: block; width: 100%; border: 0; background: var(--accent); color: #fff; font-weight: 650; font-size: 14px; padding: calc(var(--safe-t) + 8px) 12px 8px; }
.update-bar + .top { padding-top: 10px; }
