/* ==========================================================================
   Design-Tokens
   ========================================================================== */
:root {
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --radius: 10px;
    --radius-sm: 6px;
    --sidebar-w: 248px;
    --list-w: 380px;
    --ease: cubic-bezier(.2, .7, .3, 1);

    --bg: #f4f5f8;
    --surface: #ffffff;
    --surface-2: #f8f9fb;
    --surface-hover: #eef1f6;
    --border: #e3e6ec;
    --text: #1b1f29;
    --text-2: #5b6372;
    --text-3: #8a91a0;
    --accent: #4f6bed;
    --accent-hover: #3f59d6;
    --accent-soft: #e8ecfd;
    --accent-text: #ffffff;
    --danger: #d9434f;
    --danger-soft: #fde9eb;
    --warn: #e0a100;
    --selected: #e8ecfd;
    --unread-dot: #4f6bed;
    --shadow: 0 1px 2px rgba(20, 24, 36, .06), 0 4px 16px rgba(20, 24, 36, .06);
    --shadow-lg: 0 12px 48px rgba(20, 24, 36, .18);
    --scrollbar: rgba(20, 24, 36, .16);
    --scrollbar-hover: rgba(20, 24, 36, .32);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0f1116;
    --surface: #171a21;
    --surface-2: #1c2028;
    --surface-hover: #232833;
    --border: #2a2f3a;
    --text: #e7e9ee;
    --text-2: #a3aab8;
    --text-3: #727a8a;
    --accent: #7b8ff7;
    --accent-hover: #93a4fa;
    --accent-soft: #252c4a;
    --accent-text: #0f1116;
    --danger: #f06470;
    --danger-soft: #3a1e23;
    --selected: #232a45;
    --unread-dot: #7b8ff7;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --shadow-lg: 0 12px 48px rgba(0, 0, 0, .5);
    --scrollbar: rgba(255, 255, 255, .12);
    --scrollbar-hover: rgba(255, 255, 255, .26);
    color-scheme: dark;
}

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

html, body { height: 100%; }

body {
    margin: 0;
    font: 14px/1.5 var(--font);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

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

:root[data-theme="dark"] .only-light, :root:not([data-theme="dark"]) .only-dark { display: none; }

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

/* Dezente Scrollbars: schmal, ohne Spur, kräftiger beim Überfahren */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
*:hover { scrollbar-color: var(--scrollbar-hover) transparent; }

/* Fallback für Browser ohne scrollbar-color (Safari) */
@supports not (scrollbar-color: auto) {
    ::-webkit-scrollbar { width: 8px; height: 8px; }
    ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: transparent; }
    ::-webkit-scrollbar-thumb { background: var(--scrollbar); border: 2px solid transparent; border-radius: 8px; background-clip: padding-box; }
    ::-webkit-scrollbar-thumb:hover { background-color: var(--scrollbar-hover); }
}

/* ==========================================================================
   Bedienelemente
   ========================================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-weight: 500;
    transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { background: var(--surface-hover); }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; cursor: default; }
.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-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--border)); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-danger-solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger-solid:hover { background: color-mix(in srgb, var(--danger) 88%, #000); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { color: var(--text); }
.btn-block { width: 100%; }
.btn-small { height: 30px; padding: 0 10px; font-size: 13px; }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-2);
    transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn.active { color: var(--warn); }
.icon-btn.active svg { fill: currentColor; }

.avatar {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 13px;
    font-weight: 600;
    color: #fff;
    background: var(--avatar, var(--accent));
    flex: none;
    text-transform: uppercase;
}
.avatar.large { width: 42px; height: 42px; font-size: 16px; }

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--accent), #8a5cf6);
    color: #fff;
}
.brand-mark svg { width: 24px; height: 24px; }
.brand-mark.small { width: 30px; height: 30px; border-radius: 8px; }
.brand-mark.small svg { width: 17px; height: 17px; }

.mobile-only, .sidebar-backdrop { display: none; }

/* ==========================================================================
   Login
   ========================================================================== */
.login {
    min-height: 100%;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(ellipse at top left, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%),
        radial-gradient(ellipse at bottom right, color-mix(in srgb, #8a5cf6 14%, transparent), transparent 55%),
        var(--bg);
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 36px 32px 32px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    display: grid;
    gap: 16px;
}
.login-brand { display: flex; align-items: center; gap: 14px; }
.login-brand h1 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
.login-sub { margin: -4px 0 8px; color: var(--text-2); }
.login-theme { position: absolute; top: 14px; right: 14px; }

.field { display: grid; gap: 6px; }
.field span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.field input {
    height: 42px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.login-error {
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 13px;
}
.login-card .btn-block { height: 42px; margin-top: 4px; }

/* ==========================================================================
   App-Layout: drei Spalten
   ========================================================================== */
.app {
    display: grid;
    grid-template-columns: var(--sidebar-w) var(--list-w) minmax(0, 1fr);
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

/* --- Spalte 1 ----------------------------------------------------------- */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 0;
    padding: 16px 12px 12px;
    background: var(--bg);
    border-right: 1px solid var(--border);
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 0 6px; font-size: 16px; }

.folders { flex: 1; overflow-y: auto; display: grid; align-content: start; gap: 2px; margin: 0 -4px; padding: 0 4px; }
.folder {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 36px;
    padding: 0 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-2);
    text-align: left;
    transition: background .15s, color .15s;
}
.folder:hover { background: var(--surface-hover); color: var(--text); }
.folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder.drop-target { outline: 2px dashed var(--accent); outline-offset: -2px; }
.folder .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder .count { font-size: 12px; font-weight: 600; color: var(--accent); }
.folder-row { display: flex; align-items: center; gap: 2px; min-width: 0; }
.folder-row .folder { flex: 1; min-width: 0; }
.folder-row { position: relative; }
.folder-more {
    position: absolute;
    right: 4px;
    top: 50%;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 5px;
    background: var(--surface-hover);
    color: var(--text-2);
    opacity: 0;
    transform: translateY(-50%);
    transition: opacity .12s;
}
.folder-more:hover { background: var(--border); color: var(--text); }
.folder-row:hover .folder-more, .folder-more:focus-visible, .folder-more[aria-expanded="true"] { opacity: 1; }
.folder-row:hover .folder .count { visibility: hidden; }
.folder-row:has(.folder.active) .folder-more { background: var(--accent-soft); }
@media (hover: none) {
    .folder-more { opacity: 1; background: transparent; }
    .folder .count { margin-right: 28px; }
}

.dropdown-menu.folder-menu { position: fixed; top: 0; left: 0; right: auto; z-index: 60; }
.dropdown-menu button.danger { color: var(--danger); }
.dropdown-menu button.danger:hover { background: var(--danger-soft); }
.folder-sep { height: 1px; margin: 8px 6px; background: var(--border); }

.sidebar-foot {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}
.user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.user-mail { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; color: var(--text-2); }
.sidebar-actions { display: flex; }

/* --- Spalte 2 ----------------------------------------------------------- */
.list-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
}
.list-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px 8px; }
.list-head h2 { flex: 1; margin: 0; font-size: 18px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-tools { display: grid; gap: 10px; padding: 4px 16px 12px; border-bottom: 1px solid var(--border); }

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text-3);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search input { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; color: var(--text); }

.segmented { display: flex; gap: 2px; padding: 3px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.segmented button {
    flex: 1;
    height: 26px;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 500; }

.messages { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 0; list-style: none; }
.msg {
    position: relative;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 2px 8px;
    padding: 12px 16px 12px 36px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background .12s;
    user-select: none;
}
.msg:hover { background: var(--surface-hover); }
.msg.selected { background: var(--selected); }
.msg.selected::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--accent); }
.msg.unread::after {
    content: "";
    position: absolute;
    left: 14px;
    top: 19px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--unread-dot);
}
.msg.checked { background: var(--selected); }
.msg.cursor { box-shadow: inset 3px 0 0 var(--accent); }

/* --- Checkboxen ---------------------------------------------------------- */
.check {
    display: grid;
    place-items: center;
    flex: none;
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1.5px solid var(--text-3);
    border-radius: 5px;
    background: var(--surface);
    color: transparent;
    cursor: pointer;
    transition: background .12s, border-color .12s, opacity .12s;
}
.check:hover { border-color: var(--accent); }
.check svg { width: 12px; height: 12px; stroke-width: 3; }
.check.checked, .msg.checked .check { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.check.mixed { background: var(--accent); border-color: var(--accent); }
.check.mixed svg { display: none; }
.check.mixed::after { content: ""; width: 8px; height: 2px; border-radius: 1px; background: var(--accent-text); }

/* In der Liste erscheint die Checkbox beim Überfahren und dauerhaft, sobald ausgewählt wird */
.msg .check { position: absolute; z-index: 1; left: 9px; top: 14px; opacity: 0; }
.msg.unread::after { pointer-events: none; }
.msg:hover .check, .msg .check:focus-visible, .app.selecting .msg .check { opacity: 1; }
.msg:hover.unread::after, .app.selecting .msg.unread::after { opacity: 0; }

@media (hover: none) {
    .msg .check { opacity: 1; }
    .msg.unread::after { left: auto; right: 6px; top: 6px; }
}

/* --- Auswahlleiste ------------------------------------------------------- */
.selection-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 46px;
    padding: 4px 8px 4px 9px;
    border-bottom: 1px solid var(--border);
    background: var(--accent-soft);
    animation: bar-in .18s var(--ease);
}
.selection-count { flex: 1; min-width: 0; font-size: 13px; font-weight: 600; color: var(--accent); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.selection-actions { display: flex; align-items: center; }
.selection-actions .icon-btn { width: 30px; height: 30px; }
.selection-actions .icon-btn:hover { background: var(--surface); }
.selection-actions .icon-btn.danger:hover { background: var(--danger-soft); }
@keyframes bar-in { from { opacity: 0; transform: translateY(-4px); } }

.drag-ghost {
    position: fixed;
    top: -100px;
    left: -100px;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 13px;
    font-weight: 600;
}

.msg .from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.msg.unread .from, .msg.unread .subject { font-weight: 600; }
.msg .date { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.msg .subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.msg .icons { grid-column: 2; grid-row: 2; align-self: center; display: flex; gap: 4px; justify-content: end; color: var(--text-3); }
.msg .icons svg { width: 14px; height: 14px; }
.msg .icons .flag { color: var(--warn); fill: currentColor; }

.list-empty, .list-loading { padding: 48px 16px; text-align: center; color: var(--text-3); }

.skeleton { padding: 14px 16px 14px 36px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.skeleton span { display: block; height: 10px; border-radius: 4px; background: var(--surface-hover); animation: pulse 1.2s ease-in-out infinite; }
.skeleton span:first-child { width: 45%; }
.skeleton span:last-child { width: 80%; }
@keyframes pulse { 50% { opacity: .5; } }

.list-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.list-foot:empty { display: none; }
.list-foot > span { display: inline-flex; align-items: center; gap: 4px; line-height: 1; }
.list-foot .icon-btn { width: 30px; height: 30px; }
.list-foot .icon-btn:disabled { opacity: .35; cursor: default; }

/* --- Spalte 3 ----------------------------------------------------------- */
.read-pane { min-width: 0; min-height: 0; display: flex; flex-direction: column; background: var(--surface); }

.empty-state { margin: auto; display: grid; justify-items: center; gap: 12px; color: var(--text-3); text-align: center; padding: 24px; }
.empty-state svg { width: 56px; height: 56px; stroke-width: 1.2; opacity: .6; }

.reader { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
.reader-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-bottom: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(8px);
}
.toolbar-group { display: flex; gap: 2px; }
.toolbar-group + .toolbar-group { margin-left: auto; }

.reader-head { padding: 22px 28px 16px; }
.reader-head h1 { margin: 0 0 16px; font-size: 21px; line-height: 1.3; letter-spacing: -.01em; overflow-wrap: anywhere; }
.reader-meta { display: flex; align-items: center; gap: 12px; }
.meta-text { flex: 1; min-width: 0; }
.meta-from span { color: var(--text-3); font-size: 13px; }
.meta-to { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader-meta time { font-size: 13px; color: var(--text-3); white-space: nowrap; }

.remote-notice {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 28px 12px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-2);
}
.remote-notice span { flex: 1; }

.reader-body { padding: 4px 28px 24px; }
.reader-body iframe { display: block; width: 100%; border: 0; min-height: 80px; background: #fff; border-radius: var(--radius-sm); }
.reader-body pre {
    margin: 0;
    font: inherit;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}
.reader-body pre a { color: var(--accent); }

.attachments { display: flex; flex-wrap: wrap; gap: 10px; padding: 0 28px 28px; }
.attachment {
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 260px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s, background .15s;
}
.attachment:hover { border-color: var(--accent); background: var(--surface-hover); }
.attachment .att-text { min-width: 0; display: grid; }
.attachment .att-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 500; }
.attachment .att-size { font-size: 12px; color: var(--text-3); }
.attachment > svg { color: var(--accent); }

/* --- Dropdown ----------------------------------------------------------- */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 10;
    min-width: 200px;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    text-align: left;
}
.dropdown-menu button:hover { background: var(--surface-hover); }

/* ==========================================================================
   Verfassen
   ========================================================================== */
.compose {
    width: min(720px, calc(100vw - 32px));
    height: min(640px, calc(100dvh - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.compose[open] { display: flex; }
.compose::backdrop { background: rgba(10, 12, 18, .45); backdrop-filter: blur(2px); }
.compose form { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.compose-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px 20px; }
.compose-head h2 { margin: 0; font-size: 16px; }
.compose-fields { position: relative; padding: 0 20px; }
.compose .row { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid var(--border); }
.compose .row span { width: 56px; color: var(--text-3); font-size: 13px; }
.compose .row input { flex: 1; min-width: 0; height: 40px; border: 0; background: transparent; outline: none; }
.row-toggles { position: absolute; right: 20px; top: 8px; display: flex; gap: 4px; }
.row-toggles button { border: 0; background: transparent; color: var(--text-3); font-size: 13px; padding: 2px 6px; border-radius: 4px; }
.row-toggles button:hover { color: var(--accent); background: var(--surface-hover); }
.compose textarea {
    flex: 1;
    min-height: 0;
    margin: 0;
    padding: 16px 20px;
    border: 0;
    resize: none;
    outline: none;
    background: transparent;
    line-height: 1.6;
}
.compose-files { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px; }
.compose-files:empty { display: none; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 4px 4px 10px;
    border-radius: 999px;
    background: var(--surface-hover);
    font-size: 12px;
}
.chip button { display: grid; place-items: center; width: 20px; height: 20px; border: 0; border-radius: 50%; background: transparent; color: var(--text-3); }
.chip button:hover { background: var(--border); color: var(--text); }
.chip svg { width: 12px; height: 12px; }
.compose-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }
.compose-status { margin-left: auto; font-size: 13px; color: var(--text-3); }

/* ==========================================================================
   Dialog (Bestätigen / Eingabe)
   ========================================================================== */
.modal {
    width: min(440px, calc(100vw - 32px));
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: var(--surface);
    color: var(--text);
    box-shadow: var(--shadow-lg);
}
.modal[open] { animation: modal-in .18s var(--ease); }
.modal::backdrop { background: rgba(10, 12, 18, .45); backdrop-filter: blur(2px); }
.modal-body { display: flex; gap: 14px; padding: 22px 22px 18px; }
.modal-icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--danger-soft);
    color: var(--danger);
}
.modal-icon svg { width: 20px; height: 20px; }
.modal-text { flex: 1; min-width: 0; display: grid; gap: 8px; align-content: start; }
.modal-text h2 { margin: 0; font-size: 16px; line-height: 1.4; }
.modal-text p { margin: 0; color: var(--text-2); }
.modal-input {
    height: 40px;
    margin-top: 4px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.modal-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-text .modal-error { color: var(--danger); font-size: 13px; }
#modal-extra { margin-right: auto; }

/* --- Einstellungen ------------------------------------------------------- */
.modal.settings { width: min(540px, calc(100vw - 32px)); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 16px 4px 22px; }
.modal-head h2 { margin: 0; font-size: 16px; }
.settings-body { display: grid; gap: 12px; padding: 12px 22px 20px; }
.settings-body textarea {
    min-height: 130px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    line-height: 1.5;
    resize: vertical;
}
.settings-body textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.settings-body .hint { margin: -4px 0 4px; font-size: 12px; color: var(--text-3); }
.check-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.check-row input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.settings-body .modal-error { margin: 0; color: var(--danger); font-size: 13px; }
.settings-sep { height: 1px; margin: 4px 0; background: var(--border); }

/* --- Adressbuch ---------------------------------------------------------- */
.modal.contacts { width: min(560px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 32px)); }
.modal.contacts[open] { display: flex; flex-direction: column; }
.contacts-tools { display: flex; gap: 8px; padding: 8px 22px 12px; }
.contacts-tools .search { flex: 1; }
.contact-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 0 22px 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}
.contact-form .field input { height: 36px; }
.contact-form .modal-error { grid-column: 1 / -1; margin: 0; color: var(--danger); font-size: 13px; }
.contact-form-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; gap: 8px; }
.contacts-list { flex: 1; min-height: 0; overflow-y: auto; margin: 0; padding: 0 12px; list-style: none; border-top: 1px solid var(--border); }
.contact { display: flex; align-items: center; gap: 12px; padding: 10px; border-bottom: 1px solid var(--border); }
.contact:last-child { border-bottom: 0; }
.contact-text { flex: 1; min-width: 0; display: grid; }
.contact-text strong, .contact-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-text span { font-size: 13px; color: var(--text-3); }
.contact-actions { display: flex; opacity: 0; transition: opacity .12s; }
.contact:hover .contact-actions, .contact:focus-within .contact-actions { opacity: 1; }
@media (hover: none) { .contact-actions { opacity: 1; } }
.contacts-foot { padding: 10px 22px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }
.contacts-foot:empty { display: none; }

.icon-btn.mini { width: 24px; height: 24px; vertical-align: middle; margin-left: 2px; }
.icon-btn.mini svg { width: 15px; height: 15px; }

/* --- Autovervollständigung ----------------------------------------------- */
.autocomplete {
    position: absolute;
    z-index: 5;
    max-width: calc(100% - 40px);
    max-height: 320px;
    overflow-y: auto;
    margin: 2px 0 0;
    padding: 6px;
    list-style: none;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.autocomplete li { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: var(--radius-sm); cursor: pointer; }
.autocomplete li.active, .autocomplete li:hover { background: var(--surface-hover); }
.autocomplete .avatar { width: 28px; height: 28px; font-size: 11px; }
.ac-text { min-width: 0; display: grid; }
.ac-text strong, .ac-text span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ac-text strong { font-weight: 500; }
.ac-text span { font-size: 12px; color: var(--text-3); }
.autocomplete mark { background: none; color: var(--accent); font-weight: 600; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 14px 14px; }
@keyframes modal-in { from { opacity: 0; transform: translateY(6px) scale(.98); } }

/* ==========================================================================
   Toasts
   ========================================================================== */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; justify-items: center; pointer-events: none; }
.toast {
    padding: 10px 16px;
    border-radius: var(--radius);
    background: var(--text);
    color: var(--bg);
    font-size: 13px;
    box-shadow: var(--shadow-lg);
    animation: toast-in .25s var(--ease);
}
.toast.error { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ==========================================================================
   Responsiv
   ========================================================================== */
@media (max-width: 1200px) {
    :root { --sidebar-w: 216px; --list-w: 320px; }
}

@media (max-width: 960px) {
    .app { grid-template-columns: var(--list-w) minmax(0, 1fr); }
    .mobile-only#btn-menu { display: inline-grid; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 50;
        width: 272px;
        transform: translateX(-100%);
        transition: transform .25s var(--ease);
        box-shadow: var(--shadow-lg);
    }
    .app.sidebar-open .sidebar { transform: none; }
    .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(10, 12, 18, .4); opacity: 0; pointer-events: none; transition: opacity .25s; }
    .app.sidebar-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
}

@media (max-width: 680px) {
    .app { grid-template-columns: 100%; }
    .mobile-only { display: inline-grid; }
    .app[data-view="list"] .read-pane { display: none; }
    .app[data-view="message"] .list-pane { display: none; }
    .reader-toolbar { padding: 8px 12px; }
    .reader-head, .reader-body { padding-left: 16px; padding-right: 16px; }
    .attachments { padding: 0 16px 20px; }
    .remote-notice { margin: 0 16px 12px; }
    .compose { width: 100vw; height: 100dvh; max-width: none; max-height: none; border-radius: 0; }
}
