:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #000000;
  --secondary: #8e8e93;
  --separator: rgba(60, 60, 67, 0.18);
  --blue: #007aff;
  --red: #ff3b30;
  --green: #34c759;
  --fill: rgba(118, 118, 128, 0.12);
  --segment: #ffffff;
  --bar: rgba(249, 249, 249, 0.88);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #ffffff;
    --secondary: #8e8e93;
    --separator: rgba(84, 84, 88, 0.6);
    --blue: #0a84ff;
    --red: #ff453a;
    --green: #30d158;
    --fill: rgba(118, 118, 128, 0.24);
    --segment: #636366;
    --bar: rgba(22, 22, 23, 0.88);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: env(safe-area-inset-top) 0 calc(64px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
main { max-width: 640px; margin: 0 auto; padding: 0 16px; }

/* Navigatie */
.nav { padding: 12px 4px 8px; }
h1 { font-size: 34px; font-weight: 700; letter-spacing: 0.01em; margin: 32px 0 12px; }
.segmented {
  display: flex; background: var(--fill); border-radius: 9px; padding: 2px; margin-bottom: 16px;
}
.segmented button {
  flex: 1; padding: 6px 0; font-size: 13px; font-weight: 500; border-radius: 7px; transition: background .2s;
}
.segmented button.active { background: var(--segment); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 3px 1px rgba(0,0,0,.04); }

/* Lijst */
.list { list-style: none; margin: 0; padding: 0; background: var(--card); border-radius: 10px; overflow: hidden; }
.list:empty { display: none; }
.task { display: flex; align-items: flex-start; gap: 12px; padding: 11px 16px 0; transition: opacity .3s; }
.task.leaving { opacity: 0; }
.check {
  flex: none; width: 22px; height: 22px; margin-top: 1px; border-radius: 50%;
  border: 1.5px solid #c7c7cc; display: grid; place-items: center; transition: all .15s;
}
.check.on { border-color: var(--blue); }
.check.on::after { content: ""; width: 14px; height: 14px; border-radius: 50%; background: var(--blue); }
.task-body {
  flex: 1; min-width: 0; padding-bottom: 11px; border-bottom: 0.5px solid var(--separator); text-align: left;
}
.task:last-child .task-body { border-bottom: 0; }
.task-title { overflow-wrap: anywhere; }
.task.done .task-title { color: var(--secondary); }
.task-meta { font-size: 15px; color: var(--secondary); margin-top: 2px; display: flex; align-items: center; gap: 6px; }
.task-meta.overdue { color: var(--red); }
.task-meta svg { width: 15px; height: 15px; }
.task-notes { font-size: 15px; color: var(--secondary); margin-top: 2px; white-space: pre-wrap; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.empty { text-align: center; color: var(--secondary); margin-top: 64px; }

/* Werkbalk onderaan */
.toolbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 20px calc(10px + env(safe-area-inset-bottom));
  background: var(--bar); backdrop-filter: saturate(180%) blur(20px); -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid var(--separator);
}
.tool-add { display: flex; align-items: center; gap: 8px; color: var(--blue); font-weight: 600; }
.tool-add svg { width: 24px; height: 24px; }
.tool-icon { color: var(--blue); }
.tool-icon svg { width: 28px; height: 28px; display: block; }

/* Bottom sheet */
.backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .25s;
}
.backdrop[hidden] { display: none; }
.sheet {
  width: 100%; max-width: 640px; max-height: calc(100% - env(safe-area-inset-top) - 12px); overflow-y: auto;
  background: var(--bg); border-radius: 12px 12px 0 0;
  padding: 0 16px calc(24px + env(safe-area-inset-bottom));
  animation: rise .3s cubic-bezier(.2,.8,.2,1);
}
.sheet-bar {
  position: sticky; top: 0; background: var(--bg); z-index: 1;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 16px 0 14px;
}
.sheet-bar h2 { font-size: 17px; font-weight: 600; margin: 0; }
.sheet-bar button { color: var(--blue); justify-self: start; }
.sheet-bar button.strong { font-weight: 600; justify-self: end; }
.group { background: var(--card); border-radius: 10px; margin-bottom: 20px; overflow: hidden; }
.group input[name=title], .group textarea {
  display: block; width: 100%; border: 0; background: none; color: var(--text); font: inherit; padding: 11px 16px; outline: none;
  resize: none;
}
.group input[name=title] { border-bottom: 0.5px solid var(--separator); }
.row { display: flex; align-items: center; gap: 12px; padding: 7px 16px; min-height: 48px; }
.row + .row { border-top: 0.5px solid var(--separator); }
.row-icon { flex: none; width: 29px; height: 29px; border-radius: 7px; display: grid; place-items: center; }
.row-icon svg { width: 19px; height: 19px; }
.row-icon.red { background: var(--red); }
.row-icon.blue { background: var(--blue); }
.row-label { flex: 1; }
.row input[type=datetime-local] {
  font: inherit; font-size: 15px; color: var(--blue); background: var(--fill); border: 0; border-radius: 7px; padding: 6px 8px;
  max-width: 55%;
}
.hint { font-size: 13px; color: var(--secondary); margin: -12px 16px 20px; }
.hint:empty { display: none; }
.danger { width: 100%; padding: 12px; color: var(--red); }

/* iOS-schakelaar */
.switch {
  -webkit-appearance: none; appearance: none; flex: none; width: 51px; height: 31px; margin: 0;
  border-radius: 16px; background: var(--fill); position: relative; transition: background .25s; cursor: pointer;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 8px rgba(0,0,0,.15), 0 3px 1px rgba(0,0,0,.06); transition: transform .25s;
}
.switch:checked { background: var(--green); }
.switch:checked::after { transform: translateX(20px); }

/* Melding */
.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(30,30,30,.92); color: #fff; font-size: 15px; padding: 10px 18px; border-radius: 20px;
  max-width: calc(100% - 32px); text-align: center; animation: fade .2s;
}
.toast[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(100%); } }

/* Inlogscherm */
.login { max-width: 360px; margin: 18vh auto 0; text-align: center; }
.login img { border-radius: 18px; }
.login h1 { margin: 12px 0 28px; }
.login .group input {
  display: block; width: 100%; border: 0; background: none; color: var(--text); font: inherit; padding: 13px 16px; outline: none;
}
.login-error { color: var(--red); font-size: 15px; min-height: 1em; margin: -8px 0 12px; }
.login-button { width: 100%; padding: 14px; border-radius: 12px; background: var(--blue); color: #fff; font-weight: 600; }
