:root {
  --green: #1a66d6; /* accentkleur (blauw) */
  --green-dark: #1450ab;
  --bg: #ffffff;
  --card: #f1f5fd;
  --tint: #e8f0fe;
  --text: #0e2147;
  --muted: #4f6185;
  --line: #d9e3f3;
  --ring: #a8bde0;
  --danger: #c0392b;
  --bonus: #ff7a00;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--green); }
html, body { margin: 0; color: var(--text);
  font: 17px/1.4 ui-rounded, "SF Pro Rounded", -apple-system, BlinkMacSystemFont, system-ui, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
input, select { font: inherit; color: var(--text); background: var(--card); width: 100%;
  border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; outline: none; }
input:focus, select:focus { border-color: var(--green); }
h2 { font-size: 15px; font-weight: 800; color: var(--muted); margin: 24px 4px 8px; }

.btn { border: 0; border-radius: 14px; padding: 11px 16px; background: var(--card); border: 1px solid var(--line); font-weight: 600; }
.btn.primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 15px; }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:active { opacity: .7; }
.row { display: flex; gap: 8px; margin-top: 12px; } .row .btn { flex: 1; }
.error { color: var(--danger); }
.hint { color: var(--muted); font-size: 15px; margin: 8px 4px; }
.field { display: block; color: var(--muted); font-size: 14px; margin: 10px 0; }
.field input { margin-top: 4px; }

/* login */
.screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--bg); }
.login-box { width: 100%; max-width: 360px; text-align: center; }
.login-box img { border-radius: 20px; }
.login-box form { display: grid; gap: 10px; margin-top: 16px; }

/* layout */
/* Blauwe bovenkant met titel, voortgangsring en invoerveld; daaronder een wit vel met de lijst */
#app { --side: max(16px, calc((100% - 640px) / 2)); min-height: 100vh; }
.hero { background: var(--green); color: #fff; padding: calc(var(--safe-top) + 8px) var(--side) 30px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.top-text { min-width: 0; }
.top h1 { margin: 0; font-size: 30px; font-weight: 900; letter-spacing: -.01em; line-height: 1.05; }
.subtitle { margin: 2px 0 0; font-size: 13px; font-weight: 700; color: #dce9ff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ring { --p: 0%; position: relative; flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(#fff 0 var(--p), rgba(255,255,255,.28) var(--p) 100%); }
.ring::before { content: ""; grid-area: 1 / 1; width: 36px; height: 36px; border-radius: 50%; background: var(--green); }
.ring span:first-child { grid-area: 1 / 1; position: relative; font-size: 12px; font-weight: 900; font-variant-numeric: tabular-nums; }
.live { position: absolute; top: 0; right: 0; width: 10px; height: 10px; border-radius: 50%; background: #9db3d6; border: 2px solid var(--green); }
.live.on { background: #7dffb0; }
#app:not(.on-list) .subtitle, #app:not(.on-list) .ring, #app:not(.on-list) #add-form { display: none; }
#app:not(.on-list) .hero { padding-bottom: 26px; }
.hero .add-bar { gap: 6px; margin: 12px 0 0; background: #fff; border-radius: 16px; padding: 5px 5px 5px 14px; }
.hero .add-bar input { background: none; border: 0; padding: 8px 0; font-weight: 700; font-size: 16px; }
.hero .icon-btn { width: 36px; height: 36px; border: 0; border-radius: 12px; background: var(--tint); }
.hero .icon-btn svg { width: 20px; height: 20px; }
.sheet { position: relative; background: var(--bg); border-radius: 24px 24px 0 0; margin-top: -16px; min-height: 70vh;
  padding: 12px var(--side) calc(var(--safe-bottom) + 150px); }

/* Golven onderin, achter de tabbalk; de kleuren wisselen per dagdeel */
.waves { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--safe-bottom) + 120px); z-index: 4; pointer-events: none;
  --w1: #c7ddff; --w2: #7fb0f3; --w3: var(--green); --sun: #ffe9a8; --sun-y: 0px; }
.waves::before { content: ""; position: absolute; left: 0; right: 0; top: -24px; height: 24px; background: linear-gradient(rgba(255,255,255,0), #fff); }
.waves svg { display: block; width: 100%; height: 100%; background: #fff; }
.waves .w1 { fill: var(--w1); } .waves .w2 { fill: var(--w2); } .waves .w3 { fill: var(--w3); }
.waves .sun { fill: var(--sun); transform: translateY(var(--sun-y)); }
body.dp-ochtend .waves { --w1: #dbe8fb; --w2: #a9c9f5; --w3: #6fa3ea; --sun: #ffd27a; --sun-y: 14px; }
body.dp-avond .waves { --w1: #b8c4ea; --w2: #6d7fcc; --w3: #2b3f8f; --sun: #f2f5ff; --sun-y: 6px; }

.add-bar { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.icon-btn { flex: none; width: 50px; height: 50px; border-radius: 14px; border: 1px solid var(--line); background: var(--card); display: grid; place-items: center; }
.icon-btn svg { width: 26px; height: 26px; fill: none; stroke: var(--green); stroke-width: 2; stroke-linecap: round; }

.suggestions { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 8px; }
.suggestions button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 10px 12px; border: 0; background: none; text-align: left; border-bottom: 1px solid var(--line); }
.suggestions button:last-child { border-bottom: 0; }
.suggestions img, .thumb { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: #fff; flex: none; }
.thumb.blank { background: var(--line); }

.banner { display: flex; align-items: center; gap: 10px; justify-content: space-between; background: var(--tint); color: #12407f; font-weight: 700; border-radius: 14px; padding: 10px 12px; margin: 8px 0; }

.list { list-style: none; margin: 0; padding: 0; }
.cat { font-size: 13px; font-weight: 800; color: var(--muted); padding: 14px 6px 4px; }
.item { display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 14px; padding: 2px 4px 2px 8px; margin: 4px 0; min-height: 44px; }
.item.done { background: transparent; }
.item .name { white-space: nowrap; }
.item .meta { font-size: 12px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#list .thumb { width: 28px; height: 28px; }
.check { flex: none; width: 32px; height: 32px; margin: 0 -6px 0 -4px; padding: 0; border: 0; background: none; display: grid; place-items: center; }
.check::before { content: ""; grid-area: 1 / 1; width: 24px; height: 24px; border-radius: 50%; border: 2.5px solid var(--ring); background: #fff; box-sizing: border-box; transition: background .15s, border-color .15s; }
.item.done .check::before { background: var(--green); border-color: var(--green); }
.item.done .check::after { content: "✓"; grid-area: 1 / 1; color: #fff; font-size: 14px; font-weight: 900; }
.item .body { flex: 1; min-width: 0; }
.item .name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; }
.item .meta { font-size: 13px; font-weight: 600; color: var(--muted); }
.item .qty { display: inline-block; min-width: 20px; padding: 0 6px; margin-right: 6px; border-radius: 8px; background: var(--green); color: #fff; font-size: 13px; font-weight: 800; text-align: center; vertical-align: 1px; }
.item.done .qty { background: var(--line); color: var(--muted); }
.item.done .name { text-decoration: line-through; color: #637496; font-weight: 700; }
.item.done .thumb { opacity: .4; }
.more { border: 0; background: none; font-size: 22px; color: var(--muted); padding: 4px 8px; min-width: 40px; min-height: 40px; }
.trash { flex: none; border: 0; background: none; padding: 6px; margin-right: -6px; min-width: 40px; min-height: 40px; display: grid; place-items: center; }
.trash svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.trash:active svg { stroke: var(--danger); }
.sort-bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 6px 2px 2px; font-size: 14px; color: var(--muted); }
.seg { display: flex; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 10px; font-size: 14px; color: var(--muted); }
.seg button.active { background: var(--green); color: #fff; font-weight: 600; }
.seg-wide { width: 100%; }
.seg-wide button { flex: 1; }
.dash-nav { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.dash-nav .btn { font-size: 22px; line-height: 1; padding: 2px 14px; }
.dash-nav .btn:disabled { opacity: .3; }
.dash-list { list-style: none; margin: 4px 0 0; padding: 0; }
.dash-list li { display: grid; grid-template-columns: minmax(0, 1fr) 30% 36px; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px solid var(--line); font-size: 15px; }
.dash-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-bar { height: 8px; background: var(--card); border-radius: 4px; overflow: hidden; }
.dash-bar span { display: block; height: 100%; background: var(--green); border-radius: 4px; }
.dash-num { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bonus-ic { display: inline-grid; place-items: center; width: 17px; height: 17px; margin-left: 6px; border-radius: 50%; background: var(--bonus); color: #fff; font-size: 11px; font-weight: 800; vertical-align: 2px; }
.edit-bonus { color: var(--bonus); font-weight: 700; font-size: 14px; margin: 8px 2px 0; }
#pick-dialog { margin: calc(var(--safe-top) + 10px) auto auto; padding: 10px 12px; width: min(94vw, 460px); max-height: var(--vvh, 90dvh); overflow-y: auto; background: var(--bg); }
#pick-dialog .add-bar { margin: 0; }
#pick-dialog input { padding: 8px 10px; font-size: 16px; }
#pick-dialog .hint { font-size: 13px; margin: 6px 2px; }
#pick-dialog .result { padding: 6px 8px; gap: 10px; margin: 4px 0; cursor: pointer; }
#pick-dialog .result img { width: 44px; height: 44px; }
#pick-dialog .result .name { font-size: 15px; }
#pick-dialog .result:active { background: var(--line); }
.link-btn { display: block; text-align: center; text-decoration: none; color: var(--green); margin-top: 0; }
.hint a { color: var(--green); }
.handle { flex: none; width: 28px; min-height: 40px; display: grid; place-items: center; font-size: 20px; color: var(--muted); touch-action: none; cursor: grab; user-select: none; -webkit-user-select: none; margin-left: -4px; }
.item.dragging { box-shadow: 0 4px 14px rgba(0,0,0,.18); opacity: .95; position: relative; z-index: 2; }
.empty { text-align: center; color: var(--muted); margin: 40px 10px; }
.list-actions { display: flex; gap: 8px; justify-content: space-between; margin-top: 16px; }

.results { list-style: none; margin: 0; padding: 0; }
.result { display: flex; gap: 12px; align-items: center; background: var(--card); border-radius: 14px; padding: 10px; margin: 6px 0; }
.result img { width: 56px; height: 56px; object-fit: contain; background: #fff; border-radius: 8px; flex: none; }
.result .body { flex: 1; min-width: 0; }
.result .name { font-weight: 600; }
.result .meta { font-size: 13px; color: var(--muted); }
.price { font-weight: 700; }
.bonus { color: var(--bonus); font-weight: 700; font-size: 13px; }
.add-round { flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--green); color: #fff; font-size: 24px; line-height: 1; }
.add-round.added { background: var(--line); color: var(--muted); }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; padding: 7px 8px var(--safe-bottom);
  background: rgba(255,255,255,.7); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.tabbar button { flex: 1; border: 0; background: none; padding: 0 0 6px; font-size: 11px; font-weight: 800; color: #637496; display: grid; justify-items: center; gap: 2px; }
.tabbar button span { display: grid; place-items: center; width: 52px; height: 30px; border-radius: 15px; }
.tabbar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.1; stroke-linecap: round; stroke-linejoin: round; }
.tabbar button.active { color: var(--green); }
.tabbar button.active span { background: var(--tint); }

dialog { border: 0; border-radius: 20px; padding: 18px; width: min(92vw, 420px); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog h2 { margin-top: 0; text-transform: none; font-size: 20px; color: var(--text); letter-spacing: 0; }
/* Bewerken: bovenaan en compact, zodat alles boven het iPhone-toetsenbord past */
#edit-dialog { margin: calc(var(--safe-top) + 10px) auto auto; padding: 12px 14px; max-height: var(--vvh, 100dvh); overflow-y: auto; background: var(--bg); }
#edit-dialog h2 { font-size: 17px; margin-bottom: 4px; }
#edit-dialog .field { margin: 6px 0; font-size: 13px; }
#edit-dialog .field input { padding: 8px 10px; margin-top: 2px; font-size: 16px; }
#edit-dialog .edit-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
#edit-dialog .edit-buttons .btn { height: 40px; padding: 0 8px; white-space: nowrap; font-size: 15px; }
#edit-dialog .hint { font-size: 13px; margin: 6px 2px 0; }
.btn.small { min-height: 0; }

.scanner { position: fixed; inset: 0; background: #000; z-index: 50; }
.scanner video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame { position: absolute; left: 10%; right: 10%; top: 35%; height: 22%; border: 3px solid rgba(255,255,255,.85); border-radius: 14px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
.scanner-status { position: absolute; top: calc(var(--safe-top) + 20px); left: 0; right: 0; text-align: center; color: #fff; font-weight: 600; padding: 0 20px; text-shadow: 0 1px 3px #000; }
.scanner-actions { position: absolute; bottom: calc(var(--safe-bottom) + 24px); left: 20px; right: 20px; display: flex; gap: 10px; }
.scanner-actions .btn { flex: 1; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-bottom) + 90px); background: rgba(14,33,71,.94); color: #fff; padding: 10px 16px; border-radius: 20px; z-index: 60; max-width: 90vw; text-align: center; font-size: 15px; }
.item .thumb.blank { display: none; }
.list-actions .btn { white-space: nowrap; font-size: 15px; }

/* Koopjes: aanbiedingen per supermarkt */
.pills { overflow-x: auto; scrollbar-width: none; margin: 4px 0 2px; }
.pills::-webkit-scrollbar { display: none; }
.pills button { flex: 1 0 auto; white-space: nowrap; padding: 7px 14px; font-size: 15px; }
.offer-cat { margin: 4px 0; }
.cat-row { width: 100%; border: 0; text-align: left; padding: 8px 10px 8px 14px; }
.cat-row .count { flex: none; min-width: 28px; padding: 1px 8px; border-radius: 10px; background: var(--bonus); color: #fff; font-size: 13px; font-weight: 800; text-align: center; }
.chev { flex: none; color: var(--muted); font-size: 22px; line-height: 1; padding: 0 2px 0 6px; transition: transform .15s; }
.offer-cat.open .chev { transform: rotate(90deg); }
.offer-list { padding-left: 8px; }
.offer-list .hint { list-style: none; }
.offer .name { font-size: 15px; line-height: 1.25; }
.deal { display: inline-block; background: var(--bonus); color: #fff; font-size: 12px; font-weight: 800; border-radius: 8px; padding: 1px 7px; vertical-align: 1px; }
.was { color: var(--muted); font-size: 13px; }
.source { text-align: center; font-size: 13px; margin-top: 20px; }
.source a { color: var(--green); }

/* Supermarkten kiezen */
.back { margin: 2px 0 4px -6px; color: var(--green); border: 0; }
.chain { position: relative; cursor: pointer; padding: 6px 10px; }
.chain input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.chain .check { margin: 0 4px 0 -4px; }
.item.chain.done { background: var(--card); }
.item.chain.done .name { text-decoration: none; color: var(--text); font-weight: 800; }
.chooser { display: flex; align-items: center; gap: 8px; text-align: left; margin-top: 0; }
.chooser span:first-child { color: var(--muted); font-weight: 600; flex: none; }
.chooser strong { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Aanbieding bekijken */
.offer { cursor: pointer; }
/* Hooguit 75% van de schermhoogte; past altijd in de breedte, scrollt verticaal */
#offer-dialog { background: var(--bg); padding: 14px; width: min(86vw, 360px); max-width: calc(100vw - 32px);
  max-height: 75vh; max-height: 75dvh; overflow-x: hidden; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.offer-detail { text-align: center; min-width: 0; max-width: 100%; }
.offer-detail > * { max-width: 100%; overflow-wrap: anywhere; }
.offer-detail img { display: block; margin: 0 auto; width: 110px; height: 110px; object-fit: contain; background: #fff; border-radius: 12px; }
.od-shop { margin: 6px 0 0; font-size: 12px; font-weight: 800; color: var(--green); }
.offer-detail h2 { margin: 2px 0; font-size: 17px; line-height: 1.25; }
.offer-detail .hint { margin: 3px 0; font-size: 13px; }
.od-price { margin: 6px 0 2px; font-size: 17px; display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 4px 8px; }
.od-price .deal { font-size: 12px; }
.od-buttons { display: grid; gap: 8px; margin-top: 10px; }
.od-buttons .btn { width: 100%; margin: 0; padding: 10px 12px; font-size: 15px; white-space: normal; }
