:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #f9fafb;
  --border: #d9dce1;
  --text: #1d232b;
  --muted: #66707d;
  --accent: #1f6fd1;
  --accent-soft: #e3eefc;
  --sel: #cfe2fb;
  --danger: #c62828;
  --ok: #2e7d32;
  --star: #e8a400;
  --toolbar: #eceef1;
  --shadow: 0 6px 24px rgba(0,0,0,.15);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1e23; --panel: #23272e; --panel-2: #2a2f37; --border: #3a404a; --text: #e6e9ee; --muted: #9aa3af;
    --accent: #5aa0f2; --accent-soft: #23364f; --sel: #2c4a73; --toolbar: #262a31; --shadow: 0 6px 24px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1e23; --panel: #23272e; --panel-2: #2a2f37; --border: #3a404a; --text: #e6e9ee; --muted: #9aa3af;
  --accent: #5aa0f2; --accent-soft: #23364f; --sel: #2c4a73; --toolbar: #262a31; --shadow: 0 6px 24px rgba(0,0,0,.5);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.error-text { color: var(--danger); }
.ok-text { color: var(--ok); }

/* Buttons & Inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 11px; border: 1px solid var(--border); background: var(--panel); border-radius: 6px; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--panel-2); border-color: #b8bec7; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(127,127,127,.12); }
.btn .ic { font-size: 16px; line-height: 1; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], input[type=url], select, textarea {
  border: 1px solid var(--border); background: var(--panel); border-radius: 6px; padding: 6px 8px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
label.field { display: block; margin-bottom: 10px; }
label.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }
.row > .narrow { flex: 0 0 140px; }

/* Login */
.login-wrap { display: grid; place-items: center; height: 100vh; padding: 16px; }
.login { width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 28px; box-shadow: var(--shadow); }
.login h1 { margin: 0 0 4px; font-size: 22px; display: flex; align-items: center; gap: 10px; }
.login p { margin: 0 0 18px; }
.login .btn { width: 100%; justify-content: center; padding: 9px; }

/* Layout */
.shell { display: grid; grid-template-rows: auto 1fr; height: 100vh; }
.topbar { display: flex; align-items: center; gap: 4px; padding: 0 8px; background: var(--toolbar); border-bottom: 1px solid var(--border); height: 42px; }
.topbar .brand { font-weight: 600; display: flex; align-items: center; gap: 8px; margin-right: 12px; }
.topbar .brand img { width: 20px; height: 20px; }
.tab { padding: 6px 12px; border-radius: 6px; cursor: pointer; border: 0; background: none; color: var(--muted); display: flex; gap: 6px; align-items: center; }
.tab.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 8px; color: var(--muted); }

.mail { display: grid; grid-template-columns: var(--folderw, 250px) 1fr; min-height: 0; }
.folders { background: var(--panel-2); border-right: 1px solid var(--border); overflow: auto; padding: 6px 0 20px; }
.acc-head { display: flex; align-items: center; gap: 6px; padding: 8px 10px 4px; font-weight: 600; cursor: pointer; user-select: none; }
.acc-head .caret { width: 14px; color: var(--muted); font-size: 11px; }
.acc-head .acc-email { font-weight: 400; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder { display: flex; align-items: center; gap: 6px; padding: 4px 10px; cursor: pointer; border-radius: 0; white-space: nowrap; user-select: none; }
.folder:hover { background: rgba(127,127,127,.1); }
.folder.active { background: var(--sel); }
.folder.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.folder .fi { width: 18px; text-align: center; }
.folder .ftoggle { width: 14px; flex: none; text-align: center; color: var(--muted); font-size: 11px; border-radius: 3px; }
.folder .ftoggle:not(.none):hover { background: rgba(127,127,127,.2); color: var(--fg, inherit); }
.folder .badge.sub { opacity: .8; }
.folder .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.folder .unread { font-weight: 600; }
.folder .badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 600; }
.folder.noselect { color: var(--muted); cursor: default; }
.acc-error { color: var(--danger); font-size: 12px; padding: 2px 12px 6px 30px; }

.main { display: grid; grid-template-rows: auto auto 1fr; min-width: 0; min-height: 0; }
.toolbar { display: flex; align-items: center; gap: 4px; padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--panel); flex-wrap: wrap; }
.toolbar .sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.toolbar .btn { padding: 6px 8px; }
.toolbar .search { margin-left: auto; display: flex; gap: 6px; align-items: center; flex: 1 1 160px; max-width: 300px; min-width: 140px; }
.toolbar .search input { width: 100%; }
.filterbar { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-bottom: 1px solid var(--border); background: var(--panel-2); font-size: 12px; color: var(--muted); }
.chip { border: 1px solid var(--border); background: var(--panel); border-radius: 12px; padding: 2px 10px; cursor: pointer; font-size: 12px; }
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.filterbar .count { margin-left: auto; }

.panes { display: grid; grid-template-rows: var(--listh, 42%) 6px 1fr; min-height: 0; }
.panes.vertical { grid-template-rows: none; grid-template-columns: var(--listw, 45%) 6px 1fr; }
.splitter { background: var(--border); cursor: row-resize; opacity: .5; }
.panes.vertical .splitter { cursor: col-resize; }
.list { overflow: auto; background: var(--panel); min-height: 0; }
.list table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.list th.sortable { cursor: pointer; user-select: none; }
.list th.sortable:hover { color: var(--fg, inherit); }
.list th.sorted { color: var(--accent); }
.list th { position: sticky; top: 0; background: var(--panel-2); text-align: left; font-weight: 500; font-size: 12px; color: var(--muted); padding: 5px 8px; border-bottom: 1px solid var(--border); z-index: 1; }
.list td { padding: 5px 8px; border-bottom: 1px solid rgba(127,127,127,.12); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
.list tr.unread td { font-weight: 600; }
.list tr.sel td { background: var(--sel); }
.list tr:hover td { background: rgba(127,127,127,.08); }
.list tr.sel:hover td { background: var(--sel); }
.list .c-star, .list .c-att, .list .c-read { width: 26px; text-align: center; padding: 5px 2px; }
.list .c-date { width: 130px; }
.list .c-from { width: 28%; }
.star { cursor: pointer; color: var(--muted); }
.star.on { color: var(--star); }
.dot { cursor: pointer; color: var(--accent); font-size: 10px; }
.dot.off { color: transparent; text-shadow: 0 0 0 rgba(127,127,127,.4); }
.list .more { text-align: center; padding: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.reader { overflow: auto; background: var(--panel); min-height: 0; display: flex; flex-direction: column; }
.msg-head { padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--panel-2); }
.msg-head h2 { margin: 0 0 6px; font-size: 17px; font-weight: 600; }
.msg-head .hl { display: grid; grid-template-columns: 70px 1fr; gap: 2px 8px; font-size: 13px; }
.msg-head .hl .k { color: var(--muted); text-align: right; }
.msg-actions { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.addr { cursor: pointer; border-radius: 4px; padding: 0 2px; }
.addr:hover { background: var(--accent-soft); }
.addr .em { color: var(--muted); }
.remote-note { background: #fff6d6; color: #5c4600; padding: 6px 16px; font-size: 13px; display: flex; gap: 10px; align-items: center; border-bottom: 1px solid #f0df9c; }
.msg-body { flex: 1; min-height: 200px; }
.msg-body iframe { width: 100%; height: 100%; border: 0; background: #fff; min-height: 300px; display: block; }
.msg-body pre { white-space: pre-wrap; word-wrap: break-word; font: 14px/1.5 ui-monospace, Menlo, Consolas, monospace; padding: 14px 16px; margin: 0; }
.atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 16px; border-top: 1px solid var(--border); background: var(--panel-2); }
.att { display: inline-flex; gap: 6px; align-items: center; padding: 4px 10px; border: 1px solid var(--border); border-radius: 6px; background: var(--panel); text-decoration: none; color: var(--text); font-size: 13px; }
.att:hover { border-color: var(--accent); }

/* Menüs */
.menu { position: fixed; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow); padding: 4px; z-index: 1000; min-width: 180px; max-height: 70vh; overflow: auto; }
.menu .mi { padding: 6px 12px; border-radius: 5px; cursor: pointer; white-space: nowrap; }
.menu .mi:hover { background: var(--accent-soft); }
.menu .mh { padding: 6px 12px 2px; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.menu .msep { height: 1px; background: var(--border); margin: 4px 0; }

/* Dialoge */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); display: grid; place-items: center; z-index: 900; padding: 16px; }
.dialog { background: var(--panel); border-radius: 10px; box-shadow: var(--shadow); width: 100%; max-width: 560px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; }
.dialog.wide { max-width: 860px; }
.dialog header { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 16px; display: flex; align-items: center; }
.dialog header .x { margin-left: auto; }
.dialog .body { padding: 16px 18px; overflow: auto; }
.dialog footer { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.dialog footer .left { margin-right: auto; }
fieldset { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px 2px; margin: 0 0 12px; }
legend { padding: 0 6px; font-weight: 600; font-size: 13px; }

/* Verfassen */
.compose { position: fixed; left: 50%; top: 50%; width: min(760px, calc(100vw - 32px)); height: min(640px, calc(100vh - 32px)); background: var(--panel); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; z-index: 800; }
.compose.max { inset: 50px 16px 16px 16px !important; width: auto !important; height: auto !important; }
.compose.max .rz { display: none; }
.compose.min { height: 44px !important; overflow: hidden; }
.compose.min .rz:not(.rz-e):not(.rz-w) { display: none; }
.compose .ch { cursor: move; touch-action: none; }
.compose .ch .btn { cursor: pointer; }
.compose .rz { position: absolute; z-index: 2; touch-action: none; }
.compose .rz-n, .compose .rz-s { left: 10px; right: 10px; height: 7px; cursor: ns-resize; }
.compose .rz-n { top: -3px; } .compose .rz-s { bottom: -3px; }
.compose .rz-e, .compose .rz-w { top: 10px; bottom: 10px; width: 7px; cursor: ew-resize; }
.compose .rz-e { right: -3px; } .compose .rz-w { left: -3px; }
.compose .rz-ne, .compose .rz-nw, .compose .rz-se, .compose .rz-sw { width: 14px; height: 14px; }
.compose .rz-ne { top: -3px; right: -3px; cursor: nesw-resize; } .compose .rz-sw { bottom: -3px; left: -3px; cursor: nesw-resize; }
.compose .rz-nw { top: -3px; left: -3px; cursor: nwse-resize; } .compose .rz-se { bottom: -3px; right: -3px; cursor: nwse-resize; }
body.dragging-win, body.dragging-win * { user-select: none !important; }
body.dragging-win iframe { pointer-events: none; }
.compose .ch { display: flex; align-items: center; gap: 6px; padding: 8px 12px; background: var(--toolbar); border-radius: 10px 10px 0 0; border-bottom: 1px solid var(--border); font-weight: 600; }
.compose .ch .t { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.compose .cf { padding: 8px 12px 0; display: grid; grid-template-columns: 70px 1fr; gap: 6px 8px; align-items: center; }
.compose .cf > span { color: var(--muted); text-align: right; font-size: 13px; }
.compose .ctools { display: flex; gap: 2px; padding: 6px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.compose .ctools .btn { padding: 3px 8px; }
.compose .editor { flex: 1; overflow: auto; padding: 10px 14px; outline: none; min-height: 120px; }
.compose textarea.editor { border: 0; border-radius: 0; resize: none; font-family: ui-monospace, Menlo, Consolas, monospace; }
.compose .editor p { margin: 0 0 .5em; }
.compose .editor blockquote { border-left: 3px solid var(--accent); margin: 0 0 0 4px; padding-left: 10px; color: var(--muted); }
.compose .cfoot { display: flex; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); align-items: center; flex-wrap: wrap; }
.compose .att-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px; }
.compose .att-list .att button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 0 0 4px; }
.recip { position: relative; display: flex; flex-wrap: wrap; gap: 4px; border: 1px solid var(--border); border-radius: 6px; padding: 3px 4px; background: var(--panel); min-height: 32px; align-items: center; }
.recip:focus-within { border-color: var(--accent); }
.recip input { border: 0 !important; outline: none !important; flex: 1; min-width: 160px; padding: 3px 4px !important; background: transparent; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); border-radius: 12px; padding: 1px 4px 1px 10px; font-size: 13px; max-width: 100%; }
.pill.bad { background: #fde2e2; color: var(--danger); }
.pill button { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 0 4px; }
.ac { position: absolute; top: 100%; left: 0; right: 0; background: var(--panel); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow); z-index: 10; max-height: 260px; overflow: auto; }
.ac .opt { padding: 6px 10px; cursor: pointer; display: flex; gap: 8px; }
.ac .opt.on, .ac .opt:hover { background: var(--accent-soft); }
.ac .opt .e { color: var(--muted); overflow: hidden; text-overflow: ellipsis; }

/* Adressbuch */
.ab { display: grid; grid-template-columns: 230px 340px 1fr; min-height: 0; }
.ab-books { background: var(--panel-2); border-right: 1px solid var(--border); overflow: auto; padding: 8px 0; display: flex; flex-direction: column; }
.ab-book { padding: 7px 12px; cursor: pointer; display: flex; gap: 8px; align-items: center; }
.ab-book:hover { background: rgba(127,127,127,.1); }
.ab-book.active { background: var(--sel); }
.ab-book .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ab-book .cnt { color: var(--muted); font-size: 12px; }
.ab-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.ab-list .top { padding: 8px; border-bottom: 1px solid var(--border); display: flex; gap: 6px; }
.ab-list .items { overflow: auto; flex: 1; }
.ab-item { display: flex; gap: 10px; align-items: center; padding: 7px 12px; cursor: pointer; border-bottom: 1px solid rgba(127,127,127,.1); }
.ab-item:hover { background: rgba(127,127,127,.08); }
.ab-item.active { background: var(--sel); }
.ab-item .n { font-weight: 500; }
.ab-item .e { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; flex: 0 0 34px; overflow: hidden; font-size: 13px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.big { width: 72px; height: 72px; flex-basis: 72px; font-size: 26px; }
.ab-detail { overflow: auto; padding: 20px 24px; background: var(--panel); }
.ab-detail .hd { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.ab-detail h2 { margin: 0; font-size: 20px; }
.ab-detail dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 12px; margin: 0 0 16px; }
.ab-detail dt { color: var(--muted); text-align: right; }
.ab-detail dd { margin: 0; white-space: pre-wrap; }
.multi-row { display: flex; gap: 6px; margin-bottom: 6px; }
.multi-row select { flex: 0 0 120px; }
.sync-status { font-size: 11px; color: var(--muted); padding: 0 12px 0 32px; margin-top: -4px; margin-bottom: 4px; }

/* Einstellungen */
.settings { display: grid; grid-template-columns: 220px 1fr; min-height: 0; }
.settings nav { background: var(--panel-2); border-right: 1px solid var(--border); padding: 8px 0; }
.settings nav div { padding: 8px 16px; cursor: pointer; }
.settings nav div.active { background: var(--sel); }
.settings .content { overflow: auto; padding: 20px 28px; }
.settings h2 { margin-top: 0; }
.card-list { display: grid; gap: 10px; max-width: 820px; }
.card { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: var(--panel); display: flex; gap: 12px; align-items: center; }
.card .grow { flex: 1; min-width: 0; }
.card .t { font-weight: 600; }
table.grid { border-collapse: collapse; width: 100%; max-width: 980px; background: var(--panel); }
table.grid th, table.grid td { border-bottom: 1px solid var(--border); padding: 7px 10px; text-align: left; }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 500; }

#toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 2000; }
.toast { background: #2b3038; color: #fff; padding: 9px 16px; border-radius: 8px; box-shadow: var(--shadow); max-width: 80vw; }
.toast.err { background: var(--danger); }
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }

/* schmale Bildschirme */
@media (max-width: 820px) {
  .mail { grid-template-columns: 1fr; }
  .folders { display: none; }
  .mail.show-folders .folders { display: block; position: fixed; top: 42px; bottom: 0; left: 0; width: 260px; z-index: 50; box-shadow: var(--shadow); }
  .panes, .panes.vertical { grid-template-rows: 1fr; grid-template-columns: 1fr; }
  .panes .splitter { display: none; }
  .panes .reader { display: none; }
  .panes.reading .list { display: none; }
  .panes.reading .reader { display: flex; }
  .toolbar .search input { width: 140px; }
  .list .c-from { width: 35%; }
  .list .c-date { width: 80px; }
  .ab { grid-template-columns: 1fr; }
  .ab-books { display: none; }
  .ab .ab-detail { display: none; }
  .ab.detail .ab-list { display: none; }
  .ab.detail .ab-detail { display: block; }
  .settings { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .settings nav { display: flex; overflow-x: auto; padding: 0; }
  .topbar .brand span, .userbox .uname { display: none; }
  .hide-sm { display: none !important; }
}
@media (min-width: 821px) { .show-sm { display: none !important; } }

/* Lokale KI */
.compose.ai-busy .editor { opacity: .55; pointer-events: none; }
.dialog textarea { width: 100%; box-sizing: border-box; resize: vertical; font: inherit; }
.ai-live { margin: 6px 12px; border: 1px solid var(--accent); border-radius: 8px; background: var(--panel-2); display: flex; flex-direction: column; max-height: 45%; min-height: 80px; }
.ai-live-head { display: flex; align-items: center; gap: 6px; padding: 5px 8px; border-bottom: 1px solid var(--border); font-size: 13px; }
.ai-live-text { padding: 8px 10px; white-space: pre-wrap; overflow: auto; flex: 1; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.crypt-bar { display: inline-flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.btn.toggle.on { background: var(--sel); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.crypt-method { width: auto; padding: 2px 4px; }
.crypt-info { max-width: 360px; }
.ok-text { color: #2e7d32; }
.compose.encrypted .ch { background: linear-gradient(90deg, rgba(46,125,50,.18), var(--toolbar)); }
.sec-banner { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; padding: 6px 10px; margin: 6px 0 0; border-radius: 6px; font-size: 13px; background: rgba(127,127,127,.08); }
.sec-banner .ok { color: #2e7d32; } .sec-banner .warn { color: #b26a00; } .sec-banner .bad { color: #c62828; font-weight: 600; }
/* KI-Statusanzeige */
.ai-status { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--panel); color: var(--muted); border-radius: 12px; padding: 2px 10px 2px 8px; font: inherit; font-size: 12px; cursor: pointer; max-width: 260px; }
.ai-status .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ai-status .dot { width: 8px; height: 8px; border-radius: 50%; background: #9aa3ad; flex: none; }
.ai-status.ok .dot { background: #2e7d32; }
.ai-status.ok { color: inherit; }
.ai-status.err .dot { background: #c62828; }
.ai-status.err { color: #c62828; border-color: rgba(198,40,40,.4); }
.ai-status.busy .dot { background: var(--accent); animation: aipulse 1s ease-in-out infinite; }
.ai-status.busy { color: var(--accent); border-color: var(--accent); }
@keyframes aipulse { 50% { opacity: .25; transform: scale(.7); } }
@media (max-width: 700px) { .ai-status .lbl { display: none; } .ai-status { padding: 4px; } }
.tpl-editor { border: 1px solid var(--border); border-radius: 6px; min-height: 180px; max-height: 45vh; overflow: auto; padding: 8px 10px; outline: none; background: var(--panel); }
.tpl-editor p { margin: 0 0 .5em; }
.kbd { display: inline-block; margin-left: 8px; padding: 0 6px; border: 1px solid var(--border); border-radius: 4px; font: 12px ui-monospace, Menlo, Consolas, monospace; color: var(--muted); background: var(--panel-2); }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Matrix-Chat ---------- */
.tab .tab-badge { background: var(--danger); color: #fff; border-radius: 9px; padding: 0 6px; font-size: 11px; font-weight: 600; margin-left: 4px; line-height: 17px; }
.chat { display: grid; grid-template-columns: 290px 1fr; min-height: 0; height: 100%; }
.chat-side { border-right: 1px solid var(--border); background: var(--panel-2); overflow-y: auto; min-height: 0; }
.chat-acc { display: flex; align-items: center; gap: 6px; padding: 10px 10px 4px 14px; font-weight: 600; font-size: 13px; }
.chat-note { padding: 4px 14px 10px; }
.chat-room { display: flex; align-items: center; gap: 10px; padding: 7px 12px; cursor: pointer; border-left: 3px solid transparent; }
.chat-room:hover { background: rgba(127,127,127,.08); }
.chat-room.sel { background: var(--sel); border-left-color: var(--accent); }
.chat-room.unread .t { font-weight: 700; }
.chat-room .t { font-size: 14px; }
.chat-room .lock { font-size: 11px; }
.chat-room .badge { background: var(--accent); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; font-weight: 600; }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--panel); }
.chat-head { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.chat-head .t { font-weight: 600; font-size: 15px; }
.chat-main > .sec-banner, .chat-empty > .sec-banner { margin: 8px 16px 0; }
.sec-banner.warn { background: rgba(232,164,0,.14); }
.sec-banner.ok { background: rgba(46,125,50,.12); }
.chat-empty { flex: 1; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; padding: 20px; text-align: center; }
.chat-tl { flex: 1; overflow-y: auto; padding: 10px 16px; min-height: 0; }
.chat-day { text-align: center; margin: 14px 0 6px; }
.chat-day span { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; padding: 1px 10px; font-size: 12px; color: var(--muted); }
.chat-sys { text-align: center; margin: 4px 0; }
.chat-msg { display: flex; flex-direction: column; align-items: flex-start; margin-top: 8px; }
.chat-msg.cont { margin-top: 2px; }
.chat-msg.mine { align-items: flex-end; }
.chat-msg .who { font-size: 12px; font-weight: 600; color: var(--accent); margin: 0 0 2px 10px; }
.chat-msg .bubble { max-width: min(680px, 78%); background: var(--panel-2); border: 1px solid var(--border); border-radius: 14px; padding: 6px 10px; overflow-wrap: anywhere; }
.chat-msg.mine .bubble { background: var(--accent-soft); border-color: transparent; }
.chat-msg.pending .bubble { opacity: .7; }
.chat-msg .time { font-size: 11px; color: var(--muted); margin-left: 8px; float: right; margin-top: 4px; }
.chat-text { white-space: pre-wrap; }
.chat-img { display: block; max-width: 320px; max-height: 320px; border-radius: 8px; cursor: zoom-in; }
.chat-file { text-decoration: none; }
.chat-input { display: flex; align-items: flex-end; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-input textarea { flex: 1; resize: none; border: 1px solid var(--border); border-radius: 18px; padding: 8px 14px; background: var(--panel); max-height: 160px; outline: none; }
.chat-input textarea:focus { border-color: var(--accent); }
.mx-emoji { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin: 12px 0 16px; text-align: center; }
.mx-emoji div { display: flex; flex-direction: column; align-items: center; }
.mx-emoji span { font-size: 34px; }
.mx-emoji small { font-size: 11px; color: var(--muted); }
.mx-results { gap: 4px; margin: 4px 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 2px; background: var(--accent-soft); border-radius: 12px; padding: 0 4px 0 10px; font-size: 13px; }
.chip .btn { padding: 0 6px; }
@media (max-width: 760px) {
  .chat { grid-template-columns: 1fr; }
  .chat.room-open .chat-side { display: none; }
  .chat:not(.room-open) .chat-main { display: none; }
}

/* Wiedervorlagen / geplanter Versand */
.folder.planner .fname { font-weight: 500; }
.planner-sep { border-top: 1px solid var(--border); margin: 6px 8px; }
.fu-ic { font-size: 12px; opacity: .75; }
.fu-ic.due { opacity: 1; }
.card.due { border-color: var(--star); }

/* Gemeinsame Postfächer / Abwesenheit */
.acc-ic { font-size: 12px; }
.pill { display: inline-block; font-size: 11px; padding: 0 7px; border-radius: 9px; background: var(--accent-soft); margin-left: 6px; font-weight: 500; vertical-align: middle; }
.pill.warn { background: rgba(232,164,0,.2); }
.share-list { display: grid; gap: 4px; max-height: 50vh; overflow: auto; border: 1px solid var(--border); border-radius: 6px; padding: 8px; }
.share-row { display: flex; gap: 8px; align-items: center; cursor: pointer; }

/* Spamschutz (Hornetsecurity) */
.pill.ok { background: rgba(40,160,80,.18); color: #1d7a3e; }
label.check { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.hornet-grid { max-width: none; font-size: 13px; }
.hornet-grid tr.sel td { background: var(--sel); }
.hornet-grid td { vertical-align: top; word-break: break-word; }
.chip.small { font-size: 12px; padding: 1px 9px; border: 1px solid var(--border); background: var(--panel); }
.chip.small.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.hornet-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; max-width: 980px; }
.hornet-bar input, .hornet-bar select { width: auto; }

/* Im Intranet eingebettet: Marke und Name stehen schon in der Intranet-Kopfzeile */
html.embedded .topbar .brand, html.embedded .userbox .uname { display: none; }

/* App (PWA): iPhone-Notch/Home-Indikator, dynamische Höhe, Offline-Hinweis */
@supports (height: 100dvh) {
  .shell, .boot, .login-wrap { height: 100dvh; }
  .dialog { max-height: calc(100dvh - 32px); }
}
html.standalone .shell { padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
html.standalone .login-wrap { padding-top: calc(16px + env(safe-area-inset-top)); padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
html.standalone body { -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; overscroll-behavior: none; }
html.standalone input, html.standalone textarea, html.standalone [contenteditable], html.standalone .msg-body, html.standalone .reader, html.standalone pre { -webkit-user-select: text; user-select: text; }
@media (max-width: 760px) {
  html.standalone .compose { left: 0 !important; top: 0 !important; transform: none !important; width: 100vw; height: 100dvh; border-radius: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
  input, select, textarea { font-size: 16px; } /* verhindert das Hineinzoomen auf dem iPhone */
}
.offline-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(10px + env(safe-area-inset-bottom)); z-index: 1500; background: #3a3f47; color: #fff;
  padding: 6px 14px; border-radius: 16px; font-size: 12px; box-shadow: var(--shadow); max-width: calc(100vw - 24px); text-align: center; pointer-events: none; }
#toasts { padding-bottom: env(safe-area-inset-bottom); }
.pwa-steps { padding-left: 20px; line-height: 1.7; }
.pwa-steps li { margin: 2px 0; }
.notice { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--panel-2); margin: 8px 0; font-size: 13px; }
.notice.warn { border-color: rgba(232,164,0,.55); background: rgba(232,164,0,.10); }
