:root {
  color-scheme: light;
  --bg: #f4f3f0;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --border: #e0ded7;
  --text: #1b1b1a;
  --text-2: #52514e;
  --muted: #6d6c67;
  --primary: #2a78d6;
  --primary-ink: #ffffff;
  --primary-soft: #e3eefb;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --grid: #e6e4de;
  --ref-band: rgba(27, 175, 122, 0.12);
  --ref-line: #1baf7a;
  --good-bg: #e3f4ea; --good: #17663d;
  --warn-bg: #fdf1dc; --warn: #8a5300;
  --bad-bg: #fbe4e3; --bad: #a02826;
  --info-bg: #e3eefb; --info: #1c5cab;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #252523;
    --border: #33332f;
    --text: #f4f4f1;
    --text-2: #c3c2b7;
    --muted: #9e9d95;
    --primary: #3987e5;
    --primary-soft: #1d2f47;
    --series-1: #3987e5;
    --series-2: #d95926;
    --grid: #2c2c29;
    --ref-band: rgba(25, 158, 112, 0.16);
    --ref-line: #199e70;
    --good-bg: #173325; --good: #8fdcb0;
    --warn-bg: #3a2c10; --warn: #f2c46b;
    --bad-bg: #3d1a19; --bad: #f19c9b;
    --info-bg: #1d2f47; --info: #9ec5f4;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }

.container { max-width: 960px; margin: 0 auto; padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Kopbalk en navigatie */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.brand { display: block; max-width: 960px; margin: 0 auto; padding: 10px 16px 0; font-weight: 700; font-size: 1.1rem; color: var(--text); text-decoration: none; }
.nav {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none;
  max-width: 960px; margin: 0 auto; padding: 8px 12px;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: 0 0 auto; display: flex; align-items: center; gap: 6px;
  padding: 7px 12px; border-radius: 999px;
  color: var(--text-2); text-decoration: none; font-size: .92rem; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current] { background: var(--primary-soft); color: var(--primary); font-weight: 600; }

/* Submenu binnen een groep */
.subnav:empty { display: none; }
.subnav { padding-bottom: 0; }
.subnav-row { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 4px; }
.subnav-row::-webkit-scrollbar { display: none; }
.subnav-row a {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); text-decoration: none; font-size: .88rem; white-space: nowrap;
}
.subnav-row a[aria-current] { background: var(--primary-soft); border-color: transparent; color: var(--primary); font-weight: 600; }
.subnav-row .subnav-home { padding: 6px 10px; }

/* Tegels op de groepspagina's */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tile {
  display: flex; flex-direction: column; gap: 2px; padding: 14px; min-height: 120px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none;
}
.tile:hover { background: var(--surface-2); }
.tile-icon { font-size: 1.6rem; line-height: 1; margin-bottom: 4px; }
.tile-title { font-weight: 700; }
.tile-text { font-size: .82rem; color: var(--muted); }
.tile-status { margin-top: auto; padding-top: 6px; font-size: .82rem; font-weight: 600; color: var(--primary); }

/* Gezondheidsmeter */
.gauge { display: block; margin: 0 auto; max-width: 100%; }
.gauge-track { fill: none; stroke: var(--surface-2); stroke-width: 16; stroke-linecap: round; }
.gauge-value { fill: none; stroke-width: 16; stroke-linecap: round; }
.gauge-value.good { stroke: var(--good); }
.gauge-value.warn { stroke: var(--warn); }
.gauge-value.bad { stroke: var(--bad); }
.gauge-score { font-size: 40px; font-weight: 700; fill: var(--text); font-variant-numeric: tabular-nums; }
.gauge-max { font-size: 11px; fill: var(--muted); }
.meter-main { text-align: center; }
.meter-label { margin: 4px 0; }
.meter-label .badge { font-size: 1rem; padding: 4px 14px; }
.meter-link { display: block; color: var(--text); text-decoration: none; }
.meter-link:hover { background: var(--surface-2); }
.meter-row { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: center; }
.meter-row h2 { margin: 0 0 4px; }
.meter-row p { margin: 2px 0; }
.link-text { color: var(--primary); font-weight: 600; }
.meter-flag { color: var(--bad); font-weight: 600; margin: 8px 0 0; }
.reasons { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.reasons li { display: grid; grid-template-columns: 22px 1fr; gap: 6px; align-items: start; }
.reason-icon { font-weight: 700; text-align: center; border-radius: 50%; width: 22px; height: 22px; line-height: 22px; font-size: .8rem; }
.reasons.good .reason-icon { background: var(--good-bg); color: var(--good); }
.reasons.bad .reason-icon { background: var(--warn-bg); color: var(--warn); }
.reason-link { font-size: .78rem; white-space: nowrap; margin-left: 4px; }
.domain-list { display: grid; gap: 4px; }
.domain summary { display: grid; grid-template-columns: minmax(130px, 38%) 1fr 32px; gap: 10px; align-items: center; padding: 8px 0; cursor: pointer; list-style: none; }
.domain summary::-webkit-details-marker { display: none; }
.domain summary::after { content: none; }
.domain + .domain { border-top: 1px solid var(--border); }
.domain-name { font-weight: 600; }
.domain-score { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.bar-fill.good { background: var(--good); }
.bar-fill.warn { background: var(--warn); }
.bar-fill.bad { background: var(--bad); }
.domain-body { padding: 4px 0 10px; font-size: .92rem; }
.domain-body p { margin: 4px 0; }
@media (max-width: 420px) { .meter-row { grid-template-columns: 1fr; text-align: center; } }

.multi-options { display: flex; flex-wrap: wrap; gap: 6px; }
.chip.multi span { min-width: 0; height: auto; min-height: 36px; padding: 6px 12px; font-size: .88rem; }

/* Sport */
.sport-add { margin: -6px 0 14px; }
.muscle-grid { list-style: none; padding: 0; margin: 6px 0 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 6px; }
.muscle-grid li { padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); display: flex; flex-direction: column; }
.muscle-grid li small { color: var(--muted); font-size: .76rem; }
.muscle-grid li.fresh { background: var(--good-bg); border-color: transparent; }
.muscle-grid li.fresh small { color: var(--good); }
.muscle-grid li.ok { background: var(--info-bg); border-color: transparent; }
.muscle-grid li.old small, .muscle-grid li.none small { color: var(--warn); }

.type-choice { display: grid; gap: 8px; }

/* Focus */
.next-task .next-title { font-size: 1.25rem; font-weight: 700; margin: 0; }
.task-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.task-list li { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.task-main small { display: block; color: var(--text-2); margin-top: 3px; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.task-actions { display: flex; flex-wrap: wrap; gap: 4px; align-items: flex-start; justify-content: flex-end; max-width: 150px; }
.task-list .progress { margin: 6px 0 2px; height: 6px; }
.routine-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.routine-list li { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.routine-list .dose-toggle { grid-template-columns: 30px 0 1fr; }
.routine-list li.done .dose-toggle { background: var(--good-bg); border-color: transparent; }
.routine-list li.done .check { background: var(--good); border-color: var(--good); color: var(--surface); }
.focus-park { display: flex; gap: 6px; margin: 8px 0; }
.focus-park input { flex: 1; }
.thought-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.thought-list li { display: flex; justify-content: space-between; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--border); }
#focus-overlay {
  position: fixed; inset: 0; z-index: 100; background: var(--bg); display: grid; place-items: center; padding: 20px;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
.focus-box { width: min(520px, 100%); text-align: center; }
.focus-box h2 { font-size: 1.4rem; margin: 8px 0; }
.focus-label { color: var(--muted); font-weight: 600; margin: 0; }
.focus-step { font-size: 1.05rem; }
.focus-time { font-size: clamp(4rem, 22vw, 7rem); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -2px; margin: 12px 0; color: var(--primary); }
.focus-buttons { justify-content: center; }

/* Weekmenu */
.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: -6px 0 10px; }
.allergy-card p { margin: 2px 0; }
.meal-row { display: grid; grid-template-columns: 88px 1fr auto; gap: 8px; align-items: start; padding: 8px 0; border-top: 1px solid var(--border); }
.meal-row:first-of-type { border-top: 0; }
.meal-label { font-size: .82rem; font-weight: 600; color: var(--muted); padding-top: 2px; }
.meal-main a { font-weight: 600; text-decoration: none; }
.meal-note { display: block; color: var(--text-2); margin-top: 2px; }
.meal-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 480px) { .meal-row { grid-template-columns: 1fr auto; } .meal-label { grid-column: 1 / -1; } }
.recipe-list { list-style: none; padding: 0; margin: 0 0 10px; display: grid; gap: 6px; }
.recipe-list a { text-decoration: none; font-weight: 600; }
.shop-list { list-style: none; padding: 0; margin: 0 0 8px; }
.shop-list li { padding: 5px 0; border-bottom: 1px solid var(--border); }
.shop-list label { display: flex; gap: 8px; align-items: center; }
.shop-list input { width: 20px; height: 20px; min-height: 0; }
.shop-list input:checked + * , .shop-list label:has(input:checked) { color: var(--muted); text-decoration: line-through; }

/* Energie */
.energy-question { margin: 0 0 8px; }
.energy-buttons { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.energy-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; min-height: 64px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer;
}
.energy-btn span { font-size: 1.6rem; line-height: 1.1; }
.energy-btn small { font-size: .7rem; color: var(--text-2); }
.energy-btn:hover { background: var(--surface-2); }
.energy-btn:active { background: var(--primary-soft); }
.energy-moments { list-style: none; padding: 0; margin: 10px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.energy-moments li { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-2); border-radius: 999px; padding: 2px 4px 2px 10px; font-size: .88rem; }
.icon-btn.small { width: 26px; height: 26px; font-size: .8rem; }
.energy-today { font-size: .95rem; margin: 0 0 8px; }
.energy-today strong { font-size: 2rem; }
.factor-list { list-style: none; padding: 0; margin: 4px 0 12px; display: grid; gap: 6px; }
.factor-list li { display: grid; grid-template-columns: 28px 1fr auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); }
.factor-icon { font-size: 1.2rem; text-align: center; }
.factor-text small { display: block; color: var(--muted); font-size: .76rem; }
.factor-effect { font-weight: 700; font-variant-numeric: tabular-nums; padding: 2px 10px; border-radius: 999px; }
.factor-effect.plus { background: var(--good-bg); color: var(--good); }
.factor-effect.min { background: var(--warn-bg); color: var(--warn); }

/* Telefoon: hoofdmenu als vaste balk onderin */
@media (max-width: 640px) {
  .nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; max-width: none; margin: 0;
    display: grid; grid-template-columns: repeat(6, 1fr); gap: 0; padding: 4px 2px calc(4px + env(safe-area-inset-bottom));
    background: var(--surface); border-top: 1px solid var(--border); overflow: visible;
  }
  .nav a { flex-direction: column; gap: 1px; padding: 6px 0; border-radius: 10px; font-size: .68rem; justify-content: center; }
  .nav a span { font-size: 1.25rem; line-height: 1.1; }
  .nav a[aria-current] { background: var(--primary-soft); }
  .brand { padding-bottom: 10px; }
  body { padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
}

/* Paginakop */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin: 8px 0 16px; }
.page-head h1 { margin: 0; }
.actions, .button-row, .controls { display: flex; flex-wrap: wrap; gap: 8px; }
.hero { margin: 8px 0 16px; }
.hero h1 { margin-bottom: 0; }
.back { text-decoration: none; }
.section-title { margin: 24px 0 10px; font-size: 1.05rem; color: var(--text-2); }

/* Kaarten */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.item-head h3 { margin: 0; font-size: 1.05rem; }
.item.upcoming { border-left: 4px solid var(--primary); }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + * { margin-top: 14px; }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.welcome ol { padding-left: 1.2rem; margin: .5rem 0 0; }
.welcome li { margin: .3rem 0; }

.empty { text-align: center; padding: 24px 16px; color: var(--muted); border: 1px dashed var(--border); border-radius: var(--radius); background: var(--surface); margin-bottom: 14px; }

details.stopped { margin-top: 16px; }
details.stopped summary { cursor: pointer; color: var(--text-2); font-weight: 600; padding: 8px 0; }
details.stopped .card { opacity: .8; }

/* Knoppen */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: .88rem; }
.icon-btn { border: 0; background: transparent; color: var(--muted); font-size: 1.1rem; width: 36px; height: 36px; border-radius: 8px; cursor: pointer; flex: 0 0 auto; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

select, input, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; width: 100%; min-height: 42px;
}
.controls select { width: auto; }
textarea { resize: vertical; }

/* Badges en lijstjes */
.badge { display: inline-block; white-space: nowrap; padding: 2px 9px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); vertical-align: middle; }
.badge.good { background: var(--good-bg); color: var(--good); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.info { background: var(--info-bg); color: var(--info); }
.pills { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.pills li { background: var(--surface-2); padding: 3px 10px; border-radius: 999px; font-size: .9rem; }
.list { padding-left: 1.1rem; margin: 6px 0 10px; }
.list li { margin: 6px 0; }
.alerts { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.alerts li { padding: 9px 12px; border-radius: 10px; }
.alerts li a { color: inherit; text-decoration: none; display: block; }
.alerts li.warn { background: var(--warn-bg); color: var(--warn); }
.alerts li.warn::before { content: "! "; font-weight: 700; }
.alerts li.bad { background: var(--bad-bg); color: var(--bad); }
.alerts li.bad::before { content: "✕ "; font-weight: 700; }
.alerts li.info { background: var(--info-bg); color: var(--info); }
.alerts li.info::before { content: "i "; font-weight: 700; }
.alerts li::before { float: left; margin-right: 4px; }

.kvs { margin: 8px 0; display: grid; gap: 4px; }
.kv { display: grid; grid-template-columns: minmax(110px, 38%) 1fr; gap: 10px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

/* Medicatie-innames */
.doses { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 6px; }
.dose-toggle {
  display: grid; grid-template-columns: 30px 52px 1fr auto; align-items: center; gap: 8px; width: 100%;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
  color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.dose-toggle:hover { background: var(--surface-2); }
.dose-toggle .check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--muted); display: grid; place-items: center; font-weight: 700; }
.dose-toggle .time { font-variant-numeric: tabular-nums; font-weight: 600; }
.dose-toggle small { display: block; color: var(--muted); }
.doses li.taken .dose-toggle { background: var(--good-bg); border-color: transparent; }
.doses li.taken .check { background: var(--good); border-color: var(--good); color: var(--surface); }
.doses li.taken .what strong { text-decoration: line-through; text-decoration-thickness: 1px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 4px 0 8px; }
.progress span { display: block; height: 100%; background: var(--good); border-radius: 999px; transition: width .2s; }

.doses li.late .dose-toggle { border-color: var(--warn); }
.late-label { font-size: .75rem; font-weight: 600; color: var(--warn); background: var(--warn-bg); padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
@media (max-width: 420px) { .late-label { grid-column: 3 / -1; justify-self: start; } }

/* Pijndagboek */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 4px 0 14px; }
.stats > div { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-value.small { font-size: 1rem; line-height: 1.3; padding: 4px 0; }
.stat-label { font-size: .8rem; color: var(--muted); }
.pain-list { list-style: none; padding: 0; margin: 8px 0 0; display: grid; gap: 10px; }
.pain-list li { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: start; }
.pain-score { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: 1.1rem; }
.pain-score.good { background: var(--good-bg); color: var(--good); }
.pain-score.warn { background: var(--warn-bg); color: var(--warn); }
.pain-score.bad { background: var(--bad-bg); color: var(--bad); }
.pain-body small { color: var(--text-2); }

/* Bloeduitslagen */
.table-wrap { overflow-x: auto; margin: 8px 0; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .82rem; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
tr.out td { background: var(--warn-bg); }
.results-table a { text-decoration: none; }
.param-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.param { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; color: var(--text); text-decoration: none; }
.param:hover { background: var(--surface-2); }
.param-name { font-weight: 600; font-size: .9rem; }
.param-value { font-size: 1.25rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.param-value small { font-size: .8rem; color: var(--muted); font-weight: 500; }
.param-meta { font-size: .8rem; color: var(--muted); }
.param .badge { align-self: flex-start; margin-top: 4px; }

/* Grafiek */
.chart { position: relative; }
.chart svg { display: block; max-width: 100%; overflow: visible; touch-action: pan-y; }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { fill: var(--muted); font-size: 11px; }
.chart .ref-band { fill: var(--ref-band); }
.chart .ref-line { stroke: var(--ref-line); stroke-width: 1; stroke-dasharray: 4 3; }
.chart .series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .series-dot { stroke: var(--surface); stroke-width: 2; }
.chart .series-dot.out { stroke: var(--bad); stroke-width: 2.5; }
.chart .direct-label { fill: var(--text-2); font-size: 11px; font-weight: 600; }
.chart .crosshair { stroke: var(--muted); stroke-width: 1; }
.chart-tip {
  position: absolute; top: 0; pointer-events: none; z-index: 2;
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; font-size: .85rem; box-shadow: 0 4px 14px rgba(0,0,0,.12); white-space: nowrap;
}
.tip-date { color: var(--muted); font-size: .8rem; }
.tip-row { display: flex; align-items: center; gap: 6px; }
.tip-key { display: inline-block; width: 14px; height: 3px; border-radius: 2px; vertical-align: middle; }
.flag { font-size: .78rem; font-weight: 600; color: var(--bad); }
.legend { display: flex; gap: 14px; font-size: .85rem; color: var(--text-2); margin-bottom: 6px; }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

/* Formulier-dialoog */
dialog {
  width: min(640px, calc(100vw - 16px)); max-height: calc(100dvh - 16px);
  padding: 0; border: 0; border-radius: 16px; background: var(--surface); color: var(--text);
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog-form { display: flex; flex-direction: column; max-height: calc(100dvh - 16px); }
.dialog-head, .dialog-foot { display: flex; align-items: center; gap: 8px; padding: 12px 16px; }
.dialog-head { border-bottom: 1px solid var(--border); justify-content: space-between; }
.dialog-head h2 { margin: 0; }
.dialog-foot { border-top: 1px solid var(--border); flex-wrap: wrap; }
.dialog-foot .spacer { flex: 1; }
.dialog-body { padding: 16px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { grid-column: 1 / -1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.half { grid-column: auto; }
@media (max-width: 340px) { .field.half { grid-column: 1 / -1; } }
.field label, .field .label { font-weight: 600; font-size: .9rem; }
.field.check label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.field.check input { width: 20px; height: 20px; min-height: 0; }
.help { color: var(--muted); font-size: .8rem; }
.form-error { color: var(--bad); background: var(--bad-bg); padding: 8px 12px; border-radius: 8px; margin-top: 12px; }
.scale { display: flex; flex-wrap: wrap; gap: 6px; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: grid; place-items: center; min-width: 42px; height: 42px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: 1.1rem; background: var(--surface);
}
.chip input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.chip input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }
.results-head, .result-row { display: grid; grid-template-columns: 2.2fr 1fr 1fr .9fr .9fr 36px; gap: 6px; align-items: center; }
.results-head { font-size: .75rem; color: var(--muted); }
.results { display: grid; gap: 6px; margin-bottom: 6px; }
.result-row input { padding: 7px 8px; min-height: 38px; }
@media (max-width: 520px) {
  .results-head { display: none; }
  .result-row { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
  .result-row:not(.custom) { grid-template-columns: 1fr 1fr 1fr 36px; }
  .result-row:not(.custom) [data-k="name"] { grid-column: 1 / 4; }
  .result-row:not(.custom) [data-remove-row] { grid-column: 4; grid-row: 1; }
}

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 50; font-weight: 600;
  white-space: nowrap; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis;
}

/* Formulier: tussenkopjes en keuzevragen */
.form-section { margin-top: 10px; padding-top: 12px; border-top: 1px solid var(--border); }
.form-section h3 { margin: 0; font-size: 1rem; color: var(--primary); }
.form-grid > .form-section:first-of-type { margin-top: 0; }
fieldset.choice { border: 0; padding: 0; margin: 0; }
fieldset.choice legend { font-weight: 600; font-size: .92rem; padding: 0; margin-bottom: 6px; }
.choice-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 6px; }
.choice-opt input { position: absolute; opacity: 0; pointer-events: none; }
.choice-opt span { display: flex; align-items: center; min-height: 42px; height: 100%; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; font-size: .88rem; line-height: 1.25; background: var(--surface); }
.choice-opt input:checked + span { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.choice-opt input:focus-visible + span { outline: 3px solid var(--primary); outline-offset: 2px; }

/* Welzijn */
.trend { font-size: .78rem; color: var(--muted); margin-top: 2px; }
.trend.better { color: var(--good); }
.trend.worse { color: var(--bad); }
.stat-value small { font-size: .8rem; color: var(--muted); font-weight: 500; }
.big-score { font-size: 2.6rem; font-weight: 700; margin: 0; line-height: 1.1; }
.big-score small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.journal { list-style: none; padding: 0; margin: 0; display: grid; gap: 12px; }
.journal li + li { border-top: 1px solid var(--border); padding-top: 12px; }
.journal p { margin: 2px 0 0; }
.crisis { background: var(--info-bg); color: var(--text); border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; font-size: .92rem; line-height: 1.5; }
.crisis a { color: var(--info); font-weight: 600; }
details summary { cursor: pointer; }

/* Snel noteren en staafjes */
.quick-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.bars { display: grid; gap: 6px; margin: 6px 0 10px; }
.bar-row { display: grid; grid-template-columns: minmax(120px, 42%) 1fr 28px; align-items: center; gap: 8px; font-size: .85rem; }
.bar-label { color: var(--text-2); }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

/* Voedingsdoelen */
.goals { display: grid; gap: 10px; margin: 6px 0 8px; }
.goal-head { display: flex; justify-content: space-between; gap: 8px; font-size: .92rem; }
.goal .progress { margin: 4px 0 0; }
.check-inline { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-size: .92rem; }
.check-inline input { width: 20px; height: 20px; min-height: 0; }

/* Drinken */
.fluid-big { font-size: 2rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.fluid-big small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.progress.over span { background: var(--bad); }
.quick-drinks { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.quick-drinks .btn small { color: var(--muted); font-weight: 500; }
.drink-list { list-style: none; padding: 0; margin: 6px 0; display: grid; gap: 2px; }
.drink-list li { display: grid; grid-template-columns: 48px 1fr auto 36px; align-items: center; gap: 8px; padding: 2px 0; border-bottom: 1px solid var(--border); }
.field.urine { margin-top: 12px; }
.field.urine select { width: auto; }

/* Afdrukken (medisch overzicht) */
@media print {
  .topbar, .no-print, .toast, .actions { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
  .container { max-width: none; padding: 0; }
}

/* Telefoon: melding boven de menubalk (na de algemene .toast-regel) */
@media (max-width: 640px) {
  .toast { bottom: calc(84px + env(safe-area-inset-bottom)); }
}
@media print {
  .nav, .subnav { display: none !important; }
  body { padding-bottom: 0; }
}

/* Verbanden */
.filter-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; margin-bottom: 6px; scrollbar-width: thin; }
.fchip { flex: none; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.fchip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.insights { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 10px; }
.insight { display: flex; gap: 10px; align-items: flex-start; }
.insight p { margin: 0 0 4px; }
.insight-icon { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: .8rem; background: var(--surface-2); color: var(--text-2); }
.insight.good .insight-icon { background: var(--good-bg); color: var(--good); }
.insight.bad .insight-icon { background: var(--bad-bg); color: var(--bad); }
.insight-body { flex: 1; min-width: 0; }
.insight-bar { height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; margin: 2px 0 4px; }
.insight-bar span { display: block; height: 100%; background: var(--muted); border-radius: 3px; }
.insight-bar span.good { background: var(--good); }
.insight-bar span.bad { background: var(--bad); }
.good-text { color: var(--good); font-size: 1rem; }
.bad-text { color: var(--bad); font-size: 1rem; }
.day-nav { display: flex; gap: 8px; align-items: center; }
.day-nav input { flex: 1; max-width: 220px; }
.day-nav .disabled { opacity: .4; pointer-events: none; }
.day-part .card-head h2 { font-size: 1.05rem; }

/* Nachtscherm (Slaapwel / 😴 / Goeiemorgen): altijd donker en gedimd, ook in licht thema */
#night-overlay {
  position: fixed; inset: 0; z-index: 110; background: #06070b; color: #9a9cb0; display: grid; place-items: center;
  padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); overflow-y: auto; color-scheme: dark;
}
.night-mode, .night-mode body { background: #06070b; }
.night-box { width: min(440px, 100%); text-align: center; display: grid; gap: 12px; justify-items: center; }
.night-box h2 { color: #c4c6d6; margin: 0; }
.night-clock { font-size: clamp(3.5rem, 20vw, 6rem); font-weight: 300; font-variant-numeric: tabular-nums; margin: 0; color: #6f7290; letter-spacing: -1px; }
.night-state { margin: 0; font-size: 1.05rem; color: #b4b6c8; }
.night-q { margin: 6px 0 0; }
.night-dim { color: #62647a; margin: 0; }
.night-btn {
  display: grid; justify-items: center; gap: 4px; width: 100%; max-width: 320px; padding: 18px; border-radius: 22px;
  border: 1px solid #262838; background: #11131c; color: #b4b6c8; font: inherit; font-size: 1.05rem; cursor: pointer;
}
.night-btn span { font-size: 2rem; line-height: 1; }
.night-btn.big { padding: 34px 18px; }
.night-btn.big span { font-size: 3.6rem; }
.night-btn.sun { border-color: #3a3322; color: #d8c79a; }
.night-btn:focus-visible, .night-chip:focus-visible, .night-link:focus-visible { outline: 3px solid #5c6bd6; outline-offset: 2px; }
.night-reasons { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.night-chip { padding: 8px 12px; border-radius: 999px; border: 1px solid #262838; background: #0d0f16; color: #9a9cb0; font: inherit; font-size: .9rem; cursor: pointer; }
.night-chip.on { background: #262a44; border-color: #3d4270; color: #d0d2e4; }
.night-link { background: none; border: 0; color: #7a7d98; text-decoration: underline; font: inherit; cursor: pointer; padding: 8px 4px; min-height: 44px; }
.night-foot { margin: 0; }

/* Sociale kring */
.circles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .circles { grid-template-columns: 1fr; } }
.circle-col { border-radius: 12px; padding: 10px 12px; background: var(--surface-2); }
.circle-col.circle-binnen { background: var(--bad-bg); }
.circle-col.circle-midden { background: var(--info-bg); }
.circle-col h3 { font-size: .95rem; margin: 0 0 6px; }
.circle-col .list li { padding: 4px 0; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-weight: 600; color: var(--primary); cursor: pointer; text-align: left; min-height: 32px; }
.warn-text { color: var(--warn); }
.social-row { display: flex; justify-content: space-between; gap: 10px; align-items: center; flex-wrap: wrap; }
.social-row .button-row { margin: 0; }

/* Back-up */
.backup-card.warn { border-left: 4px solid var(--warn); }
.backup-card.bad { border-left: 4px solid var(--bad); }
.backup-status.good { border-left: 4px solid var(--good); }
.backup-status.warn { border-left: 4px solid var(--warn); }
.backup-status.bad { border-left: 4px solid var(--bad); }
.backup-big { font-size: 1.1rem; font-weight: 600; margin: 0 0 4px; }
.safety-steps { padding-left: 22px; display: grid; gap: 10px; margin: 8px 0 0; }
.safety-steps li { line-height: 1.45; }
.safety-steps li.done::marker { content: '✓  '; color: var(--good); font-weight: 700; }
.type-choice .btn small { font-weight: 400; opacity: .85; }
.restore-btn { display: flex; flex-direction: column; align-items: flex-start; text-align: left; gap: 2px; width: 100%; height: auto; padding: 12px 16px; }
.restore-btn small { font-weight: 400; opacity: .9; }
