/* Afiya web-app. Zelfde kleuren als de Android-app; licht en donker volgen de instelling van het toestel. */

:root {
  --bg: #f8f6f0;
  --surface: #ffffff;
  --surface-2: #f4f1e8;
  --ink: #1a2520;
  --muted: #55615b;
  --outline: #d5cfbe;
  --primary: #014b3c;
  --on-primary: #ffffff;
  --primary-soft: #d9ebe2;
  --on-primary-soft: #00261d;
  --gold-soft: #f3e7cc;
  --on-gold-soft: #3b2a06;
  --track: #efebe0;
  --error: #b3261e;
  --error-soft: #f9dedc;
  --on-error-soft: #410e0b;
  --shadow: 0 1px 2px rgba(26, 37, 32, 0.06);
  --radius: 22px;
  --radius-sm: 16px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1714;
    --surface: #16211d;
    --surface-2: #1a2622;
    --ink: #e3eae6;
    --muted: #b3c0b9;
    --outline: #3a4942;
    --primary: #7fcdaf;
    --on-primary: #00382b;
    --primary-soft: #0d4a3b;
    --on-primary-soft: #cdeedd;
    --gold-soft: #4a3913;
    --on-gold-soft: #f6e3b8;
    --track: #24322c;
    --error: #f2b8b5;
    --error-soft: #601410;
    --on-error-soft: #f9dedc;
    --shadow: none;
    color-scheme: dark;
  }
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

h1, h2, h3, p { margin: 0; }
h1 { font-size: 30px; line-height: 1.15; font-weight: 700; letter-spacing: -0.01em; }
h2 { font-size: 24px; line-height: 1.2; font-weight: 700; }
h3 { font-size: 17px; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--primary); }

/* --- Indeling ------------------------------------------------------------------------------------------------ */

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(18px + env(safe-area-inset-top)) 16px 24px;
}
.app.has-tabs { padding-bottom: calc(108px + env(safe-area-inset-bottom)); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-lg { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.grow { flex: 1 1 auto; min-width: 0; }
.center { text-align: center; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.spacer-sm { height: 6px; }
.spacer { height: 14px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.page-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.page-head h2 { flex: 1; }
.section-title { font-size: 18px; font-weight: 650; margin: 10px 2px 2px; }

/* --- Kaarten, knoppen, velden -------------------------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--outline);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--surface-2); }
.card.flat { box-shadow: none; }
.card.soft { background: var(--primary-soft); color: var(--on-primary-soft); border-color: transparent; }

.btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-weight: 650;
  font-size: 16px;
  width: 100%;
  text-align: center;
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-secondary { background: transparent; color: var(--primary); border-color: var(--outline); }
.btn-quiet { background: transparent; color: var(--primary); width: auto; min-height: 44px; padding: 0 12px; }
.btn-danger { background: transparent; color: var(--error); border-color: var(--outline); }
.btn-sm { min-height: 40px; padding: 0 16px; font-size: 15px; width: auto; }
.btn .spin { width: 18px; height: 18px; }
.btn svg { width: 22px; height: 22px; flex: none; fill: currentColor; }

.icon-btn {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--ink);
}
.icon-btn:active { background: var(--surface-2); }
.icon-btn svg { width: 24px; height: 24px; fill: currentColor; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 14px; font-weight: 600; color: var(--muted); }
.input {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--outline);
  background: var(--surface);
  font-size: 16px; /* 16px voorkomt dat Safari inzoomt bij het typen */
}
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
textarea.input { min-height: 84px; resize: vertical; }
.help { font-size: 13px; color: var(--muted); }
.error-text { font-size: 14px; color: var(--error); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  appearance: none;
  -webkit-appearance: none;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1.5px solid var(--outline);
  background: transparent;
  font-weight: 600;
  font-size: 15px;
}
.chip[aria-pressed="true"], .chip.on { background: var(--primary-soft); color: var(--on-primary-soft); border-color: var(--primary); }
.chip[aria-pressed="true"]::before { content: "✓ "; }

.choice {
  display: block;
  width: 100%;
  text-align: left;
  padding: 16px;
  border-radius: 18px;
  border: 1.5px solid var(--outline);
  background: var(--surface);
}
.choice[aria-pressed="true"] { border-color: var(--primary); background: var(--primary-soft); color: var(--on-primary-soft); border-width: 2px; }
.choice b { display: block; font-size: 17px; }
.choice span { font-size: 14px; color: var(--muted); }
.choice[aria-pressed="true"] span { color: inherit; }

.banner {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--gold-soft);
  color: var(--on-gold-soft);
  font-size: 15px;
}
.banner.error { background: var(--error-soft); color: var(--on-error-soft); }
.banner.ok { background: var(--primary-soft); color: var(--on-primary-soft); }
.banner svg { width: 22px; height: 22px; flex: none; fill: currentColor; margin-top: 1px; }

.empty { text-align: center; padding: 30px 12px; }
.empty h3 { margin-bottom: 6px; }

.checkbox { display: flex; gap: 12px; align-items: center; min-height: 48px; cursor: pointer; }
.checkbox input { width: 26px; height: 26px; accent-color: var(--primary); flex: none; }

.switch { display: flex; align-items: center; gap: 12px; }
.switch input { appearance: none; -webkit-appearance: none; flex: none; width: 52px; height: 32px; border-radius: 999px; background: var(--outline); position: relative; border: 0; transition: background 0.15s; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: transform 0.15s; box-shadow: 0 1px 2px rgba(0,0,0,0.3); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(20px); }

.spin {
  display: inline-block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid currentColor;
  border-right-color: transparent;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spin { animation-duration: 2.4s; } }

/* --- Vandaag: ring, macro's, maaltijden ----------------------------------------------------------------------- */

.ring-wrap { position: relative; width: 220px; height: 220px; margin: 4px auto 0; }
.ring-wrap svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { stroke: var(--track); }
.ring-fill { stroke: var(--primary); transition: stroke-dashoffset 0.4s; }
.ring-fill.over { stroke: #b3863a; }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 0 30px; }
.ring-center .big { font-size: 44px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.05; }
.ring-center .sub { font-size: 14px; color: var(--muted); }
.ring-center .left { font-size: 17px; font-weight: 650; color: var(--primary); margin-top: 4px; }

.macro { display: flex; flex-direction: column; gap: 6px; }
.macro-head { display: flex; justify-content: space-between; font-size: 15px; }
.macro-head b { font-weight: 650; }
.bar { height: 10px; border-radius: 999px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--primary); border-radius: 999px; transition: width 0.4s; }
.bar.over > i { background: #b3863a; }

.meal-card { display: flex; gap: 14px; align-items: center; padding: 12px; cursor: pointer; }
.meal-card:active { background: var(--surface-2); }
.thumb { flex: none; width: 76px; height: 76px; border-radius: 18px; background: var(--surface-2); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb svg { width: 30px; height: 30px; fill: currentColor; opacity: 0.6; }
.meal-main { flex: 1 1 auto; min-width: 0; }
.meal-title { font-weight: 650; font-size: 16px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.meal-meta { font-size: 14px; color: var(--muted); margin-top: 2px; }
.meal-kcal { text-align: right; flex: none; font-variant-numeric: tabular-nums; }
.meal-kcal b { font-size: 20px; display: block; line-height: 1.1; }
.meal-kcal span { font-size: 13px; color: var(--muted); }

.pill { display: inline-flex; align-items: center; gap: 6px; margin-top: 6px; padding: 3px 11px; border-radius: 999px; font-size: 13px; font-weight: 650; background: var(--surface-2); color: var(--ink); }
.pill.counted { background: var(--primary-soft); color: var(--on-primary-soft); }
.pill.needs_input { background: var(--gold-soft); color: var(--on-gold-soft); }
.pill.analyzing, .pill.waiting_upload, .pill.on_device { background: var(--surface-2); }

.live { border-color: var(--primary); }
.live-head { display: flex; gap: 14px; align-items: center; }
.live-title { font-weight: 650; }
.progress { height: 8px; border-radius: 999px; background: var(--track); overflow: hidden; margin: 12px 0 8px; }
.progress > i { display: block; height: 100%; width: calc(var(--p, 0) * 100%); background: var(--primary); border-radius: 999px; transition: width 0.5s; }
.live-items { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.live-items li { display: flex; gap: 10px; align-items: baseline; }
.live-items .name { flex: 1; min-width: 0; }
.live-items .state { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.live-items .state.matched { color: var(--primary); font-weight: 600; }

/* --- Maaltijd ------------------------------------------------------------------------------------------------- */

.hero { width: 100%; aspect-ratio: 4 / 3; max-height: 340px; border-radius: var(--radius); background: var(--surface-2); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.hero img { width: 100%; height: 100%; object-fit: cover; display: block; }
.big-kcal { font-size: 34px; font-weight: 750; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.macros3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.macros3 div { background: var(--surface-2); border-radius: 14px; padding: 10px; text-align: center; }
.macros3 b { display: block; font-size: 18px; }
.macros3 span { font-size: 13px; color: var(--muted); }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--outline); }
.item:first-child { border-top: 0; }
.item .nm { font-weight: 600; }
.item .kc { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; }
.edit-item { padding: 14px; border: 1.5px solid var(--outline); border-radius: 18px; display: flex; flex-direction: column; gap: 10px; background: var(--surface); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* --- Dagboek en voortgang ------------------------------------------------------------------------------------ */

.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal .dow { font-size: 12px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal button { appearance: none; -webkit-appearance: none; border: 0; background: transparent; min-height: 46px; border-radius: 14px; font-size: 15px; position: relative; padding: 0; }
.cal button.dim { color: var(--muted); opacity: 0.45; }
.cal button.today { border: 1.5px solid var(--primary); }
.cal button.sel { background: var(--primary); color: var(--on-primary); }
.cal button .mark { display: block; font-size: 11px; line-height: 1; margin-top: 1px; height: 11px; }
.legend { font-size: 13px; color: var(--muted); text-align: center; }

.bars { display: flex; align-items: flex-end; gap: 4px; height: 150px; padding-top: 10px; }
.bars .col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 0; }
.bars .col i { display: block; width: 100%; max-width: 28px; border-radius: 6px 6px 2px 2px; background: var(--primary); min-height: 2px; height: calc(var(--p, 0) * 100%); }
.bars .col.dim i { opacity: 0.4; }
.bars .col.none i { background: var(--track); height: 2px; }
.bars .lbl { font-size: 11px; color: var(--muted); margin-top: 4px; }
.tabs { display: flex; gap: 6px; background: var(--surface-2); padding: 4px; border-radius: 999px; }
.tabs button { flex: 1; appearance: none; -webkit-appearance: none; border: 0; background: transparent; min-height: 40px; border-radius: 999px; font-weight: 650; color: var(--muted); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.line-chart { width: 100%; height: 180px; }
.line-chart .axis { stroke: var(--outline); stroke-width: 1; }
.line-chart .ln { stroke: var(--primary); stroke-width: 2.5; fill: none; }
.line-chart .dot { fill: var(--primary); }
.line-chart text { fill: var(--muted); font-size: 11px; }

/* --- Navigatie, schuifpaneel, melding ----------------------------------------------------------------------- */

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 20;
  background: var(--surface-2);
  border-top: 1px solid var(--outline);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar-inner { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: 1fr 1fr 84px 1fr 1fr; align-items: end; padding: 6px 4px 6px; }
.tab { appearance: none; -webkit-appearance: none; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 52px; padding: 4px 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.tab svg { width: 26px; height: 26px; fill: currentColor; }
.tab[aria-current="page"] { color: var(--primary); }
.tab[aria-current="page"] .ti { background: var(--primary-soft); }
.tab .ti { padding: 3px 16px; border-radius: 999px; display: flex; }
.fab {
  appearance: none;
  -webkit-appearance: none;
  justify-self: center;
  width: 68px;
  height: 68px;
  margin-top: -30px;
  border-radius: 50%;
  border: 4px solid var(--bg);
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}
.fab svg { width: 32px; height: 32px; fill: currentColor; }

.scrim { position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, 0.45); display: flex; align-items: flex-end; justify-content: center; }
.scrim.center-box { align-items: center; padding: 20px; }
.sheet { width: 100%; max-width: 560px; background: var(--bg); border-radius: 26px 26px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); max-height: 92vh; overflow: auto; display: flex; flex-direction: column; gap: 12px; }
.dialog { width: 100%; max-width: 420px; background: var(--surface); border-radius: 26px; padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.toasts { position: fixed; left: 0; right: 0; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 18px; border-radius: 14px; font-size: 15px; max-width: 480px; box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25); }

.offline-bar { position: sticky; top: 0; z-index: 15; margin: -18px -16px 14px; padding: 8px 16px; background: var(--gold-soft); color: var(--on-gold-soft); font-size: 14px; text-align: center; }

.logo { display: block; margin: 10px auto 0; width: 170px; height: auto; border-radius: 34px; }
@media (prefers-color-scheme: dark) {
  /* Het donkergroene logo is op een donkere achtergrond bijna onzichtbaar: geef het een lichte ondergrond. */
  .logo { background: #f8f6f0; padding: 14px; width: 190px; }
}
.photo-preview { width: 100%; max-height: 52vh; object-fit: contain; border-radius: var(--radius); background: #000; display: block; }

/* --- Tips en recepten ---------------------------------------------------------------------------------------- */

.tips-title { font-size: 18px; }
.tips-row { display: flex; gap: 12px; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.tips-row::-webkit-scrollbar { display: none; }
.tip-card { flex: 0 0 272px; scroll-snap-align: start; display: flex; flex-direction: column; gap: 6px; min-height: 148px; }
.tip-title { font-weight: 650; font-size: 16px; line-height: 1.25; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.tip-facts { font-size: 14px; color: var(--primary); font-weight: 600; }
.tip-card .small { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.tip-foot { margin-top: auto; display: flex; flex-direction: column; gap: 2px; padding-top: 4px; }
.recipe-time { color: var(--primary); font-size: 15px; font-weight: 600; }
.facts4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.bullets { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; }
.steps { margin: 0; padding-left: 24px; display: flex; flex-direction: column; gap: 10px; }
.stepper-count { min-width: 92px; text-align: center; font-size: 17px; }
