/* easymail Webmail - Hell/Dunkel ueber CSS-Variablen; data-theme erzwingt ein Schema. */
:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f0f2f7;
  --surface-3: #e6e9f1;
  --text: #1d2129;
  --text-2: #5a6272;
  --text-3: #8a91a0;
  --border: #e1e4eb;
  --accent: #3b5bdb;
  --accent-2: #2f4ac0;
  --accent-soft: #e7ecfd;
  --accent-text: #ffffff;
  --danger: #d6336c;
  --warn: #e8590c;
  --flag: #f08c00;
  --unread: #1d2129;
  --selected: #dde5fd;
  --mark: #ffe066;
  --shadow: 0 8px 30px rgba(20, 24, 40, .14), 0 2px 6px rgba(20, 24, 40, .08);
  --radius: 10px;
  --topbar: 56px;
  --row-pad: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161c;
    --surface: #1b1e26;
    --surface-2: #222631;
    --surface-3: #2b303d;
    --text: #e5e8ef;
    --text-2: #a8afbf;
    --text-3: #7a8192;
    --border: #2c313d;
    --accent: #7b93ff;
    --accent-2: #94a8ff;
    --accent-soft: #263055;
    --accent-text: #0f1220;
    --danger: #ff6b9a;
    --unread: #ffffff;
    --selected: #2a3558;
    --mark: #8a6d00;
    --shadow: 0 8px 30px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161c;
  --surface: #1b1e26;
  --surface-2: #222631;
  --surface-3: #2b303d;
  --text: #e5e8ef;
  --text-2: #a8afbf;
  --text-3: #7a8192;
  --border: #2c313d;
  --accent: #7b93ff;
  --accent-2: #94a8ff;
  --accent-soft: #263055;
  --accent-text: #0f1220;
  --danger: #ff6b9a;
  --unread: #ffffff;
  --selected: #2a3558;
  --mark: #8a6d00;
  --shadow: 0 8px 30px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .4);
  color-scheme: dark;
}
:root[data-density="compact"] { --row-pad: 5px; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }
.muted { color: var(--text-2); }
.small { font-size: 12px; }
.error { color: var(--danger); }
.noscript { padding: 2em; text-align: center; }
mark { background: var(--mark); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ---------- Symbole und Schaltflaechen ---------- */
.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.icon.small { width: 15px; height: 15px; }
.icon.big { width: 56px; height: 56px; stroke-width: 1.2; opacity: .35; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 0; border-radius: 50%; background: transparent; color: var(--text-2); cursor: pointer; flex: none;
}
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn:focus-visible, .btn:focus-visible, .folder:focus-visible, .msg:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.icon-btn.on { color: var(--flag); }
.icon-btn.danger:hover { color: var(--danger); }
.btn {
  display: inline-flex; align-items: center; gap: 8px; height: 36px; padding: 0 16px; border-radius: 18px;
  border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 500; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.primary:hover { background: var(--accent-2); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-3); }
.btn.small { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.wide { width: 100%; justify-content: center; }
.btn:disabled { opacity: .6; cursor: default; }
.btn .icon { width: 18px; height: 18px; }
.btn-group { display: inline-flex; }
.btn-group .btn:first-child { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.btn.split { border-top-left-radius: 0; border-bottom-left-radius: 0; padding: 0 8px; border-left: 1px solid rgba(255, 255, 255, .35); }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0 4px; font-size: 13px; }
.link-btn:hover { text-decoration: underline; }
.tag { display: inline-block; font-size: 11px; line-height: 16px; padding: 0 6px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); }
.tag.draft { background: #ffe3e3; color: #c92a2a; }

/* ---------- Anmeldung ---------- */
.login-page { height: 100%; overflow: auto; }
.login-wrap { min-height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; padding: 24px 16px; }
.login-legal { font-size: 13px; color: var(--muted, #6b7280); }
.login-legal a { color: inherit; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px 28px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; text-align: center; }
.login-logo { display: flex; justify-content: center; }
.login-logo .icon { width: 48px; height: 48px; color: var(--accent); stroke-width: 1.5; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.login-card label.check, label.check { flex-direction: row; align-items: center; gap: 8px; cursor: pointer; }
.login-card input[type=email], .login-card input[type=password] {
  height: 42px; padding: 0 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 15px;
}
.login-card input:focus { outline: 2px solid var(--accent); border-color: transparent; }
.login-error { background: #ffe3e3; color: #a51d2d; border-radius: 8px; padding: 10px 12px; font-size: 13px; }
.login-hint { margin: 0; font-size: 12.5px; color: var(--text-2); background: var(--accent-soft); padding: 10px 12px; border-radius: 8px; }

/* ---------- Grundgeruest ---------- */
.shell, .app { height: 100%; }
.app { display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar); flex: none; display: flex; align-items: center; gap: 16px; padding: 0 12px 0 16px;
  background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 10px; width: 228px; font-weight: 600; font-size: 17px; flex: none; }
.brand .icon { color: var(--accent); width: 26px; height: 26px; }
.search {
  flex: 1; max-width: 720px; display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 6px 0 14px;
  background: var(--surface-3); border-radius: 21px; color: var(--text-2);
}
.search:focus-within { background: var(--surface); box-shadow: var(--shadow); }
.search input { flex: 1; border: 0; background: transparent; outline: none; height: 100%; min-width: 0; font-size: 15px; }
.search input::-webkit-search-cancel-button { display: none; }
.search .search-clear { visibility: hidden; width: 30px; height: 30px; }
.search.active .search-clear { visibility: visible; }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.top-actions .user { color: var(--text-2); font-size: 13px; padding: 0 8px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panes { flex: 1; min-height: 0; display: flex; gap: 0; padding: 0 12px 12px 0; }

/* Ordnerleiste */
.sidebar { width: 256px; flex: none; display: flex; flex-direction: column; padding: 4px 8px 8px; min-height: 0; }
.compose-btn { height: 48px; border-radius: 16px; padding: 0 22px; margin: 0 0 12px 4px; align-self: flex-start; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.folders { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.folder {
  display: flex; align-items: center; gap: 14px; height: 34px; padding: 0 12px 0 calc(16px + var(--depth, 0) * 16px);
  border-radius: 0 17px 17px 0; margin-right: 4px; color: var(--text); text-decoration: none; font-size: 14px;
}
.folder:hover { background: var(--surface-3); }
.folder.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder .icon { width: 18px; height: 18px; color: var(--text-2); }
.folder.active .icon { color: var(--accent); }
.folder-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder.has-unread .folder-name { font-weight: 600; }
.folder .count { font-size: 12px; font-weight: 600; color: var(--text-2); }
.folder.active .count { color: var(--accent); }
.quota { padding: 10px 12px 4px; font-size: 12px; color: var(--text-2); }
.quota-bar { height: 4px; background: var(--surface-3); border-radius: 2px; overflow: hidden; margin-bottom: 6px; }
.quota-bar span { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.quota-bar.warn span { background: var(--warn); }
.quota-bar.full span { background: var(--danger); }

/* Liste */
.list-pane {
  width: 420px; flex: none; display: flex; flex-direction: column; min-height: 0; background: var(--surface);
  border-radius: var(--radius) 0 0 var(--radius); border-right: 1px solid var(--border);
}
.list-head { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--border); min-height: 52px; }
.list-heading { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.list-title { margin: 0; font-size: 16px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-count { color: var(--text-3); font-size: 12px; }
.list-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.msg-list { list-style: none; margin: 0; padding: 0; }
.list-status { padding: 24px 16px; text-align: center; color: var(--text-3); font-size: 13px; }
.list-status:empty { padding: 0; }
.list-sentinel { height: 1px; }
.msg {
  position: relative; display: flex; gap: 12px; padding: var(--row-pad) 40px var(--row-pad) 14px; cursor: pointer;
  border-bottom: 1px solid var(--border); border-left: 3px solid transparent;
}
.msg:hover { background: var(--surface-2); }
.msg.selected { background: var(--selected); }
.msg.unread { border-left-color: var(--accent); }
.msg.child { padding-left: 34px; background: var(--surface-2); }
.msg.child .avatar { width: 28px; height: 28px; font-size: 11px; }
.msg-main { flex: 1; min-width: 0; }
.msg-top, .msg-mid { display: flex; align-items: center; gap: 6px; min-width: 0; }
.msg-from { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.msg.unread .msg-from, .msg.unread .msg-subject { color: var(--unread); font-weight: 650; }
.msg-date { flex: none; font-size: 12px; color: var(--text-3); }
.msg.unread .msg-date { color: var(--accent); font-weight: 600; }
.msg-subject { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.msg-icons { flex: none; display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); }
.msg-preview { color: var(--text-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
:root[data-density="compact"] .msg-preview { display: none; }
:root[data-density="compact"] .msg > .avatar { width: 28px; height: 28px; font-size: 11px; }
.thread-count {
  flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); border-radius: 10px;
  font-size: 11px; line-height: 16px; padding: 0 7px; cursor: pointer; font-weight: 600;
}
.thread-count:hover, .thread-count.open { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.flag-btn {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%); border: 0; background: none; padding: 4px; cursor: pointer;
  color: var(--text-3); opacity: 0; border-radius: 50%;
}
.flag-btn .icon { width: 17px; height: 17px; }
.msg:hover .flag-btn, .flag-btn.on, .flag-btn:focus-visible { opacity: 1; }
.flag-btn.on { color: var(--flag); }
.flag-btn.on .icon { fill: var(--flag); }
.avatar {
  --hue: 220;
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; color: #fff; background: hsl(var(--hue), 55%, 52%); user-select: none;
}
.avatar.large { width: 44px; height: 44px; font-size: 16px; }
/* Absender-Logo (logos.js): Bild ueber den Initialen, erst nach erfolgreichem Laden sichtbar */
.avatar[data-logo] { position: relative; overflow: hidden; }
.avatar > img { position: absolute; inset: 0; width: 100%; height: 100%; box-sizing: border-box; padding: 12%; object-fit: contain; opacity: 0; }
.avatar.has-logo { background: #fff; color: transparent; box-shadow: inset 0 0 0 1px var(--border); }
.avatar.has-logo > img { opacity: 1; }

/* Lesebereich */
.reader-pane { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; min-height: 0; }
.reader-empty, .reader-loading { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-3); gap: 8px; }
.reader { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.reader-toolbar { display: flex; align-items: center; gap: 2px; padding: 8px 12px; border-bottom: 1px solid var(--border); min-height: 52px; flex-wrap: wrap; }
.reader-toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.reader-scroll { flex: 1; overflow-y: auto; display: flex; flex-direction: column; min-height: 0; }
.reader-head { padding: 18px 24px 8px; }
.reader-subject { margin: 0 0 16px; font-size: 21px; font-weight: 500; line-height: 1.3; overflow-wrap: anywhere; }
.reader-from { display: flex; align-items: flex-start; gap: 12px; }
.reader-from .who { flex: 1; min-width: 0; }
.reader-from .name { font-weight: 600; overflow-wrap: anywhere; }
.reader-from .addr { font-weight: 400; color: var(--text-2); font-size: 13px; }
.reader-from .to { color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
.reader-date { color: var(--text-3); font-size: 12.5px; white-space: nowrap; }
.reader-details { margin: 10px 0 0 56px; padding: 10px 12px; background: var(--surface-2); border-radius: 8px; font-size: 13px; }
.reader-details .label { color: var(--text-3); display: inline-block; min-width: 90px; }
.reader-details .rcpt { overflow-wrap: anywhere; }
.attachments { margin: 8px 24px; }
.att-title { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--text-2); margin-bottom: 6px; }
.attachments ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.att {
  display: flex; align-items: center; gap: 10px; max-width: 280px; padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; text-align: left;
}
.att:hover { background: var(--surface-2); }
.att-icon { flex: none; width: 34px; height: 34px; border-radius: 6px; background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.att-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.att-size { flex: none; color: var(--text-3); font-size: 12px; }
.remote-banner { display: flex; align-items: center; gap: 10px; margin: 8px 24px; padding: 8px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; flex-wrap: wrap; }
.remote-banner span { flex: 1; min-width: 160px; }
.reader-body { flex: 1; padding: 8px 24px 24px; display: flex; flex-direction: column; min-height: 320px; }
.reader-body.html { padding: 8px 12px 12px; }
.mail-frame { flex: 1; width: 100%; min-height: 480px; border: 0; border-radius: 8px; background: #fff; }
.plain-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.55; }
.plain-body .quote { border-left: 3px solid var(--border); padding-left: 10px; color: var(--text-2); margin: 2px 0; }
.plain-body .quote.q2 { border-left-color: var(--accent-soft); }

/* Verfassen */
.composer {
  position: fixed; right: 24px; bottom: 0; width: min(640px, calc(100vw - 48px)); height: min(640px, calc(100vh - 80px));
  background: var(--surface); border-radius: 12px 12px 0 0; box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 40;
  border: 1px solid var(--border); border-bottom: 0;
}
.composer.min { height: auto; }
.composer.min > :not(.compose-head) { display: none; }
.composer.drop { outline: 3px dashed var(--accent); outline-offset: -6px; }
.compose-head { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 16px; background: var(--surface-2); border-radius: 12px 12px 0 0; cursor: default; }
.compose-title { flex: 1; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose-fields { padding: 0 16px; }
.field { display: flex; align-items: center; gap: 8px; border-bottom: 1px solid var(--border); min-height: 40px; }
.field-label { color: var(--text-3); font-size: 13px; min-width: 42px; }
.from-select { flex: 1; border: 0; background: transparent; height: 38px; min-width: 0; }
.subject-input { flex: 1; border: 0; background: transparent; height: 40px; outline: none; font-size: 15px; min-width: 0; }
.chips { flex: 1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 4px 0; min-width: 0; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--surface-3); border-radius: 14px; padding: 0 2px 0 10px; height: 26px; font-size: 13px; max-width: 100%; }
.chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-x { width: 22px; height: 22px; }
.chip-x .icon { width: 13px; height: 13px; }
.chip-input { flex: 1; min-width: 120px; border: 0; background: transparent; outline: none; height: 30px; }
.chip-input.invalid { color: var(--danger); }
.cc-toggles { flex: none; }
.body-input { flex: 1; resize: none; border: 0; outline: none; padding: 12px 16px; background: transparent; font-size: 14.5px; line-height: 1.55; min-height: 120px; }
.compose-atts { list-style: none; margin: 0; padding: 4px 16px; display: flex; flex-direction: column; gap: 4px; max-height: 120px; overflow: auto; }
.catt { display: flex; align-items: center; gap: 8px; padding: 2px 2px 2px 10px; background: var(--surface-2); border-radius: 6px; font-size: 13px; }
.catt.busy { opacity: .75; }
.catt.failed { color: var(--danger); }
.compose-foot { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.compose-foot .grow { flex: 1; }
.compose-status { font-size: 12px; }
.schedule-box { display: flex; align-items: flex-end; gap: 8px; padding: 10px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; background: var(--surface-2); }
.schedule-box label { display: flex; flex-direction: column; font-size: 12px; color: var(--text-2); gap: 2px; }
.schedule-box input { height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); padding: 0 8px; }

/* Menue, Meldungen, Dialoge */
.menu {
  position: fixed; z-index: 60; min-width: 200px; max-height: 60vh; overflow: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px 0;
}
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 14px; border: 0; background: none; cursor: pointer; text-align: left; font-size: 14px; }
.menu-item .icon { width: 17px; height: 17px; color: var(--text-2); }
.menu-item:hover:not([disabled]), .menu-item:focus { background: var(--surface-2); outline: none; }
.menu-item[disabled] { opacity: .45; cursor: default; }
.menu-sep { height: 1px; background: var(--border); margin: 4px 0; }
#toasts { position: fixed; left: 24px; bottom: 24px; z-index: 70; display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 48px); }
.toast {
  display: flex; align-items: center; gap: 10px; min-width: 280px; max-width: 520px; padding: 6px 6px 6px 16px; border-radius: 8px;
  background: #2b2f3a; color: #f1f3f7; box-shadow: var(--shadow); font-size: 14px; animation: toast-in .2s ease-out;
}
.toast.error { background: #a51d2d; }
.toast.out { opacity: 0; transform: translateY(8px); transition: all .2s; }
.toast-text { flex: 1; }
.toast-action { border: 0; background: none; color: #a5b8ff; font-weight: 700; cursor: pointer; padding: 6px 8px; border-radius: 6px; text-transform: uppercase; font-size: 13px; }
.toast-action:hover { background: rgba(255, 255, 255, .1); }
.toast .icon-btn { color: #c8ccd6; width: 30px; height: 30px; }
.toast .icon-btn:hover { background: rgba(255, 255, 255, .1); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-back { position: fixed; inset: 0; z-index: 50; background: rgba(10, 12, 20, .45); display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); width: 100%; max-width: 480px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.modal.wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; padding: 12px 12px 4px 20px; }
.modal-head h2 { flex: 1; margin: 0; font-size: 18px; }
.modal-body { padding: 8px 20px 20px; overflow: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.settings-form { display: flex; flex-direction: column; gap: 14px; }
.settings-form label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.settings-form label.check { flex-direction: row; color: var(--text); font-size: 14px; }
.settings-form input[type=text], .settings-form input[type=date], .settings-form textarea, .settings-form select {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 8px 10px; font-size: 14px;
}
.settings-form textarea { resize: vertical; }
.settings-form .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.settings-form .actions { display: flex; justify-content: flex-end; }
.settings-section { margin-bottom: 20px; }
.settings-section h3 { margin: 0 0 8px; font-size: 15px; }
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.plain-list.scheduled li > div { flex: 1; min-width: 160px; }

/* ---------- Stufe 2: Ordnerverwaltung, Auswahl, Editor, Extras, Filter ---------- */
.grow { flex: 1; }
.icon-btn.small { width: 30px; height: 30px; }
.icon-btn.small .icon { width: 17px; height: 17px; }
.hint { margin: 0 0 12px; font-size: 13px; color: var(--text-2); background: var(--accent-soft); padding: 10px 12px; border-radius: 8px; }
.hint.warn { background: #fff3bf; color: #5c3c00; }
:root[data-theme="dark"] .hint.warn { background: #4a3a00; color: #ffe8a3; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hint.warn { background: #4a3a00; color: #ffe8a3; } }
.actions-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 8px 0; }
.tag.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; margin-left: 6px; }
.tag + .tag { margin-left: 4px; }

/* Ordnerleiste */
.folders-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 2px 16px; font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .04em; }
.folder { position: relative; }
.folder-more {
  display: none; border: 0; background: none; color: var(--text-2); width: 26px; height: 26px; border-radius: 50%; padding: 0; cursor: pointer;
  align-items: center; justify-content: center; margin-right: -6px;
}
.folder-more .icon { width: 16px; height: 16px; stroke-width: 2.6; }
.folder:hover .folder-more, .folder:focus-within .folder-more { display: inline-flex; }
.folder:hover .count { display: none; }
.folder-more:hover { background: var(--surface); }
.folder.unsub .folder-name { opacity: .55; font-style: italic; }
.folder.drop-target { background: var(--accent-soft); outline: 2px dashed var(--accent); outline-offset: -2px; }
.dragging-mail .folder { transition: background .1s; }

/* Liste: Mehrfachauswahl */
.list-head { flex-direction: column; align-items: stretch; padding: 0; gap: 0; }
.list-head-main, .list-bulk { display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 10px; min-height: 52px; }
.list-bulk { background: var(--accent-soft); border-radius: var(--radius) 0 0 0; }
.bulk-count { font-weight: 600; font-size: 14px; padding: 0 4px; white-space: nowrap; }
.select-all-btn .icon { width: 18px; height: 18px; }
.msg-lead { position: relative; flex: none; width: 38px; height: 38px; }
:root[data-density="compact"] .msg-lead { width: 28px; height: 28px; }
.msg.child .msg-lead { width: 28px; height: 28px; }
.msg-check {
  position: absolute; inset: 0; margin: auto; width: 18px; height: 18px; cursor: pointer; opacity: 0; accent-color: var(--accent);
}
.msg:hover .msg-check, .msg-list.selecting .msg-check, .msg-check:focus-visible { opacity: 1; }
.msg:hover .msg-lead .avatar, .msg-list.selecting .msg-lead .avatar { visibility: hidden; }
.msg.checked { background: var(--accent-soft); }
.msg.checked.selected { background: var(--selected); }
.drag-ghost {
  position: fixed; top: -100px; left: -100px; padding: 6px 12px; border-radius: 8px; background: var(--accent); color: var(--accent-text);
  font-size: 13px; font-weight: 600; max-width: 280px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px;
}

/* Adressvorschlaege */
.chips-field { position: relative; }
.suggest {
  position: absolute; left: 40px; right: 0; top: 100%; z-index: 45; margin: 0; padding: 4px 0; list-style: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); max-height: 280px; overflow: auto;
}
.suggest li { display: flex; align-items: center; gap: 8px; padding: 6px 12px; cursor: pointer; font-size: 13.5px; min-width: 0; }
.suggest li .icon { color: var(--text-3); }
.suggest li.active, .suggest li:hover { background: var(--surface-2); }
.sugg-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sugg-addr { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }

/* Editor */
.compose-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.rich-toolbar { display: flex; align-items: center; gap: 1px; padding: 4px 10px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.rich-toolbar .sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.rich-input {
  flex: 1; overflow: auto; outline: none; padding: 12px 16px; font-size: 14.5px; line-height: 1.55; min-height: 120px; overflow-wrap: anywhere;
}
.rich-input blockquote { margin: 4px 0 4px 4px; padding-left: 10px; border-left: 3px solid var(--border); color: var(--text-2); }
.rich-input img { max-width: 100%; height: auto; }
.rich-input ul, .rich-input ol { padding-left: 24px; margin: 4px 0; }
.rich-input p { margin: 0 0 8px; }
.fmt-toggle { font-size: 12.5px; }

/* Lesebereich: Extras */
.back-btn { display: none; }
.reader-toolbar .grow { flex: 1; }
.mdn-banner { display: flex; align-items: center; gap: 10px; margin: 8px 24px; padding: 8px 12px; border-radius: 8px; background: var(--surface-2); font-size: 13px; flex-wrap: wrap; }
.mdn-banner > span { flex: 1; min-width: 180px; }
.attachments li { display: flex; align-items: center; gap: 2px; }
.att-dl { width: 30px; height: 30px; }
.headers-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.headers-table th { text-align: left; vertical-align: top; padding: 4px 10px 4px 0; color: var(--text-2); white-space: nowrap; font-weight: 600; }
.headers-table td { padding: 4px 0; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.headers-table tr + tr { border-top: 1px solid var(--border); }
pre.source {
  margin: 0; padding: 12px; background: var(--surface-2); border-radius: 8px; font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 65vh; overflow: auto;
}
.modal.wide.source-modal, .modal.wide.preview-modal { max-width: 960px; }
.preview-img { display: flex; justify-content: center; background: var(--surface-2); border-radius: 8px; padding: 8px; }
.preview-img img { max-width: 100%; max-height: 70vh; object-fit: contain; }
#print-view { display: none; }

/* Lesebereich unter der Liste / aus (nur breite Bildschirme) */
@media (min-width: 900px) {
  .app[data-pane="bottom"] .panes { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(160px, 42%) minmax(0, 1fr); }
  .app[data-pane="bottom"] .sidebar { grid-row: 1 / span 2; }
  .app[data-pane="bottom"] .list-pane { width: auto; border-right: 0; border-bottom: 1px solid var(--border); border-radius: var(--radius) var(--radius) 0 0; }
  .app[data-pane="bottom"] .reader-pane { border-radius: 0 0 var(--radius) var(--radius); }
  .app[data-pane="off"] .list-pane { flex: 1; width: auto; border-right: 0; border-radius: var(--radius); }
  .app[data-pane="off"] .reader-pane { display: none; border-radius: var(--radius); }
  .app[data-pane="off"][data-view="reader"] .reader-pane { display: flex; }
  .app[data-pane="off"][data-view="reader"] .list-pane { display: none; }
  .app[data-pane="off"] .back-btn { display: inline-flex; }
}

/* Filter */
.rule-list { list-style: none; margin: 0 0 8px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rule { display: flex; align-items: center; gap: 6px; padding: 8px 6px 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.rule.off { opacity: .6; }
.rule-text { flex: 1; min-width: 0; }
.rule-text .muted { overflow-wrap: anywhere; }
.filter-status { margin: 0 0 8px; font-size: 13px; color: var(--text-2); }
.filter-status.on { color: var(--accent); font-weight: 600; }
.rule-form .rule-head { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.rule-rows { display: flex; flex-direction: column; gap: 6px; }
.rule-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.rule-row select, .rule-row input[type=text], .rule-row input[type=email], .rule-row input[type=number] {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 6px 8px; font-size: 13.5px; min-width: 0;
}
.rule-row .grow { flex: 1; min-width: 140px; }
.rule-row .narrow { width: 110px; }
.settings-form input[type=email], .settings-form input[type=number] {
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 8px 10px; font-size: 14px;
}
.settings-form label.check.small, label.check.small { font-size: 13px; color: var(--text-2); }
.indent { margin: 2px 0 0 26px; }
.plain-list.scripts li > .grow { min-width: 160px; }
.trust-list li { padding: 4px 0; }
.script-editor { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.script-editor h4 { margin: 0; font-size: 14px; }
.script-editor label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-2); }
.script-editor input[type=text] { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 8px 10px; }
textarea.code {
  width: 100%; resize: vertical; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); padding: 10px;
  font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; tab-size: 2; white-space: pre; overflow: auto;
}
.script-error { color: var(--danger); background: #ffe3e3; border-radius: 8px; padding: 8px 10px; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
:root[data-theme="dark"] .script-error { background: #4a1020; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .script-error { background: #4a1020; } }
.script-ok { color: #2b8a3e; font-size: 13px; }

/* Druck: nur die Druckansicht */
@media print {
  html, body { height: auto; overflow: visible; background: #fff; color: #000; }
  body > *:not(#print-view) { display: none !important; }
  #print-view { display: block; padding: 0; }
  .print-head { border-bottom: 1px solid #999; margin-bottom: 12px; padding-bottom: 8px; font-size: 12px; }
  .print-head h1 { font-size: 18px; margin: 0 0 8px; }
  .print-body .plain-body { font-size: 12.5px; }
}

.only-mobile { display: none !important; }
.scrim { display: none; }
.fab { display: none; }

/* ---------- mittlere Breite: Ordnerleiste schmaler ---------- */
@media (max-width: 1200px) {
  .sidebar { width: 210px; }
  .brand { width: 182px; }
  .list-pane { width: 360px; }
  .top-actions .user { display: none; }
}

/* ---------- schmal (Handy/Tablet hochkant): ein Bereich zur Zeit ---------- */
@media (max-width: 899px) {
  :root { --topbar: 52px; }
  .only-mobile { display: inline-flex !important; }
  .back-btn { display: inline-flex; }
  .mdn-banner { margin-left: 16px; margin-right: 16px; }
  .suggest { left: 0; }
  .folder-more { display: inline-flex; }
  .folder .count { display: inline; }
  .brand span { display: none; }
  .brand { width: auto; }
  .topbar { gap: 8px; padding: 0 6px 0 10px; }
  .panes { padding: 0; position: relative; }
  .list-pane, .reader-pane { width: 100%; border-radius: 0; border-right: 0; }
  .reader-pane { display: none; }
  .app[data-view="reader"] .reader-pane { display: flex; }
  .app[data-view="reader"] .list-pane { display: none; }
  .sidebar {
    position: absolute; inset: 0 auto 0 0; width: 280px; max-width: 85vw; z-index: 30; background: var(--bg);
    transform: translateX(-105%); transition: transform .2s ease; box-shadow: var(--shadow); padding-top: 12px;
  }
  .app[data-view="folders"] .sidebar { transform: none; }
  .app[data-view="folders"] .scrim { display: block; position: absolute; inset: 0; z-index: 25; background: rgba(10, 12, 20, .35); }
  .compose-btn { display: none; }
  .fab {
    display: flex; position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 20; width: 56px; height: 56px;
    border-radius: 18px; border: 0; background: var(--accent); color: var(--accent-text); align-items: center; justify-content: center; box-shadow: var(--shadow);
  }
  .app[data-view="reader"] .fab { display: none; }
  .reader-head { padding: 14px 16px 6px; }
  .reader-subject { font-size: 18px; }
  .reader-details { margin-left: 0; }
  .attachments, .remote-banner { margin-left: 16px; margin-right: 16px; }
  .reader-body { padding: 8px 16px 16px; }
  .reader-body.html { padding: 4px; }
  .reader-date { display: none; }
  .composer { inset: 0; width: 100%; height: 100%; border-radius: 0; border: 0; }
  .compose-head { border-radius: 0; }
  #toasts { left: 12px; right: 12px; bottom: 84px; max-width: none; }
  .toast { min-width: 0; max-width: none; }
  .settings-form .row2 { grid-template-columns: 1fr; }
  .msg { padding-right: 36px; }
  .flag-btn { opacity: 1; }
  .flag-btn:not(.on) { opacity: .35; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* Signatur */
.sig-hint { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 4px 16px; border-top: 1px solid var(--border); }
.sig-hint .sig-preview { flex-basis: 100%; margin-bottom: 4px; }
.sig-preview { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.sig-frame { width: 100%; min-height: 0; height: 180px; border: 0; display: block; }
.sig-text { margin: 0; padding: 10px; white-space: pre-wrap; font-size: 13px; background: var(--surface-2); color: var(--text); }
.sig-edit { border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; }
.sig-editor { min-height: 100px; max-height: 260px; }

/* Team-Postfach: "X antwortet gerade", gelesen/beantwortet von (ui/presence.js); Archiv-Hinweis (ui/archivenote.js) */
.presence-banner { display: flex; align-items: center; gap: 8px; margin: 8px 24px; padding: 6px 12px; border-radius: 8px; background: var(--accent-soft); font-size: 13px; }
.presence-banner[hidden] { display: none; }
.team-info { margin: 4px 24px; display: flex; flex-direction: column; gap: 2px; }
.team-info > div { display: flex; align-items: center; gap: 4px; }
.archive-badge { display: inline-flex; align-items: center; padding: 0 6px; color: var(--text-2); opacity: .75; cursor: help; }
.archive-note { display: flex; align-items: center; gap: 6px; }
.fwd-atts { display: flex; align-items: center; gap: 6px; padding: 4px 16px; font-size: 13px; }
@media (max-width: 720px) {
  .presence-banner, .team-info { margin-left: 16px; margin-right: 16px; }
}
/* Regel-Baukasten: Sortieren per Drag & Drop, Code-Bloecke */
.rule-grip { cursor: grab; color: var(--muted, #888); user-select: none; padding: 0 2px; }
.rule.dragging { opacity: .4; }
.rule.dropover { outline: 2px solid var(--accent); outline-offset: 1px; }
.rule .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sieve-preview { max-height: 40vh; overflow: auto; white-space: pre; font-size: 12px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }

/* Signatur-Editor (sigeditor.js) */
.sig-edit .rich-toolbar { flex-wrap: wrap; }
.sig-color { display: inline-flex; align-items: center; gap: 2px; font-weight: 600; cursor: pointer; padding: 0 4px; }
.sig-color input[type=color] { width: 22px; height: 22px; padding: 0; border: 0; background: none; }
.sig-imgbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 6px; border-bottom: 1px solid var(--border); }
.sig-imgbar[hidden], .sig-source[hidden] { display: none; }
.sig-source { min-height: 160px; border: 0; border-top: 1px solid var(--border); }
.sig-size.error { color: var(--danger, #c0392b); font-weight: 600; }
.sig-editor table td { outline: 1px dashed #c9cfdb; }
.sig-edit .rich-input[hidden] { display: none; }
