/* Koch-App Web – Design: frisch & modern, Grün (wie die iPhone-App) */

:root {
  --accent: #22A06B;
  --accent-soft: rgba(34, 160, 107, 0.12);
  --bg: #F2F2F7;
  --card: #FFFFFF;
  --text: #1C1C1E;
  --secondary: #8A8A8E;
  --separator: rgba(60, 60, 67, 0.14);
  --fill: rgba(120, 120, 128, 0.12);
  --danger: #E5484D;
  --warning: #F08C00;
  --pink: #E64980;
  --star: #FAB005;
  --radius: 18px;
  --shadow: 0 3px 10px rgba(0, 0, 0, 0.06);
  --tabbar-h: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #4CCB85;
    --accent-soft: rgba(76, 203, 133, 0.16);
    --bg: #000000;
    --card: #1C1C1E;
    --text: #F2F2F7;
    --secondary: #98989F;
    --separator: rgba(84, 84, 88, 0.6);
    --fill: rgba(120, 120, 128, 0.24);
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 17px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }

#view {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--safe-top) + 8px) 16px calc(var(--tabbar-h) + var(--safe-bottom) + 24px);
  min-height: 100vh;
}

/* ---------- Kopfzeile ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 44px; gap: 8px; }
.topbar .actions { display: flex; gap: 4px; align-items: center; }
.large-title { font-size: 34px; font-weight: 800; letter-spacing: -0.5px; margin: 4px 0 12px; }
.back-btn { display: inline-flex; align-items: center; gap: 2px; color: var(--accent); background: none; border: 0; padding: 8px 4px; font-size: 17px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 20px; border: 0;
  background: none; color: var(--accent);
}
.icon-btn:active { background: var(--fill); }
.icon-btn.pink { color: var(--pink); }
.icon-btn svg, .btn svg, .row svg, .pill svg, .tab svg, .link-btn svg { flex-shrink: 0; }

/* ---------- Tab-Leiste ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 0; background: none; color: var(--secondary); font-size: 10.5px; font-weight: 600;
}
.tab.active { color: var(--accent); }

/* ---------- Gruppen / Zeilen (wie iOS-Listen) ---------- */
.section { margin: 18px 0; }
.section-header { font-size: 13px; text-transform: uppercase; letter-spacing: 0.3px; color: var(--secondary); margin: 0 16px 6px; display: flex; align-items: center; gap: 6px; }
.section-footer { font-size: 13px; color: var(--secondary); margin: 6px 16px 0; }
.group { background: var(--card); border-radius: 12px; overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 46px;
  padding: 10px 16px; position: relative; width: 100%;
  background: none; border: 0; text-align: left;
}
.group > .row + .row::before, .group > .row + .stack::before, .group > .stack + .row::before, .group > .stack + .stack::before {
  content: ""; position: absolute; top: 0; left: 16px; right: 0; height: 0.5px; background: var(--separator);
}
.stack { position: relative; padding: 10px 16px; }
.row .grow, .grow { flex: 1; min-width: 0; }
.row .trail { color: var(--secondary); text-align: right; }
button.row:active, .row.tappable:active { background: var(--fill); }
.row.accent { color: var(--accent); }
.row.danger { color: var(--danger); }
.caption { font-size: 13px; color: var(--secondary); }
.small { font-size: 15px; }
.bold { font-weight: 700; }
.muted { color: var(--secondary); }
.strike { text-decoration: line-through; color: var(--secondary); }
.accent-text { color: var(--accent); }
.warn-text { color: var(--warning); }
.danger-text { color: var(--danger); }

/* ---------- Eingaben ---------- */
.input, .textarea, .select {
  width: 100%; border: 0; outline: none; background: transparent; padding: 0; min-height: 26px;
}
.textarea { resize: none; overflow: hidden; display: block; }
.input::placeholder, .textarea::placeholder { color: var(--secondary); }
.field-row { display: flex; gap: 10px; align-items: center; }
.field-row .amount { width: 92px; flex-shrink: 0; }
.select { appearance: none; -webkit-appearance: none; color: var(--accent); text-align: right; text-align-last: right; cursor: pointer; }
.search {
  display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 10px; padding: 8px 10px; margin-bottom: 12px; color: var(--secondary);
}
.search input { border: 0; outline: none; background: transparent; flex: 1; color: var(--text); }

/* Stepper */
.stepper { display: inline-flex; border-radius: 9px; background: var(--fill); overflow: hidden; }
.stepper button { width: 46px; height: 32px; border: 0; background: none; font-size: 20px; color: var(--text); }
.stepper button + button { border-left: 0.5px solid var(--separator); }
.stepper button:disabled { color: var(--secondary); opacity: 0.5; }

/* Schalter */
.switch { position: relative; width: 51px; height: 31px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: var(--fill); border-radius: 31px; transition: background 0.2s; }
.switch span::after { content: ""; position: absolute; width: 27px; height: 27px; left: 2px; top: 2px; background: #fff; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.2); transition: transform 0.2s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(20px); }

/* Segmente */
.segmented { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; width: 100%; }
.segmented button { flex: 1; border: 0; background: none; padding: 6px 4px; border-radius: 7px; font-size: 14px; font-weight: 600; }
.segmented button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0,0,0,0.15); }

/* Auswahl-Kreise */
.check { width: 24px; height: 24px; flex-shrink: 0; color: var(--secondary); }
.check.on { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%;
  border: 0; border-radius: 14px; padding: 14px 16px; font-weight: 700; font-size: 17px;
  background: var(--accent); color: #fff;
}
.btn:active { filter: brightness(0.92); }
.btn:disabled { opacity: 0.45; }
.btn.secondary { background: var(--accent-soft); color: var(--accent); }
.btn.plain { background: none; color: var(--accent); font-weight: 600; }
.btn.danger { background: none; color: var(--danger); font-weight: 600; }
.link-btn { border: 0; background: none; color: var(--accent); padding: 4px 0; display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.btn-row { display: flex; justify-content: space-between; gap: 8px; }

/* ---------- Karten ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px;
  border: 0; width: 100%; text-align: left;
}
.card:active { transform: scale(0.99); }
.card-title { font-size: 17px; font-weight: 700; margin: 0 0 8px; display: flex; gap: 6px; align-items: baseline; justify-content: space-between; }
.recipe-icon { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; flex-shrink: 0; }
.pills, .chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 8px; border-radius: 999px; background: var(--fill); color: var(--secondary); font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; font-weight: 700; border: 0; white-space: nowrap; }
.chip.on { background: var(--accent); color: #fff; }
.stars { display: inline-flex; gap: 1px; color: var(--star); font-size: 12px; }
.stars .off { color: var(--secondary); opacity: 0.4; }
.rating { display: inline-flex; gap: 6px; }
.rating button { border: 0; background: none; padding: 2px; color: var(--secondary); font-size: 24px; line-height: 1; }
.rating button.on { color: var(--star); }

/* Kopfbereich Detail */
.hero { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.hero h1 { font-size: 24px; margin: 0 0 4px; }
.hero .summary { color: var(--secondary); font-size: 15px; margin: 0; }

/* Nährwerte */
.nutri-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 8px; padding: 6px 0; text-align: center; }
.nutri-grid .v { font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.nutri-grid .u { font-size: 11px; color: var(--secondary); margin-left: 2px; }
.nutri-grid .l { font-size: 11px; color: var(--secondary); }
.compare { width: 100%; border-collapse: collapse; font-size: 15px; }
.compare td, .compare th { padding: 5px 4px; text-align: right; font-variant-numeric: tabular-nums; }
.compare td:first-child, .compare th:first-child { text-align: left; }
.compare th { font-size: 12px; color: var(--secondary); font-weight: 600; }
.delta-good { color: var(--accent); font-weight: 800; }
.delta-bad { color: var(--warning); font-weight: 800; }

/* Warnbox */
.warnbox { color: var(--warning); font-size: 15px; display: flex; flex-direction: column; gap: 6px; }
.warnbox .caption { color: var(--secondary); }

/* Leerer Zustand */
.empty { text-align: center; padding: 48px 24px; color: var(--secondary); }
.empty .emoji { font-size: 56px; }
.empty h2 { color: var(--text); margin: 10px 0 6px; font-size: 22px; }
.empty .btn { width: auto; display: inline-flex; margin-top: 16px; padding: 12px 20px; }

/* ---------- Sheets (Fenster von unten) ---------- */
#sheets .sheet-backdrop {
  position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,0.35);
  animation: fade 0.2s ease;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  top: calc(var(--safe-top) + 12px);
  max-width: 720px; margin: 0 auto;
  background: var(--bg); border-radius: 14px 14px 0 0;
  display: flex; flex-direction: column;
  animation: slideup 0.28s cubic-bezier(.2,.8,.2,1);
}
.sheet.full { top: 0; border-radius: 0; }
.sheet-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 10px 12px; border-bottom: 0.5px solid var(--separator); min-height: 52px;
}
.sheet-head .title { font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 46vw; padding: 0 6px; }
.sheet-head .left { justify-self: start; }
.sheet-head .right { justify-self: end; }
.sheet-head button { border: 0; background: none; color: var(--accent); font-size: 17px; padding: 6px 4px; white-space: nowrap; }
.sheet-head .right button { font-weight: 700; }
.sheet-head button:disabled { color: var(--secondary); opacity: 0.6; }
.sheet-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px calc(var(--safe-bottom) + 32px); }
.sheet-closing { animation: slidedown 0.22s ease forwards; }

/* Aktionsmenü */
.action-sheet { position: fixed; left: 8px; right: 8px; bottom: calc(var(--safe-bottom) + 8px); z-index: 61; max-width: 560px; margin: 0 auto; animation: slideup 0.22s ease; }
.action-sheet .group { margin-bottom: 8px; border-radius: 14px; }
.action-sheet .row { justify-content: center; color: var(--accent); font-size: 18px; min-height: 56px; }
.action-sheet .row.danger { color: var(--danger); }
.action-sheet .row.cancel { font-weight: 700; }
.action-sheet .head { text-align: center; padding: 12px 16px; font-size: 13px; color: var(--secondary); }
.action-backdrop { position: fixed; inset: 0; z-index: 60; background: rgba(0,0,0,0.35); animation: fade 0.2s ease; }

/* Hinweis unten */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: rgba(30,30,30,0.92); color: #fff; padding: 10px 16px; border-radius: 14px; font-size: 15px;
  max-width: calc(100vw - 32px); transition: opacity 0.25s, transform 0.25s; text-align: center;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Ladeanzeige */
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,0.4); border-top-color: #fff; border-radius: 50%; animation: spin 0.8s linear infinite; }
.btn.secondary .spinner, .spinner.dark { border-color: var(--fill); border-top-color: var(--accent); }

/* Einführung */
.onboarding { position: fixed; inset: 0; z-index: 70; background: var(--bg); display: flex; flex-direction: column; }
.onboarding .ob-head { display: flex; justify-content: space-between; align-items: center; padding: calc(var(--safe-top) + 8px) 12px 6px; min-height: 52px; }
.onboarding .ob-head button { border: 0; background: none; color: var(--accent); font-size: 17px; padding: 6px; }
.onboarding .ob-title { font-weight: 700; }
.onboarding .ob-body { flex: 1; overflow-y: auto; padding: 4px 16px 16px; max-width: 720px; width: 100%; margin: 0 auto; }
.onboarding .ob-foot { padding: 12px 16px calc(var(--safe-bottom) + 12px); background: var(--card); border-top: 0.5px solid var(--separator); }
.progress { height: 4px; background: var(--fill); border-radius: 2px; margin-bottom: 12px; overflow: hidden; }
.progress div { height: 100%; background: var(--accent); transition: width 0.25s; }
.welcome { text-align: center; padding: 48px 16px 16px; }
.welcome .logo { width: 96px; height: 96px; border-radius: 22px; box-shadow: var(--shadow); }
.welcome h1 { font-size: 26px; margin: 18px 0 8px; }
.welcome p { color: var(--secondary); }

@keyframes slideup { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slidedown { from { transform: translateY(0); } to { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 760px) {
  .sheet { top: 40px; bottom: 40px; border-radius: 14px; }
}
