:root {
  --bg: #f4f3ee;
  --card: #ffffff;
  --ink: #1c1c1c;
  --muted: #6b6b6b;
  --green: #0b3d2e;
  --amber: #e0a100;
  --red: #c0392b;
  --line: #e6e4dd;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08), 0 4px 12px rgba(0, 0, 0, .04);
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}
.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 16px; }

.topbar {
  background: linear-gradient(135deg, #0b3d2e, #14694e);
  color: #fff;
  padding: 18px 0 16px;
  padding-top: calc(18px + env(safe-area-inset-top));
}
.topbar h1 { margin: 0; font-size: 1.5rem; letter-spacing: -.02em; }
.topbar h1 span { font-weight: 400; opacity: .8; }
.tagline { margin: 4px 0 0; opacity: .85; font-size: .9rem; }

.controls { position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 12px 0 6px; }

.segmented {
  display: flex; background: #e7e5dd; border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 10px;
}
.seg {
  flex: 1; border: 0; background: transparent; padding: 9px 8px; border-radius: 9px;
  font-size: .95rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: .15s;
}
.seg.active { background: #fff; color: var(--green); box-shadow: var(--shadow); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 8px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 6px 12px; border-radius: 999px; font-size: .85rem; cursor: pointer; transition: .15s;
}
.chip.active { background: var(--green); border-color: var(--green); color: #fff; }
.chip .n { opacity: .6; font-variant-numeric: tabular-nums; }
.chip.active .n { opacity: .8; }

.meta { color: var(--muted); font-size: .82rem; margin: 4px 2px 12px; }

.grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (min-width: 560px) { .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }

.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; position: relative;
}
.card .imgbox {
  height: 170px; flex: 0 0 170px; overflow: hidden;
  background: #faf9f5; display: flex; align-items: center; justify-content: center; padding: 10px;
}
.card .imgbox img { width: 100%; height: 100%; object-fit: contain; mix-blend-mode: multiply; }
.card .noimg { font-size: 2.4rem; opacity: .35; }

.badges { position: absolute; top: 8px; left: 8px; display: flex; gap: 5px; }
.store {
  font-size: .7rem; font-weight: 700; color: #fff; padding: 3px 7px; border-radius: 6px; letter-spacing: .01em;
}
.store.Edeka { background: #1a4ea0; }
.store.Kaufland { background: #c0392b; }
.store.Trinkgut { background: #00733a; }
.store.Aldi { background: #00295b; }
.store.Lidl { background: #0050aa; }
.cat { position: absolute; top: 8px; right: 8px; font-size: .85rem; }

.body { padding: 10px 11px 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.title { font-size: .9rem; font-weight: 600; line-height: 1.25; }
.unit { font-size: .72rem; color: var(--muted); line-height: 1.3; }
.priceline { display: flex; align-items: baseline; gap: 8px; margin-top: auto; padding-top: 6px; }
.price { font-size: 1.35rem; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.old { font-size: .8rem; color: var(--muted); text-decoration: line-through; }
.sub { display: flex; flex-wrap: wrap; gap: 6px; font-size: .72rem; color: var(--muted); }
.tag { background: #f0eee6; border-radius: 5px; padding: 2px 6px; }
.tag.deal { background: #fff2cf; color: #8a6300; font-weight: 600; }
.valid { font-size: .7rem; color: var(--muted); margin-top: 2px; }

.store.folder { background: #7a6000; }
.card.leaflet .imgbox { background: #fff; }
.folderbtn {
  margin-top: auto; display: inline-flex; align-items: center; gap: 6px;
  background: var(--green); color: #fff; text-decoration: none;
  padding: 8px 12px; border-radius: 9px; font-size: .85rem; font-weight: 600;
  justify-content: center;
}
.folderbtn:active { opacity: .85; }

.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.foot {
  display: flex; align-items: center; justify-content: space-between;
  color: var(--muted); font-size: .78rem; padding: 22px 16px 30px;
}
.linkbtn { background: none; border: 0; color: var(--green); cursor: pointer; font-size: .8rem; }
.skeleton { animation: pulse 1.2s infinite; background: #eceae3; border-radius: var(--radius); aspect-ratio: 3/4; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }
