/* =========================================================================
   Planner – stylesheet (mobile first)
   Kaartkleuren aanpassen? Wijzig de --type-* variabelen hieronder
   (licht én donker). Tekstkleur (fg) staat op een lichte/donkere tint (bg)
   zodat het contrast ruim boven WCAG AA (4.5:1) blijft.
   ========================================================================= */

:root {
  /* --- Kaarttypes: accent (rand/icoon/balk), bg (achtergrond), fg (tekst) --- */
  --type-active-accent:   #e8590c;  /* Actieve inspanning – oranje/rood */
  --type-active-bg:       #fff0e6;
  --type-active-fg:       #5c1d00;
  --type-mental-accent:   #7c3aed;  /* Mentale inspanning – paars */
  --type-mental-bg:       #f1eafe;
  --type-mental-fg:       #36146e;
  --type-physrelax-accent:#2b8a3e;  /* Fysieke ontspanning – groen */
  --type-physrelax-bg:    #e6f6e9;
  --type-physrelax-fg:    #0d3d17;
  --type-mentrelax-accent:#1971c2;  /* Mentale ontspanning – blauw */
  --type-mentrelax-bg:    #e5f0fb;
  --type-mentrelax-fg:    #0b3157;

  /* --- Interface --- */
  --bg: #f4f5f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --text: #1b1f29;
  --muted: #5b6375;
  --line: #d9dde5;
  --line-soft: #eceef3;
  --primary: #2f4fd8;
  --primary-text: #ffffff;
  --danger: #c92a2a;
  --now: #e03131;
  --focus: #2f4fd8;
  --shadow: 0 1px 2px rgb(16 24 40 / .08), 0 2px 6px rgb(16 24 40 / .06);
  --shadow-lg: 0 10px 30px rgb(16 24 40 / .22);
  --banner-bg: #fff3bf;
  --banner-fg: #4a3800;
  --toast-bg: #20242e;
  --toast-fg: #f3f4f7;
  --toast-btn: #a9bcff;

  /* --- Maten (worden deels door JS gezet) --- */
  --axis-w: 44px;
  --head-h: 84px;
  --hour-h: 72px;
  --col-w: 160px;
  --days: 7;
  --radius: 10px;
  --tap: 44px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);

  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* ---------- Thema's ----------
   Zonder keuze (of 'auto') volgt de app het apparaat (licht/donker).
   Instellingen › Thema zet data-theme op <html>: light | bright | dark. */
:root[data-theme="dark"] {
    --type-active-accent:   #ee7432;
    --type-active-bg:       #3d1f10;
    --type-active-fg:       #ffe0cf;
    --type-mental-accent:   #a57cff;
    --type-mental-bg:       #2c1d4a;
    --type-mental-fg:       #ebe0ff;
    --type-physrelax-accent:#45b35e;
    --type-physrelax-bg:    #16331d;
    --type-physrelax-fg:    #d3f3da;
    --type-mentrelax-accent:#4ea3f0;
    --type-mentrelax-bg:    #132b44;
    --type-mentrelax-fg:    #d6e9fc;

    --bg: #14171f;
    --surface: #1c2029;
    --surface-2: #262b36;
    --text: #e8eaf0;
    --muted: #a0a8b8;
    --line: #313746;
    --line-soft: #232834;
    --primary: #7d97ff;
    --primary-text: #0d1020;
    --danger: #ff7b7b;
    --now: #ff6b6b;
    --focus: #9db0ff;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 2px 6px rgb(0 0 0 / .3);
    --shadow-lg: 0 10px 30px rgb(0 0 0 / .6);
    --banner-bg: #4a3a00;
    --banner-fg: #ffec99;
    --toast-bg: #e8eaf0;
    --toast-fg: #14171f;
    --toast-btn: #2f4fd8;
    color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]), :root[data-theme="auto"] {
    --type-active-accent:   #ee7432;
    --type-active-bg:       #3d1f10;
    --type-active-fg:       #ffe0cf;
    --type-mental-accent:   #a57cff;
    --type-mental-bg:       #2c1d4a;
    --type-mental-fg:       #ebe0ff;
    --type-physrelax-accent:#45b35e;
    --type-physrelax-bg:    #16331d;
    --type-physrelax-fg:    #d3f3da;
    --type-mentrelax-accent:#4ea3f0;
    --type-mentrelax-bg:    #132b44;
    --type-mentrelax-fg:    #d6e9fc;

    --bg: #14171f;
    --surface: #1c2029;
    --surface-2: #262b36;
    --text: #e8eaf0;
    --muted: #a0a8b8;
    --line: #313746;
    --line-soft: #232834;
    --primary: #7d97ff;
    --primary-text: #0d1020;
    --danger: #ff7b7b;
    --now: #ff6b6b;
    --focus: #9db0ff;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 2px 6px rgb(0 0 0 / .3);
    --shadow-lg: 0 10px 30px rgb(0 0 0 / .6);
    --banner-bg: #4a3a00;
    --banner-fg: #ffec99;
    --toast-bg: #e8eaf0;
    --toast-fg: #14171f;
    --toast-btn: #2f4fd8;
    color-scheme: dark;
  }
}
:root[data-theme="light"] { color-scheme: light; }

/* Extra licht: witte vlakken, zachtere lijnen en schaduwen, pastel kaartjes.
   Alle tekstcombinaties halen minstens WCAG AA (4,5:1). */
:root[data-theme="bright"] {
  --type-active-bg:       #fff6f0;
  --type-mental-bg:       #f7f2fe;
  --type-physrelax-bg:    #eefaf1;
  --type-mentrelax-bg:    #eef5fd;

  --bg: #fbfcfe;
  --surface: #ffffff;
  --surface-2: #f4f6fa;
  --text: #20263a;
  --muted: #5f6b80;
  --line: #e3e7ee;
  --line-soft: #f1f3f7;
  --primary: #3557e0;
  --focus: #3557e0;
  --shadow: 0 1px 2px rgb(16 24 40 / .05), 0 1px 4px rgb(16 24 40 / .04);
  --shadow-lg: 0 8px 24px rgb(16 24 40 / .14);
  --banner-bg: #fff8db;
  --toast-bg: #2b3142;
  color-scheme: light;
}

/* Typekoppeling: één plek die elke type-klasse aan zijn variabelen hangt */
.t-active_effort   { --accent: var(--type-active-accent);    --tbg: var(--type-active-bg);    --tfg: var(--type-active-fg); }
.t-mental_effort   { --accent: var(--type-mental-accent);    --tbg: var(--type-mental-bg);    --tfg: var(--type-mental-fg); }
.t-physical_relax  { --accent: var(--type-physrelax-accent); --tbg: var(--type-physrelax-bg); --tfg: var(--type-physrelax-fg); }
.t-mental_relax    { --accent: var(--type-mentrelax-accent); --tbg: var(--type-mentrelax-bg); --tfg: var(--type-mentrelax-fg); }

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: none; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { touch-action: manipulation; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
a { color: var(--primary); }
.small { font-size: .85rem; }
.noscript { padding: 2rem; text-align: center; }

/* ---------- Knoppen ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: var(--tap); padding: 0 1rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-weight: 600; white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--danger); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.icon-btn {
  display: inline-grid; place-items: center; width: var(--tap); height: var(--tap);
  border: 0; border-radius: 999px; background: transparent; color: var(--text); padding: 0;
}
.icon-btn:active, .btn:active { transform: scale(.97); }

/* ---------- Formulieren ---------- */
.field { display: flex; flex-direction: column; gap: .3rem; margin: 0 0 .9rem; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-size: .85rem; font-weight: 600; color: var(--muted); padding: 0; }
.field input, .field select {
  min-height: var(--tap); width: 100%; padding: .5rem .75rem; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font-size: 16px; /* voorkomt automatisch inzoomen op iOS */
}
.field-row { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: .5rem; }
.form-error { color: var(--danger); font-weight: 600; margin: .25rem 0 .75rem; }
.segmented { display: flex; gap: 4px; padding: 4px; background: var(--surface-2); border-radius: 12px; }
.segmented label { flex: 1; position: relative; }
.segmented input { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.segmented span {
  display: grid; place-items: center; min-height: 40px; border-radius: 9px; font-weight: 600; cursor: pointer;
}
.segmented input:checked + span { background: var(--surface); box-shadow: var(--shadow); }
.segmented input:focus-visible + span { outline: 3px solid var(--focus); }

/* ---------- Opstart en inloggen ---------- */
.splash { position: fixed; inset: 0; display: grid; place-items: center; }
.spinner { width: 36px; height: 36px; border-radius: 50%; border: 4px solid var(--line); border-top-color: var(--primary); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-view { min-height: 100dvh; display: grid; place-items: center; padding: 1.25rem; overflow: auto; }
.login-card {
  width: min(380px, 100%); background: var(--surface); border-radius: 18px; padding: 1.75rem 1.25rem;
  box-shadow: var(--shadow);
}
.login-card h1 { margin: .5rem 0 0; font-size: 1.6rem; }
.login-card .muted { margin: .2rem 0 1.4rem; }
.login-logo { border-radius: 14px; display: block; }

/* ---------- App-layout ---------- */
.app-view { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.topbar {
  flex: none; background: var(--surface); border-bottom: 1px solid var(--line);
  padding: var(--safe-top) max(4px, env(safe-area-inset-right)) 0 max(4px, env(safe-area-inset-left));
  z-index: 50;
}
.topbar-row { display: flex; align-items: center; gap: 2px; min-height: 52px; }
.week-label { flex: 1; min-width: 0; text-align: center; font-weight: 700; line-height: 1.15; }
.week-label small { display: block; font-weight: 500; color: var(--muted); font-size: .78rem; }
#btn-today { padding: 0 .7rem; }

.weekstrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 0 2px 6px; }
.weekstrip button {
  min-height: var(--tap); border: 0; border-radius: 10px; background: transparent; padding: 2px 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1;
  color: var(--muted); font-size: .72rem; font-weight: 600;
}
.weekstrip button b { font-size: .95rem; color: var(--text); }
.weekstrip button.in-view { background: var(--surface-2); color: var(--text); }
.weekstrip button.is-today b { color: var(--primary); }
.weekstrip button.is-today::after { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--primary); margin-top: 2px; }

.sync-banner {
  font-size: .82rem; text-align: center; padding: 4px 8px; background: var(--banner-bg); color: var(--banner-fg);
}

/* ---------- Bord ---------- */
.board {
  flex: 1; min-height: 0; position: relative; overflow: auto;
  scroll-snap-type: x mandatory; scroll-padding-left: var(--axis-w);
  overscroll-behavior: contain;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
.board:focus { outline: none; }
.board.no-snap { scroll-snap-type: none; }
.grid {
  display: grid;
  grid-template-columns: var(--axis-w) repeat(var(--days), var(--col-w));
  grid-template-rows: var(--head-h) var(--body-h);
  width: max-content; min-width: 100%;
  padding-bottom: calc(88px + var(--safe-bottom));
}
.corner { position: sticky; top: 0; left: 0; z-index: 40; background: var(--surface); border-bottom: 1px solid var(--line); }
.day-head {
  position: sticky; top: 0; z-index: 30; background: var(--surface);
  border-bottom: 1px solid var(--line); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; justify-content: center; gap: 3px; padding: 2px 6px 5px; min-width: 0;
}
.day-head-btn {
  display: flex; align-items: center; gap: 6px; min-height: 38px; border: 0; background: transparent;
  padding: 0 2px; border-radius: 8px; text-align: left; width: 100%;
}
.day-head-btn .dow { font-size: .8rem; text-transform: uppercase; color: var(--muted); font-weight: 700; letter-spacing: .03em; }
.day-head-btn .dom { font-size: 1.05rem; font-weight: 700; min-width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; }
.day-head-btn .total { margin-left: auto; font-size: .75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.day-head.is-today .dom { background: var(--primary); color: var(--primary-text); }
.day-sum { display: grid; gap: 2px; }
.day-pts { display: flex; gap: 4px; flex-wrap: nowrap; overflow: hidden; }
.pts {
  font-size: .68rem; font-weight: 700; padding: 1px 6px; border-radius: 999px; white-space: nowrap;
  font-variant-numeric: tabular-nums; line-height: 1.5;
}
.pts.is-effort { background: var(--text); color: var(--surface); }
.pts.is-relax { background: transparent; color: var(--text); box-shadow: inset 0 0 0 1.5px var(--text); }
.weekscore {
  display: flex; align-items: center; gap: 8px; padding: 0 10px 6px; font-size: .78rem; min-height: 26px;
}
.weekscore .ws-label { font-weight: 700; color: var(--muted); }
.weekscore .ws-unit { color: var(--muted); }
.weekscore .ws-bar { flex: 1; display: flex; gap: 2px; height: 8px; min-width: 40px; max-width: 360px; }
.weekscore .ws-bar i { display: block; min-width: 0; }
.weekscore .ws-bar .is-effort { background: var(--text); opacity: .8; border-radius: 4px 0 0 4px; }
.weekscore .ws-bar .is-relax { background: repeating-linear-gradient(45deg, var(--muted) 0 3px, transparent 3px 6px); border: 1px solid var(--muted); border-radius: 0 4px 4px 0; }
.day-sum i { display: block; height: 3px; border-radius: 2px; background: var(--accent); width: 0; transition: width .25s; }

.axis { position: sticky; left: 0; z-index: 20; background: var(--surface); border-right: 1px solid var(--line); }
.axis-label {
  position: absolute; right: 6px; transform: translateY(-50%); font-size: .7rem; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.axis-label:first-child { transform: none; }

.day-col {
  position: relative; scroll-snap-align: start; border-left: 1px solid var(--line);
  background-image:
    repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour-h)),
    repeating-linear-gradient(to bottom, var(--line-soft) 0 1px, transparent 1px calc(var(--hour-h) / 2));
  cursor: cell;
}
.day-col.is-today { background-color: color-mix(in srgb, var(--primary) 4%, transparent); }
.day-col.drop-target { background-color: color-mix(in srgb, var(--primary) 9%, transparent); }

.now-line { position: absolute; left: 0; right: 0; height: 2px; background: var(--now); z-index: 450; pointer-events: none; }
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--now); }

/* ---------- Kaartjes ---------- */
.card {
  position: absolute; border-radius: 8px; color: var(--tfg); background: var(--tbg);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-left: 4px solid var(--accent);
  box-shadow: var(--shadow);
  touch-action: pan-x pan-y; /* gewoon scrollen blijft werken; slepen start pas na long-press */
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  cursor: grab; outline-offset: 1px;
  transition: opacity .15s, box-shadow .15s;
}
.card-inner { height: 100%; overflow: hidden; padding: 2px 5px 2px 5px; font-size: .74rem; line-height: 1.25; }
.card-head { display: flex; align-items: center; gap: 3px; min-width: 0; }
.card-head svg { width: 13px; height: 13px; color: var(--accent); stroke-width: 2.4; }
.card-type { font-weight: 700; font-size: .66rem; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-time { margin-left: auto; font-size: .66rem; font-variant-numeric: tabular-nums; white-space: nowrap; opacity: .85; }
.card-title { font-weight: 700; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.card-snippet { opacity: .85; margin-top: 1px; overflow: hidden; word-break: break-word; }
.card-check { font-size: .68rem; font-weight: 600; margin-top: 1px; }

/* compact: kort kaartje → alles op één regel */
.card.is-compact .card-inner { display: flex; align-items: center; gap: 4px; padding-top: 0; padding-bottom: 0; }
.card.is-compact .card-head { flex: none; }
.card.is-compact .card-type, .card.is-compact .card-snippet, .card.is-compact .card-check { display: none; }
.card.is-compact .card-title { -webkit-line-clamp: 1; flex: 1; min-width: 0; font-size: .74rem; order: 1; }
.card.is-compact .card-time { order: 2; margin-left: 0; }
.card.is-tiny .card-time { display: none; }
/* smal: tijd onder het typelabel i.p.v. ernaast */
.card.is-narrow:not(.is-compact) .card-head { flex-wrap: wrap; }
.card.is-narrow:not(.is-compact) .card-type { flex: 1; min-width: 0; }
.card.is-narrow:not(.is-compact) .card-time { flex-basis: 100%; margin-left: 0; order: 3; }

.card.is-stacked { opacity: .86; }
.card.is-stacked.is-front, .card.is-selected { opacity: 1; }
.card.is-selected { box-shadow: 0 0 0 2px var(--accent), var(--shadow-lg); }
.card.drag-source { opacity: .3 !important; }

.card-resize {
  position: absolute; left: 0; right: 0; bottom: -4px; height: 12px; cursor: ns-resize;
  touch-action: none; z-index: 2;
}
.card-resize::after {
  content: ""; position: absolute; left: 50%; bottom: 5px; width: 26px; height: 4px; margin-left: -13px;
  border-radius: 2px; background: var(--accent); opacity: 0; transition: opacity .15s;
}
.card:hover .card-resize::after, .card.is-selected .card-resize::after { opacity: .8; }

/* Touch: de resize-greep verschijnt pas als een kaartje geselecteerd is (eerste tik),
   en is dan groot genoeg om met een vinger te pakken. */
@media (pointer: coarse) {
  .card-resize { display: none; }
  .card.is-selected .card-resize { display: block; height: 30px; bottom: -15px; }
  .card.is-selected .card-resize::after { bottom: 11px; width: 34px; height: 6px; margin-left: -17px; opacity: 1; }
}

.drag-preview {
  position: absolute; left: 3px; right: 3px; z-index: 500; pointer-events: none;
  border-radius: 8px; border: 2px dashed var(--accent); background: color-mix(in srgb, var(--tbg) 85%, transparent);
  color: var(--tfg); box-shadow: var(--shadow-lg); padding: 2px 6px; font-size: .75rem; font-weight: 700;
  display: flex; align-items: flex-start; gap: 4px;
}
.drag-preview svg { width: 14px; height: 14px; color: var(--accent); }
.board.is-dragging { cursor: grabbing; }
.board.is-dragging .card { cursor: grabbing; }

/* ---------- FAB ---------- */
.fab {
  position: fixed; right: max(16px, env(safe-area-inset-right)); bottom: calc(16px + var(--safe-bottom));
  width: 60px; height: 60px; border-radius: 50%; border: 0; z-index: 60;
  background: var(--primary); color: var(--primary-text); box-shadow: var(--shadow-lg);
  display: grid; place-items: center;
}
.fab svg { width: 28px; height: 28px; stroke-width: 2.5; }

/* ---------- Dialogen / bottom-sheets ---------- */
dialog.sheet {
  padding: 0; border: 0; margin: 0; max-width: 100%; max-height: 100%;
  width: 100%; background: var(--surface); color: var(--text);
  position: fixed; inset: auto 0 0 0; border-radius: 18px 18px 0 0;
  box-shadow: var(--shadow-lg); overscroll-behavior: contain;
}
dialog.sheet[open] { animation: sheet-up .22s cubic-bezier(.2, .8, .2, 1); }
dialog.sheet::backdrop { background: rgb(10 12 20 / .45); }
@keyframes sheet-up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
dialog.sheet-full { height: 100%; height: 100dvh; inset: 0; border-radius: 0; }
dialog.sheet-small { max-height: 85dvh; }
.sheet-inner { display: flex; flex-direction: column; height: 100%; max-height: inherit; }
.sheet-header {
  flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .5rem;
  padding: calc(6px + var(--safe-top)) 8px 6px; border-bottom: 1px solid var(--line);
}
.sheet-small .sheet-header { padding-top: 8px; grid-template-columns: 1fr auto; padding-left: 16px; }
.sheet-small .sheet-header h2 { text-align: left; }
.sheet-header h2 { margin: 0; font-size: 1.05rem; text-align: center; }
.sheet-header > :first-child { justify-self: start; }
.sheet-header > :last-child { justify-self: end; }
.sheet-sub { margin: .6rem 1rem 0; }
.editor-body { flex: 1; overflow: auto; padding: 1rem 1rem 1.25rem; -webkit-overflow-scrolling: touch; }
.editor-body h3 { font-size: .95rem; margin: 1.4rem 0 .6rem; }
.editor-body h3:first-child { margin-top: 0; }
.sheet-footer {
  flex: none; display: flex; justify-content: space-between; gap: .5rem;
  padding: 8px 8px calc(8px + var(--safe-bottom)); border-top: 1px solid var(--line);
}
.app-version { margin-top: 2rem; }

.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 1rem 1rem calc(1rem + var(--safe-bottom)); }
.type-choice {
  min-height: 84px; border-radius: 14px; border: 2px solid var(--accent); background: var(--tbg); color: var(--tfg);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 6px; padding: 10px 12px;
  font-weight: 700; text-align: left;
}
.type-choice svg { color: var(--accent); width: 26px; height: 26px; }

.type-segments { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; border: 0; padding: 0; margin: 0 0 1rem; }
.type-segments label { position: relative; }
.type-segments input { position: absolute; opacity: 0; pointer-events: none; }
.type-segments span {
  display: flex; align-items: center; gap: 6px; min-height: var(--tap); padding: 6px 10px; border-radius: 10px;
  border: 2px solid transparent; background: var(--tbg); color: var(--tfg); font-weight: 600; font-size: .88rem; cursor: pointer;
}
.type-segments svg { color: var(--accent); width: 20px; height: 20px; }
.type-segments input:checked + span { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.type-segments input:checked + span::after { content: "✓"; margin-left: auto; color: var(--accent); font-weight: 800; }
.type-segments input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }

.summary-list { list-style: none; margin: 0; padding: .5rem 1rem calc(1rem + var(--safe-bottom)); }
.summary-list li { display: flex; align-items: center; gap: 10px; padding: .55rem 0; border-bottom: 1px solid var(--line-soft); }
.summary-list li:last-child { border-bottom: 0; font-weight: 700; }
.summary-list svg { color: var(--accent); }
.summary-list .bar { flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.summary-list .bar i { display: block; height: 100%; background: var(--accent); }
.summary-list .val { min-width: 4.5em; text-align: right; font-variant-numeric: tabular-nums; }
.summary-list .lbl { min-width: 9.5em; }

/* ---------- Rich-text-editor (Quill) ---------- */
.rte { border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.rte .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--line); padding: 4px; display: flex; flex-wrap: wrap; font-family: inherit; }
.rte .ql-toolbar.ql-snow .ql-formats { margin-right: 6px; display: inline-flex; }
.rte .ql-snow.ql-toolbar button { width: 40px; height: 40px; padding: 9px; border-radius: 8px; }
.rte .ql-snow.ql-toolbar button.ql-active { background: var(--surface-2); }
.rte .ql-container.ql-snow { border: 0; font-family: inherit; font-size: 1rem; }
.rte .ql-editor { min-height: 180px; padding: 12px; -webkit-user-select: text; user-select: text; }
.rte .ql-editor.ql-blank::before { color: var(--muted); font-style: normal; }
.rte .ql-snow .ql-stroke { stroke: currentColor; }
.rte .ql-snow .ql-fill { fill: currentColor; }
.rte .ql-snow.ql-toolbar button:hover .ql-stroke, .rte .ql-snow.ql-toolbar button.ql-active .ql-stroke { stroke: var(--primary); }
.rte .ql-snow.ql-toolbar button:hover .ql-fill, .rte .ql-snow.ql-toolbar button.ql-active .ql-fill { fill: var(--primary); }
.rte .ql-snow .ql-tooltip {
  background: var(--surface); color: var(--text); border-color: var(--line); box-shadow: var(--shadow-lg);
  z-index: 10; border-radius: 10px; left: 8px !important; max-width: calc(100% - 16px);
}
.rte .ql-snow .ql-tooltip input[type=text] { background: var(--surface); color: var(--text); border-color: var(--line); font-size: 16px; height: 36px; width: 180px; max-width: 50vw; }
.rte .ql-snow a { color: var(--primary); }
@media (pointer: coarse) {
  .rte .ql-snow.ql-toolbar button { width: var(--tap); height: var(--tap); padding: 11px; }
}

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; left: 0; right: 0; bottom: calc(88px + var(--safe-bottom)); z-index: 1000;
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px;
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px; max-width: 520px; width: max-content;
  background: var(--toast-bg); color: var(--toast-fg); padding: 6px 6px 6px 16px; border-radius: 12px; box-shadow: var(--shadow-lg);
  animation: toast-in .2s ease-out; font-size: .92rem; min-height: var(--tap);
}
.toast.is-error { background: #a61e1e; color: #fff; }
.toast button { background: transparent; border: 0; color: var(--toast-btn); font-weight: 700; min-height: 40px; padding: 0 10px; border-radius: 8px; }
.toast.is-error button { color: #fff; text-decoration: underline; }

@keyframes toast-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Terugblik ---------- */
.stats-view { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; background: var(--bg); }
.stats-toprow { gap: 6px; }
.stats-title { font-size: 1.1rem; margin: 0; flex: 1; }
.stats-navrow { border-top: 1px solid var(--line-soft); }
.segmented > button {
  flex: 1; min-height: 36px; border: 0; border-radius: 9px; background: transparent; font-weight: 600; padding: 0 .7rem;
}
.segmented > button[aria-pressed="true"] { background: var(--surface); box-shadow: var(--shadow); }
.stats-periods { flex: none; }
.stats-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; }
.stats-body { max-width: 980px; margin: 0 auto; padding: 14px 12px calc(24px + var(--safe-bottom)); display: grid; gap: 14px; }
.stats-body[aria-busy="true"] { opacity: .6; }
.stats-body section { background: var(--surface); border-radius: 14px; padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.stats-body h3 { margin: 0; font-size: .95rem; }
.stats-empty { text-align: center; padding: 40px 12px; }
.stats-hero { display: grid; gap: 12px; }
.stats-hero-num { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stats-balance-labels { display: flex; justify-content: space-between; gap: 8px; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.stats-balance-bar { display: flex; gap: 2px; height: 12px; }
.stats-balance-bar i { display: block; min-width: 0; }
.stats-balance-bar .is-effort { background: var(--text); opacity: .75; border-radius: 4px 0 0 4px; }
.stats-balance-bar .is-relax { background: repeating-linear-gradient(45deg, var(--muted) 0 3px, transparent 3px 6px); border: 1px solid var(--muted); border-radius: 0 4px 4px 0; }
.stats-tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; background: transparent !important; box-shadow: none !important; padding: 0 !important; }
.stats-tile { background: var(--surface); border-radius: 14px; padding: 12px; box-shadow: var(--shadow); border-top: 4px solid var(--accent); min-width: 0; }
.stats-tile-head { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: .85rem; }
.stats-tile-head svg { color: var(--accent); width: 18px; height: 18px; }
.stats-points { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; grid-column: 1 / -1; }
.stats-points .pts { font-size: .8rem; padding: 2px 10px; }
.stats-tile-pts { font-weight: 700; font-size: .85rem; margin-bottom: 2px; }
.stats-tile-num { font-size: 1.5rem; font-weight: 800; margin: 4px 0 2px; font-variant-numeric: tabular-nums; }
.stats-chart-wrap { position: relative; }
.stats-chart-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.btn-small { min-height: 36px; padding: 0 .8rem; }
.stats-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; margin: 0 0 8px; padding: 0; font-size: .8rem; color: var(--text); }
.stats-legend li { display: flex; align-items: center; gap: 6px; }
.stats-legend i { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.stats-legend .is-future i { background: var(--muted); opacity: .4; }
.stats-chart { position: relative; }
.stats-chart svg { display: block; width: 100%; height: auto; overflow: visible; stroke: none; fill: none; }
.stats-chart text { stroke: none; }
.stats-chart .grid { stroke: var(--line-soft); stroke-width: 1; }
.stats-chart .axis-base { stroke: var(--line); stroke-width: 1; }
.stats-chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.stats-chart .tick.is-today { fill: var(--text); font-weight: 700; }
.stats-chart .seg { fill: var(--accent); }
.stats-chart .seg.is-future { opacity: .35; }
.stats-chart .hit { fill: transparent; cursor: pointer; }
.stats-chart .hit.is-active { fill: var(--text); fill-opacity: .05; }
.stats-tip {
  position: absolute; top: -6px; transform: translateY(-100%); z-index: 5; pointer-events: none;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-lg);
  padding: 8px 10px; font-size: .8rem; line-height: 1.5; min-width: 170px;
}
.stats-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; background: var(--accent); margin-right: 6px; }
.stats-tip-total { border-top: 1px solid var(--line-soft); margin-top: 4px; padding-top: 4px; font-weight: 700; }
.stats-table-wrap { overflow-x: auto; }
.stats-table { width: 100%; border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; }
.stats-table th, .stats-table td { padding: 6px 8px; border-bottom: 1px solid var(--line-soft); text-align: right; white-space: nowrap; }
.stats-table th[scope="row"], .stats-table thead th:first-child { text-align: left; }
.stats-table tr.is-future { color: var(--muted); }
.stats-top ol { list-style: none; margin: 8px 0 0; padding: 0; }
.stats-top li { display: grid; grid-template-columns: 22px minmax(0, 1fr) 30% auto; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line-soft); font-size: .88rem; }
.stats-top li:last-child { border-bottom: 0; }
.stats-top svg { color: var(--accent); width: 18px; height: 18px; }
.stats-top-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stats-top-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.stats-top-bar i { display: block; height: 100%; background: var(--accent); border-radius: 0 4px 4px 0; }
.stats-top-val { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ---------- Activiteiten waarderen ---------- */
.act-status { margin-left: auto; text-align: right; max-width: 45%; }
.act-body .act-section { display: block; }
.act-intro p { margin: 0 0 .5rem; }
.act-intro p:last-child { margin: 0; }
.act-list { list-style: none; margin: 8px 0 0; padding: 0; }
.act-row {
  display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; align-items: center; gap: 4px 8px;
  padding: 8px 0; border-bottom: 1px solid var(--line-soft);
}
.act-row:last-child { border-bottom: 0; }
.act-icon svg { color: var(--accent); width: 20px; height: 20px; }
.act-name, .act-name-static { min-width: 0; font-weight: 600; }
.act-name {
  min-height: 40px; border: 1px solid transparent; border-radius: 8px; background: transparent; padding: 0 6px; font-size: 16px;
}
.act-name:hover, .act-name:focus { border-color: var(--line); background: var(--surface); }
.act-row-extra { grid-column: 2 / -1; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.act-type { min-height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); padding: 0 6px; font-size: .85rem; max-width: 60%; }
.act-del { min-height: 36px; padding: 0 .6rem; font-size: .85rem; }
.act-group-head { display: flex; align-items: center; gap: 6px; }
.act-group-head svg { color: var(--accent); width: 20px; height: 20px; }
.act-group-head small { font-weight: 500; }
.act-toolbar { display: flex; }
.act-search { flex: 1; min-height: var(--tap); border-radius: 10px; border: 1px solid var(--line); background: var(--surface); padding: 0 .75rem; font-size: 16px; }
.act-add { display: grid; gap: 0 10px; grid-template-columns: 1fr; align-items: end; }
.act-add .field { margin-bottom: .6rem; }
.act-add select, .act-add input { min-height: var(--tap); }
.stepper { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-2); border-radius: 999px; padding: 2px; }
.stepper .icon-btn { width: 40px; height: 40px; font-size: 1.3rem; font-weight: 700; }
@media (pointer: coarse) { .stepper .icon-btn { width: var(--tap); height: var(--tap); } }
.stepper-val { min-width: 2.2em; text-align: center; font-weight: 800; font-variant-numeric: tabular-nums; }
.stepper-unit { font-size: .75rem; color: var(--muted); padding-right: 8px; }
@media (min-width: 700px) {
  .act-row { grid-template-columns: 26px minmax(0, 1fr) auto auto; }
  .act-row-extra { grid-column: auto; }
  .act-add { grid-template-columns: 2fr 1.4fr auto auto; }
}

/* ---------- CalDAV-instellingen ---------- */
.caldav-cred { grid-template-columns: 1fr 1fr; }
.check { display: flex; align-items: center; gap: 8px; min-height: var(--tap); font-size: .9rem; }
.check input { width: 20px; height: 20px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: .4rem 0; }
.caldav-box { border-radius: 10px; padding: 10px 12px; margin-bottom: .8rem; display: grid; gap: 2px; }
.caldav-box.is-ok { background: color-mix(in srgb, var(--type-physrelax-accent) 12%, var(--surface)); }
.caldav-box.is-error { background: color-mix(in srgb, var(--danger) 12%, var(--surface)); }

/* ---------- Home Assistant-instellingen ---------- */
.ha-steps { padding-left: 1.2rem; margin: .5rem 0 1rem; display: grid; gap: .4rem; }
.ha-steps code, .ha-created code { font-size: .85em; background: var(--surface-2); padding: 1px 4px; border-radius: 4px; word-break: break-all; }
.ha-new { grid-template-columns: 1fr auto; align-items: end; }
.ha-new .btn { margin-bottom: .9rem; }
.ha-created { background: var(--surface-2); border-radius: 10px; padding: 10px; margin-bottom: .8rem; }
.ha-copy { display: flex; gap: 6px; }
.ha-copy input { flex: 1; min-width: 0; min-height: var(--tap); padding: 0 .6rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-family: ui-monospace, monospace; font-size: 14px; }
.ha-tokens { list-style: none; margin: 0; padding: 0; }
.ha-tokens li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); }

/* ---------- Laptop / groter scherm ---------- */
@media (min-width: 700px) {
  .stats-tiles { grid-template-columns: repeat(4, 1fr); }
  .stats-hero { grid-template-columns: auto 1fr; align-items: center; gap: 24px; }
}
@media (min-width: 900px) {
  .weekstrip { display: none; }
  .weekscore { max-width: 1400px; margin: 0 auto; padding: 0 16px 8px; }
  .topbar-row { max-width: 1400px; margin: 0 auto; padding: 0 8px; }
  .week-label { text-align: left; padding-left: .5rem; font-size: 1.1rem; order: -1; }
  .week-label small { display: inline; margin-left: .5rem; }
  :root { --axis-w: 52px; }
  .card-inner { font-size: .78rem; }
}
@media (min-width: 700px) {
  dialog.sheet, dialog.sheet-full {
    inset: 0; margin: auto; width: min(600px, calc(100% - 32px)); height: fit-content; max-height: min(88dvh, 860px);
    border-radius: 16px;
  }
  dialog.sheet-full .sheet-inner { max-height: min(88dvh, 860px); }
  .sheet-header { padding-top: 8px; }
  .type-grid { grid-template-columns: repeat(4, 1fr); }
  .field-row { grid-template-columns: 1.4fr 1fr 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- Gebruikersbeheer en thema-keuze ---------- */
.segmented-wrap { flex-wrap: wrap; }
.segmented-wrap label { flex: 1 1 40%; }
@media (min-width: 500px) { .segmented-wrap label { flex: 1; } }
.badge {
  display: inline-block; font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px;
  background: var(--primary); color: var(--primary-text); vertical-align: middle;
}
.badge-soft { background: var(--surface-2); color: var(--text); }
.user-list { list-style: none; margin: 8px 0 0; padding: 0; }
.user-row { padding: 10px 0; border-bottom: 1px solid var(--line-soft); display: grid; gap: 4px; }
.user-row:last-child { border-bottom: 0; }
.user-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.user-row .btn-row { margin: 2px 0 0; }
.user-row .btn-row .btn { min-height: 40px; padding: 0 .7rem; font-size: .88rem; }
.user-confirm { background: var(--surface-2); border-radius: 10px; padding: 8px 10px; }
.user-confirm input, .pw-reveal input { flex: 1; min-width: 0; min-height: var(--tap); padding: 0 .6rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.pw-reveal { border: 2px solid var(--primary); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.user-add { grid-template-columns: 1fr; }
@media (min-width: 700px) { .user-add { grid-template-columns: 1.2fr 1.2fr auto auto; } }
.user-add .check { margin-bottom: .6rem; }

/* ---------- Updates ---------- */
.upd-file { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upd-pick { margin-top: .4rem; }
.upd-file:focus-visible + .upd-pick, .upd-pick:focus-within { outline: 3px solid var(--focus); }
.upd-sha { display: block; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; word-break: break-all;
  background: var(--surface-2); padding: 8px 10px; border-radius: 8px; user-select: all; -webkit-user-select: all; }
.upd-ok { color: var(--type-physrelax-accent); font-weight: 600; }
.upd-warn { color: var(--danger); font-weight: 600; }
.upd-apply { display: flex; gap: 8px; margin: .6rem 0; }
.upd-apply input { flex: 1; min-width: 0; min-height: var(--tap); padding: 0 .7rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 16px; }
.upd-status.is-ok { border-left: 4px solid var(--type-physrelax-accent); }
.upd-status.is-error { border-left: 4px solid var(--danger); }
.upd-status.is-busy { border-left: 4px solid var(--primary); }
.upd-spinner { width: 24px; height: 24px; border-width: 3px; margin: .4rem 0; }
.upd-log { max-height: 50vh; overflow: auto; background: var(--surface-2); border-radius: 8px; padding: 10px; font-size: .75rem;
  line-height: 1.45; white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  -webkit-user-select: text; user-select: text; }
.upd-status details summary { cursor: pointer; font-weight: 600; margin: .4rem 0; min-height: var(--tap); display: flex; align-items: center; }
