:root {
  --bg: #f3eee6;
  --card: #fffdf9;
  --text: #2c2433;
  --muted: #5c5366;
  --primary: #5e3f86;
  --primary-dark: #4a316c;
  --primary-soft: #f0e7f8;
  --btn: #6a4a94;
  --btn-text: #fff;
  --who-jacky: #9a3412;
  --who-ronald: #1d5559;
  --who-paps: #1d5559;
  --who-bren: #5b3d86;
  --who-jacky-ink: #9a3412;
  --who-ronald-ink: #1d5559;
  --who-paps-ink: #1d5559;
  --who-bren-ink: #5b3d86;
  --bubble-other: #fffdf9;
  --bubble-mine: #6a4a94;
  --danger: #c4374a;
  --danger-ink: #9d2436;
  --border: #e4dbd0;
  --header: #5c3d82;
  --header-text: #f7f2ea;
  --nav: #6a6274;
  --shadow: 0 1px 2px rgba(62, 40, 18, 0.05), 0 8px 24px rgba(62, 36, 18, 0.07);
  --radius: 18px;
  --icon-person: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Ccircle cx='12' cy='8' r='3.2' fill='black'/%3E%3Cpath fill='black' d='M5 19.2c1.4-3 3.8-4.4 7-4.4s5.6 1.4 7 4.4z'/%3E%3C/svg%3E");
  --icon-meds: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='8' y='3' width='8' height='18' rx='4' fill='black'/%3E%3C/svg%3E");
  --icon-tasks: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M5 6h14v2H5zm0 5h14v2H5zm0 5h9v2H5z'/%3E%3C/svg%3E");
  --icon-phone: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M8 3h8a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z'/%3E%3C/svg%3E");
  --icon-print: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M7 4h10v4H7zm-2 6h14a2 2 0 0 1 2 2v5h-4v3H7v-3H3v-5a2 2 0 0 1 2-2z'/%3E%3C/svg%3E");
  --icon-heart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 20s-7-4.4-7-9a4 4 0 0 1 7-2 4 4 0 0 1 7 2c0 4.6-7 9-7 9z'/%3E%3C/svg%3E");
  --icon-chart: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M5 19V9h3v10zm5 0V5h3v14zm5 0v-7h3v7z'/%3E%3C/svg%3E");
  --icon-bell: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M12 3a5 5 0 0 0-5 5v3.2L5 14.5V16h14v-1.5L17 11.2V8a5 5 0 0 0-5-5zm0 18a2.4 2.4 0 0 0 2.3-2h-4.6A2.4 2.4 0 0 0 12 21z'/%3E%3C/svg%3E");
  --icon-trash: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M8 7h8l-.7 13H8.7zM6 6h12v2H6zm3-3h6v2H9z'/%3E%3C/svg%3E");
  --icon-download: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M11 4h2v9l3.2-3.2 1.4 1.4L12 17l-5.6-5.8 1.4-1.4L11 13zM5 19h14v2H5z'/%3E%3C/svg%3E");
  --icon-type: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M4 6V4h16v2h-6.2v14h-3.6V6z'/%3E%3C/svg%3E");
  --icon-hands: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M8 11V5.5a1.5 1.5 0 0 1 3 0V11h1V4.5a1.5 1.5 0 0 1 3 0V12h1V7.5a1.5 1.5 0 0 1 3 0V15a6 6 0 0 1-6 6h-1.2A6 6 0 0 1 6 16.2V13a1.5 1.5 0 0 1 2-1.4z'/%3E%3C/svg%3E");
  --icon-out: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='black' d='M10 4H6v16h4v-2H8V6h2zm2 3.5 5 4.5-5 4.5V14H4v-4h8z'/%3E%3C/svg%3E");
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1816;
    --card: #2a2428;
    --text: #f6f1ea;
    --muted: #d5ccd8;
    --primary: #eadff8;
    --primary-dark: #f6eeff;
    --primary-soft: #3c314c;
    --btn: #cbb6ee;
    --btn-text: #24182f;
    --who-jacky: #9a3412;
    --who-ronald: #1d5559;
    --who-paps: #1d5559;
    --who-bren: #5b3d86;
    --who-jacky-ink: #ffc7b0;
    --who-ronald-ink: #b7ebe8;
    --who-paps-ink: #b7ebe8;
    --who-bren-ink: #e4d4ff;
    --bubble-other: #332c36;
    --bubble-mine: #cbb6ee;
    --danger-ink: #ffb4be;
    --border: #3d3540;
    --header: #3a2c4a;
    --header-text: #f7f2ea;
    --nav: #c8bfd0;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 10px 28px rgba(0, 0, 0, 0.28);
  }
}

* { box-sizing: border-box; }

html { font-size: 17px; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}
h1, h2, h3 { letter-spacing: -0.02em; line-height: 1.25; }

[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Login ---------- */

#login-view {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
  background:
    radial-gradient(900px 420px at 50% -8%, #efe2cf 0%, transparent 62%),
    var(--bg);
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.login-card { width: 100%; max-width: 380px; padding: 24px 22px 20px; }
.login-card form { text-align: left; }
.login-brand { display: flex; align-items: center; gap: 14px; padding-bottom: 18px; border-bottom: 1px solid var(--border); }
.login-brand h1 { margin: 0; font-size: 1.6rem; line-height: 1.1; letter-spacing: -0.01em; }
.login-brand p { margin: 2px 0 0; font-size: 0.95rem; }
.logo { width: 52px; height: 52px; flex: none; }
h1 { margin: 8px 0 4px; }
.muted { color: var(--muted); margin-top: 0; }
.login-greet { margin: 20px 0 12px; font-size: 1.25rem; }
.login-hint { font-size: 0.9rem; margin: 10px 0 0; }
.login-note { font-size: 0.85rem; margin: 8px 0 0; text-align: center; }
.login-foot { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.login-foot .emergency-call { margin: 0; text-align: center; }
.password-wrap { position: relative; }
.password-wrap input { padding-right: 52px; }
.password-toggle {
  position: absolute;
  top: 0;
  right: 0;
  width: 48px;
  height: 100%;
  min-height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  color: var(--muted);
  border-radius: 0 10px 10px 0;
  padding: 0;
}
.password-toggle svg { width: 22px; height: 22px; }
.password-toggle[aria-pressed="true"] { color: var(--primary); }
.error { color: var(--danger); margin: 8px 0 0; }

label { display: block; font-weight: 600; margin: 14px 0 6px; font-size: 0.92rem; }

input, textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: max(16px, 1rem);
}
textarea { resize: vertical; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primary); border-color: transparent; }

button, .chip, .tab, .user-btn, summary {
  min-height: 44px;
}
button {
  font: inherit;
  border: none;
  border-radius: 10px;
  padding: 10px 16px;
  cursor: pointer;
}
button:disabled { opacity: 0.6; cursor: wait; }

.primary { background: var(--btn); color: var(--btn-text); font-weight: 700; }
.primary:hover { background: var(--primary-dark); }
.login-card .primary { width: 100%; margin-top: 18px; padding: 13px; }
.ghost { background: transparent; color: var(--primary); font-weight: 600; }
.danger { background: transparent; color: var(--danger-ink); font-weight: 600; }

.user-picker { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.user-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  color: var(--text);
  border: 2px solid transparent;
  border-radius: 14px;
  font-weight: 700;
  padding: 12px 4px 10px;
  min-width: 0;
}
.user-btn .avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--card);
  color: var(--primary);
  border: 1px solid var(--border);
  font-size: 1.05rem;
  font-weight: 800;
}
.user-btn.selected { border-color: var(--btn); background: var(--primary-soft); color: var(--text); }
.user-btn.selected .avatar { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }

/* ---------- App shell ---------- */

#app-view {
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: calc(12px + env(safe-area-inset-top)) 14px 12px;
  background: linear-gradient(180deg, #6a4a94 0%, var(--header) 100%);
  color: var(--header-text);
  flex-shrink: 0;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.08);
}
.topbar h1 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 0;
  min-width: 0;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--header-text);
}
.topbar-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; min-width: 0; }
.topbar .ghost { color: var(--header-text); padding: 8px 10px; }
.pill { background: rgba(255,255,255,0.18); color: var(--header-text); padding: 4px 10px; border-radius: 999px; font-size: 0.9rem; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #ffb4b4; }
.dot.online { background: #6dffa8; }

.tab-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
}

.scroll {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 100px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}
.scroll > input[type="search"] { margin: 10px 0; }

.bottomnav {
  display: flex;
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(62, 36, 18, 0.04);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  position: relative;
  background: none;
  color: var(--nav);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 2px 8px;
  min-height: 58px;
  border-radius: 0;
}
.nav-icon { width: 26px; height: 26px; display: block; }
.nav-btn span { font-size: 0.78rem; font-weight: 700; }
.nav-btn.active { color: var(--primary); box-shadow: inset 0 3px 0 var(--btn); }
.badge-count {
  position: absolute;
  top: 4px;
  left: calc(50% + 6px);
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  min-width: 18px;
  padding: 1px 5px;
  border-radius: 999px;
}

.empty {
  text-align: center;
  color: var(--muted);
  margin: 20px 4px;
  padding: 28px 18px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 1rem;
  line-height: 1.45;
}
.empty::before {
  content: "";
  display: block;
  width: 26px;
  height: 26px;
  margin: 6px auto 20px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 14px var(--primary-soft);
  -webkit-mask: var(--icon-heart) center / 22px 22px no-repeat;
  mask: var(--icon-heart) center / 22px 22px no-repeat;
}
#messages .empty::before { -webkit-mask-image: var(--icon-bell); mask-image: var(--icon-bell); }
#diary-list .empty::before { -webkit-mask-image: var(--icon-type); mask-image: var(--icon-type); }
#meet-list .empty::before { -webkit-mask-image: var(--icon-tasks); mask-image: var(--icon-tasks); }

/* ---------- Chat ---------- */

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.messages > * { width: 100%; max-width: 760px; margin-left: auto; margin-right: auto; }

.day-sep { text-align: center; margin: 12px auto 6px; }
.day-sep span {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
}

.bubble-row { display: flex; }
.bubble-row.mine { justify-content: flex-end; }
.bubble {
  max-width: min(78%, 520px);
  background: var(--bubble-other);
  border: 1px solid var(--border);
  border-radius: 16px 16px 16px 4px;
  padding: 7px 11px 5px;
}
.mine .bubble {
  background: var(--bubble-mine);
  border-color: transparent;
  color: #fff;
  border-radius: 16px 16px 4px 16px;
  box-shadow: var(--shadow);
}
.bubble-author { font-size: 0.78rem; font-weight: 700; color: var(--primary); margin-bottom: 2px; }
.bubble-row.who-jacky .bubble-author { color: var(--who-jacky-ink); }
.bubble-row.who-ronald .bubble-author,
.bubble-row.who-paps .bubble-author { color: var(--who-ronald-ink); }
.bubble-row.who-bren .bubble-author { color: var(--who-bren-ink); }
.bubble-row:not(.mine).who-jacky .bubble { border-left: 4px solid var(--who-jacky); }
.bubble-row:not(.mine).who-ronald .bubble,
.bubble-row:not(.mine).who-paps .bubble { border-left: 4px solid var(--who-ronald); }
.bubble-row:not(.mine).who-bren .bubble { border-left: 4px solid var(--who-bren); }
.mine.who-jacky .bubble { background: var(--who-jacky); }
.mine.who-ronald .bubble,
.mine.who-paps .bubble { background: var(--who-ronald); }
.mine.who-bren .bubble { background: var(--who-bren); }
.bubble-row.mine.who-jacky .bubble-author,
.bubble-row.mine.who-ronald .bubble-author,
.bubble-row.mine.who-paps .bubble-author,
.bubble-row.mine.who-bren .bubble-author,
.bubble-row.mine.who-other .bubble-author,
.bubble-row.mine .bubble-body,
.bubble-row.mine .bubble-time { color: #fff; }
.bubble-body { white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble-time { font-size: 0.75rem; text-align: right; margin-top: 2px; color: var(--muted); }
.pdf-note { margin: 0 0 8px; color: var(--muted); font-size: 0.85rem; line-height: 1.35; }
#tab-chat .pdf-note { margin: 0; padding: 6px 16px 0; background: var(--card); }

.composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  padding: 8px 12px;
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.composer textarea { resize: none; max-height: 140px; border-radius: 20px; padding: 10px 14px; }
.send { width: 48px; height: 48px; border-radius: 50%; padding: 0; flex-shrink: 0; display: grid; place-items: center; }
.send svg { width: 22px; height: 22px; display: block; }

/* ---------- Dagboek ---------- */

.diary-compose label { margin-top: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 14px; }
.chip {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 600;
  font-size: 0.88rem;
}
.chip.active { background: var(--btn); border-color: var(--btn); color: var(--btn-text); }

.list { display: grid; gap: 10px; }
.list-day { margin: 10px 0 0; font-size: 0.85rem; color: var(--muted); text-transform: capitalize; }
.chip-label { margin: 10px 0 4px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.entry.important { border-color: #e0b15a; box-shadow: 0 0 0 1px #e0b15a, var(--shadow); }
.entry.editable { cursor: pointer; }
.entry.editable:hover { border-color: var(--primary); }
.entry-author { font-size: 1rem; }
.entry-author.who-jacky { color: var(--who-jacky-ink); }
.entry-author.who-ronald { color: var(--who-ronald-ink); }
.entry-author.who-bren { color: var(--who-bren-ink); }
.entry-body { margin: 8px 0 0; font-size: 1.05rem; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.entry-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.entry-cat, .entry-flag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}
.entry-cat { background: var(--bg); color: var(--muted); }
.entry-flag { background: #ffe7b3; color: #7a5200; }

/* ---------- Overleg ---------- */

.tabs { display: flex; gap: 6px; }
.tab { flex: 1; background: var(--card); color: var(--text); border: 1px solid var(--border); font-weight: 700; box-shadow: var(--shadow); padding: 8px 4px; font-size: 0.92rem; }
.day-nav { display: flex; gap: 8px; align-items: center; margin-top: 12px; }
.day-nav .ghost { min-width: 44px; padding: 8px; }
.day-nav input { flex: 1; }
.day-picks { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin: 8px 0 12px; }
.day-pick {
  min-height: 52px;
  padding: 4px 0;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.1;
}
.day-pick span { display: block; font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.day-pick.active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
.day-pick.active span { color: var(--btn-text); }
.tab.active { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }

a[href^="tel:"]:not(.emergency-call) {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}
.item { cursor: pointer; }
.item:hover { border-color: var(--primary); }
.item-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.item-title { font-weight: 700; font-size: 1.05rem; margin: 0; overflow-wrap: anywhere; }
.item-date { color: var(--primary); font-weight: 600; font-size: 0.85rem; }
.item-who { color: var(--muted); font-size: 0.85rem; margin: 4px 0 0; }
.kind-label { margin: 6px 0 0; font-size: 0.85rem; font-weight: 600; color: var(--primary); }
.ics-btn { margin-top: 10px; min-height: 44px; padding-left: 0; }
.item-section { margin-top: 10px; }
.item-section h4 { margin: 0 0 4px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.item-section p { margin: 0; white-space: pre-wrap; }
.item-section ul { margin: 0; padding-left: 20px; }
.item-meta { margin-top: 10px; font-size: 0.8rem; color: var(--muted); }
.badge { display: inline-block; font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; background: #ffe7b3; color: #7a5200; margin-left: 6px; }

.meet-tabs { margin-top: 0; }
#tab-meet .cal {
  flex-shrink: 0;
  margin: 8px 16px 0;
  max-height: 480px;
  opacity: 1;
  overflow: hidden;
  transition: max-height .22s ease, opacity .16s ease, margin-top .22s ease;
}
#tab-meet .cal.is-away {
  max-height: 0;
  opacity: 0;
  margin-top: 0;
  pointer-events: none;
}
.cal-show { width: 100%; margin: 0 0 8px; }
.install-bar {
  position: fixed;
  z-index: 40;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
}
body:has(#app-view:not([hidden])) .install-bar { bottom: calc(78px + env(safe-area-inset-bottom)); }
.install-bar p { margin: 0 0 8px; }
.install-actions { display: flex; gap: 8px; }
.install-actions .primary, .install-actions .ghost { min-height: 44px; }
.meet-tabs .tab { min-height: 44px; font-size: 0.92rem; padding: 8px 4px; }
#add-btn { width: 100%; margin: 8px 0; }
#meet-search { width: 100%; margin: 0 0 8px; }
#meet-heading { margin-top: 4px; }
.cal { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 8px 8px 10px; margin: 0; }
.cal-head { display: flex; align-items: center; gap: 4px; }
.cal-head h2 { flex: 1; margin: 0; text-align: center; font-size: 1rem; text-transform: capitalize; }
.cal-head .ghost { min-width: 44px; min-height: 44px; font-size: 1.4rem; padding: 0; }
.cal-head input[type="date"] { width: 9.2rem; flex: 0 0 auto; min-height: 44px; padding: 6px 8px; }
.cal-dows, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dows { margin: 6px 0 4px; color: var(--muted); font-size: 0.72rem; font-weight: 700; text-align: center; }
.cal-day {
  min-height: 44px;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.1;
}
.cal-day i { font-style: normal; font-size: 0.65rem; font-weight: 800; color: var(--primary); }
.cal-day .task-dot {
  width: 7px;
  height: 7px;
  margin-top: 2px;
  border-radius: 50%;
  background: #d7c4f2;
  box-shadow: inset 0 0 0 1px rgba(94, 63, 134, 0.28);
}
.cal-day.on .task-dot { background: #3a2c4a; box-shadow: none; }
.cal-day.today { border-color: var(--btn); }
.cal-day.on { background: var(--btn); color: var(--btn-text); }
.cal-day.on i { color: inherit; }
.cal-empty { min-height: 44px; }
.chip-row { flex-wrap: nowrap; overflow-x: auto; margin-top: 8px; padding-bottom: 2px; }
.chip-row .chip { flex: 0 0 auto; }
.menu-label { margin: 16px 4px 0; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
.contact-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; cursor: pointer; }
.contact-copy { flex: 1 1 140px; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.contact-copy strong { font-size: 1rem; }
.contact-copy span { color: var(--muted); font-size: 0.88rem; }
.contact-phone { color: var(--text) !important; font-weight: 700; font-size: 1rem !important; }
.contact-actions { display: flex; gap: 8px; margin-left: auto; flex-shrink: 0; }
.contact-actions .ghost, .contact-actions .primary { min-height: 44px; padding: 8px 12px; }
a.contact-call[href^="tel:"],
a.contact-call[href^="mailto:"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  background: var(--btn);
  color: var(--btn-text);
  text-decoration: none;
}
.who-add-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.who-add-row input { flex: 1; min-width: 0; }
.who-add-row .primary { flex: 0 0 auto; }
.contact-add { width: 100%; margin: 8px 0 12px; }

.fab {
  position: absolute;
  right: 20px;
  bottom: 20px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 2rem;
  line-height: 1;
  padding: 0;
  box-shadow: 0 8px 20px rgba(92, 61, 130, 0.28);
}

dialog {
  width: min(560px, 94vw);
  max-height: 92dvh;
  overflow: auto;
  border: none;
  border-radius: var(--radius);
  background: var(--card);
  color: var(--text);
  padding: 20px;
}
dialog::backdrop { background: rgba(10, 8, 20, 0.55); }
dialog h2 { margin-top: 0; }

.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
@media (max-width: 420px) {
  .row { grid-template-columns: 1fr; }
  #editor-form .row { grid-template-columns: 1fr 1fr; }
}
.checks { display: flex; gap: 16px; flex-wrap: wrap; }
.checks label { font-weight: 500; margin: 0; display: flex; align-items: center; gap: 8px; min-height: 44px; }
.checks input { width: 24px; height: 24px; }

.dialog-buttons { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dialog-buttons button { flex: 0 1 auto; }
.spacer { flex: 1; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(80px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: #1d1b2c;
  color: white;
  padding: 10px 16px;
  border-radius: 10px;
  max-width: 90vw;
  z-index: 10;
}

/* ---------- Home / Meer ---------- */

.emergency-btn {
  width: 100%;
  background: var(--danger);
  color: white;
  font-weight: 700;
  font-size: 1.15rem;
  padding: 16px;
  min-height: 52px;
  margin-bottom: 12px;
  border-radius: 12px;
}
.emergency-btn:hover { filter: brightness(0.95); }

.home-card { margin-bottom: 12px; }
.home-card .notice { margin: 0 0 8px; }
.home-card textarea { margin-top: 8px; }
.stay-tile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  margin: 0 0 12px;
  min-height: 84px;
  color: var(--text);
}
.stay-copy { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stay-copy strong { font-size: 1.15rem; }
.stay-copy span { color: var(--muted); font-size: 0.9rem; }
.stay-address { color: var(--text) !important; font-size: 0.95rem !important; font-weight: 700; }
.home-link { margin: 0 0 12px; }
.house { position: relative; width: 64px; height: 64px; flex: none; color: var(--primary); }
.house svg { width: 64px; height: 64px; display: block; }
.house span {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 20px;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.15;
  color: var(--text);
  background: var(--card);
  border-radius: 6px;
}
.pencil {
  width: 44px;
  height: 44px;
  min-height: 44px;
  border-radius: 50%;
  padding: 0;
  background: transparent;
  color: var(--primary);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
.pencil svg { width: 18px; height: 18px; display: block; }
.stay-choices { display: grid; gap: 8px; }
.stay-choice {
  width: 100%;
  text-align: left;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 700;
}
.stay-choice.on { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
.stay-row { display: flex; gap: 8px; align-items: center; min-width: 0; }
.stay-row .stay-choice { flex: 1; min-width: 0; }
.stay-add { display: flex; gap: 8px; align-items: center; }
.stay-add input { flex: 1; min-width: 0; }
.stay-add .primary { flex-shrink: 0; }
.stay-nood { font-weight: 800; margin: 8px 0 12px; }
.present-now { font-size: 1.2rem; font-weight: 800; margin: 0 0 8px; }
.present-card.is-here { background: var(--card); border-left: 6px solid #2f7d4a; }
.shift-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.shift-actions button { width: 100%; font-weight: 700; }
.shift-actions button:disabled { cursor: default; }
#present-leave { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.dose-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.dose-slot { background: var(--bg); color: var(--text); border: 1px solid var(--border); font-weight: 700; }
.dose-slot.on { background: var(--btn); color: var(--btn-text); border-color: var(--btn); }
@media (prefers-color-scheme: dark) {
  .present-card.is-here { background: #1c3d2a; }
}
.stock-box, .stock-line, .stock-note { margin-top: 10px; }
.stock-forecast { margin: 4px 0 0; font-size: 0.95rem; line-height: 1.4; }
.stock-note { margin: 4px 0 0; color: var(--muted); font-size: 0.92rem; line-height: 1.4; }
.stock-box { border-radius: 14px; padding: 12px; }
.stock-box p { margin: 0; line-height: 1.4; }
.stock-box strong { display: block; font-size: 1rem; }
.stock-warn { background: #fff4e5; border: 1px solid #e0a15a; }
.stock-warn p, .stock-warn strong { color: #7a4a00; }
.stock-ordered { background: #eef8f0; border: 1px solid #8fbf9a; }
.stock-ordered p { color: #1d5538; }
.stock-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.stock-line p { margin: 0; flex: 1 1 10rem; line-height: 1.4; }
.stock-actions { display: grid; gap: 8px; margin-top: 10px; }
.stock-actions button, .stock-line button { width: 100%; min-height: 44px; font-weight: 700; }
.stock-actions .ghost, .stock-line button {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
}
.stock-warn .stock-actions .ghost {
  background: #fff8ee;
  color: #7a4a00;
  border: 1px solid #e0a15a;
}
.stock-line button { width: auto; flex: none; }
.stock-home { display: grid; gap: 8px; margin: 0 0 12px; }
.stock-home .stock-box { margin-top: 0; }
@media (prefers-color-scheme: dark) {
  .stock-warn { background: #3a2a18; border-color: #e0a15a; }
  .stock-warn p, .stock-warn strong { color: #ffd7a8; }
  .stock-warn .stock-actions .ghost { background: #4a3520; color: #ffd7a8; border-color: #e0a15a; }
  .stock-ordered { background: #1c3d2a; border-color: #8fbf9a; }
  .stock-ordered p { color: #d7f5e2; }
}
.home-card h2 { margin: 0 0 8px; font-size: 1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.card-head h2 { margin: 0; }
.plus-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--primary);
  color: var(--btn-text);
  font-size: 1.7rem;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.alert-dot {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #e23b4a;
  box-shadow: 0 0 0 2px var(--card);
}
.home-card .primary { margin-top: 8px; min-height: 44px; }
.empty-inline { color: var(--muted); margin: 0; font-size: 0.95rem; }

.home-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-top: 8px;
  min-height: 44px;
}
.home-row strong { font-size: 0.95rem; }
.home-row span { color: var(--muted); font-size: 0.85rem; }

.menu-list { display: grid; gap: 8px; }
.menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 10px 14px;
  min-height: 56px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.menu-item::before {
  content: "";
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
  margin: 7px;
  border-radius: 8px;
  background: var(--primary);
  box-shadow: 0 0 0 7px var(--primary-soft);
  -webkit-mask: var(--icon-person) center / 20px 20px no-repeat;
  mask: var(--icon-person) center / 20px 20px no-repeat;
}
.menu-item[data-go="meds"]::before { -webkit-mask-image: var(--icon-meds); mask-image: var(--icon-meds); }
.menu-item[data-go="tasks"]::before { -webkit-mask-image: var(--icon-tasks); mask-image: var(--icon-tasks); }
.menu-item[data-go="contacts"]::before { -webkit-mask-image: var(--icon-phone); mask-image: var(--icon-phone); }
.menu-item[data-go="print"]::before { -webkit-mask-image: var(--icon-print); mask-image: var(--icon-print); }
.menu-item[data-go="timeline"]::before { -webkit-mask-image: var(--icon-chart); mask-image: var(--icon-chart); }
.menu-item[data-go="wishes"]::before { -webkit-mask-image: var(--icon-heart); mask-image: var(--icon-heart); }
.menu-item[data-go="measure"]::before { -webkit-mask-image: var(--icon-chart); mask-image: var(--icon-chart); }
.menu-item[data-go="push"]::before { -webkit-mask-image: var(--icon-bell); mask-image: var(--icon-bell); }
.menu-item[data-go="trash"]::before { -webkit-mask-image: var(--icon-trash); mask-image: var(--icon-trash); }
#export-btn::before { -webkit-mask-image: var(--icon-download); mask-image: var(--icon-download); }
#large-text-btn::before { -webkit-mask-image: var(--icon-type); mask-image: var(--icon-type); }
.menu-item[data-go="support"]::before { -webkit-mask-image: var(--icon-hands); mask-image: var(--icon-hands); }
#logout-btn-more::before { -webkit-mask-image: var(--icon-out); mask-image: var(--icon-out); background: var(--danger-ink); }
.menu-item.danger { color: var(--danger); }
.back { margin-bottom: 8px; min-height: 44px; padding-left: 0; }

.nood-scroll { text-align: center; }
.emergency-call {
  display: block;
  background: var(--danger);
  color: white;
  font-weight: 800;
  font-size: 1.5rem;
  text-decoration: none;
  padding: 18px 14px;
  border-radius: 14px;
  margin: 8px 0;
  min-height: 56px;
}
.emergency-call.small { font-size: 1.05rem; padding: 12px; min-height: 48px; font-weight: 700; }
.nood-scroll { padding-bottom: 24px; }
.nood-scroll h2 { margin: 4px 0 8px; }
.nood-scroll h3 { margin: 12px 0 6px; font-size: 0.95rem; }
.nood-block { text-align: left; background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; margin-top: 10px; }
.nood-block p { margin: 0; white-space: pre-wrap; }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 600; min-height: 44px; }
.check-line input { width: 24px; height: 24px; }
.danger-badge { background: #ffd0d4; color: #8a1020; }
#eef-form .primary { margin-top: 12px; min-height: 44px; }
.notice {
  background: #fff6d8;
  color: #5c4a12;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.92rem;
}
@media (prefers-color-scheme: dark) {
  .notice { background: #3a3218; color: #f3e6b0; }
}
.section-title { font-size: 1.05rem; margin: 16px 0 8px; }
.stopped-box { margin-top: 16px; }
.stopped-box summary { font-weight: 700; cursor: pointer; min-height: 44px; display: flex; align-items: center; }
.scroll, .list, .task-card, .task-check, .item-head, .item-title { min-width: 0; }
.task-card { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 8px; cursor: default; max-width: 100%; }
.task-check { display: flex; gap: 10px; align-items: flex-start; flex: 1 1 100%; margin: 0; font-weight: 500; min-height: 44px; }
.task-check input { width: 24px; height: 24px; margin-top: 2px; flex-shrink: 0; }
.task-check span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.task-check strong, .task-check .item-who { overflow-wrap: break-word; }
.task-edit { margin-left: auto; }
.task-card.done strong { text-decoration: line-through; color: var(--muted); }
.task-card.late { border-color: var(--danger); }
.task-card.late .item-who { color: var(--danger); font-weight: 700; }
.task-edit { min-height: 44px; flex-shrink: 0; }
.status-for, .ics-btn { display: flex; align-items: center; width: 100%; text-align: left; }
#make-tasks { margin-top: 8px; min-height: 44px; }
.together {
  margin-bottom: 12px;
  font-size: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 4px 14px 8px;
  box-shadow: var(--shadow);
}
.together summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.together p { margin: 8px 0 0; color: var(--muted); }
#print-btn { margin: 8px 0 16px; min-height: 44px; }
#wishes-form .primary { margin-top: 12px; min-height: 44px; }
.home-card .notice { background: transparent; color: var(--muted); padding: 0; margin: 0 0 8px; }
.status-card { text-align: left; margin-bottom: 12px; background: var(--card); border-left: 6px solid var(--border); }
.status-kicker { margin: 0; color: var(--muted); font-size: 0.85rem; }
.status-big { font-size: 1.45rem; font-weight: 800; margin: 4px 0; }
.status-good { border-left-color: #2f7d4a; }
.status-ok { border-left-color: #c4841d; }
.status-bad { border-left-color: #b42334; }
.status-none { border-left-color: var(--border); }
.emergency-btn { font-size: 1rem; min-height: 48px; }
#contact-editor[open],
#editor[open],
#med-editor[open],
#task-editor[open],
#status-dialog[open] {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 0;
}
#contact-form,
#editor-form,
#med-form,
#task-form,
#status-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 92dvh;
}
.contact-scroll,
.dialog-scroll,
.status-scroll { overflow: auto; min-height: 0; padding: 20px 20px 8px; }
#contact-form .dialog-buttons,
#editor-form .dialog-buttons,
#med-form .dialog-buttons,
#task-form .dialog-buttons,
.status-actions {
  flex: 0 0 auto;
  margin: 0;
  padding: 8px 20px 16px;
  background: var(--card);
  box-shadow: 0 -8px 16px rgba(62, 36, 18, 0.06);
}
.status-traits { margin: 0 0 8px; font-weight: 700; }
.status-fields { display: grid; gap: 2px; margin-top: 4px; }
.status-fields label { margin-top: 8px; }
.status-for { margin-top: 8px; }
.status-btns { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin: 12px 0; }
.status-btns button { min-height: 52px; min-width: 0; font-weight: 800; border-radius: 12px; }
@media (max-width: 360px) {
  .status-btns { grid-template-columns: 1fr; }
}
html.large-text .status-btns { grid-template-columns: 1fr; }
@media (prefers-color-scheme: dark) {
  .status-good { border-left-color: #8ddeaf; }
  .status-ok { border-left-color: #e6c27a; }
  .status-bad { border-left-color: #ffb4bc; }
  .present-card.is-here { background: var(--card); }
}
#measure-form .primary { margin-top: 12px; min-height: 44px; }
html.large-text { font-size: 21.25px; }
button, .menu-item, .chip, .tab, .home-row, .emergency-call, .nav-btn, .user-btn, .fab, .send {
  transition: background-color .18s ease, color .18s ease, border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.menu-item:active, .primary:active, .home-row:active, .user-btn:active { transform: scale(0.98); }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
@media (prefers-color-scheme: dark) {
  .topbar { background: var(--header); }
  #login-view { background: radial-gradient(900px 420px at 50% -8%, #3a2c4a 0%, transparent 62%), var(--bg); }
}
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}
.print-head h1 { font-size: 1.3rem; margin: 0 0 4px; }
.print-section { margin: 16px 0; break-inside: avoid; }
.print-section h2 { font-size: 1.05rem; border-bottom: 1px solid var(--border); padding-bottom: 4px; }
.print-section h3 { font-size: 0.9rem; margin: 10px 0 4px; }
.print-section p, .print-section li { white-space: pre-wrap; }

@media print {
  :root { --bg: #fff; --text: #000; --card: #fff; --border: #ccc; --muted: #333; --primary: #000; }
  body, html, #app-view { height: auto !important; background: #fff; color: #000; }
  .topbar, .bottomnav, .no-print, .fab, dialog, .toast { display: none !important; }
  .tab-panel { display: none !important; overflow: visible !important; height: auto !important; }
  #tab-print:not([hidden]), #tab-timeline:not([hidden]) { display: block !important; }
  .scroll { padding: 0; max-width: none; overflow: visible; }
  #print-root { font-size: 11pt; }
  a { color: #000; text-decoration: none; }
}
