/* bibi-fit – Salbeigrün + Koralle, hell, für das Handy gemacht */
:root {
  --bg: #f3f5ef;
  --surface: #ffffff;
  --sage-50: #e9efe6;
  --sage-100: #dbe5d6;
  --sage-300: #a9bfa5;
  --sage-500: #7a9a7e;
  --sage-700: #4c6b52;
  --sage-900: #2c3f30;
  --coral-50: #fdeee9;
  --coral-300: #f6a593;
  --coral-500: #ee7a63;
  --coral-600: #dc634c;
  --ink: #26332b;
  --muted: #6d7a71;
  --line: #dfe5da;
  --danger: #b8432f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(38, 51, 43, .06), 0 4px 14px rgba(38, 51, 43, .06);
  --serif: "Noto Serif", Georgia, "Times New Roman", serif;
  --sans: Roboto, "Segoe UI", system-ui, -apple-system, sans-serif;
  --tabbar: 64px;
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 var(--sans); }
body { min-height: 100dvh; }
#app { max-width: 600px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px calc(var(--tabbar) + 28px + env(safe-area-inset-bottom)); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -.01em; margin: 0; }
h1 { font-size: 1.65rem; line-height: 1.2; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0; }
a { color: var(--sage-700); }
img { display: block; max-width: 100%; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 14px; }
.stack-sm > * + * { margin-top: 8px; }
.hidden { display: none !important; }

/* Kopfzeile */
.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 6px 0 18px; }
.top .eyebrow { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--sage-700); font-weight: 600; }
.daynav { display: flex; gap: 6px; }
.iconbtn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink); cursor: pointer; }
.iconbtn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.iconbtn:disabled { opacity: .35; }

/* Karten */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.flat { box-shadow: none; border: 1px solid var(--line); }

/* Gewichtsstreifen auf „Heute“ */
.weightstrip { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; align-items: center; text-decoration: none; color: inherit; }
.weightstrip .kg { font-family: var(--serif); font-size: 2rem; line-height: 1; font-weight: 600; }
.weightstrip .kg small { font-size: 1rem; font-weight: 500; color: var(--muted); margin-left: 2px; }
.weightstrip .delta { color: var(--sage-700); font-weight: 600; font-size: .92rem; }
.weightstrip svg { grid-row: span 2; width: 100%; height: 54px; }

/* Hinweise (Wiegetag, Spritze) */
.notice { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--coral-50); color: #7a3426; font-size: .95rem; }
.notice.sage { background: var(--sage-50); color: var(--sage-900); }
.notice b { font-weight: 600; }
.notice .btn { margin-left: auto; }

/* Buttons */
.btn { appearance: none; border: 0; border-radius: 999px; min-height: 44px; padding: 0 18px; font: 600 1rem var(--sans); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; }
.btn-primary { background: var(--coral-500); color: #fff; }
.btn-primary:active { background: var(--coral-600); }
.btn-sage { background: var(--sage-700); color: #fff; }
.btn-soft { background: var(--sage-50); color: var(--sage-900); }
.btn-ghost { background: transparent; color: var(--sage-700); padding: 0 10px; }
.btn-danger { background: transparent; color: var(--danger); }
.btn-block { width: 100%; }
.btn-big { min-height: 60px; font-size: 1.12rem; border-radius: 18px; }
.btn:disabled { opacity: .5; }
.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Mahlzeiten-Liste */
.meal { display: grid; grid-template-columns: 84px 1fr; gap: 12px; padding: 12px; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.meal .thumb { width: 84px; height: 84px; border-radius: 12px; object-fit: cover; background: var(--sage-50); }
.meal .thumb.empty { display: grid; place-items: center; color: var(--sage-500); font-family: var(--serif); font-size: 1.6rem; }
.meal .type { font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; color: var(--sage-700); font-weight: 700; }
.meal .desc { margin-top: 2px; white-space: pre-line; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.meal .amount { margin-top: 4px; font-size: .88rem; color: var(--coral-600); font-weight: 500; }
.meal .more { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--sage-50); color: var(--sage-900); font-size: .84rem; font-weight: 500; }
.pill.coral { background: var(--coral-50); color: #8a3a2b; }
.empty-state { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty-state h3 { color: var(--ink); margin-bottom: 4px; }

/* Verlauf */
.dayhead { position: sticky; top: 0; z-index: 2; background: var(--bg); padding: 10px 0 8px; display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.dayhead h3 { font-size: 1.05rem; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--sage-50); display: block; color: inherit; text-decoration: none; }
.tile img { width: 100%; height: 100%; object-fit: cover; }
.tile .label { position: absolute; left: 6px; bottom: 6px; right: 6px; font-size: .72rem; font-weight: 700; color: #fff; text-shadow: 0 1px 3px rgba(0,0,0,.5); text-transform: uppercase; letter-spacing: .05em; }
.tile.text { padding: 10px; font-size: .84rem; display: flex; flex-direction: column; justify-content: space-between; }
.tile.text .label { position: static; color: var(--sage-700); text-shadow: none; }
.tile .count { position: absolute; top: 6px; right: 6px; background: rgba(0,0,0,.45); color: #fff; border-radius: 999px; font-size: .72rem; padding: 1px 7px; }

/* Kalender */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-size: .74rem; color: var(--muted); font-weight: 600; padding: 4px 0; }
.cal .d { aspect-ratio: 1; border-radius: 10px; background: var(--surface); position: relative; overflow: hidden; display: block; color: var(--ink); text-decoration: none; font-size: .8rem; }
.cal .d span { position: absolute; top: 3px; left: 5px; font-weight: 600; z-index: 1; text-shadow: 0 0 3px #fff; }
.cal .d img { width: 100%; height: 100%; object-fit: cover; opacity: .9; }
.cal .d.off { background: transparent; }
.cal .d.today { outline: 2px solid var(--coral-500); }
.cal .d i { position: absolute; bottom: 3px; right: 4px; font-style: normal; font-size: .7rem; }

/* Segment-Auswahl & Chips */
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--sage-50); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button, .chip { appearance: none; border: 0; background: transparent; font: 500 .95rem var(--sans); color: var(--sage-900); border-radius: 9px; min-height: 40px; cursor: pointer; padding: 0 8px; }
.seg button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); font-weight: 700; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 0 14px; min-height: 38px; }
.chip[aria-pressed="true"] { background: var(--sage-700); border-color: var(--sage-700); color: #fff; }

/* Formulare */
label.field { display: block; }
label.field > span { display: block; font-size: .84rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=search], input[type=number], textarea, select {
  width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 12px 14px; font: 1rem var(--sans); color: var(--ink);
}
textarea { min-height: 96px; resize: vertical; }
input:focus, textarea:focus, select:focus, button:focus-visible, a:focus-visible { outline: 2px solid var(--sage-500); outline-offset: 2px; }
.bignum { font-family: var(--serif); font-size: 2.6rem; text-align: center; font-weight: 600; padding: 14px; }

/* Fotos im Formular */
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--sage-50); }
.photo img { width: 100%; height: 100%; object-fit: cover; }
.photo .x { position: absolute; top: 4px; right: 4px; width: 32px; height: 32px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.photo .tag { position: absolute; left: 4px; bottom: 4px; border: 0; border-radius: 999px; padding: 4px 10px; font: 600 .76rem var(--sans); cursor: pointer; background: rgba(255,255,255,.92); color: var(--sage-900); }
.photo .tag.rest { background: var(--coral-500); color: #fff; }
.photo.busy::after { content: ""; position: absolute; inset: 0; background: rgba(255,255,255,.6) url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50"><circle cx="25" cy="25" r="18" fill="none" stroke="%237a9a7e" stroke-width="5" stroke-dasharray="80 40"><animateTransform attributeName="transform" type="rotate" from="0 25 25" to="360 25 25" dur="1s" repeatCount="indefinite"/></circle></svg>') center / 36px no-repeat; }
.addphoto { aspect-ratio: 1; border-radius: 12px; border: 2px dashed var(--sage-300); background: transparent; color: var(--sage-700); font: 600 .86rem var(--sans); cursor: pointer; display: grid; place-items: center; text-align: center; padding: 6px; }
.addphoto svg { width: 28px; height: 28px; fill: none; stroke: currentColor; stroke-width: 1.8; display: block; margin: 0 auto 4px; }

/* Detailansicht */
.gallery { display: grid; gap: 8px; }
.gallery img { width: 100%; border-radius: var(--radius); }
.gallery .restlabel { font-size: .8rem; font-weight: 700; color: var(--coral-600); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }

/* Fortschritt */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--surface); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); }
.stat b { display: block; font-family: var(--serif); font-size: 1.35rem; }
.stat span { font-size: .78rem; color: var(--muted); }
.chart { width: 100%; height: auto; display: block; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.list li:last-child { border-bottom: 0; }
.milestones { display: flex; flex-wrap: wrap; gap: 8px; }

/* Spritzen-Stellen */
.sites { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.sites button { position: relative; min-height: 52px; }
.sites button em { position: absolute; top: -8px; right: 8px; font-style: normal; font-size: .68rem; background: var(--coral-500); color: #fff; border-radius: 999px; padding: 1px 7px; }

/* Prüf-Assistent */
.review-meal { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); }
.review-meal .photos { grid-template-columns: repeat(2, 1fr); }
.review-meal select { padding: 8px 10px; font-size: .9rem; }
.photo-tools { display: grid; gap: 6px; margin-top: 6px; }
.flag { font-size: .8rem; color: #8a3a2b; background: var(--coral-50); border-radius: 8px; padding: 6px 10px; }
.progress { height: 8px; background: var(--sage-100); border-radius: 999px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--sage-500); }

/* Anmeldung */
.login { min-height: 80dvh; display: grid; align-content: center; gap: 18px; }
.brand { font-family: var(--serif); font-size: 2.4rem; font-weight: 600; color: var(--sage-900); }
.brand span { color: var(--coral-500); }

/* Tab-Leiste */
#tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: rgba(255,255,255,.96); border-top: 1px solid var(--line); display: grid; grid-template-columns: repeat(4, 1fr); }
#tabs[hidden] { display: none; }
#tabs a { display: grid; place-items: center; align-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: .74rem; font-weight: 600; }
#tabs svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
#tabs a[aria-current="page"] { color: var(--sage-700); }
#tabs a[aria-current="page"] svg { stroke: var(--coral-500); }

/* Hinweis-Toast */
#toast { position: fixed; left: 50%; bottom: calc(var(--tabbar) + 16px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--sage-900); color: #fff; padding: 10px 18px; border-radius: 999px; font-weight: 500; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--danger); }

/* Vollbild-Foto */
.lightbox { position: fixed; inset: 0; background: rgba(15, 20, 17, .94); z-index: 30; display: grid; place-items: center; padding: 12px; }
.lightbox img { max-height: 92dvh; border-radius: 8px; }

.sheet-head { display: flex; align-items: center; gap: 8px; margin: 4px 0 16px; }
.sheet-head h1 { font-size: 1.4rem; }
.savebar { position: sticky; bottom: calc(var(--tabbar) + 10px + env(safe-area-inset-bottom)); margin-top: 20px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(4, 1fr); } }

/* Offline-Warteschlange */
.pill.pending { border: 1.5px dashed var(--sage-500); }
.meal.pending { box-shadow: none; border: 1.5px dashed var(--sage-500); background: var(--sage-50); }
#queuebar { position: fixed; left: 12px; right: 12px; bottom: calc(var(--tabbar) + 10px + env(safe-area-inset-bottom)); z-index: 30; border: 0; border-radius: 999px; padding: 10px 16px; background: var(--sage-900); color: #fff; font: inherit; font-size: .9rem; box-shadow: var(--shadow); }
#queuebar.error { background: var(--coral-600); }

/* Erinnerungen */
.remrow { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.remrow input[type=time] { width: auto; min-width: 96px; }
.remrow input[type=time]:disabled { opacity: .45; }
.remlabel { line-height: 1.3; }
.switch { position: relative; display: inline-block; width: 46px; height: 28px; flex: none; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch span { position: absolute; inset: 0; border-radius: 999px; background: var(--line); transition: background .15s; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--sage-500); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--coral-600); outline-offset: 2px; }
