/* Stockly — Styles. Übernommen aus dem <style>-Block der alten index.html
   (die CSP verbietet <style>-Blöcke); Schrift lokal statt von Google Fonts. */

@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('vendor/inter/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('vendor/inter/inter-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('vendor/inter/inter-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('vendor/inter/inter-latin-700-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('vendor/inter/inter-latin-800-normal.woff2') format('woff2');
}

:root {
  color-scheme: light dark;
  --bg: #f1f1f6;
  --bg-accent-1: #eef0ff;
  --bg-accent-2: #f3ecff;
  --surface: #ffffff;
  --surface-2: #f8f8fc;
  --text: #16162a;
  --muted: #767a8c;
  --border: #e8e8f2;
  --primary: #6b53f5;
  --primary-2: #8b6ef7;
  --primary-dark: #5439e0;
  --primary-soft: #efeaff;
  --danger: #ef4462;
  --ok: #16a06a;
  --warn: #e0912a;
  --radius: 20px;
  --radius-sm: 14px;
  --radius-xs: 10px;
  --shadow: 0 1px 2px rgba(20,20,50,.04), 0 8px 24px -14px rgba(20,20,50,.16);
  --shadow-lg: 0 16px 40px -10px rgba(80,60,220,.28);
  --nav-h: 62px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101018; --bg-accent-1: #16162a; --bg-accent-2: #1c1730;
    --surface: #1a1a28; --surface-2: #20202f; --text: #f2f2f8; --muted: #9a9db0;
    --border: #2c2c3d; --primary-soft: #2a2350;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -12px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important; animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important; scroll-behavior: auto !important;
  }
}
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  margin: 0; padding: 0;
  background:
    radial-gradient(600px 300px at 15% -5%, var(--bg-accent-1), transparent),
    radial-gradient(500px 260px at 100% 0%, var(--bg-accent-2), transparent),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* ---------- App shell ---------- */
.app-bar {
  position: sticky; top: 0; z-index: 8;
  padding: calc(var(--safe-t) + 14px) 16px 12px;
  /* Vor color-mix() eine einfarbige Fallback-Deklaration: Browser ohne
     color-mix() ignorieren nur die zweite Zeile und behalten die erste. */
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 60%, transparent);
}
.app-bar-inner { max-width: 520px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 38px; height: 38px; flex-shrink: 0; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; box-shadow: 0 6px 16px -8px rgba(107,83,245,.9);
}
.brand-mark svg { width: 21px; height: 21px; }
h1 { font-size: 1.15rem; margin: 0; font-weight: 800; letter-spacing: -0.02em; }
.app-bar-sub { margin: 1px 0 0; font-size: .78rem; color: var(--muted); font-weight: 500; }
main { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 28px); }
h3 { font-size: 1rem; margin: 22px 0 10px; font-weight: 700; letter-spacing: -0.01em; }
h3:first-child { margin-top: 4px; }
.section-head { display: flex; align-items: center; gap: 8px; margin: 22px 0 10px; }
.section-head:first-child { margin-top: 2px; }
.section-head h3 { margin: 0; flex: 1; }
.badge {
  font-size: .74rem; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary);
}
.hint { font-size: .8rem; color: var(--muted); margin: 0 0 12px; line-height: 1.45; }

/* ---------- Bottom nav ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 9;
  display: flex; justify-content: center; gap: 2px;
  padding: 6px 8px calc(var(--safe-b) + 6px);
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 84%, transparent);
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  border-top: 1px solid var(--border);
}
.tabbar button {
  flex: 1; max-width: 130px; background: none; border: none; box-shadow: none; padding: 5px 0 3px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: .68rem; font-weight: 600; letter-spacing: .01em;
  border-radius: var(--radius-xs);
}
.tabbar button:hover { transform: none; }
.tabbar button svg { width: 22px; height: 22px; stroke-width: 1.9; }
.tabbar button .nav-icon {
  display: grid; place-items: center; width: 46px; height: 28px; border-radius: 999px;
  transition: background .18s ease, color .18s ease;
}
.tabbar button.active { color: var(--primary); }
.tabbar button.active .nav-icon { background: var(--primary-soft); }
video, canvas { width: 100%; border-radius: var(--radius); background: #000; }
.hidden { display: none !important; }
form { display: flex; flex-direction: column; gap: 10px; margin: 0; }
input, button, select, textarea {
  font-size: .95rem; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  font-family: inherit; transition: border-color .15s, box-shadow .15s, transform .1s;
}
/* Eingabefelder mindestens 16px, sonst zoomt iOS Safari beim Fokussieren
   hinein. Knöpfe betrifft das nicht, sie bleiben bei .95rem. */
input, select, textarea { min-height: 46px; font-size: max(16px, .95rem); }
input::placeholder, textarea::placeholder { color: var(--muted); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.row { display: flex; gap: 8px; }
.row > * { flex: 1; min-width: 0; }
button {
  cursor: pointer; font-weight: 600; border: 1px solid var(--border); min-height: 46px;
  background: var(--surface-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  transition: transform .12s ease, box-shadow .12s ease, opacity .12s ease, background .12s ease;
}
button svg { width: 18px; height: 18px; flex-shrink: 0; }
button:active { transform: scale(.97); opacity: .9; }
.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; border: none; box-shadow: 0 8px 18px -8px rgba(107,83,245,.75);
}
.danger { background: var(--danger); color: #fff; border: none; }
.icon-btn {
  min-height: 0; width: 36px; height: 36px; padding: 0; flex-shrink: 0;
  border-radius: 11px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn.is-danger { color: var(--danger); }
.icon-btn.is-on { color: var(--primary); background: var(--primary-soft); border-color: transparent; }

/* ---------- Cards & tiles ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: 16px; margin-bottom: 12px;
}
.card > h3:first-child { margin-top: 0; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tile {
  flex-direction: column; gap: 8px; padding: 18px 10px; min-height: 96px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); font-size: .85rem; font-weight: 600; text-align: center; line-height: 1.25;
}
.tile .tile-icon {
  width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center;
  background: var(--primary-soft); color: var(--primary);
}
.tile .tile-icon svg { width: 21px; height: 21px; }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; gap: 8px; }
.list-card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); overflow: hidden;
}
.row-item { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.row-item:last-child { border-bottom: none; }
.thumb {
  width: 48px; height: 48px; object-fit: cover; border-radius: var(--radius-xs); flex-shrink: 0;
  background: var(--primary-soft); display: grid; place-items: center; font-size: 1.2rem;
}
.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 600; letter-spacing: -.01em; overflow-wrap: anywhere; }
.row-sub { color: var(--muted); font-size: .82rem; margin-top: 1px; }
.row-meta { font-size: .75rem; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.empty { text-align: center; padding: 34px 20px; color: var(--muted); }
.empty .empty-icon { font-size: 1.9rem; margin-bottom: 8px; }
.empty b { display: block; color: var(--text); font-size: .95rem; margin-bottom: 4px; }
.empty span { font-size: .82rem; line-height: 1.5; }
.search-wrap { position: relative; margin-bottom: 12px; }
.search-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--muted); pointer-events: none;
}
.search-wrap input { width: 100%; padding-left: 40px; }

/* ---------- Kategorie-Chips ---------- */
.chips {
  display: flex; gap: 7px; margin-bottom: 12px; overflow-x: auto;
  padding-bottom: 4px; scrollbar-width: none; -ms-overflow-style: none;
  /* Chips dürfen am Rand nicht abgeschnitten wirken */
  margin-inline: -16px; padding-inline: 16px;
}
.chips::-webkit-scrollbar { display: none; }
.chips:empty { display: none; }
/* im Modal gibt es kein Seiten-Padding, das die Chips überziehen dürften */
.modal .chips { margin-inline: 0; padding-inline: 0; margin-bottom: 0; margin-top: 12px; }
.modal .chips .chip { width: auto; margin-top: 0; }
.chip {
  flex-shrink: 0; min-height: 0; width: auto;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px;
  font-size: .82rem; font-weight: 600; white-space: nowrap;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); box-shadow: none;
}
.chip .chip-count {
  font-size: .72rem; font-weight: 700; color: var(--muted);
}
.chip.is-active {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.chip.is-active .chip-count { color: rgba(255,255,255,.8); }
.group-tag {
  flex-shrink: 0; font-size: .72rem; font-weight: 700; padding: 4px 9px;
  border-radius: 999px; background: var(--surface-2); color: var(--muted);
  border: 1px solid var(--border); white-space: nowrap;
}
.recipe {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 8px;
  border: 1px solid var(--border);
}
.recipe img, .recipe .thumb-placeholder {
  width: 48px; height: 48px; border-radius: var(--radius-xs); flex-shrink: 0; object-fit: cover;
  background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 1.25rem;
}
.recipe .recipe-name { flex: 1; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.recipe .recipe-main {
  flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 5px;
}
.recipe .recipe-main .recipe-name { flex: none; width: 100%; }
.recipe .photo-btn { flex-shrink: 0; width: 36px; height: 36px; min-height: 0; padding: 0; border-radius: 11px; font-size: 1rem; }
.recipe .pick-pct {
  flex-shrink: 0; font-size: 0.78rem; font-weight: 700; padding: 4px 9px;
  border-radius: 999px; background: var(--primary-soft);
}
.recipe .pick-pct.ok { background: var(--surface-2); background: color-mix(in srgb, var(--ok) 18%, transparent); }
.recipe .pick-pct.warn { background: var(--surface-2); background: color-mix(in srgb, var(--warn) 18%, transparent); }
.recipe .pick-pct.missing { background: var(--surface-2); background: color-mix(in srgb, var(--danger) 18%, transparent); }
.ing { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.ing:last-child { border-bottom: none; padding-bottom: 0; }
.ing > span:first-child { min-width: 0; overflow-wrap: anywhere; }
.ing small { white-space: nowrap; }
.ing > span:last-child { flex-shrink: 0; text-align: right; }
/* Bearbeiten · Foto entfernen · Rezept löschen unter dem Zutaten-Check —
   umbrechen statt quetschen, auf schmalen Telefonen passt keine Dreierreihe. */
.recipe-actions { flex-wrap: wrap; margin-top: 14px; }
.recipe-actions > * { flex: 1 1 auto; }
.ok { color: var(--ok); font-weight: 600; }
.warn { color: var(--warn); font-weight: 600; }
.missing { color: var(--danger); font-weight: 600; }
.unclear { color: var(--muted); font-weight: 600; }
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,15,30,.5); backdrop-filter: blur(4px);
  display: flex; align-items: flex-end; justify-content: center; z-index: 10;
  animation: fadeIn .15s ease;
}
.modal {
  background: var(--surface); color: var(--text); width: 100%; max-width: 520px;
  padding: 8px 20px calc(20px + var(--safe-b)); border-radius: 26px 26px 0 0;
  /* dvh berücksichtigt ein-/ausblendende mobile Adressleisten; vh als
     Fallback für Browser ohne dvh-Unterstützung. */
  max-height: 88vh; max-height: 88dvh; overflow-y: auto; overscroll-behavior: contain;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border); border-bottom: none;
  animation: sheetUp .22s cubic-bezier(.2,.8,.3,1);
}
.modal::before {
  content: ''; display: block; width: 38px; height: 4px; border-radius: 999px;
  background: var(--border); margin: 0 auto 14px;
}
.modal h3 { margin-top: 0; }
.modal::before, .modal h3, .modal > input { flex-shrink: 0; }
.modal > p:first-of-type { margin-top: 0; }
.modal button { width: 100%; margin-top: 8px; }
/* Zwischenüberschriften und Liste in Modals (bisher nur „Hinweise zur Beta“). */
.modal h4 { font-size: .9rem; margin: 18px 0 6px; }
.modal h4 + p { margin-top: 0; }
.modal ul { margin: 0 0 12px; padding-left: 1.2em; }
.modal li + li { margin-top: 6px; }
@media (min-width: 560px) {
  .modal-backdrop { align-items: center; }
  .modal { max-width: 400px; border-radius: var(--radius); border-bottom: 1px solid var(--border); padding-bottom: 20px; animation: popIn .18s ease; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }
@keyframes sheetUp { from { transform: translateY(14%); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
/* ---------- Wochenplan ---------- */
.today-card {
  background: linear-gradient(150deg, var(--primary), var(--primary-2));
  color: #fff; border: none; box-shadow: var(--shadow-lg); padding: 18px;
}
.today-card .today-head { display: flex; align-items: center; gap: 12px; }
.today-card .today-head img { width: 52px; height: 52px; object-fit: cover; border-radius: var(--radius-xs); flex-shrink: 0; }
.today-card .today-kicker { font-size: .7rem; text-transform: uppercase; letter-spacing: .09em; opacity: .75; font-weight: 700; }
.today-card .today-name { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.2; margin-top: 2px; }
.today-card .steps { list-style: none; counter-reset: s; padding: 0; margin: 16px 0 0; }
.today-card .steps li {
  counter-increment: s; position: relative; padding-left: 34px; margin-bottom: 12px;
  font-size: .9rem; line-height: 1.5;
}
.today-card .steps li::before {
  content: counter(s); position: absolute; left: 0; top: -1px;
  width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.22); font-size: .76rem; font-weight: 700;
}
.today-card .steps small { opacity: .8; }
.today-card .empty {
  color: rgba(255,255,255,.85); padding: 10px 0 0; text-align: left;
  display: flex; flex-direction: column; align-items: flex-start;
}
.today-card .empty b { color: #fff; }
.today-card .today-goto-plan {
  margin-top: 12px; align-self: flex-start; background: rgba(255,255,255,.2); color: #fff;
  border: none; box-shadow: none; font-weight: 700; font-size: .85rem; padding: 9px 14px;
}
.wake-toggle { display: flex; align-items: center; gap: 8px; font-size: .74rem; opacity: .9; flex-shrink: 0; }
.day-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px 8px 8px;
  background: var(--surface); border-radius: var(--radius-sm); margin-bottom: 8px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.day-row.is-today { border-color: var(--primary); border-color: color-mix(in srgb, var(--primary) 45%, transparent); }
.day-label {
  width: 38px; height: 38px; flex-shrink: 0; font-weight: 700; color: var(--muted);
  display: grid; place-items: center; background: var(--surface-2);
  border-radius: 11px; font-size: 0.76rem;
}
.day-row.is-today .day-label {
  background: linear-gradient(135deg, var(--primary), var(--primary-2)); color: #fff;
}
.recipe-pick-btn {
  flex: 1; min-width: 0; text-align: left; background: none; border: none; box-shadow: none;
  padding: 4px 0; min-height: 38px; justify-content: flex-start;
  display: flex; align-items: center; gap: 6px; font-weight: 600;
}
.recipe-pick-btn span {
  flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.recipe-pick-btn.is-empty span { color: var(--muted); font-weight: 500; }
.recipe-pick-btn::after { content: '›'; color: var(--muted); font-size: 1.2rem; line-height: 1; flex-shrink: 0; }
.day-row.is-done .recipe-pick-btn span { text-decoration: line-through; color: var(--muted); }
.day-done-toggle { display: flex; align-items: center; cursor: pointer; flex-shrink: 0; }
.day-done-toggle:has(input:disabled) { cursor: not-allowed; opacity: .35; }

/* ---------- Einkaufsliste ---------- */
.progress-card { display: flex; align-items: center; gap: 14px; }
.progress-ring { position: relative; width: 52px; height: 52px; flex-shrink: 0; }
.progress-ring svg { width: 52px; height: 52px; transform: rotate(-90deg); }
.progress-ring circle { fill: none; stroke-width: 5; stroke-linecap: round; }
.progress-ring .track { stroke: var(--border); }
.progress-ring .bar { stroke: var(--primary); transition: stroke-dasharray .35s ease; }
.progress-ring b {
  position: absolute; inset: 0; display: grid; place-items: center; font-size: .78rem; font-weight: 700;
}
.shopping-item {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; cursor: pointer;
  background: var(--surface); border-radius: var(--radius-sm); margin-bottom: 8px; box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.shopping-item .shop-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.shopping-item .cat-btn {
  min-height: 0; width: 34px; height: 34px; padding: 0; flex-shrink: 0; font-size: 1rem;
  border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border);
}

/* ---------- Markt & Gänge ---------- */
.market-bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.market-bar select { flex: 1; min-width: 0; }
.market-bar .icon-btn { width: 46px; height: 46px; font-size: 1.05rem; }
.quick-add { margin-bottom: 14px; gap: 8px; }
.quick-add .add-btn { flex: 0 0 52px; padding: 0; font-size: 1.3rem; }
.quick-add .qa-qty { flex: 1.1; }
.quick-add .qa-unit { flex: 1; }
.link-btn {
  background: none; border: none; box-shadow: none; color: var(--primary);
  font-size: .82rem; font-weight: 600; min-height: 0; padding: 2px 0; align-self: flex-start;
}
.group-head {
  display: flex; align-items: center; gap: 8px; margin: 18px 0 8px;
  font-size: .78rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase; color: var(--muted);
}
.group-head:first-child { margin-top: 4px; }
.group-head .group-line { flex: 1; height: 1px; background: var(--border); }
.aisle-row {
  display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border);
}
.aisle-row:last-of-type { border-bottom: none; }
.aisle-row .aisle-no {
  width: 24px; height: 24px; flex-shrink: 0; border-radius: 8px; display: grid; place-items: center;
  background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 700;
}
.aisle-row .aisle-name { flex: 1; min-width: 0; font-size: .9rem; font-weight: 600; overflow-wrap: anywhere; }
.aisle-row .icon-btn { width: 32px; height: 32px; font-size: .95rem; }
.market-row {
  display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border);
}
.market-row .market-name { flex: 1; min-width: 0; font-weight: 600; text-align: left; overflow-wrap: anywhere; }
.market-row .market-pick {
  flex: 1; min-width: 0; background: none; border: none; box-shadow: none; min-height: 38px;
  justify-content: flex-start; text-align: left; padding: 0; gap: 8px;
}
.market-row .market-pick .market-sub { font-size: .76rem; color: var(--muted); font-weight: 500; }
.market-row.is-active .market-name { color: var(--primary); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }
.cat-opt {
  width: 100%; justify-content: flex-start; gap: 10px; margin-bottom: 6px;
  background: var(--surface-2); font-weight: 600;
}
.cat-opt.is-active { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }
.qty-badge {
  flex-shrink: 0; font-size: .76rem; font-weight: 700; padding: 4px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  width: 26px; height: 26px; min-height: 0; flex-shrink: 0; padding: 0;
  border: 2px solid var(--border); border-radius: 8px;
  background: var(--surface-2); cursor: pointer; position: relative;
  transition: background .15s, border-color .15s;
}
input[type="checkbox"]:disabled { opacity: .4; cursor: not-allowed; }
input[type="checkbox"]:checked {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: var(--primary);
}
input[type="checkbox"]:checked::after {
  content: ''; position: absolute; left: 8px; top: 3px;
  width: 6px; height: 12px; border: solid #fff; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
/* toggle switch (wake lock) */
.switch { position: relative; display: inline-flex; width: 40px; height: 24px; flex-shrink: 0; }
.switch input[type="checkbox"] {
  width: 40px; height: 24px; min-height: 0; border-radius: 999px;
  background: rgba(255,255,255,.3); border: none;
}
.switch input[type="checkbox"]::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border: none; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
  transform: none; transition: transform .18s ease;
}
.switch input[type="checkbox"]:checked { background: rgba(255,255,255,.95); border: none; }
.switch input[type="checkbox"]:checked::after {
  content: ''; left: 3px; top: 3px; width: 18px; height: 18px; border: none;
  background: var(--primary); transform: translateX(16px);
}
/* collapsible panel */
details.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 0 16px; margin-bottom: 14px;
}
details.panel > summary {
  list-style: none; cursor: pointer; padding: 15px 0; font-weight: 600; font-size: .92rem;
  display: flex; align-items: center; gap: 8px;
}
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: '+'; margin-left: auto; color: var(--muted); font-size: 1.15rem; }
details.panel[open] > summary::after { content: '–'; }
details.panel > summary + * { margin-bottom: 16px; }
.receipt-row {
  display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border);
}
.receipt-row:last-child { border-bottom: none; }
.receipt-row .receipt-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.receipt-row .receipt-sub { display: flex; gap: 6px; }
.receipt-row .receipt-qty { max-width: 90px; }
.receipt-row .receipt-price { max-width: 90px; }
.receipt-head { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.receipt-head-row { display: flex; gap: 8px; align-items: center; }
.receipt-head-row > span { flex-shrink: 0; }
.receipt-head-row select, .receipt-head-row input { flex: 1; min-width: 0; }
.receipt-sums { font-size: .82rem; color: var(--muted); }
.receipt-sums.is-bad { color: var(--warn); }
/* ---------- Ausgaben ---------- */
.spend-total { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; }
.spend-bar-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; }
.spend-bar-label { flex: 1; min-width: 0; font-size: .88rem; overflow-wrap: anywhere; }
.spend-bar-amount { font-variant-numeric: tabular-nums; font-weight: 600; font-size: .88rem; }
.spend-bar-track { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin-top: 4px; }
.spend-bar-fill { height: 100%; border-radius: 3px; background: var(--primary); }
.price-row { padding: 9px 0; border-bottom: 1px solid var(--border); }
.price-row:last-child { border-bottom: none; }
.price-head { display: flex; gap: 8px; align-items: baseline; }
.price-head .price-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.price-saving { font-size: .8rem; font-weight: 700; color: var(--ok); white-space: nowrap; }
.price-market { display: flex; gap: 8px; font-size: .82rem; color: var(--muted); margin-top: 3px; }
.price-market .price-market-name { flex: 1; min-width: 0; }
.price-market.is-best .price-market-name { color: var(--primary); font-weight: 600; }
.receipt-log-row { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--border); }
.receipt-log-row:last-child { border-bottom: none; }
.receipt-log-main { flex: 1; min-width: 0; text-align: left; background: none; border: 0; color: inherit; padding: 0; font: inherit; }
.receipt-log-lines { font-size: .82rem; color: var(--muted); margin: 4px 0 2px 0; }
.shop-saving { display: block; font-size: .76rem; color: var(--muted); font-weight: 500; }
.rate-hint { display: flex; gap: 6px; align-items: center; }
.rate-hint button {
  background: none; border: 0; padding: 0 2px; color: var(--muted); font: inherit; cursor: pointer;
}
.rate-hint .rate-apply { color: var(--primary); font-weight: 600; text-decoration: underline; }
.status {
  display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .86rem; margin: 10px 0;
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border); border-top-color: var(--primary); animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Start-Screens: Laden, Login, Onboarding, Schlüssel ---------- */
.screen {
  max-width: 440px; margin: 0 auto;
  padding: calc(var(--safe-t) + 36px) 16px calc(var(--safe-b) + 32px);
}
.screen .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.screen h2 { font-size: 1.3rem; margin: 0; font-weight: 800; letter-spacing: -.02em; }
.screen .card { display: flex; flex-direction: column; gap: 10px; }
.screen .card h3 { margin: 0; }
.screen .card button, .sheet .card .stack button { width: 100%; }
.or-line { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; margin: 6px 0 14px; }
.or-line::before, .or-line::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.recovery-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .9rem; letter-spacing: .03em;
  padding: 12px; border-radius: var(--radius-sm); background: var(--surface-2);
  border: 1px dashed var(--border); overflow-wrap: anywhere; user-select: all;
}
.form-error { color: var(--danger); font-size: .84rem; margin: 0; }
.form-error:empty { display: none; }
.modal .form-error { margin-top: 8px; }
.field-label { display: block; font-size: .84rem; font-weight: 600; margin: 4px 0 6px; }
/* Rezept-JSON (KI-Vorschau/Bearbeiten) und „Mehrere Artikel“: klein und
   dicht am Desktop, auf Touch-Geräten aber mindestens 16px — sonst zoomt
   iOS Safari beim Antippen hinein. */
.json-editor {
  width: 100%; height: 220px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: .82rem; line-height: 1.5;
}
.bulk-input { width: 100%; height: 170px; font-size: .9rem; }
@media (pointer: coarse) {
  .json-editor, .bulk-input { font-size: 16px; }
}
/* Rezept-Picker im Wochenplan: Liste scrollt, Suche und Knopf bleiben stehen. */
.modal.modal-picker { display: flex; flex-direction: column; overflow: hidden; }
.modal-picker .picker-list { overflow-y: auto; flex: 1; margin-top: 12px; -webkit-overflow-scrolling: touch; }
.modal-picker > button { flex-shrink: 0; margin-top: 12px; }
.check-line { display: flex; align-items: center; gap: 10px; font-size: .88rem; cursor: pointer; }
.modal .check-line { margin: 10px 0; }
/* Überschriften und Bereiche, die nur per Skript den Fokus bekommen (neuer
   Screen, Einstellungen, aufgedeckter Schlüssel): kein Fokusrahmen. */
.screen [tabindex="-1"]:focus, .sheet [tabindex="-1"]:focus, #keyReveal:focus { outline: none; }
.turnstile-box { min-height: 65px; display: flex; justify-content: center; }
.code-input { font-size: 1.3rem; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }

/* ---------- App-Bar: Sync-Hinweis und Einstellungen ---------- */
.app-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.sync-badge {
  min-height: 0; padding: 5px 10px; border-radius: 999px; border: none; box-shadow: none;
  font-size: .74rem; font-weight: 700;
  background: var(--surface-2);
  background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn);
}

/* ---------- Einstellungen (Vollbild) ---------- */
.sheet { position: fixed; inset: 0; z-index: 9; background: var(--bg); overflow-y: auto; overscroll-behavior: contain; animation: fadeIn .15s ease; }
.sheet-head {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: 10px;
  padding: calc(var(--safe-t) + 14px) 16px 12px;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.sheet-head-inner { max-width: 520px; width: 100%; margin: 0 auto; display: flex; align-items: center; gap: 10px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
.sheet-body { max-width: 520px; margin: 0 auto; padding: 16px 16px calc(var(--safe-b) + 32px); }
.stack { display: flex; flex-direction: column; gap: 8px; }
.settings-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.settings-row:last-child { border-bottom: none; }
.settings-row .row-main { flex: 1; min-width: 0; }
.qr-box { display: grid; place-items: center; background: #fff; border-radius: var(--radius-sm); padding: 12px; margin: 4px 0 8px; }
.qr-box svg { width: 220px; height: 220px; }
.scan-video { width: 100%; border-radius: var(--radius-sm); background: #000; margin-bottom: 8px; }

/* ---------- Meldungen ---------- */
.toast-area {
  position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + var(--safe-b) + 14px); z-index: 12;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.toast {
  max-width: 480px; margin: 0 16px; padding: 11px 14px; border-radius: var(--radius-sm);
  background: var(--text); color: var(--bg); font-size: .86rem; line-height: 1.4;
  box-shadow: var(--shadow-lg); pointer-events: auto; animation: popIn .18s ease;
}
.toast button { min-height: 0; padding: 4px 10px; margin-left: 10px; font-size: .8rem; }
