/* eivogel-mail: stijl in de geest van Proton Mail. Donkere zijbalk, lichte lijst en leesvenster,
   paars accent. Volgt de systeeminstelling voor donker. Desktop: drie kolommen, mobiel: gestapeld. */

:root {
  /* Zijbalk (altijd donker) */
  --side-bg: #1b1a22;
  --side-text: #e6e4ec;
  --side-muted: #a19eb0;
  --side-hover: #2a2833;
  --side-active: #34304a;
  --side-line: #2c2a36;

  /* Inhoud */
  --bg: #ffffff;
  --reader-bg: #f5f4f2;
  --panel: #ffffff;
  --panel-2: #f5f4f2;
  --panel-3: #eae7e4;
  --line: #eae7e4;
  --line-strong: #dedbd8;
  --text: #0c0c14;
  --muted: #706d6b;
  --hint: #8f8d8a;

  --accent: #6d4aff;
  --accent-hover: #6243e6;
  --accent-text: #6d4aff;
  --accent-soft: #f1eeff;
  --accent-soft-2: #e2dbff;
  --on-accent: #ffffff;

  --danger: #dc3251;
  --danger-text: #c0283f;
  --danger-soft: #fdecef;
  --ok: #1ea885;
  --ok-text: #12795f;
  --ok-soft: #e4f6f0;
  --warn: #ff8a00;
  --warn-text: #a85a00;
  --warn-soft: #fff3e3;

  --shadow-sm: 0 1px 2px rgba(12, 12, 20, 0.06);
  --shadow: 0 8px 24px rgba(12, 12, 20, 0.12);
  --shadow-lg: 0 16px 48px rgba(12, 12, 20, 0.18);
  --toast-bg: #262533;
  --toast-text: #ffffff;
  --overlay: rgba(12, 12, 20, 0.45);

  --radius: 8px;
  --radius-lg: 12px;
  --sidebar-w: 240px;
  --list-w: 380px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --side-bg: #0f0e15;
    --side-hover: #1f1d29;
    --side-active: #2c2742;
    --side-line: #1f1d29;

    --bg: #16141c;
    --reader-bg: #121118;
    --panel: #1f1d27;
    --panel-2: #26232f;
    --panel-3: #312d3c;
    --line: #2b2836;
    --line-strong: #3a3647;
    --text: #f1f0f5;
    --muted: #a7a4b5;
    --hint: #8a8799;

    --accent: #8a6eff;
    --accent-hover: #9b84ff;
    --accent-text: #b4a3ff;
    --accent-soft: #261f42;
    --accent-soft-2: #33295a;

    --danger-text: #ff8a9b;
    --danger-soft: #3a1b24;
    --ok-text: #6fdcbf;
    --ok-soft: #14332b;
    --warn-text: #ffbf6e;
    --warn-soft: #3a2a12;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.6);
    --toast-bg: #312d3c;
    --overlay: rgba(0, 0, 0, 0.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.9em; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1rem; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.82rem; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.icon { flex: none; }

/* ---------- Knoppen en invoer ---------- */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--panel); color: var(--text);
  font: inherit; font-size: 0.92rem; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
button:hover, .button:hover { background: var(--panel-2); text-decoration: none; }
button:disabled { opacity: 0.55; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
button.primary:hover, .button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.danger, .button.danger { color: var(--danger-text); border-color: var(--line-strong); background: var(--panel); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
button.link { background: none; border: 0; color: var(--accent-text); padding: 0 6px; min-height: 0; font-weight: 500; }
button.link:hover { background: none; text-decoration: underline; }
button.small, .button.small { min-height: 30px; padding: 0 10px; font-size: 0.85rem; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; min-height: 0; padding: 0;
  border: 0; border-radius: var(--radius); background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.active { color: var(--accent); }
.icon-btn.small { width: 28px; height: 28px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

input, select, textarea {
  width: 100%; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--panel); color: var(--text);
  font: inherit; font-size: 16px; /* voorkomt inzoomen op iOS */
}
input::placeholder, textarea::placeholder { color: var(--hint); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
input[type="color"] { width: 64px; height: 38px; padding: 2px; }
textarea { resize: vertical; }
textarea.code { font-family: var(--mono); font-size: 13px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft-2); }

/* ---------- Opstarten en inloggen ---------- */
.boot, .reader-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  height: 100%; color: var(--hint);
}
.spinner {
  width: 26px; height: 26px; margin: 16px auto;
  border: 3px solid var(--panel-3); border-top-color: var(--accent); border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.auth-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; background: var(--side-bg); }
.auth-card {
  width: 100%; max-width: 400px; padding: 32px 28px;
  background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg);
}
.auth-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; font-size: 1.3rem; font-weight: 700; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form p { margin: 0; color: var(--muted); }
.auth-form button.primary { min-height: 42px; }
.auth-form .code { font-family: var(--mono); font-size: 1.5rem; letter-spacing: 0.3em; text-align: center; }
.form-error { color: var(--danger-text); min-height: 1em; margin: 0; font-size: 0.9rem; }
.qr { align-self: center; background: #fff; border-radius: 8px; padding: 8px; border: 1px solid var(--line); }
.secret { display: block; word-break: break-all; padding: 8px; background: var(--panel-2); border-radius: 6px; margin-top: 6px; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) 1fr;
  height: 100vh; height: 100dvh;
}
.sidebar, .list-pane, .read-pane, .settings-pane { min-height: 0; min-width: 0; }
.settings-pane { display: none; grid-column: 2 / 4; overflow: auto; background: var(--reader-bg); }
body[data-view="settings"] .list-pane, body[data-view="settings"] .read-pane { display: none; }
body[data-view="settings"] .settings-pane { display: block; }
.mobile-only { display: none !important; }

/* ---------- Zijbalk ---------- */
.sidebar {
  display: flex; flex-direction: column; gap: 2px;
  padding: calc(14px + env(safe-area-inset-top)) 12px calc(14px + env(safe-area-inset-bottom));
  background: var(--side-bg); color: var(--side-text); overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; font-weight: 700; font-size: 1.05rem; color: #fff; }
.compose-btn { margin: 0 2px 14px; min-height: 42px; font-weight: 600; border-radius: var(--radius); }
.nav { display: flex; flex-direction: column; gap: 1px; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 7px 10px; border-radius: var(--radius); color: var(--side-text); font-size: 0.92rem;
}
.nav-link:hover { background: var(--side-hover); text-decoration: none; }
.nav-link .icon { color: var(--side-muted); }
.nav-link.active { background: var(--side-active); color: #fff; font-weight: 600; }
.nav-link.active .icon { color: #fff; }
.nav-link.sub { padding-left: 28px; font-size: 0.86rem; color: var(--side-muted); }
.nav-link.sub.active { color: #fff; }
.nav-link .grow { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-section { margin: 16px 10px 6px; font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--side-muted); }
.sidebar .badge { background: transparent; color: var(--side-text); font-weight: 700; padding: 0 2px; }
.sidebar .nav-link.active .badge { color: #fff; }
.badge { min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 0.78rem; font-weight: 700; text-align: right; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--muted); }
.offline-pill { margin: 8px; padding: 6px 10px; border-radius: var(--radius); background: rgba(255, 138, 0, 0.18); color: #ffc477; font-size: 0.85rem; text-align: center; }

/* ---------- Lijst ---------- */
.list-pane { display: flex; flex-direction: column; border-right: 1px solid var(--line); background: var(--bg); position: relative; }
.list-head {
  display: flex; align-items: center; gap: 6px;
  padding: calc(12px + env(safe-area-inset-top)) 14px 6px;
}
.list-title { flex: 1; font-size: 1.2rem; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-wrap { position: relative; margin: 4px 14px 10px; }
.search-wrap .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--hint); }
.search { padding-left: 34px; background: var(--panel-2); border-color: transparent; border-radius: var(--radius); }
.search:focus { background: var(--panel); }
.list-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
.thread-list { display: flex; flex-direction: column; }
.row {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 11px 14px 11px 12px; border-bottom: 1px solid var(--line);
  cursor: pointer; background: var(--bg); position: relative;
  transition: transform 0.15s ease-out, background 0.1s;
}
.row::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: transparent; }
.row:hover { background: var(--panel-2); }
.row.selected { background: var(--accent-soft); }
.row.selected::before { background: var(--accent); }
.row .dot { margin-top: 7px; width: 8px; height: 8px; }
.row-main { flex: 1; min-width: 0; }
.row-top { display: flex; align-items: baseline; gap: 6px; }
.row .from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.row .count { font-size: 0.75rem; color: var(--muted); border: 1px solid var(--line-strong); border-radius: 4px; padding: 0 4px; line-height: 1.4; }
.row .date { flex: none; font-size: 0.8rem; color: var(--muted); }
.row-subject { display: flex; align-items: center; gap: 5px; overflow: hidden; white-space: nowrap; color: var(--text); }
.row-subject > span:not(.label):not(.flag):not(.clip) { overflow: hidden; text-overflow: ellipsis; }
.row-snippet { color: var(--muted); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row:not(.unread) .from, .row:not(.unread) .row-subject { color: var(--muted); }
.row.unread .from, .row.unread .row-subject { color: var(--text); font-weight: 700; }
.row.unread .date { color: var(--text); font-weight: 600; }
.row.failed .from { color: var(--danger-text); }
.row .flag { color: var(--warn); display: inline-flex; }
.row .clip { color: var(--muted); display: inline-flex; }
.row.swipe-left { background: var(--ok-soft); }
.row.swipe-right { background: var(--accent-soft); }
.label {
  display: inline-block; flex: none; padding: 0 7px; border-radius: 4px;
  background: var(--accent-soft); color: var(--accent-text); font-size: 0.72rem; font-weight: 600; line-height: 1.6;
}
.label.danger { background: var(--danger-soft); color: var(--danger-text); }
.empty { padding: 48px 20px; text-align: center; color: var(--hint); }
.load-more { display: block; margin: 12px auto; }
.offline-note { padding: 8px 14px; background: var(--warn-soft); color: var(--warn-text); font-size: 0.85rem; }
.fab {
  position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 16px; padding: 0;
  background: var(--accent); border: 0; color: var(--on-accent); box-shadow: var(--shadow);
}
.fab:hover { background: var(--accent-hover); }

/* ---------- Leesvenster ---------- */
.read-pane { display: flex; flex-direction: column; background: var(--reader-bg); }
.reader-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.folder-chip { font-size: 0.8rem; color: var(--muted); padding: 2px 8px; border-radius: 4px; background: var(--panel-2); }
.reader-scroll { flex: 1; overflow-y: auto; padding: 20px 24px calc(40px + env(safe-area-inset-bottom)); }
.reader-head { margin-bottom: 16px; }
.reader-head h2 { font-size: 1.4rem; font-weight: 700; line-height: 1.3; overflow-wrap: anywhere; }
.reader-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.identity-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 10px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line); font-size: 0.8rem; color: var(--muted);
}
.identity-chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--accent)); }
.banner {
  margin: 0 0 14px; padding: 14px 16px; border-radius: var(--radius-lg);
  background: var(--accent-soft); border: 1px solid var(--accent-soft-2);
}
.banner.bad { background: var(--danger-soft); border-color: transparent; }
.banner p { margin: 0 0 10px; }
.banner-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.messages { display: flex; flex-direction: column; gap: 10px; }
.message { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); overflow: hidden; box-shadow: var(--shadow-sm); }
.message.outgoing { border-left: 3px solid var(--accent); }
.message-head { display: flex; gap: 12px; align-items: center; padding: 12px 16px; cursor: pointer; }
.message:not(.expanded) .message-head:hover { background: var(--panel-2); }
.message.expanded .message-head { cursor: default; }
.avatar {
  width: 36px; height: 36px; flex: none; border-radius: var(--radius);
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); font-weight: 700; font-size: 0.85rem;
}
.message-who { flex: 1; min-width: 0; overflow: hidden; }
.message-who > div:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.collapsed-snippet { color: var(--muted); font-size: 0.86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.message.expanded .collapsed-snippet { display: none; }
.message-date { flex: none; font-size: 0.8rem; color: var(--muted); }
.message-body { display: none; }
.message.expanded .message-body { display: block; }
.message-details { padding: 0 16px 10px 64px; font-size: 0.85rem; color: var(--muted); }
.message-details .addr-line { color: var(--text); }
.addr-line { overflow-wrap: anywhere; }
.auth-warn { margin: 0 16px 10px; padding: 8px 12px; border-radius: var(--radius); background: var(--danger-soft); color: var(--danger-text); font-size: 0.88rem; }
.images-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px;
  margin: 0 16px 10px; padding: 7px 12px; border-radius: var(--radius); background: var(--panel-2); font-size: 0.85rem; color: var(--muted);
}
.mail-frame { display: block; width: 100%; min-height: 60px; border: 0; border-top: 1px solid var(--line); background: #fff; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 0; }
.attachment {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  min-height: 34px; padding: 4px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius);
  background: var(--panel); color: var(--text); font-size: 0.85rem;
}
button.attachment:hover { border-color: var(--accent); }
.attachment.uploading { opacity: 0.6; }
.att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.message-actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 12px 16px; }
.reader-footer { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }

/* ---------- Opstellen ---------- */
.compose-dock {
  position: fixed; right: 20px; bottom: 0; z-index: 40;
  display: flex; align-items: flex-end; gap: 12px; pointer-events: none;
}
.compose {
  pointer-events: auto;
  display: flex; flex-direction: column;
  width: 560px; max-width: calc(100vw - 40px); height: min(660px, calc(100vh - 40px));
  background: var(--panel); border: 1px solid var(--line); border-bottom: 0;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-lg);
}
.compose.large { width: min(920px, calc(100vw - 40px)); height: calc(100vh - 40px); }
.compose.minimized { height: auto; }
.compose.minimized .compose-body, .compose.minimized .compose-foot { display: none; }
.compose.dragging { outline: 2px dashed var(--accent); outline-offset: -6px; }
.compose-head {
  display: flex; align-items: center; gap: 2px;
  padding: 6px 6px 6px 16px; background: var(--side-bg); color: #fff;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0; cursor: pointer;
}
.compose-head .icon-btn { color: var(--side-muted); }
.compose-head .icon-btn:hover { background: var(--side-hover); color: #fff; }
.compose-title { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; }
.field { display: flex; align-items: center; gap: 8px; padding: 2px 16px; border-bottom: 1px solid var(--line); min-height: 42px; position: relative; }
.field > label { flex: none; width: 34px; color: var(--muted); font-size: 0.88rem; }
.field select, .field input { border: 0; background: transparent; padding: 8px 0; box-shadow: none; }
.field-row { display: flex; align-items: center; border-bottom: 1px solid var(--line); padding-right: 12px; }
.field-row .field { flex: 1; border-bottom: 0; }
.chips { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 5px 0; min-width: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  padding: 1px 2px 1px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); font-size: 0.86rem; font-weight: 500;
}
.chip.invalid { background: var(--danger-soft); color: var(--danger-text); }
.chip-x { min-height: 0; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 1rem; }
.chip-x:hover { background: var(--accent-soft-2); }
.addr-input { flex: 1; min-width: 120px; width: auto; }
.suggest {
  position: absolute; left: 54px; right: 12px; top: 100%; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.suggest-item { padding: 8px 12px; cursor: pointer; font-size: 0.9rem; }
.suggest-item:hover, .suggest-item.active { background: var(--accent-soft); }
.subject { font-weight: 600; }
.editor-toolbar { display: flex; gap: 2px; padding: 4px 12px; border-bottom: 1px solid var(--line); background: var(--panel-2); }
.compose-paper { flex: 1; background: #fff; color: #0c0c14; padding: 16px; min-height: 220px; }
.editor { min-height: 140px; outline: none; font: 15px/1.5 var(--font); overflow-wrap: anywhere; }
.editor:empty::before { content: "Schrijf je bericht..."; color: #8f8d8a; }
.editor a, .compose-paper a { color: #6d4aff; }
.editor blockquote, .quoted-body blockquote { margin: 0 0 0 0.6em; padding-left: 0.8em; border-left: 3px solid #c9bdff; color: #4e4b48; }
.sig-block { margin-top: 16px; padding-top: 8px; border-top: 1px dashed #dedbd8; user-select: none; overflow-x: auto; }
.sig-block.off, .sig-block:empty { display: none; }
.sig-block img { max-width: 100%; height: auto; }
.quoted { margin-top: 14px; color: #4e4b48; }
.quoted summary { cursor: pointer; color: #8f8d8a; font-size: 0.85rem; }
.quoted-body { margin-top: 8px; font-size: 0.92rem; overflow-x: auto; }
.quoted-body img { max-width: 100%; height: auto; }
.compose .attachments { padding: 10px 16px; }
.compose-foot { display: flex; align-items: center; gap: 6px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.compose-foot button.primary { min-height: 38px; padding: 0 18px; }

/* ---------- Instellingen ---------- */
.settings { display: grid; grid-template-columns: 240px 1fr; min-height: 100%; }
.settings-nav { padding: calc(16px + env(safe-area-inset-top)) 12px 14px; border-right: 1px solid var(--line); background: var(--bg); display: flex; flex-direction: column; gap: 2px; }
.settings-nav-head { display: flex; align-items: center; gap: 6px; padding: 4px 8px 14px; }
.settings-nav-head h2 { font-size: 1.2rem; font-weight: 700; }
.settings-link { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-radius: var(--radius); color: var(--text); }
.settings-link .icon { color: var(--muted); }
.settings-link:hover { background: var(--panel-2); text-decoration: none; }
.settings-link.active { background: var(--accent-soft); color: var(--accent-text); font-weight: 600; }
.settings-link.active .icon { color: var(--accent); }
.settings-content { padding: calc(22px + env(safe-area-inset-top)) 32px calc(40px + env(safe-area-inset-bottom)); max-width: 1000px; min-width: 0; }
.section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.section-head h2 { font-size: 1.35rem; font-weight: 700; }
.settings-content > p { margin: 0 0 18px; }
.cards { display: flex; flex-direction: column; gap: 12px; }
.card { border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--panel); box-shadow: var(--shadow-sm); }
.card-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-body { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.card-body p { margin: 0; }
.card-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 16px; }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; background: var(--panel-2); color: var(--muted); font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok-text); }
.pill.bad { background: var(--danger-soft); color: var(--danger-text); }
.pill.warn { background: var(--warn-soft); color: var(--warn-text); }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form { display: flex; flex-direction: column; gap: 16px; max-width: 720px; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 0.85rem; color: var(--text); font-weight: 600; }
.hint { font-size: 0.8rem; color: var(--muted); }
.form-actions, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.addr-compose { display: flex; align-items: center; gap: 6px; }
.addr-compose input, .addr-compose select { flex: 1; }
.group { margin-top: 22px; }
.group h3 { margin-bottom: 8px; }
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; background: var(--panel); }
.list:empty { display: none; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-bottom: 1px solid var(--line); color: var(--text); background: var(--panel); }
.list-row:last-child { border-bottom: 0; }
a.list-row:hover { background: var(--panel-2); text-decoration: none; }
.validation { display: flex; flex-direction: column; gap: 4px; font-size: 0.88rem; }
.v-error { color: var(--danger-text); }
.v-warn { color: var(--warn-text); }
.v-ok { color: var(--ok-text); }
.preview-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.preview-frame { width: 100%; height: 220px; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
.inline-form { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; }
.inline-form.wrap { flex-wrap: wrap; padding: 14px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.inline-form.wrap select, .inline-form.wrap input { width: auto; flex: 1 1 140px; }

/* ---------- Wizard ---------- */
.wizard { display: flex; flex-direction: column; gap: 18px; }
.steps { display: flex; gap: 6px; padding: 0; margin: 0; list-style: none; overflow-x: auto; }
.steps li { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.steps li.current { background: var(--accent-soft); border-color: var(--accent-soft-2); color: var(--accent-text); font-weight: 600; }
.steps li.done { color: var(--ok-text); }
.step-n { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--panel-3); font-size: 0.75rem; font-weight: 700; }
.steps li.current .step-n { background: var(--accent); color: var(--on-accent); }
.steps li.done .step-n { background: var(--ok-soft); }
.wizard-body { display: flex; flex-direction: column; gap: 12px; padding: 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.wizard-body p { margin: 0; }
.wizard-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.dns { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.dns th, table.dns td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.dns tr:last-child td { border-bottom: 0; }
table.dns th { background: var(--panel-2); color: var(--muted); font-weight: 600; }
table.dns tr.conflict td { background: var(--danger-soft); }
table.dns td.value { max-width: 360px; }
.copyable { display: inline-flex; align-items: flex-start; gap: 4px; max-width: 100%; }
.copyable code { word-break: break-all; }

/* ---------- Dialogen en meldingen ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px; background: var(--overlay); }
.dialog { width: 100%; max-width: 440px; padding: 24px; border-radius: 16px; background: var(--panel); box-shadow: var(--shadow-lg); display: flex; flex-direction: column; gap: 12px; }
.dialog h3 { font-size: 1.1rem; }
.dialog p { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.dialog-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
#toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 110;
  transform: translate(-50%, 150%); transition: transform 0.2s ease; pointer-events: none;
  width: max-content; max-width: calc(100vw - 32px);
}
#toast.show { transform: translate(-50%, 0); pointer-events: auto; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--radius); background: var(--toast-bg); color: var(--toast-text);
  box-shadow: var(--shadow-lg); font-size: 0.92rem;
}
.toast button.link { color: #c4b5ff; }
.toast.error { background: var(--danger); }
.toast.error button.link { color: #fff; }
.backdrop { display: none; }

/* ---------- Mobiel ---------- */
@media (max-width: 1023px) {
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .layout { grid-template-columns: 1fr; }
  .list-pane, .read-pane, .settings-pane { grid-column: 1; grid-row: 1; border-right: 0; }
  .read-pane, .settings-pane { display: none; }
  body[data-view="thread"] .list-pane { display: none; }
  body[data-view="thread"] .read-pane { display: flex; }
  body[data-view="settings"] .settings-pane { display: block; }

  .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60; width: min(300px, 84vw);
    transform: translateX(-102%); transition: transform 0.2s ease;
  }
  body.drawer-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  body.drawer-open .backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: var(--overlay); }

  .reader-scroll { padding: 14px 10px calc(40px + env(safe-area-inset-bottom)); }
  .message-details { padding-left: 16px; }
  .reader-toolbar { padding-left: 4px; padding-right: 4px; }

  .compose-dock { inset: 0; right: 0; display: block; pointer-events: none; }
  .compose, .compose.fullscreen {
    position: absolute; inset: 0; width: 100%; max-width: none; height: 100%;
    border-radius: 0; border: 0; padding-top: env(safe-area-inset-top); background: var(--side-bg);
  }
  .compose .compose-body, .compose .compose-foot { background: var(--panel); }
  .compose.minimized { inset: auto 0 0 0; height: auto; padding-top: 0; }
  .compose-head { border-radius: 0; }
  .compose-paper { overflow-x: hidden; }
  .compose-foot .save-state { display: none; }
  .compose-foot button.link { white-space: normal; text-align: left; min-width: 0; flex-shrink: 1; }

  .settings { grid-template-columns: 1fr; }
  .settings.has-section .settings-nav { display: none; }
  .settings:not(.has-section) .settings-content { display: none; }
  .settings-nav { border-right: 0; }
  .settings-content { padding: calc(12px + env(safe-area-inset-top)) 14px calc(40px + env(safe-area-inset-bottom)); }
  .form, .wizard-body { padding: 16px; }
  .preview-pair { grid-template-columns: 1fr; }
  .att-name { max-width: 150px; }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  :root { --sidebar-w: 210px; --list-w: 330px; }
}
