:root {
  --bg: #161618; --card: #202024; --card2: #2a2a2f; --line: #2e2e34;
  --text: #f4f4f5; --muted: #9a9aa0; --dim: #6b6b72;
  --accent: #35d07f; --accent-dim: rgba(53, 208, 127, .18);
  --p: #35d07f; --k: #f0b429; --f: #8b7cff; --danger: #ff453a;
  --r: 18px; --r-s: 12px;
  --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f4f4f6; --card: #ffffff; --card2: #ebebef; --line: #e0e0e6;
  --text: #17171a; --muted: #6b6b72; --dim: #9a9aa0;
  --accent: #1fb86a; --accent-dim: rgba(31, 184, 106, .16);
  --p: #1fb86a; --k: #d99a12; --f: #6f5cf5; --danger: #e0352b;
  color-scheme: light;
}
:root[data-theme="light"] .sheet-bg { background: rgba(0,0,0,.35); }
:root[data-theme="light"] .fab, :root[data-theme="light"] .toast { box-shadow: 0 6px 20px rgba(0,0,0,.15); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif; overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
svg.i { width: 22px; height: 22px; display: block; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }

/* ---------- Grundgeruest ---------- */
#app { display: flex; flex-direction: column; height: 100dvh; }
.page { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.top { padding: calc(var(--sat) + 10px) 16px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top h1 { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.icon-btn:active { background: var(--card); color: var(--text); }
.date-nav { display: flex; align-items: center; gap: 2px; }
.date-nav .label { font-size: 18px; font-weight: 700; padding: 6px 8px; border-radius: 10px; }
.date-nav .label:active { background: var(--card); }
.tabs { display: flex; justify-content: space-around; padding: 6px 10px calc(var(--sab) + 6px); border-top: 1px solid var(--line); background: var(--bg); }
.tabs button { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--dim); font-size: 11px; padding: 4px 18px; border-radius: 12px; }
.tabs button.on { color: var(--accent); }

/* ---------- kcal-Karte ---------- */
.kcal { margin: 0 16px; background: var(--card); border-radius: var(--r); padding: 14px 16px 12px; }
.kcal .big { display: flex; align-items: baseline; gap: 6px; }
.kcal .big b { font-size: 40px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.kcal .big span { color: var(--muted); font-size: 15px; }
.bar { height: 10px; background: var(--card2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .4s ease; }
.bar i.over { background: var(--danger); }
.macros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.macro { font-size: 12px; color: var(--muted); }
.macro b { color: var(--text); font-weight: 600; }
.macro .bar { height: 5px; margin-top: 5px; }
.macro.p .bar i { background: var(--p); } .macro.k .bar i { background: var(--k); } .macro.f .bar i { background: var(--f); }

/* ---------- Chat ---------- */
.chat { flex: 1; min-height: 0; overflow-y: auto; padding: 12px 16px 8px; display: flex; flex-direction: column; gap: 8px; -webkit-overflow-scrolling: touch; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; font-size: 15.5px; }
.msg.user { align-self: flex-end; background: var(--accent-dim); border-bottom-right-radius: 5px; }
.msg.model { align-self: flex-start; background: var(--card); border-bottom-left-radius: 5px; }
.msg img { display: block; max-width: 200px; border-radius: 10px; margin-bottom: 6px; }
.msg .att { font-size: 12px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; background: var(--card2); border-radius: 10px; padding: 5px 9px; font-size: 13px; margin: 6px 6px 0 0; }
.chip b { color: var(--accent); }
.typing { align-self: flex-start; color: var(--dim); font-size: 13px; padding: 4px 6px; }
.typing i { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--dim); margin-right: 3px; animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .2s } .typing i:nth-child(3) { animation-delay: .4s }
@keyframes blink { 0%, 80%, 100% { opacity: .2 } 40% { opacity: 1 } }
.inbar { display: flex; align-items: flex-end; gap: 6px; padding: 6px 10px 8px; }
.inbar textarea { flex: 1; background: var(--card); border-radius: 20px; padding: 10px 14px; border: 0; outline: 0; resize: none; max-height: 120px; line-height: 1.3; }
.inbar textarea::placeholder { color: var(--dim); }
.round { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; }
.round.send { background: var(--accent); color: #0b2a19; }
.round.rec { background: var(--danger); color: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255,69,58,.5) } 50% { box-shadow: 0 0 0 8px rgba(255,69,58,0) } }

/* ---------- Listen, Karten ---------- */
.list { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; flex: 1; min-height: 0; }
.row { background: var(--card); border-radius: var(--r-s); padding: 12px 14px; display: flex; align-items: center; gap: 12px; }
.row .main { flex: 1; min-width: 0; }
.row .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { font-size: 13px; color: var(--muted); margin-top: 2px; }
.row .kc { font-weight: 700; white-space: nowrap; }
.row.sel { outline: 2px solid var(--accent); }
.circle { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--dim); display: grid; place-items: center; color: #0b2a19; flex: none; }
.circle.on { background: var(--accent); border-color: var(--accent); }
.search { margin: 0 16px 10px; }
.search input { width: 100%; background: var(--card); border: 0; border-radius: 12px; padding: 10px 14px; outline: 0; }
.fab { position: fixed; right: 18px; bottom: calc(var(--sab) + 70px); width: 54px; height: 54px; border-radius: 50%; background: var(--accent); color: #0b2a19; display: grid; place-items: center; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
.selbar { position: fixed; left: 16px; right: 16px; bottom: calc(var(--sab) + 70px); display: flex; gap: 10px; }
.btn { border-radius: 14px; padding: 13px 16px; font-weight: 700; text-align: center; background: var(--card2); flex: 1; }
.btn.primary { background: var(--accent); color: #0b2a19; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: none; color: var(--muted); font-weight: 500; }
.btn:disabled { opacity: .5; }
.empty { color: var(--dim); text-align: center; padding: 40px 20px; }

/* ---------- Rezept-Detail ---------- */
.detail { padding: 0 16px 24px; overflow-y: auto; flex: 1; }
.detail h2 { font-size: 24px; margin: 4px 0 10px; letter-spacing: -.02em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.chips span { background: var(--card); border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.chips span b { font-weight: 700; }
.stepper { display: inline-flex; align-items: center; background: var(--card); border-radius: 12px; }
.stepper button { width: 40px; height: 38px; display: grid; place-items: center; color: var(--muted); }
.stepper b { min-width: 34px; text-align: center; }
.sect { margin: 16px 0 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.ing { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.ing.done { opacity: .4; text-decoration: line-through; }
.ing .amt { color: var(--muted); min-width: 64px; font-variant-numeric: tabular-nums; }
.step { display: flex; gap: 10px; padding: 8px 0; }
.step b { color: var(--accent); min-width: 20px; }
.actions { display: flex; gap: 10px; margin-top: 18px; }

/* ---------- Sheets ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; z-index: 20; }
.sheet { background: var(--card); width: 100%; border-radius: 22px 22px 0 0; padding: 10px 16px calc(var(--sab) + 16px); max-height: 88dvh; display: flex; flex-direction: column; animation: up .22s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--dim); margin: 0 auto 10px; }
.sheet h3 { margin: 4px 0 12px; font-size: 18px; }
.sheet .body { overflow-y: auto; flex: 1; min-height: 0; padding-right: 12px; scrollbar-gutter: stable; }
.sheet .foot { display: flex; gap: 10px; margin-top: 14px; }
.sheet textarea { width: 100%; min-height: 110px; background: var(--card2); border: 0; border-radius: 12px; padding: 12px; outline: 0; resize: none; }
.sheet pre { white-space: pre-wrap; font: inherit; background: var(--card2); border-radius: 12px; padding: 12px; margin: 0; }
.entry { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.entry .main { flex: 1; min-width: 0; }
.entry .n { font-weight: 600; }
.entry .m { font-size: 12px; color: var(--muted); }
.entry .k { font-weight: 700; }
.opt { display: flex; align-items: center; gap: 12px; padding: 14px 4px; border-bottom: 1px solid var(--line); font-weight: 600; }
.opt:active { opacity: .6; }

/* Felder: Beschriftung im Feld, schwebt nach oben */
.field { position: relative; display: block; margin: 8px 0; }
.field input { width: 100%; background: var(--card2); border: 0; border-radius: 12px; padding: 20px 14px 7px; outline: 0; font-size: 16px; }
.field span { position: absolute; left: 14px; top: 14px; color: var(--dim); font-size: 15px; pointer-events: none; transition: .15s; }
.field input:focus + span, .field input:not(:placeholder-shown) + span { top: 6px; font-size: 11px; color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }

/* ---------- Kalender ---------- */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .d { aspect-ratio: 1; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 14px; background: var(--card2); }
.cal .d.off { opacity: .25; background: none; }
.cal .d.sel { outline: 2px solid var(--accent); }
.cal .d.today { color: var(--accent); font-weight: 700; }
.cal .d small { font-size: 9px; color: var(--muted); }
.cal .d.ok small { color: var(--accent); } .cal .d.over small { color: var(--danger); }
.cal .wd { text-align: center; font-size: 11px; color: var(--dim); padding: 4px 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; font-weight: 700; }

/* ---------- Login ---------- */
.login { position: fixed; inset: 0; background: var(--bg); display: grid; place-items: center; z-index: 50; padding: 20px; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.logo { width: 64px; height: 64px; border-radius: 50%; border: 6px solid var(--accent); margin: 0 auto 18px; display: grid; place-items: center; }
.logo span { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); }
.err { color: var(--danger); font-size: 13px; min-height: 18px; text-align: center; }
.spin { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: rot .8s linear infinite; margin: 20px auto; }
@keyframes rot { to { transform: rotate(360deg) } }
.toast { position: fixed; left: 50%; bottom: calc(var(--sab) + 90px); transform: translateX(-50%); background: var(--card2); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 60; box-shadow: 0 6px 20px rgba(0,0,0,.4); }
