:root {
  --blue: #2b5fd9; --blue-dark: #1e48ad; --blue-soft: #e5edfc;
  --bg: #f3f6fb; --card: #fff; --text: #172033; --muted: #66708a; --line: #dbe1ec;
  --warn: #c46a00; --warn-soft: #fff1dc; --danger: #b3261e; --danger-soft: #fdecea;
  --tap: 52px; --radius: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text);
  font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
.hidden { display: none !important; }
h1, h2 { margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; }
.muted, .hint { color: var(--muted); }
.hint { margin: .5rem 0; font-size: .95rem; }
.error { color: var(--danger); min-height: 1.4em; font-weight: 600; text-align: center; }

input, select, button, textarea { font: inherit; color: inherit; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 0 14px; border: 2px solid var(--line);
  border-radius: var(--radius); background: #fff; outline: none;
}
textarea { padding: 10px 14px; resize: vertical; min-height: 96px; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
label { display: block; margin: .8rem 0 .3rem; font-weight: 600; }
label.check { display: flex; gap: 10px; align-items: center; font-weight: 500; }
label.check input { width: auto; min-height: 0; }

.btn { min-height: var(--tap); padding: 0 18px; border: 2px solid var(--line); border-radius: var(--radius);
  background: #fff; font-weight: 600; cursor: pointer; }
.btn:active { transform: scale(.98); }
.btn.big { min-height: 56px; font-size: 1.05rem; }
.btn.small { min-height: 44px; padding: 0 14px; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:active { background: var(--blue-dark); }
.btn.danger { background: #fff; border-color: #e7b9b5; color: var(--danger); width: 100%; margin-top: .8rem; }
.icon-btn { min-width: var(--tap); min-height: var(--tap); border: none; background: none; font-size: 1.5rem; cursor: pointer; }

/* login */
.screen { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 420px; background: var(--card); border-radius: 22px; padding: 28px 22px; box-shadow: 0 6px 24px rgba(0,0,0,.08); text-align: center; }
.login-card h1 { margin: 10px 0 14px; }
.login-card form, .login-card label { text-align: left; }
.login-card form .btn { width: 100%; margin-top: 14px; }

/* app */
#app { max-width: 640px; margin: 0 auto; padding-bottom: calc(86px + env(safe-area-inset-bottom)); }
.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 16px; padding-top: calc(6px + env(safe-area-inset-top)); background: var(--blue); color: #fff; }
.topbar .who { flex: 1; display: flex; flex-direction: column; line-height: 1.15; }
.topbar .muted { color: #d6e2fb; font-size: .85rem; }
.topbar .icon-btn { color: #fff; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: #9fe3bd; flex: none; }
.dot.off { background: #ffb4a8; }
.tab { padding: 14px 14px 20px; }
.offline-bar { background: #fff3cd; color: #6b4e00; padding: 10px 16px; font-weight: 600; font-size: .95rem; }

.add-form { background: var(--card); border-radius: var(--radius); padding: 10px; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-bottom: 12px; }
.add-form .row { display: flex; gap: 8px; margin-bottom: 8px; }
.add-form .row:last-child { margin-bottom: 0; }
.add-btn { min-width: var(--tap); padding: 0; font-size: 1.5rem; }
.small-row input, .small-row select, .small-row .btn { min-height: 44px; }
.small-row input[type=date] { flex: 1.4; }
.small-row input.time { flex: 1; }
.prio-btn { min-width: 52px; padding: 0; font-size: 1.2rem; color: var(--muted); }
.prio-btn[aria-pressed=true] { background: var(--danger-soft); border-color: #e7b9b5; color: var(--danger); }

.empty { text-align: center; color: var(--muted); padding: 28px 10px; }
.group-head { margin: 16px 4px 6px; font-size: .82rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.group-head.late { color: var(--danger); }

.task { display: flex; align-items: center; gap: 2px; background: var(--card); border-radius: var(--radius);
  margin-bottom: 6px; box-shadow: 0 1px 3px rgba(0,0,0,.05); min-height: 60px; border-left: 5px solid transparent; }
.task.high { border-left-color: var(--danger); }
.task .check { flex: none; width: 58px; height: 60px; border: none; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; }
.task .check i { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #a3aec4; display: flex; align-items: center; justify-content: center; font-style: normal; color: #fff; font-weight: 800; }
.task.done .check i { background: var(--blue); border-color: var(--blue); }
.task .body { flex: 1; min-width: 0; padding: 9px 12px 9px 0; text-align: left; border: none; background: none; cursor: pointer; }
.task .title { font-weight: 600; overflow-wrap: anywhere; }
.task.done .title { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.task .meta { color: var(--muted); font-size: .88rem; margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.task .meta .late { color: var(--danger); font-weight: 600; }
.tag { display: inline-block; font-size: .75rem; font-weight: 700; padding: 1px 8px; border-radius: 99px; background: var(--blue-soft); color: var(--blue-dark); }
.tag.high { background: var(--danger-soft); color: var(--danger); }
.done-tools { text-align: center; margin-top: 16px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; max-width: 640px; margin: 0 auto; display: flex; background: #fff;
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 6; }
.tabbtn { flex: 1; min-height: 66px; border: none; background: none; font-weight: 600; font-size: .85rem; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; position: relative; }
.tabbtn span { font-size: 1.3rem; }
.tabbtn.active { color: var(--blue-dark); box-shadow: inset 0 3px 0 var(--blue); }
.badge { background: var(--danger); color: #fff; border-radius: 99px; font-size: .72rem; padding: 0 7px; }
.tabbtn .badge { position: absolute; top: 6px; left: calc(50% + 12px); }

dialog { border: none; border-radius: 20px; padding: 20px; width: min(94vw, 460px); max-height: 92vh; overflow-y: auto; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog .row { display: flex; gap: 8px; margin-top: 12px; }
dialog .row .btn { flex: 1; }
dialog .row.two > div { flex: 1; min-width: 0; }
dialog .row.two label { margin-top: 0; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom)); max-width: 94vw;
  display: flex; align-items: center; gap: 14px; background: #172033; color: #fff; padding: 10px 12px 10px 18px; border-radius: 99px;
  font-weight: 600; z-index: 20; box-shadow: 0 4px 16px rgba(0,0,0,.3); }
.toast-action { border: none; background: none; color: #9cc0ff; font-weight: 700; min-height: 40px; padding: 0 8px; cursor: pointer; }

/* setup.php */
body.setup { display: flex; justify-content: center; padding: 24px 12px; }
.setup-card { max-width: 520px; width: 100%; text-align: left; }
.setup-card form { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.setup-card code { background: var(--blue-soft); padding: 1px 5px; border-radius: 6px; }
.setup-card a.btn { display: block; text-align: center; text-decoration: none; line-height: 52px; margin-top: 8px; }
.bigcode { font-size: 1.4rem; font-weight: 700; text-align: center; background: var(--blue-soft); padding: 12px; border-radius: var(--radius); overflow-wrap: anywhere; }
.bigcode.apikey { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 1rem; user-select: all; }
.add-form .row > * { min-width: 0; }
.small-row input[type=date], .small-row input[type=time] { padding: 0 8px; }
.add-form .row > .prio-btn, .add-form .row > .add-btn { flex: none; min-width: 52px; }

/* checklist in het bewerkscherm */
.checklist { margin-top: 1rem; }
.check-head { font-weight: 600; margin-bottom: .4rem; }
.check-item { display: flex; align-items: center; gap: 4px; margin-bottom: 6px; }
.check-item .cbox { flex: none; width: 44px; height: 44px; border: none; background: none; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.check-item .cbox i { width: 24px; height: 24px; border-radius: 6px; border: 3px solid #a3aec4; display: flex; align-items: center; justify-content: center; font-style: normal; color: #fff; font-weight: 800; font-size: .85rem; }
.check-item.done .cbox i { background: var(--blue); border-color: var(--blue); }
.check-item input { flex: 1; min-width: 0; min-height: 44px; padding: 0 10px; }
.check-item.done input { text-decoration: line-through; color: var(--muted); }
.check-item .mini { flex: none; width: 40px; min-height: 44px; border: 2px solid var(--line); border-radius: var(--radius); background: #fff; cursor: pointer; padding: 0; font-size: 1rem; }
.check-item .mini.del { color: var(--danger); }
.check-item .mini[disabled] { visibility: hidden; }
dialog .row.check-add { margin-top: 4px; }
.check-add input { min-height: 44px; }
dialog .row.check-add .btn { flex: none; min-width: 52px; min-height: 44px; padding: 0; font-size: 1.3rem; }
.check-undo { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 8px; background: #172033; color: #fff; padding: 4px 6px 4px 14px; border-radius: 99px; font-weight: 600; font-size: .92rem; }
.hint.small { font-size: .82rem; margin: .4rem 0 0; }
.tag.ckprog { background: #eef1f6; color: var(--muted); }
.tag.ckprog.complete { background: #e2f5ea; color: #1d6b3c; }
