/* ============================================================
   v5.22.30: Mail-Reiter in Lead- und Kundenakte (Gespraeche)
   ------------------------------------------------------------
   Geladen NACH style.css und posteingang.css. Liste, Lesebereich,
   Aktionsleiste und die weisse Leseflaeche kommen aus posteingang.css
   (pe-Klassen). Hier steht nur, was es dort nicht gibt. Praefix: am-.
   Farben ausschliesslich aus vorhandenen Tokens und den pe-Werten.
   ============================================================ */
:root {
    --am-topbar-unten: 72px;      /* Kopfleiste: 16 px Abstand + 56 px Hoehe */
}
.am-flex { flex: 1 1 auto; min-width: 0; }

/* Der Mail-Bereich ist so hoch wie das Fenster unter der Kopfleiste und
   bleibt dort stehen, waehrend die rechte Spalte daneben weiterscrollt. */
.am-tab { min-width: 0; }
.am-arbeitsflaeche {
    container: amf / inline-size;
    position: sticky; top: calc(var(--am-topbar-unten) + 12px);
    height: calc(100vh - var(--am-topbar-unten) - 28px);
    height: calc(100dvh - var(--am-topbar-unten) - 28px);
    min-height: 420px;
}

/* Breit genug (Liste 320 + Trenner 7 + Verlauf 560 = 887 Pixel):
   Gespraechsliste und Verlauf stehen nebeneinander. */
.am-frame.pe-frame {
    height: 100%;
    grid-template-columns: var(--am-w-liste) 7px minmax(560px, 1fr);
    --am-w-liste: 320px;
}
.am-frame > .pe-list { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; min-height: 0; }
.am-frame > .pe-resizer { grid-column: 2; grid-row: 1; cursor: default; }
.am-frame > .pe-read { grid-column: 3; grid-row: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.am-frame .pe-list__body { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.am-frame .pe-read__scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.am-listekopf { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-bottom: 1px solid var(--color-border); }
/* Sechs Pillen passen nicht in eine Zeile der Liste: sie brechen um */
.am-listekopf > * { min-width: 0; max-width: 100%; }
.am-listekopf .pe-chips { flex-wrap: wrap; overflow: visible; }
@container amf (min-width: 1000px) { .am-frame.pe-frame { --am-w-liste: 360px; } }
@container amf (min-width: 1200px) { .am-frame.pe-frame { --am-w-liste: 400px; } }
@container amf (min-width: 1400px) { .am-frame.pe-frame { --am-w-liste: 440px; } }
.am-zurueck { display: none; }
/* Schmaler: nur die Gespraechsliste. Ein Klick oeffnet den Verlauf an
   derselben Stelle, oben steht "Zurueck zur Liste". */
@container amf (max-width: 886px) {
    .am-frame.pe-frame { grid-template-columns: minmax(0, 1fr); }
    .am-frame > .pe-list, .am-frame > .pe-read { grid-column: 1; }
    .am-frame > .pe-resizer,
    .am-frame:not(.is-detail) > .pe-read,
    .am-frame.is-detail > .pe-list { display: none; }
    .am-zurueck {
        display: flex; align-items: center; gap: 10px;
        flex: 0 0 auto; min-width: 0;
        padding: 8px 12px;
        border-bottom: 1px solid var(--color-border);
    }
    .am-zurueck__betreff { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); color: var(--color-text-tertiary); }
}

/* Gespraechszeile */
/* Im Posteingang weicht der Avatar beim Ueberfahren der Auswahl-Checkbox.
   Die Akte hat keine Mehrfachauswahl: der Avatar bleibt stehen. */
.pe-item.am-g:hover .pe-avatar { opacity: 1; }
.am-g .pe-item__name { color: var(--color-text-primary); font-weight: 600; }
.am-g:not(.is-unread) .pe-item__name { font-weight: 500; }
.am-g__wer { color: var(--color-text-tertiary) !important; flex: 1 1 auto !important; }
.am-g .pe-item__row--co { min-height: 22px; }
.am-seit { font-size: var(--text-xs); color: var(--color-text-tertiary); white-space: nowrap; }
.am-anzahl {
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 0 1px var(--color-border-strong);
    color: var(--color-text-secondary);
    font-size: var(--text-2xs); font-weight: 700; line-height: 18px; text-align: center;
}
.pe-item.is-open .am-anzahl { background: rgba(79, 126, 219, 0.30); color: var(--color-text-primary); }
.am-av-seq { color: var(--color-brand-light); background: rgba(79, 126, 219, 0.14); box-shadow: inset 0 0 0 1px rgba(79, 126, 219, 0.32); }
.am-ordnerchip {
    display: inline-flex; align-items: center; gap: 5px;
    min-width: 0; max-width: 150px;
    font-size: var(--text-xs); color: var(--color-text-tertiary);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.am-ordnerchip svg { flex: 0 0 auto; }
/* Im Verlaufskopf ist die Ordner-Marke der Knopf zum Verschieben */
.am-ordnerchip--knopf { padding: 2px 8px; border: 1px solid var(--color-border-strong); border-radius: 999px; background: transparent; font: inherit; font-size: var(--text-xs); cursor: pointer; }
.am-ordnerchip--knopf:hover { color: var(--color-text-primary); background: rgba(255, 255, 255, 0.05); }
.am-ordnerchip--knopf:focus-visible { outline: 2px solid var(--color-brand-light); outline-offset: 2px; }
.am-ordnerchip--knopf span { overflow: hidden; text-overflow: ellipsis; }
.am-team { display: inline-flex; flex: 0 0 auto; gap: 3px; }
.am-seqtrenner { margin: 14px 10px 4px; color: var(--color-text-muted); }
.am-seqtrenner .pe-newsep__line { background: var(--color-border-strong); }
.am-leerliste { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 40px 16px; text-align: center; color: var(--color-text-tertiary); font-size: var(--text-sm); }

/* Listenkopf: Ordner-Knopf und Team-Filter */
.am-ordnerknopf { flex: 0 1 auto; min-width: 0; max-width: 46%; }
.am-ordnerknopf .pulse-action-button__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.am-ordnerknopf.is-gesetzt { border-color: rgba(79, 126, 219, 0.55); color: var(--color-text-primary); }
.am-teamfilter { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.am-teamfilter__label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-muted); margin-right: 2px; }
.am-teamknopf {
    display: inline-flex; align-items: center; gap: 6px;
    height: 28px; padding: 0 10px 0 3px;
    border-radius: 999px;
    border: 1px solid var(--color-border-strong);
    background: transparent; color: var(--color-text-secondary);
    font: inherit; font-size: var(--text-xs); font-weight: 500;
    cursor: pointer;
}
.am-teamknopf--alle { padding: 0 10px; }
.am-teamknopf:hover { background: rgba(255, 255, 255, 0.05); color: var(--color-text-primary); }
.am-teamknopf.is-active { background: rgba(79, 126, 219, 0.16); border-color: rgba(79, 126, 219, 0.55); color: var(--color-text-primary); }
.am-teamknopf:focus-visible { outline: 2px solid var(--color-brand-light); outline-offset: 2px; }
.am-teamknopf:disabled { opacity: 0.4; cursor: default; }
@container plist (max-width: 369px) {
    .am-teamknopf:not(.am-teamknopf--alle) span:last-child { display: none; }
    .am-teamknopf:not(.am-teamknopf--alle) { padding: 0 3px; }
}

/* Ordner-Menue */
.am-ordnermenu { min-width: 280px !important; }
.am-ordnerzeile { display: flex; align-items: center; }
.am-ordnerzeile .kebab-menu-item { flex: 1 1 auto; min-width: 0; }
.am-ordnerzeile__knopf {
    flex: 0 0 auto; width: 28px; height: 28px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 0; border-radius: 6px; background: transparent;
    color: var(--color-text-muted); cursor: pointer;
}
.am-ordnerzeile__knopf:hover { background: rgba(255, 255, 255, 0.08); color: var(--color-text-primary); }
.am-ordnerzeile__knopf:focus-visible { outline: 2px solid var(--color-brand-light); outline-offset: -2px; }

/* Verlauf: dieselbe weisse Leseflaeche wie im Posteingang, aber nie
   breiter als gut lesbar. */
.am-papier { max-width: 880px; }
.pe-mailhead__tags { align-items: center; }
.am-hinweis { margin: 0; padding: 12px var(--pe-edge) 0; font-size: var(--text-2xs); color: var(--pe-ink-soft); overflow-wrap: anywhere; }
.am-hinweis + .pe-msg { padding-top: 8px; }
.pe-msgx > .pe-msg { padding-left: 0; padding-right: 0; }
.pe-msgx > .am-hinweis { padding: 4px 0 0; }
.am-msgc__anh { flex: 0 0 auto; display: inline-flex; color: var(--pe-ink-soft); }
.am-laedt { padding: 12px 4px; font-size: var(--text-sm); color: var(--pe-ink-soft); }

/* Kleiner Dialog (Ordner anlegen, umbenennen) */
.am-fenster { width: min(460px, calc(100vw - 32px)); padding: 0; border: 0; background: transparent; color: inherit; }
.am-fenster::backdrop { background: rgba(0, 0, 0, 0.55); }
.am-fenster__karte { display: flex; flex-direction: column; padding: 0 !important; overflow: hidden; background: rgba(20, 20, 28, 0.97) !important; }
.am-fenster__kopf { flex: 0 0 auto; padding: 14px 20px 8px; }
.am-fenster__kopf h2 { margin: 0; font-size: var(--text-md); font-weight: 600; color: var(--color-text-primary); }
.am-fenster__inhalt { padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 8px; }
.am-fenster__inhalt label { font-size: var(--text-xs); font-weight: 600; color: var(--color-text-secondary); }
.am-fenster__inhalt input { width: 100%; }
.am-fenster__fehler { font-size: var(--text-xs); color: var(--status-danger-icon, #f87171); min-height: 16px; }
.am-fenster__fuss { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--color-border-strong); }
.am-vorschlaege { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; font-size: var(--text-xs); color: var(--color-text-tertiary); }
.am-vorschlaege > div { display: flex; flex-wrap: wrap; gap: 6px; }

/* Rechte Spalte der Akte einklappbar. Ausgeklappt ist sie unveraendert,
   nur der kleine Knopf steht ueber den Karten. Eingeklappt bleibt ein
   schmaler Streifen mit dem Knopf. Unter 1101 Pixel Fensterbreite stapelt
   Pulse die Spalte ohnehin unter den Inhalt. */
.am-spaltekopf { display: flex; justify-content: flex-end; margin-bottom: -6px; }
.am-spalteknopf {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--color-border); border-radius: 8px;
    background: transparent; color: var(--color-text-tertiary);
    cursor: pointer;
}
.am-spalteknopf:hover { background: rgba(255, 255, 255, 0.06); color: var(--color-text-primary); }
.am-spalteknopf:focus-visible { outline: 2px solid var(--color-brand-light); outline-offset: 2px; }
@media (min-width: 1101px) {
    .lead-detail__body.am-spalte-zu { grid-template-columns: minmax(0, 1fr) 44px; }
    .am-spalte-zu > .lead-detail__sidebar {
        position: sticky; top: calc(var(--am-topbar-unten) + 12px);
        align-self: start;
        height: calc(100vh - var(--am-topbar-unten) - 28px);
        height: calc(100dvh - var(--am-topbar-unten) - 28px);
        min-height: 420px;
        padding: 8px 0;
        align-items: center;
        border: 1px solid var(--color-border-glass); border-radius: 14px;
        background: rgba(255, 255, 255, 0.03);
    }
    .am-spalte-zu .am-spaltekopf { margin: 0; }
    .am-spalte-zu > .lead-detail__sidebar > :not(.am-spaltekopf) { display: none !important; }
}
@media (max-width: 1100px) { .am-spaltekopf { display: none; } }

/* Hell-Theme: Liste und Knoepfe liegen auf heller Flaeche */
:root[data-theme="light"] .am-anzahl { background: rgba(15, 23, 42, 0.06); }
:root[data-theme="light"] .am-teamknopf:hover,
:root[data-theme="light"] .am-ordnerchip--knopf:hover,
:root[data-theme="light"] .am-spalteknopf:hover { background: rgba(15, 23, 42, 0.05); }
:root[data-theme="light"] .am-fenster__karte { background: #ffffff !important; }

/* v5.22.31: eingebettete Antwort unter dem Verlauf. Die Ablage haelt ein
   angefangenes Verfassen, solange ein anderes Gespraech gezeigt wird. */
.am-ablage { display: none !important; }
.am-papier .pe-quick.is-hidden { display: none; }
.am-antwort:empty { display: none; }
