:root {
  --bg: #f6f3ec;
  --card: #ffffff;
  --ink: #1f2a24;
  --muted: #6b756f;
  --line: #e3ded2;
  --accent: #2f6b4f;
  --accent-ink: #ffffff;
  --soft: #e6f0ea;
  --danger: #b3402e;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161a18;
    --card: #212724;
    --ink: #eef1ee;
    --muted: #9aa59f;
    --line: #333b37;
    --accent: #6fbf95;
    --accent-ink: #10231a;
    --soft: #26342d;
    --danger: #ee8672;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 14px 14px calc(96px + env(safe-area-inset-bottom));
}
h1, h2, h3 { margin: 0; text-wrap: balance; }
h2 { font-size: 1.05rem; }
h3 { font-size: .95rem; margin: 18px 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; border-radius: 10px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px;
}
input, select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
}
textarea { resize: vertical; }

/* knoppen */
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; padding: 12px 16px; min-height: 46px; }
.ghost { background: var(--soft); padding: 12px 16px; min-height: 46px; font-weight: 600; }
.danger { color: var(--danger); padding: 12px 10px; min-height: 46px; font-weight: 600; }
.wide { width: 100%; margin-top: 14px; }
.link { color: var(--accent); font-weight: 600; padding: 8px; display: block; margin: 0 auto 6px; }
.icon { width: 46px; height: 46px; font-size: 1.6rem; line-height: 1; color: var(--muted); flex: none; }
.icon:hover { background: var(--soft); color: var(--ink); }
.icon.small { width: 40px; height: 40px; font-size: 1.35rem; }
.add {
  width: 100%; text-align: left; padding: 11px 12px; margin-top: 6px;
  color: var(--accent); font-weight: 600; border: 1.5px dashed var(--line);
}
.add:hover { background: var(--soft); }

/* weekbalk */
.weekbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.weekbar .icon { background: var(--card); border: 1px solid var(--line); color: var(--ink); }
.weektitle { text-align: center; }
.weektitle strong { display: block; font-size: 1.3rem; }
.weektitle span { color: var(--muted); font-size: .9rem; }

/* kaarten */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-top: 10px;
}
.card > header { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.card > header span { color: var(--muted); font-size: .88rem; white-space: nowrap; }
.day.today { border-color: var(--accent); box-shadow: inset 4px 0 0 var(--accent); }
.entry {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: var(--soft); border-radius: 10px; padding: 2px 2px 2px 12px; margin-top: 6px;
}
.entry span { overflow-wrap: anywhere; font-weight: 500; }

/* boodschappen */
.inline, .toolbar { display: flex; gap: 8px; margin-top: 12px; }
.inline button, .toolbar button { flex: none; }
.progress { margin-top: 14px; color: var(--muted); font-size: .9rem; display: flex; justify-content: space-between; align-items: center; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.group h3 { color: var(--muted); text-transform: uppercase; letter-spacing: .05em; font-size: .78rem; margin: 18px 4px 6px; }
.group .card { padding: 0; margin-top: 0; overflow: hidden; }
.item {
  display: flex; align-items: center; gap: 12px; padding: 8px 10px 8px 14px; min-height: 56px;
  border-top: 1px solid var(--line); cursor: pointer;
}
.item:first-child { border-top: 0; }
.item input { width: 26px; height: 26px; min-height: 0; flex: none; accent-color: var(--accent); padding: 0; }
.item .nm { flex: 1; min-width: 0; overflow-wrap: anywhere; font-weight: 500; }
.item small { display: block; color: var(--muted); font-weight: 400; font-size: .8rem; }
.item .qty { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.item.done .nm, .item.done .qty { text-decoration: line-through; opacity: .5; }

/* gerechten & archief */
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%;
  text-align: left; padding: 13px 14px; background: var(--card); border: 1px solid var(--line);
  margin-top: 8px; min-height: 52px; font-weight: 500;
}
.row:hover { border-color: var(--accent); }
.row small { color: var(--muted); font-weight: 400; white-space: nowrap; }
.row.alt { color: var(--accent); border-style: dashed; }
.arch { list-style: none; margin: 6px 0 0; padding: 0; }
.arch li { padding: 3px 0; overflow-wrap: anywhere; }
.arch b { display: inline-block; width: 2.2em; color: var(--muted); font-weight: 600; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.actions .danger { margin-right: auto; }
.empty { text-align: center; color: var(--muted); padding: 26px 10px; }

/* dialoog */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(560px, calc(100vw - 20px));
  max-height: calc(100dvh - 24px); background: var(--bg); color: var(--ink);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
dialog h2 { font-size: 1.2rem; margin-bottom: 12px; }
.fld { display: block; font-weight: 600; font-size: .9rem; margin-top: 12px; }
.fld input, .fld textarea { margin-top: 4px; font-weight: 400; font-size: 1rem; }
.ing {
  display: grid; grid-template-columns: 1fr 1.2fr 1.8fr 40px; gap: 6px;
  padding: 8px; margin-top: 8px; background: var(--card); border: 1px solid var(--line); border-radius: 12px;
}
.ing input, .ing select { padding: 10px 8px; }
.ing .iname { grid-column: 1 / 4; }
.ing .icon { grid-column: 4; grid-row: 1; align-self: center; }
.ing .icat { grid-column: 3 / 5; }

/* navigatie */
#nav {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
#nav button {
  flex: 1; max-width: 160px; padding: 8px 2px 9px; border-radius: 0; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .74rem; font-weight: 600;
}
#nav svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#nav button.on { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

#toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-size: .92rem;
  opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
#dlgc { padding: 18px; }

/* aanmelden */
#nav[hidden] { display: none; }
.auth { max-width: 380px; margin: 12vh auto 0; padding: 26px 22px; text-align: center; }
.auth h1 { font-size: 1.5rem; margin-top: 8px; }
.auth p { color: var(--muted); }
.auth .fld { text-align: left; }
.hint { color: var(--muted); font-size: .88rem; margin: 12px 0 0; }
.foot { display: flex; justify-content: center; gap: 6px; margin: 26px 0 0; }
.foot .link { margin: 0; font-weight: 500; font-size: .88rem; color: var(--muted); }

/* geen verbinding */
#offline {
  position: fixed; left: 0; right: 0; bottom: calc(62px + env(safe-area-inset-bottom));
  background: #8a5a00; color: #fff; text-align: center; font-size: .85rem; padding: 7px 12px;
}
#offline[hidden] { display: none; }
body.offline #app { padding-bottom: calc(140px + env(safe-area-inset-bottom)); }
body.offline #toast { bottom: calc(140px + env(safe-area-inset-bottom)); }
/* als app geopend: ruimte voor de statusbalk */
@media (display-mode: standalone) { #app { padding-top: calc(14px + env(safe-area-inset-top)); } }
