:root {
  --bg: #f5efe4;
  --card: #fffdf8;
  --ink: #2a2924;
  --muted: #847d6f;
  --line: #e6dccb;
  --primary: #2f5d50;
  --primary-soft: #dfe9e3;
  --accent: #d9622f;
  --accent-soft: #f8e3d6;
  --ok: #3c8a5f;
  --warn: #d99a2b;
  --err: #c2412d;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 45, 20, .06), 0 4px 14px rgba(60, 45, 20, .06);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a17; --card: #26241f; --ink: #f1ece2; --muted: #a39b8b; --line: #3a372f;
    --primary: #7fb8a3; --primary-soft: #2c3b35; --accent: #ef8a5c; --accent-soft: #3d2b22;
    --shadow: 0 1px 2px rgba(0,0,0,.3);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.45; }
body { min-height: 100vh; padding-bottom: calc(76px + var(--safe-b)); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: var(--ink); }

/* ---------- Header ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  padding: calc(14px + var(--safe-t)) 18px 10px;
  border-bottom: 1px solid var(--line);
}
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.top h1 { font-family: var(--serif); font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.sync i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); display: inline-block; }
.sync.pending i { background: var(--warn); }
.sync.offline i { background: var(--err); }

.weeknav { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.weeknav .lbl { flex: 1; text-align: center; font-weight: 600; }
.weeknav .lbl small { display: block; font-weight: 400; color: var(--muted); font-size: 13px; }
.iconbtn { width: 38px; height: 38px; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); display: grid; place-items: center; font-size: 20px; }
.pill { font-size: 13px; padding: 6px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-weight: 600; }

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

/* ---------- Tabbar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + var(--safe-b));
}
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; font-size: 11px; color: var(--muted); border-radius: 12px; position: relative; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.active { color: var(--primary); font-weight: 600; }
.tabbar .badge { position: absolute; top: 2px; left: 55%; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; line-height: 18px; font-weight: 700; }

/* ---------- Cards ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
.summary { display: flex; gap: 10px; margin-bottom: 14px; }
.summary .card { flex: 1; padding: 12px 14px; }
.summary b { display: block; font-size: 22px; font-family: var(--serif); }
.summary span { font-size: 12px; color: var(--muted); }

.today { padding: 16px; margin-bottom: 16px; background: var(--primary); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow); width: 100%; text-align: left; }
.today small { opacity: .8; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.today h2 { font-family: var(--serif); margin: 4px 0 2px; font-size: 22px; }
.today p { margin: 0; opacity: .9; font-size: 14px; }
@media (prefers-color-scheme: dark) { .today { color: #12201b; } }

.day { display: grid; grid-template-columns: 48px 1fr; gap: 10px; margin-bottom: 10px; }
.day .date { text-align: center; padding-top: 10px; }
.day .date b { display: block; font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; }
.day .date span { font-size: 20px; font-family: var(--serif); font-weight: 700; }
.day.is-today .date span { color: #fff; background: var(--accent); border-radius: 50%; width: 34px; height: 34px; display: inline-grid; place-items: center; font-size: 17px; }
.meal { padding: 12px 14px; text-align: left; width: 100%; }
.meal h3 { margin: 4px 0 0; font-family: var(--serif); font-size: 18px; line-height: 1.2; }
.meal .sub { color: var(--muted); font-size: 14px; margin-top: 1px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.meta span { display: inline-flex; align-items: center; gap: 4px; }
.empty-day { width: 100%; padding: 12px 14px; border: 1.5px dashed var(--line); border-radius: var(--radius); color: var(--muted); text-align: left; font-size: 14px; }
.leftover { font-size: 13px; color: var(--muted); padding: 2px 4px 6px; }
.leftover b { color: var(--ink); font-weight: 600; }
.stack { display: flex; flex-direction: column; gap: 6px; }

.tag { display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 2px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary); }
.tag.t-klassiker { background: #f1e4cf; color: #8a5a1c; }
.tag.t-international { background: #dde7f3; color: #2f5b8a; }
.tag.t-asiatisch { background: var(--accent-soft); color: var(--accent); }
.tag.t-vegetarisch { background: #dcefdc; color: #2f7a3c; }
.tag.t-fisch { background: #d8eeee; color: #23716f; }
@media (prefers-color-scheme: dark) {
  .tag.t-klassiker { background: #3b3020; color: #e3b778; }
  .tag.t-international { background: #22303f; color: #8fb6e0; }
  .tag.t-vegetarisch { background: #213325; color: #8fd09b; }
  .tag.t-fisch { background: #1f3534; color: #85d0cd; }
}

/* ---------- Shopping ---------- */
.progress { height: 8px; background: var(--line); border-radius: 4px; overflow: hidden; margin: 4px 0 14px; }
.progress i { display: block; height: 100%; background: var(--ok); transition: width .3s; }
.shop-head { display: flex; justify-content: space-between; align-items: baseline; font-size: 14px; color: var(--muted); }
.group { margin-bottom: 14px; overflow: hidden; }
.group h4 { margin: 0; padding: 10px 14px 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.item { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-top: 1px solid var(--line); width: 100%; text-align: left; }
.item .box { width: 24px; height: 24px; flex: none; border-radius: 7px; border: 2px solid var(--line); display: grid; place-items: center; transition: .15s; }
.item.done .box { background: var(--ok); border-color: var(--ok); }
.item.done .box::after { content: ""; width: 6px; height: 11px; border: solid #fff; border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-1px, -1px); }
.item .txt { flex: 1; min-width: 0; }
.item .name { font-weight: 500; }
.item .for { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .amt { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.item.done .name, .item.done .amt { text-decoration: line-through; color: var(--muted); font-weight: 400; }
.item .del { color: var(--muted); font-size: 20px; padding: 0 4px; }
.addrow { display: flex; gap: 8px; margin-bottom: 14px; }
.addrow input { flex: 1; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 14px; outline: none; }
.addrow input:focus { border-color: var(--primary); }
.btn { padding: 11px 16px; border-radius: 12px; background: var(--primary); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { .btn { color: #12201b; } }
.btn.ghost { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.btn.danger { background: transparent; color: var(--err); box-shadow: none; }
.btn.block { width: 100%; display: block; text-align: center; }
.toolbar { display: flex; gap: 8px; justify-content: space-between; margin: 4px 0 14px; flex-wrap: wrap; }
.toggle { font-size: 14px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }

/* ---------- Recipes ---------- */
.search { width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 11px 14px; margin-bottom: 10px; outline: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: var(--shadow); font-size: 14px; }
.chip.on { background: var(--ink); color: var(--bg); }
.rlist { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Sheet ---------- */
.overlay { position: fixed; inset: 0; background: rgba(20, 15, 5, .45); z-index: 50; opacity: 0; transition: opacity .2s; }
.overlay.show { opacity: 1; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 92vh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 8px 18px calc(24px + var(--safe-b));
  transform: translateY(100%); transition: transform .25s ease-out; max-width: 680px; margin: 0 auto;
  overscroll-behavior: contain;
}
.sheet.show { transform: none; }
.grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line); margin: 4px auto 10px; }
.sheet h2 { font-family: var(--serif); font-size: 26px; line-height: 1.15; margin: 8px 0 2px; }
.sheet .sub { color: var(--muted); margin-bottom: 8px; }
.sheet h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; }
.sheet-close { position: sticky; top: 0; float: right; width: 34px; height: 34px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); font-size: 18px; }
.stepper { display: inline-flex; align-items: center; gap: 0; background: var(--card); border-radius: 12px; box-shadow: var(--shadow); }
.stepper button { width: 40px; height: 40px; font-size: 20px; font-weight: 600; color: var(--primary); }
.stepper span { min-width: 92px; text-align: center; font-weight: 600; }
.servrow { display: flex; align-items: center; justify-content: space-between; margin-top: 14px; gap: 10px; }
.servrow small { color: var(--muted); font-size: 13px; }
.ing { list-style: none; padding: 0; margin: 0; }
.ing li { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ing li .a { width: 84px; flex: none; text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.ing li .n small { color: var(--muted); }
.ing li.pantry { color: var(--muted); }
.steps { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.steps li { counter-increment: s; position: relative; padding: 10px 0 10px 44px; border-bottom: 1px solid var(--line); cursor: pointer; }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 9px; width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); font-weight: 700; display: grid; place-items: center; font-size: 14px; }
.steps li.done { color: var(--muted); text-decoration: line-through; }
.steps li.done::before { background: var(--ok); color: #fff; content: "✓"; }
.tips { margin: 0; padding: 12px 14px 12px 32px; background: var(--accent-soft); border-radius: 14px; }
.tips li { margin: 4px 0; }
.actions { display: flex; gap: 8px; margin-top: 22px; flex-wrap: wrap; }
.actions .btn { flex: 1; text-align: center; }
.pick { display: flex; flex-direction: column; gap: 8px; }
.daypick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.daypick button { padding: 10px 0; border-radius: 12px; background: var(--card); box-shadow: var(--shadow); font-size: 13px; line-height: 1.2; }
.daypick button b { display: block; font-size: 16px; font-family: var(--serif); }
.daypick button.taken { opacity: .5; }

/* ---------- Misc ---------- */
.sec { padding: 16px; margin-bottom: 14px; }
.sec h3 { margin: 0 0 6px; font-family: var(--serif); font-size: 19px; }
.sec p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.sec textarea { width: 100%; min-height: 110px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--bg); font-family: ui-monospace, Menlo, monospace; font-size: 13px; }
.muted { color: var(--muted); }
.center { text-align: center; }
.emptystate { text-align: center; padding: 40px 20px; color: var(--muted); }
.emptystate b { display: block; font-family: var(--serif); color: var(--ink); font-size: 20px; margin-bottom: 4px; }
.toast { position: fixed; left: 50%; bottom: calc(88px + var(--safe-b)); transform: translate(-50%, 20px); opacity: 0; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60; transition: .25s; pointer-events: none; max-width: 90vw; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login .card { padding: 28px 22px; width: 100%; max-width: 380px; text-align: center; }
.login img { width: 72px; height: 72px; border-radius: 18px; }
.login h1 { font-family: var(--serif); margin: 12px 0 4px; }
.login input { width: 100%; text-align: center; font-size: 20px; letter-spacing: .1em; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 16px 0 10px; background: var(--bg); }
.login .err { color: var(--err); font-size: 14px; min-height: 20px; }

.sheet .meal h3 { font-family: var(--serif); font-size: 18px; text-transform: none; letter-spacing: 0; color: var(--ink); margin: 4px 0 0; }

/* ---------- Thermomix ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin-top: 16px; background: var(--card); border-radius: 14px; box-shadow: var(--shadow); }
.seg button { padding: 10px 0; border-radius: 10px; font-weight: 600; font-size: 15px; color: var(--muted); }
.seg button.on { background: var(--primary); color: #fff; }
@media (prefers-color-scheme: dark) { .seg button.on { color: #12201b; } }
.tmnote { margin: 0 0 6px; padding: 10px 12px; border-radius: 12px; background: var(--primary-soft); color: var(--primary); font-size: 14px; }
.setting { display: block; width: fit-content; margin-bottom: 4px; padding: 2px 9px; border-radius: 7px; background: var(--ink); color: var(--bg); font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; text-decoration: none; }
.steps li.done .setting { opacity: .5; }
.tmchip { padding: 0 7px; border-radius: 6px; border: 1px solid var(--line); font-size: 12px; font-weight: 600; }
