/* =========================================================
   Werkmodus — stijlen
   ========================================================= */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --surface-3: #e7eaef;
  --border: #e2e5ea;
  --border-strong: #cfd4dc;
  --text: #1a1e26;
  --text-2: #565f6d;
  --text-3: #8b93a0;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #c2620a;
  --success: #15803d;
  --page: #ffffff;
  --page-desk: #e9ebef;
  --goal: #c2410c;
  --goal-soft: #fff4ec;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 12px rgba(16, 24, 40, .05);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1014;
    --surface: #161920;
    --surface-2: #1d2129;
    --surface-3: #262b35;
    --border: #272c36;
    --border-strong: #363c48;
    --text: #e8eaee;
    --text-2: #a4abb8;
    --text-3: #6e7685;
    --accent: #818cf8;
    --accent-hover: #a5b4fc;
    --accent-soft: #23264a;
    --accent-text: #0e1014;
    --danger: #f87171;
    --danger-soft: #3a1d1f;
    --warn: #f59e0b;
    --success: #4ade80;
    --page: #1b1f27;
    --page-desk: #111318;
  --goal: #fb923c;
  --goal-soft: #36210f;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1014;
  --surface: #161920;
  --surface-2: #1d2129;
  --surface-3: #262b35;
  --border: #272c36;
  --border-strong: #363c48;
  --text: #e8eaee;
  --text-2: #a4abb8;
  --text-3: #6e7685;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --accent-soft: #23264a;
  --accent-text: #0e1014;
  --danger: #f87171;
  --danger-soft: #3a1d1f;
  --warn: #f59e0b;
  --success: #4ade80;
  --page: #1b1f27;
  --page-desk: #111318;
  --goal: #fb923c;
  --goal-soft: #36210f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 1px 3px rgba(0, 0, 0, .35), 0 4px 12px rgba(0, 0, 0, .25);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

svg {
  width: 18px; height: 18px;
  fill: none; stroke: currentColor;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
svg .fill { fill: currentColor; stroke: none; }

h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 15px; font-weight: 600; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Layout ---------- */

.app {
  display: grid;
  grid-template-columns: 236px 1fr;
  height: 100vh;
  height: 100dvh;
}

.main { min-width: 0; overflow: hidden; position: relative; }

.view {
  height: 100%;
  overflow-y: auto;
  padding: 36px 44px 60px;
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.eyebrow { margin: 0 0 4px; color: var(--text-3); font-weight: 500; }
.eyebrow::first-letter, .cal-head h1::first-letter, .cal-day h2::first-letter { text-transform: uppercase; }
.sub { margin: 4px 0 0; color: var(--text-2); }

/* ---------- Sidebar ---------- */

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
  gap: 6px;
}

.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-logo {
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--accent);
  display: grid; place-items: center;
  color: var(--accent-text);
}
.brand-logo svg { stroke-width: 3; width: 18px; height: 18px; }
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: -0.01em; }

.nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex; align-items: center; gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: 0; border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-weight: 500;
  text-align: left;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.small { font-size: 13px; padding: 7px 12px; }
.nav-item.small svg { width: 16px; height: 16px; }

.badge {
  margin-left: auto;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px;
  background: var(--accent); color: var(--accent-text);
  font-size: 11.5px; font-weight: 600;
  display: inline-grid; place-items: center;
}

.sidebar-footer { margin-top: auto; display: flex; flex-direction: column; gap: 2px; border-top: 1px solid var(--border); padding-top: 10px; }

/* ---------- Synchronisatie & account ---------- */

.sync-status {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 12px 8px;
  font-size: 12px; color: var(--text-3);
}
.sync-status .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; }
.sync-status[data-state="saving"] .dot { background: var(--warn); animation: pulse 1s ease-in-out infinite; }
.sync-status[data-state="offline"] .dot { background: var(--danger); }
.sync-status[data-state="offline"] { color: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

.account { border-top: 1px solid var(--border); margin-top: 6px; padding-top: 8px; }
.account-email {
  display: block; padding: 0 12px 2px;
  font-size: 12px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Laden & inloggen ---------- */

.loading {
  position: fixed; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); color: var(--text-3); font-weight: 500;
  z-index: 50;
}
.loading .brand-logo { width: 44px; height: 44px; border-radius: 13px; animation: pulse 1.2s ease-in-out infinite; }
.loading .brand-logo svg { width: 26px; height: 26px; }

.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(900px 500px at 15% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    radial-gradient(700px 400px at 100% 110%, color-mix(in srgb, var(--goal) 10%, transparent), transparent 60%),
    var(--bg);
}
.auth-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  padding: 28px 28px 22px;
}
.auth-brand { padding: 0 0 22px; }
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr;
  background: var(--surface-2);
  border-radius: 10px; padding: 4px;
  margin-bottom: 22px;
}
.auth-tabs button {
  height: 34px; border: 0; border-radius: 7px;
  background: transparent; color: var(--text-2);
  font-weight: 600; font-size: 13.5px;
}
.auth-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.auth h1 { font-size: 22px; }
.auth-sub { color: var(--text-2); margin: 4px 0 18px; font-size: 14px; }
#auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-submit { height: 42px; margin-top: 4px; }
.auth-submit:disabled { opacity: .6; cursor: wait; }
.auth-link { align-self: center; }
.auth-msg { margin: 0; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13.5px; }
.auth-msg.error { background: var(--danger-soft); color: var(--danger); }
.auth-msg.ok { background: color-mix(in srgb, var(--success) 14%, transparent); color: var(--success); }

/* ---------- Buttons & inputs ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-weight: 600; font-size: 14px;
  white-space: nowrap;
  transition: background .12s, border-color .12s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--text); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn.sm { height: 32px; padding: 0 12px; font-size: 13px; }

.link-btn {
  border: 0; background: none; padding: 0;
  color: var(--accent); font-weight: 500; font-size: 13px;
}
.link-btn:hover { text-decoration: underline; }

.icon-btn {
  width: 32px; height: 32px;
  display: inline-grid; place-items: center;
  border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-3);
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn svg { width: 16px; height: 16px; }

input[type="text"], input[type="search"], input[type="date"], input[type="time"], input[type="email"], input[type="password"], select, textarea {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  min-width: 0;
}
textarea { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

/* ---------- Cards & stats ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 10px; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.stat-label { color: var(--text-2); font-size: 13px; }
.stat.alert .stat-num { color: var(--danger); }

.today-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
  grid-template-rows: auto auto;
  gap: 20px;
}
.today-grid .card-tasks { grid-row: span 2; }

.quick-add { display: flex; gap: 8px; margin-bottom: 10px; }
.quick-add input { flex: 1; }

.empty {
  color: var(--text-3);
  text-align: center;
  padding: 24px 12px;
  font-size: 13.5px;
}

/* ---------- Tasks ---------- */

.task-form {
  display: grid;
  grid-template-columns: 1fr 160px 130px auto;
  gap: 8px;
  padding: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.task-form input[type="text"] { border-color: transparent; font-size: 15px; }
.task-form input[type="text"]:focus { box-shadow: none; border-color: transparent; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 22px; }
.chip-btn {
  height: 32px; padding: 0 14px;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-2);
  font-weight: 500; font-size: 13px;
}
.chip-btn:hover { color: var(--text); background: var(--surface-2); }
.chip-btn.active { background: var(--text); border-color: var(--text); color: var(--bg); }
.chip-btn .count { opacity: .6; margin-left: 4px; font-variant-numeric: tabular-nums; }

.task-group { margin-bottom: 24px; }
.task-group-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3);
  margin: 0 0 8px 4px;
}
.task-group-head.overdue { color: var(--danger); }
.task-group-head .n { font-weight: 500; }

.task-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.task-group .task-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 0;
  overflow: hidden;
}
.task-group .task + .task { border-top: 1px solid var(--border); }

.task {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 11px 10px 11px 14px;
  background: var(--surface);
  transition: background .12s, opacity .3s;
}
.card .task { border-radius: var(--radius-sm); padding: 9px 8px 9px 6px; }
.task:hover { background: var(--surface-2); }

.check {
  width: 22px; height: 22px; margin-top: 1px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: transparent;
  display: grid; place-items: center;
  padding: 0;
  flex-shrink: 0;
  color: transparent;
  transition: background .15s, border-color .15s, color .15s, transform .15s;
}
.check svg { width: 13px; height: 13px; stroke-width: 3.2; }
.check:hover { border-color: var(--accent); color: color-mix(in srgb, var(--accent) 55%, transparent); }
.task.prio-hoog .check { border-color: var(--danger); }
.task.done .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); transform: scale(1.04); }
.task.done .check:hover { color: var(--accent-text); }

.task-main { flex: 1; min-width: 0; cursor: pointer; }
.task-title { font-weight: 500; overflow-wrap: anywhere; transition: color .2s; }
.task.done .task-title { color: var(--text-3); text-decoration: line-through; }
.task-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 2px; font-size: 12.5px; color: var(--text-3); }
.task-meta span { display: inline-flex; align-items: center; gap: 4px; }
.task-meta svg { width: 13px; height: 13px; }
.task-meta .overdue { color: var(--danger); font-weight: 500; }
.task-meta .is-today { color: var(--accent); font-weight: 500; }
.task-meta .prio-hoog { color: var(--danger); }
.task-meta .prio-laag { color: var(--text-3); }

.task .task-del { opacity: 0; transition: opacity .12s; margin-top: -4px; }
.task:hover .task-del, .task:focus-within .task-del { opacity: 1; }
@media (hover: none) { .task .task-del { opacity: .7; } }

.task.leaving { opacity: 0; }

/* ---------- Grote doelen ---------- */

.task-form { grid-template-columns: auto 1fr 160px 130px auto; }
.task-form.goal-mode {
  border-color: var(--goal);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--goal) 16%, transparent);
}

.goal-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-2);
  font-weight: 600; font-size: 13px;
  white-space: nowrap;
  transition: background .12s, color .12s, border-color .12s;
}
.goal-toggle:hover { color: var(--goal); border-color: var(--goal); }
.goal-toggle.active { border-style: solid; border-color: var(--goal); background: var(--goal-soft); color: var(--goal); }
.goal-toggle svg { width: 16px; height: 16px; }

.chip-btn { display: inline-flex; align-items: center; gap: 4px; }
.chip-btn svg { width: 14px; height: 14px; }
.chip-btn .count { margin-left: 2px; }

.goal-list { display: flex; flex-direction: column; gap: 10px; }

.goal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: border-color .15s;
}
.goal-card.open { border-color: color-mix(in srgb, var(--goal) 45%, var(--border)); }

.goal-head { cursor: pointer; padding: 14px 10px 14px 16px; align-items: flex-start; }
.goal-head .check { border-color: var(--goal); }
.goal-head .check:hover { color: color-mix(in srgb, var(--goal) 60%, transparent); border-color: var(--goal); }
.goal-head.done .check { background: var(--goal); border-color: var(--goal); color: #fff; }
.goal-main { flex: 1; min-width: 0; }
.goal-title { display: flex; align-items: center; gap: 8px; font-weight: 650; font-size: 15.5px; overflow-wrap: anywhere; }
.goal-title svg { color: var(--goal); width: 17px; height: 17px; }
.goal-card.done .goal-title span { text-decoration: line-through; color: var(--text-3); }
.goal-head .task-meta { margin-top: 3px; }
.task-meta .next { color: var(--text-2); }

.progress {
  height: 6px; max-width: 420px;
  margin-top: 10px;
  border-radius: 3px;
  background: var(--surface-3);
  overflow: hidden;
}
.progress span { display: block; height: 100%; border-radius: 3px; background: var(--goal); transition: width .35s ease; }

.chevron svg { transition: transform .2s; }
.goal-card.open .chevron svg { transform: rotate(180deg); }

.goal-body {
  border-top: 1px solid var(--border);
  padding: 6px 12px 12px 46px;
  background: color-mix(in srgb, var(--surface-2) 45%, var(--surface));
}
.goal-body .task-list { border: 0; border-radius: 0; background: transparent; }
.goal-body .task { background: transparent; padding: 8px 6px; align-items: center; }
.goal-body .task:hover { background: var(--surface-2); }
.goal-body .task .check { margin-top: 0; }
.goal-body .task .task-del { margin-top: 0; }
.goal-hint { color: var(--text-2); font-size: 13.5px; margin: 10px 6px 6px; }

.sub-date {
  height: 32px !important; width: 140px;
  padding: 0 8px !important;
  font-size: 12.5px;
  color: var(--text-2);
  border-color: transparent !important;
  background: transparent !important;
}
.sub-date:hover, .sub-date:focus { border-color: var(--border-strong) !important; background: var(--surface) !important; }
.sub-date.empty { color: var(--text-3); }
.sub-date.overdue { color: var(--danger); font-weight: 500; }
.task.done .sub-date { opacity: .5; }

.sub-add { display: flex; gap: 6px; align-items: center; margin-top: 6px; padding: 4px 0 0 6px; }
.sub-add-plus { color: var(--text-3); font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.sub-add input[type="text"] { flex: 1; height: 34px; }
.sub-add input[type="date"] { height: 34px; width: 150px; font-size: 13px; }

.task-meta .goal-tag { color: var(--goal); }
.task-meta .goal-tag svg { width: 13px; height: 13px; }
.task-meta .goal-tag[data-task-action] { cursor: pointer; }
.task-meta .goal-tag[data-task-action]:hover { text-decoration: underline; }
.task.is-goal .task-title { font-weight: 600; }
.task.is-goal .check { border-color: var(--goal); }
.task.is-goal.done .check { background: var(--goal); border-color: var(--goal); color: #fff; }

.ev-chip.task-chip.goal-chip { color: var(--goal); font-weight: 600; }
.ev-chip.task-chip.goal-chip::before { content: "◎ "; color: var(--goal); }

/* ---------- Notes ---------- */

.view-notes {
  padding: 0;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  overflow: hidden;
}

.notes-side {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  min-height: 0;
}
.notes-side-head { display: flex; align-items: center; justify-content: space-between; padding: 26px 18px 14px; }
.notes-side-head h1 { font-size: 22px; }
.notes-side .search { margin: 0 18px 10px; }

.note-list { list-style: none; margin: 0; padding: 4px 10px 20px; overflow-y: auto; flex: 1; }
.note-item {
  padding: 11px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  margin-bottom: 2px;
}
.note-item:hover { background: var(--surface-2); }
.note-item.active { background: var(--accent-soft); }
.note-item-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-item-snippet {
  color: var(--text-2); font-size: 13px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-top: 1px;
}
.note-item-date { color: var(--text-3); font-size: 12px; margin-top: 4px; }

.notes-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--page-desk); }

.editor-empty {
  margin: auto; text-align: center; color: var(--text-3);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.editor-empty svg { width: 44px; height: 44px; stroke-width: 1.5; }
.editor-empty p { margin: 0; }

.editor-wrap { display: flex; flex-direction: column; min-height: 0; flex: 1; }

.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 2px;
  padding: 8px 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.tb-group { display: flex; align-items: center; gap: 2px; padding: 0 6px; border-right: 1px solid var(--border); }
.tb-group:last-of-type, .tb-group.tb-right { border-right: 0; }
.tb-right { margin-left: auto; }

.tb {
  position: relative;
  min-width: 32px; height: 32px; padding: 0 6px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 6px;
  background: transparent; color: var(--text-2);
  font-size: 15px;
  cursor: pointer;
}
.tb:hover { background: var(--surface-2); color: var(--text); }
.tb.active { background: var(--accent-soft); color: var(--accent); }
.tb.danger:hover { background: var(--danger-soft); color: var(--danger); }
.tb b, .tb i, .tb u, .tb s { font-family: Georgia, serif; font-size: 16px; }
.tb svg { width: 17px; height: 17px; }
.note-back { display: none; }

.tb-select {
  height: 32px; padding: 0 6px;
  border: 1px solid transparent;
  background: transparent;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-2);
  max-width: 140px;
}
.tb-select:hover { background: var(--surface-2); }
.tb-select.narrow { width: 58px; }
.tb-select:focus { box-shadow: none; border-color: var(--border-strong); }

.color-tb { flex-direction: column; gap: 0; padding: 2px 6px 4px; }
.color-tb input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.color-a { font-family: Georgia, serif; font-weight: 700; font-size: 15px; line-height: 1; }
.color-tb svg { width: 15px; height: 15px; }
.color-bar { width: 16px; height: 3px; border-radius: 2px; margin-top: 2px; background: #dc2626; }

.page-scroll { flex: 1; overflow-y: auto; padding: 32px 24px 80px; }

.page {
  max-width: 816px;           /* ongeveer A4-breedte */
  min-height: 1056px;
  margin: 0 auto;
  background: var(--page);
  box-shadow: var(--shadow);
  border-radius: 4px;
  padding: 64px 80px;
}

.note-title {
  width: 100%;
  border: 0; outline: 0; background: transparent;
  font-size: 30px; font-weight: 700; letter-spacing: -0.02em;
  padding: 0; margin-bottom: 18px;
  height: auto; box-shadow: none !important;
}
.note-title::placeholder { color: var(--text-3); }

.editor {
  outline: none;
  min-height: 700px;
  font-size: 16px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}
.editor:empty::before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.editor > :first-child { margin-top: 0; }
.editor p { margin: 0 0 .7em; }
.editor h1 { font-size: 2em; margin: .8em 0 .35em; }
.editor h2 { font-size: 1.5em; margin: .8em 0 .35em; }
.editor h3 { font-size: 1.2em; margin: .8em 0 .3em; }
.editor blockquote {
  margin: .8em 0; padding: .2em 1em;
  border-left: 3px solid var(--accent);
  color: var(--text-2);
}
.editor pre {
  background: var(--surface-2); padding: 12px 14px; border-radius: 6px;
  font-family: "Cascadia Code", Consolas, monospace; font-size: .9em;
  white-space: pre-wrap;
}
.editor a { color: var(--accent); }
.editor ul, .editor ol { padding-left: 1.6em; margin: 0 0 .7em; }
.editor hr { border: 0; border-top: 1px solid var(--border-strong); margin: 1.4em 0; }
.editor img { max-width: 100%; height: auto; border-radius: 4px; }
.editor table { border-collapse: collapse; width: 100%; margin: .8em 0; }
.editor td, .editor th { border: 1px solid var(--border-strong); padding: 6px 10px; min-width: 40px; vertical-align: top; }

.editor ul.checklist { list-style: none; padding-left: .2em; }
.editor ul.checklist li { position: relative; padding-left: 1.8em; }
.editor ul.checklist li::before {
  content: "";
  position: absolute; left: 0; top: .3em;
  width: 1.05em; height: 1.05em;
  border: 2px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  box-sizing: border-box;
}
.editor ul.checklist li.checked { color: var(--text-3); text-decoration: line-through; }
.editor ul.checklist li.checked::before {
  background: var(--accent) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5'/%3E%3C/svg%3E") center / 80% no-repeat;
  border-color: var(--accent);
}

.statusbar {
  display: flex; justify-content: space-between;
  padding: 6px 16px;
  font-size: 12px; color: var(--text-3);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

/* ---------- Calendar ---------- */

.cal-nav { display: flex; gap: 10px; align-items: center; }

.seg { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.seg-btn { height: 36px; min-width: 38px; padding: 0 12px; border: 0; background: transparent; font-weight: 500; display: grid; place-items: center; }
.seg-btn + .seg-btn { border-left: 1px solid var(--border-strong); }
.seg-btn:hover { background: var(--surface-2); }

.cal-layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }

.cal-month {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.cal-weekdays { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-bottom: 1px solid var(--border); }
.cal-weekdays span { padding: 10px 10px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }

.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(112px, 1fr); }
.cal-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 6px;
  min-width: 0;
  cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
  transition: background .1s;
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell:nth-last-child(-n+7) { border-bottom: 0; }
.cal-cell:hover { background: var(--surface-2); }
.cal-cell.other { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.cal-cell.other .cal-num { color: var(--text-3); }
.cal-cell.weekend:not(.other) { background: color-mix(in srgb, var(--surface-2) 35%, transparent); }
.cal-cell.selected { box-shadow: inset 0 0 0 2px var(--accent); }

.cal-num {
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.cal-cell.today .cal-num { background: var(--accent); color: var(--accent-text); }

.ev-chip {
  --c: #4f46e5;
  display: block;
  font-size: 12px; line-height: 1.35;
  padding: 2px 6px;
  border-radius: 4px;
  background: color-mix(in srgb, var(--c) 16%, transparent);
  border-left: 3px solid var(--c);
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ev-chip .t { color: var(--text-2); font-variant-numeric: tabular-nums; margin-right: 3px; }
.ev-chip.task-chip { --c: var(--text-3); background: transparent; border-left: 0; padding-left: 2px; color: var(--text-2); }
.ev-chip.task-chip::before { content: "○ "; }
.ev-chip.task-chip.done { text-decoration: line-through; color: var(--text-3); }
.ev-chip.task-chip.done::before { content: "● "; color: var(--accent); }
.more { font-size: 11.5px; color: var(--text-3); padding-left: 4px; }

.cal-day { position: sticky; top: 0; }
.cal-day h2 { font-size: 17px; }
.cal-day .sub { margin: 2px 0 14px; font-size: 13px; }
.day-actions { display: flex; gap: 8px; margin-bottom: 18px; }
.day-actions .btn { flex: 1; }
.day-section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 16px 0 8px; }

.event-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.event-item {
  --c: #4f46e5;
  display: flex; gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--c) 10%, transparent);
  border-left: 3px solid var(--c);
  cursor: pointer;
}
.event-item:hover { background: color-mix(in srgb, var(--c) 17%, transparent); }
.event-time { font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-width: 82px; }
.event-body { min-width: 0; }
.event-title { font-weight: 600; overflow-wrap: anywhere; }
.event-desc { font-size: 12.5px; color: var(--text-2); margin-top: 2px; white-space: pre-line; overflow-wrap: anywhere; }
.event-repeat { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }

/* Vandaag – agenda-lijst */
.upcoming-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); margin: 16px 0 8px; }

.mini-notes { list-style: none; margin: 0; padding: 0; }
.mini-notes li { padding: 9px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.mini-notes li:hover { background: var(--surface-2); }
.mini-notes .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-notes .d { font-size: 12px; color: var(--text-3); }

/* ---------- Dialogs ---------- */

.dialog {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 0;
  width: min(480px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(10, 12, 16, .45); backdrop-filter: blur(2px); }
.dialog form { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 14px; }
.dialog h2 { font-size: 18px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check-field { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check-field input { width: 17px; height: 17px; accent-color: var(--accent); }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 28px; height: 28px; border-radius: 50%;
  border: 0; padding: 0;
  background: var(--c);
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 2px transparent;
  transition: box-shadow .12s;
}
.swatch.active { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--c); }

.form-error { margin: 0; color: var(--danger); font-size: 13px; }

.dialog-wide { width: min(620px, calc(100vw - 32px)); }
.dialog-inner { padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 6px; }
.dialog-inner .sub { margin: 0 0 10px; font-size: 13.5px; }
.history-list { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.history-body { flex: 1; min-width: 0; }
.history-top { display: flex; gap: 10px; font-size: 12px; color: var(--text-3); }
.history-type { font-weight: 600; color: var(--accent); }
.history-title { font-weight: 600; overflow-wrap: anywhere; }
.history-preview {
  font-size: 13px; color: var(--text-2); margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
@media (max-width: 760px) {
  .history-item { flex-direction: column; align-items: stretch; }
}

.dialog-actions { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.spacer { flex: 1; }

/* ---------- Toasts ---------- */

.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  z-index: 100;
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex; align-items: center; gap: 14px;
  background: #1a1e26; color: #f3f4f6;
  padding: 10px 12px 10px 16px;
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: toast-in .18s ease-out;
}
:root[data-theme="dark"] .toast { background: #2a2f3a; }
.toast button { border: 0; background: transparent; color: #a5b4fc; font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.toast button:hover { background: rgba(255, 255, 255, .08); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Responsive ---------- */

@media (max-width: 1100px) {
  .cal-layout { grid-template-columns: 1fr; }
  .cal-day { position: static; }
  .today-grid { grid-template-columns: 1fr; }
  .today-grid .card-tasks { grid-row: auto; }
  .page { padding: 48px 48px; }
}

@media (max-width: 760px) {
  body { font-size: 15px; }
  .app { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .main { grid-row: 1; }

  .sidebar {
    grid-row: 2;
    flex-direction: row;
    border-right: 0; border-top: 1px solid var(--border);
    padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
    gap: 0;
  }
  .brand, .hide-mobile { display: none; }
  .nav { flex-direction: row; flex: 1; gap: 0; }
  .nav-item { flex-direction: column; gap: 2px; font-size: 11px; padding: 6px 4px; align-items: center; text-align: center; position: relative; }
  .nav-item svg { width: 20px; height: 20px; }
  .badge { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; min-width: 18px; height: 18px; font-size: 10.5px; }
  .sidebar-footer { margin: 0; border: 0; padding: 0; flex-direction: row; }
  .sidebar-footer .nav-item { width: 56px; }
  .sidebar-footer .nav-item span { display: none; }
  .account { border: 0; margin: 0; padding: 0; }
  .auth-card { padding: 22px 18px 18px; }

  .view { padding: 22px 16px 40px; }
  h1 { font-size: 22px; }

  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 12px 14px; }
  .stat-num { font-size: 22px; }

  .task-form { grid-template-columns: 1fr 1fr; }
  .task-form input[type="text"] { grid-column: 1 / -1; border-color: var(--border-strong); }
  .task-form .btn { grid-column: 1 / -1; }
  .task-form .goal-toggle { grid-column: 1 / -1; justify-self: start; }
  .goal-head { padding: 12px 6px 12px 12px; }
  .goal-body { padding: 4px 8px 10px; }
  .sub-date { width: 118px; }
  .sub-add { flex-wrap: wrap; padding-left: 0; }
  .sub-add-plus { display: none; }
  .sub-add input[type="text"] { flex: 1 1 100%; }
  .sub-add input[type="date"] { flex: 1; width: auto; }

  .view-notes { grid-template-columns: 1fr; padding: 0; }
  .view-notes .notes-main { display: none; }
  .view-notes.editing .notes-side { display: none; }
  .view-notes.editing .notes-main { display: flex; }
  .note-back { display: inline-flex; }
  .page-scroll { padding: 12px 8px 40px; }
  .page { padding: 28px 20px; min-height: 70vh; }
  .note-title { font-size: 24px; }
  .editor { min-height: 50vh; }
  .tb-right { margin-left: 0; }

  .cal-head { align-items: flex-start; }
  .cal-weekdays span { padding: 8px 2px; text-align: center; font-size: 11px; }
  .cal-grid { grid-auto-rows: minmax(58px, 1fr); }
  .cal-cell { padding: 4px 2px; align-items: center; gap: 2px; }
  .cal-cell .ev-chip, .cal-cell .more { display: none; }
  .cal-dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
  .cal-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c, var(--text-3)); }

  .field-row { grid-template-columns: 1fr; }
  .toasts { bottom: 84px; width: calc(100% - 32px); }
}

@media (min-width: 761px) { .cal-dots { display: none; } }

/* ---------- Print: alleen de notitie ---------- */

@media print {
  body { background: #fff; }
  .sidebar, .notes-side, .toolbar, .statusbar, .toasts, .view:not(#view-notities) { display: none !important; }
  .app, .main, .view, .notes-main, .editor-wrap, .page-scroll { display: block !important; height: auto !important; overflow: visible !important; background: #fff !important; padding: 0 !important; }
  .page { box-shadow: none; padding: 0; max-width: none; min-height: 0; background: #fff; color: #000; }
  .editor { min-height: 0; }
}
