:root {
  /* Apple Mail (licht) */
  --bg: #f2f2f7;       /* paginakleur */
  --bg2: #ffffff;      /* invoer/velden */
  --card: #ffffff;     /* kaarten */
  --line: #e5e5ea;     /* hairline-scheiding */
  --line2: #c6c6c8;
  --text: #1c1c1e;     /* hoofdtekst */
  --muted: #8e8e93;    /* secundair grijs */
  --accent: #007aff;   /* Apple-blauw */
  --green: #34c759;
  --red: #ff3b30;
  --amber: #ff9500;
  --purple: #af52de;
  --radius: 12px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen { max-width: 680px; margin: 0 auto; padding: 16px; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* Login */
.login-card { margin-top: 16vh; text-align: center; padding: 28px 22px; }
.logo { font-size: 44px; }
h1 { font-size: 22px; margin: 6px 0 2px; font-weight: 700; }
.pin-input {
  width: 100%; margin: 18px 0 12px; padding: 14px; font-size: 22px; text-align: center;
  letter-spacing: 6px; border-radius: 10px; border: 1px solid var(--line2);
  background: var(--bg2); color: var(--text);
}
.pin-input:focus { outline: none; border-color: var(--accent); }

/* Buttons */
.btn {
  display: inline-block; border: none; border-radius: 10px; padding: 13px 18px;
  font-size: 16px; font-weight: 600; cursor: pointer; width: 100%;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.ghost { background: var(--card); color: var(--accent); border: 1px solid var(--line); width: auto; }
.icon-btn {
  background: var(--card); border: 1px solid var(--line); color: var(--accent);
  width: 40px; height: 40px; border-radius: 10px; font-size: 19px; cursor: pointer;
}
.error { color: var(--red); margin-top: 10px; }

/* Topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.topbar h1 { font-size: 26px; margin: 0; font-weight: 700; letter-spacing: -0.02em; }

.stale {
  background: #fff8e6; color: #9a6700;
  border: 1px solid #ffe0a3; padding: 10px 12px; border-radius: 10px; font-size: 14px;
}

/* Cards */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.section { margin: 16px 0; }
.section > h2 {
  font-size: 13px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 0 0 8px 4px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}

.item { padding: 11px 0; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: none; }
.item .row { display: flex; gap: 10px; align-items: baseline; }
.time { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--accent); min-width: 52px; }
.title { font-weight: 600; }
.tag { font-size: 11px; color: var(--muted); border: 1px solid var(--line2); border-radius: 999px; padding: 1px 8px; }
.sub { color: var(--muted); font-size: 14px; margin-top: 2px; }
.summary { font-size: 14px; margin-top: 5px; color: #3a3a3c; }

/* Voorstellen */
.action { border-left: 3px solid var(--amber); padding-left: 12px; }
.action.send { border-left-color: var(--green); }
.action.delete { border-left-color: var(--red); }
.action-buttons { display: flex; gap: 8px; margin-top: 10px; }
.action-buttons .btn { width: auto; flex: 1; padding: 10px; font-size: 14px; }
.btn.approve { background: var(--green); color: #fff; }
.btn.reject { background: var(--card); color: var(--muted); border: 1px solid var(--line2); }
.status-pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; font-weight: 600; }
.status-approved { background: #e7f8ee; color: #1b7a3d; }
.status-rejected { background: #efeff4; color: var(--muted); }
.status-done { background: #e6f0ff; color: var(--accent); }
.status-failed { background: #ffe9e8; color: var(--red); }

.empty { text-align: center; color: var(--muted); padding: 26px 10px; }
.footer { display: flex; justify-content: space-between; align-items: center; margin: 22px 0 8px; }
.draft-body {
  white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 10px; font-size: 13px; margin-top: 8px; max-height: 220px; overflow: auto;
}
.unread-dot { display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--accent); margin-right:6px; }

/* Nu bijwerken */
.btn.generate { width: 100%; margin: 4px 0 10px; }
.toast {
  background: #e6f0ff; color: var(--accent);
  border: 1px solid #cfe0ff; padding: 10px 12px; border-radius: 10px; font-size: 14px;
}

/* Mail-categorieën */
.cat-head {
  display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 700;
  color: var(--text); margin: 14px 0 4px; padding-top: 12px; border-top: 1px solid var(--line);
}
.cat-head:first-child { border-top: none; padding-top: 0; margin-top: 0; }
.cat-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.cat-count { margin-left: auto; color: var(--muted); font-weight: 600; font-size: 12px; }
.mail-item { padding: 9px 0; }
.hint {
  margin-top: 6px; font-size: 13px; color: #6b4ea8;
  background: #f4eefc; border: 1px solid #e6d8fb;
  border-radius: 8px; padding: 6px 10px;
}

/* Agenda afvinken */
.link-btn {
  margin-left: auto; background: none; border: none; color: var(--accent);
  font-size: 12px; cursor: pointer; text-transform: none; letter-spacing: 0; padding: 0;
}
.event-item { display: flex; align-items: flex-start; gap: 10px; }
.event-item .check {
  background: none; border: none; color: var(--accent); font-size: 22px; line-height: 1;
  cursor: pointer; padding: 0; margin-top: 1px; flex: none;
}
.event-item.done { opacity: .5; }
.event-item.done .title { text-decoration: line-through; }
.event-item.done .check { color: var(--green); }
.ev-body { flex: 1; min-width: 0; }

/* Mini-acties onder een mail */
.mini-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.mini {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; padding: 6px 12px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--line2); color: var(--accent);
  text-decoration: none; cursor: pointer; font-weight: 500;
}
.mini:active { background: #e9e9ee; }
.mail-item.is-read { opacity: .5; }
.mail-item.is-read .title { text-decoration: line-through; }

/* Carryover-label */
.tag.carry { color: var(--amber); border-color: #ffd591; background: #fff8e6; }

/* Agenda-schakelaars */
.cal-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 8px 2px; }
.cal-chip {
  font-size: 12px; padding: 5px 10px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line2); background: var(--card); color: var(--text);
}
.cal-chip.off { color: var(--muted); background: var(--bg); text-decoration: line-through; }

/* Antwoord-scherm */
.reply-view {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.reply-card {
  background: var(--card); width: 100%; max-width: 680px; max-height: 92vh; overflow: auto;
  border-radius: 16px 16px 0 0; padding: 18px;
  padding-bottom: calc(18px + env(safe-area-inset-bottom));
}
.reply-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.reply-orig { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.reply-subj { font-weight: 700; }
.reply-body { font-size: 14px; color: #3a3a3c; margin-top: 6px; white-space: pre-wrap; }
.reply-label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }
.reply-text {
  width: 100%; border: 1px solid var(--line2); border-radius: 10px; padding: 12px;
  font-size: 15px; font-family: inherit; color: var(--text); background: var(--bg2); resize: vertical;
}
.reply-text:focus { outline: none; border-color: var(--accent); }
.reply-actions { display: flex; gap: 10px; margin-top: 12px; }
.reply-actions .btn { flex: 1; text-align: center; }
