/* Posteingang — Look nach DispoConnect (ui_styles.py)
   Kopf #1E1F5B · Akzent Türkis #008BA3 · Segoe UI 14px · Radien 6/8/10
   Nutzt die Tokens aus styles.css (--navy, --accent, --border, --muted, --danger). */

.pe-wrap { display: flex; flex-direction: column; height: calc(100vh - 64px); }

.pe-kopf { display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #fff; border-bottom: 1px solid var(--border); }
.pe-titel { font-weight: 700; font-size: 15px; color: var(--navy); }
.pe-pf { min-width: 230px; padding: 6px 8px; border: 1px solid var(--border-input); border-radius: 6px;
  font: inherit; background: #fff; }
.pe-suche { flex: 1; max-width: 460px; padding: 6px 10px; border: 1px solid var(--border-input);
  border-radius: 6px; font: inherit; }

.pe-tools { display: flex; align-items: center; gap: 3px; padding: 6px 14px;
  background: #F7F8FA; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.pe-tbtn { padding: 5px 9px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; font-size: 15px; line-height: 1; cursor: pointer; }
.pe-tbtn:hover { background: var(--chip-bg); border-color: var(--chip-rand); }
.pe-tsep { width: 1px; height: 20px; background: var(--border); margin: 0 5px; }
.pe-filter { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.pe-vorschau-wahl { padding: 4px 6px; border: 1px solid var(--border-input); border-radius: 6px;
  font-size: 12px; background: #fff; }

/* Drei Bereiche; Breiten/Hoehe kommen als CSS-Variablen aus dem localStorage */
.pe-split { flex: 1; display: flex; min-height: 0; background: var(--bg); }
.pe-split.zieht { user-select: none; cursor: col-resize; }
.pe-baum { width: var(--pe-baum, 260px); flex: 0 0 auto; overflow: auto;
  background: #fff; padding: 6px 0; }
.pe-mitte { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.pe-split.pe-rechts .pe-mitte { flex-direction: row; }
.pe-split.pe-rechts .pe-liste { width: var(--pe-tab, 470px); flex: 0 0 auto; }
.pe-split:not(.pe-rechts) .pe-liste { height: var(--pe-hoehe, 300px); flex: 0 0 auto; }
.pe-liste { overflow: auto; background: #fff; display: flex; flex-direction: column; min-width: 0; }
.pe-detail { flex: 1; overflow: auto; background: #fff; min-width: 0; min-height: 0;
  border-top: 1px solid var(--border); display: flex; flex-direction: column; }
.pe-split.pe-rechts .pe-detail { border-top: none; border-left: 1px solid var(--border); }

.pe-griff { width: 6px; cursor: col-resize; background: var(--bg); flex: 0 0 auto; }
.pe-griff:hover { background: var(--accent); }
.pe-griff-v { height: 6px; cursor: row-resize; background: var(--bg); flex: 0 0 auto; }
.pe-griff-v:hover { background: var(--accent); }

/* ---- Ordnerbaum ---- */
.pe-baum-zeile { display: flex; align-items: center; gap: 5px; padding: 4px 8px;
  cursor: pointer; font-size: 13px; border-left: 3px solid transparent; }
.pe-baum-zeile:hover { background: #F2F4F8; }
.pe-baum-zeile.on { background: var(--chip-bg); border-left-color: var(--accent); font-weight: 600; }
.pe-baum-zeile.ungelesen .pe-baum-name { font-weight: 700; }
/* Eigene Ordnerfarbe: Balken links + eingefaerbter Name. Die aktive Auswahl
   (.on) gewinnt bewusst, sonst sieht man nicht mehr, wo man steht. */
.pe-baum-zeile.farbig { border-left-color: var(--o-farbe); }
.pe-baum-zeile.farbig .pe-baum-name { color: var(--o-farbe); font-weight: 600; }
.pe-baum-zeile.farbig.on { border-left-color: var(--accent); }
.pe-baum-zeile.zieht { opacity: .45; }
/* Zwei Wirkungen an derselben Geste, deshalb zwei klar verschiedene Marken:
   eine LINIE zwischen den Zeilen heisst sortieren (nur unsere Ansicht), ein
   umrandetes FELD heisst in diesen Ordner verschieben (wirkt in Exchange). */
.pe-baum-zeile.drop-vor { box-shadow: inset 0 2px 0 var(--accent); }
.pe-baum-zeile.drop-nach { box-shadow: inset 0 -2px 0 var(--accent); }
.pe-baum-zeile.drop-hinein { background: var(--chip-bg);
  outline: 2px dashed var(--danger); outline-offset: -2px; }
.pe-baum-pfeil { width: 12px; color: var(--muted); font-size: 10px; text-align: center; }
.pe-baum-icon { font-size: 13px; }
.pe-baum-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-baum-zahl { font-size: 11px; color: #fff; background: var(--accent);
  border-radius: 999px; padding: 0 6px; font-weight: 700; }
.pe-baum-laedt, .pe-baum-fehler { padding: 10px 12px; font-size: 12px; color: var(--muted); }
.pe-baum-fehler { color: var(--danger); }

.pe-gruppe { display: flex; align-items: center; gap: 6px; padding: 7px 8px 4px;
  margin-top: 6px; font-size: 11px; font-weight: 800; letter-spacing: .04em;
  text-transform: uppercase; color: var(--g-farbe, var(--navy)); cursor: pointer;
  border-top: 1px solid var(--border); }
.pe-gruppe:hover { background: #F2F4F8; }
.pe-gruppe.drop { background: var(--chip-bg); box-shadow: inset 0 2px 0 var(--accent); }
/* Gruppen lassen sich ziehen (ordnet die Abschnitte). Dieselbe Marke wie im
   Baum: eine LINIE heisst einordnen, ein Feld heisst aufnehmen. */
.pe-gruppe.zieht { opacity: .45; }
.pe-gruppe.drop-vor { box-shadow: inset 0 2px 0 var(--accent); }
.pe-gruppe.drop-nach { box-shadow: inset 0 -2px 0 var(--accent); }
.pe-gruppe-pfeil { font-size: 9px; }
.pe-gruppe-name { flex: 1; }
.pe-gruppe-zahl { color: var(--muted); font-weight: 600; }
/* Ordner aus einer tieferen Ebene, hier nur verknuepft: der Pfeil und die
   schwaechere Schrift sagen, dass der Ordner woanders im Baum wirklich liegt. */
.pe-baum-zeile.pe-gruppe-zeile .pe-baum-pfeil { color: var(--accent); font-size: 11px; }
.pe-baum-zeile.pe-gruppe-zeile.fehlt { color: var(--muted); cursor: help; }
.pe-baum-zeile.pe-gruppe-zeile.fehlt .pe-baum-name { text-decoration: line-through; }
.pe-gruppe-weg { font-size: 10px; color: var(--danger); font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em; }
.pe-gruppe-neu { padding: 8px 12px; font-size: 12px; color: var(--muted); cursor: pointer; }
.pe-gruppe-neu:hover { color: var(--accent); }

/* ---- Ordner umbauen ---- */
/* Umbenennen an Ort und Stelle: das Feld sitzt genau dort, wo der Name stand */
.pe-baum-inp { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 1px 5px;
  border: 1px solid var(--accent); border-radius: 4px; background: #fff; outline: none; }
.pe-baum-zeile.umbenennt { background: var(--chip-bg); cursor: default; }

.pe-baum-neu { padding: 10px 12px 2px; font-size: 12px; color: var(--muted); cursor: pointer; }
.pe-baum-neu:hover { color: var(--accent); }
.pe-baum-fremd { margin: 10px 8px 4px; padding: 7px 9px; font-size: 11.5px; line-height: 1.45;
  color: var(--text); background: var(--bg); border: 1px solid var(--border);
  border-left: 3px solid var(--muted); border-radius: 6px; }

/* Schwebender Hinweis am Zeiger: sagt WAEHREND des Ziehens, was passieren wird.
   Rot bei der Wirkung, die bis in Outlook durchschlaegt. */
.pe-zieh-hinweis { position: fixed; z-index: 10000; pointer-events: none;
  background: var(--navy); color: #fff; font-size: 11.5px; font-weight: 600;
  padding: 4px 9px; border-radius: 6px; max-width: 250px;
  box-shadow: 0 3px 10px rgba(16, 24, 64, .3); }
.pe-zieh-hinweis.server { background: var(--danger); }

.pe-ctx-hinweis { padding: 5px 12px; max-width: 250px; font-size: 11.5px;
  line-height: 1.4; color: var(--muted); }

.pe-loesch-hart { margin-top: 16px; padding: 10px 12px; background: var(--bg);
  border: 1px solid var(--border); border-left: 3px solid var(--danger); border-radius: 6px; }
.pe-loesch-hart-titel { font-size: 12px; font-weight: 700; color: var(--danger); }
.pe-fehlertext { white-space: pre-wrap; user-select: text; font-size: 13px; line-height: 1.5; }

/* ---- Mailliste ---- */
.pe-kopfzeile { display: flex; position: sticky; top: 0; z-index: 2;
  background: var(--navy); color: #fff; font-size: 12px; font-weight: 600; }
.pe-th { padding: 7px 8px; cursor: pointer; overflow: hidden; white-space: nowrap; }
.pe-th:hover, .pe-th.sortiert { background: var(--navy-hover); }
.pe-rows { flex: 1; }
.pe-row { display: flex; align-items: center; font-size: 13px; cursor: pointer;
  border-bottom: 1px solid var(--grid); box-shadow: inset 3px 0 0 transparent; }
.pe-row:hover { background: #F2F4F8; }
.pe-row.on { background: var(--chip-bg); }
.pe-row.markiert { background: var(--gelb-bg); }
.pe-row.ungelesen { font-weight: 700; box-shadow: inset 3px 0 0 var(--danger); }
.pe-c { padding: 6px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-betreff { display: flex; align-items: center; gap: 6px; }
.pe-wichtig { color: var(--danger); }
.pe-buendel { border: 1px solid var(--chip-rand); background: var(--chip-bg); color: var(--chip-text);
  border-radius: 999px; padding: 0 7px; font: inherit; font-size: 11px; font-weight: 700;
  cursor: pointer; flex: 0 0 auto; }
.pe-buendel:hover { background: #C7EAF0; }
.pe-row.kind { background: #FAFBFC; }
.pe-row.kind .pe-betreff { padding-left: 18px; }
/* ---- Nachverfolgung, Suchtreffer, Kategorie-Farben ---- */
.pe-fahne { cursor: pointer; text-align: center; opacity: .35; }
.pe-fahne:hover { opacity: 1; }
.pe-fahne.an { opacity: 1; }
.pe-ordnerspalte { color: var(--muted); font-size: 11px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
/* Farbe als Rand und Schrift, nicht als Flaeche: bei acht Kategorien in einer
   Zeile waere die Liste sonst ein Farbkasten und der Betreff verschwindet. */
.pe-kat.farbig { border-color: var(--k-farbe); color: var(--k-farbe); background: #fff; }

.pe-suche-modal .pe-suche-gitter { display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px; margin: 8px 0; }
.pe-suche-stand { font-size: 12px; margin: 4px 0; }
.pe-suche-treffer { max-height: 46vh; overflow: auto; border: 1px solid var(--border);
  border-radius: 6px; }
.pe-suche-treffer:empty { display: none; }
.pe-suche-hinweis { padding: 5px 8px; font-size: 11px; color: var(--muted);
  background: var(--bg); border-bottom: 1px solid var(--border); }
.pe-suche-zeile { display: flex; gap: 8px; align-items: center; padding: 5px 8px;
  font-size: 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.pe-suche-zeile:hover { background: #F2F4F8; }
.pe-suche-datum { width: 118px; color: var(--muted); flex: 0 0 auto; }
.pe-suche-von { width: 150px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 0 0 auto; }
.pe-suche-betreff { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-suche-ordner { color: var(--muted); font-size: 11px; flex: 0 0 auto; max-width: 160px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pe-oof-zeit { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0; }

.pe-kat-verw { max-height: 40vh; overflow: auto; border: 1px solid var(--border);
  border-radius: 6px; }
.pe-kat-zeile { display: flex; gap: 8px; align-items: center; padding: 5px 8px;
  border-bottom: 1px solid var(--border); font-size: 13px; }
.pe-kat-zeile input[type="color"] { width: 34px; height: 24px; padding: 0; border: none;
  background: none; cursor: pointer; }

.pe-kat { font-size: 10px; background: var(--chip-bg); color: var(--chip-text); border: 1px solid var(--chip-rand);
  border-radius: 8px; padding: 0 6px; font-weight: 600; }
.pe-pager { display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 8px; font-size: 12px; border-top: 1px solid var(--border); }
.pe-leer, .pe-leer-klein { text-align: center; color: var(--muted); padding: 40px 20px; }
.pe-leer-klein { padding: 24px 12px; font-size: 13px; }

/* ---- Leseansicht ---- */
.pe-detail-kopf { padding: 12px 14px 8px; border-bottom: 1px solid var(--border); flex: 0 0 auto; }
.pe-detail-betreff { font-size: 15px; font-weight: 700; color: var(--navy);
  user-select: text; margin-bottom: 4px; }
.pe-detail-meta { font-size: 12px; color: var(--muted); user-select: text; }
.pe-aktionen { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 14px; flex: 0 0 auto;
  border-bottom: 1px solid var(--border); background: #F7F8FA; }
.pe-body-frame { width: 100%; flex: 1; min-height: 260px; border: 0; background: #fff; }
.pe-body-text { padding: 12px 14px; white-space: pre-wrap; font-size: 14px;
  line-height: 1.5; user-select: text; flex: 1; }
.pe-bildwarnung { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 0 0 auto;
  padding: 7px 14px; background: var(--gelb-bg); border-bottom: 1px solid var(--prio-mittel); font-size: 12px; }

.pe-anh-wrap { padding: 10px 14px 16px; border-top: 1px solid var(--border); flex: 0 0 auto; }
.pe-anh-titel { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.pe-anh { display: flex; flex-wrap: wrap; gap: 6px; }
.pe-chip { display: inline-flex; align-items: center; gap: 6px; max-width: 320px;
  padding: 5px 10px; border: 1px solid var(--chip-rand); border-radius: 8px; background: var(--chip-bg);
  font: inherit; font-size: 12px; color: var(--chip-text); cursor: pointer; }
.pe-chip:hover { background: #C7EAF0; }
.pe-chip-sym { font-size: 14px; }
.pe-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-chip-gr { color: var(--muted); font-size: 11px; }

/* ---- Kontextmenue (hell erzwungen, wie in DispoConnect) ---- */
.pe-ctx { position: fixed; z-index: 9999; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-lift); padding: 4px; min-width: 200px; font-size: 13px; }
.pe-ctx-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px;
  border-radius: 6px; cursor: pointer; position: relative; white-space: nowrap; }
.pe-ctx-item:hover { background: var(--chip-bg); }
.pe-ctx-item.gefahr { color: var(--danger); }
.pe-ctx-item.gefahr:hover { background: #FDECEE; }
.pe-ctx-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.pe-ctx-punkt { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.pe-ctx-pfeil { margin-left: auto; color: var(--muted); }
.pe-ctx-fly { display: none; position: absolute; left: 100%; top: -4px; background: #fff;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lift);
  padding: 4px; min-width: 180px; max-height: 60vh; overflow: auto; }
.pe-ctx-sub:hover > .pe-ctx-fly { display: block; }

.pe-verschieb { max-height: 320px; overflow: auto; border: 1px solid var(--border);
  border-radius: 8px; margin-top: 8px; }
.pe-verschieb-pfad { font-size: 12px; color: var(--muted); margin-top: 6px; }
.pe-verschieb-zeile { display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  cursor: pointer; font-size: 13px; border-bottom: 1px solid var(--grid); }
.pe-verschieb-zeile:hover { background: #F2F4F8; }
.pe-textarea { width: 100%; font: inherit; resize: vertical; }
.pe-anh-leiste { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.pe-chip-weg { border: 0; background: transparent; color: var(--muted); cursor: pointer;
  font-size: 12px; padding: 0 2px; }
.pe-chip-weg:hover { color: var(--danger); }
.modal.dropbereit { outline: 3px dashed var(--accent); outline-offset: -6px; }

/* ---- Empfaenger-Vervollstaendigung ---- */
.adr-liste { position: fixed; z-index: 10000; background: #fff; border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow-lift); max-height: 260px; overflow: auto;
  font-size: 13px; }
.adr-eintrag { display: flex; align-items: center; gap: 8px; padding: 6px 10px; cursor: pointer; }
.adr-eintrag.an, .adr-eintrag:hover { background: var(--chip-bg); }
.adr-name { flex: 0 1 auto; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.adr-mail { flex: 1; color: var(--muted); font-size: 12px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.adr-quelle { flex: 0 0 auto; font-size: 12px; opacity: .75; }
.pe-check { display: flex; align-items: center; gap: 6px; font-size: 13px; margin-top: 6px; }

/* ═══════════════════════════════════════════════════════════════
   Seitenpanel im Board + Mail-Drag&Drop auf Spalten/Karten
   ═══════════════════════════════════════════════════════════════ */
.bm-buehne { display: flex; min-height: 0; flex: 1; }
.bm-buehne > #view { flex: 1; min-width: 0; }

/* Schiebe-Panel: Board und Postfach liegen nebeneinander, dazwischen wird
   geschoben. `gleitet` animiert den Einrast-Vorgang, `zieht` schaltet die
   Animation ab, solange der Finger die Breite direkt führt — sonst hinkt das
   Panel sichtbar hinterher. */
/* Fensterhohe, mitlaufende Seitenspalte statt auf die (oft sehr hohe) Board-Höhe
   gestreckt: `align-self:flex-start` nimmt die Streckung heraus, `sticky` hält das
   Panel beim Scrollen im Blick, die feste Höhe begrenzt die Spalte — erst dadurch
   scrollt die Mailliste intern und die Vorschau sitzt am unteren sichtbaren Rand
   statt tief unter dem Board. 113px = Höhe von Topbar + Board-Werkzeugleiste,
   dieselbe Konstante wie bei `#view` (styles.css). */
.bm-panel { position: sticky; top: 113px; align-self: flex-start;
  height: calc(100vh - 113px); flex: 0 0 auto; display: flex; overflow: hidden;
  /* z-index ÜBER dem Dialog-Overlay (50): bei offenem Kartenfenster soll die
     Mailleiste greifbar bleiben, damit man eine Mail auf den Verlauf ziehen kann.
     Das Panel steht rechts, das (zentrierte) Kartenfenster überlappt es auf
     breitem Schirm nicht — der Verlauf bleibt als Drop-Ziel frei. */
  z-index: 55;
  background: #fff; border-left: 1px solid var(--border); box-shadow: -2px 0 8px rgba(16,24,64,.06); }
.bm-panel.gleitet { transition: width .24s cubic-bezier(.22,.61,.36,1); }
.bm-panel.zieht { transition: none; user-select: none; }
/* Wohin es beim Loslassen einrastet, schon während des Ziehens zeigen */
.bm-panel.fast-ganz { box-shadow: -2px 0 0 2px var(--primary), -8px 0 22px rgba(16,24,64,.14); }
.bm-panel.fast-zu { opacity: .55; }

.bm-griff { width: 8px; cursor: col-resize; flex: 0 0 auto; position: relative;
  background: transparent; touch-action: none; }
.bm-griff::before { content: ""; position: absolute; top: 50%; left: 50%;
  width: 3px; height: 34px; margin: -17px 0 0 -1.5px; border-radius: 2px;
  background: var(--border); transition: background .15s; }
.bm-griff:hover::before, .bm-panel.zieht .bm-griff::before { background: var(--primary); }
/* Auf dem Touchscreen ist ein 8-px-Griff nicht zu treffen — Fangfläche verbreitern */
@media (pointer: coarse) {
  .bm-griff { width: 8px; }
  .bm-griff::after { content: ""; position: absolute; top: 0; bottom: 0; left: -12px; right: -12px; }
}

.bm-inhalt { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.bm-kopf { display: flex; align-items: center; gap: 6px; padding: 7px 10px;
  background: var(--navy); color: #fff; }
.bm-titel { flex: 1; font-weight: 700; font-size: 13px; }

/* Reiter Posteingang / Gesendet */
.bm-reiter { flex: 1; display: flex; gap: 3px; min-width: 0; }
.bm-reiter-knopf { flex: 1; padding: 5px 8px; font: inherit; font-size: 12px;
  color: rgba(255,255,255,.72); background: rgba(255,255,255,.10); border: 0;
  border-radius: 6px; cursor: pointer; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; transition: background .15s, color .15s; }
.bm-reiter-knopf:hover { background: rgba(255,255,255,.20); color: #fff; }
.bm-reiter-knopf.aktiv { background: #fff; color: var(--navy); font-weight: 700; }
.bm-kopf .btn { background: rgba(255,255,255,.14); color: #fff; border-color: transparent; }
.bm-kopf .btn:hover { background: rgba(255,255,255,.26); }
.bm-hinweis { padding: 7px 10px; font-size: 11px; color: var(--muted);
  background: #F7F8FA; border-bottom: 1px solid var(--border); }
.bm-liste { flex: 1; overflow: auto; padding: 6px; }
.bm-laedt { padding: 14px 10px; font-size: 12px; color: var(--muted); }
.bm-pf { width: 100%; padding: 5px 7px; margin-bottom: 6px; font: inherit; font-size: 12px;
  border: 1px solid var(--border-input); border-radius: 6px; background: #fff; }

.bm-mail { padding: 7px 9px; margin-bottom: 4px; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; cursor: grab; font-size: 12px;
  box-shadow: inset 3px 0 0 transparent; }
.bm-mail:hover { background: #F2F4F8; border-color: var(--chip-rand); }
.bm-mail:active { cursor: grabbing; }
.bm-mail.ungelesen { box-shadow: inset 3px 0 0 var(--danger); font-weight: 600; }
.bm-mail.zieht { opacity: .4; }
.bm-mail-kopf { display: flex; align-items: center; gap: 5px; color: var(--muted); font-size: 11px; }
.bm-mail-von { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-mail-datum { flex: 0 0 auto; }
.bm-mail-betreff { margin-top: 2px; overflow: hidden; text-overflow: ellipsis;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

/* Ordnerwahl (auch Unterordner) — Aufklapp-Menü unter den Reitern */
.bm-ordnermenue { display: none; }
.bm-ordnermenue.offen { display: block; background: #fff; max-height: 45%; overflow: auto;
  border-bottom: 1px solid var(--border); box-shadow: inset 0 -6px 8px -8px rgba(16,24,64,.25); }
.bm-om-krume { display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 6px 8px; font-size: 11px; background: #F7F8FA; border-bottom: 1px solid var(--border); }
.bm-om-krume-teil { border: 0; background: transparent; color: var(--primary); cursor: pointer;
  font: inherit; padding: 1px 4px; border-radius: 4px; }
.bm-om-krume-teil:hover { background: rgba(16,24,64,.08); }
.bm-om-pfeil { color: var(--muted); }
.bm-om-zeile { display: flex; align-items: center; border-bottom: 1px solid #F0F2F5; }
.bm-om-zeile.aktiv { background: #EAF4F6; }
.bm-om-name { flex: 1; display: flex; align-items: center; gap: 6px; text-align: left;
  border: 0; background: transparent; cursor: pointer; font: inherit; font-size: 12px;
  padding: 7px 9px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-om-name:hover { background: #F2F4F8; }
.bm-om-zahl { flex: 0 0 auto; background: var(--danger); color: #fff; border-radius: 9px;
  font-size: 10px; padding: 0 6px; }
.bm-om-tiefer { flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  font-size: 15px; color: var(--muted); padding: 6px 10px; }
.bm-om-tiefer:hover { color: var(--navy); background: #F2F4F8; }
.bm-om-leer, .bm-om-laedt { padding: 9px 10px; font-size: 12px; color: var(--muted); }

/* Vorschau: Leseausschnitt unter der Mailliste. Bleibt IMMER im Panel — deckt
   nie das Board ab. „offen" = normale Höhe, „gross" = füllt das Panel (Liste
   tritt zurück), sonst nur die Kopfleiste (zugeklappt). */
.bm-vorschau { flex: 0 0 auto; display: flex; flex-direction: column; min-height: 0;
  background: #fff; border-top: 2px solid var(--border); }
.bm-vorschau.offen { flex: 0 0 var(--bm-vh, 46%); min-height: 90px; }
/* Griff zum Ziehen der Vorschauhöhe (nur im aufgeklappten Zustand) */
.bm-vorschau-griff { flex: 0 0 auto; height: 7px; cursor: row-resize; position: relative; background: transparent; }
.bm-vorschau-griff::before { content: ""; position: absolute; left: 50%; top: 2px;
  width: 34px; height: 3px; margin-left: -17px; border-radius: 2px; background: var(--border); }
.bm-vorschau-griff:hover::before { background: var(--primary); }
.bm-vorschau:not(.offen) .bm-vorschau-griff { display: none; }
.bm-vorschau-kopf { flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  padding: 5px 8px; background: #EEF1F6; border-bottom: 1px solid var(--border); }
.bm-vorschau-betreff { flex: 1; font-size: 12px; font-weight: 700; color: var(--navy);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bm-vorschau-btn { flex: 0 0 auto; border: 0; background: transparent; cursor: pointer;
  font-size: 13px; line-height: 1; color: var(--muted); padding: 3px 6px; border-radius: 5px; }
.bm-vorschau-btn:hover { background: rgba(16,24,64,.08); color: var(--navy); }
.bm-vorschau-koerper { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.bm-vorschau:not(.offen) .bm-vorschau-koerper { display: none; }
.bm-vorschau-meta { flex: 0 0 auto; padding: 6px 10px; font-size: 11px; color: var(--muted);
  border-bottom: 1px solid var(--border); }
.bm-vorschau-frame { flex: 1 1 auto; min-height: 0; width: 100%; border: 0; background: #fff; }
.bm-vorschau-text { flex: 1 1 auto; min-height: 0; overflow: auto; padding: 8px 10px;
  font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.bm-vorschau-anh { flex: 0 0 auto; padding: 5px 10px; font-size: 11px; color: var(--muted);
  border-top: 1px solid var(--border); }

/* Anhang-Chips in Vorschau und „Ganz öffnen"-Fenster */
.bm-anh-wrap { flex: 0 0 auto; border-top: 1px solid var(--border); padding: 6px 10px; background: #fff; }
.bm-anh-titel { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.bm-anh-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.bm-anh-chip { display: inline-flex; align-items: center; gap: 5px; max-width: 100%;
  border: 1px solid var(--border-input); background: #fff; border-radius: 8px;
  padding: 3px 8px; font: inherit; font-size: 12px; cursor: pointer; }
.bm-anh-chip:hover { background: #F2F4F8; border-color: var(--chip-rand); }
.bm-anh-sym { flex: 0 0 auto; }
.bm-anh-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.bm-anh-gr { color: var(--muted); font-size: 11px; flex: 0 0 auto; }
.bm-anh-chip.hat-vorschau { border-style: solid; }

/* Mini-Vorschau beim Drüberfahren über einen Anhang. pointer-events:none, damit
   das Popover den Hover nie selbst stiehlt. */
.bm-anh-pop { position: fixed; z-index: 80; display: none; pointer-events: none;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 40px rgba(16,24,64,.28); padding: 6px; }
.bm-anh-pop.offen { display: block; }
.bm-anh-pop-img { display: block; max-width: 320px; max-height: 60vh; border-radius: 6px; }
.bm-anh-pop-lad { padding: 22px 26px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.bm-vorschau-leer { padding: 12px 10px; font-size: 12px; color: var(--muted); }

/* „Ganz öffnen": Mail in voller Breite im Fenster — hier hat die breite Tabelle Platz */
.bm-modal-frame { width: 100%; height: 72vh; border: 1px solid var(--border);
  border-radius: 8px; background: #fff; }
.bm-modal-text { max-height: 72vh; overflow: auto; white-space: pre-wrap; word-break: break-word;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }

/* Zielordner-Wähler beim „Verschieben nach …" */
.pe-ziel-liste { max-height: 46vh; overflow: auto; border: 1px solid var(--border);
  border-radius: 8px; margin: 4px 0 2px; }
.pe-ziel-zeile { display: flex; align-items: center; gap: 6px; padding: 5px 8px;
  border-bottom: 1px solid #F0F2F5; font-size: 13px; }
.pe-ziel-zeile:last-child { border-bottom: 0; }
.pe-ziel-zeile.gesperrt { color: var(--muted); }
.pe-ziel-pfeil { flex: 0 0 16px; width: 16px; text-align: center; cursor: pointer; color: var(--muted); }
.pe-ziel-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pe-ziel-hier { flex: 0 0 auto; border: 1px solid var(--border-input); background: #fff;
  border-radius: 6px; padding: 2px 10px; font: inherit; font-size: 12px; cursor: pointer; color: var(--primary); }
.pe-ziel-hier:hover { background: var(--primary); color: #fff; border-color: var(--primary); }
.pe-ziel-hier.ist-hier { border: 0; background: transparent; color: var(--muted); cursor: default; }

/* Während eines Mail-Drags: Ziele sichtbar machen */
body.bm-zieht .column { outline: 2px dashed rgba(0,139,163,.35); outline-offset: -3px; }
body.bm-zieht .kcard { outline: 1px dashed rgba(0,139,163,.30); }
.column.mail-drop { outline: 3px solid var(--accent) !important; outline-offset: -3px;
  background: rgba(0,139,163,.07); }
.kcard.mail-drop { outline: 3px solid var(--accent) !important;
  box-shadow: 0 0 0 4px rgba(0,139,163,.18) !important; }
/* Verlauf im geöffneten Kartenfenster als Mail-Ablageziel */
body.bm-zieht .hist-panel { outline: 2px dashed var(--accent); outline-offset: -4px; }
.hist-panel.mail-drop { outline: 3px solid var(--accent) !important; outline-offset: -4px;
  background: rgba(0,139,163,.06); }
.hist-drophint { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 8px; }

/* ---- Verschiebe-Regeln ---- */
.mr-wrap { max-height: 65vh; overflow: auto; }
.mr-automatik { display: flex; align-items: center; gap: 10px; padding: 10px;
  background: #F7F8FA; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.mr-regel { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 8px; margin-bottom: 5px; background: #fff; }
.mr-regel-text { font-size: 13px; overflow: hidden; text-overflow: ellipsis; }
.mr-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
.mr-chip { padding: 4px 10px; border: 1px solid var(--chip-rand); border-radius: 999px;
  background: #fff; color: var(--chip-text); font: inherit; font-size: 12px; cursor: pointer; }
.mr-chip.an { background: var(--accent); color: #fff; border-color: var(--accent); }
.mr-wahl { display: flex; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; }
.mr-vorschau { max-height: 52vh; overflow: auto; border: 1px solid var(--border);
  border-radius: 8px; margin: 8px 0; }
.mr-v-zeile { display: flex; align-items: center; gap: 10px; padding: 6px 10px;
  font-size: 12px; border-bottom: 1px solid var(--grid); }
.mr-v-zeile.gut { background: #F1FAF3; }
.mr-v-zeile.zurueck { opacity: .5; text-decoration: line-through; }
.mr-v-betreff { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mr-v-ziel { flex: 0 0 auto; color: var(--accent); font-weight: 600; }

/* ═══════════════════════════════════════════════════════════════
   Verfassen: Signatur, Textbausteine, KI-Leiste (verfassen.js)
   ═══════════════════════════════════════════════════════════════ */

/* Der Verfassen-Dialog trägt jetzt drei Leisten und den KI-Vorschlag — ohne
   eigene Höhenbegrenzung wächst er unter dem Fensterrand hinaus. */
.modal.vf-modal { max-height: 92vh; overflow: auto; }

/* `.modal-foot` wird in allen Mail-Dialogen benutzt, war aber nie gestaltet —
   die Knöpfe klebten links unter dem letzten Feld. */
.modal-foot { display: flex; justify-content: flex-end; align-items: center;
  gap: 10px; margin-top: 18px; }

.vf-klein { font-size: 11px; }
.vf-rechts { margin-left: auto; }
.vf-warnung { color: var(--danger); }
/* `btn small gefahr` wird im Posteingang längst benutzt, war aber nie gestaltet */
.btn.gefahr { color: var(--danger); border-color: var(--danger); }
.btn.gefahr:hover { background: #FDECEE; }

/* Zusatzfenster über dem Verfassen-Dialog: eigene Ebene, damit der Dialog
   darunter sichtbar stehen bleibt und nicht doppelt abgedunkelt wirkt. */
.overlay.vf-ebene { background: rgba(16,18,40,.32); }

/* ---- Leiste über dem Schreibfeld ---- */
.vf-leiste { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 12px 0 4px; padding: 7px 9px; background: #F7F8FA;
  border: 1px solid var(--border); border-radius: 8px; }
.vf-leiste-titel { font-size: 12px; font-weight: 600; color: var(--muted); }
.vf-sig-wahl { flex: 0 1 240px; min-width: 150px; padding: 5px 7px; font: inherit;
  font-size: 12px; border: 1px solid var(--border-input); border-radius: 6px; background: #fff; }

/* Angebot zum Signaturwechsel — nie ein stiller Tausch, immer eine Frage */
.vf-wechsel { display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin: 6px 0; padding: 7px 10px; font-size: 12px;
  background: var(--gelb-bg); border: 1px solid var(--prio-mittel); border-radius: 8px; }

/* ---- Bausteinauswahl (schwebend, kein zweiter Dialog) ---- */
.vf-panel { position: fixed; z-index: 10001; width: 340px; background: #fff;
  border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lift);
  padding: 8px; display: flex; flex-direction: column; gap: 6px; }
.vf-panel-suche { width: 100%; padding: 6px 8px; font: inherit; font-size: 13px;
  border: 1px solid var(--border-input); border-radius: 6px; }
.vf-panel-liste { max-height: 320px; overflow: auto; }
.vf-panel-zeile { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
.vf-panel-zeile:hover { background: var(--chip-bg); }
.vf-panel-kopf { display: flex; align-items: center; gap: 6px; }
.vf-panel-name { font-size: 13px; font-weight: 600; }
.vf-panel-text { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-panel-leer { padding: 10px 8px; font-size: 12px; }
.vf-panel-fuss { display: flex; align-items: center; justify-content: space-between;
  gap: 8px; border-top: 1px solid var(--border); padding-top: 6px; }
.vf-kuerzel { font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 8px;
  background: var(--chip-bg); color: var(--chip-text); border: 1px solid var(--chip-rand); }

/* ---- KI-Leiste ---- */
.vf-ki { display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin: 8px 0; padding: 7px 9px; background: #F7F8FA;
  border: 1px solid var(--border); border-radius: 8px; }
.vf-ki-titel { font-size: 12px; font-weight: 700; color: var(--navy); letter-spacing: .04em; }
.vf-ki.aus { background: #F2F3F5; color: var(--muted); }
.vf-ki.aus .btn { opacity: .55; }
.vf-ki.laeuft .vf-ki-status { color: var(--accent); font-weight: 600; }
/* `.modal input` setzt width:100% und ist spezifischer als eine reine Klasse —
   deshalb hier mit .modal davor, sonst sprengt das Feld die Leiste. */
.modal .vf-ki-ziel { flex: 0 0 110px; width: 110px; padding: 4px 7px;
  font: inherit; font-size: 12px; border: 1px solid var(--border-input); border-radius: 6px; }
.vf-ki-status { margin-left: 4px; }

/* ---- KI-Vorschlag: erst ansehen, dann übernehmen ---- */
.vf-vorschlag { margin: 8px 0; padding: 10px; border: 1px solid var(--accent);
  border-radius: 10px; background: #F4FCFD; }
.vf-vorschlag-kopf { display: flex; align-items: center; gap: 4px; margin-bottom: 4px;
  font-size: 13px; color: var(--navy); }
.vf-vorschlag-text { width: 100%; font: inherit; resize: vertical; background: #fff; }
.vf-vorschlag-fuss { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ---- Verwaltung: Liste links, Formular rechts ---- */
.vf-reiter { display: flex; gap: 6px; margin: 10px 0; }
.vf-verw { display: flex; gap: 14px; align-items: flex-start; }
.vf-verw-liste { flex: 0 0 210px; max-height: 52vh; overflow: auto;
  border: 1px solid var(--border); border-radius: 8px; padding: 5px; }
.vf-verw-form { flex: 1; min-width: 0; max-height: 62vh; overflow: auto; }
.vf-verw-zeile { display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-radius: 6px; cursor: pointer; font-size: 13px; }
.vf-verw-zeile:hover { background: #F2F4F8; }
.vf-verw-zeile.on { background: var(--chip-bg); font-weight: 600; }
.vf-verw-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vf-verw-typ { font-size: 10px; color: var(--muted); }
.vf-vorgabe { font-size: 10px; font-weight: 700; color: #fff; background: var(--accent);
  border-radius: 8px; padding: 1px 6px; }
.vf-verw-neu { width: 100%; margin-top: 6px; }
.vf-verw-fuss { display: flex; align-items: center; gap: 8px; margin-top: 14px; }

@media (max-width: 900px) {
  .vf-verw { flex-direction: column; }
  .vf-verw-liste { flex: 0 0 auto; width: 100%; max-height: 30vh; }
}

@media (max-width: 1100px) {
  /* Schmaler Bildschirm: Panel als Überlagerung statt als Spalte — hier volle
     Fensterhöhe (überschreibt die feste Spaltenhöhe von oben). */
  .bm-panel { position: fixed; top: 0; right: 0; bottom: 0; height: 100vh; z-index: 60;
    box-shadow: -6px 0 22px rgba(16,24,64,.22); }
}

@media (max-width: 900px) {
  .pe-baum { display: none; }
  .pe-griff { display: none; }
  .pe-split:not(.pe-rechts) .pe-liste { height: 45vh; }
  .pe-split.pe-rechts { flex-direction: column; }
  .pe-split.pe-rechts .pe-mitte { flex-direction: column; }
  .pe-split.pe-rechts .pe-liste { width: auto; height: 45vh; }
}

/* ---- Mails in Ordner ziehen + erkannter Zielordner ---- */
.pe-row[draggable="true"] { cursor: grab; }
.pe-row.zieht { opacity: .45; }
/* Waehrend Mails gezogen werden, treten die Ordner hervor — man sieht auf einen
   Blick, wo man sie ueberhaupt fallen lassen kann. */
body.pe-mail-zieht .pe-baum-zeile { outline: 1px dashed var(--border); outline-offset: -1px; }
body.pe-mail-zieht .pe-baum-zeile.drop-hinein { outline: 2px solid var(--accent);
  background: var(--chip-bg); }
/* Der von der Adresserkennung vorgeschlagene Ordner leuchtet beim Anheben auf. */
.pe-baum-zeile.vorschlag { background: var(--gelb-bg, #FFF7E6);
  box-shadow: inset 3px 0 0 var(--warn, #F4A300); }
.pe-vorschlag { margin-left: 6px; font-size: 10px; padding: 1px 7px; border-radius: 999px;
  border: 1px dashed var(--accent); background: #fff; color: var(--accent);
  cursor: pointer; font-family: inherit; white-space: nowrap; }
.pe-vorschlag:hover { background: var(--accent); color: #fff; border-style: solid; }
/* Verwalter am Vorschlag: gedaempft und kleiner — der Ordnername fuehrt, der
   Verwalter beantwortet nur die Frage "bei wem liegt das Objekt?". */
.pe-vorschlag-verw { margin-left: 5px; padding-left: 5px; border-left: 1px solid currentColor;
  opacity: .7; font-size: 9.5px; }
.pe-vorschlag.mehrdeutig { border-color: var(--muted); color: var(--muted); }
.pe-vorschlag.mehrdeutig:hover { background: var(--muted); color: #fff; }
/* Unsicher = Strasse erkannt, Hausnummer stand nicht im Betreff. Als Frage
   zeigen, nicht als Ansage — und deutlich blasser als ein sicherer Treffer. */
.pe-vorschlag.unsicher { border-color: var(--muted); color: var(--muted); font-style: italic; }
.pe-vorschlag.unsicher:hover { background: var(--muted); color: #fff; font-style: normal; }

/* ---- Spaltenbreiten ziehen ---- */
.pe-sp-griff { width: 5px; flex: 0 0 auto; cursor: col-resize; align-self: stretch; }
.pe-kopfzeile .pe-sp-griff:hover { background: var(--accent); }
body.pe-sp-zieht { cursor: col-resize; user-select: none; }
/* Der Zielordner steht in einer EIGENEN Spalte — hinter dem Betreff wurde er bei
   langen Betreffzeilen von overflow:hidden verschluckt. */
.pe-vorschlag-zelle { display: flex; align-items: center; justify-content: flex-end;
  overflow: visible; }
.pe-vorschlag-fehler { padding: 6px 10px; font-size: 11.5px; color: var(--danger);
  background: var(--gelb-bg, #FFF7E6); border-top: 1px solid var(--border); }

/* Angehaengte MAIL: eigenes Zeichen genuegt nicht, wenn zwanzig Chips
   nebeneinander stehen — deshalb auch eigene Farbe und Randfarbe. */
.pe-chip.mail { border-color: var(--accent); background: var(--chip-bg); }
.pe-chip.mail .pe-chip-sym { color: var(--accent); font-size: 15px; }
.pe-chip.mail .pe-chip-name { font-weight: 600; }

/* ---- Zielordner-Diagnose + Ordnersuche beim Verschieben ---- */
.pe-vorschlag-stand { padding: 5px 10px; font-size: 11px; color: var(--muted);
  background: var(--bg); border-top: 1px solid var(--border); }
.pe-erk-liste { margin: 4px 0 10px; padding-left: 18px; font-size: 12.5px; line-height: 1.6; }
.pe-verschieb-treffer { max-height: 42vh; overflow: auto; }
.pe-verschieb-treffer:empty { display: none; }

/* ───────────────────────────── Besprechungsanfragen
   Eine Einladung ist keine gewöhnliche Mail — sie hebt sich deshalb sichtbar ab
   und trägt ihre Antwortknöpfe direkt bei sich, nicht in der allgemeinen
   Aktionsleiste (dort wären sie bei jeder Mail zu sehen). */
.pe-einladung {
  margin: 8px 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-left: 4px solid #1E1F5B;
  border-radius: 8px;
  background: var(--panel, rgba(30, 31, 91, .04));
}
.pe-einladung.abgesagt { border-left-color: #B03030; }
.pe-einl-kopf { font-weight: 600; margin-bottom: 6px; }
.pe-einl-zeile { font-size: 13px; line-height: 1.6; }
.pe-einl-knoepfe { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.pe-einl-marke { margin-right: 4px; opacity: .85; }

/* Der Zielordner-Chip IST ein Knopf — das sieht man ihm aber nicht an. Der
   Zusatz in der Spaltenüberschrift sagt es einmal, statt es im Tooltip zu
   verstecken (den sieht nur, wer mit der Maus stehen bleibt). */
.pe-th-hinweis { display: block; font-weight: 400; font-size: 9.5px;
  color: var(--muted); line-height: 1.2; }
