:root {
  --bg: #f5f7fb; --surface: #ffffff; --surface-2: #eef1f7; --text: #1d2433; --muted: #69738a;
  --border: #dde2ec; --accent: #4f7cff; --accent-soft: #e6edff; --danger: #e5484d; --ok: #2bb673; --warn: #f5a623;
  --radius: 14px; --shadow: 0 1px 2px rgba(20, 30, 60, .06), 0 4px 16px rgba(20, 30, 60, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11151d; --surface: #1a202b; --surface-2: #232b38; --text: #e8ecf4; --muted: #98a2b8;
    --border: #2e3746; --accent: #6f93ff; --accent-soft: #24304d; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 1rem; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 16px 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; padding: 4px 10px 14px; }
.brand img { width: 30px; height: 30px; }
.group-switch { width: calc(100% - 8px); margin: 0 4px 12px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav .ico { width: 22px; text-align: center; }
.badge-premium { font-size: .65rem; background: linear-gradient(90deg, #f5a623, #ff6b6b); color: #fff; padding: 1px 6px; border-radius: 99px; margin-left: auto; }
main { padding: 24px; max-width: 1200px; width: 100%; }

@media (max-width: 699px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 500; padding: 4px; border-right: 0; border-top: 1px solid var(--border); }
  .sidebar .brand, .sidebar .group-switch { display: none; }
  .nav { display: flex; overflow-x: auto; gap: 2px; }
  .nav a { flex-direction: column; gap: 2px; font-size: .7rem; padding: 6px 8px; min-width: 64px; }
  .badge-premium { display: none; }
  main { padding: 16px 16px 90px; }
}

/* components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar h1 { margin: 0; margin-right: auto; }
button, .btn { font: inherit; border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 10px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
button:hover { background: var(--surface-2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { filter: brightness(1.07); }
button.danger { color: var(--danger); }
button.icon { padding: 6px 9px; border: 0; background: transparent; }
button.sm { padding: 4px 10px; font-size: .85rem; }
input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; width: 100%; }
textarea { min-height: 90px; resize: vertical; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
input[type=color] { padding: 2px; height: 38px; }
label.field { display: grid; gap: 4px; font-size: .85rem; color: var(--muted); margin-bottom: 10px; }
label.check { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs button.active { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 4px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list li.done .txt { text-decoration: line-through; color: var(--muted); }
.list .txt { flex: 1; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.chip.warn { background: #fdecc8; color: #8a5a00; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-weight: 700; font-size: .8rem; flex: none; }
.stat { font-size: 1.8rem; font-weight: 700; }
.empty { color: var(--muted); padding: 12px 0; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth .card { width: 100%; max-width: 400px; }
.auth .brand { justify-content: center; font-size: 1.4rem; }
.lang-pick { display: flex; gap: 6px; justify-content: center; margin-top: 12px; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(10, 15, 25, .45); display: grid; place-items: center; z-index: 1000; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--radius); padding: 20px; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.modal .actions .danger { margin-right: auto; }
.members-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.members-pick label { display: flex; gap: 6px; align-items: center; padding: 4px 10px; border: 1px solid var(--border); border-radius: 99px; font-size: .85rem; color: var(--text); }

#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 2000; }
#toast.show { opacity: 1; }

/* calendar */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.cal .head { background: var(--surface-2); padding: 6px; text-align: center; font-size: .8rem; color: var(--muted); }
.cal .day { background: var(--surface); min-height: 104px; padding: 4px; cursor: pointer; overflow: hidden; }
.cal .day.other { background: var(--bg); color: var(--muted); }
.cal .day.today .num { background: var(--accent); color: #fff; border-radius: 99px; padding: 0 6px; }
.cal .num { font-size: .8rem; font-weight: 600; display: inline-block; margin-bottom: 2px; }
.ev { display: block; font-size: .72rem; padding: 1px 5px; border-radius: 5px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; background: var(--accent); cursor: pointer; }
@media (max-width: 699px) { .cal .day { min-height: 64px; } .ev { font-size: .62rem; } }

.week { display: grid; grid-template-columns: repeat(7, minmax(110px, 1fr)); gap: 8px; overflow-x: auto; }
.week .col { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 8px; min-height: 160px; }
.week .col h3 { font-size: .85rem; text-align: center; color: var(--muted); }
.slot { border-radius: 8px; padding: 6px 8px; margin-bottom: 6px; font-size: .8rem; color: #fff; cursor: pointer; }

.meal-grid { display: grid; grid-template-columns: 110px repeat(7, minmax(120px, 1fr)); gap: 6px; overflow-x: auto; }
.meal-grid .cell { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 6px; min-height: 70px; font-size: .82rem; cursor: pointer; }
.meal-grid .cell:hover { border-color: var(--accent); }
.meal-grid .lbl { font-weight: 600; font-size: .82rem; align-self: center; }
.meal-grid .hd { text-align: center; font-size: .8rem; color: var(--muted); }
.meal { background: var(--accent-soft); border-radius: 6px; padding: 3px 6px; margin-bottom: 3px; }

.recipe-card img { width: 100%; height: 150px; object-fit: cover; border-radius: 10px; margin-bottom: 8px; background: var(--surface-2); }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.photos figure { margin: 0; position: relative; }
.photos img, .photos video { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: pointer; background: var(--surface-2); }
.photos figcaption { font-size: .78rem; color: var(--muted); }
.lightbox img, .lightbox video { max-width: 100%; max-height: 75vh; display: block; margin: 0 auto; border-radius: 8px; }

.bar { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--ok); }
.bar.over > span { background: var(--danger); }
.amount.expense { color: var(--danger); }
.amount.income { color: var(--ok); }

.chat { display: flex; flex-direction: column; height: calc(100vh - 140px); }
.chat .msgs { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.msg { max-width: 75%; background: var(--surface); border: 1px solid var(--border); padding: 8px 12px; border-radius: 14px; }
.msg.mine { align-self: flex-end; background: var(--accent); color: #fff; border-color: var(--accent); }
.msg .meta { font-size: .72rem; opacity: .75; }
.msg img { max-width: 240px; border-radius: 8px; display: block; margin-top: 4px; }
.chat form { display: flex; gap: 8px; }
@media (max-width: 699px) { .chat { height: calc(100vh - 170px); } }

#map { height: 420px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 0; }
.code { font-family: ui-monospace, Menlo, monospace; background: var(--surface-2); padding: 6px 10px; border-radius: 8px; word-break: break-all; font-size: .85rem; }
.grid.split { grid-template-columns: 2fr 1fr; }
@media (max-width: 699px) { .grid.split { grid-template-columns: 1fr; } }

/* ---------- iPhone & iPad ---------- */
html { -webkit-text-size-adjust: 100%; }
body { padding-top: env(safe-area-inset-top); -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none; }
/* 16px voorkomt dat iOS inzoomt bij het focussen van een veld */
input, select, textarea { font-size: 16px; }
button, .btn, .nav a { touch-action: manipulation; }
.sidebar { padding-top: max(16px, env(safe-area-inset-top)); padding-left: max(10px, env(safe-area-inset-left)); }
main { padding-right: max(24px, env(safe-area-inset-right)); }

/* iPad staand & smalle tablets: compacte zijbalk met alleen iconen */
@media (min-width: 700px) and (max-width: 1080px) {
  .shell { grid-template-columns: 76px 1fr; }
  .sidebar { padding: max(12px, env(safe-area-inset-top)) 6px 12px max(6px, env(safe-area-inset-left)); }
  .sidebar .brand { justify-content: center; padding: 4px 0 12px; font-size: 0; gap: 0; }
  .sidebar .group-switch { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: .66rem; padding: 8px 2px; text-align: center; }
  .nav .ico { font-size: 1.25rem; width: auto; }
  .badge-premium { display: none; }
}
/* telefoon: tabbalk onderaan */
@media (max-width: 699px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; z-index: 500; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border); }
  .sidebar .brand, .sidebar .group-switch { display: none; }
  .nav { display: flex; overflow-x: auto; gap: 2px; scrollbar-width: none; }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex-direction: column; gap: 2px; font-size: .7rem; padding: 6px 8px; min-width: 64px; }
  .badge-premium { display: none; }
  main { padding: 16px 16px calc(90px + env(safe-area-inset-bottom)); }
  .chat { height: calc(100dvh - 170px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
  /* formulieren als bottom sheet */
  .modal-bg { place-items: end stretch; padding: 0; }
  .modal { max-width: none; border-radius: 18px 18px 0 0; max-height: 92dvh; padding-bottom: calc(20px + env(safe-area-inset-bottom)); }
  .toolbar h1 { width: 100%; }
  #map { height: 55dvh; }
}
@media (display-mode: standalone) { .auth { padding-top: env(safe-area-inset-top); } }

/* ---------- recepten & catalogus ---------- */
.big-tabs button { font-size: 1rem; padding: 10px 16px; }
.recipe-flag { height: 110px; display: grid; place-items: center; font-size: 3.2rem; background: var(--surface-2); border-radius: 10px; margin-bottom: 8px; }
.recipe-card { cursor: pointer; }
.recipe-card:hover, .cuisine-card:hover { border-color: var(--accent); }
.cuisine-card { display: flex; gap: 14px; align-items: center; text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer; }
.cuisine-flag { font-size: 2.6rem; line-height: 1; }
.servings { display: flex; align-items: center; gap: 12px; margin: 10px 0 4px; padding: 8px 12px; background: var(--surface-2); border-radius: 12px; width: fit-content; }
.servings b { font-size: 1.3rem; }
button.round { width: 40px; height: 40px; border-radius: 50%; justify-content: center; font-size: 1.3rem; padding: 0; }
.modal .actions.wrap { flex-wrap: wrap; }
.modal .actions.wrap .chip { align-self: center; }

/* ---------- gezinstablet ---------- */
body.tablet { font-size: 17px; }
body.tablet button, body.tablet .btn { min-height: 44px; }
body.tablet .nav a { padding: 12px; }
.tablet-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; flex-wrap: wrap; margin-bottom: 18px; }
.tablet-clock { font-size: 3.4rem; font-weight: 700; line-height: 1; letter-spacing: -.02em; }
.tablet-greet { font-size: 1.3rem; text-align: right; }
.who-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; margin-top: 6px; }
.who { flex-direction: column; gap: 4px; padding: 8px 10px; border-radius: 14px; min-width: 76px; font-size: .85rem; border: 2px solid transparent; background: var(--surface); }
.who .avatar { width: 48px; height: 48px; font-size: 1.2rem; }
.who.active { border-color: var(--accent); background: var(--accent-soft); }
.who-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 12px; margin: 12px 0; }
.who-grid .who { min-height: 120px; justify-content: center; font-size: 1rem; }
.tablet-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); }
.tablet-grid .card h2 { font-size: 1.2rem; }
.tablet-grid .list li { padding: 12px 4px; }
.big-check { width: 56px; height: 56px; border-radius: 50%; font-size: 1.6rem; justify-content: center; padding: 0; background: var(--ok); color: #fff; border: 0; flex: none; }
.big-check:hover { filter: brightness(1.08); background: var(--ok); }
input.big { width: 28px; height: 28px; }
.tonight { width: 100%; text-align: left; padding: 16px; border-radius: 14px; display: block; font: inherit; color: inherit; }
.tonight-title { font-size: 1.35rem; font-weight: 700; }
.tablet-nav { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; margin-top: 18px; }
.tablet-nav a { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 16px 8px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--text); text-decoration: none; font-weight: 600; }
.tablet-nav a span { font-size: 1.8rem; }
@media (max-width: 699px) { .tablet-greet { text-align: left; } .who-bar { justify-content: flex-start; } .tablet-clock { font-size: 2.6rem; } }
