/* ═══ Sinici Mail ═══ */

:root {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #f1f3f4;
  --surface-3: #e8eaed;
  --border: #e3e6ea;
  --text: #1f2328;
  --text-2: #5f6368;
  --text-3: #80868b;
  --accent: #1a73e8;
  --accent-soft: #e8f0fe;
  --danger: #d93025;
  --star: #f4b400;
  --read-bg: #f8f9fb;
  --shadow: 0 1px 3px rgba(60,64,67,.08), 0 4px 14px rgba(60,64,67,.07);
  --radius: 14px;
  color-scheme: light;
}

[data-theme="dark"] {
  --bg: #101318;
  --surface: #1a1e25;
  --surface-2: #232830;
  --surface-3: #2c323c;
  --border: #2b3139;
  --text: #e6e8eb;
  --text-2: #a2a8b4;
  --text-3: #7b8290;
  --accent: #7aa7ff;
  --accent-soft: #1c2740;
  --danger: #ff6b5e;
  --star: #ffcf4d;
  --read-bg: #151920;
  --shadow: 0 1px 3px rgba(0,0,0,.45), 0 8px 24px rgba(0,0,0,.3);
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px; -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; font-size: inherit; cursor: pointer; }
input, textarea { font-family: inherit; font-size: inherit; }

/* ═══ Icons ═══ */
.ic {
  width: 19px; height: 19px;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  flex: 0 0 auto; pointer-events: none;
}
.ic-lg { width: 24px; height: 24px; }
.ic-xl { width: 40px; height: 40px; stroke-width: 1.4; }
.ic-xxl { width: 58px; height: 58px; stroke-width: 1.2; opacity: .35; }

/* ═══ Login ═══ */
.login-wrap {
  min-height: 100dvh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(circle at 20% 10%, var(--accent-soft), transparent 55%), var(--bg);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 20px;
  padding: 32px 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 16px;
}
.login-logo {
  width: 54px; height: 54px; margin: 0 auto;
  display: grid; place-items: center; border-radius: 16px;
  background: var(--accent); color: #fff;
}
.login-logo .ic { stroke-width: 2; }
.login-card h1 { margin: 0; font-size: 22px; text-align: center; font-weight: 600; }
.login-sub { margin: -8px 0 8px; text-align: center; color: var(--text-2); font-size: 13px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; }
.login-card label span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.login-card input {
  width: 100%; padding: 11px 13px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-error {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
  color: var(--danger); padding: 10px 12px; border-radius: 10px; font-size: 13px;
}
.login-hint { margin: 0; font-size: 11px; color: var(--text-3); text-align: center; line-height: 1.5; }

/* ═══ Buttons ═══ */
.btn-primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: none; border-radius: 10px;
  background: var(--accent); color: #fff; font-weight: 600;
  transition: filter .15s, opacity .15s;
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: transparent; color: var(--text-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost.icon-only { padding: 10px 11px; }

.icon-btn {
  border: none; background: transparent; color: var(--text-2);
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.active { color: var(--star); }
.icon-btn.active .ic { fill: currentColor; }
.icon-btn.small { width: 32px; height: 32px; }
.icon-btn.small .ic { width: 16px; height: 16px; }
.icon-btn.tiny { width: 26px; height: 26px; }
.icon-btn.tiny .ic { width: 14px; height: 14px; }

/* ═══ App ═══ */
.app { display: flex; flex-direction: column; height: 100dvh; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 8px;
  text-decoration: none; color: var(--text);
  font-weight: 600; font-size: 18px; padding: 4px 8px; border-radius: 10px;
}
.brand:hover { background: var(--surface-2); }

.search {
  flex: 1 1 auto; max-width: 720px;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid transparent;
  border-radius: 999px; padding: 0 14px; height: 42px;
  transition: background .15s, border-color .15s;
}
.search:focus-within { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow); }
.search-icon { color: var(--text-3); }
.search input { flex: 1; border: none; background: transparent; outline: none; color: var(--text); height: 100%; }
/* Eigenes X statt des Browser-Clears — sonst stehen zwei Kreuze im Feld */
.search input::-webkit-search-cancel-button,
.search input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
.search-clear { border: none; background: transparent; color: var(--text-3); display: grid; place-items: center; }

.topbar-right { display: flex; align-items: center; gap: 2px; margin-left: auto; }

/* ═══ Suche: Feld, Vorschläge, Treffer ═══ */
.search-wrap { position: relative; flex: 1 1 auto; max-width: 720px; display: flex; }

.search-drop {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0; z-index: 60;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 6px; max-height: 60vh; overflow: auto;
}
.sd-head {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); padding: 8px 10px 4px;
}
.sd-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: none; border-radius: 10px;
  background: transparent; color: var(--text); text-align: left;
}
.sd-item:hover, .sd-item.active { background: var(--accent-soft); }
.sd-item .ic { width: 16px; height: 16px; color: var(--text-3); }
.sd-item.active .ic { color: var(--accent); }
.sd-text { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-sub { color: var(--text-3); font-size: 12px; flex: 0 0 auto; max-width: 45%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-kind {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-3); background: var(--surface-2); border-radius: 6px; padding: 2px 6px;
}

.search-view { padding: 12px 14px 28px; }
.sr-summary { color: var(--text-3); font-size: 12px; margin: 0 4px 10px; }
.sr-group { margin-bottom: 18px; }
.sr-group-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; font-weight: 700; color: var(--text-2);
  padding: 6px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.sr-group-head .ic { width: 15px; height: 15px; color: var(--text-3); }
.sr-count { margin-left: auto; color: var(--text-3); font-weight: 500; }
.sr-item {
  display: flex; gap: 10px; width: 100%; text-align: left;
  padding: 10px 8px; border: none; border-radius: 10px; background: transparent; color: var(--text);
}
.sr-item:hover { background: var(--surface-2); }
.sr-ic { flex: 0 0 auto; width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.sr-body { flex: 1 1 auto; min-width: 0; }
.sr-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-snip { color: var(--text-2); font-size: 12.5px; margin-top: 2px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.sr-meta { color: var(--text-3); font-size: 11.5px; margin-top: 3px; }
.sr-title mark, .sr-snip mark {
  background: color-mix(in srgb, var(--star) 45%, transparent);
  color: inherit; border-radius: 3px; padding: 0 1px;
}
.search-skel { display: flex; flex-direction: column; gap: 10px; padding: 8px 4px; }
.search-skel span { display: block; height: 12px; border-radius: 6px; background: var(--surface-2); animation: skel 1s infinite alternate; }
.search-skel span:nth-child(2) { width: 75%; animation-delay: .1s; }
.search-skel span:nth-child(3) { width: 55%; animation-delay: .2s; }
@keyframes skel { from { opacity: .45 } to { opacity: .9 } }
.search-empty { text-align: center; color: var(--text-3); padding: 38px 16px; }
.search-empty .ic { width: 40px; height: 40px; opacity: .4; margin-bottom: 8px; }
.search-tip { color: var(--text-3); font-size: 12px; text-align: center; padding: 10px; }

.live-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-3); margin-right: 6px; opacity: .5;
  transition: background .3s, opacity .3s;
}
.live-dot.on { background: #34a853; opacity: 1; box-shadow: 0 0 0 3px color-mix(in srgb, #34a853 22%, transparent); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; border: none;
  background: var(--accent); color: #fff; font-weight: 600; font-size: 13px;
  display: grid; place-items: center;
}
.account { position: relative; }
.account-menu {
  position: absolute; right: 0; top: 44px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow);
  min-width: 230px; padding: 8px; z-index: 40;
}
.account-mail {
  font-size: 12px; color: var(--text-2); padding: 8px 10px;
  border-bottom: 1px solid var(--border); margin-bottom: 6px; word-break: break-all;
}
.account-menu button {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left; border: none; background: transparent;
  color: var(--text); padding: 10px; border-radius: 8px;
}
.account-menu button:hover { background: var(--surface-2); }

/* ═══ Layout ═══ */
.layout { flex: 1 1 auto; display: flex; min-height: 0; }

.sidebar {
  width: 236px; flex: 0 0 auto; padding: 12px 8px;
  display: flex; flex-direction: column; gap: 8px;
  border-right: 1px solid var(--border);
  background: var(--bg); overflow-y: auto;
}

.compose-btn {
  display: flex; align-items: center; gap: 10px;
  margin: 0 6px 8px; padding: 14px 20px;
  border: none; border-radius: 16px;
  background: var(--accent); color: #fff;
  font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); transition: filter .15s, transform .1s;
}
.compose-btn:hover { filter: brightness(1.07); }
.compose-btn:active { transform: scale(.98); }

.folders, .labels { display: flex; flex-direction: column; gap: 1px; }

.folder, .label-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px; border: none; background: transparent;
  color: var(--text-2); border-radius: 0 999px 999px 0;
  text-align: left; width: 100%;
}
.folder:hover, .label-row:hover { background: var(--surface-2); color: var(--text); }
.folder.active, .label-row.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.folder-name, .label-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.folder-count, .label-count { font-size: 12px; font-weight: 600; color: var(--accent); }
.label-dot { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 auto; }

.labels-block { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.labels-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 4px 14px; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-3); font-weight: 600;
}

/* ═══ Liste ═══ */
.list-pane {
  width: 430px; flex: 0 0 auto; display: flex; flex-direction: column;
  border-right: 1px solid var(--border); background: var(--surface); min-width: 0;
}
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.list-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.list-actions { display: flex; align-items: center; gap: 6px; }
.list-count { font-size: 12px; color: var(--text-3); }

/* Kategorien wie in Gmail: Allgemein · Werbung · Soziale Netzwerke */
.cats {
  display: flex; gap: 2px; padding: 0 6px; flex: 0 0 auto;
  border-bottom: 1px solid var(--border); overflow-x: auto;
  scrollbar-width: none; -ms-overflow-style: none;
}
.cats::-webkit-scrollbar { display: none; }
.cats[hidden] { display: none; }
.cat {
  display: flex; align-items: center; gap: 6px; padding: 9px 8px 8px;
  border: 0; border-bottom: 2.5px solid transparent; background: none;
  color: var(--text-3); font: inherit; font-size: 12px; font-weight: 600;
  cursor: pointer; white-space: nowrap; min-width: 0; flex: 0 1 auto;
  transition: color .12s, border-color .12s;
}
.cat > span { overflow: hidden; text-overflow: ellipsis; }
.cat .ic { width: 16px; height: 16px; flex: 0 0 auto; }
.cat:hover { color: var(--text); }
.cat.on { color: var(--accent); border-bottom-color: var(--accent); }
.cat-n {
  font-style: normal; font-size: 10.5px; font-weight: 700; line-height: 1.55;
  padding: 0 5px; border-radius: 99px; background: var(--accent); color: #fff;
  flex: 0 0 auto;
}
.cat-n[hidden] { display: none; }

.list-scroll { flex: 1; overflow-y: auto; }
.list-empty { padding: 48px 20px; text-align: center; color: var(--text-3); display: grid; justify-items: center; gap: 10px; }

.msg {
  display: flex; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer; background: var(--read-bg); transition: background .12s;
}
.msg:hover { background: var(--surface-2); }
.msg.unread { background: var(--surface); }
.msg.unread .msg-from, .msg.unread .msg-subject { font-weight: 700; color: var(--text); }
.msg.selected { background: var(--accent-soft); }
.msg.selected:hover { background: var(--accent-soft); }

/* ═══ Chat-Liste (wie Messenger) ═══ */
.ci {
  position: relative; align-items: center; gap: 12px;
  padding: 9px 14px; border-bottom: none; background: var(--surface);
}
.ci:hover { background: var(--surface-2); }
.ci.selected { background: var(--accent-soft); }
.ci-av { width: 42px; height: 42px; font-size: 14px; flex: 0 0 auto; }
.ci-main { flex: 1 1 auto; min-width: 0; }
.ci-top { display: flex; align-items: baseline; gap: 8px; }
.ci-name {
  flex: 1 1 auto; min-width: 0; font-size: 14.5px; font-weight: 600; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ci-time { font-size: 11.5px; color: var(--text-3); flex: 0 0 auto; }
.ci-bottom { display: flex; align-items: center; gap: 8px; margin-top: 2px; }
.ci-preview {
  flex: 1 1 auto; min-width: 0; font-size: 13px; color: var(--text-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  display: flex; align-items: center; gap: 5px;
}
.ci-preview .ic { width: 12px; height: 12px; flex: 0 0 auto; }
.ci-badge {
  flex: 0 0 auto; min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 999px; background: var(--accent); color: #fff;
  font-size: 11.5px; font-weight: 700; display: grid; place-items: center;
}
.ci.unread .ci-name { font-weight: 700; }
.ci.unread .ci-preview { color: var(--text-2); font-weight: 600; }
.ci.unread .ci-time { color: var(--accent); }
.ci-star {
  position: absolute; right: 6px; bottom: 4px;
  opacity: 0; transition: opacity .12s; width: 26px; height: 26px;
}
.ci:hover .ci-star, .ci-star.on { opacity: 1; }
.ci-star .ic { width: 15px; height: 15px; }

.msg-main { flex: 1; min-width: 0; }
.msg-row { display: flex; align-items: baseline; gap: 8px; }
.msg-from {
  flex: 1; min-width: 0; font-weight: 500; font-size: 13.5px; color: var(--text-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.msg-date { font-size: 11.5px; color: var(--text-3); flex: 0 0 auto; }
.msg-subject {
  display: flex; align-items: center; gap: 6px;
  font-size: 13.5px; color: var(--text-2); margin-top: 1px;
}
.msg-subject span.txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-badges { display: flex; gap: 6px; margin-top: 4px; align-items: center; flex-wrap: wrap; }
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10.5px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-3);
}
.badge .ic { width: 11px; height: 11px; }
.badge.count { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.label-chip {
  font-size: 10.5px; padding: 1px 8px; border-radius: 999px;
  color: #fff; font-weight: 600;
}

.msg-star { border: none; background: transparent; color: var(--text-3); padding: 2px; line-height: 1; align-self: flex-start; }
.msg-star.on { color: var(--star); }
.msg-star.on .ic { fill: currentColor; }

.load-more {
  display: block; width: calc(100% - 28px); margin: 12px 14px 20px;
  padding: 10px; border: 1px solid var(--border); border-radius: 10px;
  background: transparent; color: var(--accent);
}

/* ═══ Lesen ═══ */
.read-pane { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; background: var(--surface); }
.read-empty {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; color: var(--text-3); gap: 12px;
}
.read-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.read-toolbar {
  display: flex; align-items: center; gap: 2px; padding: 8px 12px;
  border-bottom: 1px solid var(--border); flex: 0 0 auto;
}
.spacer { flex: 1; }
.read-scroll { flex: 1; overflow-y: auto; padding: 8px 24px 60px; }
.read-subject { margin: 0 0 6px; font-size: 21px; font-weight: 500; line-height: 1.35; }
.thread-note { font-size: 12px; color: var(--text-3); margin-bottom: 18px; }

.tmsg { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 18px; }
.tmsg:last-child { border-bottom: none; }
.tmsg-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.tmsg-meta { flex: 1; min-width: 0; }
.tmsg-from { font-weight: 600; }
.tmsg-to { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.tmsg-date { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.tmsg.collapsed .tmsg-body { display: none; }
.tmsg-toggle {
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2);
  border-radius: 8px; padding: 4px 10px; font-size: 12px; margin-top: 10px;
}

.avatar.small { width: 38px; height: 38px; font-size: 14px; flex: 0 0 auto; }

.images-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 14px;
  font-size: 13px; color: var(--text-2);
}
.images-banner button {
  display: inline-flex; align-items: center; gap: 6px;
  border: none; background: var(--accent); color: #fff;
  padding: 6px 12px; border-radius: 8px; font-weight: 600;
}

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.attach {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 8px 12px; background: var(--surface-2);
  color: var(--text); text-decoration: none; font-size: 13px;
}
.attach:hover { border-color: var(--accent); }
.attach-size { color: var(--text-3); font-size: 11px; }

.pgp-locked {
  display: grid; gap: 10px; padding: 18px;
  border: 1px dashed var(--border); border-radius: 12px;
  background: var(--surface-2); color: var(--text-2); font-size: 13px;
}
.pgp-locked textarea {
  width: 100%; min-height: 90px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); padding: 10px; font-family: ui-monospace, monospace; font-size: 11px;
}

.read-content { line-height: 1.6; word-wrap: break-word; overflow-wrap: anywhere; }
.read-content img { max-width: 100%; height: auto; }
.read-content table { max-width: 100% !important; }
.read-content a { color: var(--accent); }
.read-content blockquote { border-left: 3px solid var(--border); margin: 12px 0; padding-left: 12px; color: var(--text-2); }
.read-content pre { white-space: pre-wrap; word-wrap: break-word; background: var(--surface-2); padding: 12px; border-radius: 8px; }

/* ═══ Verfassen ═══ */
.compose {
  position: fixed; right: 20px; bottom: 0; width: 560px;
  max-width: calc(100vw - 24px); background: var(--surface);
  border: 1px solid var(--border); border-bottom: none;
  border-radius: 14px 14px 0 0; box-shadow: 0 -2px 26px rgba(0,0,0,.18);
  display: flex; flex-direction: column; z-index: 60; max-height: 80vh;
}
.compose-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 14px; background: var(--surface-2);
  border-radius: 14px 14px 0 0; font-weight: 600; font-size: 13.5px;
}
.compose-save { margin-left: auto; font-weight: 400; font-size: 11.5px; color: var(--text-3); }

.compose-fields { display: flex; flex-direction: column; border-bottom: 1px solid var(--border); }
.field {
  display: flex; align-items: center; gap: 6px;
  border-bottom: 1px solid var(--border); padding-left: 14px;
}
.field:last-child { border-bottom: none; }
.field > span { width: 60px; font-size: 12.5px; color: var(--text-3); flex: 0 0 auto; }
.field input {
  flex: 1; border: none; background: transparent; padding: 11px 8px;
  color: var(--text); outline: none;
}
.chipbox { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 1; padding: 4px 0; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface-3); border-radius: 999px;
  padding: 3px 6px 3px 10px; font-size: 12.5px; color: var(--text);
}
.chip button { border: none; background: transparent; color: var(--text-2); display: grid; place-items: center; padding: 2px; }
.chip button .ic { width: 13px; height: 13px; }

.compose textarea {
  flex: 1; min-height: 220px; border: none; outline: none; resize: none;
  padding: 16px; background: transparent; color: var(--text); line-height: 1.6;
}

.attach-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.attach-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 5px 6px 5px 10px;
  font-size: 12.5px; max-width: 100%;
}
.attach-chip .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 190px; }
.attach-chip .sz { color: var(--text-3); font-size: 11px; }
.attach-chip button {
  border: none; background: transparent; color: var(--text-2);
  display: grid; place-items: center; padding: 2px; border-radius: 6px;
}
.attach-chip button:hover { background: var(--surface-3); color: var(--danger); }
.attach-chip .ic { width: 13px; height: 13px; }
.attach-chip.uploading { opacity: .8; }
.attach-chip .bar {
  display: block; width: 54px; height: 4px; border-radius: 3px;
  background: var(--surface-3); overflow: hidden;
}
.attach-chip .bar i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.compose-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-top: 1px solid var(--border);
}
.compose-foot .btn-ghost { padding: 10px 12px; }
.compose-status { font-size: 12px; color: var(--text-2); margin-left: auto; }
.ai-menu {
  position: absolute; right: 12px; bottom: 62px; z-index: 70;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; box-shadow: var(--shadow); padding: 6px; min-width: 200px;
}
.ai-menu-head {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .6px;
  color: var(--text-3); padding: 6px 10px;
}
.ai-menu button {
  display: block; width: 100%; text-align: left; border: none;
  background: transparent; color: var(--text); padding: 9px 10px;
  border-radius: 8px; font-size: 13px;
}
.ai-menu button:hover { background: var(--accent-soft); color: var(--accent); }
.compose-status.ok { color: #34a853; }
.compose-status.err { color: var(--danger); }

.autocomplete {
  position: absolute; z-index: 70;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
  min-width: 280px; max-height: 220px; overflow-y: auto; padding: 4px;
}
.autocomplete button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px;
  width: 100%; border: none; background: transparent; text-align: left;
  padding: 8px 10px; border-radius: 8px; color: var(--text);
}
.autocomplete button:hover, .autocomplete button.active { background: var(--accent-soft); }
.autocomplete .ac-name { font-size: 13px; font-weight: 600; }
.autocomplete .ac-mail { font-size: 11.5px; color: var(--text-3); }

/* ═══ Modal ═══ */
.modal {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(0,0,0,.42);
  display: grid; place-items: center; padding: 20px;
}
.modal-card {
  width: 100%; max-width: 520px; max-height: 84vh; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 12px 12px 18px; border-bottom: 1px solid var(--border); font-weight: 600;
}
.modal-body { padding: 16px 18px; overflow-y: auto; }
.modal-foot {
  display: flex; gap: 10px; padding: 12px 18px;
  border-top: 1px solid var(--border);
}
.modal-foot input {
  flex: 1; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); padding: 10px 12px; outline: none;
}

.label-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px; border-radius: 8px;
}
.label-item:hover { background: var(--surface-2); }
.label-item .grow { flex: 1; }

.keys { width: 100%; border-collapse: collapse; font-size: 13px; }
.keys td { padding: 7px 6px; border-bottom: 1px solid var(--border); color: var(--text-2); }
.keys td:first-child { width: 130px; }
kbd {
  display: inline-block; padding: 2px 7px; border-radius: 6px;
  border: 1px solid var(--border); background: var(--surface-2);
  font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--text);
}
.hint { font-size: 12.5px; color: var(--text-2); line-height: 1.55; margin: 0 0 14px; }
.pgp-status { font-size: 12.5px; margin-bottom: 14px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.pgp-status.ok { color: #2e7d32; }
.pgp-status.no { color: var(--text-2); }
.pgp-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.pgp-field { display: flex; flex-direction: column; gap: 6px; }
.pgp-field span { font-size: 12px; color: var(--text-2); }
.pgp-field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); padding: 10px;
  font-family: ui-monospace, monospace; font-size: 11.5px; resize: vertical;
}

/* ═══ Wissen & Schreibstil ═══ */
.mem-h {
  font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-2); margin: 18px 0 9px; padding-top: 14px; border-top: 1px solid var(--border);
}
.mem-h:first-of-type { border-top: none; padding-top: 0; margin-top: 2px; }
.mem-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 10px; }
.mem-grid .modal-input { margin-bottom: 10px; }
.mem-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 10px 0 4px; }
.mem-fact-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 8px; align-items: start; }
.mem-fact-add .modal-input { margin-bottom: 0; }
.mem-facts { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.mem-fact {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 9px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border);
}
.mem-fact-t { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mem-fact-t strong { font-size: 13.5px; }
.mem-fact-t span { font-size: 12.5px; color: var(--text-2); line-height: 1.5; }
.mem-empty { font-size: 12.5px; color: var(--text-2); padding: 6px 0; }
.mem-box {
  font-size: 12.5px; color: var(--text-2); line-height: 1.55;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px;
}
.mem-row { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; }
.mem-row span { color: var(--text-2); }
.mem-row b { color: var(--text); font-weight: 600; text-align: right; }
@media (max-width: 560px) {
  .mem-grid { grid-template-columns: 1fr; }
  .mem-fact-add { grid-template-columns: 1fr; }
}

/* ═══ Assistent ═══ */
.chat-card { display: flex; flex-direction: column; max-height: 84dvh; }
.chat-list {
  flex: 1; min-height: 200px; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 10px;
}
.chat-empty {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px; text-align: center; color: var(--text-2); font-size: 13px; line-height: 1.6;
}
.chat-msg { display: flex; flex-direction: column; max-width: 88%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.assistant { align-self: flex-start; align-items: flex-start; }
.chat-bubble {
  padding: 10px 14px; border-radius: 14px; font-size: 13.5px;
  line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere;
}
.chat-msg.user .chat-bubble { background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.chat-msg.assistant .chat-bubble { background: var(--surface-2); color: var(--text); border-bottom-left-radius: 5px; }
.chat-acts { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.chat-act {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  font: inherit; font-size: 11.5px; padding: 4px 10px; border-radius: 99px; cursor: pointer;
}
.chat-act:hover { border-color: var(--accent); color: var(--accent); }
.chat-input-wrap {
  flex: 0 0 auto; display: flex; gap: 8px; align-items: flex-end;
  padding: 12px 16px; border-top: 1px solid var(--border);
}
.chat-input {
  flex: 1; min-width: 0; resize: none; font: inherit; font-size: 13.5px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); outline: none; line-height: 1.5;
  max-height: 120px;
}
.chat-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-thinking { align-self: flex-start; color: var(--text-2); font-size: 12.5px; padding: 4px 2px; }
.chat-hint {
  flex: 0 0 auto; margin: 0 16px 8px; padding: 8px 12px; border-radius: 10px;
  background: var(--accent-soft); color: var(--text); font-size: 12.5px; line-height: 1.5;
}
.chat-chips {
  flex: 0 0 auto; display: flex; gap: 6px; flex-wrap: wrap;
  padding: 0 16px 10px; border-top: none;
}
.chat-chip {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  font: inherit; font-size: 11.5px; padding: 5px 11px; border-radius: 99px;
  cursor: pointer; white-space: nowrap; transition: .15s;
}
.chat-chip:hover { border-color: var(--accent); color: var(--accent); }
.chat-msg.assistant .chat-acts { margin-top: 6px; }

/* ═══ Termine ═══ */
.appt-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.appt-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.appt-when {
  flex: 0 0 auto; min-width: 92px; font-size: 12px; font-weight: 700;
  color: var(--accent); font-variant-numeric: tabular-nums;
}
.appt-main { flex: 1; min-width: 0; }
.appt-title { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-meta { font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appt-empty { font-size: 12.5px; color: var(--text-2); padding: 8px 0; }

@media (max-width: 560px) {
  .chat-msg { max-width: 94%; }
  .appt-when { min-width: 74px; font-size: 11px; }
}

/* ═══ Zitat-Verlauf ═══ */
.quoted-wrap { margin: 8px 0 2px; }
.quoted-toggle {
  min-width: 34px; height: 18px; padding: 0 8px;
  border-radius: 9px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text-2);
  font: inherit; font-size: 11px; line-height: 1; cursor: pointer;
  letter-spacing: 1px;
}
.quoted-toggle:hover { border-color: var(--accent); color: var(--accent); }
.quoted-toggle.open { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.quoted-body {
  margin-top: 6px; padding-left: 12px;
  border-left: 2px solid var(--border); opacity: .85;
}

/* ═══ Chat-Ansicht (wie Messenger) ═══ */
#threadMessages.as-chat {
  display: flex; flex-direction: column; gap: 3px;
  padding: 4px 2px 12px;
  max-width: 900px; margin: 0 auto; width: 100%;
}
.chat-day { display: flex; justify-content: center; margin: 14px 0 8px; }
.chat-day span {
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
  color: var(--text-2); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 4px 12px;
}

.chat-row { position: relative; display: block; max-width: 100%; }
.chat-row.other { padding-left: 36px; }
.chat-row.own { padding-right: 0; }
.chat-av { position: absolute; left: 0; bottom: 2px; }
.chat-av .avatar { width: 28px; height: 28px; font-size: 11px; }

.chat-bubble {
  width: fit-content;
  max-width: min(760px, 94%);
  padding: 9px 13px 7px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 1px 1px rgba(0,0,0,.04);
  position: relative;
  /* Der Leser setzt pre-wrap für Reintext — in der Blase würde das
     die Einrückung des Templates als Leerzeilen rendern. */
  white-space: normal;
}
.chat-row.own .chat-bubble { margin-left: auto; }
.chat-row.other .chat-bubble { border-bottom-left-radius: 5px; }

/* Gestaltete HTML-Mails: Karte statt Sprechblase — breiter und besser lesbar */
.chat-bubble.rich,
.chat-row.own .chat-bubble.rich {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 14px;
  padding: 16px 18px 12px;
  box-shadow: var(--shadow);
  width: 100%; max-width: 100%;
}
.chat-bubble.rich .read-content { font-size: 14.5px; line-height: 1.6; }
.chat-bubble.rich .read-content img { max-width: 100%; height: auto; }
.chat-bubble.rich .chat-time { color: var(--text-3); }
.chat-row.cont .chat-who { display: none; }
.chat-row.cont .chat-av { visibility: hidden; }

/* Aktionen pro Nachricht: dezent, tauchen beim Überfahren auf */
.chat-acts {
  position: absolute; top: 0; right: 0;
  display: flex; gap: 2px; opacity: 0; transition: opacity .15s;
}
.chat-row.own .chat-acts { right: auto; left: 0; }
.chat-row:hover .chat-acts, .chat-row:focus-within .chat-acts { opacity: 1; }
.chat-act {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center;
}
.chat-act:hover { color: var(--danger); border-color: var(--danger); }
.chat-act .ic { width: 14px; height: 14px; }

.toast-undo {
  margin-left: 12px; border: none; background: transparent;
  color: var(--accent); font-weight: 700; text-decoration: underline;
}
.compose-status.warn { color: var(--star); }

/* ═══ Termineinladung ═══ */
.invite-banner {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); background: var(--accent-soft);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 10px;
}
.invite-ico { display: grid; place-items: center; color: var(--accent); }
.invite-txt { display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; }
.invite-txt strong { font-size: 13.5px; }
.invite-txt span { font-size: 12px; color: var(--text-2); }
.invite-accept { padding: 7px 14px; }

/* ═══ Regeln ═══ */
.rules-list { list-style: none; margin: 0 0 6px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rule-item {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px;
}
.rule-txt { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rule-txt strong { font-size: 13.5px; }
.rule-txt span { font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rule-toggle { padding: 5px 10px; font-size: 12px; }
.rule-toggle.on { color: var(--accent); border-color: var(--accent); }
.rule-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); margin: 6px 0; }

/* ═══ Serienmail ═══ */
.bulk-list { list-style: none; margin: 8px 0 0; padding: 0; max-height: 40vh; overflow: auto; }
.bulk-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 13px; }
.bulk-item input { width: 16px; height: 16px; }
.chat-row.own .chat-bubble {
  border-bottom-right-radius: 5px;
  background: var(--accent); color: #fff; border-color: transparent;
}
.chat-row.own + .chat-row.own .chat-bubble { margin-top: 2px; }
.chat-row.other + .chat-row.other .chat-bubble { margin-top: 2px; }

.chat-who { font-size: 12px; font-weight: 700; color: var(--accent); margin-bottom: 2px; }
.chat-time { font-size: 10.5px; color: var(--text-3); text-align: right; margin-top: 4px; }
.chat-row.own .chat-time { color: rgba(255,255,255,.78); }

/* Inhalt in der Blase: kein doppelter Rahmen, keine Einzüge */
.chat-bubble .read-content { background: transparent; padding: 0; font-size: 14px; }
.chat-bubble .read-content p { margin: 0 0 6px; }
.chat-bubble .read-content p:last-child { margin-bottom: 0; }
.chat-bubble .read-content a { color: inherit; text-decoration: underline; }
.chat-bubble .attachments { margin: 0 0 6px; }
.chat-bubble .attach {
  background: color-mix(in srgb, currentColor 8%, transparent);
  border-color: color-mix(in srgb, currentColor 22%, transparent);
  color: inherit;
}
.chat-bubble .images-banner {
  background: color-mix(in srgb, currentColor 10%, transparent);
  border-color: color-mix(in srgb, currentColor 20%, transparent);
  color: inherit; margin-bottom: 6px;
}
.chat-bubble .quoted-toggle {
  background: color-mix(in srgb, currentColor 10%, transparent);
  border-color: color-mix(in srgb, currentColor 25%, transparent);
  color: inherit;
}
.chat-bubble .quoted-body { border-left-color: color-mix(in srgb, currentColor 30%, transparent); }
.chat-bubble pre {
  white-space: pre-wrap; margin: 0; padding: 0;
  background: transparent; color: inherit;
  font-family: inherit; font-size: 14px; line-height: 1.5;
}

/* Antwortleiste unten */
.chat-bar {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 8px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border); background: var(--surface);
}
.chat-bar textarea {
  flex: 1 1 auto; resize: none; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface-2); color: var(--text);
  padding: 10px 14px; line-height: 1.4; min-height: 40px; max-height: 150px; outline: none;
}
.chat-bar textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-send {
  width: 40px; height: 40px; flex: 0 0 auto;
  border: none; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent); color: #fff;
}
.chat-send:hover { filter: brightness(1.08); }
.chat-send:disabled { opacity: .5; }

/* ═══ Verfassen: Rich-Text (wie Gmail) ═══ */
.cmp-body {
  flex: 1; min-height: 240px; overflow-y: auto;
  padding: 14px 16px; outline: none;
  background: var(--surface); color: var(--text);
  font-size: 14px; line-height: 1.6;
  word-wrap: break-word;
}
.cmp-body:empty::before {
  content: attr(data-placeholder);
  color: var(--text-2); pointer-events: none;
}
.cmp-body a { color: var(--accent); }
.cmp-body ul, .cmp-body ol { margin: 8px 0 8px 22px; }
.cmp-body p { margin: 0 0 10px; }
.cmp-body hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

.cmp-tools {
  display: flex; align-items: center; gap: 3px; flex-wrap: wrap;
  padding: 6px 12px; background: var(--surface-2);
  border-top: 1px solid var(--border);
}
.cmp-tool {
  min-width: 30px; height: 30px; padding: 0 7px;
  border: 1px solid transparent; border-radius: 7px; background: transparent;
  color: var(--text); font: inherit; font-size: 12.5px; line-height: 1; cursor: pointer;
}
.cmp-tool:hover { background: var(--surface); border-color: var(--border); }
.cmp-tool.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.cmp-tool.wide { padding: 0 10px; }
.cmp-sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.cmp-grow { flex: 1; }
.cmp-select {
  height: 30px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text); font: inherit; font-size: 12px; padding: 0 6px;
}
.cmp-color-wrap {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 7px; cursor: pointer;
}
.cmp-color-wrap:hover { background: var(--surface); border: 1px solid var(--border); }
.cmp-a { font-size: 13px; font-weight: 700; border-bottom: 3px solid #1f2937; line-height: 1.1; }
.cmp-a.hi { border-bottom-color: #fde68a; }
.cmp-color-wrap input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: none; padding: 0;
}
.cmp-html {
  width: 100%; flex: 1; min-height: 220px; resize: none;
  border: none; outline: none; padding: 14px;
  background: var(--surface); color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px; line-height: 1.6;
}
.cmp-preview {
  flex: 1; min-height: 220px; overflow: auto; padding: 14px;
  background: #fff; color: #1f2937;
}
.cmp-preview iframe { width: 100%; min-height: 260px; border: none; }

/* ═══ Toast ═══ */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #323232; color: #fff; padding: 12px 20px;
  border-radius: 10px; font-size: 13px; z-index: 100;
  box-shadow: 0 6px 24px rgba(0,0,0,.3);
}

/* ═══ Kontakte / Medien / Signatur ═══ */
.modal-card.wide { max-width: 800px; }
.modal-input {
  width: 100%; margin-bottom: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); outline: none;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 13.5px; resize: vertical; outline: none; line-height: 1.55;
}
.contact-list { display: flex; flex-direction: column; gap: 2px; max-height: 52vh; overflow-y: auto; }
.contact-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 10px; border: none;
  background: transparent; text-align: left; width: 100%; color: var(--text);
}
.contact-item:hover { background: var(--surface-2); }
.ci-name { font-weight: 600; font-size: 13.5px; }
.ci-mail { font-size: 12px; color: var(--text-3); }

.media-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.media-tab {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px;
}
.media-tab:hover { background: var(--surface-2); }
.media-tab.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.media-group { margin-bottom: 20px; }
.media-group h4 {
  margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-3);
}
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.media-item {
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); text-decoration: none; color: var(--text); overflow: hidden;
}
.media-item:hover { border-color: var(--accent); }
.media-thumb {
  height: 86px; border-radius: 8px; background: var(--surface-3);
  display: grid; place-items: center; overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .ic { width: 28px; height: 28px; color: var(--text-3); }
.media-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta { font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-empty { padding: 30px 10px; text-align: center; color: var(--text-3); }

/* ═══ Kontakte / Medien / Signatur ═══ */
.modal-card.wide { max-width: 800px; }
.modal-input {
  width: 100%; margin-bottom: 12px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-2); color: var(--text); outline: none;
}
.modal-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.modal-textarea {
  width: 100%; padding: 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface-2); color: var(--text);
  font-family: inherit; font-size: 13.5px; resize: vertical; outline: none; line-height: 1.55;
}
.contact-list { display: flex; flex-direction: column; gap: 2px; max-height: 52vh; overflow-y: auto; }
.contact-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 10px; border-radius: 10px; border: none;
  background: transparent; text-align: left; width: 100%; color: var(--text);
}
.contact-item:hover { background: var(--surface-2); }
.ci-name { font-weight: 600; font-size: 13.5px; }
.ci-mail { font-size: 12px; color: var(--text-3); }

.media-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.media-tab {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  border-radius: 999px; padding: 5px 12px; font-size: 12.5px;
}
.media-tab:hover { background: var(--surface-2); }
.media-tab.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; font-weight: 600; }
.media-group { margin-bottom: 20px; }
.media-group h4 {
  margin: 0 0 8px; font-size: 11.5px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-3);
}
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.media-item {
  display: flex; flex-direction: column; gap: 6px; padding: 10px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); text-decoration: none; color: var(--text); overflow: hidden;
}
.media-item:hover { border-color: var(--accent); }
.media-thumb {
  height: 86px; border-radius: 8px; background: var(--surface-3);
  display: grid; place-items: center; overflow: hidden;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.media-thumb .ic { width: 28px; height: 28px; color: var(--text-3); }
.media-name { font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-meta { font-size: 10.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-empty { padding: 30px 10px; text-align: center; color: var(--text-3); }

/* ═══ Tooltip ═══ */
[data-tip] { position: relative; }
[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%);
  background: var(--surface-3); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  padding: 4px 8px; font-size: 11px; white-space: nowrap;
  z-index: 90; pointer-events: none; box-shadow: var(--shadow);
}

/* ═══ Mobil ═══ */
@media (max-width: 1140px) { .list-pane { width: 360px; } }

@media (max-width: 880px) {
  .menu-btn { display: grid; }
  .brand-text { display: none; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 272px; z-index: 50;
    transform: translateX(-100%); transition: transform .22s ease;
    box-shadow: var(--shadow); padding-top: 70px; background: var(--surface);
  }
  .sidebar.open { transform: translateX(0); }
  .list-pane { width: 100%; border-right: none; }
  .read-pane {
    position: fixed; inset: 0; z-index: 45;
    transform: translateX(100%); transition: transform .22s ease;
  }
  .read-pane.open { transform: translateX(0); }
  .read-scroll { padding: 16px 16px 70px; }
  .read-subject { font-size: 18px; }
  .compose {
    right: 0; left: 0; width: 100%; max-width: 100%;
    height: 100dvh; max-height: 100dvh; border-radius: 0; border: none;
  }
  .compose-head { border-radius: 0; }
  [data-tip]:hover::after { display: none; }
}

@media (min-width: 881px) {
  .menu-btn { display: none; }
  #btnBack { display: none; }
}

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ═══════════════════════════════════════════════════════════════
   Schmale Smartphones (<= 560px) — Kopfleiste, Toolbars, Safe-Area
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 560px) {
  .topbar { padding: 6px 8px; gap: 6px; }
  .topbar .brand { padding: 2px; }
  .search { height: 40px; padding: 0 10px; gap: 8px; min-width: 0; }
  .search-wrap { min-width: 0; }
  .search-drop { left: -6px; right: -6px; }
  .search input { min-width: 0; font-size: 15px; }
  .search input::-webkit-search-cancel-button { display: none; }
  .topbar-right { gap: 0; }
  .topbar-right .icon-btn { width: 34px; height: 34px; }
  .topbar-right .icon-btn .ic { width: 18px; height: 18px; }
  #btnShortcuts { display: none; }
  .live-dot { margin-right: 2px; }
  .avatar { width: 32px; height: 32px; font-size: 12px; }

  .list-head { padding: 9px 12px; }
  .msg { padding: 11px 12px; }
  .msg-from, .msg-subject { font-size: 14px; }

  /* Werkzeugleisten duerfen seitlich scrollen statt zu druecken */
  .read-toolbar,
  .compose-toolbar { overflow-x: auto; scrollbar-width: none; padding: 6px 8px; }
  .read-toolbar::-webkit-scrollbar,
  .compose-toolbar::-webkit-scrollbar { display: none; }
  .read-toolbar > *,
  .compose-toolbar > * { flex: 0 0 auto; }

  .read-subject { font-size: 17px; }
  .account-menu { right: -6px; min-width: 210px; }
}

/* iPhone-Notch: nichts unter der Home-Leiste verstecken */
.sidebar { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
.list-scroll { padding-bottom: env(safe-area-inset-bottom); }
.read-scroll { padding-bottom: calc(70px + env(safe-area-inset-bottom)); }
.compose-foot { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }

/* ═══ Sidebar auf Mobile: Abdunkelung + Kopfzeile mit Schliessen ═══ */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
  background: rgba(10, 15, 22, .45);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
.sidebar-head { display: none; }

@media (max-width: 880px) {
  .sidebar { padding-top: 12px; }
  .sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 6px 8px;
  }
  .sidebar-title {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--text-3);
  }
  .sidebar-head .icon-btn { width: 36px; height: 36px; }
  body.sidebar-open { overscroll-behavior: none; }
}
/* â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•
   Feinschliff: Startbildschirm, Lade-Skelette, ÃœbergÃ¤nge
   â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â•â• */

/* â•â•â• Startbildschirm â•â•â• */
.boot {
  position: fixed; inset: 0; z-index: 900;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg);
}
.boot-logo {
  width: 58px; height: 58px; border-radius: 18px;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  animation: bootPulse 1.8s ease-in-out infinite;
}
.boot-name { font-weight: 600; letter-spacing: .02em; color: var(--text-2); font-size: 14px; }
.boot-bar { width: 168px; height: 4px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.boot-bar span {
  display: block; width: 42%; height: 100%; border-radius: 999px;
  background: var(--accent); animation: bootSlide 1.25s ease-in-out infinite;
}
@keyframes bootPulse { 0%,100% { transform: scale(1); opacity: .92 } 50% { transform: scale(1.07); opacity: 1 } }
@keyframes bootSlide { 0% { transform: translateX(-110%) } 100% { transform: translateX(300%) } }

/* â•â•â• Skelette â•â•â• */
@keyframes skPulse { 0%,100% { opacity: .55 } 50% { opacity: 1 } }

.sk-row { display: flex; gap: 12px; align-items: center; padding: 10px 14px; }
.sk-av {
  width: 42px; height: 42px; border-radius: 50%; flex: 0 0 auto;
  background: var(--surface-2); animation: skPulse 1.15s ease-in-out infinite;
}
.sk-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.sk-line { height: 11px; border-radius: 6px; background: var(--surface-2); animation: skPulse 1.15s ease-in-out infinite; }
.sk-line.w1 { width: 42%; }
.sk-line.w2 { width: 78%; animation-delay: .12s; }
.sk-folder { height: 34px; margin: 6px 12px; border-radius: 10px; background: var(--surface-2); animation: skPulse 1.15s ease-in-out infinite; }
.sk-folder:nth-child(2) { width: 80%; }
.sk-folder:nth-child(3) { width: 66%; animation-delay: .1s; }

.sk-thread { display: flex; flex-direction: column; gap: 12px; max-width: 760px; margin: 0 auto; padding: 10px 0; }
.sk-day {
  width: 84px; height: 22px; border-radius: 999px; margin: 10px auto;
  background: var(--surface-2); animation: skPulse 1.15s ease-in-out infinite;
}
.sk-bubble {
  height: 84px; width: 62%; border-radius: 16px;
  background: var(--surface-2); animation: skPulse 1.15s ease-in-out infinite;
}
.sk-bubble.short { height: 56px; width: 46%; }
.sk-bubble.own { margin-left: auto; width: 58%; background: var(--accent-soft); animation-delay: .12s; }

/* â•â•â• Feine ÃœbergÃ¤nge â•â•â• */
.btn-primary, .btn-ghost, .icon-btn, .chat-send, .ci, .sd-item, .sr-item, .folder, .label-row {
  transition: background .15s ease, color .15s ease, border-color .15s ease,
              transform .08s ease, filter .15s ease, opacity .15s ease;
}
.btn-primary:active, .btn-ghost:active, .icon-btn:active, .chat-send:active { transform: scale(.97); }

:where(button, a, input, textarea, select, [tabindex]):focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
:where(input, textarea, select):focus-visible { outline: none; }

.modal:not([hidden]) { animation: fadeIn .14s ease-out; }
.modal:not([hidden]) .modal-card { animation: popIn .18s ease-out; }
@keyframes fadeIn { from { opacity: 0 } to { opacity: 1 } }
@keyframes popIn { from { opacity: 0; transform: translateY(10px) scale(.985) } to { opacity: 1; transform: none } }

.toast:not([hidden]) {
  display: flex; align-items: center; gap: 4px;
  animation: toastIn .18s ease-out;
}
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 12px) }
  to { opacity: 1; transform: translate(-50%, 0) }
}

/* Dezentere Scrollbalken */
* { scrollbar-width: thin; scrollbar-color: var(--surface-3) transparent; }

/* Weniger Bewegung, wenn das System es verlangt */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}


/* ═══ Feinschliff 2 ═══ */
.login-card { animation: popIn .22s ease-out; }
::selection { background: var(--accent-soft); }

/* Betreff bleibt beim Scrollen oben stehen */
.read-subject {
  position: sticky; top: 0; z-index: 6;
  margin: 0; padding: 6px 0 9px;
  background: var(--surface);
  backdrop-filter: blur(6px);
}

/* Knopf mit Dreher */
.spin {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid currentColor; border-top-color: transparent;
  display: inline-block; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══ Newsletter abbestellen ═══ */
.unsub-bar {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 6px 10px; margin-bottom: 10px;
  background: var(--surface-2); font-size: 12.5px; color: var(--text-2);
  width: fit-content;
}
.unsub-txt { font-weight: 600; }
.unsub-btn { padding: 5px 10px; font-size: 12px; }
.unsub-done { color: var(--text-3); border-color: transparent; background: transparent; }

/* ═══ Wichtig-Marker und Label-Punkte ═══ */
.ci.important { box-shadow: inset 3px 0 0 var(--star); }
.ci-imp {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--star); flex: 0 0 auto; margin-left: 2px;
}
.ci-dots { display: flex; gap: 3px; flex: 0 0 auto; }
.ci-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

/* ═══ Leere Zustände einheitlich ═══ */
.chat-empty, .appt-empty, .media-empty, .contact-empty, .mem-empty {
  text-align: center; color: var(--text-3); padding: 26px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.chat-empty .ic, .appt-empty .ic { opacity: .35; }
.chat-empty p, .appt-empty p { margin: 0; font-size: 13px; }
.chat-empty .sub { font-size: 12px; color: var(--text-3); }

/* ═══ Dunkelmodus: Kontrast nachziehen ═══ */
[data-theme="dark"] .invite-banner {
  background: color-mix(in srgb, var(--accent) 16%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
[data-theme="dark"] .ci.unread .ci-time { color: var(--accent); }
[data-theme="dark"] .ci-badge { color: #0b1220; }
[data-theme="dark"] .rule-item { border-color: var(--border); background: var(--surface-2); }
[data-theme="dark"] .unsub-bar { background: var(--surface-2); color: var(--text-2); }
[data-theme="dark"] .chat-row.own .chat-bubble { background: color-mix(in srgb, var(--accent) 58%, #000); }
[data-theme="dark"] .chat-bubble.rich,
[data-theme="dark"] .chat-row.own .chat-bubble.rich { background: var(--surface-2); }

/* ═══ Mobile: grössere Tippflächen ═══ */
@media (max-width: 560px) {
  .topbar-right .icon-btn { width: 40px; height: 40px; }
  .ci { padding: 11px 12px; }
  .ci-av { width: 44px; height: 44px; }
  .chat-bubble { max-width: 100%; }
  .chat-row.other { padding-left: 0; }
  .chat-av { position: static; margin-right: 6px; }
}

/* ═══ Mobile: Aktionsliste statt Icon-Reihe ═══ */
.tb-more { display: none; }
.sheet { position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.38); display: flex; align-items: flex-end; }
.sheet-card {
  width: 100%; background: var(--surface); border-radius: 18px 18px 0 0;
  padding: 8px 10px calc(12px + env(safe-area-inset-bottom));
  animation: sheetUp .2s ease-out; box-shadow: 0 -8px 30px rgba(0,0,0,.25);
}
@keyframes sheetUp { from { transform: translateY(100%) } to { transform: none } }
.sheet-grip { width: 40px; height: 4px; border-radius: 999px; background: var(--surface-3); margin: 6px auto 10px; }
.sheet-title { font-size: 12px; color: var(--text-3); text-align: center; margin-bottom: 4px; }
.sheet-list { display: flex; flex-direction: column; }
.sheet-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 13px 12px; border: none; border-radius: 12px;
  background: transparent; color: var(--text); font-size: 14.5px; text-align: left;
}
.sheet-item:hover, .sheet-item:active { background: var(--surface-2); }
.sheet-item .ic { width: 18px; height: 18px; color: var(--text-2); }
.sheet-cancel {
  width: 100%; margin-top: 6px; padding: 13px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-weight: 600;
}

@media (max-width: 700px) {
  .read-toolbar .icon-btn { display: none; }
  .read-toolbar .icon-btn.tb-keep, .read-toolbar .tb-more { display: grid; }
  .read-toolbar { padding: 4px 8px; gap: 2px; }
  .read-subject { font-size: 17px; line-height: 1.32; padding: 8px 0; }
  .read-scroll { padding: 12px 12px 96px; }
  .chat-bar { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); gap: 6px; }
  .chat-bubble { border-radius: 14px; padding: 10px 12px 8px; }
  .tmsg-to { display: none; }
  .tmsg-date { font-size: 11px; }
  .tmsg { padding-bottom: 12px; margin-bottom: 12px; }
  .list-head { padding: 8px 12px; }
}

@media (max-width: 420px) {
  .ci-preview { font-size: 12.5px; }
  .ci-name { font-size: 14px; }
  .read-scroll { padding: 10px 10px 96px; }
}

/* ═══════════════════════════════════════════════════════════════
   Touch: kein Doppeltipp-Zoom, keine grauen Blitze
   ═══════════════════════════════════════════════════════════════ */
button, a, .ci, .msg, .folder, .label-row, .attach, .sheet-item, .reply-tool {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ═══════════════════════════════════════════════════════════════
   Mobile 2.0: grössere Tippflächen, grössere Schrift, keine Ränder
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  html, body { font-size: 15px; }

  /* Kopfleiste */
  .topbar { padding: 6px 6px; gap: 4px; }
  .topbar-right .icon-btn { width: 44px; height: 44px; }
  .topbar-right .icon-btn .ic { width: 21px; height: 21px; }
  .avatar { width: 34px; height: 34px; font-size: 12.5px; }
  .search { height: 46px; padding: 0 12px; gap: 8px; }
  .search input { font-size: 16px; }

  /* Seitenleiste */
  .sidebar { width: 288px; }
  .folder, .label-row { padding: 13px 16px; font-size: 15px; min-height: 48px; }
  .folder .ic, .label-row .ic { width: 21px; height: 21px; }
  .labels-head { font-size: 12px; padding: 8px 16px; }
  .compose-btn { min-height: 50px; font-size: 15px; }
  .sidebar-head .icon-btn { width: 44px; height: 44px; }

  /* Chat-Liste */
  .list-head { padding: 10px 14px; }
  .list-head h2 { font-size: 17px; }
  .ci { padding: 12px 14px; min-height: 68px; }
  .ci-av { width: 46px; height: 46px; font-size: 15px; }
  .ci-name { font-size: 15.5px; }
  .ci-preview { font-size: 14px; }
  .ci-time { font-size: 12.5px; }
  .ci-badge { min-width: 22px; height: 22px; font-size: 12.5px; }
  .ci-star { width: 36px; height: 36px; right: 4px; bottom: 2px; }
  .ci-star .ic { width: 17px; height: 17px; }
  .msg { padding: 13px 14px; min-height: 72px; }
  .msg-from, .msg-subject { font-size: 15px; }
  .msg-date { font-size: 12.5px; }
  .load-more { padding: 14px; font-size: 14.5px; }

  /* Lesen */
  .read-toolbar { padding: 4px 6px; gap: 0; }
  .read-toolbar .icon-btn { width: 46px; height: 46px; }
  .read-toolbar .icon-btn .ic { width: 22px; height: 22px; }
  .read-subject { font-size: 19px; line-height: 1.3; padding: 8px 0 4px; }
  .thread-note { font-size: 13px; }
  .avatar.small { width: 44px; height: 44px; font-size: 16px; }
  .tmsg-from { font-size: 15.5px; }
  .tmsg-date { font-size: 12.5px; }
  .read-content { font-size: 16px; line-height: 1.65; }
  .chat-bubble.rich .read-content { font-size: 15.5px; }
  .chat-bubble { font-size: 15px; }
  .chat-time { font-size: 11.5px; }
  .images-banner { font-size: 13.5px; padding: 12px 14px; }
  .images-banner button { padding: 10px 14px; font-size: 14px; }
  .attach { padding: 12px 14px; font-size: 14px; }
  .tmsg-toggle { padding: 10px 14px; font-size: 13.5px; }
  .quoted-toggle { height: 28px; padding: 0 12px; font-size: 12.5px; }

  /* Verfassen */
  .compose-head { padding: 12px 12px; font-size: 15px; }
  .compose-head .icon-btn { width: 44px; height: 44px; }
  .field > span { width: 52px; font-size: 13px; }
  .field input { padding: 14px 8px; font-size: 16px; }
  .compose textarea { font-size: 16px; }
  .compose-toolbar .icon-btn { width: 44px; height: 44px; }
  .compose-toolbar .icon-btn .ic { width: 21px; height: 21px; }
  .compose-foot .btn-primary { min-height: 48px; }

  /* Dialoge */
  .sheet-card { padding: 8px 8px calc(12px + env(safe-area-inset-bottom)); }
  .sheet-item { padding: 15px 14px; font-size: 15.5px; }
  .sheet-item .ic { width: 21px; height: 21px; }
  .sheet-cancel { padding: 15px; font-size: 15px; }
  .modal-card, .card { max-width: 100%; }
  .mem-box { font-size: 13.5px; }
  .chat-input { font-size: 16px; padding: 12px 14px; }
  .chat-chip, .chat-act { font-size: 13px; padding: 8px 13px; }
}

/* Sehr schmale Geräte (iPhone SE) */
@media (max-width: 380px) {
  .read-toolbar .icon-btn { width: 44px; height: 44px; }
  .chat-bubble { font-size: 14.5px; }
}

/* ═══ Emoji im Betreff und Bild-Freigabe ═══ */
.subj-emoji { font-size: .82em; vertical-align: baseline; }
.images-banner { flex-wrap: wrap; }
.img-always {
  border: none; background: transparent; color: var(--text-3);
  font-size: 12px; text-decoration: underline; padding: 4px 6px;
}
.img-always:hover { color: var(--accent); }

/* ═══ Antwortfeld wie in Gmail ═══ */
.chat-bar { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
.reply-shell {
  width: 100%; max-width: 900px; margin: 0 auto;
  border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); box-shadow: 0 1px 3px rgba(60,64,67,.08);
  padding: 10px 12px 8px;
  transition: box-shadow .15s, border-color .15s;
}
.reply-shell:focus-within { box-shadow: 0 4px 16px rgba(60,64,67,.14); border-color: var(--accent); }
.reply-head { font-size: 12.5px; color: var(--text-3); margin-bottom: 4px; }
.reply-shell textarea,
.reply-body {
  width: 100%; border: none; background: transparent; color: var(--text);
  outline: none; resize: none; padding: 4px 2px; min-height: 28px; max-height: 200px;
  line-height: 1.45; overflow-y: auto; word-wrap: break-word;
}
.reply-body:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3); pointer-events: none;
}
.reply-body p { margin: 0 0 6px; }
.reply-body p:last-child { margin-bottom: 0; }
.reply-tools { display: flex; align-items: center; gap: 4px; }
.reply-foot { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.reply-tool {
  border: 1px solid var(--border); background: transparent; color: var(--text-2);
  border-radius: 8px; padding: 5px 10px; font-size: 12.5px;
}
.reply-tool:hover { background: var(--surface-2); color: var(--text); }
.reply-grow { flex: 1 1 auto; }
.chat-bar .chat-send { width: 36px; height: 36px; }

/* ═══════════════════════════════════════════════════════════════
   Antwortfeld: Werkzeugleiste bricht um statt seitlich auszureissen
   (muss nach dem Gmail-Block oben stehen, sonst gewinnt der alte Wert)
   ═══════════════════════════════════════════════════════════════ */
.reply-shell { min-width: 0; }
.reply-body { font-size: 14.5px; }
.reply-foot { flex-wrap: wrap; row-gap: 6px; }
.reply-tools {
  flex: 1 1 auto; min-width: 0;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.reply-tools::-webkit-scrollbar { display: none; }
.reply-tools > * { flex: 0 0 auto; }
.reply-grow { display: none; }
#replyAttach { margin-left: auto; }
.chat-send { flex: 0 0 auto; }

/* Auf dem Desktop passt alles in eine Zeile, wenn wir etwas enger stapeln */
@media (min-width: 701px) {
  .reply-foot { gap: 6px; }
  .reply-tool { padding: 5px 8px; }
}

@media (max-width: 700px) {
  .chat-bar { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); }
  .reply-shell { border-radius: 16px; padding: 10px 10px 8px; }
  .reply-head { font-size: 13px; }
  .reply-body { font-size: 16px; min-height: 42px; padding: 6px 4px; }
  /* Werkzeuge eigene Zeile, darunter Anhang · Vollbild · Senden */
  .reply-tools { flex: 1 1 100%; gap: 6px; padding: 2px 0; }
  .reply-tool { min-height: 40px; padding: 8px 12px; font-size: 14px; border-radius: 10px; }
  #replyAttach { margin-left: 0; }
  #btnChatExpand { flex: 0 1 auto; max-width: 55%; }
  .chat-bar .chat-send { width: 48px; height: 48px; margin-left: auto; }
  .chat-bar .chat-send .ic { width: 22px; height: 22px; }
}

@media (max-width: 380px) {
  .reply-tool { padding: 8px 10px; font-size: 13.5px; }
  #btnChatExpand { max-width: 46%; font-size: 13px; }
}

/* Kopf auf dem Handy: die Suche hat Vorrang vor Aktualisieren */
@media (max-width: 560px) {
  #btnRefresh { display: none; }
}

/* ═══════════════════════════════════════════════════════════════
   App installieren (PWA)
   ═══════════════════════════════════════════════════════════════ */
.install-help { padding: 4px 14px 10px; color: var(--text-2); font-size: 13.5px; line-height: 1.6; }
.install-help ol { margin: 0 0 10px; padding-left: 20px; display: grid; gap: 8px; }
.install-help li b { color: var(--text); }
.install-help .hint { margin: 0; font-size: 12.5px; color: var(--text-3); line-height: 1.5; }

@media (max-width: 700px) {
  .install-help { font-size: 15px; }
  .install-help .hint { font-size: 13.5px; }
}

/* Installiert: keine Doppeltipp-Verzoegerung, kein Gummiband-Effekt */
html.standalone body { overscroll-behavior-y: none; }

/* ═══════════════════════════════════════════════════════════════
   Gemeinsamer Kopf: Marken-Icon + App-Umschalter (wie Google)
   ═══════════════════════════════════════════════════════════════ */
.brand { gap: 9px; }
.brand-mark { width: 28px; height: 28px; border-radius: 8px; display: block; flex: 0 0 auto; }
.apps { position: relative; display: flex; }
.apps-menu {
  position: absolute; right: 0; top: 46px; min-width: 212px; z-index: 70;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow); padding: 6px;
}
.apps-menu a {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px;
  border-radius: 10px; text-decoration: none; color: var(--text);
  font-size: 14px; font-weight: 500;
}
.apps-menu a:hover { background: var(--accent-soft); }
.apps-menu .ic { width: 20px; height: 20px; color: var(--text-2); }

@media (max-width: 560px) {
  .apps-menu { top: 44px; min-width: 196px; }
  .apps-menu a { padding: 13px 12px; font-size: 15px; }
}

/* ═══════════════════════════════════════════════════════════════
   Kopfleiste, Kontomenü und Trefferlisten auf Touch-Grösse
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  .menu-btn { width: 44px; height: 44px; flex: 0 0 auto; }
  .menu-btn .ic { width: 22px; height: 22px; }
  .avatar { width: 40px; height: 40px; font-size: 13px; }
  .search-clear { width: 34px; height: 34px; }
  .search-clear .ic { width: 17px; height: 17px; }
  .account-menu { min-width: 244px; padding: 6px; }
  .account-menu button { padding: 14px 12px; font-size: 15px; border-radius: 10px; }
  .account-menu button .ic { width: 19px; height: 19px; }
  .account-mail { font-size: 13px; padding: 10px 12px; }
  .sd-item { padding: 13px 10px; }
  .sd-text { font-size: 15px; }
  .sd-sub { font-size: 12.5px; }
  .sd-head { font-size: 12px; }
  .sr-item { padding: 12px 8px; }
  .sr-title { font-size: 15px; }
  .sr-snip { font-size: 13.5px; }
  .sr-ic { width: 34px; height: 34px; }
  .search-view { padding: 10px 10px 28px; }
  .tmsg-more, .chat-more { width: 38px; height: 38px; }

  /* Verfassen: Werkzeugleiste auf Fingergrösse */
  .cmp-body { font-size: 16px; padding: 14px 14px; }
  .cmp-tools { padding: 8px 8px; gap: 4px; }
  .cmp-tool { min-width: 40px; height: 40px; padding: 0 9px; font-size: 14px; border-radius: 9px; }
  .cmp-select { height: 40px; font-size: 14px; padding: 0 8px; }
  .cmp-color-wrap { width: 40px; height: 40px; }
  .cmp-sep { height: 26px; margin: 0 2px; }
  .cmp-html { font-size: 14px; }
  .compose-foot .icon-btn { width: 46px; height: 46px; }
  .compose-foot .icon-btn .ic { width: 21px; height: 21px; }
  .compose-foot .btn-ghost { min-height: 46px; font-size: 15px; }
}

/* Auf sehr schmalen Geräten weicht das Logo dem Suchfeld */
@media (max-width: 440px) {
  .brand { display: none; }
  .topbar { gap: 2px; }
}

/* === Cloud-Anhang-Picker (Dateien aus der eigenen Cloud) === */
.cloud-pick{position:fixed;inset:0;z-index:120;background:rgba(15,20,28,.45);display:flex;
align-items:center;justify-content:center;padding:16px}
.cp-card{background:var(--surface,#fff);border-radius:16px;box-shadow:0 20px 60px rgba(0,0,0,.32);
width:100%;max-width:460px;max-height:82vh;display:flex;flex-direction:column;overflow:hidden}
.cp-head{display:flex;align-items:center;justify-content:space-between;padding:14px 16px;
border-bottom:1px solid var(--line,#e3e6ea);font-weight:600;font-size:14.5px}
.cp-q{margin:12px 16px;padding:10px 12px;border:1px solid var(--line,#e3e6ea);border-radius:10px;
font:inherit;font-size:16px;background:transparent;color:inherit;outline:none}
.cp-q:focus{border-color:var(--accent,#1a73e8)}
.cp-list{overflow:auto;padding:0 8px 10px;display:grid;gap:4px;flex:1}
.cp-row{display:flex;align-items:center;gap:11px;width:100%;padding:10px 8px;border:none;
background:transparent;border-radius:10px;cursor:pointer;text-align:left;font:inherit;
color:inherit;min-height:54px}
.cp-row:hover{background:rgba(26,115,232,.1)}
.cp-mini{flex:0 0 auto;padding:6px 11px;border-radius:99px;border:1px solid var(--line,#e3e6ea);
background:transparent;color:var(--accent,#1a73e8);font:inherit;font-size:12px;font-weight:600;
cursor:pointer;min-height:32px}
.cp-mini:hover{background:rgba(26,115,232,.12);border-color:var(--accent,#1a73e8)}
.cp-mini:disabled{opacity:.5;cursor:default}
.cp-ico{width:34px;height:34px;border-radius:9px;background:rgba(26,115,232,.14);color:#1a73e8;
display:grid;place-items:center;font-size:9.5px;font-weight:800;flex:0 0 auto}
.cp-meta{min-width:0;display:block}
.cp-name{display:block;font-size:14px;font-weight:550;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.cp-sub{display:block;font-size:11.5px;color:var(--muted,#5f6368)}
.cp-empty{padding:26px 14px;text-align:center;color:var(--muted,#5f6368);font-size:13.5px;margin:0}
html[data-theme="dark"] .cp-card{background:#1a1e25}
@media (prefers-color-scheme:dark){.cp-card{background:#1a1e25}}


