/* Pepsi steuern (tabs/pepsi-steuerung.js): Leiste oben im Pepsi-Tab + Dialog „System-Prompt & Einstellungen“.
   Desktop: drei Spalten ohne inneres Scrollen des Dialogs (nur Textfelder scrollen selbst), feste Kopf- und Fußleiste.
   Handy: Vollbild, Inhalt scrollt, Fußleiste bleibt stehen. */

/* ---------- Leiste oben ---------- */
.pst-leiste{display:flex;align-items:center;gap:12px;margin:0 0 14px;padding:10px 12px 10px 14px;border:1px solid var(--crm-line,#e5e7eb);border-radius:var(--crm-radius,10px);background:var(--crm-surface,var(--bs-body-bg,#fff));animation:pst-ein .2s ease}
.pst-leiste .pst-icon{display:inline-flex;flex:none;width:32px;height:32px;align-items:center;justify-content:center;border-radius:9px;color:var(--crm-accent,#175676);background:color-mix(in srgb,var(--crm-accent,#175676) 9%,transparent)}
.pst-leiste .pst-text{display:flex;flex-direction:column;gap:2px;flex:1 1 auto;min-width:0}
.pst-leiste .pst-titel{font-size:14px;font-weight:600;line-height:1.35;overflow-wrap:anywhere}
.pst-leiste .pst-sub{font-size:12.5px;color:var(--crm-quiet,#6b7280);font-variant-numeric:tabular-nums}
.pst-leiste .pst-pausiert{color:#9a6700}
.pst-knopf{display:inline-flex;align-items:center;gap:8px;flex:none;min-height:40px;padding:0 14px;border-radius:10px;font-weight:600;white-space:nowrap}
.pst-knopf svg{flex:none}
.pst-skelett{display:block;width:min(360px,60%);height:12px;border-radius:6px;background:var(--crm-line,#e5e7eb);animation:pst-puls 1.2s ease-in-out infinite}
@keyframes pst-puls{50%{opacity:.45}}
@keyframes pst-ein{from{opacity:0;transform:translateY(-2px)}to{opacity:1;transform:none}}

/* Zustands-Pillen */
.pst-pille{display:inline-flex;align-items:center;gap:5px;margin-left:6px;padding:1px 8px;border-radius:999px;font-size:11.5px;font-weight:600;line-height:18px;vertical-align:1px;white-space:nowrap;border:1px solid transparent}
.pst-pille::before{content:"";width:6px;height:6px;border-radius:50%;background:currentColor}
.pst-pille[data-art="ok"]{color:#116329;background:#e9f6ec;border-color:#bfe3c8}
.pst-pille[data-art="laeuft"]{color:#175676;background:#e8f2f8;border-color:#bcd8e8}
.pst-pille[data-art="warnung"]{color:#7a4d00;background:#fff4dc;border-color:#f1d79a}
.pst-pille[data-art="fehler"]{color:#a1150e;background:#fdecea;border-color:#f5c2bd}
.pst-pille[data-art="still"]{color:var(--crm-quiet,#6b7280);background:transparent;border-color:var(--crm-line,#e5e7eb)}
[data-bs-theme="dark"] .pst-pille[data-art="ok"]{color:#7ee2a0;background:rgba(46,160,67,.14);border-color:rgba(46,160,67,.4)}
[data-bs-theme="dark"] .pst-pille[data-art="laeuft"]{color:#8fc6e3;background:rgba(94,172,214,.12);border-color:rgba(94,172,214,.4)}
[data-bs-theme="dark"] .pst-pille[data-art="warnung"]{color:#f2cc60;background:rgba(210,153,34,.14);border-color:rgba(210,153,34,.4)}
[data-bs-theme="dark"] .pst-pille[data-art="fehler"]{color:#ff9b93;background:rgba(248,81,73,.14);border-color:rgba(248,81,73,.4)}
[data-bs-theme="dark"] .pst-leiste .pst-pausiert{color:#f2cc60}
[data-bs-theme="dark"] .pst-leiste .pst-icon{color:#8fc6e3;background:rgba(143,198,227,.1)}

/* ---------- Dialog ---------- */
.pst-dialog{width:min(1400px,calc(100vw - 32px));height:min(880px,calc(100dvh - 32px));max-width:none;max-height:none;padding:0;border:1px solid var(--bs-border-color,#d9dde1);border-radius:14px;background:var(--bs-body-bg,#fff);color:var(--bs-body-color,#1d2428);box-shadow:0 18px 48px rgba(8,16,22,.32);overflow:hidden}
.pst-dialog::backdrop{background:rgba(8,16,22,.5)}
.pst-dialog[open]{animation:pst-auf .18s ease}
@keyframes pst-auf{from{opacity:0;transform:translateY(8px) scale(.99)}to{opacity:1;transform:none}}
.pst-form{display:flex;flex-direction:column;height:100%;margin:0}
.pst-kopf,.pst-banner,.pst-fuss{flex:none}
.pst-kopf{display:flex;align-items:flex-start;justify-content:space-between;gap:16px;padding:14px 16px 12px 22px;border-bottom:1px solid var(--crm-line,#e5e7eb)}
.pst-kopf h2{margin:0;font-size:18px;font-weight:650;letter-spacing:-.01em}
.pst-kopf .pst-hilfe{margin:3px 0 0}
.pst-zu{display:inline-flex;align-items:center;justify-content:center;flex:none;width:40px;height:40px;border:0;border-radius:10px;background:transparent;color:inherit;cursor:pointer}
.pst-zu:hover{background:color-mix(in srgb,currentColor 8%,transparent)}
.pst-zu:focus-visible{outline:2px solid var(--crm-accent,#175676);outline-offset:1px}
.pst-banner{display:flex;align-items:center;gap:12px;padding:9px 22px;font-size:13px;border-bottom:1px solid var(--crm-line,#e5e7eb)}
.pst-banner span{flex:1 1 auto}
.pst-banner .btn{flex:none}
.pst-banner[data-art="warnung"]{background:#fff8e6}
.pst-banner[data-art="fehler"]{background:#fdecea}
[data-bs-theme="dark"] .pst-banner[data-art="warnung"]{background:rgba(210,153,34,.12)}
[data-bs-theme="dark"] .pst-banner[data-art="fehler"]{background:rgba(248,81,73,.12)}

.pst-koerper{flex:1 1 auto;display:grid;grid-template-columns:320px 320px minmax(0,1fr);min-height:0;overflow:hidden}
.pst-spalte{display:flex;flex-direction:column;gap:10px;min-height:0;padding:16px 20px 14px 22px;border-right:1px solid var(--crm-line,#e5e7eb);overflow:auto}
.pst-spalte.pst-rechts{border-right:0;padding-right:22px}
.pst-spalte h3{margin:0 0 2px;font-size:13px;font-weight:650;text-transform:uppercase;letter-spacing:.04em;color:var(--crm-quiet,#6b7280)}
.pst-spalte .form-label{display:block;margin:0 0 4px;font-size:13px;font-weight:600}
.pst-spalte .form-control,.pst-spalte .form-select{min-height:38px;font-size:14px}
.pst-hilfe{margin:4px 0 0;font-size:12.5px;line-height:1.45;color:var(--crm-quiet,#6b7280)}
.pst-zeile{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}

/* Schalter */
.pst-schalter{position:relative;display:grid;grid-template-columns:auto 1fr;gap:2px 12px;align-items:start;margin:0;padding:10px 12px;border:1px solid var(--crm-line,#e5e7eb);border-radius:10px;cursor:pointer}
.pst-schalter input{position:absolute;opacity:0;width:1px;height:1px}
.pst-bahn{position:relative;width:40px;height:24px;margin-top:1px;border-radius:999px;background:#cbd5e1;transition:background-color .18s ease}
.pst-bahn::after{content:"";position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:#fff;box-shadow:0 1px 2px rgb(0 0 0/.25);transition:transform .18s ease}
.pst-schalter input:checked+.pst-bahn{background:var(--crm-accent,#175676)}
.pst-schalter input:checked+.pst-bahn::after{transform:translateX(16px)}
.pst-schalter input:focus-visible+.pst-bahn{outline:2px solid var(--crm-accent,#175676);outline-offset:2px}
.pst-schalter-text{display:flex;flex-direction:column;gap:1px;line-height:1.35;font-size:14px}
.pst-schalter-text small{font-size:12.5px;color:var(--crm-quiet,#6b7280)}
[data-bs-theme="dark"] .pst-bahn{background:#475569}

/* Zeitplan */
.pst-zeitplan{display:flex;flex-direction:column;gap:10px;transition:opacity .15s ease}
.pst-zeitplan[data-aus]{opacity:.55}
.pst-tage{margin:0;padding:0;border:0;min-width:0}
.pst-tage legend{float:none;width:auto;padding:0}
.pst-chips{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:4px}
.pst-chip{position:relative;margin:0;cursor:pointer}
.pst-chip input{position:absolute;opacity:0;width:1px;height:1px}
.pst-chip span{display:flex;align-items:center;justify-content:center;height:36px;border:1px solid var(--crm-line,#e5e7eb);border-radius:8px;font-size:13px;font-weight:600;color:var(--crm-quiet,#6b7280);transition:background-color .15s ease,color .15s ease,border-color .15s ease}
.pst-chip input:checked+span{background:var(--crm-accent,#175676);border-color:var(--crm-accent,#175676);color:#fff}
.pst-chip input:focus-visible+span{outline:2px solid var(--crm-accent,#175676);outline-offset:2px}
[data-bs-theme="dark"] .pst-chip input:checked+span{background:#2a7aa3;border-color:#2a7aa3}
.pst-schnell{display:flex;gap:12px;margin-top:2px}
.pst-schnell .btn-link,.pst-ph .btn-link{padding:0;min-height:28px;text-decoration:none;font-size:12.5px}
.pst-dreier{display:grid;grid-template-columns:1fr 1fr;gap:10px 8px;align-items:end}
.pst-zweier{display:grid;grid-template-columns:1fr 1fr;gap:8px;align-items:end}
.pst-zusammen{margin:0;font-size:13px;font-weight:600;color:var(--crm-accent,#175676)}
[data-bs-theme="dark"] .pst-zusammen{color:#8fc6e3}
.pst-eigen{margin:0;font-size:13px}
.pst-wache{margin:0;padding:6px 10px;border-left:3px solid #d4a72c;border-radius:4px;background:#fff8e6;font-size:12px;line-height:1.4;color:#5c3d00}
[data-bs-theme="dark"] .pst-wache{background:rgba(210,153,34,.12);color:#f2cc60}
.pst-lauf{display:grid;grid-template-columns:auto 1fr;gap:4px 12px;margin:auto 0 0;padding:10px 12px;border-radius:10px;background:color-mix(in srgb,var(--crm-accent,#175676) 5%,transparent);font-size:12.5px;line-height:1.4}
.pst-lauf dt{font-weight:600;color:var(--crm-quiet,#6b7280)}
.pst-lauf dd{margin:0;font-variant-numeric:tabular-nums}

/* Listenfelder */
.pst-feld{display:flex;flex-direction:column;min-height:0}
.pst-feld-ankerorte{flex:1 1 auto}
.pst-feld-ankerorte textarea{flex:1 1 auto;min-height:120px}
.pst-feld textarea{resize:none;font-size:13.5px;line-height:1.45}
.pst-zahl{display:inline-block;min-width:20px;margin-left:4px;padding:0 6px;border-radius:999px;background:color-mix(in srgb,currentColor 9%,transparent);font-size:11.5px;font-weight:600;text-align:center;font-variant-numeric:tabular-nums}

/* Rechte Spalte: System-Prompt */
.pst-rechts-kopf{display:flex;align-items:center;justify-content:space-between;gap:8px;flex-wrap:wrap}
.pst-rechts-kopf h3{margin:0}
.pst-knoepfe{display:flex;gap:6px}
.pst-text-feld{flex:1 1 auto;min-height:160px;width:100%;margin:0;padding:12px 14px;border:1px solid var(--bs-border-color,#d9dde1);border-radius:10px;font:13.5px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;resize:none;white-space:pre-wrap;overflow:auto;background:var(--bs-body-bg,#fff);color:inherit}
textarea.pst-text-feld:focus{border-color:var(--crm-accent,#175676);box-shadow:0 0 0 3px color-mix(in srgb,var(--crm-accent,#175676) 18%,transparent);outline:0}
.pst-vorschau{background:color-mix(in srgb,var(--crm-accent,#175676) 3%,var(--bs-body-bg,#fff))}
[data-bs-theme="dark"] .pst-text-feld{background:#212529}
.pst-ph{display:flex;flex-wrap:wrap;align-items:center;gap:4px 6px}
.pst-ph .pst-hilfe{margin:0 4px 0 0;width:100%}
.pst-ph-chip{display:inline-flex;align-items:center;gap:6px;min-height:28px;padding:0 8px;border:1px solid var(--crm-line,#e5e7eb);border-radius:7px;background:transparent;color:inherit;font-size:12px;cursor:pointer}
.pst-ph-chip code{font-size:11.5px;color:var(--crm-accent,#175676);background:none;padding:0}
.pst-ph-chip span{color:var(--crm-quiet,#6b7280)}
.pst-ph-chip:hover{border-color:var(--crm-accent,#175676)}
.pst-ph-chip:focus-visible{outline:2px solid var(--crm-accent,#175676);outline-offset:1px}
[data-bs-theme="dark"] .pst-ph-chip code{color:#8fc6e3}
.pst-hinweise{margin:0;padding:8px 12px 8px 28px;border-radius:8px;background:#fff8e6;font-size:12.5px;color:#7a4d00}
[data-bs-theme="dark"] .pst-hinweise{background:rgba(210,153,34,.12);color:#f2cc60}

/* Versionen */
.pst-versionen{list-style:none;margin:0;padding:0;overflow:auto;flex:1 1 auto;min-height:0;border-top:1px solid var(--crm-line,#e5e7eb)}
.pst-versionen>li{padding:10px 2px 8px;border-bottom:1px solid var(--crm-line,#e5e7eb)}
.pst-versionen>li.ist-aktuell{background:color-mix(in srgb,var(--crm-accent,#175676) 4%,transparent)}
.pst-v-kopf{display:flex;align-items:baseline;gap:4px 10px;flex-wrap:wrap;font-size:13.5px}
.pst-v-kopf span:not(.pst-pille){font-size:12.5px;color:var(--crm-quiet,#6b7280);font-variant-numeric:tabular-nums}
.pst-v-aend{margin:4px 0 0;padding-left:18px;font-size:12.5px;line-height:1.45}
.pst-v-notiz{font-style:italic}
.pst-v-knoepfe{display:flex;gap:14px;margin-top:2px}
.pst-v-knoepfe .btn-link{padding:0;min-height:30px;font-size:12.5px;text-decoration:none}

/* Fußleiste */
.pst-fuss{display:flex;align-items:center;gap:10px;padding:12px 22px;border-top:1px solid var(--crm-line,#e5e7eb);background:var(--bs-body-bg,#fff)}
.pst-notiz{flex:0 1 300px;min-height:40px;font-size:14px}
.pst-fuss .pst-stand{flex:1 1 auto;margin:0;font-size:13px}
.pst-fuss .btn{flex:none;min-height:42px;min-width:110px}

/* Meldung */
.pst-toast{position:fixed;left:50%;bottom:84px;z-index:20;max-width:min(560px,calc(100vw - 32px));padding:10px 16px;border-radius:10px;background:#1d2428;color:#fff;font-size:13.5px;box-shadow:0 10px 30px rgba(0,0,0,.25);transform:translateX(-50%);animation:pst-ein .18s ease;transition:opacity .25s ease}
.pst-toast[data-art="fehler"]{background:#a1150e}
.pst-toast.weg{opacity:0}
body>.pst-toast{bottom:24px}

/* Mittlere Breite: Einstellungen nebeneinander, System-Prompt darunter; Dialog scrollt als Ganzes */
@media (max-width:1199.98px){
  .pst-koerper{grid-template-columns:minmax(0,1fr) minmax(0,1fr);overflow:auto}
  .pst-spalte{overflow:visible}
  .pst-spalte.pst-rechts{grid-column:1/-1;border-top:1px solid var(--crm-line,#e5e7eb)}
  .pst-spalte:nth-child(2){border-right:0}
  .pst-text-feld{min-height:420px}
  .pst-versionen{max-height:60vh}
}
/* Niedrige Desktop-Fenster: lieber den Inhalt scrollen als Felder zerquetschen */
@media (min-width:1200px) and (max-height:779.98px){
  .pst-koerper{overflow:auto}
  .pst-spalte{overflow:visible}
  .pst-text-feld{min-height:440px}
}
/* Handy: Vollbild */
@media (max-width:767.98px){
  .pst-leiste{flex-wrap:wrap;gap:10px;padding:12px}
  .pst-leiste .pst-icon{display:none}
  .pst-leiste .pst-text{flex-basis:100%}
  .pst-knopf{width:100%;justify-content:center;min-height:44px}
  .pst-dialog{width:100vw;height:100dvh;max-width:100vw;max-height:100dvh;margin:0;border:0;border-radius:0}
  .pst-kopf{padding:10px 8px 10px 16px}
  .pst-kopf h2{font-size:16.5px}
  .pst-zu{width:44px;height:44px}
  .pst-banner{flex-wrap:wrap;padding:9px 16px}
  .pst-koerper{display:block;overflow:auto;overscroll-behavior:contain}
  .pst-spalte{padding:14px 16px;border-right:0;border-bottom:1px solid var(--crm-line,#e5e7eb)}
  .pst-spalte .form-control,.pst-spalte .form-select{min-height:44px;font-size:16px}
  .pst-chip span{height:44px}
  .pst-feld textarea,.pst-text-feld{font-size:16px}
  .pst-feld-ankerorte textarea{min-height:200px}
  .pst-text-feld{min-height:60dvh}
  .pst-versionen{max-height:none;overflow:visible}
  .pst-fuss{flex-wrap:wrap;gap:8px;padding:10px 16px calc(10px + env(safe-area-inset-bottom));box-shadow:0 -8px 12px -10px rgba(16,24,35,.25)}
  .pst-notiz{flex:1 1 100%;font-size:16px}
  .pst-fuss .pst-stand{flex-basis:100%;order:-1}
  .pst-fuss .btn{flex:1 1 0;min-width:0;min-height:44px}
  .pst-toast{bottom:150px}
}
@media (prefers-reduced-motion:reduce){.pst-leiste,.pst-dialog[open],.pst-toast{animation:none}.pst-bahn,.pst-bahn::after,.pst-chip span,.pst-zeitplan{transition:none}.pst-skelett{animation:none}}
