:root {
  --bg: #f6f1e9;
  --card: #ffffff;
  --ink: #2b2620;
  --muted: #8a8075;
  --line: #e6ddd0;
  --accent: #e0703a;
  --accent-ink: #ffffff;
  --accent-soft: #fbe6d9;
  --green: #3f8f5a;
  --danger: #c0392b;
  --radius: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916; --card: #262320; --ink: #f2ece4; --muted: #a39887;
    --line: #3a352f; --accent: #f08a52; --accent-soft: #4a2f20;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
input, textarea { font: inherit; color: inherit; font-size: 17px; }
.hidden { display: none !important; }
.muted { color: var(--muted); font-weight: 400; }

.view { display: none; flex-direction: column; height: 100dvh; }
.view.active { display: flex; }

.topbar { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-t) + 8px) 12px 8px;
  background: var(--bg); position: sticky; top: 0; z-index: 5; min-height: 56px; }
.topbar h1 { flex: 1; text-align: center; font-size: 18px; margin: 0; }
.topbar .spacer { width: 80px; }
.icon-btn { width: 48px; height: 48px; font-size: 32px; line-height: 1; border-radius: 50%; color: var(--accent); }
.icon-btn:active { background: var(--accent-soft); }
.text-btn { color: var(--accent); padding: 10px 6px; min-width: 80px; text-align: left; }
.text-btn.danger { color: var(--danger); text-align: right; }
.day-title { flex: 1; display: flex; flex-direction: column; align-items: center; position: relative; padding: 4px; }
#day-label { font-size: 22px; font-weight: 700; }
#day-sub { color: var(--muted); font-size: 14px; }
#day-picker { position: absolute; inset: 0; opacity: 0; width: 100%; }
.time-pill { flex: 1; font-weight: 700; font-size: 18px; background: var(--card); border-radius: 999px; padding: 8px 14px; max-width: 220px; margin: 0 auto; }

.content { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 14px 24px; }
.content.center { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }

.bottombar { display: flex; gap: 10px; padding: 10px 14px calc(var(--safe-b) + 10px);
  background: linear-gradient(to top, var(--bg) 70%, transparent); }
.primary-btn { background: var(--accent); color: var(--accent-ink); border-radius: var(--radius); font-weight: 700; padding: 14px 20px; }
.primary-btn.big { min-height: 60px; font-size: 19px; flex: 1; }
.primary-btn:active, .secondary-btn:active { transform: scale(.98); filter: brightness(.95); }
.primary-btn:disabled { opacity: .5; }
.secondary-btn { background: var(--accent-soft); color: var(--accent); border-radius: 14px; font-weight: 700; padding: 14px; min-height: 52px; }
.ghost-btn { background: var(--card); border-radius: var(--radius); padding: 14px 18px; font-weight: 600; min-height: 60px; }
.full { width: 100%; }

.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.label { font-weight: 700; font-size: 15px; margin: 4px 0 8px; }
.hint { color: var(--muted); font-size: 14px; }
.center-text { text-align: center; }

/* Tagesliste */
.meal { background: var(--card); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; display: flex; gap: 12px; width: 100%; text-align: left; }
.meal:active { background: var(--accent-soft); }
.meal-time { font-weight: 800; font-size: 18px; min-width: 54px; color: var(--accent); }
.meal-body { flex: 1; min-width: 0; display: grid; grid-template-columns: max-content 1fr; column-gap: 10px; row-gap: 3px; align-items: baseline; }
.meal-body .amt { color: var(--muted); font-size: 15px; max-width: 42vw; }
.meal-body .fd { overflow-wrap: anywhere; }
.meal-body .meal-notes { grid-column: 1 / -1; justify-self: start; }
.meal-notes { margin-top: 6px; font-size: 14px; background: #fff3cd; color: #6b5300; border-radius: 10px; padding: 4px 8px; display: inline-block; }
@media (prefers-color-scheme: dark) { .meal-notes { background: #4a3d10; color: #f5df9a; } }
.empty { text-align: center; color: var(--muted); margin-top: 18vh; }
.empty-emoji { font-size: 64px; }

/* Uhrzeit */
.time-date { color: var(--muted); font-size: 17px; }
.time-big input::-webkit-calendar-picker-indicator { display: none; }
.time-big input { font-size: 64px; font-weight: 800; text-align: center; border: 0; background: var(--card);
  border-radius: 24px; padding: 10px 24px; width: 300px; color: var(--ink); -webkit-appearance: none; appearance: none; }

/* Chips */
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip-row.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-right: -14px; padding-right: 14px; }
.chip-row.scroll::-webkit-scrollbar { display: none; }
.chip { background: var(--accent-soft); color: var(--ink); border-radius: 999px; padding: 10px 14px; min-height: 42px; white-space: nowrap; font-weight: 600; }
.chip.ghost { background: transparent; border: 1px solid var(--line); font-weight: 500; }
.chip.on { background: var(--accent); color: var(--accent-ink); }
.chip-row.small .chip { padding: 6px 12px; min-height: 36px; font-size: 15px; }
.chip .chip-sub { color: var(--muted); font-weight: 400; font-size: 13px; margin-left: 4px; }

/* Lebensmittel */
.input-wrap { position: relative; }
#food-input, textarea, .card input[type=text] { width: 100%; border: 1.5px solid var(--line); background: var(--bg); border-radius: 14px; padding: 14px 44px 14px 14px; }
textarea { padding: 12px; resize: none; }
#food-input:focus, textarea:focus, .card input:focus { outline: none; border-color: var(--accent); }
.clear-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 36px; height: 36px; color: var(--muted); }

.unit-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.unit { background: var(--bg); border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 2px; min-height: 66px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.unit .ico { font-size: 24px; line-height: 1; }
.unit .ico.small { font-size: 17px; }
.unit .nm { font-size: 12.5px; font-weight: 600; text-align: center; line-height: 1.1; }
.unit .sx { font-size: 11px; color: var(--muted); }
.unit.on { border-color: var(--accent); background: var(--accent-soft); }
.unit-hint { color: var(--muted); font-size: 13px; min-height: 18px; margin-top: 6px; }

.qty-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 10px; }
.qty-btn { width: 60px; height: 60px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 30px; font-weight: 700; }
.qty-btn:active { background: var(--accent); color: var(--accent-ink); }
.qty-value { font-size: 40px; font-weight: 800; min-width: 90px; text-align: center; }
#qty-chips { justify-content: center; }
#qty-chips .chip { min-width: 48px; }

.item-list { list-style: none; margin: 0 0 12px; padding: 0; }
.item-list .it { background: var(--card); border-radius: 14px; padding: 10px 6px 10px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; animation: pop .2s ease; }
.item-list .edit-ico { font-size: 15px; opacity: .45; }
.add-head { display: flex; align-items: center; justify-content: space-between; min-height: 36px; margin: -4px 0 6px; font-weight: 700; font-size: 15px; }
.add-head .text-btn { min-width: 0; padding: 6px 0; text-align: right; }
.add-card.editing { outline: 2.5px solid var(--accent); box-shadow: 0 6px 20px rgba(224,112,58,.18); }
.item-list .it-main { flex: 1; min-width: 0; }
.item-list .it-food { font-weight: 600; overflow-wrap: anywhere; }
.item-list .it-amt { color: var(--muted); font-size: 14px; }
.item-list .del { width: 44px; height: 44px; color: var(--muted); font-size: 18px; }
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }

.date-row { display: flex; gap: 10px; }
.date-row label { flex: 1; display: flex; flex-direction: column; color: var(--muted); font-size: 13px; gap: 4px; }
.date-row input { border: 1.5px solid var(--line); background: var(--bg); border-radius: 12px; padding: 10px; width: 100%; min-height: 46px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--safe-b) + 96px); transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; opacity: 0; transition: all .25s; pointer-events: none; z-index: 50; font-weight: 600; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); color: #fff; }
