:root {
  --bg: #faf6f0;
  --card: #ffffff;
  --text: #2b2520;
  --muted: #7a6f66;
  --line: #eadfd3;
  --accent: #c2410c;
  --accent-soft: #fdeadd;
  --on-accent: #ffffff;
  --ok: #2f8f46;
  --danger: #c0262d;
  --shadow: 0 1px 3px rgba(60, 40, 20, .08), 0 6px 18px rgba(60, 40, 20, .06);
  --radius: 16px;
  --nav-h: 62px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1815;
    --card: #26221e;
    --text: #f3ece4;
    --muted: #a89c90;
    --line: #3a332d;
    --accent: #f97316;
    --accent-soft: #3b2616;
    --on-accent: #1b1815;
    --ok: #5cc777;
    --danger: #f0676d;
    --shadow: 0 1px 3px rgba(0, 0, 0, .4);
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; }
.boot { text-align: center; padding: 30vh 20px; color: var(--muted); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg.ic { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- Kopfzeile ---------- */
header.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 6px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
header.top h1 { flex: 1; font-size: 1.25rem; padding-left: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 2px; }
.iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: transparent; color: var(--text); text-decoration: none;
}
.iconbtn:active { background: var(--line); }
.iconbtn.on { color: var(--accent); }
.iconbtn.on svg { fill: currentColor; }
.offline { background: #7a6f66; color: #fff; text-align: center; font-size: .85rem; padding: 4px 10px; }

main { padding: 14px 14px calc(var(--nav-h) + 90px + env(safe-area-inset-bottom)); }
main.flush { padding-left: 0; padding-right: 0; padding-top: 0; }
.pad { padding: 0 16px; }

/* ---------- Navigation unten ---------- */
nav.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav.tabs a {
  flex: 1; max-width: 240px; height: var(--nav-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); text-decoration: none; font-size: .75rem; font-weight: 600;
}
nav.tabs a.active { color: var(--accent); }

.fab {
  position: fixed; z-index: 25;
  right: max(16px, calc(50vw - 344px));
  bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  height: 56px; padding: 0 20px 0 16px; border: 0; border-radius: 28px;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: var(--on-accent); font-weight: 700; text-decoration: none;
  box-shadow: 0 6px 18px rgba(194, 65, 12, .35);
}

/* ---------- Formularelemente ---------- */
input[type=text], input[type=password], input[type=search], select, textarea {
  width: 100%; padding: 12px 14px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  font-size: 16px; outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 76px; line-height: 1.45; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: .85rem; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.field > span .linkbtn { padding: 0; font-size: inherit; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font-weight: 650; text-decoration: none;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.danger { color: var(--danger); }
.btn.block { display: flex; width: 100%; }
.btn.small { min-height: 38px; padding: 0 12px; font-size: .9rem; border-radius: 10px; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; }
.btnrow .btn { flex: 1; }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0 12px; }
.empty { text-align: center; color: var(--muted); padding: 48px 20px; }
.empty .big { font-size: 3rem; line-height: 1; margin-bottom: 10px; }
h3.sec { font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); margin: 26px 0 10px; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 1.05rem; margin-bottom: 8px; }

/* ---------- Anmeldung ---------- */
.login { max-width: 380px; margin: 0 auto; padding: 12vh 22px 40px; text-align: center; }
.login img { width: 96px; height: 96px; border-radius: 24px; box-shadow: var(--shadow); }
.login h1 { margin: 18px 0 6px; font-size: 1.6rem; }
.login p { color: var(--muted); margin: 0 0 22px; }
.login form { display: grid; gap: 12px; text-align: left; }

/* ---------- Rezeptliste ---------- */
.search { position: relative; margin-bottom: 10px; }
.search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 44px; border-radius: 999px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 14px 10px; margin: 0 -14px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 999px; padding: 7px 14px; font-size: .9rem; white-space: nowrap;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.chip.add::before { content: "+ "; color: var(--accent); font-weight: 700; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(3, 1fr); } }
.rcard {
  display: block; background: var(--card); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); color: inherit; text-decoration: none;
}
.rcard .img { aspect-ratio: 4 / 3; background: var(--accent-soft) center / cover no-repeat; display: flex; align-items: center; justify-content: center; font-size: 2.4rem; }
.rcard .txt { padding: 10px 12px 12px; }
.rcard b { display: block; line-height: 1.25; }
.rcard small { color: var(--muted); }

/* ---------- Rezeptansicht ---------- */
.hero { width: 100%; aspect-ratio: 4 / 3; max-height: 420px; object-fit: cover; display: block; background: var(--accent-soft); }
.hero.none { display: flex; align-items: center; justify-content: center; font-size: 4rem; aspect-ratio: 3 / 1; }
.rtitle { font-size: 1.6rem; margin: 16px 0 6px; }
.desc { color: var(--muted); margin: 0 0 10px; }
.meta { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.meta span { display: inline-flex; align-items: center; gap: 6px; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: .85rem; }
.meta svg.ic { width: 15px; height: 15px; color: var(--muted); }
ul.ing { list-style: none; margin: 0; padding: 0 16px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); }
ul.ing li { display: flex; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
ul.ing li:last-child { border-bottom: 0; }
ul.ing .amt { flex: 0 0 5.2em; font-weight: 650; }
ul.ing li.group { font-weight: 700; color: var(--muted); font-size: .9rem; padding-top: 16px; }
ul.ing li.struck { text-decoration: line-through; color: var(--muted); }
ol.steps { list-style: none; counter-reset: s; margin: 0; padding: 0; }
ol.steps li { counter-increment: s; position: relative; padding: 0 0 16px 44px; }
ol.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent); font-weight: 700;
  display: flex; align-items: center; justify-content: center; font-size: .9rem;
}
.notes { white-space: pre-line; background: var(--card); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); margin: 0; }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumbs img, .thumbs button { width: 72px; height: 72px; object-fit: cover; border-radius: 10px; border: 2px solid var(--line); padding: 0; background: var(--card) center / cover; }
.thumbs button.sel { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

/* ---------- Rezeptformular ---------- */
.scanbox { border: 2px dashed var(--accent); background: var(--accent-soft); border-radius: var(--radius); padding: 18px; text-align: center; margin-bottom: 18px; }
.scanbox p { margin: 8px 0 0; font-size: .9rem; color: var(--muted); }
.cover { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius); display: block; margin-bottom: 10px; background: var(--accent-soft); }
.irow { display: grid; grid-template-columns: 6em 1fr 40px; gap: 6px; margin-bottom: 6px; align-items: center; }
.srow { display: grid; grid-template-columns: 26px 1fr 40px; gap: 6px; margin-bottom: 8px; align-items: start; }
.srow .num { padding-top: 12px; font-weight: 700; color: var(--accent); text-align: center; }
.rm { width: 40px; height: 44px; border: 0; background: transparent; color: var(--muted); border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; }
.rm:active { background: var(--line); }
.savebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; justify-content: center;
}
.savebar .btn { width: 100%; max-width: 692px; }

/* ---------- Listen ---------- */
.lcard { display: flex; align-items: center; gap: 12px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 10px; color: inherit; text-decoration: none; }
.lcard .grow { flex: 1; min-width: 0; }
.lcard b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lcard small { color: var(--muted); }
.badge { background: var(--accent); color: var(--on-accent); border-radius: 999px; min-width: 28px; height: 28px; padding: 0 9px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .9rem; }
.badge.zero { background: var(--line); color: var(--muted); }

.addform { display: flex; gap: 8px; margin-bottom: 10px; }
.addform input { flex: 1; }
.addform .btn { flex: none; width: 52px; padding: 0; }
ul.items { list-style: none; margin: 0 0 6px; padding: 0; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
ul.items:empty { display: none; }
ul.items li { display: flex; align-items: center; border-bottom: 1px solid var(--line); }
ul.items li:last-child { border-bottom: 0; }
.item-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 12px 4px 12px 14px; border: 0; background: transparent; text-align: left; }
.box { flex: none; width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--muted); display: inline-flex; align-items: center; justify-content: center; color: transparent; }
.box svg.ic { width: 18px; height: 18px; stroke-width: 3; }
li.done .box { background: var(--ok); border-color: var(--ok); color: #fff; }
li.done .item-txt { text-decoration: line-through; color: var(--muted); }
.item-txt { min-width: 0; overflow-wrap: anywhere; }
.item-txt small { display: block; color: var(--muted); font-size: .78rem; text-decoration: none; }
ul.items .iconbtn { width: 40px; height: 44px; color: var(--muted); }
ul.items .iconbtn svg.ic { width: 19px; height: 19px; }
ul.items .iconbtn.on { color: #e8a317; }
.sechead { display: flex; align-items: center; justify-content: space-between; margin: 20px 4px 8px; color: var(--muted); font-size: .9rem; font-weight: 600; }
.linkbtn { border: 0; background: transparent; color: var(--accent); font-weight: 600; padding: 6px 4px; }

.frow { display: flex; align-items: center; gap: 4px; padding-left: 14px; border-bottom: 1px solid var(--line); }
.frow:last-child { border-bottom: 0; }
.frow span { flex: 1; padding: 13px 0; overflow-wrap: anywhere; }

/* ---------- Punkte-Tagebuch ---------- */
nav.tabs a { position: relative; }
nav.tabs a.dot::after { content: ""; position: absolute; top: 9px; left: calc(50% + 8px); width: 10px; height: 10px; border-radius: 50%; background: var(--danger); border: 2px solid var(--card); }
.daynav { display: flex; align-items: center; justify-content: space-between; margin: -6px 0 8px; }
.daylabel { font-size: 1.05rem; color: var(--text); font-weight: 700; }
.ptscard { text-align: center; }
.ptsbig { font-size: 3.2rem; font-weight: 800; line-height: 1; color: var(--ok); }
.ptscard.over .ptsbig { color: var(--danger); }
.ptslabel { color: var(--muted); margin: 4px 0 12px; }
.bar { height: 10px; border-radius: 5px; background: var(--line); overflow: hidden; }
.bar span { display: block; height: 100%; border-radius: 5px; background: var(--ok); }
.ptscard.over .bar span { background: var(--danger); }
.ptsmeta { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin-top: 8px; font-size: .85rem; color: var(--muted); }
.movecard { border-left: 5px solid var(--accent); }
.movecard.done { border-left-color: var(--ok); }
.moverow { display: flex; align-items: center; gap: 12px; }
.moverow .grow { flex: 1; min-width: 0; }
.movecard .linkbtn { display: inline-flex; align-items: center; gap: 6px; margin-top: 8px; padding-left: 0; font-size: .9rem; }
.movecard .linkbtn svg.ic { width: 16px; height: 16px; }
.dots { display: flex; gap: 5px; margin-top: 8px; }
.dots span { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; color: var(--muted); }
.dots span.on { background: var(--ok); border-color: var(--ok); color: #fff; font-weight: 700; }
.dots span.cur { box-shadow: 0 0 0 2px var(--accent-soft), 0 0 0 3px var(--accent); }
.ptsform .addform { margin-bottom: 2px; }
.ptsin { flex: 0 0 4.6em !important; text-align: center; padding-left: 6px !important; padding-right: 6px !important; }
.formline { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: .9rem; }
.check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
b.pts { flex: none; min-width: 2.2em; text-align: right; padding-right: 4px; }
.calcres { text-align: center; font-size: 1.1rem; margin: 4px 0 14px; }
.calcres b { font-size: 2.2rem; color: var(--accent); }
.daypick { display: flex; gap: 6px; }
.daypick label { flex: 1; }
.daypick input { position: absolute; opacity: 0; pointer-events: none; }
.daypick span { display: flex; align-items: center; justify-content: center; height: 42px; border-radius: 10px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: .9rem; }
.daypick input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
input[type=time] { width: 100%; padding: 12px 14px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; font-size: 16px; }

/* ---------- Sheet (Dialog von unten) ---------- */
.sheet-back { position: fixed; inset: 0; z-index: 50; background: rgba(20, 12, 6, .5); display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease-out; }
.sheet {
  width: 100%; max-width: 720px; max-height: 88vh; max-height: 88dvh; overflow-y: auto;
  background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom));
  animation: up .2s ease-out;
}
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 14px; }
.sheet h2 { font-size: 1.2rem; margin-bottom: 4px; }
.sheet .stack { display: grid; gap: 10px; margin-top: 14px; }
.sheet .btn { justify-content: flex-start; }
.sheet .btn.primary, .sheet .btn.center { justify-content: center; }
ul.pick { list-style: none; margin: 10px 0 16px; padding: 0; background: var(--card); border-radius: var(--radius); overflow: hidden; }
ul.pick li { border-bottom: 1px solid var(--line); }
ul.pick li:last-child { border-bottom: 0; }
ul.pick label { display: flex; align-items: center; gap: 12px; padding: 11px 14px; }
ul.pick input { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
ul.pick input:not(:checked) ~ span { color: var(--muted); text-decoration: line-through; }
ul.pick .amt { font-weight: 650; }
ul.pick li.group { padding: 12px 14px 6px; font-weight: 700; font-size: .85rem; color: var(--muted); }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }

/* ---------- Meldungen ---------- */
#toast {
  position: fixed; z-index: 70; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 22px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 28px); width: max-content;
  background: #2b2520; color: #fff; border-radius: 14px; padding: 12px 16px;
  display: flex; align-items: center; gap: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
  font-size: .95rem;
}
#toast button { border: 0; background: transparent; color: #fdba74; font-weight: 700; padding: 0; white-space: nowrap; }
#busy { position: fixed; inset: 0; z-index: 80; background: rgba(20, 12, 6, .6); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 30px; text-align: center; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .3); border-top-color: #fff; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
