:root {
  --bg: #fbf7f2;
  --card: #ffffff;
  --ink: #2a211b;
  --muted: #7a6a5e;
  --line: #ece3d9;
  --accent: #c2410c;
  --accent-soft: #fde8dc;
  --ok: #15803d;
  --migros: #ff6600;
  --coop: #e2001a;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(60, 30, 10, .07);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1714;
    --card: #26201c;
    --ink: #f3ebe4;
    --muted: #b3a294;
    --line: #3a312b;
    --accent: #fb923c;
    --accent-soft: #3d2618;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: .5rem;
  padding: calc(.6rem + env(safe-area-inset-top)) 1rem .6rem;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { flex: 1; font-size: 1.15rem; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  border: 0; background: none; color: var(--ink);
  font-size: 1.5rem; width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
}
.icon-btn:active { background: var(--line); }

main { max-width: 720px; margin: 0 auto; padding: 1rem; }

.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; border: 0; background: none; color: var(--muted);
  padding: .5rem 0 .6rem; font-size: .75rem; display: flex; flex-direction: column; align-items: center; cursor: pointer;
}
.tabbar button span { font-size: 1.3rem; }
.tabbar button.active { color: var(--accent); font-weight: 600; }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 1rem; margin-bottom: 1rem;
}
.hero { text-align: center; padding: 1.5rem 1rem; }
.hero .emoji { font-size: 3rem; }

label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .8rem; }
input, select, textarea {
  display: block; width: 100%; margin-top: .3rem;
  font: inherit; padding: .65rem .8rem; border-radius: 12px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
}
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .3rem 0 .8rem; }
.chip {
  border: 1px solid var(--line); background: var(--bg); color: var(--ink);
  padding: .4rem .8rem; border-radius: 999px; font-size: .9rem; cursor: pointer;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600;
  padding: .8rem 1.2rem; border-radius: 12px; cursor: pointer;
}
.btn.big { width: 100%; padding: 1rem; font-size: 1.05rem; }
.btn.ghost { background: var(--accent-soft); color: var(--accent); }
.btn:disabled { opacity: .5; }
.link { border: 0; background: none; color: var(--muted); font: inherit; text-decoration: underline; cursor: pointer; margin-top: .8rem; }
.row { display: flex; gap: .6rem; justify-content: flex-end; }

.proposal { cursor: pointer; transition: transform .1s; }
.proposal:active { transform: scale(.98); }
.proposal h3 { font-size: 1.1rem; }
.meta { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .5rem; }
.tag { font-size: .78rem; background: var(--accent-soft); color: var(--accent); padding: .15rem .55rem; border-radius: 999px; }

.loading { text-align: center; padding: 3rem 1rem; }
.spinner {
  width: 44px; height: 44px; margin: 0 auto 1rem; border-radius: 50%;
  border: 4px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.segmented { display: flex; background: var(--line); border-radius: 12px; padding: 3px; margin-bottom: 1rem; }
.segmented button {
  flex: 1; border: 0; background: none; color: var(--ink); font: inherit; font-weight: 600;
  padding: .55rem; border-radius: 10px; cursor: pointer;
}
.segmented button.on { background: var(--card); box-shadow: var(--shadow); }

.market-badge { display: inline-block; color: #fff; font-weight: 700; padding: .1rem .6rem; border-radius: 6px; font-size: .85rem; }
.market-badge.migros { background: var(--migros); }
.market-badge.coop { background: var(--coop); }

.progress { height: 8px; background: var(--line); border-radius: 99px; overflow: hidden; margin: .4rem 0 1rem; }
.progress > div { height: 100%; background: var(--ok); transition: width .25s; }

.cat { margin-bottom: 1rem; }
.cat h3 { font-size: .95rem; display: flex; align-items: center; gap: .4rem; padding: .3rem 0; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.cat h3 .count { margin-left: auto; font-weight: 400; text-transform: none; }
.item {
  display: flex; align-items: flex-start; gap: .75rem; padding: .7rem .2rem;
  border-bottom: 1px solid var(--line); cursor: pointer;
}
.item:last-child { border-bottom: 0; }
.check {
  flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted);
  display: grid; place-items: center; color: #fff; font-size: .9rem; margin-top: 2px;
}
.item.done .check { background: var(--ok); border-color: var(--ok); }
.item.done .item-text > :not(.by) { opacity: .45; text-decoration: line-through; }
.item-text { flex: 1; min-width: 0; }
.item-text b { display: block; font-weight: 600; }
.item-text small { color: var(--muted); display: block; }
.item a { color: var(--muted); font-size: 1.1rem; text-decoration: none; padding: 0 .3rem; }
.pantry { font-size: .72rem; background: var(--line); color: var(--muted); padding: .05rem .45rem; border-radius: 99px; margin-left: .3rem; }

.ing-list { padding-left: 1.1rem; margin: 0; }
.ing-list li { margin: .25rem 0; }

.steps-overview ol { padding-left: 1.2rem; }
.steps-overview li { margin-bottom: .7rem; }

.stepper { text-align: center; }
.stepper .step-num { color: var(--accent); font-weight: 700; font-size: .9rem; }
.stepper .step-title { font-size: 1.3rem; margin: .3rem 0 .8rem; }
.stepper .step-text { font-size: 1.15rem; text-align: left; min-height: 8rem; }
.stepper .step-ings { text-align: left; background: var(--accent-soft); border-radius: 12px; padding: .6rem .9rem; margin: .8rem 0; font-size: .95rem; }
.stepper .tip { text-align: left; font-size: .92rem; color: var(--muted); border-left: 3px solid var(--accent); padding-left: .7rem; margin: .8rem 0; }
.dots { display: flex; justify-content: center; gap: 6px; margin: 1rem 0; flex-wrap: wrap; }
.dots span { width: 8px; height: 8px; border-radius: 50%; background: var(--line); }
.dots span.on { background: var(--accent); }
.step-nav { display: flex; gap: .6rem; }
.step-nav .btn { flex: 1; }

.timer { display: inline-flex; align-items: center; gap: .5rem; margin-top: .5rem; }
.timer .time { font-variant-numeric: tabular-nums; font-size: 1.4rem; font-weight: 700; }

.saved-item { display: flex; align-items: center; gap: .8rem; cursor: pointer; }
.saved-item .grow { flex: 1; min-width: 0; }
.saved-item h3 { font-size: 1rem; margin: 0; }
.del { border: 0; background: none; color: var(--muted); font-size: 1.2rem; cursor: pointer; }

dialog {
  border: 0; border-radius: 20px; padding: 1.4rem; width: min(92vw, 420px);
  background: var(--card); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20, 10, 5, .45); }
.market-choice { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; margin: 1rem 0 .3rem; }
.market {
  border: 0; border-radius: 16px; padding: 1.2rem .6rem; color: #fff; cursor: pointer;
  display: flex; flex-direction: column; gap: .2rem; font: inherit;
}
.market b { font-size: 1.3rem; }
.market small { opacity: .9; font-size: .75rem; }
.market.migros { background: var(--migros); }
.market.coop { background: var(--coop); }

#toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: .6rem 1rem; border-radius: 12px; font-size: .9rem;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw;
}
#toast.show { opacity: 1; }
.error { color: var(--coop); }

/* ---- v2: Sync, Mehrfachauswahl, Wein ---- */
#sync-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--line); flex: none; }
#sync-dot.ok { background: var(--ok); }
#sync-dot.pending { background: #eab308; }
#sync-dot.offline { background: var(--coop); }
.hidden { display: none !important; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.stepper-input { display: flex; align-items: center; margin-top: .3rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); overflow: hidden; }
.stepper-input button { border: 0; background: none; color: var(--accent); font-size: 1.4rem; width: 44px; height: 44px; cursor: pointer; }
.stepper-input span { flex: 1; text-align: center; font-size: 1.1rem; font-weight: 700; }
.toggle { display: flex; align-items: center; gap: .7rem; padding: .7rem .9rem; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); cursor: pointer; }
.toggle input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); flex: none; }
.segmented button { font-size: .88rem; }
.proposal { display: flex; gap: .8rem; align-items: flex-start; border: 2px solid transparent; }
.proposal.selected { border-color: var(--accent); }
.proposal .sel { flex: none; width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; color: #fff; font-weight: 700; margin-top: 2px; }
.proposal.selected .sel { background: var(--accent); border-color: var(--accent); }
.action-bar { position: fixed; left: 0; right: 0; bottom: calc(64px + env(safe-area-inset-bottom)); padding: .6rem 1rem; z-index: 9; transform: translateY(150%); transition: transform .2s; pointer-events: none; }
.action-bar.show { transform: none; pointer-events: auto; }
.action-bar .btn { max-width: 688px; margin: 0 auto; display: flex; box-shadow: 0 6px 20px rgba(0,0,0,.25); }
main:has(.action-bar.show) { padding-bottom: 6rem; }
.recipe-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
a.chip { text-decoration: none; font-size: .82rem; }
a.btn { text-decoration: none; }
.rnum { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--accent); color: #fff; font-size: .7rem; font-weight: 700; margin-left: 3px; }
.item small.by { color: var(--ok); font-weight: 600; }
.item.done small.by { opacity: 1; }
.wine { border-left: 4px solid #7f1d1d; }
.archived { opacity: .55; }
.saved-item .progress { margin: .5rem 0 0; }

/* ---- v3: iPhone-Layout absichern ---- */
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation; /* kein Doppeltipp-Zoom (z. B. bei +/−) */
}
html, body { overflow-x: hidden; max-width: 100%; }
body { overflow-wrap: break-word; }
.segmented button, .grid2 > *, .proposal > div, .item-text, .saved-item .grow { min-width: 0; }
.segmented button { display: flex; flex-direction: column; align-items: center; gap: .1rem; line-height: 1.2; padding: .5rem .2rem; }
input, select, textarea { font-size: 16px; } /* < 16px würde iOS beim Antippen zoomen lassen */

/* ---- Timer-Leiste ---- */
.topbar { flex-wrap: wrap; }
#timerbar { flex-basis: 100%; width: 100%; min-width: 0; display: flex; flex-direction: column; gap: .35rem; }
#timerbar:empty { display: none; }
.tpill {
  display: flex; align-items: center; gap: .6rem; min-width: 0; max-width: 100%; background: var(--accent-soft); color: var(--ink);
  border-radius: 12px; padding: .4rem .5rem .4rem .8rem; font-size: .9rem;
}
.tpill .tl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.tpill .tt { font-variant-numeric: tabular-nums; font-weight: 700; }
.tpill button { border: 0; background: var(--accent); color: #fff; border-radius: 9px; padding: .35rem .7rem; font-weight: 700; cursor: pointer; font-size: .85rem; }
.tpill.ringing { background: var(--coop); color: #fff; animation: pulse 1s infinite; }
.tpill.ringing button { background: #fff; color: var(--coop); }
@keyframes pulse { 50% { opacity: .75; } }
.timer .btn.stop { background: var(--coop); color: #fff; }

/* ---- Vorschläge ---- */
.course-head { margin: 1.4rem 0 .3rem; }
.tag.orig { background: #ede9fe; color: #6d28d9; }
@media (prefers-color-scheme: dark) { .tag.orig { background: #2e1065; color: #c4b5fd; } }
.proposal .twist { font-size: .88rem; margin: .35rem 0 0; color: var(--accent); }
.tpill .tt, .tpill button { flex: none; }
.topbar h1 { min-width: 0; }
