/* Essensplaner — essen.jan-krueger.org */
:root {
  --bg: #f6f1e7;
  --bg-soft: #efe8da;
  --card: #fffdf8;
  --card-2: #faf5ec;
  --ink: #2a211c;
  --ink-soft: #6f625a;
  --line: #e4dbcc;
  --tomate: #d93a2b;
  --tomate-soft: #fbe7e2;
  --olive: #6b7a46;
  --olive-soft: #eef0e2;
  --gold: #c8912e;
  --shadow: 0 8px 30px rgba(42, 33, 28, .10);
  --shadow-sm: 0 2px 10px rgba(42, 33, 28, .07);
  --r: 22px;
  --r-sm: 14px;
  --font-d: "Fraunces", Georgia, serif;
  --font-b: "Outfit", system-ui, sans-serif;
}
[data-theme="dark"] {
  --bg: #191412;
  --bg-soft: #211a17;
  --card: #241d1a;
  --card-2: #2c2420;
  --ink: #f0e9e0;
  --ink-soft: #a3968c;
  --line: #3a302a;
  --tomate: #ff6b4a;
  --tomate-soft: #3c2521;
  --olive: #a3b573;
  --olive-soft: #2a2e20;
  --gold: #e0ac4d;
  --shadow: 0 8px 30px rgba(0, 0, 0, .40);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .30);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: var(--font-b);
  background: var(--bg);
  color: var(--ink);
  min-height: 100dvh;
  transition: background .35s ease, color .35s ease;
  overscroll-behavior-y: contain;
}
[hidden] { display: none !important; }
button { font-family: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: 1rem; color: var(--ink); }
a { color: var(--tomate); }

/* ---------- PIN ---------- */
.pin-gate {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.pin-card { text-align: center; padding: 24px; animation: rise .5s cubic-bezier(.2,.9,.3,1.2); }
.pin-logo { font-size: 3rem; margin-bottom: 8px; }
.pin-card h1 { font-family: var(--font-d); font-weight: 700; font-size: 2rem; line-height: 1.1; margin-bottom: 10px; }
.pin-hint { color: var(--ink-soft); margin-bottom: 18px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; margin-bottom: 26px; }
.pin-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--ink-soft);
  transition: all .18s ease;
}
.pin-dots i.on { background: var(--tomate); border-color: var(--tomate); transform: scale(1.15); }
.pin-dots.shake { animation: shake .4s; }
.pin-pad { display: grid; grid-template-columns: repeat(3, 72px); gap: 12px; justify-content: center; }
.pin-pad button {
  height: 72px; border-radius: 50%;
  background: var(--card); box-shadow: var(--shadow-sm);
  font-size: 1.5rem; font-weight: 500;
  transition: transform .1s ease, background .15s ease;
}
.pin-pad button:active { transform: scale(.92); background: var(--tomate-soft); }
.pin-error { color: var(--tomate); margin-top: 16px; min-height: 1.4em; font-weight: 500; }
@keyframes shake { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-8px)} 75%{transform:translateX(8px)} }
@keyframes rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

/* ---------- Layout ---------- */
.app { max-width: 720px; margin: 0 auto; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(10px + env(safe-area-inset-top)) 14px 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.week-label {
  flex: 1; text-align: center;
  font-family: var(--font-d); font-weight: 700; font-size: 1.15rem;
  padding: 8px 4px; border-radius: var(--r-sm);
}
.week-label small { display: block; font-family: var(--font-b); font-weight: 400; font-size: .78rem; color: var(--ink-soft); }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 1.4rem; background: var(--card); box-shadow: var(--shadow-sm);
  transition: transform .1s ease;
  flex: none;
}
.icon-btn:active { transform: scale(.9); }

main { padding: 6px 14px 20px; }
.view { animation: rise .35s ease; }

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; justify-content: center; gap: 4px;
  max-width: 720px; margin: 0 auto;
  padding: 8px 12px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1; max-width: 120px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 7px 4px; border-radius: 16px;
  font-size: .74rem; font-weight: 500; color: var(--ink-soft);
  transition: all .2s ease;
}
.tab-ico { font-size: 1.3rem; transition: transform .25s cubic-bezier(.2,.9,.3,1.4); }
.tab.active { color: var(--tomate); background: var(--tomate-soft); }
.tab.active .tab-ico { transform: translateY(-2px) scale(1.12); }

/* ---------- Wochenansicht ---------- */
.day-card {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
  overflow: hidden;
  transition: box-shadow .25s ease;
}
.day-card.today { outline: 2px solid var(--tomate); outline-offset: -2px; }
.day-card.open { box-shadow: var(--shadow); }
.day-head {
  width: 100%; display: flex; align-items: center; gap: 12px;
  padding: 15px 16px; text-align: left;
}
.day-date {
  flex: none; width: 48px; text-align: center;
}
.day-date b { font-family: var(--font-d); font-size: 1.35rem; font-weight: 700; display: block; line-height: 1; }
.day-date span { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); }
.today .day-date b { color: var(--tomate); }
.day-meal { flex: 1; min-width: 0; }
.day-meal .meal-name { font-weight: 700; font-size: 1.02rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-meal .meal-empty { color: var(--ink-soft); font-weight: 400; }
.day-meal .meal-sub { font-size: .78rem; color: var(--ink-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.day-chev { flex: none; color: var(--ink-soft); transition: transform .3s cubic-bezier(.2,.9,.3,1.2); }
.day-card.open .day-chev { transform: rotate(180deg); }
.day-body {
  display: grid; grid-template-rows: 0fr;
  transition: grid-template-rows .38s cubic-bezier(.3,.9,.3,1);
}
.day-card.open .day-body { grid-template-rows: 1fr; }
.day-body-inner { overflow: hidden; }
.day-body-pad { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 10px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 14px; border-radius: 999px;
  background: var(--card-2); border: 1px solid var(--line);
  font-size: .87rem; font-weight: 500;
  transition: transform .1s ease, background .15s;
  text-decoration: none; color: var(--ink);
}
.chip:active { transform: scale(.95); }
.chip.primary { background: var(--tomate); border-color: var(--tomate); color: #fff; }
.chip.link { color: var(--tomate); }
.chip.danger { color: var(--tomate); }
.chip.olive { background: var(--olive-soft); border-color: transparent; color: var(--olive); }

.note-input {
  width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm);
  background: var(--card-2); padding: 10px 12px; resize: none;
  min-height: 44px; line-height: 1.4;
}
.note-input:focus { outline: 2px solid var(--tomate); border-color: transparent; }

.rate-row { display: flex; gap: 8px; }
.rate-btn {
  flex: 1; padding: 10px 6px; border-radius: var(--r-sm);
  background: var(--card-2); border: 1px solid var(--line);
  font-size: .82rem; font-weight: 500; text-align: center;
  transition: all .15s ease;
}
.rate-btn em { display: block; font-style: normal; font-size: 1.25rem; margin-bottom: 2px; }
.rate-btn.on-3 { background: var(--olive-soft); border-color: var(--olive); color: var(--olive); }
.rate-btn.on-2 { background: var(--card-2); border-color: var(--gold); color: var(--gold); }
.rate-btn.on-1 { background: var(--tomate-soft); border-color: var(--tomate); color: var(--tomate); }

/* ---------- Einkaufsliste ---------- */
.shop-head { display: flex; align-items: center; justify-content: space-between; margin: 8px 2px 14px; }
.shop-head h2, .view h2 { font-family: var(--font-d); font-size: 1.5rem; font-weight: 700; }
.shop-add { display: flex; gap: 8px; margin-bottom: 14px; }
.shop-add input {
  flex: 1; padding: 13px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card);
  box-shadow: var(--shadow-sm);
}
.shop-add input:focus { outline: 2px solid var(--tomate); }
.shop-add button {
  width: 50px; border-radius: 50%; flex: none;
  background: var(--tomate); color: #fff; font-size: 1.5rem; font-weight: 500;
  box-shadow: var(--shadow-sm);
  transition: transform .1s;
}
.shop-add button:active { transform: scale(.9); }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--r-sm);
  padding: 12px 14px; margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  animation: rise .25s ease;
}
.shop-check {
  width: 26px; height: 26px; border-radius: 9px; flex: none;
  border: 2px solid var(--ink-soft);
  display: grid; place-items: center; font-size: .95rem; color: transparent;
  transition: all .18s ease;
}
.shop-item.done .shop-check { background: var(--olive); border-color: var(--olive); color: #fff; }
.shop-text { flex: 1; transition: opacity .2s; }
.shop-item.done .shop-text { opacity: .45; text-decoration: line-through; }
.shop-del { color: var(--ink-soft); font-size: 1.1rem; padding: 4px 6px; }
.shop-tools { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }

/* ---------- Gerichte ---------- */
.search-row { display: flex; gap: 8px; margin: 8px 0 14px; }
.search-row input {
  flex: 1; padding: 13px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow-sm);
}
.search-row input:focus { outline: 2px solid var(--tomate); }
.dish-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border-radius: var(--r-sm);
  padding: 13px 14px; margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  width: 100%; text-align: left;
  transition: transform .1s;
}
.dish-item:active { transform: scale(.985); }
.dish-item .d-main { flex: 1; min-width: 0; }
.dish-item .d-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dish-item .d-sub { font-size: .78rem; color: var(--ink-soft); }
.d-badge { flex: none; font-size: 1.2rem; }

/* ---------- Ideen ---------- */
.tag-scroll { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; scrollbar-width: none; }
.tag-scroll::-webkit-scrollbar { display: none; }
.tag-pill {
  flex: none; padding: 8px 15px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--line);
  font-size: .85rem; font-weight: 500;
}
.tag-pill.on { background: var(--tomate); border-color: var(--tomate); color: #fff; }
.idea-card {
  background: var(--card); border-radius: var(--r);
  padding: 16px; margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 12px;
}
.idea-main { flex: 1; min-width: 0; }
.idea-name { font-family: var(--font-d); font-weight: 700; font-size: 1.08rem; }
.idea-sub { font-size: .8rem; color: var(--ink-soft); margin-top: 2px; }
.idea-ago { flex: none; text-align: center; padding: 8px 12px; border-radius: var(--r-sm); background: var(--olive-soft); color: var(--olive); }
.idea-ago b { font-family: var(--font-d); font-size: 1.2rem; display: block; line-height: 1; }
.idea-ago span { font-size: .68rem; }
.idea-ago.never { background: var(--tomate-soft); color: var(--tomate); }

/* ---------- Bottom-Sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(15, 10, 8, .45);
  animation: fadeIn .25s ease;
  backdrop-filter: blur(2px);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  max-width: 720px; margin: 0 auto;
  background: var(--card);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -10px 40px rgba(0,0,0,.25);
  max-height: 88dvh;
  display: flex; flex-direction: column;
  animation: sheetUp .35s cubic-bezier(.2,.9,.3,1);
}
.sheet-handle { width: 44px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 4px; flex: none; }
.sheet-content { overflow-y: auto; padding: 10px 18px calc(24px + env(safe-area-inset-bottom)); }
.sheet h3 { font-family: var(--font-d); font-size: 1.35rem; font-weight: 700; margin-bottom: 14px; }
.sheet label { display: block; font-size: .78rem; font-weight: 500; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-soft); margin: 14px 0 6px; }
.sheet input[type=text], .sheet input[type=url], .sheet textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--r-sm);
  border: 1px solid var(--line); background: var(--card-2);
}
.sheet input:focus, .sheet textarea:focus { outline: 2px solid var(--tomate); border-color: transparent; }
.sheet textarea { resize: vertical; min-height: 70px; line-height: 1.45; }
.sheet-actions { display: flex; gap: 10px; margin-top: 20px; }
.btn {
  flex: 1; padding: 14px; border-radius: var(--r-sm);
  font-weight: 700; font-size: 1rem; text-align: center;
  transition: transform .1s;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--tomate); color: #fff; box-shadow: var(--shadow-sm); }
.btn.ghost { background: var(--card-2); border: 1px solid var(--line); }
.btn.danger-ghost { background: none; color: var(--tomate); flex: none; padding: 14px 16px; }
.file-list { display: flex; flex-direction: column; gap: 8px; }
.file-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--card-2); border-radius: var(--r-sm); padding: 10px 12px;
}
.file-row a { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; text-decoration: none; }
.upload-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 13px; margin-top: 8px;
  border: 2px dashed var(--line); border-radius: var(--r-sm);
  color: var(--ink-soft); font-weight: 500;
}
.picker-list { max-height: 42dvh; overflow-y: auto; margin-top: 6px; }
@keyframes sheetUp { from { transform: translateY(60px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Zutatenliste (Editor) ---------- */
.scan-note { font-size: .78rem; color: var(--ink-soft); margin: 0 0 12px; line-height: 1.4; }
.ing-list { display: flex; flex-direction: column; gap: 6px; }.ing-row { display: flex; align-items: center; gap: 8px; }
.ing-check {
  flex: none; width: 30px; height: 30px; border-radius: 9px;
  border: 2px solid var(--line); display: grid; place-items: center;
  color: transparent; transition: all .15s ease;
}
.ing-check.on { background: var(--olive); border-color: var(--olive); color: #fff; }
.ing-text {
  flex: 1; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card-2);
}
.ing-text:focus { outline: 2px solid var(--tomate); border-color: transparent; }
.ing-del { flex: none; color: var(--ink-soft); font-size: 1.05rem; padding: 4px 6px; }

/* ---------- Scan-Overlay ---------- */
.scan-overlay {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: center; justify-content: center;
  background: rgba(15, 10, 8, .55);
  backdrop-filter: blur(3px);
  padding: 20px;
  animation: fadeIn .2s ease;
}
.scan-card {
  background: var(--card); border-radius: var(--r);
  padding: 30px 26px; max-width: 380px; width: 100%;
  text-align: center; box-shadow: var(--shadow);
  animation: rise .3s cubic-bezier(.2,.9,.3,1.15);
}
.scan-card h4 { font-family: var(--font-d); font-size: 1.2rem; font-weight: 700; margin: 4px 0 6px; }
.scan-spinner {
  width: 46px; height: 46px; margin: 0 auto 16px;
  border: 4px solid var(--line); border-top-color: var(--tomate);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.scan-timer { font-variant-numeric: tabular-nums; color: var(--ink-soft); font-weight: 500; font-size: .95rem; }
@keyframes spin { to { transform: rotate(360deg); } }

.scan-result { text-align: left; max-height: 82dvh; display: flex; flex-direction: column; }
.scan-result h4 { text-align: center; }
.scan-hint { text-align: center; color: var(--ink-soft); font-size: .85rem; margin-bottom: 14px; }
.scan-list { overflow-y: auto; display: flex; flex-direction: column; gap: 4px; margin-bottom: 4px; }
.scan-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: var(--r-sm);
  background: var(--card-2);
}
.scan-item input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--olive); flex: none; }

/* ---------- Toast / Empty ---------- */
.toast {
  position: fixed; bottom: calc(96px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg);
  padding: 11px 20px; border-radius: 999px;
  font-weight: 500; font-size: .9rem; z-index: 60;
  box-shadow: var(--shadow);
  animation: rise .3s ease;
  max-width: 88vw; text-align: center;
}
.empty {
  text-align: center; padding: 44px 20px; color: var(--ink-soft);
}
.empty .big { font-size: 2.6rem; margin-bottom: 8px; }

/* ---------- Desktop ---------- */
@media (min-width: 640px) {
  main { padding: 10px 20px 30px; }
  .day-head { padding: 17px 20px; }
  .tab { font-size: .8rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
