/* ================= Textvorlagen (Runde 2e, Punkt P, VORLAGEN): Einstellungen, Reiter „Textvorlagen“ (.vl2-) =================
   Nur Tokens aus styles.css, hell und dunkel über die Tokens. iPersonal Rot nur über die bestehenden Knöpfe und den Fokus,
   ungespeicherte Änderungen mit warn-Tokens (neutral für beide Abteilungen). Bausteine wiederverwendet: .fchip, .seg, .btn, .mail-preview. */

.vl2-head { margin-bottom: 10px; }
.vl2-head .btn .vl2-n { font-variant-numeric: tabular-nums; }

/* ---------- Werkzeugzeile: Suche und «Alle zuklappen» (Runde 2o: statt Sprungmarken) ---------- */
.vl2-werkzeug { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin: 0 0 6px; min-width: 0; }
.vl2-werkzeug .spacer { flex: 1; }
.vl2-suche { flex: 1 1 260px; max-width: 420px; position: relative; display: flex; flex-direction: row; align-items: center; margin: 0; min-width: 0; }
.vl2-suche svg.i { position: absolute; left: 11px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
.vl2-suche input { width: 100%; height: 38px; padding-left: 34px; }
.vl2-werkzeug .btn[hidden] { display: none; }
.vl2-regel { margin: 4px 0 6px; }

/* ---------- Runde 2o: Gruppen als aufklappbare Zeilen, je Vorlage eine Zeile mit aufklappbarem Bearbeitungsteil ---------- */
.vl2-g-inhalt[hidden], .vl2-koerper[hidden], .vl2-z-standard[hidden] { display: none !important; }
.vl2-gruppen { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.vl2-gruppe { margin: 0; min-width: 0; }
.vl2-g-h { margin: 0; font: inherit; }
.vl2-g-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; width: 100%; min-height: 56px; padding: 10px 16px; border-radius: 14px;
  background: var(--flaeche-2); border: 1px solid var(--line); color: var(--text); font: inherit; text-align: left; cursor: pointer; transition: border-color .15s; }
.vl2-g-kopf:hover { border-color: var(--line-strong); }
.vl2-g-kopf:focus-visible { outline: 2px solid var(--fokus); outline-offset: 2px; }
.vl2-g-kopf[aria-expanded="true"] { border-color: var(--line-strong); }
.vl2-g-name { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.vl2-g-zahlen { display: inline-flex; flex-wrap: wrap; align-items: center; font-size: 13.5px; color: var(--muted); }
.vl2-g-zahlen > span:not(:first-child):not(:empty)::before { content: "·"; margin: 0 7px; color: var(--muted-2); }
.vl2-g-angepasst { color: var(--info-tx); font-weight: 650; }
.vl2-g-offen { color: var(--warn-tx); font-weight: 650; }
.vl2-pfeil { flex: none; width: 8px; height: 8px; margin: 0 4px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform .15s; }
.vl2-g-kopf[aria-expanded="true"] > .vl2-pfeil, .vl2-zeile[aria-expanded="true"] > .vl2-pfeil { transform: rotate(45deg); }
.vl2-g-inhalt { padding: 8px 0 6px 10px; }
.vl2-g-hinweis { margin: 0 4px 10px; }
.vl2-karten { display: flex; flex-direction: column; gap: 8px; }

.vl2-karte { display: flex; flex-direction: column; min-width: 0; border-radius: 14px;
  background: var(--flaeche-2); border: 1px solid var(--line); box-shadow: inset 3px 0 0 transparent; transition: border-color .15s, box-shadow .15s; }
.vl2-karte:focus-within, .vl2-karte.vl2-auf { border-color: var(--line-strong); }
.vl2-karte.vl2-offen { border-color: var(--warn-ln); box-shadow: inset 3px 0 0 var(--warn-tx); }

.vl2-zeile-h { margin: 0; font: inherit; }
.vl2-zeile { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 3px 10px; width: 100%; min-height: 52px; padding: 11px 16px; border: 0; border-radius: 14px;
  background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.vl2-z-haupt { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; min-width: 0; }
.vl2-zeile:hover { background: var(--hover); }
.vl2-zeile:focus-visible { outline: 2px solid var(--fokus); outline-offset: -2px; }
.vl2-z-titel { font-size: 15.5px; font-weight: 700; letter-spacing: -.01em; min-width: 0; overflow-wrap: anywhere; }
.vl2-z-stand { display: inline-flex; align-items: center; gap: 6px; }
.vl2-z-standard { font-size: 13px; color: var(--muted); }
.vl2-z-hinweis { grid-column: 1 / 3; min-width: 0; font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vl2-karte.vl2-auf .vl2-z-hinweis { display: none; }
.vl2-koerper { display: flex; flex-direction: column; gap: 10px; width: 100%; max-width: 980px; padding: 0 16px 14px; min-width: 0; }
/* Oben im Bearbeitungsteil: Stand und die Knöpfe Frühere Fassungen und Auf Standard zurücksetzen (immer bedienbar, keine Gefahrenfarbe) */
.vl2-aktionen { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px; padding: 9px 12px; border-radius: 12px;
  background: var(--flaeche); border: 1px solid var(--line); }
.vl2-stand { margin: 0; display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; color: var(--text); min-width: 0; }
.vl2-stand svg.i { width: 15px; height: 15px; color: var(--ok-tx); flex: none; }
.vl2-aktionen-knoepfe { display: flex; flex-wrap: wrap; gap: 8px; }
.vl2-aktionen-knoepfe .btn svg.i { width: 15px; height: 15px; }
.vl2-etiketten { display: inline-flex; flex-wrap: wrap; gap: 5px; }
.vl2-et { display: inline-flex; align-items: center; height: 21px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
  color: var(--neu-tx); background: var(--neu-bg); border: 1px solid var(--neu-ln); }
.vl2-et[hidden] { display: none; }
.vl2-et-angepasst { color: var(--info-tx); background: var(--info-bg); border-color: var(--info-ln); }
.vl2-et-offen { color: var(--warn-tx); background: var(--warn-bg); border-color: var(--warn-ln); }
.vl2-hinweis { margin: -2px 0 0; font-size: 13px; color: var(--muted); line-height: 1.45; }

/* Felder: Betreff oben (einzeilig), Inhalt darunter */
.vl2-feld { gap: 5px; margin: 0; min-width: 0; }
.vl2-lbl { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.vl2-feld input[type="text"] { width: 100%; height: 38px; font-weight: 600; }
.vl2-feld textarea { min-height: 120px; line-height: 1.55; resize: vertical; overflow-wrap: anywhere; }
.vl2-feld input:focus-visible, .vl2-feld textarea:focus-visible { outline: 2px solid var(--fokus); outline-offset: 1px; }
.vl2-ohne { flex-direction: column; display: flex; }
.vl2-fest { display: flex; align-items: center; min-height: 38px; padding: 8px 12px; border-radius: 9px; border: 1px dashed var(--line-strong); color: var(--muted); font-size: 13.5px; }
.vl2-form { margin: 0; }
.vl2-form button[aria-pressed="true"] { color: #fff; }

.vl2-warn { margin: 0; padding: 7px 10px; border-radius: 9px; font-size: 13px; line-height: 1.45; color: var(--warn-tx); background: var(--warn-bg); border: 1px solid var(--warn-ln); }

/* Platzhalter-Chips */
.vl2-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.vl2-chip { font: 600 12.5px/1 var(--mono); color: var(--text); background: var(--flaeche-3); border: 1px solid var(--line); border-radius: 7px;
  padding: 6px 8px; cursor: pointer; max-width: 100%; overflow-wrap: anywhere; }
.vl2-chip:hover { border-color: var(--line-3); background: var(--hover); }
.vl2-chip:focus-visible { outline: 2px solid var(--fokus); outline-offset: 2px; }
.vl2-chip:active { transform: translateY(1px); }

.vl2-erkl { font-size: 13px; }
.vl2-erkl summary { cursor: pointer; color: var(--muted); width: fit-content; }
.vl2-erkl summary:hover { color: var(--text); }
.vl2-erkl summary:focus-visible { outline: 2px solid var(--fokus); outline-offset: 2px; border-radius: 4px; }
.vl2-erkl dl { margin: 8px 0 0; display: grid; gap: 6px; }
.vl2-erkl dl > div { display: grid; grid-template-columns: minmax(130px, max-content) 1fr; gap: 10px; align-items: baseline; }
.vl2-erkl dt { font: 600 12.5px var(--mono); color: var(--text); }
.vl2-erkl dd { margin: 0; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.vl2-bsp { display: block; color: var(--muted-2); font-size: 12.5px; }

.vl2-fuss { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 10px; border-top: 1px solid var(--line); }
.vl2-fuss .spacer { flex: 1; }

.vl2-leer { margin: 18px 0 0; text-align: center; }

/* ---------- Balken unten bei ungespeicherten Änderungen ---------- */
.vl2-balken { position: sticky; bottom: 14px; z-index: 6; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin-top: 16px; padding: 10px 12px 10px 16px;
  border-radius: 14px; background: var(--glas-voll); border: 1px solid var(--warn-ln); box-shadow: var(--sch-2); }
.vl2-balken .spacer { flex: 1; }
.vl2-balken-text { font-weight: 650; }
.vl2-balken-punkt { width: 8px; height: 8px; border-radius: 50%; background: var(--warn-tx); flex: none; }
/* Solange der Balken steht: Felder, die per Tab oder Sprung ins Bild kommen, nicht darunter verstecken */
html:has(#vorlagen-host .vl2-balken:not(.hidden)) { scroll-padding-bottom: 96px; }

/* ---------- Runde 2o: Fenster «Frühere Fassungen» ---------- */
.vl2-fs { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 16px; align-items: start; }
.vl2-fs-liste { display: flex; flex-direction: column; gap: 6px; max-height: 62vh; overflow: auto; padding: 2px; }
.vl2-fs-eintrag { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; width: 100%; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--flaeche-2); color: var(--text); font: inherit; text-align: left; cursor: pointer; }
.vl2-fs-eintrag:hover { border-color: var(--line-strong); }
.vl2-fs-eintrag:focus-visible { outline: 2px solid var(--fokus); outline-offset: 2px; }
.vl2-fs-eintrag.aktiv { border-color: var(--ak-ln); background: var(--ak-bg); }
.vl2-fs-zeit { font-size: 13.5px; font-weight: 650; }
.vl2-fs-art { font-size: 12.5px; color: var(--muted); }
.vl2-fs-quelle { font-size: 12px; color: var(--muted-2); }
.vl2-fs-gilt { display: inline-flex; align-items: center; height: 20px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
  color: var(--ink); background: var(--ak-bg); border: 1px solid var(--ak-ln); }
.vl2-fs-text { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.vl2-fs-kopf { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.vl2-fs-block { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.vl2-fs-betreff { padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--flaeche-2); font-weight: 600; overflow-wrap: anywhere; }
.vl2-fs-inhalt-kopf { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 10px; }
.vl2-fs-inhalt-kopf .seg { margin: 0; }
.vl2-fs-pre { margin: 0; max-height: 46vh; overflow: auto; padding: 14px 16px; border-radius: 10px; background: #fff; color: #111; border: 1px solid var(--line);
  font: 13px/1.55 Arial, Helvetica, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.vl2-fs-pre .muted { color: #555; }
.vl2-fs-fuss { display: flex; justify-content: flex-end; }
.vl2-fs-gilt-satz { margin: 0; font-size: 13.5px; color: var(--muted); }

/* ---------- Vorschau-Fenster ---------- */
.vl2-vs-betreff { display: flex; flex-direction: column; gap: 4px; margin: 6px 0 10px; padding: 10px 12px; border-radius: 10px; background: var(--flaeche-2); border: 1px solid var(--line); }
.vl2-vs-betreff b { font-weight: 650; overflow-wrap: anywhere; }
.vl2-vs-mail { height: 380px; }
.vl2-vs-text { margin: 0; max-height: 420px; overflow: auto; padding: 14px 16px; border-radius: 10px; background: #fff; color: #111; border: 1px solid var(--line);
  font: 13px/1.55 Arial, Helvetica, sans-serif; white-space: pre-wrap; overflow-wrap: anywhere; }
.vl2-vs-hinweis { margin: 8px 0 0; }

@media (max-width: 700px) {
  .vl2-head .btn[data-action="vl2-alle"] { width: 100%; }
  .vl2-suche { max-width: none; flex-basis: 100%; }
  .vl2-g-kopf { padding: 10px 12px; }
  .vl2-g-inhalt { padding-left: 0; }
  .vl2-zeile { padding: 11px 12px; grid-template-columns: minmax(0, 1fr) auto; }
  .vl2-z-haupt { grid-column: 1; grid-row: 1; }
  .vl2-zeile > .vl2-pfeil { grid-column: 2; grid-row: 1; }
  .vl2-z-stand { grid-column: 1; grid-row: 2; justify-self: start; }
  .vl2-z-hinweis { grid-column: 1 / -1; grid-row: 3; }
  .vl2-koerper { padding: 0 12px 12px; }
  .vl2-aktionen { padding: 9px 10px; }
  .vl2-aktionen-knoepfe { width: 100%; }
  .vl2-aktionen-knoepfe .btn { flex: 1 1 auto; justify-content: center; }
  .vl2-fs { grid-template-columns: 1fr; }
  .vl2-fs-liste { max-height: 40vh; }
  .vl2-fs-fuss .btn { flex: 1 1 auto; justify-content: center; }
  .vl2-erkl dl > div { grid-template-columns: 1fr; gap: 2px; }
  .vl2-fuss .btn { flex: 1 1 auto; }
  .vl2-fuss .spacer { display: none; }
  /* Mobil: Balken fest unten über die ganze Breite, Platz darunter frei halten */
  .vl2-balken { position: fixed; left: 8px; right: 8px; bottom: 8px; margin: 0; padding: 10px; z-index: 30; }
  #vorlagen-host:has(.vl2-balken:not(.hidden)) { padding-bottom: 120px; }
  .vl2-balken .btn { flex: 1 1 auto; }
  .vl2-balken .spacer { display: none; }
  .vl2-balken-text { flex: 1 1 calc(100% - 20px); }
  .vl2-vs-mail { height: 320px; }
}
@media (prefers-reduced-motion: reduce) {
  .vl2-karte, .vl2-g-kopf, .vl2-pfeil { transition: none; }
  .vl2-chip:active { transform: none; }
}
