/* ================================================================
   Zaunbau-Experten Webmail — Custom Build
   STRATO-inspiriertes Design, Marken-Farben aus dem Zaunbau-Logo.
   ================================================================ */

:root {
    --blue: #1e88e5;
    --blue-hover: #1a6fc0;
    --blue-dark: #1c5b9b;
    --blue-tint: #eff7ff;
    --blue-tint-2: #dbecfe;

    --ink: #1f242d;
    --ink-soft: #3d4450;
    --gray-500: #7f8590;
    --gray-300: #c0c4ca;
    --gray-200: #dde0e4;
    --gray-100: #eef1f4;
    --gray-50: #f5f6f8;
    --white: #ffffff;

    --bg: #ffffff;
    --surface: #ffffff;
    --surface-alt: #fafbfc;
    --overlay: rgba(15,23,32,.4);

    --danger-tint: #fee2e2;
    --danger-tint-2: #fecaca;
    --danger-tint-3: #fef2f2;
    --danger-dark: #b91c1c;

    --orange: #f57c00;
    --danger: #dc2626;
    --success: #16a34a;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 999px;

    --header-h: 72px;
    --sidebar-w: 240px;
    --sidebar-w-collapsed: 64px;
}

/* Dunkles Farbschema — folgt per Default der Systemeinstellung, manueller
   Umschalter (data-theme) überschreibt das explizit und wird in localStorage
   gemerkt. Selektor-Reihenfolge wichtig: die spätere Regel gewinnt. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --blue: #4da3ff; --blue-hover: #6db4ff; --blue-dark: #8ec5ff;
        --blue-tint: #16283d; --blue-tint-2: #1c3550;
        --ink: #e7eaee; --ink-soft: #b6bcc6;
        --gray-500: #8b93a1; --gray-300: #454c58; --gray-200: #333a45;
        --gray-100: #262c36; --gray-50: #1d222b;
        --bg: #14171d; --surface: #1a1f28; --surface-alt: #20262f;
        --overlay: rgba(0,0,0,.6);
        --danger-tint: #3a1f1f; --danger-tint-2: #4a2626; --danger-tint-3: #2e1a1a; --danger-dark: #ff8a8a;
        --orange: #ffa726; --danger: #f87171; --success: #4ade80;
    }
}
:root[data-theme="dark"] {
    --blue: #4da3ff; --blue-hover: #6db4ff; --blue-dark: #8ec5ff;
    --blue-tint: #16283d; --blue-tint-2: #1c3550;
    --ink: #e7eaee; --ink-soft: #b6bcc6;
    --gray-500: #8b93a1; --gray-300: #454c58; --gray-200: #333a45;
    --gray-100: #262c36; --gray-50: #1d222b;
    --bg: #14171d; --surface: #1a1f28; --surface-alt: #20262f;
    --overlay: rgba(0,0,0,.6);
    --danger-tint: #3a1f1f; --danger-tint-2: #4a2626; --danger-tint-3: #2e1a1a; --danger-dark: #ff8a8a;
    --orange: #ffa726; --danger: #f87171; --success: #4ade80;
}

* { box-sizing: border-box; }
html, body {
    margin: 0; padding: 0; height: 100%;
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    color: var(--ink);
    background: var(--bg);
    overflow: hidden;
    transition: background-color .15s, color .15s;
}
#app { height: 100vh; display: flex; flex-direction: column; }
button { font-family: inherit; cursor: pointer; }
input, textarea { font-family: inherit; }
a { color: var(--blue-dark); text-decoration: none; }
a:hover { color: var(--blue); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-200); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-500); }

/* ================================================================
   LOGIN SCREEN — STRATO-artiges Einzelpanel mit Top-Header
   ================================================================ */
#login-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--surface);
}
.login-top-header {
    width: 100%;
    box-sizing: border-box;
    padding: 14px 24px;
    border-bottom: 1px solid var(--gray-100);
    background: var(--surface);
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}
.login-top-header-logo {
    height: 36px;
    width: auto;
    max-width: 60vw;
    display: block;
}
.login-card {
    width: calc(100% - 32px);
    max-width: 440px;
    box-sizing: border-box;
    margin: 40px auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 50px -20px rgba(30,136,229,.25), 0 8px 24px -8px rgba(31,36,45,.08);
    overflow: hidden;
}
.login-heading {
    text-align: center;
    padding: 32px 32px 0;
}
.login-eyebrow {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--blue);
    margin-bottom: 6px;
}
.login-title {
    font-size: 28px;
    font-weight: 800;
    color: var(--ink);
    margin: 0 0 10px;
    line-height: 1.15;
}
.login-desc {
    font-size: 14px;
    color: var(--ink-soft);
    max-width: 320px;
    margin: 0 auto;
    line-height: 1.5;
}
.login-box {
    padding: 20px 32px 32px;
    box-sizing: border-box;
}
.login-field { margin-bottom: 16px; }
.login-field label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-soft);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-bottom: 6px;
}
.login-field input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    font-size: 14px;
    background: var(--gray-50);
    outline: none;
    transition: all .15s;
}
.login-field input:focus {
    border-color: var(--blue);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(30,136,229,.12);
}
.login-submit {
    width: 100%;
    box-sizing: border-box;
    padding: 13px;
    background: var(--blue);
    color: var(--surface);
    border: none;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 14px;
    letter-spacing: .01em;
    box-shadow: 0 4px 14px -3px rgba(30,136,229,.45);
    transition: all .15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}
.login-submit:hover { background: var(--blue-hover); transform: translateY(-1px); }
.login-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.login-error {
    background: var(--danger-tint-3);
    color: var(--danger);
    border: 1px solid var(--danger-tint-2);
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}
.login-error.visible { display: block; }

@media (max-width: 599px) {
    .login-top-header { padding: 10px 16px; }
    .login-top-header-logo { height: 30px; }
    .login-card { margin: 20px auto; border-radius: 12px; }
    .login-heading { padding: 24px 20px 0; }
    .login-box { padding: 16px 20px 24px; }
    .login-title { font-size: 24px; }
    .login-desc { font-size: 13px; max-width: 100%; }
}

/* ================================================================
   TOP HEADER
   ================================================================ */
#top-header {
    height: var(--header-h);
    flex: 0 0 auto;
    background: var(--surface);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,.03);
    z-index: 10;
}
.header-left { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.brand { display: flex; align-items: center; padding: 4px 8px; border-radius: 8px; transition: background .12s; }
.brand:hover { background: var(--gray-100); }
.brand img { height: 52px; width: auto; display: block; }
.icon-btn {
    width: 40px; height: 40px; border: none; background: transparent;
    color: var(--ink-soft); border-radius: var(--radius-full);
    display: inline-flex; align-items: center; justify-content: center;
    transition: all .12s;
}
.icon-btn:hover { background: var(--gray-100); color: var(--blue); }

.header-nav { display: flex; align-items: center; gap: 2px; }
.nav-btn {
    width: 40px; height: 40px; border: none; background: transparent;
    color: var(--ink-soft); border-radius: 10px; display: inline-flex;
    align-items: center; justify-content: center; position: relative;
    transition: all .12s;
}
.nav-btn:hover { background: var(--gray-100); color: var(--blue); }
.nav-btn.active { color: var(--blue); background: var(--blue-tint); }
.nav-btn.active::after {
    content: ""; position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%);
    width: 22px; height: 3px; background: var(--blue); border-radius: 2px;
}

.header-search {
    flex: 1; max-width: 560px; margin: 0 auto;
    display: flex; align-items: center; gap: 8px;
    background: var(--gray-100); border-radius: var(--radius-full);
    padding: 4px 14px; height: 40px; color: var(--gray-500);
    transition: all .12s; border: 1px solid transparent;
}
.header-search:focus-within { background: var(--surface); border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,136,229,.12); }
.header-search input { flex: 1; border: none; background: transparent; outline: none; font-size: 14px; color: var(--ink); }
.header-search input::placeholder { color: var(--gray-500); }

.header-right { display: flex; align-items: center; gap: 6px; }

/* ================================================================
   MAIN LAYOUT
   ================================================================ */
#main-layout { flex: 1; display: flex; overflow: hidden; min-height: 0; }

/* --- SIDEBAR --- */
#sidebar {
    width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
    background: var(--surface); border-right: 1px solid var(--gray-200);
    display: flex; flex-direction: column; overflow: hidden;
    transition: width .18s ease, flex-basis .18s ease;
}
#sidebar.collapsed { width: var(--sidebar-w-collapsed); flex-basis: var(--sidebar-w-collapsed); }

.compose-btn-wrap { padding: 16px 12px 12px; }
.compose-btn {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--blue); color: var(--surface); border: none; border-radius: var(--radius-full);
    padding: 12px 20px; font-weight: 700; font-size: 14px;
    box-shadow: 0 3px 12px -2px rgba(30,136,229,.35); transition: all .15s;
}
.compose-btn:hover { background: var(--blue-hover); transform: translateY(-1px); }
#sidebar.collapsed .compose-btn { width: 48px; height: 48px; padding: 0; border-radius: 14px; margin: 0 auto; }
#sidebar.collapsed .compose-btn #compose-open-label { display: none; }
#sidebar.collapsed .compose-btn-wrap { display: flex; justify-content: center; padding: 12px 0; }

.folder-list { flex: 1; overflow-y: auto; padding: 4px 8px; }
#sidebar.collapsed .folder-list { display: flex; flex-direction: column; align-items: center; padding: 6px 0; width: 64px; }

.folder-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; margin: 1px 0;
    border-radius: var(--radius-sm); color: var(--ink); font-size: 14px; font-weight: 500;
    cursor: pointer; transition: background .12s; border: none; background: transparent; width: 100%; text-align: left;
}
.folder-item:hover { background: var(--gray-100); color: var(--blue-dark); }
.folder-item.selected { background: var(--blue-tint); color: var(--blue-dark); font-weight: 700; box-shadow: inset 3px 0 0 var(--blue); }
.folder-item .f-icon { flex: 0 0 auto; display: flex; }
.folder-item .f-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-badge {
    background: var(--blue); color: var(--surface); border-radius: 10px; padding: 1px 8px;
    font-size: 11px; font-weight: 700; min-width: 18px; text-align: center; flex: 0 0 auto;
}

#sidebar.collapsed .folder-item {
    width: 48px; height: 48px; margin: 4px 0; padding: 0; justify-content: center;
    border-radius: 14px; background: var(--gray-50); box-shadow: 0 1px 2px rgba(0,0,0,.04);
    position: relative;
}
#sidebar.collapsed .folder-item.selected { background: var(--blue); color: var(--surface); box-shadow: 0 4px 14px -3px rgba(30,136,229,.45); }
#sidebar.collapsed .folder-item:hover { background: var(--blue-tint); transform: translateY(-1px); }
#sidebar.collapsed .folder-item .f-name, #sidebar.collapsed .folder-item .folder-badge { display: none; }
#sidebar.collapsed .folder-item .f-badge-dot {
    display: block; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px;
    background: var(--blue); border-radius: 999px; border: 2px solid var(--surface);
}
.f-badge-dot { display: none; }

.sidebar-divider { border: none; border-top: 1px solid var(--gray-100); margin: 8px 12px; }
#sidebar.collapsed .sidebar-divider, #sidebar.collapsed .sidebar-section-label { display: none; }
.sidebar-section-label { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .05em; padding: 8px 12px 4px; font-weight: 700; }

.storage-widget { margin: 12px; padding: 14px 16px; background: var(--gray-50); border: 1px solid var(--gray-100); border-radius: var(--radius-md); }
#sidebar.collapsed .storage-widget { padding: 8px; margin: 8px; }
#sidebar.collapsed .storage-label, #sidebar.collapsed .storage-desc { display: none; }
.storage-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--ink); margin-bottom: 8px; font-weight: 600; }
.storage-value { font-size: 13px; font-weight: 700; }
.storage-total { color: var(--gray-500); font-weight: 600; }
.storage-bar { width: 100%; height: 6px; background: var(--gray-200); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.storage-fill { height: 100%; background: var(--blue); border-radius: 999px; transition: width .4s; }
.storage-desc { font-size: 11px; color: var(--gray-500); }

/* --- MESSAGE LIST --- */
#message-list-panel { width: 360px; flex: 0 0 360px; border-right: 1px solid var(--gray-200); display: flex; flex-direction: column; min-width: 0; background: var(--surface); }
.list-toolbar { padding: 14px 16px; border-bottom: 1px solid var(--gray-200); }
.list-toolbar h2 { margin: 0; font-size: 16px; font-weight: 700; }
.list-toolbar .list-count { font-size: 12px; color: var(--gray-500); font-weight: 500; margin-top: 2px; }
.list-actions { display: flex; align-items: center; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--gray-200); }
.list-actions .icon-btn { width: 34px; height: 34px; border-radius: 8px; }
.list-actions .icon-btn:hover { background: var(--blue-tint); color: var(--blue-dark); }
.select-all-wrap { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; }
.select-all-wrap input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--blue); }
.bulk-count { font-size: 12px; font-weight: 600; color: var(--ink-soft); }
.bulk-actions { display: flex; align-items: center; gap: 4px; }
.bulk-actions .icon-btn { width: 34px; height: 34px; border-radius: 8px; }
.bulk-actions .icon-btn:hover { background: var(--blue-tint); color: var(--blue-dark); }
.bulk-actions .icon-btn.danger:hover { background: var(--danger-tint); color: var(--danger); }

.message-list { flex: 1; overflow-y: auto; }
.message-item {
    display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 2px 8px;
    padding: 14px 16px 14px 46px; border-bottom: 1px solid var(--gray-100); cursor: pointer; position: relative;
    transition: background .12s;
}
.message-item:hover { background: var(--surface-alt); }
.message-item.row-checked { background: var(--gray-50); }
.message-item.selected { background: var(--blue-tint); box-shadow: inset 4px 0 0 var(--orange); padding-left: 42px; }
.message-item .m-check {
    position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
    width: 15px; height: 15px; cursor: pointer; accent-color: var(--blue);
}
.message-item .m-dot {
    display: none; position: absolute; left: 36px; top: 50%; transform: translateY(-50%);
    width: 8px; height: 8px; border-radius: 50%; background: var(--blue);
}
.message-item.unread .m-dot { display: block; }
.message-item .m-sender { grid-column: 1; grid-row: 1; font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-item.unread .m-sender, .message-item.unread .m-subject { font-weight: 700; }
.message-item .m-date { grid-column: 2; grid-row: 1; font-size: 11px; color: var(--gray-500); font-weight: 500; white-space: nowrap; justify-self: end; }
.message-item .m-subject { grid-column: 1; grid-row: 2; font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.message-item .m-meta { grid-column: 2; grid-row: 2; font-size: 10px; color: var(--gray-500); justify-self: end; }
.m-thread-count { display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px; background: var(--gray-100); color: var(--gray-500); font-size: 10px; font-weight: 700; vertical-align: middle; }
.list-empty, .list-loading { padding: 40px 20px; text-align: center; color: var(--gray-500); font-size: 13px; }

/* --- KONVERSATIONSANSICHT (gestapelte Nachrichten) --- */
.view-thread-stack { padding: 16px 24px 40px; display: flex; flex-direction: column; gap: 10px; }
.thread-item { border: 1px solid var(--gray-200); border-radius: var(--radius-md); overflow: hidden; }
.thread-item-header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; }
.thread-item-header:hover { background: var(--gray-50); }
.thread-item-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex: 0 0 auto;
    background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.thread-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.thread-item-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.thread-item-snippet { font-size: 12px; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.thread-item-date { font-size: 11px; color: var(--gray-500); flex: 0 0 auto; }
.thread-item-body { display: none; border-top: 1px solid var(--gray-100); padding: 16px; }
.thread-item.expanded .thread-item-body { display: block; }
.thread-item.expanded .thread-item-snippet { display: none; }
.thread-item-loading { font-size: 13px; color: var(--gray-500); padding: 8px 0; }
.thread-item-text { white-space: pre-wrap; font-family: inherit; margin: 0; font-size: 14px; line-height: 1.6; color: var(--ink); }
.thread-item-iframe { width: 100%; border: none; min-height: 200px; background: #fff; border-radius: var(--radius-sm); }

/* --- MESSAGE VIEW --- */
#message-view-panel { flex: 1; display: flex; flex-direction: column; background: var(--surface); min-width: 0; }
.view-placeholder { flex: 1; display: flex; align-items: center; justify-content: center; color: var(--gray-500); font-size: 15px; text-align: center; padding: 20px; background: var(--gray-50); }
.view-toolbar { display: flex; align-items: center; gap: 4px; padding: 10px 20px; border-bottom: 1px solid var(--gray-200); }
.view-toolbar .icon-btn { width: 36px; height: 36px; border-radius: 8px; }
.view-toolbar .icon-btn:hover { background: var(--blue-tint); color: var(--blue-dark); }
.view-toolbar .icon-btn.danger:hover { background: var(--danger-tint); color: var(--danger); }
.view-body { flex: 1; overflow-y: auto; }
.view-subject { font-size: 22px; font-weight: 700; padding: 20px 24px 8px; color: var(--ink); }
.view-sender-card { display: flex; gap: 12px; align-items: flex-start; background: var(--surface); border: 1px solid var(--gray-100); border-radius: var(--radius-md); padding: 16px 20px; margin: 8px 20px; }
.view-sender-avatar { width: 40px; height: 40px; border-radius: 999px; background: linear-gradient(135deg, var(--blue), var(--blue-dark)); color: var(--surface); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 14px; flex: 0 0 auto; }
.view-sender-info { flex: 1; min-width: 0; }
.view-sender-name { font-weight: 700; font-size: 14px; color: var(--ink); }
.view-sender-email { font-size: 12px; color: var(--gray-500); }
.view-sender-date { font-size: 12px; color: var(--gray-500); flex: 0 0 auto; white-space: nowrap; }
.view-content { padding: 20px 24px 40px; font-size: 14px; line-height: 1.6; color: var(--ink); word-wrap: break-word; overflow-wrap: break-word; }
/* Mail-Inhalt bleibt immer auf weißem Grund, auch im Dunkelmodus — beliebiges
   HTML aus Fremd-Mails lässt sich nicht zuverlässig umfärben (eigene Farben,
   Bilder, Markenfarben), das macht praktisch jeder Mail-Client so. */
.view-content iframe { width: 100%; border: none; min-height: 300px; background: #fff; border-radius: var(--radius-md); }
.view-content img { max-width: 100%; }
.view-attachments { padding: 0 20px 16px; display: flex; flex-wrap: wrap; gap: 8px; }
.attachment-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 6px 12px; font-size: 12px; color: var(--ink-soft); text-decoration: none; cursor: pointer; }
.attachment-chip:hover { background: var(--gray-100); border-color: var(--gray-300); }

/* --- Pagination --- */
.paginator { display: flex; align-items: center; justify-content: center; gap: 4px; padding: 10px; border-top: 1px solid var(--gray-100); }
.paginator button { background: transparent; border: none; color: var(--ink-soft); padding: 6px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; }
.paginator button:hover:not(:disabled) { background: var(--gray-100); color: var(--blue); }
.paginator button.active { color: var(--blue); text-decoration: underline; }
.paginator button:disabled { opacity: .35; cursor: default; }

/* ================================================================
   COMPOSE MODAL
   ================================================================ */
#compose-overlay {
    position: fixed; inset: 0; background: var(--overlay); display: none;
    align-items: center; justify-content: center; z-index: 1000; padding: 24px;
}
#compose-overlay.visible { display: flex; }
.compose-window { width: 100%; max-width: 700px; max-height: 90vh; background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 25px 60px -15px rgba(0,0,0,.25); display: flex; flex-direction: column; overflow: hidden; }
.compose-header { background: var(--gray-50); border-bottom: 1px solid var(--gray-200); padding: 12px 20px; display: flex; align-items: center; gap: 12px; min-height: 56px; }
.compose-title { font-weight: 700; font-size: 15px; margin-right: auto; }
.compose-header .icon-btn { width: 32px; height: 32px; }
.compose-header .icon-btn:hover { background: var(--gray-100); }
.compose-send-btn { background: var(--blue); color: var(--surface); border: none; padding: 9px 20px; border-radius: 999px; font-weight: 700; font-size: 13px; display: inline-flex; align-items: center; gap: 6px; box-shadow: 0 3px 12px -2px rgba(30,136,229,.4); }
.compose-send-btn:hover { background: var(--blue-hover); }
.compose-send-btn:disabled { opacity: .6; }
.compose-close-btn { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-soft); }
.compose-close-btn:hover { background: var(--danger-tint); color: var(--danger); }
.compose-draft-btn { width: 32px; height: 32px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-soft); }
.compose-draft-btn:hover { background: var(--gray-100); }
.compose-fields { padding: 4px 24px; }
.compose-field { display: flex; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--gray-100); gap: 10px; position: relative; }
.compose-field label { color: var(--ink-soft); font-weight: 600; font-size: 13px; width: 60px; flex: 0 0 auto; }
.compose-field input { flex: 1; border: none; outline: none; font-size: 14px; color: var(--ink); background: transparent; }
.compose-ccbcc-toggle { flex: 0 0 auto; border: none; background: transparent; color: var(--gray-500); font-size: 12px; font-weight: 600; padding: 4px 6px; border-radius: 6px; }
.compose-ccbcc-toggle:hover { background: var(--gray-100); color: var(--ink-soft); }
.contact-suggest {
    position: absolute; top: calc(100% + 2px); left: 60px; right: 0; z-index: 60;
    background: var(--surface); border: 1px solid var(--gray-200); border-radius: 10px;
    box-shadow: 0 12px 32px -8px rgba(31,36,45,.18); padding: 6px; max-height: 220px; overflow-y: auto;
}
.contact-suggest-item { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: 1px; padding: 8px 10px; border: none; background: transparent; border-radius: 8px; text-align: left; cursor: pointer; }
.contact-suggest-item:hover, .contact-suggest-item.active { background: var(--gray-100); }
.contact-suggest-item .cs-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.contact-suggest-item .cs-addr { font-size: 12px; color: var(--gray-500); }

.compose-toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 24px; border-bottom: 1px solid var(--gray-100); }
.compose-fmt-btn { width: 30px; height: 30px; border-radius: 7px; border: none; background: transparent; color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; }
.compose-fmt-btn:hover { background: var(--gray-100); color: var(--ink); }
.compose-fmt-btn.active { background: var(--blue-tint); color: var(--blue-dark); }

.compose-attachments { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 24px 0; }
.compose-attachment-chip { display: inline-flex; align-items: center; gap: 6px; background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: 8px; padding: 6px 8px 6px 12px; font-size: 12px; color: var(--ink-soft); }
.compose-attachment-remove { width: 18px; height: 18px; border-radius: 50%; border: none; background: var(--gray-200); color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; }
.compose-attachment-remove:hover { background: var(--danger-tint); color: var(--danger); }

.compose-body { flex: 1; padding: 16px 24px; overflow-y: auto; }
.compose-editable {
    width: 100%; min-height: 260px; outline: none; font-family: inherit; font-size: 14px;
    line-height: 1.6; color: var(--ink);
}
.compose-editable:empty::before { content: attr(data-placeholder); color: var(--gray-500); }
.compose-editable ul { padding-left: 22px; margin: 8px 0; }
.compose-signature-block { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--gray-100); color: var(--ink-soft); white-space: pre-wrap; }
.compose-quote-block { margin-top: 16px; padding-left: 12px; border-left: 3px solid var(--gray-200); color: var(--ink-soft); }
.compose-quote-header { font-size: 12px; color: var(--gray-500); margin-bottom: 8px; }

.signature-toolbar { display: flex; align-items: center; gap: 2px; margin-top: 10px; }
.signature-editable {
    min-height: 140px; max-height: 300px; overflow-y: auto; margin-top: 4px; margin-bottom: 18px;
    padding: 10px 12px; border: 1px solid var(--gray-200); border-radius: 10px;
    font-family: inherit; font-size: 13px; line-height: 1.6; color: var(--ink);
}

/* ================================================================
   CONFIRM DIALOG
   ================================================================ */
.confirm-overlay {
    position: fixed; inset: 0; background: var(--overlay); display: flex;
    align-items: center; justify-content: center; z-index: 1100; padding: 24px;
}
.confirm-dialog { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: 0 25px 60px -15px rgba(0,0,0,.25); padding: 24px; }
.confirm-title { font-weight: 700; font-size: 16px; color: var(--ink); margin-bottom: 8px; }
.confirm-message { font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin-bottom: 20px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-btn { padding: 9px 18px; border-radius: 999px; font-weight: 700; font-size: 13px; border: none; }
.confirm-cancel { background: var(--gray-100); color: var(--ink); }
.confirm-cancel:hover { background: var(--gray-200); }
.confirm-ok { background: var(--danger); color: var(--surface); }
.confirm-ok:hover { background: var(--danger-dark); }
.signature-dialog { max-width: 460px; }
.signature-save { background: var(--blue); }
.signature-save:hover { background: var(--blue-hover); }

.rules-dialog { max-width: 560px; }
.rules-list { max-height: 220px; overflow-y: auto; margin-bottom: 4px; }
.rule-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--gray-100); }
.rule-desc { flex: 1; font-size: 13px; color: var(--ink); }
.rule-desc b { color: var(--blue-dark); }
.rule-toggle input { width: 15px; height: 15px; cursor: pointer; accent-color: var(--blue); }
.rule-delete { width: 26px; height: 26px; border-radius: 50%; border: none; background: transparent; color: var(--gray-500); display: inline-flex; align-items: center; justify-content: center; }
.rule-delete:hover { background: var(--danger-tint); color: var(--danger); }
.rules-empty { padding: 12px 0; font-size: 13px; color: var(--gray-500); }
.rules-new { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 14px 0 18px; border-top: 1px solid var(--gray-100); margin-top: 6px; }
.rules-new-label { font-size: 13px; color: var(--gray-500); }
.rules-new select, .rules-new input[type="text"] {
    border: 1px solid var(--gray-200); border-radius: 8px; padding: 7px 10px; font-size: 13px;
    font-family: inherit; color: var(--ink); background: var(--surface);
}
.rules-new input[type="text"] { flex: 1; min-width: 120px; }
.rules-add-btn { background: var(--blue); color: var(--surface); width: 100%; }
.rules-add-btn:hover { background: var(--blue-hover); }

.toast { position: fixed; bottom: 24px; right: 24px; background: var(--ink); color: var(--surface); padding: 12px 20px; border-radius: 10px; font-size: 13px; box-shadow: 0 8px 24px rgba(0,0,0,.2); z-index: 2000; opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none; }
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

.hidden { display: none !important; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 900px) {
    .header-nav { display: none; }
    #message-list-panel { width: 300px; flex-basis: 300px; }
}

/* ================================================================
   VIEW-TOOLBAR — erweiterte Aktionen (Flag, Verschieben, Mehr)
   ================================================================ */
.toolbar-spacer { flex: 1 1 auto; }

.icon-btn.active {
    background: var(--blue-tint) !important;
    color: var(--blue) !important;
}

.toolbar-dropdown { position: relative; }

.toolbar-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: 12px;
    box-shadow: 0 12px 32px -8px rgba(31,36,45,.18);
    padding: 6px;
    z-index: 50;
    max-height: 320px;
    overflow-y: auto;
}
.toolbar-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.toolbar-menu-item:hover { background: var(--gray-100); }
.toolbar-menu-item svg { flex: 0 0 auto; color: var(--gray-500); }
.move-menu-icon { display: inline-flex; flex: 0 0 auto; color: var(--gray-500); }
.toolbar-menu-empty { padding: 10px 12px; font-size: 12px; color: var(--gray-500); }

#delete-btn.icon-btn.danger:hover { background: var(--danger-tint); color: var(--danger); }

.m-flag {
    display: inline-flex;
    margin-right: 4px;
    vertical-align: -3px;
}
.m-flag svg { width: 13px; height: 13px; }

/* Farbiges Markieren-Dropdown */
.flag-menu-item {
    justify-content: space-between !important;
}
.flag-menu-icon {
    display: inline-flex;
    flex: 0 0 auto;
}
.flag-menu-icon svg { width: 16px; height: 16px; }
