/* Nestel – Kinetic designsysteem (zie DESIGN.md). Donker is standaard. */

:root {
  color-scheme: dark;
  --bg: #121212;
  --surface-low: #181818;
  --surface-mid: #242424;
  --surface-high: #2a2a2a;
  --line: #3e3e3e;
  --card-border: #242424;
  --text: #ffffff;
  --text-2: #a7a7a7;
  --accent: #ff7324;
  --accent-hover: #ff8a47;
  --accent-text: #ff9b5e;
  --on-accent: #000000;
  --badge-bg: #361d0f;
  --badge-text: #ff9b5e;
  --danger: #ff4d4d;
  --input: #1e1e1e;
  --placeholder: #727272;
  --chip: #1e1e1e;
  --chip-text: #a7a7a7;
  --chip-on-bg: #ffffff;
  --chip-on-text: #000000;
  --track: #2a2a2a;
  --nav-bg: rgba(36, 36, 36, 0.86);
  --scrim: rgba(0, 0, 0, 0.6);
  --rim: inset 0 1px 0 rgba(255, 255, 255, 0.08);
  --card-shadow: none;
  --float-shadow: 0 8px 24px rgba(255, 115, 36, 0.28);
  --nest-bg: #faf6f0;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f8f9fa;
    --surface-low: #ffffff;
    --surface-mid: #f1f3f5;
    --surface-high: #e9ecef;
    --line: #ced4da;
    --card-border: #e9ecef;
    --text: #121212;
    --text-2: #495057;
    --accent-hover: #e8590c;
    --accent-text: #a14000;
    --on-accent: #ffffff;
    --badge-bg: #ffe8db;
    --badge-text: #a14000;
    --danger: #ba1a1a;
    --input: #f1f3f5;
    --placeholder: #868e96;
    --chip: #f1f3f5;
    --chip-text: #495057;
    --chip-on-bg: #121212;
    --chip-on-text: #ffffff;
    --track: #e9ecef;
    --nav-bg: rgba(255, 255, 255, 0.9);
    --scrim: rgba(18, 18, 18, 0.35);
    --rim: none;
    --card-shadow: 0 4px 20px -2px rgba(18, 18, 18, 0.04);
    --float-shadow: 0 12px 32px -4px rgba(18, 18, 18, 0.08), 0 2px 6px -1px rgba(18, 18, 18, 0.03);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f8f9fa;
  --surface-low: #ffffff;
  --surface-mid: #f1f3f5;
  --surface-high: #e9ecef;
  --line: #ced4da;
  --card-border: #e9ecef;
  --text: #121212;
  --text-2: #495057;
  --accent-hover: #e8590c;
  --accent-text: #a14000;
  --on-accent: #ffffff;
  --badge-bg: #ffe8db;
  --badge-text: #a14000;
  --danger: #ba1a1a;
  --input: #f1f3f5;
  --placeholder: #868e96;
  --chip: #f1f3f5;
  --chip-text: #495057;
  --chip-on-bg: #121212;
  --chip-on-text: #ffffff;
  --track: #e9ecef;
  --nav-bg: rgba(255, 255, 255, 0.9);
  --scrim: rgba(18, 18, 18, 0.35);
  --rim: none;
  --card-shadow: 0 4px 20px -2px rgba(18, 18, 18, 0.04);
  --float-shadow: 0 12px 32px -4px rgba(18, 18, 18, 0.08), 0 2px 6px -1px rgba(18, 18, 18, 0.03);
}

/* ---------- Basis ---------- */

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px; line-height: 20px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
img { display: block; }
h1, h2, h3 { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ms {
  font-family: 'Material Symbols Outlined';
  font-weight: normal; font-style: normal; font-size: 24px; line-height: 1;
  letter-spacing: normal; text-transform: none; white-space: nowrap; direction: ltr;
  display: inline-block; width: 1em; overflow: hidden;
  font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  -webkit-font-smoothing: antialiased; flex: none;
}
.ms.fill { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }
.ms.sm { font-size: 20px; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Typografie (DESIGN.md) */
.headline-xl { font-size: 30px; line-height: 38px; font-weight: 800; letter-spacing: -0.025em; }
.headline-lg { font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -0.02em; }
.headline-md { font-size: 20px; line-height: 26px; font-weight: 700; letter-spacing: -0.015em; }
.headline-sm { font-size: 16px; line-height: 22px; font-weight: 700; letter-spacing: -0.01em; }
.body-lg { font-size: 16px; line-height: 24px; font-weight: 500; letter-spacing: -0.005em; }
.body-sm { font-size: 12px; line-height: 16px; letter-spacing: 0.01em; }
.label-sm { font-size: 11px; line-height: 14px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.muted { color: var(--text-2); }

/* ---------- Shell ---------- */

.app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 5;
  padding: calc(16px + env(safe-area-inset-top)) 16px 12px;
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(var(--bg) 70%, transparent);
}
.topbar .logo { width: 40px; height: 40px; border-radius: 12px; flex: none; }
.topbar .titles { flex: 1; min-width: 0; }
.topbar .overline { color: var(--text-2); }
.me-pill {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 4px;
  border-radius: 9999px; background: var(--surface-mid); font-weight: 700;
}

main { flex: 1; padding: 4px 16px calc(120px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 24px; }
@media (min-width: 400px) { main, .topbar { padding-left: 20px; padding-right: 20px; } }

.section { display: flex; flex-direction: column; gap: 12px; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }

/* ---------- Kaarten ---------- */

.card {
  background: var(--surface-low); border: 1px solid var(--card-border); border-radius: 16px;
  padding: 16px; box-shadow: var(--card-shadow), var(--rim);
  display: flex; flex-direction: column; gap: 12px;
}
.card.tight { gap: 8px; }
main > .card, main > .section { scroll-margin-top: 96px; }
.card-title { font-size: 16px; line-height: 22px; font-weight: 700; letter-spacing: -0.01em; }

/* Hero met Nestie */
.hero { flex-direction: row; align-items: center; gap: 12px; padding: 18px 16px 18px 18px; overflow: hidden; position: relative; }
.hero .grow { display: flex; flex-direction: column; gap: 8px; }
.nestie { width: 96px; height: 96px; flex: none; }
.nestie.lg { width: 168px; height: 168px; }
.nestie.md { width: 120px; height: 120px; }
.hero .nestie { margin: -8px -6px -10px 0; }
.nestie-wave { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px); } }

.progress { height: 6px; border-radius: 9999px; background: var(--track); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 9999px; background: var(--accent); transition: width .4s cubic-bezier(.2,.8,.2,1); }

/* ---------- Knoppen ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 48px; padding: 0 24px; border-radius: 9999px;
  font-size: 14px; line-height: 18px; font-weight: 700; letter-spacing: 0.01em;
  transition: transform .12s ease, background-color .15s ease, filter .15s ease;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:active { filter: brightness(1.08); }
.btn-secondary { background: var(--surface-mid); color: var(--text); border: 1px solid var(--line); }
.btn-ghost { color: var(--text-2); padding: 0 12px; }
.btn-danger { color: var(--danger); padding: 0 12px; }
.btn-sm { height: 36px; padding: 0 16px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 9999px; display: grid; place-items: center;
  background: var(--surface-mid); color: var(--text); flex: none;
}

.fab {
  position: fixed; z-index: 6; right: max(16px, calc(50% - 244px));
  bottom: calc(96px + env(safe-area-inset-bottom));
  height: 56px; padding: 0 22px 0 18px; border-radius: 9999px;
  background: var(--accent); color: var(--on-accent); font-weight: 700;
  display: flex; align-items: center; gap: 8px; box-shadow: var(--float-shadow);
}
.fab:active { transform: scale(0.97); }

/* ---------- Chips ---------- */

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  height: 36px; padding: 0 16px; border-radius: 9999px; background: var(--chip); color: var(--chip-text);
  font-weight: 600; font-size: 13px; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--chip-on-bg); color: var(--chip-on-text); font-weight: 700; }
.chip.day { min-width: 44px; padding: 0 12px; justify-content: center; }

.badge {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: 9999px; background: var(--badge-bg); color: var(--badge-text);
  font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: 0.01em;
}
.badge.neutral { background: var(--surface-mid); color: var(--text-2); }
.badge .ms { font-size: 16px; }

/* ---------- Avatars ---------- */

.avatar {
  width: 32px; height: 32px; border-radius: 9999px; display: grid; place-items: center; flex: none;
  font-weight: 800; font-size: 13px; color: #1b1c1c; border: 2px solid var(--surface-low);
}
.av-E { background: #76a99a; }
.av-J { background: #e9c46a; }
.avatar.sm { width: 24px; height: 24px; font-size: 11px; }

/* ---------- Taakkaart ---------- */

.task { gap: 12px; }
.task-row { display: flex; align-items: center; gap: 12px; }
.task-body { flex: 1; min-width: 0; text-align: left; }
.task-title { font-size: 16px; line-height: 22px; font-weight: 600; letter-spacing: -0.005em; overflow-wrap: anywhere; }
.task-meta { font-size: 12px; line-height: 16px; color: var(--text-2); margin-top: 2px; }
.task.done .task-title { color: var(--text-2); text-decoration: line-through; text-decoration-color: var(--line); }
.task-actions { display: flex; gap: 8px; padding-left: 36px; flex-wrap: wrap; }
.task-badges { display: flex; gap: 6px; flex-wrap: wrap; padding-left: 36px; }
.task-nestie { width: 44px; height: 44px; margin: -8px -4px -8px 0; flex: none; }

.check {
  width: 24px; height: 24px; border-radius: 9999px; border: 2px solid var(--line); flex: none;
  display: grid; place-items: center; color: transparent; position: relative;
  transition: background-color .18s ease, border-color .18s ease, transform .18s ease;
}
.check::after { content: ''; position: absolute; inset: -10px; } /* groter tikvlak */
.check .ms { font-size: 18px; font-variation-settings: 'FILL' 0, 'wght' 700, 'GRAD' 0, 'opsz' 20; }
.check.on { background: var(--accent); border-color: var(--accent); color: #000; }
.check.pop { animation: pop .32s cubic-bezier(.2,1.6,.4,1); }
@keyframes pop { 0% { transform: scale(.6); } 100% { transform: scale(1); } }

/* Compacte rij (week, later, taken) */
.list { display: flex; flex-direction: column; gap: 8px; }
.item {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  background: var(--surface-low); border: 1px solid var(--card-border); border-radius: 16px;
  padding: 12px 16px; min-height: 60px; box-shadow: var(--card-shadow);
}
button.item:active, .item.tap:active { background: var(--surface-mid); }
.item .grow { display: flex; flex-direction: column; gap: 2px; }
.item-title { font-weight: 600; font-size: 15px; line-height: 20px; overflow-wrap: anywhere; }
.item-meta { font-size: 12px; line-height: 16px; color: var(--text-2); }
.item.done .item-title { color: var(--text-2); text-decoration: line-through; }
.item .chev { color: var(--text-2); }

/* ---------- Verzoek ---------- */

.request { border: 1px solid var(--accent); box-shadow: var(--rim); }
.request .who { display: flex; align-items: center; gap: 8px; }
.request .text { font-size: 15px; line-height: 22px; font-weight: 500; }
.request .actions { display: flex; gap: 8px; }
.request .actions .btn { flex: 1; }
.request.out { border-color: var(--card-border); }

/* ---------- Week ---------- */

.daystrip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.day {
  display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 10px 0 8px;
  border-radius: 9999px; position: relative;
}
.day .dl { font-size: 11px; line-height: 14px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-2); }
.day .dn { font-size: 16px; line-height: 22px; font-weight: 700; }
.day .dots { display: flex; gap: 3px; height: 4px; }
.day .dot { width: 4px; height: 4px; border-radius: 9999px; background: var(--accent); }
.day .dot.done { background: var(--line); }
.day.today { background: var(--accent); }
.day.today .dl, .day.today .dn { color: #000; }
.day.today .dn { font-weight: 800; }
.day.today .dot { background: #000; }
.day.today .dot.done { background: rgba(0,0,0,.35); }
.day.vak .dn { color: var(--text-2); }

.daygroup { display: flex; flex-direction: column; gap: 8px; scroll-margin-top: 90px; }
.daygroup-head { display: flex; align-items: baseline; gap: 8px; }
.daygroup-head .headline-sm { flex: none; }
details.daygroup > summary { list-style: none; cursor: pointer; }
details.daygroup > summary::-webkit-details-marker { display: none; }
details.daygroup > summary .ms { transition: transform .2s; color: var(--text-2); }
details.daygroup[open] > summary .ms { transform: rotate(180deg); }

/* ---------- Banner ---------- */

.banner {
  display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px;
  background: var(--badge-bg); color: var(--badge-text); font-weight: 600;
}

/* ---------- Formulieren ---------- */

.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field-label { font-size: 12px; line-height: 16px; font-weight: 700; letter-spacing: 0.03em; color: var(--text-2); }
.input {
  width: 100%; background: var(--input); border: 1px solid transparent; border-radius: 12px;
  padding: 14px 16px; font-size: 16px; line-height: 20px; color: var(--text); outline: none;
  -webkit-appearance: none; appearance: none; min-height: 50px;
}
.input::placeholder { color: var(--placeholder); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255, 115, 36, 0.2); }
select.input { background-image: none; }
.hint { font-size: 12px; line-height: 16px; color: var(--text-2); }

.setting { display: flex; align-items: center; gap: 12px; min-height: 48px; }
.setting .grow { display: flex; flex-direction: column; gap: 2px; }
.setting-title { font-weight: 600; font-size: 15px; }
.divider { height: 1px; background: var(--card-border); margin: 0 -16px; }

.switch { width: 52px; height: 32px; border-radius: 9999px; background: var(--line); position: relative; flex: none; transition: background-color .2s; }
.switch::after {
  content: ''; position: absolute; top: 4px; left: 4px; width: 24px; height: 24px; border-radius: 9999px;
  background: #fff; transition: transform .2s cubic-bezier(.2,.8,.2,1);
}
.switch[aria-pressed="true"] { background: var(--accent); }
.switch[aria-pressed="true"]::after { transform: translateX(20px); }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 4px; background: var(--chip); padding: 4px; border-radius: 9999px; }
.seg button { height: 36px; border-radius: 9999px; font-weight: 600; font-size: 13px; color: var(--chip-text); }
.seg button.on { background: var(--chip-on-bg); color: var(--chip-on-text); font-weight: 700; }

/* ---------- Bottom-navigatie ---------- */

.navwrap {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 7; pointer-events: none;
  padding: 24px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, var(--bg) 55%);
}
.nav {
  pointer-events: auto; max-width: 488px; margin: 0 auto; height: 68px; border-radius: 9999px;
  background: var(--nav-bg); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border); box-shadow: var(--card-shadow);
  display: grid; grid-template-columns: repeat(4, 1fr); padding: 6px;
}
.nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border-radius: 9999px; color: var(--text-2); font-size: 11px; line-height: 14px; font-weight: 600; letter-spacing: 0.02em;
}
.nav button.on { color: var(--accent); }
.nav button.on .ms { font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24; }

/* ---------- Bottom sheet ---------- */

.scrim { position: fixed; inset: 0; z-index: 20; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet {
  width: 100%; max-width: 520px; max-height: 88dvh; overflow-y: auto;
  background: var(--surface-low); border-radius: 24px 24px 0 0; box-shadow: var(--rim);
  padding: 8px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px;
  animation: up .28s cubic-bezier(.2,.8,.2,1);
}
.sheet .grabber { width: 36px; height: 4px; border-radius: 9999px; background: var(--line); margin: 4px auto 4px; }
.sheet .item { background: var(--surface-mid); border-color: transparent; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(40px); opacity: .4; } }

/* ---------- Toast ---------- */

.toast {
  position: fixed; z-index: 30; left: 16px; right: 16px; bottom: calc(100px + env(safe-area-inset-bottom));
  max-width: 488px; margin: 0 auto; display: flex; align-items: center; gap: 12px;
  background: var(--surface-high); color: var(--text); border: 1px solid var(--line);
  border-radius: 20px; padding: 10px 10px 10px 14px; box-shadow: 0 12px 32px rgba(0,0,0,.35);
  animation: up .25s cubic-bezier(.2,.8,.2,1);
}
.toast img { width: 52px; height: 52px; margin: -10px 0 -10px -6px; }
.toast .grow { font-weight: 600; }

/* ---------- Vergrendel- en koppelscherm ---------- */

.lock {
  min-height: 100dvh; max-width: 420px; margin: 0 auto; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 20px; padding: calc(24px + env(safe-area-inset-top)) 24px calc(24px + env(safe-area-inset-bottom));
  text-align: center;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }
.brand span { font-size: 20px; font-weight: 800; letter-spacing: -0.02em; }
.lock .actions { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.pin-dots { display: flex; gap: 14px; justify-content: center; height: 16px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 9999px; border: 2px solid var(--line); }
.pin-dots span.on { background: var(--accent); border-color: var(--accent); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 72px); gap: 14px; justify-content: center; }
.keypad button {
  width: 72px; height: 72px; border-radius: 9999px; background: var(--surface-mid);
  font-size: 24px; font-weight: 700; display: grid; place-items: center;
}
.keypad button:active { background: var(--surface-high); transform: scale(.96); }
.keypad .blank { visibility: hidden; }
.keypad .key-alt { background: none; color: var(--text-2); }
.who-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; }
.who-btn {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 12px;
  border-radius: 20px; background: var(--surface-low); border: 1px solid var(--card-border); font-weight: 700; font-size: 16px;
}
.who-btn .avatar { width: 56px; height: 56px; font-size: 22px; }
.who-btn:active { background: var(--surface-mid); }
.who-btn[disabled] { opacity: .5; }
.topbar .offline { width: 40px; height: 40px; border-radius: 9999px; display: grid; place-items: center; flex: none; background: var(--badge-bg); color: var(--badge-text); }

/* Lege staat met Nestie */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 4px; padding: 8px 16px 16px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
