/* MailFinder - stijl in de lijn van VaultFind, met drie thema's:
   data-theme="dark" (standaard), "light" en "pro" (professioneel). */

:root,
[data-theme="dark"] {
    --bg: #0a1020;
    --bg-grad: linear-gradient(180deg, #08101d 0%, #0b1222 100%);
    --panel: #10182b;
    --panel-2: #0d1424;
    --panel-3: #16213a;
    --border: #22314f;
    --border-strong: #2f4370;
    --text: #edf2ff;
    --muted: #98a5c3;
    --accent: #63b8f4;
    --accent-2: #8ed4ff;
    --accent-ink: #09111f;
    --accent-soft: rgba(99, 184, 244, 0.12);
    --focus: #3e64ff;
    --select: rgba(99, 184, 244, 0.16);
    --unread: #63b8f4;
    --flag: #f5a524;
    --danger: #ff6b6b;
    --ok: #3ddc97;
    --mark-bg: rgba(255, 213, 79, 0.28);
    --mark-text: #ffe8a3;
    --shadow: 0 14px 40px rgba(0, 0, 0, 0.32);
    --radius: 16px;
    --radius-sm: 10px;
    --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --title-font: var(--font);
    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #f3f6fb;
    --bg-grad: linear-gradient(180deg, #f7f9fd 0%, #eef2f9 100%);
    --panel: #ffffff;
    --panel-2: #f6f8fc;
    --panel-3: #eef3fb;
    --border: #dbe3f0;
    --border-strong: #c2cfe4;
    --text: #172033;
    --muted: #5f6b84;
    --accent: #2f7fe0;
    --accent-2: #1d6ad0;
    --accent-ink: #ffffff;
    --accent-soft: rgba(47, 127, 224, 0.10);
    --focus: #2f7fe0;
    --select: rgba(47, 127, 224, 0.12);
    --unread: #2f7fe0;
    --flag: #e08a00;
    --danger: #d64545;
    --ok: #1f9d6a;
    --mark-bg: #fff0a6;
    --mark-text: #3a2e00;
    --shadow: 0 12px 34px rgba(23, 32, 51, 0.10);
    color-scheme: light;
}

[data-theme="pro"] {
    --bg: #eceae6;
    --bg-grad: linear-gradient(180deg, #efede9 0%, #e7e4de 100%);
    --panel: #fbfaf8;
    --panel-2: #f3f1ed;
    --panel-3: #e9e5de;
    --border: #d6d1c7;
    --border-strong: #bfb8aa;
    --text: #23262b;
    --muted: #6b6a66;
    --accent: #1f4e79;
    --accent-2: #163b5e;
    --accent-ink: #ffffff;
    --accent-soft: rgba(31, 78, 121, 0.09);
    --focus: #1f4e79;
    --select: rgba(31, 78, 121, 0.11);
    --unread: #1f4e79;
    --flag: #a5602a;
    --danger: #a33a3a;
    --ok: #2e7d4f;
    --mark-bg: #f3dfa2;
    --mark-text: #2b2100;
    --shadow: 0 8px 22px rgba(40, 34, 25, 0.10);
    --radius: 6px;
    --radius-sm: 4px;
    --title-font: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg-grad);
    background-color: var(--bg);
    overflow: hidden;
}

svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
code, kbd {
    font-family: ui-monospace, Menlo, monospace;
    font-size: 12px;
    background: var(--panel-3);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1px 5px;
}
mark { background: var(--mark-bg); color: var(--mark-text); border-radius: 3px; padding: 0 1px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small-text { font-size: 12px; }
.pad { padding: 14px; }
.spacer { flex: 1; }

.app-shell {
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0 18px 16px;
}

/* ---------------- topbar ---------------- */
.topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 22px;
    align-items: center;
    padding: 14px 0 12px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: grid; place-items: center;
    background: var(--accent-soft);
    border: 1px solid var(--border);
    color: var(--accent);
}
.logo svg { width: 28px; height: 28px; }
.eyebrow { font-size: 11px; letter-spacing: 0.22em; text-transform: uppercase; color: var(--muted); }
.brand-title { font-family: var(--title-font); font-size: 19px; font-weight: 650; white-space: nowrap; }

.search-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 12px; }
.search-box { position: relative; }
.search-icon { position: absolute; left: 16px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--muted); }
.search-box input {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--focus);
    border-radius: 18px;
    padding: 14px 48px 14px 46px;
    font-size: 16px;
    outline: none;
    transition: box-shadow .15s;
}
[data-theme="pro"] .search-box input { border-color: var(--border-strong); border-radius: var(--radius); }
.search-box input:focus { box-shadow: 0 0 0 3px var(--accent-soft); }
.search-box .icon-btn { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
.search-btn, .primary-btn {
    background: var(--accent); color: var(--accent-ink);
    border: none; border-radius: 18px; font-weight: 700; cursor: pointer;
    padding: 12px 18px;
    text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
[data-theme="pro"] .search-btn, [data-theme="pro"] .primary-btn { border-radius: var(--radius); }
.search-btn:hover, .primary-btn:hover { background: var(--accent-2); }
.primary-btn.small, .ghost-btn.small { padding: 7px 12px; font-size: 13px; border-radius: 12px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
.ghost-btn, .ghost-select, .tool-btn {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 10px 14px;
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    display: inline-flex; align-items: center; gap: 6px;
}
[data-theme="pro"] .ghost-btn, [data-theme="pro"] .ghost-select, [data-theme="pro"] .tool-btn { border-radius: var(--radius); }
.ghost-btn:hover, .tool-btn:hover, .ghost-select:hover { border-color: var(--border-strong); background: var(--panel-3); }
.ghost-btn svg { width: 18px; height: 18px; }
.ghost-btn svg.gear { width: 20px; height: 20px; stroke-width: 1.7; }
.icon-btn {
    border: 1px solid transparent; background: transparent; cursor: pointer;
    width: 32px; height: 32px; border-radius: 10px;
    display: inline-grid; place-items: center; color: var(--muted); font-size: 16px;
}
.icon-btn:hover { background: var(--panel-3); color: var(--text); }
.icon-btn.small { width: 24px; height: 24px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; padding: 4px 6px; }
.link-btn:hover { text-decoration: underline; }

.status-pill {
    display: inline-flex; align-items: center; gap: 9px;
    border: 1px solid var(--border); background: var(--panel-2);
    padding: 10px 14px; border-radius: 14px; cursor: pointer; max-width: 300px;
}
#statusText { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.status-light { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--muted); }
.status-light.idle { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.status-light.busy { background: var(--flag); box-shadow: 0 0 8px var(--flag); animation: pulse 1.2s infinite; }
.status-light.error { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }

/* ---------------- filters ---------------- */
.filter-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding-bottom: 12px; }
.seg { display: inline-flex; background: var(--panel-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
[data-theme="pro"] .seg { border-radius: var(--radius); }
.seg-btn { border: none; background: transparent; padding: 7px 14px; border-radius: 999px; cursor: pointer; color: var(--muted); font-weight: 600; }
[data-theme="pro"] .seg-btn { border-radius: var(--radius-sm); }
.seg-btn.active { background: var(--accent); color: var(--accent-ink); }
.toggle {
    display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none;
    border: 1px solid var(--border); border-radius: 999px; padding: 7px 12px; background: var(--panel-2); font-size: 13px;
}
[data-theme="pro"] .toggle { border-radius: var(--radius); }
.toggle input { accent-color: var(--accent); margin: 0; }
.toggle:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-2); }
[data-theme="light"] .toggle:has(input:checked), [data-theme="pro"] .toggle:has(input:checked) { color: var(--accent); }
.chip-select, .date-range input {
    border: 1px solid var(--border); border-radius: 999px; padding: 7px 12px; background: var(--panel-2); font-size: 13px; cursor: pointer;
}
[data-theme="pro"] .chip-select, [data-theme="pro"] .date-range input { border-radius: var(--radius); }
.date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.date-range input { padding: 6px 10px; }
body.mode-att .msg-only { display: none; }
body:not(.mode-att) .att-only { display: none; }
#resultInfo { font-size: 13px; }

/* ---------------- werkruimte ---------------- */
.workspace {
    flex: 1; min-height: 0;
    display: grid;
    grid-template-columns: 250px minmax(340px, 0.9fr) minmax(420px, 1.3fr);
    gap: 14px;
}
body.mode-att .workspace { grid-template-columns: 250px minmax(420px, 1.4fr) minmax(380px, 1fr); }
body.sidebar-collapsed .workspace { grid-template-columns: 38px minmax(340px, 0.9fr) minmax(420px, 1.3fr); }
body.sidebar-collapsed.mode-att .workspace { grid-template-columns: 38px minmax(420px, 1.4fr) minmax(380px, 1fr); }
.sidebar-rail { display: none; }
body.sidebar-collapsed .sidebar > :not(.sidebar-rail) { display: none; }
body.sidebar-collapsed .sidebar-rail {
    display: flex; flex-direction: column; align-items: center; gap: 12px; flex: 1;
    border: none; background: transparent; cursor: pointer; color: var(--muted); padding: 12px 0;
}
body.sidebar-collapsed .sidebar-rail:hover { color: var(--accent); background: var(--panel-2); }
.rail-arrow { font-size: 20px; line-height: 1; }
.rail-label { writing-mode: vertical-rl; letter-spacing: .16em; text-transform: uppercase; font-size: 11px; }
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    min-height: 0;
    overflow: hidden;
}

/* sidebar */
.sidebar { display: flex; flex-direction: column; }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px 8px; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.folder-tree { overflow: auto; padding: 0 8px 12px; flex: 1; }
.folder-item {
    display: flex; align-items: center; gap: 8px; width: 100%;
    border: none; background: transparent; text-align: left; cursor: pointer;
    padding: 7px 10px; border-radius: var(--radius-sm); color: var(--text);
}
.folder-item:hover { background: var(--panel-3); }
.folder-item.active { background: var(--select); color: var(--accent-2); font-weight: 600; }
[data-theme="light"] .folder-item.active, [data-theme="pro"] .folder-item.active { color: var(--accent); }
.folder-item .f-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-item .f-count { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.folder-item svg { width: 16px; height: 16px; flex: none; color: var(--muted); }
.folder-account { margin-top: 10px; font-weight: 650; }
.folder-account .f-name { font-size: 13px; }
.folder-sub { padding-left: 18px; font-size: 13px; }
.folder-sub.depth-2 { padding-left: 32px; }
.folder-sub.depth-3 { padding-left: 46px; }

/* lijst */
.list-pane { display: flex; flex-direction: column; position: relative; }
.result-list { overflow: auto; flex: 1; outline: none; }
.list-sentinel { height: 1px; }
.msg-row {
    display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 11px;
    padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; position: relative;
}
.msg-row:hover { background: var(--panel-2); }
.msg-row.active { background: var(--select); }
.msg-row.active::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    display: grid; place-items: center; font-weight: 700; font-size: 14px; color: #fff;
    background: hsl(var(--hue, 210), 45%, 46%);
}
[data-theme="pro"] .avatar { border-radius: 6px; background: hsl(var(--hue, 210), 22%, 45%); }
.avatar.big { width: 46px; height: 46px; font-size: 18px; }
.row-top { display: flex; gap: 8px; align-items: baseline; }
.row-from { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.unread .row-from::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--unread); margin-right: 7px; vertical-align: 1px; }
.row-date { font-size: 12px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-subject { margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-row.unread .row-subject { font-weight: 600; }
.row-snippet {
    margin-top: 3px; font-size: 12.5px; color: var(--muted); line-height: 1.45;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.row-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 7px; align-items: center; }
.badge {
    display: inline-flex; align-items: center; gap: 5px; max-width: 220px;
    font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
    border: 1px solid var(--border); background: var(--panel-2); color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
[data-theme="pro"] .badge { border-radius: 4px; }
.badge.att { cursor: pointer; color: var(--text); }
.badge.att:hover { border-color: var(--accent); }
.badge.box { background: transparent; }
.badge.flag { color: var(--flag); border-color: var(--flag); }
.att-hit { margin-top: 5px; font-size: 12px; color: var(--muted); border-left: 2px solid var(--accent); padding-left: 8px; }

/* bijlagen-grid */
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; padding: 14px; }
.att-card {
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2);
    overflow: hidden; display: flex; flex-direction: column; cursor: pointer; position: relative;
    transition: transform .12s, border-color .12s;
}
.att-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.att-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.att-card.active { border-color: var(--accent); }
.att-thumb { height: 120px; display: grid; place-items: center; background: var(--panel-3); overflow: hidden; }
.att-thumb img { width: 100%; height: 100%; object-fit: cover; }
.att-thumb.doc img { object-fit: contain; background: #fff; }
.att-info { padding: 9px 10px 10px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.att-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-sub { font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-snip { font-size: 11.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.att-check {
    position: absolute; top: 8px; left: 8px; width: 22px; height: 22px; border-radius: 6px;
    background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.6); display: grid; place-items: center; color: #fff; font-size: 13px;
    opacity: 0; transition: opacity .12s;
}
.att-card:hover .att-check, .att-card.selected .att-check { opacity: 1; }
.att-card.selected .att-check { background: var(--accent); border-color: var(--accent); }
.att-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.att-card:hover .att-actions { opacity: 1; }
.mini-btn { width: 28px; height: 28px; border-radius: 8px; border: none; background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; cursor: pointer; text-decoration: none; }
.mini-btn svg { width: 15px; height: 15px; }

.file-icon {
    width: 44px; height: 54px; border-radius: 6px; flex: none;
    display: grid; place-items: center; font-size: 10.5px; font-weight: 800; letter-spacing: .03em; color: #fff;
    background: var(--ficon, #64748b); text-transform: uppercase;
    clip-path: polygon(0 0, 72% 0, 100% 20%, 100% 100%, 0 100%);
}
.file-icon.sm { width: 22px; height: 27px; font-size: 7px; border-radius: 3px; }

.selection-bar {
    display: flex; gap: 12px; align-items: center; padding: 9px 14px;
    background: var(--accent-soft); border-bottom: 1px solid var(--border); font-size: 13px;
}

.empty-state { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 30px; color: var(--muted); }
.empty-state h3 { color: var(--text); margin: 8px 0; font-family: var(--title-font); }
.load-more { text-align: center; padding: 14px; color: var(--muted); font-size: 12px; }

/* lezer */
.reader { display: flex; flex-direction: column; }
.reader-empty { flex: 1; display: grid; place-content: center; text-align: center; color: var(--muted); gap: 4px; }
.reader-empty svg { width: 74px; height: 74px; margin: 0 auto 6px; opacity: .55; }
.reader-content { display: flex; flex-direction: column; min-height: 0; height: 100%; overflow: auto; }
.reader-toolbar { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.tool-btn { padding: 6px 11px; font-size: 12.5px; border-radius: 10px; }
.back-btn { display: none; }
.reader-subject { font-family: var(--title-font); font-size: 21px; line-height: 1.3; margin: 16px 18px 10px; word-wrap: break-word; }
.reader-meta { display: flex; gap: 12px; padding: 0 18px 12px; }
.reader-meta-text { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.r-from { word-break: break-word; }
.r-line { font-size: 13px; word-break: break-word; }
.notice { margin: 0 18px 10px; padding: 9px 12px; border-radius: var(--radius-sm); background: var(--accent-soft); border: 1px solid var(--border); font-size: 13px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.notice.warn { border-color: var(--flag); background: rgba(245,165,36,.10); margin: 0 0 14px; }
.attachment-strip { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 18px 12px; }
.att-chip {
    display: inline-flex; align-items: center; gap: 9px; max-width: 280px;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2);
    padding: 6px 6px 6px 8px; cursor: pointer;
}
.att-chip:hover { border-color: var(--accent); }
.att-chip.unavailable { opacity: .55; }
.att-chip .chip-text { min-width: 0; display: flex; flex-direction: column; }
.att-chip .chip-name { font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-chip .chip-size { font-size: 11px; color: var(--muted); }
.att-chip .mini-btn { background: var(--panel-3); color: var(--text); }
.att-chip .mini-btn:hover { background: var(--accent); color: var(--accent-ink); }
.att-zip { align-self: center; font-size: 12.5px; }
.body-frame-wrap { padding: 0 12px 14px; flex: 1; }
.body-frame { width: 100%; min-height: 300px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; display: block; }
[data-theme="dark"] .body-frame.plain { background: #151b2b; }

/* modals */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(5, 9, 18, .62); backdrop-filter: blur(3px); }
.modal-panel { position: relative; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; max-height: 92vh; }
.preview-panel { width: min(1100px, 94vw); height: 90vh; }
.settings-panel { width: min(720px, 94vw); }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.modal-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.pv-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 52vw; }
.modal-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.preview-body { flex: 1; min-height: 0; overflow: auto; display: flex; align-items: center; justify-content: center; background: var(--panel-2); }
.preview-body img { max-width: 100%; max-height: 100%; object-fit: contain; }
.preview-body iframe, .preview-body object { width: 100%; height: 100%; border: none; background: #fff; }
.preview-body pre { align-self: stretch; width: 100%; margin: 0; padding: 18px 22px; white-space: pre-wrap; word-wrap: break-word; font: 13px/1.55 ui-monospace, Menlo, monospace; }
.preview-body .pv-empty { text-align: center; color: var(--muted); padding: 30px; }
.preview-body video, .preview-body audio { max-width: 100%; max-height: 100%; }

.settings-body { padding: 16px 20px 20px; overflow: auto; }
.settings-body h3 { font-family: var(--title-font); font-size: 15px; margin: 22px 0 8px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stat { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--panel-2); }
.stat .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--muted); }
.progress-wrap { margin: 14px 0 10px; }
.progress { height: 8px; background: var(--panel-3); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width .4s; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row { display: flex; gap: 10px; align-items: center; }
.account-names { display: grid; gap: 8px; margin-bottom: 10px; }
.account-names label { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }
.account-names input { border: 1px solid var(--border); background: var(--panel-2); border-radius: var(--radius-sm); padding: 8px 10px; }
.account-list { display: grid; gap: 8px; margin-bottom: 10px; }
.account-row {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center;
    border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--panel-2); padding: 10px 12px;
}
.account-row .acc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.account-row .acc-dot.ok { background: var(--ok); }
.account-row .acc-dot.err { background: var(--danger); }
.account-row .acc-title { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row .acc-sub { font-size: 12px; color: var(--muted); }
.account-row .acc-sub.err { color: var(--danger); }
.account-row .acc-actions { display: flex; gap: 6px; align-items: center; }
.switch { position: relative; width: 38px; height: 22px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 22px; cursor: pointer; transition: background .15s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .15s; }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::before { transform: translateX(16px); }
.account-form { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 14px; margin: 10px 0; background: var(--panel-2); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.form-grid label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; }
.form-grid input[type=text], .form-grid input[type=email], .form-grid input[type=password], .form-grid input[type=number], .form-grid select {
    border: 1px solid var(--border); background: var(--panel); border-radius: var(--radius-sm); padding: 9px 10px; font-size: 14px; width: 100%;
}
.form-grid input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.adv summary { cursor: pointer; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.folder-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; max-height: 180px; overflow: auto; margin-top: 6px; font-size: 13px; }
.folder-pick label { flex-direction: row; align-items: center; gap: 6px; }
.test-result { margin: 12px 0 4px; padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid var(--border); }
.test-result.ok { border-color: var(--ok); background: rgba(61, 220, 151, .10); }
.test-result.err { border-color: var(--danger); background: rgba(255, 107, 107, .10); }
.test-result.busy { color: var(--muted); }
.form-grid + .test-result + .btn-row, .account-form .btn-row { margin-top: 12px; }

.error-list { margin-top: 14px; font: 11.5px/1.5 ui-monospace, Menlo, monospace; color: var(--danger); max-height: 160px; overflow: auto; }

.popover {
    position: fixed; z-index: 60; width: 520px; max-width: 94vw;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px;
}
.popover h4 { margin: 0 0 8px; font-family: var(--title-font); }
.popover table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.popover td { padding: 4px 6px; vertical-align: top; border-top: 1px solid var(--border); }
.popover td:first-child { white-space: nowrap; }

.ctx-menu {
    position: fixed; z-index: 90; min-width: 240px; max-width: min(360px, 94vw);
    background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); padding: 6px; user-select: none;
}
.ctx-head { padding: 6px 10px 8px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-head strong { color: var(--text); font-size: 13px; }
.ctx-item { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; text-align: left;
            padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text); font-size: 13.5px; }
.ctx-item:hover, .ctx-item:focus { background: var(--select); outline: none; }
.ctx-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.msg-row, .att-card { -webkit-touch-callout: none; }
.r-from strong.sender-link, .row-from.sender-link { cursor: pointer; }
.r-from strong.sender-link:hover { text-decoration: underline; }
@media (hover: none) { .ctx-item { padding: 12px 12px; font-size: 15px; } }

/* login */
.login-body { overflow: auto; }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { margin-bottom: 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { border: 1px solid var(--border); background: var(--panel-2); border-radius: var(--radius-sm); padding: 12px; font-size: 16px; color: var(--text); }
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-card .brand-title { display: block !important; }
.login-card .brand > div:not(.logo) { display: block !important; }
.user-line { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; }

/* spinner tijdens zoeken */
.search-spinner {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 70;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 22px 28px; border-radius: var(--radius); background: var(--panel);
    border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--muted); font-size: 13px;
    pointer-events: none;
}
.spinner-ring {
    width: 38px; height: 38px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--accent);
    animation: mf-spin .8s linear infinite;
}
@keyframes mf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner-ring { animation-duration: 2.5s; } }
.scope-chip {
    border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent);
    border-radius: 999px; padding: 3px 10px; margin-right: 8px; font-size: 12px; cursor: pointer;
}
[data-theme="pro"] .scope-chip { border-radius: 4px; }
.scope-chip:hover { background: var(--select); }
#resultInfo { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; }

.toast {
    position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 80;
    background: var(--text); color: var(--panel); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 13px;
}

/* scrollbars */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); background-clip: padding-box; border: 2px solid transparent; }

/* ---------------- responsief ---------------- */
.mobile-only, .phone-only { display: none !important; }
.drawer-backdrop { display: none; }
.count-badge {
    min-width: 17px; height: 17px; border-radius: 9px; padding: 0 4px;
    background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700;
    display: inline-grid; place-items: center; margin-left: -4px;
}
.app-shell { height: 100vh; height: 100dvh; }

/* Aanraakschermen: geen hover, dus knoppen altijd tonen en groter maken */
@media (hover: none) {
    .att-check, .att-actions { opacity: 1; }
    .att-check { width: 28px; height: 28px; }
    .mini-btn { width: 34px; height: 34px; }
    .folder-item { padding: 10px 10px; }
    .tool-btn { padding: 8px 12px; }
}

/* Tablet en kleine laptop: mappen als lade, lijst + lezer naast elkaar */
@media (max-width: 1250px) {
    .mobile-only { display: inline-flex !important; }
    .workspace, body.mode-att .workspace,
    body.sidebar-collapsed .workspace, body.sidebar-collapsed.mode-att .workspace {
        grid-template-columns: minmax(300px, 0.9fr) minmax(0, 1.3fr); gap: 12px;
    }
    body.mode-att .workspace { grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); }
    .sidebar, body.sidebar-collapsed .sidebar {
        visibility: visible;
        position: fixed; z-index: 45; top: 0; bottom: 0; left: 0;
        width: min(300px, 84vw); border-radius: 0 var(--radius) var(--radius) 0;
        transform: translateX(-105%); transition: transform .22s ease;
        padding-top: env(safe-area-inset-top);
    }
    body.drawer-open .sidebar { transform: none; }
    body.drawer-open .drawer-backdrop {
        display: block; position: fixed; inset: 0; z-index: 44; background: rgba(5, 9, 18, .5);
    }
    #collapseSidebarBtn, body.sidebar-collapsed .sidebar-rail { display: none; }
    body.sidebar-collapsed .sidebar > :not(.sidebar-rail) { display: revert; }
    body.sidebar-collapsed .folder-tree { display: block; }
    body.sidebar-collapsed .sidebar-head { display: flex; }
    .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; }
    .brand-title { display: none; }
    .eyebrow { font-size: 12px; letter-spacing: .16em; color: var(--text); font-weight: 700; }
}

/* Smalle tablet (iPad staand) en telefoon: lezer schuift over de lijst */
@media (max-width: 900px) {
    .workspace, body.mode-att .workspace,
    body.sidebar-collapsed .workspace, body.sidebar-collapsed.mode-att .workspace { grid-template-columns: minmax(0, 1fr); }
    .reader {
        position: fixed; inset: 0; z-index: 40; border-radius: 0; border: none;
        transform: translateX(100%); transition: transform .22s ease; visibility: hidden;
        padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom);
    }
    body.reader-open .reader { transform: none; visibility: visible; }
    .back-btn { display: inline-grid; font-size: 20px; }
    .topbar { grid-template-columns: auto minmax(0, 1fr); }
    .topbar-actions { grid-column: 2; grid-row: 1; justify-content: flex-end; }
    .search-row { grid-column: 1 / -1; }
}

/* Telefoon */
@media (max-width: 640px) {
    .phone-only { display: inline-flex !important; }
    .app-shell {
        padding: env(safe-area-inset-top) max(10px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(10px, env(safe-area-inset-left));
    }
    .topbar { gap: 10px; padding: 10px 0 8px; }
    .logo { width: 38px; height: 38px; }
    .brand > div:not(.logo) { display: none; }
    .search-row { grid-template-columns: 1fr; }
    .search-btn { display: none; }
    .search-box input { font-size: 16px; padding: 12px 42px 12px 42px; border-radius: 14px; } /* 16px: geen iOS-zoom */
    .search-box input::placeholder { font-size: 14px; }
    .topbar-actions { gap: 6px; }
    .ghost-btn, .ghost-select { padding: 8px 10px; border-radius: 12px; }
    .status-pill { padding: 8px 10px; }
    #statusText { display: none; }
    #themeSelect { max-width: 96px; }
    .topbar-actions { min-width: 0; }
    /* filters: standaard ingeklapt, via de filterknop open */
    .filter-row { display: none; padding-bottom: 10px; gap: 8px; }
    body.filters-open .filter-row { display: flex; }
    .filter-row .spacer { display: none; }
    .date-range { width: 100%; }
    .date-range input { flex: 1; min-width: 0; }
    #resultInfo { width: 100%; }
    .chip-select, .date-range input, .toggle { font-size: 14px; padding: 8px 12px; }
    .result-summary { display: block; }
    .msg-row { padding: 12px; gap: 10px; }
    .row-badges .badge.box { display: none; }
    .att-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; padding: 10px; }
    .att-thumb { height: 110px; }
    .panel { border-radius: 12px; }
    .reader-toolbar { padding: 10px 12px; gap: 6px; overflow-x: auto; flex-wrap: nowrap; }
    .reader-toolbar > * { flex: none; }
    #revealBtn, #sourceBtn { display: none; }
    .reader-subject { font-size: 19px; margin: 12px 14px 8px; }
    .reader-meta { padding: 0 14px 10px; }
    .attachment-strip { padding: 0 14px 10px; }
    .att-chip { max-width: 100%; flex: 1 1 100%; }
    .notice { margin: 0 14px 10px; }
    .body-frame-wrap { padding: 0 6px 10px; }
    .body-frame { border-radius: 8px; }
    .modal-panel { width: 100vw; max-height: none; height: 100dvh; border-radius: 0; border: none;
                   padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); }
    .preview-panel { width: 100vw; height: 100dvh; }
    .modal-head { flex-wrap: wrap; gap: 8px; }
    .modal-title { flex: 1 1 100%; order: 0; }
    .pv-name { max-width: 70vw; }
    .modal-actions { flex: 1 1 100%; justify-content: space-between; }
    .settings-panel .modal-head { flex-wrap: nowrap; }
    .settings-panel .modal-title { flex: 1 1 auto; }
    .settings-body { padding: 14px; }
    .account-names label { grid-template-columns: 1fr; gap: 4px; }
    .form-grid, .folder-pick { grid-template-columns: 1fr; }
    .account-row { grid-template-columns: auto minmax(0, 1fr); }
    .account-row .acc-actions { grid-column: 1 / -1; justify-content: flex-end; }
    .popover { left: 8px !important; right: 8px; width: auto; max-height: 70vh; overflow: auto; }
    .popover td:first-child { white-space: normal; }
    .ctx-menu {
    position: fixed; z-index: 90; min-width: 240px; max-width: min(360px, 94vw);
    background: var(--panel); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    box-shadow: var(--shadow); padding: 6px; user-select: none;
}
.ctx-head { padding: 6px 10px 8px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); margin-bottom: 4px;
            overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-head strong { color: var(--text); font-size: 13px; }
.ctx-item { display: flex; align-items: center; gap: 10px; width: 100%; border: none; background: none; text-align: left;
            padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text); font-size: 13.5px; }
.ctx-item:hover, .ctx-item:focus { background: var(--select); outline: none; }
.ctx-item svg { width: 16px; height: 16px; color: var(--muted); flex: none; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.msg-row, .att-card { -webkit-touch-callout: none; }
.r-from strong.sender-link, .row-from.sender-link { cursor: pointer; }
.r-from strong.sender-link:hover { text-decoration: underline; }
@media (hover: none) { .ctx-item { padding: 12px 12px; font-size: 15px; } }

/* login */
.login-body { overflow: auto; }
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(380px, 100%); padding: 26px; display: flex; flex-direction: column; gap: 14px; }
.login-card .brand { margin-bottom: 6px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input { border: 1px solid var(--border); background: var(--panel-2); border-radius: var(--radius-sm); padding: 12px; font-size: 16px; color: var(--text); }
.login-card input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.login-card .brand-title { display: block !important; }
.login-card .brand > div:not(.logo) { display: block !important; }
.user-line { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: 13px; }

/* spinner tijdens zoeken */
.search-spinner {
    position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 70;
    display: flex; flex-direction: column; align-items: center; gap: 12px;
    padding: 22px 28px; border-radius: var(--radius); background: var(--panel);
    border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--muted); font-size: 13px;
    pointer-events: none;
}
.spinner-ring {
    width: 38px; height: 38px; border-radius: 50%;
    border: 3px solid var(--border); border-top-color: var(--accent);
    animation: mf-spin .8s linear infinite;
}
@keyframes mf-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner-ring { animation-duration: 2.5s; } }
.scope-chip {
    border: 1px solid var(--accent); background: var(--accent-soft); color: var(--accent);
    border-radius: 999px; padding: 3px 10px; margin-right: 8px; font-size: 12px; cursor: pointer;
}
[data-theme="pro"] .scope-chip { border-radius: 4px; }
.scope-chip:hover { background: var(--select); }
#resultInfo { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 4px; }

.toast { bottom: calc(18px + env(safe-area-inset-bottom)); }
}
