/* =========================================================
   Frischfach – Apple Human Interface inspiriertes Design
   ========================================================= */

:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --card-2: #f2f2f7;
  --label: #000000;
  --label-2: rgba(60, 60, 67, 0.6);
  --label-3: rgba(60, 60, 67, 0.3);
  --sep: rgba(60, 60, 67, 0.18);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-2: rgba(120, 120, 128, 0.2);
  --bar: rgba(249, 249, 249, 0.78);
  --blue: #007aff;
  --green: #34c759;
  --orange: #ff9500;
  --red: #ff3b30;
  --purple: #af52de;
  --indigo: #5856d6;
  --teal: #30b0c7;
  --gray: #8e8e93;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --card-2: #2c2c2e;
    --label: #ffffff;
    --label-2: rgba(235, 235, 245, 0.6);
    --label-3: rgba(235, 235, 245, 0.3);
    --sep: rgba(84, 84, 88, 0.55);
    --fill: rgba(120, 120, 128, 0.24);
    --fill-2: rgba(120, 120, 128, 0.36);
    --bar: rgba(22, 22, 24, 0.78);
    --blue: #0a84ff;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --purple: #bf5af2;
    --indigo: #5e5ce6;
    --shadow: none;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* App-Gerüst wie bei nativen Apps: Die Seite selbst steht still, nur #view scrollt.
   So bleiben Tab-Leiste und Navigationsleiste fest, die Browserleisten springen nicht
   und der Gummiband-Effekt zieht nicht die ganze App mit. */
html { -webkit-text-size-adjust: 100%; height: 100%; overflow: hidden; touch-action: manipulation; }
body {
  position: fixed;
  inset: 0;
  overflow: hidden;
  margin: 0;
  background: var(--bg);
  color: var(--label);
  font: 17px/1.35 -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Inter', system-ui, 'Segoe UI', Roboto, sans-serif;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}
button, input, select { font: inherit; color: inherit; }
/* iOS zoomt bei Eingabefeldern unter 16 px automatisch hinein – das verhindern */
input, select, textarea { font-size: max(16px, 1em); }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:disabled { opacity: 0.4; cursor: default; }
svg { display: block; }
h1, h2, h3, p { margin: 0; }

.muted { color: var(--label-2); }
.small { font-size: 13px; }
.center { text-align: center; }
.pad { padding: 24px; }
.destructive-text { color: var(--red) !important; }

#view {
  /* seitlicher Abstand: 16 px am Handy, auf großen Bildschirmen mittig mit max. 680 px Inhalt */
  --pad: max(16px, calc((100vw - 648px) / 2));
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain; /* Scrollen endet hier, nichts dahinter bewegt sich */
  -webkit-overflow-scrolling: touch;
  padding: var(--safe-top) var(--pad) 0;
  animation: fade-in 0.35s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } }
.bottom-space { height: calc(110px + var(--safe-bottom)); }

/* ---------- Navigation ---------- */
.nav-bar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: 0 calc(-1 * var(--pad));
  padding-top: var(--safe-top);
  margin-top: calc(-1 * var(--safe-top));
  transition: background 0.2s, box-shadow 0.2s;
}
.nav-inner { height: 44px; display: flex; align-items: center; justify-content: center; position: relative; padding: 0 var(--pad); }
.nav-small-title { font-weight: 600; opacity: 0; transition: opacity 0.2s; }
.nav-trailing { position: absolute; right: calc(var(--pad) - 4px); top: 0; height: 44px; display: flex; align-items: center; gap: 6px; }
.nav-bar.scrolled { background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px); box-shadow: 0 0.5px 0 var(--sep); }
.nav-bar.scrolled .nav-small-title { opacity: 1; }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: 0.01em; line-height: 1.15; margin: 2px 0 2px; }
.subtitle { color: var(--label-2); font-size: 15px; margin-bottom: 18px; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: var(--blue); background: var(--fill); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- Tab Bar ---------- */
.tabbar {
  will-change: transform;
  position: fixed;
  left: 50%;
  bottom: calc(10px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border-radius: 999px;
  background: var(--bar);
  -webkit-backdrop-filter: saturate(180%) blur(24px);
  backdrop-filter: saturate(180%) blur(24px);
  box-shadow: 0 0 0 0.5px var(--sep), 0 10px 30px rgba(0, 0, 0, 0.12);
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 66px;
  padding: 6px 8px 5px;
  border-radius: 999px;
  color: var(--label-2);
  font-size: 10px;
  font-weight: 600;
  transition: color 0.2s, background 0.2s;
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--blue); background: var(--fill); }
.tab-add {
  width: 52px;
  height: 52px;
  margin: 0 6px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--blue);
  color: #fff;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--blue) 45%, transparent);
  transition: transform 0.2s var(--ease);
}
.tab-add svg { width: 26px; height: 26px; stroke-width: 2.6; }
.tab-add:active { transform: scale(0.9); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  font-weight: 600;
  transition: transform 0.15s var(--ease), opacity 0.15s, background 0.2s;
}
.btn:active:not(:disabled) { transform: scale(0.97); opacity: 0.85; }
.btn svg { width: 20px; height: 20px; }
.btn-block { width: 100%; }
.btn-large { min-height: 52px; border-radius: 14px; font-size: 17px; }
.btn-small { min-height: 32px; padding: 6px 14px; border-radius: 999px; font-size: 15px; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-green { background: var(--green); color: #fff; }
.btn-gray { background: var(--fill); color: var(--label); }
.btn-tinted { background: color-mix(in srgb, var(--blue) 14%, transparent); color: var(--blue); }
.btn-plain { color: var(--blue); font-weight: 500; }
.btn-glass { background: rgba(255, 255, 255, 0.25); color: #fff; -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); border-radius: 999px; min-height: 38px; padding: 8px 16px; font-size: 15px; }
.btn-text { color: var(--blue); font-size: 17px; min-width: 70px; text-align: left; }
.btn-text:last-child { text-align: right; }
.btn-text.bold { font-weight: 600; }
.chev { font-size: 20px; line-height: 1; opacity: 0.6; }

/* ---------- Karten ---------- */
.card { background: var(--card); border-radius: 18px; padding: 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.section-title { font-size: 22px; font-weight: 700; margin: 26px 0 12px; }

.hero {
  position: relative;
  overflow: hidden;
  border-radius: 22px;
  padding: 22px 20px 20px;
  color: #fff;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
}
.hero::after { content: ''; position: absolute; right: -40px; top: -40px; width: 180px; height: 180px; border-radius: 50%; background: rgba(255, 255, 255, 0.14); }
.hero h2 { font-size: 24px; font-weight: 700; line-height: 1.15; position: relative; z-index: 1; }
.hero p { opacity: 0.9; margin-top: 6px; font-size: 15px; position: relative; z-index: 1; }
.hero .btn { position: relative; z-index: 1; }
.hero-green { background: linear-gradient(135deg, #34c759, #30b0c7); }
.hero-orange { background: linear-gradient(135deg, #ff9f0a, #ff6b3d); }
.hero-red { background: linear-gradient(135deg, #ff453a, #d63384); }

.eat-card { padding: 16px 16px 12px; }
.eat-label { font-weight: 600; display: block; margin-bottom: 10px; }
.eat-form { display: flex; align-items: center; gap: 8px; background: var(--fill); border-radius: 999px; padding: 4px 4px 4px 16px; }
.eat-input { flex: 1; min-width: 0; border: 0; background: none; outline: none; height: 36px; font-size: 16px; }
.eat-input::placeholder { color: var(--label-3); }
.mic-btn, .send-btn { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; }
.mic-btn { color: var(--label-2); }
.mic-btn svg { width: 20px; height: 20px; }
.mic-btn.listening { color: #fff; background: var(--red); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--red) 25%, transparent); } }
.send-btn { background: var(--blue); color: #fff; }
.send-btn svg { width: 18px; height: 18px; }
.eat-hint { font-size: 13px; color: var(--label-2); margin: 8px 4px 0; }

.notify-card { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; align-items: center; }
.notify-icon { font-size: 28px; grid-row: span 2; }
.notify-text p { font-size: 14px; color: var(--label-2); }
.notify-actions { grid-column: 2; display: flex; gap: 6px; margin-top: 8px; }

/* Bald fällig – horizontales Karussell */
.hscroll { display: flex; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding: 0 var(--pad); overscroll-behavior-x: contain; margin: 0 calc(-1 * var(--pad)); padding: 2px var(--pad) 8px; scrollbar-width: none; }
.hscroll::-webkit-scrollbar { display: none; }
.due-card { scroll-snap-align: start; flex: 0 0 158px; background: var(--card); border-radius: 18px; padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 12px; }
.due-top { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; }
.due-emoji { font-size: 34px; line-height: 1.1; }
.due-name { font-weight: 600; font-size: 15px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.5em; }
.due-when { font-size: 13px; font-weight: 600; }
.due-card.u-expired .due-when, .due-card.u-critical .due-when { color: var(--red); }
.due-card.u-soon .due-when { color: var(--orange); }
.due-actions { display: flex; gap: 6px; margin-top: auto; }
.pill { flex: 1; min-height: 32px; border-radius: 999px; font-size: 14px; font-weight: 600; }
.pill-green { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.pill-gray { flex: 0 0 38px; background: var(--fill); }

.stats-card { display: flex; align-items: center; gap: 18px; }
.stat-ring { position: relative; width: 76px; height: 76px; flex-shrink: 0; }
.stat-ring span { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.stat-ring .ring-bg, .stat-ring .ring-fg { stroke-width: 8; }
.stat-text p + p { margin-top: 2px; font-size: 15px; }

.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tile { background: var(--card); border-radius: 18px; padding: 16px; text-align: left; display: flex; flex-direction: column; gap: 2px; box-shadow: var(--shadow); transition: transform 0.15s var(--ease); }
.tile:active { transform: scale(0.97); }
.tile-icon, .f-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: #fff; margin-bottom: 10px; }
.tile-icon svg, .f-icon svg { width: 22px; height: 22px; }
.tile-title { font-weight: 600; }
.tile-sub { font-size: 13px; color: var(--label-2); }
.t-purple { background: linear-gradient(135deg, #bf5af2, #8e44ff); }
.t-blue { background: linear-gradient(135deg, #0a84ff, #5e5ce6); }
.t-orange { background: linear-gradient(135deg, #ff9f0a, #ff6b3d); }
.t-green { background: linear-gradient(135deg, #30d158, #30b0c7); }

.empty-hero { text-align: center; padding: 28px 12px 26px; }
.empty-emoji { font-size: 72px; margin-bottom: 10px; animation: float 4s ease-in-out infinite; }
.empty-emoji.small { font-size: 44px; animation: none; }
@keyframes float { 50% { transform: translateY(-6px); } }
.empty-hero h2 { font-size: 22px; margin-bottom: 6px; }

/* ---------- Ringe & Dringlichkeit ---------- */
.ring { flex-shrink: 0; }
.ring-bg { fill: none; stroke: var(--fill-2); stroke-width: 4; }
.ring-fg { fill: none; stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset 0.6s var(--ease); }
.ring.u-fresh .ring-fg { stroke: var(--green); }
.ring.u-soon .ring-fg { stroke: var(--orange); }
.ring.u-critical .ring-fg, .ring.u-expired .ring-fg { stroke: var(--red); }
.when.u-fresh { color: var(--label-2); }
.when.u-soon { color: var(--orange); font-weight: 600; }
.when.u-critical, .when.u-expired { color: var(--red); font-weight: 600; }

/* ---------- Suche & Segmented Control ---------- */
.search { display: flex; align-items: center; gap: 6px; background: var(--fill); border-radius: 11px; padding: 0 10px; height: 38px; margin: 6px 0 12px; color: var(--label-2); }
.search svg { width: 17px; height: 17px; flex-shrink: 0; }
.search input { flex: 1; border: 0; background: none; outline: none; font-size: 17px; color: var(--label); min-width: 0; }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }

.segmented { display: flex; background: var(--fill); border-radius: 9px; padding: 2px; gap: 2px; }
.seg { flex: 1; padding: 6px 4px; border-radius: 7px; font-size: 13px; font-weight: 500; white-space: nowrap; transition: background 0.2s, box-shadow 0.2s; }
.seg small { color: var(--label-2); font-size: 11px; }
.seg.active { background: var(--card); box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 0 0 0.5px rgba(0, 0, 0, 0.04); font-weight: 600; }
@media (prefers-color-scheme: dark) { .seg.active { background: #636366; } }

/* ---------- Listen (Inset Grouped) ---------- */
.list-header { font-size: 13px; font-weight: 400; text-transform: uppercase; color: var(--label-2); margin: 24px 16px 7px; letter-spacing: 0.02em; }
.list-footer { font-size: 13px; color: var(--label-2); margin: 7px 16px 0; line-height: 1.4; }
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 12px; overflow: hidden; }

.cell { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 16px; position: relative; }
.cell + .cell::before, .swipe-row + .swipe-row::before { content: ''; position: absolute; top: 0; right: 0; left: 58px; height: 0.5px; background: var(--sep); z-index: 2; }
.list > .cell:not(:has(.cell-icon)) + .cell::before { left: 16px; }
.cell-label { flex: 1; }
.cell-link { cursor: pointer; }
.cell-link:active { background: var(--fill); }
.cell-icon { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-size: 16px; flex-shrink: 0; }
.ci-red { background: color-mix(in srgb, var(--red) 18%, transparent); }
.ci-orange { background: color-mix(in srgb, var(--orange) 18%, transparent); }
.ci-blue { background: color-mix(in srgb, var(--blue) 18%, transparent); }
.ci-green { background: color-mix(in srgb, var(--green) 18%, transparent); }
.ci-purple { background: color-mix(in srgb, var(--purple) 18%, transparent); }
.ci-gray { background: var(--fill); }
.cell-input input { flex: 1; border: 0; background: none; outline: none; font-size: 16px; min-width: 0; height: 32px; }
.cell-select { border: 0; background: none; color: var(--label-2); font-size: 16px; text-align: right; outline: none; max-width: 60%; }
.cell-date { border: 0; background: var(--fill); border-radius: 8px; padding: 5px 9px; font-size: 16px; outline: none; color: var(--label); }

/* Stepper */
.stepper { display: flex; align-items: center; background: var(--fill); border-radius: 9px; overflow: hidden; }
.stepper button { width: 40px; height: 32px; font-size: 20px; font-weight: 500; }
.stepper button:active { background: var(--fill-2); }
.stepper span { min-width: 64px; text-align: center; font-size: 15px; font-variant-numeric: tabular-nums; }

/* Switch */
.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-2); border-radius: 999px; transition: background 0.25s; }
.switch span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 1px 1px rgba(0, 0, 0, 0.16); transition: transform 0.25s var(--ease); }
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:disabled + span { opacity: 0.4; }

/* ---------- Vorrats-Zeilen mit Wischen ---------- */
.swipe-row { position: relative; overflow: hidden; }
.swipe-actions { position: absolute; inset: 0; display: flex; justify-content: flex-end; visibility: hidden; }
.swipe-row.dragging .swipe-actions, .swipe-row.open .swipe-actions, .swipe-row.removing .swipe-actions { visibility: visible; }
.sa { width: 76px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: #fff; font-size: 12px; font-weight: 500; }
.sa svg { width: 22px; height: 22px; }
.sa-used { background: var(--green); }
.sa-waste { background: var(--red); }
.swipe-row.full .sa-used { width: 100%; transition: width 0.15s; }
.swipe-row.full .sa-waste { display: none; }
.row-content {
  position: relative;
  z-index: 1;
  background: var(--card);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  min-height: 60px;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
  transition: transform 0.35s var(--ease);
}
.row-content:active { background: color-mix(in srgb, var(--card) 92%, var(--label)); }
.swipe-row.removing { animation: collapse 0.3s 0.15s var(--ease) forwards; }
@keyframes collapse { to { height: 0; min-height: 0; opacity: 0; } }
.row-emoji { font-size: 28px; width: 32px; text-align: center; flex-shrink: 0; }
.row-emoji.small { font-size: 22px; width: 26px; }
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 14px; color: var(--label-2); margin-top: 1px; }
.qty { color: var(--label-2); font-weight: 500; font-size: 0.9em; }
.tag { font-size: 11px; font-weight: 600; text-transform: uppercase; background: var(--fill); color: var(--label-2); padding: 1px 6px; border-radius: 5px; vertical-align: 2px; }
.empty-list { text-align: center; padding: 48px 16px; color: var(--label-2); display: flex; flex-direction: column; align-items: center; gap: 12px; }

/* ---------- Chips ---------- */
.chips-wrap { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.chip, .chip-static { display: inline-flex; align-items: center; gap: 4px; padding: 5px 11px; border-radius: 999px; background: var(--fill); font-size: 14px; font-weight: 500; white-space: nowrap; position: relative; }
.chip { cursor: pointer; transition: transform 0.15s var(--ease); }
.chip:active { transform: scale(0.95); }
.chip small { color: var(--label-2); font-weight: 400; }
.chip-static.u-critical, .chip-static.u-expired { background: color-mix(in srgb, var(--red) 15%, transparent); }
.chip-static.u-soon { background: color-mix(in srgb, var(--orange) 15%, transparent); }
.chip-extra { background: none; box-shadow: inset 0 0 0 1px var(--sep); color: var(--label-2); }
.chip-ai { color: var(--purple); background: color-mix(in srgb, var(--purple) 12%, transparent); }
.date-chip.u-critical, .date-chip.u-expired { color: var(--red); }
.date-chip.u-soon { color: var(--orange); }
.date-chip input { position: absolute; inset: 0; opacity: 0; width: 100%; cursor: pointer; }
.chips-wrap.quick { margin: 12px 0 4px; }

/* ---------- Sheets ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.4); opacity: 0; transition: opacity 0.35s var(--ease); z-index: 50; }
.sheet-backdrop.open { opacity: 1; }
.sheet {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 680px;
  max-height: calc(100dvh - var(--safe-top) - 12px);
  background: var(--bg);
  border-radius: 14px 14px 0 0;
  z-index: 51;
  transform: translateY(100%);
  transition: transform 0.45s var(--ease);
  display: flex;
  flex-direction: column;
  padding-bottom: var(--safe-bottom);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.15);
}
@media (prefers-color-scheme: dark) { .sheet { background: #1c1c1e; } .sheet .list, .sheet .cand { background: #2c2c2e; } }
.sheet.open { transform: translateY(0); }
.sheet-tall { height: calc(100dvh - var(--safe-top) - 12px); }
.sheet-grabber { width: 36px; height: 5px; border-radius: 3px; background: var(--label-3); margin: 6px auto 0; flex-shrink: 0; cursor: grab; touch-action: none; }
.sheet-header { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 10px; flex-shrink: 0; touch-action: none; }
.sheet-title { font-size: 17px; font-weight: 600; text-align: center; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0 8px; }
.sheet-body { padding: 8px 16px 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.sheet-body.center { text-align: center; display: flex; flex-direction: column; gap: 12px; padding: 20px 24px 24px; }
.sheet-body h2 { font-size: 22px; }
.sheet-footer { padding: 10px 16px 14px; flex-shrink: 0; border-top: 0.5px solid var(--sep); background: inherit; }
.hero-emoji { font-size: 56px; }
.text-field { width: 100%; height: 48px; border: 0; border-radius: 12px; background: var(--card); padding: 0 16px; font-size: 17px; outline: none; box-shadow: var(--shadow); }
@media (prefers-color-scheme: dark) { .text-field { background: #2c2c2e; } }

/* Action Sheet */
.sheet-clear { background: transparent !important; box-shadow: none; padding: 0 8px calc(8px + var(--safe-bottom)); }
.sheet-clear .sheet-grabber { display: none; }
.action-sheet { display: flex; flex-direction: column; gap: 8px; }
.action-group { background: var(--bar); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); border-radius: 14px; overflow: hidden; }
.action-title { text-align: center; font-size: 13px; color: var(--label-2); padding: 14px 16px; border-bottom: 0.5px solid var(--sep); }
.action-btn { width: 100%; min-height: 57px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 20px; color: var(--blue); }
.action-btn + .action-btn { border-top: 0.5px solid var(--sep); }
.action-btn:active { background: var(--fill); }
.action-btn.destructive { color: var(--red); }
.action-btn.cancel { background: var(--card); border-radius: 14px; font-weight: 600; }
@media (prefers-color-scheme: dark) { .action-btn.cancel { background: #2c2c2e; } }
.action-icon { width: 28px; text-align: center; }

/* Kandidaten (Prüf-Sheet) */
.cands { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.cand { display: flex; gap: 12px; align-items: flex-start; background: var(--card); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); animation: pop-in 0.3s var(--ease); }
@keyframes pop-in { from { opacity: 0; transform: scale(0.96); } }
.cand-emoji { font-size: 30px; line-height: 1.2; }
.cand-main { flex: 1; min-width: 0; }
.cand-name { width: 100%; border: 0; background: none; font-weight: 600; font-size: 17px; outline: none; padding: 2px 0; border-bottom: 1px solid transparent; }
.cand-name:focus { border-bottom-color: var(--blue); }
.cand-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cand-meta .chip { font-size: 13px; padding: 4px 10px; }
.cand-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.mini-stepper { display: flex; align-items: center; background: var(--fill); border-radius: 8px; }
.mini-stepper button { width: 28px; height: 28px; font-size: 17px; }
.mini-stepper span { min-width: 18px; text-align: center; font-size: 14px; font-weight: 600; }
.cand-remove { width: 26px; height: 26px; border-radius: 50%; background: var(--fill); color: var(--label-2); font-size: 12px; }

/* Produkt-Details */
.detail-head { text-align: center; padding: 6px 0 18px; }
.detail-emoji { font-size: 64px; display: block; }
.detail-name { text-align: center; border: 0; background: none; font-size: 24px; font-weight: 700; width: 100%; outline: none; margin-top: 6px; }
.detail-when { margin-top: 2px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 20px 0 6px; }
.detail-actions .btn-green:only-child, .detail-actions:has(> :nth-child(3)) .btn-green { grid-column: span 2; }

/* Bestätigen-Liste mit Checkboxen */
.check-list { margin-top: 12px; }
.check-cell { cursor: pointer; }
.check-cell::before { left: 56px !important; }
.checkbox { width: 24px; height: 24px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--label-3); display: grid; place-items: center; flex-shrink: 0; transition: background 0.2s; }
.checkbox svg { width: 14px; height: 14px; color: #fff; }
.check-cell.on .checkbox { background: var(--green); box-shadow: none; }

/* ---------- Scanner ---------- */
.sheet-full { height: 100dvh; max-height: none; border-radius: 0; background: #000 !important; padding: 0; }
.sheet-full .sheet-grabber { display: none; }
.scanner { position: relative; flex: 1; overflow: hidden; color: #fff; }
.scan-video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-shade { position: absolute; inset: 0; background: radial-gradient(ellipse 72% 26% at 50% 42%, transparent 98%, rgba(0, 0, 0, 0.55) 100%); pointer-events: none; }
.scan-frame { position: absolute; left: 50%; top: 42%; width: min(78vw, 360px); height: min(40vw, 190px); transform: translate(-50%, -50%); border-radius: 22px; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.9); overflow: hidden; }
.scanner.consume .scan-frame { box-shadow: inset 0 0 0 3px var(--green); }
.scan-line { position: absolute; left: 8%; right: 8%; height: 2px; background: linear-gradient(90deg, transparent, #fff, transparent); animation: scan 2s ease-in-out infinite; }
.scanner.consume .scan-line { background: linear-gradient(90deg, transparent, var(--green), transparent); }
@keyframes scan { 0%, 100% { top: 15%; } 50% { top: 85%; } }
.scan-top { position: absolute; top: calc(12px + var(--safe-top)); left: 12px; right: 12px; display: flex; align-items: center; gap: 10px; }
.scan-top .segmented { flex: 1; max-width: 300px; margin: 0 auto; }
.segmented.glass { background: rgba(120, 120, 128, 0.4); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.segmented.glass .seg { color: #fff; }
.segmented.glass .seg.active { background: rgba(255, 255, 255, 0.92); color: #000; }
.glass-btn { width: 40px; height: 40px; border-radius: 50%; background: rgba(120, 120, 128, 0.4); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); color: #fff; font-size: 17px; flex-shrink: 0; }
.scan-hint { position: absolute; top: calc(42% + min(20vw, 95px) + 24px); left: 24px; right: 24px; text-align: center; font-size: 15px; text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6); }
.scanner.no-camera .scan-hint { top: 40%; }
.scanner.no-camera .scan-frame, .scanner.no-camera .scan-shade { display: none; }
.scan-flash { position: absolute; top: calc(42% - min(20vw, 95px) - 56px); left: 50%; transform: translate(-50%, 10px) scale(0.9); opacity: 0; padding: 8px 16px; border-radius: 999px; font-weight: 600; font-size: 15px; transition: all 0.3s var(--ease); white-space: nowrap; max-width: 86vw; overflow: hidden; text-overflow: ellipsis; }
.scan-flash.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.scan-flash.ok { background: rgba(48, 209, 88, 0.92); }
.scan-flash.warn { background: rgba(255, 159, 10, 0.95); }
.scan-bottom { position: absolute; left: 16px; right: 16px; bottom: calc(18px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 12px; max-width: 520px; margin: 0 auto; }
.scan-tray { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.tray-pill { background: rgba(30, 30, 30, 0.6); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); border-radius: 999px; padding: 6px 12px; font-size: 14px; animation: pop-in 0.3s var(--ease); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Kühlschrank-Check ---------- */
.check-sheet { background: var(--bg) !important; }
@media (prefers-color-scheme: dark) { .check-sheet { background: #000 !important; } }
.check { flex: 1; display: flex; flex-direction: column; padding: calc(8px + var(--safe-top)) 16px 20px; max-width: 520px; width: 100%; margin: 0 auto; }
.check-top { display: flex; justify-content: space-between; align-items: center; height: 44px; }
.check-progress { font-size: 15px; color: var(--label-2); font-variant-numeric: tabular-nums; }
.check-title { font-size: 28px; font-weight: 700; margin: 8px 0 18px; }
.deck { position: relative; flex: 1; min-height: 300px; }
.card-swipe {
  position: absolute;
  inset: 0 0 calc(var(--k) * -10px);
  transform: scale(calc(1 - var(--k) * 0.05)) translateY(calc(var(--k) * 14px));
  background: var(--card);
  border-radius: 26px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12), 0 0 0 0.5px var(--sep);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.35s var(--ease);
  cursor: grab;
}
.card-swipe:not([style*='--k:0']) { pointer-events: none; }
.cs-emoji { font-size: 96px; line-height: 1.1; }
.card-swipe h3 { font-size: 26px; font-weight: 700; }
.card-swipe .when { font-size: 17px; }
.stamp { position: absolute; top: 28px; padding: 6px 12px; border-radius: 10px; font-weight: 800; font-size: 20px; letter-spacing: 0.05em; border: 3px solid; opacity: 0; }
.stamp-used { right: 24px; color: var(--green); transform: rotate(12deg); opacity: var(--used, 0); }
.stamp-keep { left: 24px; color: var(--blue); transform: rotate(-12deg); opacity: var(--keep, 0); }
.check-legend { display: flex; justify-content: space-between; font-size: 13px; color: var(--label-2); margin: 22px 8px 14px; }
.check-buttons { display: flex; justify-content: center; align-items: center; gap: 22px; }
.round-btn { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--card); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.1), 0 0 0 0.5px var(--sep); transition: transform 0.15s var(--ease); }
.round-btn:active { transform: scale(0.9); }
.round-btn svg { width: 28px; height: 28px; }
.rb-waste { width: 52px; height: 52px; color: var(--red); }
.rb-waste svg { width: 22px; height: 22px; }
.rb-used { width: 76px; height: 76px; color: #fff; background: var(--green); }
.rb-used svg { width: 34px; height: 34px; stroke-width: 2.6; }
.rb-keep { color: var(--blue); }
.check-done { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; padding-top: 40px; }

/* ---------- Rezepte ---------- */
.chips-wrap + .btn { margin-top: 4px; }
.recipe { margin-top: 14px; }
.recipe-head { display: flex; gap: 14px; align-items: center; }
.recipe-emoji { font-size: 40px; width: 56px; height: 56px; display: grid; place-items: center; background: var(--fill); border-radius: 14px; flex-shrink: 0; }
.recipe h3 { font-size: 19px; }
.recipe .muted { font-size: 14px; }
.recipe details { margin: 4px 0 12px; }
.recipe summary { color: var(--blue); font-weight: 500; cursor: pointer; padding: 6px 0; list-style: none; }
.recipe summary::-webkit-details-marker { display: none; }
.recipe summary::after { content: ' ›'; display: inline-block; transition: transform 0.2s; }
.recipe details[open] summary::after { transform: rotate(90deg); }
.recipe ol { padding-left: 20px; margin: 4px 0 0; color: var(--label); }
.recipe li { margin: 6px 0; line-height: 1.45; }

/* ---------- Toast & HUD ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  opacity: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 10px 10px 16px;
  min-height: 48px;
  max-width: calc(100vw - 32px);
  border-radius: 999px;
  background: rgba(30, 30, 32, 0.92);
  color: #fff;
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: all 0.35s var(--ease);
  font-size: 15px;
  font-weight: 500;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-msg { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 6px; }
.toast-undo { color: #ffd60a; font-weight: 600; padding: 6px 12px; border-radius: 999px; background: rgba(255, 255, 255, 0.12); white-space: nowrap; }
.sheet ~ .toast { bottom: calc(24px + var(--safe-bottom)); }

.loading-hud { position: fixed; inset: 0; display: grid; place-items: center; z-index: 90; background: rgba(0, 0, 0, 0.15); opacity: 0; transition: opacity 0.25s; }
.loading-hud.show { opacity: 1; }
.hud { background: var(--bar); -webkit-backdrop-filter: blur(30px); backdrop-filter: blur(30px); border-radius: 20px; padding: 26px 26px 20px; display: flex; flex-direction: column; align-items: center; gap: 14px; max-width: 240px; text-align: center; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2); }
.hud p { font-size: 15px; font-weight: 500; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 3px solid var(--fill-2); border-top-color: var(--blue); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Willkommen ---------- */
.welcome { display: flex; flex-direction: column; padding: 30px 28px 28px; }
.welcome h1 { font-size: 34px; font-weight: 800; text-align: center; line-height: 1.15; margin: 14px 0 34px; }
.brand { background: linear-gradient(135deg, #30d158, #0a84ff); -webkit-background-clip: text; background-clip: text; color: transparent; }
.features { list-style: none; padding: 0; margin: 0 0 auto; display: flex; flex-direction: column; gap: 26px; }
.features li { display: flex; gap: 16px; align-items: flex-start; }
.features .f-icon { flex-shrink: 0; width: 46px; height: 46px; margin: 0; }
.features p { color: var(--label-2); font-size: 15px; margin-top: 2px; }
.welcome .btn { margin-top: 32px; }

.about { text-align: center; color: var(--label-3); font-size: 13px; margin-top: 30px; }

@media (min-width: 700px) {
  .tiles { grid-template-columns: repeat(4, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* =========================================================
   Konto & Anmeldung
   ========================================================= */
body.auth-mode .tabbar { display: none; }
.auth { max-width: 420px; margin: 0 auto; padding: 40px 0 calc(40px + var(--safe-bottom)); display: flex; flex-direction: column; }
.auth-hero { text-align: center; margin-bottom: 22px; }
.auth-logo { width: 84px; height: 84px; border-radius: 20px; box-shadow: 0 10px 30px rgba(52, 199, 89, 0.3); margin-bottom: 16px; }
.auth-hero h1 { font-size: 34px; font-weight: 800; letter-spacing: -0.01em; }
.auth-hero p { color: var(--label-2); font-size: 17px; margin-top: 6px; line-height: 1.4; }
.auth-features { list-style: none; padding: 0; margin: 0 0 22px; display: flex; flex-direction: column; gap: 8px; }
.auth-features li { display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 500; background: var(--card); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); }
.auth-features span { font-size: 22px; }
.auth-seg { margin-bottom: 14px; }
.auth-sub { text-align: center; font-size: 22px; margin-bottom: 6px; }
.auth-hint { margin-bottom: 18px; font-size: 15px; }
.auth-form { display: flex; flex-direction: column; gap: 6px; }
.auth-form .list, .sheet .list { margin-bottom: 4px; }
.auth-form .cell-input input, .sheet form .cell-input input { font-size: 17px; height: 36px; }
.pw-toggle { font-size: 16px; opacity: 0.5; padding: 4px; }
.form-error { color: var(--red); font-size: 14px; min-height: 20px; padding: 0 16px; text-align: center; }
.auth-legal { font-size: 12px; color: var(--label-2); text-align: center; margin-top: 14px; line-height: 1.45; padding: 0 8px; }
.auth-legal a, .auth-footer a, .about a { color: var(--label-2); }
.auth-footer { display: flex; justify-content: center; gap: 18px; font-size: 13px; margin-top: 18px; }
.invite-banner { background: color-mix(in srgb, var(--green) 15%, transparent); border-radius: 12px; padding: 12px 14px; font-size: 15px; margin-bottom: 14px; font-weight: 500; }

.profile { display: flex; align-items: center; gap: 14px; margin-top: 8px; }
.avatar { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; background: linear-gradient(135deg, #30d158, #0a84ff); color: #fff; font-weight: 700; font-size: 24px; }
.avatar.small { width: 30px; height: 30px; font-size: 14px; }
.profile-text { flex: 1; min-width: 0; }
.profile-name { border: 0; background: none; font-size: 20px; font-weight: 700; width: 100%; outline: none; padding: 0; }
.profile-text .muted { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
.link-text { color: var(--blue); }
.list.spaced { margin-top: 28px; }
.btn-red { background: var(--red); color: #fff; }
.sheet-note { margin: 0 4px 12px; text-align: center; }
.invite-code { font: 700 28px/1 ui-monospace, 'SF Mono', Menlo, monospace; letter-spacing: 0.18em; background: var(--fill); border-radius: 14px; padding: 18px; margin: 4px 0 6px; user-select: all; }
.about { line-height: 1.8; }
body.has-pending .tab[data-tab='home']::after { content: ''; position: absolute; width: 6px; height: 6px; border-radius: 50%; background: var(--orange); margin-left: 18px; margin-top: -2px; }
.tab { position: relative; }

/* =========================================================
   Produktbilder & Kategorie-Kacheln
   ========================================================= */
.pv { position: relative; display: inline-grid; flex-shrink: 0; border-radius: 22%; overflow: hidden; background: #fff; box-shadow: inset 0 0 0 0.5px rgba(0, 0, 0, 0.08); }
.pv > * { grid-area: 1 / 1; }
.pv img { width: 100%; height: 100%; object-fit: cover; display: block; background: #fff; }
.pv-tile {
  display: grid; place-items: center; width: 100%; height: 100%;
  background: linear-gradient(145deg, hsl(var(--h) 85% 93%), hsl(calc(var(--h) + 25) 70% 84%));
}
@media (prefers-color-scheme: dark) {
  .pv { box-shadow: none; }
  .pv-tile { background: linear-gradient(145deg, hsl(var(--h) 40% 26%), hsl(calc(var(--h) + 25) 35% 18%)); }
}
.pv-xs { width: 22px; height: 22px; font-size: 13px; border-radius: 6px; vertical-align: middle; }
.pv-sm { width: 30px; height: 30px; font-size: 17px; border-radius: 8px; }
.pv-md { width: 44px; height: 44px; font-size: 25px; border-radius: 11px; }
.pv-lg { width: 56px; height: 56px; font-size: 32px; border-radius: 14px; }
.pv-xl { width: 104px; height: 104px; font-size: 58px; border-radius: 26px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); }
.pv-xxl { width: 168px; height: 168px; font-size: 92px; border-radius: 36px; margin-bottom: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12); }
.has-img .pv-tile { font-size: 0; } /* Kachel nur als Platzhalter hinter dem Foto */

.cand-photo { flex-shrink: 0; position: relative; }
.cand-photo::after { content: '📷'; position: absolute; right: -4px; bottom: -4px; font-size: 11px; background: var(--card); border-radius: 50%; width: 20px; height: 20px; display: grid; place-items: center; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); }
.detail-photo { position: relative; display: inline-block; }
.photo-badge { position: absolute; right: -6px; bottom: -6px; width: 32px; height: 32px; border-radius: 50%; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 15px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2); }
.tray-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px 4px 4px; }
.add-tip { font-size: 13px; color: var(--label-2); margin: -6px 2px 12px; }

/* =========================================================
   Mehrfachauswahl im Vorrat
   ========================================================= */
.nav-text-btn { color: var(--blue); font-size: 17px; padding: 0 6px; height: 36px; }
.sel-check {
  width: 0; height: 24px; flex-shrink: 0; margin-right: -12px; border-radius: 50%;
  display: grid; place-items: center; overflow: hidden; opacity: 0;
  box-shadow: inset 0 0 0 1.5px var(--label-3);
  transition: width 0.25s var(--ease), margin 0.25s var(--ease), opacity 0.2s, background 0.15s;
}
.sel-check svg { width: 14px; height: 14px; color: #fff; opacity: 0; }
.select-mode .sel-check { width: 24px; margin-right: 0; opacity: 1; }
.select-mode .row-content { cursor: default; }
.swipe-row.selected .sel-check { background: var(--blue); box-shadow: none; }
.swipe-row.selected .sel-check svg { opacity: 1; }
.swipe-row.selected .row-content { background: color-mix(in srgb, var(--blue) 7%, var(--card)); }
.select-mode .ring { display: none; }

body.selecting .tabbar { transform: translate(-50%, 140%); opacity: 0; pointer-events: none; }
.tabbar { transition: transform 0.35s var(--ease), opacity 0.25s; }

.select-bar {
  position: fixed; left: 50%; bottom: calc(10px + var(--safe-bottom)); z-index: 31;
  width: min(calc(100vw - 20px), 520px);
  transform: translate(-50%, 140%); opacity: 0;
  transition: transform 0.4s var(--ease), opacity 0.25s;
  background: var(--bar); -webkit-backdrop-filter: saturate(180%) blur(24px); backdrop-filter: saturate(180%) blur(24px);
  border-radius: 24px; padding: 6px 8px 8px;
  box-shadow: 0 0 0 0.5px var(--sep), 0 10px 30px rgba(0, 0, 0, 0.16);
}
.select-bar.show { transform: translate(-50%, 0); opacity: 1; }
.select-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 6px; }
.select-top .btn-text { font-size: 16px; min-width: 64px; }
.sel-count { font-size: 15px; font-weight: 600; }
.select-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.select-actions button { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 2px; border-radius: 14px; font-size: 12px; font-weight: 500; transition: background 0.15s, opacity 0.2s; }
.select-actions button:active:not(:disabled) { background: var(--fill); }
.select-actions button:disabled { opacity: 0.35; }
.sa-icon { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; color: #fff; }
.sa-icon svg { width: 19px; height: 19px; }
.sa-green { background: var(--green); }
.sa-red { background: var(--red); }
.sa-blue { background: var(--blue); }
.sa-gray { background: var(--gray); }
body.selecting #view .bottom-space { height: calc(150px + var(--safe-bottom)); }
body.selecting .toast { bottom: calc(140px + var(--safe-bottom)); }
