/* ── Tokens ──────────────────────────────────────────────────────────────
   Licht: koel saliepapier met donkergroene inkt. Geld is zonnebloemgeel,
   een gehaalde gewoonte bladgroen, alcohol wijnrood. */
:root {
  color-scheme: light;
  --paper:    #eef1ec;
  --surface:  #ffffff;
  --sunk:     #e3e8e2;
  --ink:      #17241f;
  --ink-2:    #3d4b45;
  --muted:    #5f6d66;
  --line:     #d3dbd4;
  --leaf:     #1f7a4d;
  --leaf-ink: #ffffff;
  --leaf-soft:#dcefe3;
  --coin:     #e9a800;
  --coin-soft:#fbefc6;
  --wine:     #b8383a;
  --wine-soft:#f6dede;
  --focus:    #1f6fd1;

  /* grafiekreeksen (gevalideerde volgorde) */
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --bar-off:  #b9c4bd;

  --font: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, sans-serif;
  --r-lg: 22px;
  --r-md: 16px;
  --r-sm: 10px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --paper:    #101815;
    --surface:  #18221e;
    --sunk:     #0c1310;
    --ink:      #e6ede8;
    --ink-2:    #c2cdc6;
    --muted:    #8e9e96;
    --line:     #2a3832;
    --leaf:     #3fb97a;
    --leaf-ink: #08130d;
    --leaf-soft:#173527;
    --coin:     #f2bb1d;
    --coin-soft:#3a3010;
    --wine:     #e36a6a;
    --wine-soft:#3a1d1e;
    --focus:    #6aa8f5;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --bar-off:  #3b4a43;
  }
}

/* ── Basis ───────────────────────────────────────────────────────────── */
* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font);
  font-optical-sizing: auto;
  font-size: 16px;
  line-height: 1.45;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }

:focus-visible { outline: 2.5px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.screen { min-height: 100dvh; }

/* ── Formulieren ─────────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 14px; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
.field small { font-size: 0.8rem; color: var(--muted); }

input[type="text"], input[type="password"], input[type="number"], input[type="date"] {
  width: 100%;
  min-height: 48px;
  padding: 11px 14px;
  font-size: 1rem;
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}
input:focus { border-color: var(--focus); }
input::placeholder { color: var(--muted); opacity: 0.7; }

.form-error {
  color: var(--wine);
  font-size: 0.9rem;
  font-weight: 500;
}

/* ── Knoppen ─────────────────────────────────────────────────────────── */
.btn {
  min-height: 48px;
  padding: 0 20px;
  border-radius: 999px;
  border: 1.5px solid transparent;
  font-size: 0.975rem;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s, background 0.15s;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--ink); color: var(--paper); }
.btn-secondary { background: var(--sunk); color: var(--ink); align-self: flex-start; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-danger { background: var(--wine-soft); color: var(--wine); }
.btn-block { width: 100%; }

.btn-text {
  background: none;
  border: none;
  padding: 8px 4px;
  font-weight: 700;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.icon-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { background: var(--sunk); color: var(--ink); }

/* ── Inloggen / account ──────────────────────────────────────────────── */
.auth { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-inner { width: 100%; max-width: 380px; }

.wordmark {
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}
.wordmark::before {
  content: '';
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--coin);
  box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--coin) 60%, var(--ink));
}

.auth-title {
  font-size: clamp(2.2rem, 9vw, 2.9rem);
  font-weight: 750;
  font-stretch: 80%;
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 40px 0 14px;
}
.auth-lead { color: var(--ink-2); margin-bottom: 28px; max-width: 34ch; }
#form-login { margin-top: 28px; }
.auth .btn-primary { margin-top: 8px; }

/* ── App-indeling ────────────────────────────────────────────────────── */
.tab-content {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(var(--safe-t) + 20px) 16px calc(var(--nav-h) + var(--safe-b) + 28px);
}

.page-title {
  font-size: 2.1rem;
  font-weight: 750;
  font-stretch: 82%;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 8px 0 20px;
}

.panel {
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 14px;
}
.panel h2 {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.005em;
  margin-bottom: 12px;
}
.panel .hint { color: var(--muted); font-size: 0.9rem; margin: -4px 0 16px; max-width: 60ch; }
.panel-danger h2 { color: var(--wine); }

/* ── Navigatie ───────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  padding: 6px 8px var(--safe-b);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tab {
  flex: 1;
  max-width: 140px;
  height: calc(var(--nav-h) - 12px);
  border: none;
  background: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--r-md);
}
.tab svg { width: 24px; height: 24px; }
.tab.active { color: var(--ink); }
.tab.active svg { stroke-width: 2.2; }

/* ── Spaarpot (het ene opvallende element) ───────────────────────────── */
.pot { padding: 12px 4px 22px; }
.pot-label { font-size: 1rem; font-weight: 600; color: var(--ink-2); }
.pot-amount {
  font-size: clamp(4rem, 21vw, 6.5rem);
  font-weight: 760;
  font-stretch: 75%;
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  margin: 6px 0 10px;
  position: relative;
  display: inline-block;
}
.pot-amount::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -4px;
  height: 6px;
  border-radius: 3px;
  background: var(--coin);
  transform-origin: left;
}
.pot-amount.earned::after { animation: coin-rail 0.9s cubic-bezier(.2,.8,.2,1); }
@keyframes coin-rail {
  0%   { transform: scaleX(0.15); }
  100% { transform: scaleX(1); }
}
.pot-week { color: var(--muted); font-size: 0.95rem; }
.pot-week strong { color: var(--ink); font-weight: 700; }

/* ── Weekstrip ───────────────────────────────────────────────────────── */
.week {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  margin-bottom: 14px;
}
.wd {
  border: none;
  background: transparent;
  border-radius: var(--r-md);
  padding: 8px 0 9px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  min-width: 0;
}
.wd-name { font-size: 0.75rem; font-weight: 600; }
.wd-num { font-size: 1.15rem; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.wd.is-today .wd-name { color: var(--ink); font-weight: 800; }
.wd.is-today .wd-num { text-decoration: underline 2.5px var(--coin); text-underline-offset: 4px; }
.wd[aria-selected="true"] { background: var(--surface); box-shadow: 0 0 0 1.5px var(--ink); }
.wd-marks { display: grid; grid-template-columns: repeat(2, 6px); gap: 3px; margin-top: 4px; }
.wd-marks i { width: 6px; height: 6px; border-radius: 50%; background: var(--line); }
.wd-marks i.on { background: var(--leaf); }
.wd-marks i.neg { background: var(--wine); }

/* ── Dag ─────────────────────────────────────────────────────────────── */
.day-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 4px 4px 12px; }
.day-title { font-size: 1.35rem; font-weight: 700; letter-spacing: -0.01em; }
.day-title span { color: var(--muted); font-weight: 500; }
.day-earned { font-size: 0.95rem; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.day-earned.plus { color: var(--ink); }

.habits { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

/* Bewegen: automatisch gemeten, daarom geen knop maar een meter */
.move {
  grid-column: 1 / -1;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 18px 18px 16px;
}
.move.met { box-shadow: inset 0 0 0 2px var(--leaf); }
.move-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.move-head svg { color: var(--leaf); }
.move-head h3 { font-size: 1.05rem; font-weight: 700; flex: 1; }
.status {
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  background: var(--sunk);
  color: var(--ink-2);
  display: inline-flex; align-items: center; gap: 4px;
}
.status svg { width: 16px; height: 16px; stroke-width: 2.4; }
.status.ok { background: var(--leaf); color: var(--leaf-ink); }

.meter + .meter { margin-top: 12px; }
.meter-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 0.9rem; }
.meter-name { color: var(--ink-2); }
.meter-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.meter-value span { color: var(--muted); font-weight: 500; }
.meter-bar { height: 8px; border-radius: 4px; background: var(--sunk); margin-top: 6px; overflow: hidden; }
.meter-bar i { display: block; height: 100%; border-radius: 4px; background: var(--ink-2); transition: width 0.5s cubic-bezier(.2,.8,.2,1); }
.meter.reached .meter-bar i { background: var(--leaf); }
.move-note { font-size: 0.85rem; color: var(--muted); margin-top: 2px; }
.move-received { font-size: 0.8rem; color: var(--muted); margin-top: 12px; font-variant-numeric: tabular-nums; }

/* Zelf afvinken */
.habit {
  position: relative;
  overflow: hidden;
  border: none;
  text-align: left;
  background: var(--surface);
  border-radius: var(--r-md);
  padding: 14px 12px 12px;
  min-height: 132px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.18s, color 0.18s, transform 0.1s;
}
.habit:active { transform: scale(0.96); }
.habit > svg { width: 26px; height: 26px; color: var(--ink-2); }
.habit-name { font-weight: 700; font-size: 0.975rem; line-height: 1.2; margin-top: auto; }
.habit-sub { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; line-height: 1.3; }
.habit-check {
  position: absolute;
  top: 12px; right: 12px;
  width: 26px; height: 26px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1.75px var(--line);
  display: grid; place-items: center;
}
.habit-check svg { width: 16px; height: 16px; stroke-width: 2.6; opacity: 0; transform: scale(0.5); transition: opacity 0.15s, transform 0.25s cubic-bezier(.3,1.6,.5,1); }

.habit[aria-pressed="true"] { background: var(--leaf); color: var(--leaf-ink); }
.habit[aria-pressed="true"] > svg,
.habit[aria-pressed="true"] .habit-sub { color: inherit; opacity: 0.85; }
.habit[aria-pressed="true"] .habit-check { box-shadow: none; background: var(--leaf-ink); color: var(--leaf); }
.habit[aria-pressed="true"] .habit-check svg { opacity: 1; transform: scale(1); }

.habit.negative[aria-pressed="true"] { background: var(--wine); color: #fff; }
.habit.negative[aria-pressed="true"] .habit-check { background: #fff; color: var(--wine); }
.habit.negative.at-limit { box-shadow: inset 0 0 0 1.75px var(--wine); }
.habit.negative.at-limit .habit-sub { color: var(--wine); }

.habit .ripple {
  position: absolute;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.18;
  transform: scale(0);
  animation: ripple 0.55s ease-out forwards;
  pointer-events: none;
}
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* ── Kerncijfers ─────────────────────────────────────────────────────── */
.figures {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}
.figure { background: var(--surface); border-radius: var(--r-md); padding: 14px; min-width: 0; }
.figure-value {
  font-size: 1.6rem;
  font-weight: 750;
  font-stretch: 85%;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.figure-value small { font-size: 0.6em; font-weight: 600; color: var(--muted); margin-left: 2px; }
.figure-label { font-size: 0.85rem; font-weight: 600; color: var(--ink-2); margin-top: 4px; line-height: 1.3; }
.figure-note { font-size: 0.8rem; color: var(--muted); line-height: 1.3; }

/* ── Gewicht ─────────────────────────────────────────────────────────── */
.weigh-in { background: var(--surface); border-radius: var(--r-lg); padding: 20px; margin-bottom: 14px; }
.weigh-value { display: flex; align-items: baseline; gap: 8px; border-bottom: 2px solid var(--line); margin-bottom: 16px; }
.weigh-value:focus-within { border-color: var(--focus); }
.weigh-value input {
  border: none;
  background: transparent;
  padding: 0;
  min-height: 0;
  border-radius: 0;
  font-size: 3.4rem;
  font-weight: 750;
  font-stretch: 78%;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  width: 100%;
}
.weigh-value input:focus { outline: none; }
.weigh-unit { font-size: 1.4rem; font-weight: 600; color: var(--muted); }
.weigh-row { display: flex; gap: 12px; align-items: flex-end; }
.field-inline { flex: 1; }
.weigh-in .form-error { margin-top: 10px; }

.rows { list-style: none; }
.rows li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  border-top: 1px solid var(--line);
}
.rows li:first-child { border-top: none; }
.row-main { flex: 1; color: var(--ink-2); }
.row-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.row-delta { font-size: 0.85rem; color: var(--muted); font-variant-numeric: tabular-nums; width: 60px; text-align: right; }

/* ── Grootboek van de spaarpot ───────────────────────────────────────── */
.ledger { list-style: none; font-variant-numeric: tabular-nums; }
.ledger li { display: flex; align-items: baseline; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); }
.ledger li:first-child { border-top: none; padding-top: 2px; }
.ledger-name { flex: 1; }
.ledger-calc { display: block; font-size: 0.82rem; color: var(--muted); }
.ledger-amount { font-weight: 650; white-space: nowrap; }
.ledger-amount.minus { color: var(--wine); }
.ledger li.ledger-total { border-top: 2px solid var(--ink); margin-top: 4px; padding-top: 14px; }
.ledger-total .ledger-name { font-weight: 700; }
.ledger-total .ledger-amount { font-size: 1.6rem; font-weight: 760; font-stretch: 80%; letter-spacing: -0.02em; }

/* ── Grafieken ───────────────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 210px; }
.chart-wrap-tall { height: 250px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.82rem; color: var(--ink-2); margin: -4px 0 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend i { width: 10px; height: 10px; border-radius: 3px; }
.chart-legend i.dash { width: 16px; height: 0; border-top: 2px dashed var(--ink-2); border-radius: 0; }

.chart-table { margin-top: 12px; font-size: 0.875rem; }
.chart-table summary { color: var(--ink-2); font-weight: 600; padding: 6px 0; }
.chart-table table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; margin-top: 6px; }
.chart-table th, .chart-table td { text-align: right; padding: 7px 0 7px 8px; border-top: 1px solid var(--line); }
.chart-table th { font-weight: 600; color: var(--muted); border-top: none; }
.chart-table th:first-child, .chart-table td:first-child { text-align: left; padding-left: 0; }

/* ── Instellingen ────────────────────────────────────────────────────── */
.secrets { margin-bottom: 14px; }
.secret {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
}
.secret:first-child { border-top: none; }
.secret dt { font-size: 0.875rem; color: var(--muted); }
.secret dd { min-width: 0; }
.secret code { word-break: break-all; user-select: all; -webkit-user-select: all; }
.hint code { background: var(--sunk); padding: 1px 5px; border-radius: 5px; }

.notice {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--coin-soft);
  border-radius: var(--r-sm);
  padding: 8px 8px 8px 14px;
  font-size: 0.9rem;
  margin-bottom: 14px;
}

/* ── Omlaag trekken om te vernieuwen ─────────────────────────────────── */
html, body { overscroll-behavior-y: contain; } /* eigen gebaar in plaats van dat van de browser */

.ptr {
  position: fixed;
  top: calc(var(--safe-t) - 40px);
  left: 50%;
  z-index: 70;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface);
  color: var(--muted);
  box-shadow: 0 4px 14px -4px rgba(10, 20, 15, 0.3);
  opacity: 0;
  transform: translate(-50%, 0);
  transition: transform 0.25s cubic-bezier(.2,.8,.2,1), opacity 0.2s, color 0.15s;
  pointer-events: none;
}
.ptr svg { width: 20px; height: 20px; stroke-width: 2.2; }
.ptr.pulling { transition: color 0.15s; }
.ptr.ready, .ptr.busy { color: var(--leaf); }
.ptr.busy svg { animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Melding, dialoog, update ────────────────────────────────────────── */
.toast, .update-banner {
  position: fixed;
  left: 16px; right: 16px;
  bottom: calc(var(--nav-h) + var(--safe-b) + 12px);
  max-width: 480px;
  margin: 0 auto;
  z-index: 60;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 52px;
  padding: 6px 10px 6px 18px;
  border-radius: var(--r-md);
  background: var(--ink);
  color: var(--paper);
  font-size: 0.95rem;
  font-weight: 500;
  box-shadow: 0 10px 30px -10px rgba(10, 20, 15, 0.45);
  animation: rise 0.25s cubic-bezier(.2,.8,.2,1);
}
.toast .btn-text, .update-banner .btn-text { color: var(--coin); }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }

.dialog {
  margin: auto;
  width: min(400px, calc(100% - 32px));
  border: none;
  border-radius: var(--r-lg);
  padding: 24px;
  background: var(--surface);
  color: var(--ink);
}
.dialog::backdrop { background: rgba(8, 14, 11, 0.5); }
.dialog h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 8px; }
.dialog p { color: var(--ink-2); margin-bottom: 22px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }
.dialog.danger #confirm-ok { background: var(--wine); color: #fff; }

.empty { color: var(--muted); font-size: 0.95rem; padding: 6px 0; }

/* ── Breder scherm ───────────────────────────────────────────────────── */
@media (min-width: 640px) {
  .tab-content { padding-top: 40px; }
  .habit { min-height: 148px; padding: 18px 16px 16px; }
}

/* Alleen op desktop zichtbaar */
.nav-brand, .nav-keys, .tab kbd { display: none; }

/* ── Muis ────────────────────────────────────────────────────────────── */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: color-mix(in srgb, var(--ink) 86%, var(--paper)); }
  .btn-secondary:hover { background: color-mix(in srgb, var(--sunk) 80%, var(--ink)); }
  .btn-ghost:hover { border-color: var(--ink-2); color: var(--ink); }
  .btn-danger:hover { background: color-mix(in srgb, var(--wine-soft) 80%, var(--wine)); }
  .btn-text:hover { text-decoration-thickness: 2px; }
  .icon-btn:hover { background: var(--sunk); color: var(--ink); }
  .tab:hover { color: var(--ink); }
  .wd:hover:not([aria-selected="true"]) { background: color-mix(in srgb, var(--surface) 55%, transparent); }
  .habit:not([aria-pressed="true"]):hover { box-shadow: inset 0 0 0 1.5px var(--ink-2); }
  .habit:not([aria-pressed="true"]):hover .habit-check { box-shadow: inset 0 0 0 1.75px var(--ink-2); }
  .habit.negative.at-limit:not([aria-pressed="true"]):hover { box-shadow: inset 0 0 0 1.75px var(--wine); }
  .chart-table summary { cursor: pointer; }
  .chart-table summary:hover { color: var(--ink); }
}

/* ── Desktop: zijbalk en meer kolommen ───────────────────────────────── */
@media (min-width: 1024px) {
  :root { --side-w: 232px; }

  .nav {
    top: 0; right: auto;
    width: var(--side-w);
    flex-direction: column;
    justify-content: flex-start;
    gap: 2px;
    padding: 28px 14px 24px;
    border-top: none;
    border-right: 1px solid var(--line);
  }
  .nav-brand { display: flex; padding: 0 12px; margin-bottom: 28px; }
  .tab {
    flex: none;
    max-width: none;
    height: 44px;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 12px;
    font-size: 0.95rem;
    border-radius: var(--r-sm);
  }
  .tab svg { width: 22px; height: 22px; }
  .tab span { flex: 1; text-align: left; }
  .tab.active { background: var(--surface); }
  .tab kbd, .nav-keys kbd {
    display: inline-grid;
    place-items: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    font: 600 0.72rem/1 var(--font);
    color: var(--muted);
    border: 1px solid var(--line);
    border-radius: 5px;
  }
  .tab kbd { opacity: 0; transition: opacity 0.15s; }
  .nav:hover .tab kbd, .nav:focus-within .tab kbd { opacity: 1; }
  .nav-keys {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
    padding: 0 12px;
    font-size: 0.8rem;
    line-height: 1.7;
    color: var(--muted);
  }

  .tab-content {
    max-width: 1120px;
    margin-left: var(--side-w);
    margin-right: 0;
    padding: 48px 48px 64px;
  }
  @media (min-width: 1400px) {
    .tab-content { margin-left: calc(var(--side-w) + (100vw - var(--side-w) - 1120px) / 2); }
  }

  .page-title { font-size: 2.5rem; margin: 0 0 28px; }
  .chart-wrap { height: 260px; }
  .chart-wrap-tall { height: 300px; }

  /* Dagboek: spaarpot en week links, de dag rechts */
  #tab-dashboard {
    display: grid;
    grid-template-columns: minmax(280px, min(30vw, 400px)) minmax(0, 1fr);
    gap: clamp(32px, 3.5vw, 48px);
    align-items: start;
  }
  .dash-side { position: sticky; top: 48px; }
  .pot { padding-top: 0; }
  .pot-amount { font-size: clamp(4.5rem, 6.5vw, 6.5rem); }
  .week { margin-bottom: 0; }
  .day-head { margin-top: 0; }
  .habit { min-height: 164px; }

  /* Gewicht: invoer en metingen links, grafiek rechts */
  #tab-weight {
    display: grid;
    grid-template-columns: minmax(320px, 400px) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr; /* lege ruimte naast de grafiek valt onder de metingen */
    column-gap: 24px;
    align-items: start;
  }
  #tab-weight > * { grid-column: 1; }
  #tab-weight > .page-title { grid-column: 1 / -1; }
  #tab-weight > .weight-chart {
    grid-column: 2;
    grid-row: 2 / span 3;
    position: sticky;
    top: 48px;
  }
  .weight-chart .chart-wrap { height: 380px; }

  /* Overzicht: twee kolommen panelen */
  #tab-stats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto 1fr;
    column-gap: 24px;
    align-items: start;
    grid-auto-flow: dense;
  }
  #tab-stats > .page-title { grid-column: 1 / -1; }
  #tab-stats > .ledger-panel { grid-row: span 2; }
  #tab-stats > .figures { grid-column: 2; }
  #tab-stats > .panel:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Instellingen: panelen naast elkaar */
  #tab-settings {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 24px;
    align-items: start;
    max-width: 960px;
  }
  #tab-settings > .page-title { grid-column: 1 / -1; }
  #btn-logout { grid-column: 1 / -1; width: auto; justify-self: start; margin-top: 10px; }

  /* Meldingen zitten niet meer boven een onderbalk */
  .toast, .update-banner {
    bottom: 24px;
    left: calc(var(--side-w) + 24px);
    right: 24px;
  }
}

@media (max-width: 360px) {
  .habits { grid-template-columns: 1fr 1fr; }
  .figures { grid-template-columns: 1fr 1fr; }
  .pair { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
