:root {
  --bg: #f4f6f3;
  --card: #ffffff;
  --text: #1c231f;
  --muted: #66706a;
  --line: #e2e6e2;
  --chip: #e9ece8;
  --accent: #2f7d4f;
  --accent-ink: #ffffff;
  --accent-soft: #e3f1e8;
  --danger: #c62828;
  --warn: #b26a00;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 4px 14px rgb(0 0 0 / .05);
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111412;
    --card: #1a1f1c;
    --text: #e7ece8;
    --muted: #9ba59f;
    --line: #2a312d;
    --chip: #252b27;
    --accent: #5cb27e;
    --accent-ink: #0b1a11;
    --accent-soft: #1d3326;
    --danger: #ef6b6b;
    --warn: #f0a840;
    --shadow: 0 1px 2px rgb(0 0 0 / .4);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}
button:disabled { opacity: .35; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; font-weight: 600; }
button.danger { color: var(--danger); }
button.big { width: 100%; padding: 14px; font-size: 17px; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
label input, label select { color: var(--text); font-size: 16px; }
.hint { color: var(--muted); font-size: 14px; margin: 6px 0; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; background: transparent; border-radius: 50%;
}
.icon-btn svg, .add-btn svg {
  width: 22px; height: 22px; fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.icon-btn:active { background: var(--chip); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; display: inline-block; }

/* ------------------------------------------------ kop */
#main-view, .page { max-width: 640px; margin: 0 auto; }
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  padding: calc(env(safe-area-inset-top) + 6px) 16px 10px;
  border-bottom: 1px solid var(--line);
}
.title-row { display: flex; align-items: center; gap: 4px; }
.title-row h1 { font-size: 20px; margin: 0; flex: 1; }
.sync {
  font-size: 12px; padding: 3px 8px; border-radius: 99px;
  background: var(--chip); color: var(--muted); white-space: nowrap;
}
.sync::before { content: "●"; margin-right: 4px; }
.sync.live::before { color: #2e9d57; }
.sync.offline { color: var(--warn); }
.sync.offline::before { color: var(--warn); }

.stores {
  display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 10px;
  scrollbar-width: none; margin: 0 -16px; padding-left: 16px; padding-right: 16px;
}
.stores::-webkit-scrollbar { display: none; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  white-space: nowrap; border-radius: 99px; padding: 7px 13px;
  background: var(--chip); border: 1px solid transparent; font-size: 15px;
}
.stores .chip.on { background: var(--c, var(--accent)); color: #fff; }
.stores .chip.on .dot { background: #fff; }

.add { position: relative; display: flex; gap: 8px; }
.add input { font-size: 17px; padding: 12px 14px; border-radius: 12px; }
.add-btn { width: 50px; flex: none; display: grid; place-items: center; padding: 0; border-radius: 12px; }
.add-btn svg { stroke-width: 2.6; }
.suggest {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); padding: 8px; max-height: 50vh; overflow: auto; z-index: 10;
}
.sg-title { font-size: 13px; color: var(--muted); margin: 2px 4px 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.sg-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  text-align: left; border: 0; background: transparent; padding: 11px 8px; border-radius: 8px;
}
.sg-row:active, .suggest .chip:active { background: var(--accent-soft); }

/* ------------------------------------------------ lijst */
.list { padding: 8px 16px 120px; }
.group h2 {
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--muted);
  margin: 18px 4px 6px; text-transform: none;
}
.group h2 .emoji { font-size: 17px; }
.group h2 .count {
  margin-left: auto; font-weight: 500; font-size: 12px;
  background: var(--chip); border-radius: 99px; padding: 1px 8px;
}
.group ul {
  list-style: none; margin: 0; padding: 0;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.item {
  display: flex; align-items: center; gap: 12px;
  min-height: 54px; padding: 6px 4px 6px 14px;
  border-top: 1px solid var(--line); cursor: pointer; user-select: none;
}
.item:first-child { border-top: 0; }
.item:active { background: var(--accent-soft); }
.check {
  width: 26px; height: 26px; flex: none; border-radius: 50%;
  border: 2px solid var(--line); display: grid; place-items: center;
}
.check svg { width: 16px; height: 16px; fill: none; stroke: var(--accent-ink); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.item .body { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px; }
.item .name { font-size: 17px; overflow-wrap: anywhere; }
.item .qty {
  font-size: 13px; font-weight: 600; color: var(--accent);
  background: var(--accent-soft); border-radius: 6px; padding: 1px 7px;
}
.item .note { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.who {
  width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: var(--c); color: #fff; font-size: 11px; font-weight: 700;
  display: grid; place-items: center; opacity: .85;
}
.item .edit { color: var(--muted); width: 44px; height: 44px; }
.item.pending { box-shadow: inset 3px 0 0 var(--warn); }
.item.done .check { background: var(--accent); border-color: var(--accent); }
.item.done .check svg { opacity: 1; }
.item.done .name { text-decoration: line-through; color: var(--muted); }
.item.done .qty { background: var(--chip); color: var(--muted); }
.done-group ul { opacity: .9; }
.item.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: var(--accent-soft); } 100% { background: transparent; } }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty.small { padding: 24px 16px 0; }
.empty p { margin: 6px 0; }
.big-emoji { font-size: 44px; }

/* ------------------------------------------------ kar */
.cart {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 6;
  display: flex; align-items: center; gap: 12px;
  max-width: 640px; margin: 0 auto;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgb(0 0 0 / .06);
}
.cart span { flex: 1; font-weight: 600; }
.cart button { padding: 12px 20px; }

/* ------------------------------------------------ pagina's */
.page-top {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; gap: 6px;
  padding: calc(env(safe-area-inset-top) + 6px) 8px 6px;
  border-bottom: 1px solid var(--line);
}
.page-top h1 { font-size: 20px; margin: 0; }
.page-body { padding: 8px 16px 48px; }
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px 16px; margin: 14px 0;
}
.card h2 { font-size: 17px; margin: 0 0 4px; }
details.store { border-top: 1px solid var(--line); }
details.store:first-of-type { margin-top: 10px; }
details.store summary {
  display: flex; align-items: center; gap: 10px; padding: 13px 2px; cursor: pointer;
  list-style: none; font-weight: 600;
}
details.store summary::-webkit-details-marker { display: none; }
details.store summary::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 22px; line-height: 1; transition: transform .15s; }
details.store[open] summary::after { transform: rotate(90deg); }
.sname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { font-size: 12px; font-weight: 500; color: var(--muted); background: var(--chip); border-radius: 99px; padding: 1px 8px; }
.store-body { display: grid; gap: 10px; padding: 0 0 14px; }
label.toggle { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 15px; }
label.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }
ol.order { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; counter-reset: ord; }
ol.order li {
  display: flex; align-items: center; gap: 8px; padding: 4px 4px 4px 12px;
  border-top: 1px solid var(--line); counter-increment: ord;
}
ol.order li:first-child { border-top: 0; }
ol.order li > span:first-child { flex: 1; }
ol.order li > span:first-child::before { content: counter(ord) "."; color: var(--muted); display: inline-block; width: 26px; font-size: 14px; }
.ord-btns { display: flex; }
.add-store { display: grid; gap: 8px; margin-top: 12px; padding-top: 14px; border-top: 1px solid var(--line); }

.day { font-size: 14px; color: var(--muted); margin: 22px 4px 0; font-weight: 600; }
.hist { margin-top: 8px; }
.hist-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.hist-head .hint { margin: 0; flex-basis: 100%; }
.chips.static .chip { font-size: 14px; padding: 4px 10px; }
.chip small { color: var(--muted); }

/* ------------------------------------------------ dialogen */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog form { display: grid; gap: 12px; padding: 18px; }
dialog h3 { margin: 0; font-size: 19px; }
dialog p { margin: 0; }
.dlg-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; flex-wrap: wrap; }
.spacer { flex: 1; }
.chip.radio { cursor: pointer; padding: 9px 14px; }
.chip.radio input { position: absolute; opacity: 0; pointer-events: none; width: 0; }
.chip.radio:has(input:checked) { background: var(--c, var(--accent)); color: #fff; }
.chip.radio:has(input:checked) .dot { background: #fff; }
.chip.radio:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------ inloggen */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); display: grid; gap: 14px; text-align: center; padding: 28px 22px; }
.login-card img { margin: 0 auto; border-radius: 16px; }
.login-card h1 { margin: 0; font-size: 24px; }
.login-card label { text-align: left; }

/* ------------------------------------------------ melding */
.toast {
  position: fixed; left: 50%; bottom: 24px; z-index: 50;
  transform: translate(-50%, calc(100% + 40px)); opacity: 0; pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
  display: flex; align-items: center; gap: 12px;
  max-width: calc(100vw - 32px); padding: 12px 16px; border-radius: 12px;
  background: #1f2a24; color: #fff; box-shadow: 0 8px 30px rgb(0 0 0 / .3); font-size: 15px;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; pointer-events: auto; }
.has-cart .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
.toast button { background: transparent; border: 0; color: #8fe0ad; font-weight: 700; padding: 4px 6px; }
