/* ==========================================================================
   StreamGuard · UI-Bausteine (Richtung A „Regieraum“)
   Geteilte Komponenten für Dashboard und Admin. Nur Tokens aus tokens.css.
   Benennung: .block, .block__teil, .block--variante, Zustände als .is-*.
   Die passenden Erzeuger stehen in core.js (StreamGuard.ui) – siehe FRONTEND-API.md.
   ========================================================================== */

/* ---------- Basis ---------------------------------------------------------- */

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font: var(--t-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scrollbar-color: var(--line-2) transparent;
}

img { max-width: 100%; }
a { color: var(--pgm-ink); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
p { margin: 0; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
code, kbd, samp { font-family: var(--f-mono); }
[hidden] { display: none !important; }
:focus-visible { outline: var(--focus-ring); outline-offset: var(--focus-offset); }
::selection { background: var(--pgm-line); color: var(--ink); }

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Typo-Helfer */
.lbl { font: var(--t-label); letter-spacing: var(--label-track); text-transform: uppercase; color: var(--ink-3); }
.mono { font-family: var(--f-mono); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.muted { color: var(--ink-3); }
.soft { color: var(--ink-2); }
.strong { color: var(--ink); font-weight: 500; }
.text { color: var(--ink-2); font: var(--t-body-l); max-width: 68ch; }
.route { color: var(--pgm-ink); }

.icon {
  width: 16px;
  height: 16px;
  flex: none;
  display: inline-block;
  vertical-align: -3px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- LED & Status ---------------------------------------------------- */

.led {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--led-off);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45);
  flex: none;
}
.led--ok { background: var(--sig); box-shadow: 0 0 0 2px rgba(65, 192, 126, 0.13); }
.led--warn { background: var(--amber); box-shadow: 0 0 0 2px rgba(227, 163, 60, 0.13); }
.led--err { background: var(--red); box-shadow: 0 0 0 2px rgba(229, 84, 76, 0.14); }
.led--pgm { background: var(--pgm); box-shadow: 0 0 0 2px rgba(91, 141, 239, 0.16); }
.led--blink { animation: ledBlink 1.1s steps(2, jump-none) infinite; }
@keyframes ledBlink { 50% { opacity: 0.25; } }

/* LED + Text, z. B. „Bot verbunden“ */
.st {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  font: 500 12px/1 var(--f-mono);
  color: var(--ink-2);
}

/* Tally: der rote Punkt der Kamera – hier Programmblau („Live“) */
.tally {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--r1);
  background: var(--pgm);
  color: var(--on-pgm);
  font: 600 11px/1 var(--f-mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.tally i { width: 6px; height: 6px; border-radius: 50%; background: var(--on-pgm); }
.tally--off { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line-2); }
.tally--off i { background: var(--led-off); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.45); }
.tally--warn { background: transparent; color: var(--amber); box-shadow: inset 0 0 0 1px var(--warn-line); }
.tally--warn i { background: var(--amber); }
.tally--err { background: transparent; color: var(--red); box-shadow: inset 0 0 0 1px var(--danger-line); }
.tally--err i { background: var(--red); }

/* Timecode */
.tc {
  font: 500 14px/1 var(--f-mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  font-feature-settings: "zero" 1, "tnum" 1;
  letter-spacing: 0.02em;
}

/* ---------- Buttons ---------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: var(--ctl-h);
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-bottom-color: var(--key-lo);
  border-radius: var(--r1);
  background: var(--key);
  box-shadow: var(--key-inset);
  color: var(--ink);
  font: 500 13px/1 var(--f-sans);
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background-color var(--dur-1), border-color var(--dur-1), color var(--dur-1);
}
.btn:hover { background: var(--key-hi); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn .icon { width: 15px; height: 15px; }
.btn-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }

.btn--primary { background: var(--pgm); border-color: var(--pgm); color: var(--on-pgm); box-shadow: none; }
.btn--primary:hover { background: var(--pgm-hover); border-color: var(--pgm-hover); color: var(--on-pgm); }

.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn--ghost:hover { background: var(--raised); color: var(--ink); }

.btn--danger:hover { color: var(--red); border-color: var(--danger-line); }
.btn--ghost-danger { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn--ghost-danger:hover { background: var(--danger-wash); color: var(--red); }
.btn--danger-solid { background: var(--red); border-color: var(--red); color: var(--on-red); box-shadow: none; }
.btn--danger-solid:hover { background: var(--red-hover); border-color: var(--red-hover); color: var(--on-red); }

.btn--sm { height: var(--ctl-h-sm); padding: 0 10px; font-size: 12.5px; gap: 6px; }
.btn--lg { height: var(--ctl-h-lg); padding: 0 18px; font-size: 14.5px; gap: 10px; }
.btn--block { width: 100%; }
.btn--icon { width: var(--ctl-h); padding: 0; }
.btn--icon.btn--sm { width: var(--ctl-h-sm); }

.btn:disabled,
.btn.is-disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.btn:disabled:hover,
.btn.is-disabled:hover { background: var(--key); color: var(--ink); }
.btn--primary:disabled:hover,
.btn--primary.is-disabled:hover { background: var(--pgm); color: var(--on-pgm); }
.btn--ghost:disabled:hover,
.btn--ghost-danger:disabled:hover { background: transparent; color: var(--ink-2); }
/* Läuft gerade (ctx.action/submit/busy): weich gesperrt per aria-disabled, der Fokus bleibt auf dem Button */
.btn.is-busy,
.key.is-busy { cursor: progress; opacity: 0.72; }
.btn.is-busy:active,
.key.is-busy:active { transform: none; }

.button-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Pult-Taste mit LED (Umschalter, Szenen, Schnellaktionen) */
.key {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-bottom-color: var(--key-lo);
  border-radius: var(--r1);
  background: var(--key);
  box-shadow: var(--key-inset);
  color: var(--ink-2);
  font: 500 12px/1 var(--f-mono);
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-1), color var(--dur-1), border-color var(--dur-1);
}
.key:hover { background: var(--key-hi); color: var(--ink); }
.key:active { transform: translateY(1px); }
.key:disabled { opacity: 0.42; cursor: not-allowed; transform: none; }
.key .led { width: 6px; height: 6px; }
.key[aria-pressed="true"] { color: var(--ink); border-color: var(--warn-line); }
.key[aria-pressed="true"] .led { background: var(--amber); box-shadow: 0 0 0 2px rgba(227, 163, 60, 0.14); }
.key--bus[aria-pressed="true"] { background: var(--pgm); border-color: var(--pgm); color: var(--on-pgm); }
.key--bus[aria-pressed="true"] .led { background: var(--on-pgm); box-shadow: none; }
.key--danger.is-armed { border-color: var(--red); color: var(--red); }
.key.is-fired { border-color: var(--pgm); color: var(--ink); }
.key.is-fired .led { background: var(--pgm); }
.key .pts { color: var(--ink-3); font-weight: 400; }

/* ---------- Eingaben ----------------------------------------------------------- */

.input,
.select {
  display: block;
  width: 100%;
  height: var(--ctl-h);
  padding: 0 10px;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  background: var(--void);
  color: var(--ink);
  font: 400 13px/1.3 var(--f-sans);
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
textarea.input { height: auto; min-height: 76px; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.input::placeholder { color: var(--ink-3); opacity: 1; }
.input:hover,
.select:hover { border-color: var(--line-3); }
.input:focus,
.select:focus { outline: none; border-color: var(--pgm); box-shadow: 0 0 0 1px var(--pgm); }
.input:disabled,
.select:disabled { opacity: 0.5; cursor: not-allowed; }
.input[readonly] { color: var(--ink-2); }
.input[readonly]:focus { border-color: var(--line-3); box-shadow: none; }
.input--mono { font: 400 12.5px/1.3 var(--f-mono); }
textarea.input--mono { line-height: 1.55; }
.input--num { font: 400 12.5px/1.3 var(--f-mono); font-variant-numeric: tabular-nums; }
.input:user-invalid { border-color: var(--red); }

.select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237c8492' stroke-width='1.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 10px 6px;
}
.select option { background: var(--panel); color: var(--ink); }
.select--sm { height: var(--ctl-h-sm); font-size: 12.5px; }
.select--auto { width: auto; min-width: 140px; }

/* Suchfeld mit Lupe */
.search { position: relative; display: inline-flex; align-items: center; min-width: 0; }
.search .icon { position: absolute; left: 9px; width: 14px; height: 14px; color: var(--ink-3); pointer-events: none; }
.search .input { height: 30px; width: 220px; max-width: 100%; padding-left: 30px; font-size: 12.5px; }
.search .input::-webkit-search-cancel-button { filter: grayscale(1) opacity(0.6); }

/* Eingabe mit angehängtem Button */
.input-group { display: flex; gap: 8px; min-width: 0; }
.input-group .input { flex: 1; min-width: 0; }
.inline-form { display: flex; gap: 8px; align-items: flex-start; }
.inline-form .input { flex: 1; min-width: 0; }

/* Formularfelder */
.field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.field__label { font: var(--t-label); letter-spacing: var(--label-track); text-transform: uppercase; color: var(--ink-3); }
.field__hint { font: var(--t-small); color: var(--ink-3); }
.field__row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.fields { display: grid; gap: 16px; min-width: 0; }
.fields--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.fields--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.form-error { font: var(--t-small); color: var(--red); }
.form-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.counter { font: 400 11.5px/1 var(--f-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--red); }

/* Schalter: eckig wie ein Kippschalter am Pult */
.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 20px;
  cursor: pointer;
  user-select: none;
  font: 400 13px/1.35 var(--f-sans);
  color: var(--ink);
}
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.switch__track {
  position: relative;
  flex: none;
  width: 30px;
  height: 16px;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  background: var(--void);
  transition: background-color var(--dur-2), border-color var(--dur-2);
}
.switch__track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 1px;
  background: var(--ink-3);
  transition: transform var(--dur-2) var(--ease), background-color var(--dur-2);
}
.switch:hover .switch__track { border-color: var(--line-3); }
.switch input:checked + .switch__track { border-color: var(--pgm); background: var(--pgm-wash); }
.switch input:checked + .switch__track::after { transform: translateX(14px); background: var(--pgm); }
.switch input:focus-visible + .switch__track { outline: var(--focus-ring); outline-offset: 2px; }
.switch input:disabled + .switch__track { opacity: 0.4; }
.switch:has(input:disabled) { cursor: not-allowed; color: var(--ink-3); }
.switch-list { display: grid; gap: 10px; }

/* Schieberegler */
.range-row { display: flex; align-items: center; gap: 12px; min-width: 0; }
.range {
  flex: 1;
  min-width: 0;
  height: 18px;
  margin: 0;
  background: transparent;
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track { height: 4px; border-radius: 1px; background: var(--line-2); }
.range::-moz-range-track { height: 4px; border-radius: 1px; background: var(--line-2); }
.range::-moz-range-progress { height: 4px; border-radius: 1px; background: var(--pgm); }
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px;
  height: 16px;
  margin-top: -6px;
  border: 1px solid var(--line-3);
  border-radius: var(--r1);
  background: var(--ink);
}
.range::-moz-range-thumb { width: 12px; height: 16px; border: 1px solid var(--line-3); border-radius: var(--r1); background: var(--ink); }
.range:focus-visible { outline: var(--focus-ring); outline-offset: 4px; }
.range:disabled { opacity: 0.45; cursor: not-allowed; }
.range-value { min-width: 52px; text-align: right; font: 500 12.5px/1 var(--f-mono); font-variant-numeric: tabular-nums; color: var(--ink); }

/* Segmentschalter (Radiogruppe oder Buttons mit aria-pressed) */
.seg {
  display: inline-flex;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  background: var(--void);
  overflow: hidden;
  max-width: 100%;
}
.seg__opt { position: relative; display: flex; }
.seg__opt input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.seg__opt span,
.seg > button {
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border: 0;
  border-left: 1px solid var(--line-2);
  background: none;
  font: 500 12px/1 var(--f-mono);
  color: var(--ink-3);
  white-space: nowrap;
  cursor: pointer;
}
.seg__opt:first-child span,
.seg > button:first-child { border-left: 0; }
.seg__opt input:checked + span,
.seg > button[aria-pressed="true"] { background: var(--raised); color: var(--ink); }
.seg__opt:hover span,
.seg > button:hover { color: var(--ink); }
.seg__opt input:focus-visible + span { outline: var(--focus-ring); outline-offset: -2px; }

/* Filter-Tabs mit Zählern */
.tabs { display: flex; flex-wrap: wrap; gap: 2px; }
.tabs button {
  height: 28px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: var(--r1);
  background: none;
  cursor: pointer;
  font: 500 12px/1 var(--f-sans);
  color: var(--ink-3);
  white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-pressed="true"] { background: var(--raised); border-color: var(--line-2); color: var(--ink); }
.tabs .n { margin-left: 6px; font: 400 11px/1 var(--f-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; }

/* ---------- Paneele ------------------------------------------------------------- */

.pnl {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
}
.pnl__h {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 42px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.pnl__code { font: 500 10px/1 var(--f-mono); letter-spacing: 0.1em; color: var(--ink-3); }
.pnl__t { font: var(--t-heading); margin: 0; }
.pnl__meta { font: var(--t-label); letter-spacing: var(--label-track); text-transform: uppercase; color: var(--ink-3); display: inline-flex; align-items: center; gap: 8px; }
.pnl__actions { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pnl__b { padding: 14px 14px 16px; min-width: 0; }
.pnl__b--flush { padding: 0; }
.pnl__notice { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.pnl__foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); font: 400 11.5px/1.4 var(--f-mono); color: var(--ink-3); }
.pnl__foot > :last-child { margin-left: auto; }
.pnl--clip { overflow: hidden; }

/* Aufklappbares Paneel */
.disclosure > summary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 6px 14px;
  cursor: pointer;
  list-style: none;
}
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary .icon { color: var(--ink-3); transition: transform var(--dur-2) var(--ease); }
.disclosure[open] > summary { border-bottom: 1px solid var(--line); }
.disclosure[open] > summary .icon { transform: rotate(90deg); }
.disclosure__body { padding: 14px; display: grid; gap: 14px; }

/* ---------- Tabellen --------------------------------------------------------------- */

.tbl-wrap { position: relative; overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  font: 500 10.5px/1.2 var(--f-mono);
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: left;
  white-space: nowrap;
}
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: var(--hover); }
.tbl .num { text-align: right; white-space: nowrap; }
.tbl td.num { font: 400 12.5px/1.4 var(--f-mono); font-variant-numeric: tabular-nums; color: var(--ink-2); }
.tbl td.strong { color: var(--ink); font-weight: 500; }
.tbl td.num.strong { color: var(--ink); font-weight: 500; }
.tbl .cell-text { max-width: 440px; color: var(--ink-2); }
.tbl .cell-mono { font: 400 12.5px/1.4 var(--f-mono); color: var(--ink-2); }
.tbl .cell-actions { width: 1%; text-align: right; white-space: nowrap; }
.tbl .cell-actions .btn + .btn { margin-left: 2px; }
.tbl--sort th button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  color: inherit;
  cursor: pointer;
}
.tbl--sort th[aria-sort] button { color: var(--ink); }
.tbl tr.is-selected td { background: rgba(91, 141, 239, 0.05); }
.tbl tr.is-clickable { cursor: pointer; }

/* Zeilenaktionen: auf Geräten mit Maus erst beim Überfahren voll sichtbar */
@media (hover: hover) {
  .tbl .cell-actions .btn--ghost,
  .tbl .cell-actions .btn--ghost-danger { opacity: 0.5; transition: opacity var(--dur-1); }
  .tbl tr:hover .cell-actions .btn,
  .tbl .cell-actions .btn:focus-visible { opacity: 1; }
}

/* Inaktive Zeilen und Einträge über dem Plan-Limit */
.tbl tr.is-muted td { color: var(--ink-3); }
.tbl tr.is-muted .code { color: var(--ink-3); }
.tbl tr.is-over-limit td { color: var(--ink-3); }
.tbl tr.is-over-limit .code,
.tbl tr.is-over-limit .strong { color: var(--ink-3); text-decoration: line-through; text-decoration-color: var(--ink-4); }
.over-limit-hint { display: block; margin-top: 3px; font: 400 11.5px/1.35 var(--f-sans); color: var(--amber); white-space: normal; text-decoration: none; }

.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.code { font: 500 12.5px/1.45 var(--f-mono); color: var(--pgm-ink); white-space: nowrap; }

/* Antwort-Vorlage mit Platzhaltern (ui.template; A: „Befehle · Vorschau“) */
.tpl { font: 400 12.5px/1.55 var(--f-mono); color: var(--ink-2); overflow-wrap: anywhere; }
.ph { padding: 1px 3px; border-radius: var(--r1); background: var(--pgm-wash); color: var(--pgm-ink); white-space: nowrap; }
.ph--unknown { background: var(--warn-wash); color: var(--amber); text-decoration: underline dotted; text-underline-offset: 3px; }
.tbl tr.is-muted .tpl,
.tbl tr.is-over-limit .tpl { color: var(--ink-3); }
.tbl tr.is-muted .ph,
.tbl tr.is-over-limit .ph { background: transparent; color: var(--ink-3); box-shadow: inset 0 0 0 1px var(--line-2); }

/* ---------- Tags, Badges, Chips --------------------------------------------------------- */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 5px;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  font: 500 10.5px/1 var(--f-mono);
  letter-spacing: 0.03em;
  color: var(--ink-2);
  white-space: nowrap;
  vertical-align: 1px;
}
.tag--pgm { color: var(--pgm-ink); border-color: var(--pgm-line); }
.tag--ok { color: var(--sig); border-color: var(--ok-line); }
.tag--warn { color: var(--amber); border-color: var(--warn-line); }
.tag--danger { color: var(--red); border-color: var(--danger-line); }
.tag--solid { background: var(--pgm); border-color: var(--pgm); color: var(--on-pgm); }

/* Twitch-Badges im Chat */
.bdg {
  display: inline-grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: var(--r1);
  font: 600 9.5px/1 var(--f-mono);
  text-decoration: none;
  cursor: help;
  vertical-align: 1px;
}
.bdg--b { background: rgba(229, 84, 76, 0.16); color: var(--bdg-b); }
.bdg--m { background: rgba(65, 192, 126, 0.16); color: var(--bdg-m); }
.bdg--v { background: rgba(222, 110, 168, 0.16); color: var(--bdg-v); }
.bdg--s { background: rgba(91, 141, 239, 0.16); color: var(--pgm-ink); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  background: var(--void);
  font: 500 12px/1 var(--f-mono);
  color: var(--ink-2);
  white-space: nowrap;
}
button.chip { cursor: pointer; }
button.chip:hover { border-color: var(--line-3); color: var(--ink); }
.chip--ph { background: var(--pgm-wash); border-color: var(--pgm-line); color: var(--pgm-ink); }
.chip--ph:hover { color: var(--ink); }
.chip--removable { padding-right: 2px; color: var(--ink); }
.chip__remove {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--r1);
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.chip__remove:hover { background: var(--danger-wash); color: var(--red); }
.chip__remove .icon { width: 12px; height: 12px; }

/* ---------- Meter, Nutzung, KPI ------------------------------------------------------------- */

/* LED-Segmentbalken (horizontal) und -leiter (vertikal) */
.meter { display: flex; gap: 3px; height: 10px; min-width: 0; }
.meter i { flex: 1; min-width: 2px; border-radius: 1px; background: var(--chart-track); transition: background-color var(--dur-1); }
.meter i.on { background: var(--pgm); }
.meter i.pk { background: var(--pgm-ink); }
.meter--neutral i.on { background: var(--chart-lit); }
.meter--neutral i.pk { background: var(--chart-peak); }
.meter i.on.w { background: var(--amber); }
.meter i.on.h { background: var(--red); }
.meter--lg { height: 12px; }
.meter--ladder { flex-direction: column-reverse; width: 20px; height: auto; }
.meter--ladder i { min-height: 2px; }

/* Nutzung gegen ein Plan-Limit („3 / 10“) */
.usage { display: inline-flex; align-items: center; gap: 10px; font: 500 12px/1 var(--f-mono); color: var(--ink-2); white-space: nowrap; }
.usage__bar { display: flex; gap: 2px; width: 72px; height: 6px; }
.usage__bar i { flex: 1; border-radius: 1px; background: var(--chart-track); }
.usage__bar i.on { background: var(--ink-2); }
.usage.is-full { color: var(--amber); }
.usage.is-full .usage__bar i.on { background: var(--amber); }

/* KPI-Leiste */
.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  background: var(--panel);
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  overflow: hidden;
}
.kpis--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpi { min-width: 0; padding: 14px 16px 12px; border-left: 1px solid var(--line); margin-left: -1px; }
@media (max-width: 1024px) {
  .kpis--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis--4 .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
}
.kpi__v { margin-top: 8px; font: var(--t-kpi); letter-spacing: -0.005em; font-variant-numeric: tabular-nums; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi__v small { margin-left: 3px; font: 500 15px var(--f-cond); color: var(--ink-2); }
.kpi__d { margin-top: 6px; font: 400 11.5px/1.35 var(--f-mono); color: var(--ink-3); }
.kpi__d .up { color: var(--sig); }
.kpi__d .dn { color: var(--red); }
.spark { display: block; width: 100%; height: 26px; margin-top: 10px; overflow: visible; }
.spark path { fill: none; stroke: var(--ink-3); stroke-width: 1.5; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.spark circle { fill: var(--pgm); }

/* Kleine Statistik-Kacheln (Zähler dieser Sitzung) */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { padding: 12px 14px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); margin: -1px 0 0 -1px; min-width: 0; }
.stat__label { font: var(--t-label); letter-spacing: var(--label-track); text-transform: uppercase; color: var(--ink-3); }
.stat__value { margin-top: 6px; font: 600 24px/1 var(--f-cond); font-variant-numeric: tabular-nums; color: var(--ink); }

/* ---------- Listen ------------------------------------------------------------------ */

/* Kompakte Zeilen: Zeit · Text · Wert */
.list { list-style: none; margin: 0; padding: 0; }
.list__row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.list__row:last-child { border-bottom: 0; }
.list__t { font: 400 11.5px/1.45 var(--f-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; font-feature-settings: "zero" 1, "tnum" 1; }
.list__x { min-width: 0; color: var(--ink-2); overflow-wrap: anywhere; }
.list__x b { color: var(--ink); font-weight: 500; }
.list__n { font: 500 12px/1.45 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }

.list__main { color: var(--ink); }
.list__meta { margin-top: 3px; font: 400 11.5px/1.4 var(--f-mono); color: var(--ink-3); }

/* „Mehr laden“ unter Listen */
.more { display: flex; justify-content: center; padding: 10px 14px; border-top: 1px solid var(--line); }

/* Zweizeilige Zelle: Name und Login darunter; Identität mit Avatar */
.cell-2 { display: grid; gap: 2px; min-width: 0; }
.cell-2__main { color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }
.cell-2__sub { font: 400 11.5px/1.3 var(--f-mono); color: var(--ink-3); overflow-wrap: anywhere; }
.ident { display: flex; align-items: center; gap: 10px; min-width: 0; }

/* Schlüssel · LED · Wert */
.kv { list-style: none; margin: 0; padding: 0; }
.kv__row {
  display: grid;
  grid-template-columns: minmax(96px, 132px) 12px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
}
.kv__row:last-child { border-bottom: 0; }
.kv__k { color: var(--ink-3); }
.kv__v { min-width: 0; font: 400 12px/1.45 var(--f-mono); color: var(--ink); overflow-wrap: anywhere; }
.kv__v small { display: block; color: var(--red); font-family: var(--f-sans); }

/* Schlüssel-Wert-Liste (ui.facts; A: .facts), z. B. Grenzen eines Plans */
.facts { margin: 0; padding: 0; border-top: 1px solid var(--line); }
.facts__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font: 400 12.5px/1.45 var(--f-mono);
}
.facts dt { flex: none; color: var(--ink-3); }
.facts dd { min-width: 0; margin: 0; color: var(--ink-2); text-align: right; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.facts dd.is-muted { color: var(--ink-3); }
.facts dd code { color: var(--pgm-ink); }
.facts dd .usage { vertical-align: middle; }

/* „Im Chat“-Liste (ui.commands): Befehl · was passiert · wer darf */
.cmds { margin: 0; }
.cmds__row { display: grid; gap: 3px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.cmds__row:last-child { border-bottom: 0; }
.cmds__cmd { margin: 0; }
.cmds__cmd code { font: var(--t-code); color: var(--pgm-ink); overflow-wrap: anywhere; }
.cmds__text { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; margin: 0; color: var(--ink-2); }
.cmds__who { font: var(--t-label); letter-spacing: var(--label-track); text-transform: uppercase; color: var(--ink-3); white-space: nowrap; }

/* Definitionsliste zweispaltig */
.dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 20px; margin: 0; }
.dl dt { color: var(--ink-3); }
.dl dd { margin: 0; font: 400 12.5px/1.45 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
/* Variante: Schlüssel als Code, Beschreibung als Fließtext (z. B. URL-Parameter) */
.dl--text dt { font: 400 12.5px/1.45 var(--f-mono); color: var(--ink-2); }
.dl--text dd { font: var(--t-body); color: var(--ink-2); }

/* Protokoll / Zeitleiste */
.log { list-style: none; margin: 0; padding: 0; }
.log__day {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  font: var(--t-label);
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  color: var(--ink-3);
}
.log__entry {
  display: grid;
  grid-template-columns: 52px auto minmax(0, 1fr);
  align-items: baseline;
  gap: 4px 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.log__entry:last-child { border-bottom: 0; }
.log__time { font: 400 12px/1.5 var(--f-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; font-feature-settings: "zero" 1, "tnum" 1; }
.log__main { min-width: 0; }
.log__text { color: var(--ink); overflow-wrap: anywhere; }
.log__meta { margin-top: 2px; font: 400 11.5px/1.4 var(--f-mono); color: var(--ink-3); }

/* ---------- Chat-Zeilen ----------------------------------------------------------------- */

.chatlog { display: flex; flex-direction: column; gap: 1px; padding: 6px 8px 8px 14px; font-size: 13.5px; line-height: 1.45; }
.msg { position: relative; display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: 8px; padding: 3px 6px 3px 0; border-radius: 1px; }
.msg__time { font: 400 11px/19px var(--f-mono); color: var(--ink-3); font-variant-numeric: tabular-nums; font-feature-settings: "zero" 1, "tnum" 1; }
.msg__b { min-width: 0; overflow-wrap: anywhere; color: var(--ink); }
.msg__b > * { margin-right: 5px; }
.msg__b > .msg__text { margin-right: 0; }
.msg__chan { font: 500 10.5px/1 var(--f-mono); color: var(--ink-3); }
.msg__badges { display: inline-flex; gap: 2px; }
.msg__name { font-weight: 600; margin-right: 0; }
.msg__colon { color: var(--ink-3); }
.msg__text .cmd { font-family: var(--f-mono); font-size: 0.92em; color: var(--pgm-ink); }
.msg--bot { background: var(--pgm-soft); box-shadow: inset 2px 0 0 var(--pgm); }
.msg--bot .msg__time { padding-left: 8px; }
.msg--hit .msg__text { color: var(--ink-3); text-decoration: line-through; text-decoration-color: rgba(229, 84, 76, 0.8); }
.msg--sys .msg__text { color: var(--ink-3); font-style: italic; }
.msg .hit {
  display: inline-block;
  margin-left: 6px;
  padding: 3px 5px;
  border: 1px solid rgba(229, 84, 76, 0.42);
  border-radius: var(--r1);
  font: 500 10.5px/1 var(--f-mono);
  color: var(--red);
  white-space: nowrap;
  vertical-align: 1px;
}
.msg.is-new { animation: msgIn var(--dur-3) ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Live-Fenster: scrollt selbst, der Rest der Seite bleibt stehen */
.feed { position: relative; flex: 1; min-height: 0; }
.feed__scroll {
  height: clamp(360px, 62vh, 640px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.feed__scroll:focus-visible { outline-offset: -2px; }
/* Wie in jedem Chat: wenige Zeilen stehen unten an der Eingabe, der leere Zustand mittig */
.feed__scroll > .chatlog { min-height: 100%; justify-content: flex-end; }
.feed__scroll > .chatlog > .empty { margin-block: auto; }

/* Als Bot schreiben */
.say { display: flex; gap: 8px; padding: 10px 14px 12px; border-top: 1px solid var(--line); }
.say .input { flex: 1; min-width: 0; height: 34px; }
.say .select { width: auto; max-width: 180px; height: 34px; font-family: var(--f-mono); font-size: 12.5px; }
.say .btn { height: 34px; }
.say__hint { padding: 0 14px 12px; font: var(--t-small); color: var(--ink-3); }

/* Großer Messwert mit Wort und Balken (A: Stimmung) */
.readout { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: end; gap: 4px 16px; }
.readout__v { font: 600 46px/0.9 var(--f-cond); font-variant-numeric: tabular-nums; color: var(--ink); }
.readout__w { font: 500 14px/1.2 var(--f-sans); color: var(--pgm-ink); }
.readout__p { font: 400 11.5px/1.4 var(--f-mono); color: var(--ink-3); }
.readout .meter { grid-column: 1 / -1; margin-top: 12px; }
.scale-l { display: flex; justify-content: space-between; margin-top: 6px; font: 400 10.5px/1 var(--f-mono); color: var(--ink-3); }

/* Kennzahl mit Beschriftung (z. B. aktueller Plan) */
.figure { display: grid; gap: 6px; align-content: start; }
.figure__v { font: var(--t-display-m); letter-spacing: -0.005em; color: var(--ink); }
.figure__sub { font: 400 12.5px/1.4 var(--f-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }

.kv__empty { padding: 12px 14px; color: var(--ink-2); list-style: none; }

/* Sprung zu neuen Nachrichten */
.jump {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--pgm);
  border-radius: var(--r1);
  background: var(--pgm);
  color: var(--on-pgm);
  font: 500 12px/1 var(--f-mono);
  cursor: pointer;
  box-shadow: var(--shadow-pop);
}

/* ---------- Hinweise, Zustände ---------------------------------------------------------- */

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  background: var(--panel);
  box-shadow: inset 2px 0 0 var(--ink-3);
  color: var(--ink-2);
  font: var(--t-body);
}
.notice__icon { width: 16px; height: 16px; margin-top: 1px; color: var(--ink-3); }
.notice__text { flex: 1; min-width: 0; }
.notice__text strong { color: var(--ink); font-weight: 500; }
.notice > .btn,
.notice > .button-row { flex: none; align-self: center; }
.notice--info { box-shadow: inset 2px 0 0 var(--pgm); }
.notice--info .notice__icon { color: var(--pgm-ink); }
.notice--ok { box-shadow: inset 2px 0 0 var(--sig); }
.notice--ok .notice__icon { color: var(--sig); }
.notice--warn { box-shadow: inset 2px 0 0 var(--amber); background: var(--warn-panel); border-color: var(--warn-line); }
.notice--warn .notice__icon { color: var(--amber); }
.notice--danger { box-shadow: inset 2px 0 0 var(--red); background: var(--danger-panel); border-color: var(--danger-line); }
.notice--danger .notice__icon { color: var(--red); }

/* Leerer Zustand: erklärt, was hier erscheinen wird */
.empty {
  display: grid;
  justify-items: center;
  gap: 6px;
  padding: 36px 20px;
  text-align: center;
}
.empty__code { font: var(--t-label); letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-3); display: inline-flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.empty__title { font: 500 14px/1.35 var(--f-sans); color: var(--ink); }
.empty__text { max-width: 46ch; color: var(--ink-2); }
.empty .btn { margin-top: 10px; }

/* Laden */
.loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 28px 16px;
  font: var(--t-label);
  letter-spacing: var(--label-track);
  text-transform: uppercase;
  color: var(--ink-3);
}
.loading .led { background: var(--pgm); animation: ledBlink 1.1s steps(2, jump-none) infinite; }

.skel { display: grid; gap: 16px; }
.skel__head { display: grid; gap: 10px; max-width: 600px; padding: 6px 0 10px; }
.skel__pnl .pnl__h { min-height: 44px; }
.skel__bar--l { width: 100%; }
.skel__bar--m { width: 58%; }
.skel__bar--s { width: 132px; }
.skel__row { display: grid; grid-template-columns: 1.2fr 3fr 1fr; gap: 24px; padding: 14px; border-bottom: 1px solid var(--line); }
.skel__row:last-child { border-bottom: 0; }
.skel__bar { height: 10px; border-radius: 1px; background: var(--raised); animation: skelPulse 1.6s ease-in-out infinite; }
.skel__bar:nth-child(2) { animation-delay: 0.15s; }
.skel__bar:nth-child(3) { animation-delay: 0.3s; }
@keyframes skelPulse { 50% { opacity: 0.45; } }

/* ---------- Avatar ------------------------------------------------------------------------ */

.avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: var(--r1);
  background: var(--avatar-bg);
  object-fit: cover;
  font: 600 11px/1 var(--f-mono);
  color: var(--ink-2);
}
.avatar--sm { width: 20px; height: 20px; font-size: 10px; }
.avatar--lg { width: 40px; height: 40px; font-size: 15px; }

/* ---------- Dialoge -------------------------------------------------------------------------- */

.modal {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100dvh - 48px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.modal--wide { width: min(720px, calc(100vw - 32px)); }
.modal[open] { animation: popIn var(--dur-2) var(--ease-out); }
.modal::backdrop { background: rgba(4, 5, 7, 0.72); }
.modal__form { display: flex; flex-direction: column; max-height: calc(100dvh - 50px); }
.modal__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 8px 0 18px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  flex: none;
}
.modal__title { flex: 1; min-width: 0; font: 600 15px/1.3 var(--f-sans); overflow-wrap: anywhere; }
.modal__body { display: grid; gap: 16px; padding: 18px; overflow: auto; }
.modal__foot { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); flex: none; }
.modal__text { color: var(--ink-2); font: var(--t-body-l); overflow-wrap: anywhere; }
.modal__error { font: var(--t-small); color: var(--red); }
@keyframes popIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Seitliche Schublade (Details) */
.drawer {
  position: fixed;
  inset: 0 0 0 auto;
  width: min(560px, 100vw);
  height: 100%;
  max-width: 100vw;
  max-height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line-2);
  border-radius: 0;
  background: var(--panel);
  color: var(--ink);
  box-shadow: var(--shadow-pop);
}
.drawer--wide { width: min(760px, 100vw); }
.drawer[open] { display: flex; flex-direction: column; animation: drawerIn var(--dur-3) var(--ease-out); }
.drawer::backdrop { background: rgba(4, 5, 7, 0.6); }
.drawer__head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--bridge-h);
  padding: 0 8px 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--raised);
  flex: none;
}
.drawer__title { flex: 1; min-width: 0; font: var(--t-title); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawer__body { flex: 1; min-height: 0; overflow: auto; padding: 20px; display: grid; gap: 16px; align-content: start; }
.drawer__foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--line); flex: none; }
@keyframes drawerIn { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- Toasts ---------------------------------------------------------------------------- */

.toasts {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(400px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: start;
  gap: 10px;
  padding: 11px 6px 12px 14px;
  overflow: hidden;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  background: var(--float);
  box-shadow: var(--shadow-pop), inset 2px 0 0 var(--ink-3);
  color: var(--ink);
  pointer-events: auto;
  animation: popIn var(--dur-2) var(--ease-out);
  transition: opacity var(--dur-2), transform var(--dur-2);
}
.toast__icon { width: 16px; height: 16px; margin-top: 1px; color: var(--ink-3); }
.toast__text { min-width: 0; padding-top: 1px; overflow-wrap: anywhere; }
.toast__action {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--pgm-line);
  border-radius: var(--r1);
  background: none;
  font: 500 12px/1 var(--f-sans);
  color: var(--pgm-ink);
  cursor: pointer;
  white-space: nowrap;
}
.toast__action:hover { background: var(--pgm-wash); color: var(--ink); }
.toast__close {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: var(--r1);
  background: none;
  color: var(--ink-3);
  cursor: pointer;
}
.toast__close:hover { background: var(--raised); color: var(--ink); }
.toast__close .icon { width: 14px; height: 14px; }
.toast__prog { position: absolute; left: 0; right: 0; bottom: 0; height: 2px; background: var(--line-2); transform-origin: left center; animation: prog linear forwards; }
.toast--ok { box-shadow: var(--shadow-pop), inset 2px 0 0 var(--sig); }
.toast--ok .toast__icon { color: var(--sig); }
.toast--info { box-shadow: var(--shadow-pop), inset 2px 0 0 var(--pgm); }
.toast--info .toast__icon { color: var(--pgm-ink); }
.toast--warn { box-shadow: var(--shadow-pop), inset 2px 0 0 var(--amber); }
.toast--warn .toast__icon { color: var(--amber); }
.toast--error { box-shadow: var(--shadow-pop), inset 2px 0 0 var(--red); }
.toast--error .toast__icon { color: var(--red); }
.toast.is-leaving { opacity: 0; transform: translateY(4px); }
@keyframes prog { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* ---------- Menü (Popover) ---------------------------------------------------------------------- */

.menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: var(--z-menu);
  min-width: 248px;
  padding: 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  background: var(--panel);
  box-shadow: var(--shadow-pop);
  animation: popIn var(--dur-2) var(--ease-out);
}
.menu__head { display: grid; gap: 3px; padding: 8px 10px 10px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.menu__name { font: 500 13px/1.3 var(--f-sans); color: var(--ink); overflow-wrap: anywhere; }
.menu__sub { font: 400 11.5px/1.3 var(--f-mono); color: var(--ink-3); overflow-wrap: anywhere; }
.menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--r1);
  background: none;
  font: 400 13px/1 var(--f-sans);
  color: var(--ink-2);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu__item .icon { color: var(--ink-3); }
.menu__item:hover,
.menu__item:focus-visible { background: var(--raised); color: var(--ink); outline: none; }
.menu__item--danger:hover,
.menu__item--danger:focus-visible { color: var(--red); }
.menu__item--danger:hover .icon { color: var(--red); }
.menu__sep { height: 1px; margin: 6px 0; background: var(--line); }

/* ---------- Diagramme ------------------------------------------------------------------------------ */

/* Säulendiagramm (ui.chart.columns) in HTML: Schrift und Achsen bleiben auf jeder Breite gleich groß.
   --cc-h: Höhe der Zeichenfläche, --cc-gutter: Platz für die Y-Achse, --n: Anzahl Säulen (setzt das Skript),
   --h: Höhe einer Säule in %, --x/--y: Position des Tooltips (0–1).                                          */
.cc {
  --cc-h: 248px;
  --cc-gutter: 56px;
  --cc-top: 22px;
  --cc-right: 18px;
  position: relative;
  padding: var(--cc-top) var(--cc-right) 6px 0;
}
.cc--lg { --cc-h: 300px; }
.cc--sm { --cc-h: 216px; }
.cc__plot { position: relative; height: var(--cc-h); margin-left: var(--cc-gutter); }
.cc__grid { position: absolute; inset: 0; pointer-events: none; }
.cc__tick { position: absolute; left: 0; right: 0; height: 0; border-top: 1px solid var(--chart-grid); }
.cc__tick--0 { border-top-color: var(--chart-axis); }
.cc__tick span {
  position: absolute;
  right: calc(100% + 10px);
  top: 0;
  transform: translateY(-50%);
  font: 400 11px/1 var(--f-mono);
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.cc__cols { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.cc__col {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  min-width: 0;
  outline: none;
  cursor: crosshair;
  -webkit-tap-highlight-color: transparent;
}
.cc__col:focus-visible { background: var(--pgm-soft); box-shadow: inset 0 -2px 0 var(--pgm-ink); }
.cc__bar {
  width: min(24px, 56%);
  height: calc(var(--h) * 1%);
  min-height: 2px;
  border-radius: 4px 4px 0 0;
  background: var(--chart-bar);
  transition: background-color var(--dur-1);
}
.cc__col.is-now .cc__bar { background: var(--chart-now); }
.cc__col.is-h .cc__bar { background: var(--chart-bar-hi); }
.cc__col.is-now.is-h .cc__bar { background: var(--chart-now-hi); }
.cc__dl {
  position: absolute;
  bottom: calc(var(--h) * 1% + 6px);
  left: 50%;
  transform: translateX(-50%);
  font: 500 11px/1 var(--f-mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.cc__x { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); margin-left: var(--cc-gutter); padding-top: 8px; }
.cc__x span { min-width: 0; text-align: center; font: 400 11px/1.35 var(--f-mono); color: var(--ink-3); white-space: nowrap; }
.cc__x span.is-skip { visibility: hidden; }
.cc__x small { display: block; font-size: 10.5px; }
.cc__empty {
  position: absolute;
  inset: 0 8% 0;
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--ink-2);
  font: var(--t-small);
  pointer-events: none;
}
.cc.is-empty .cc__x { opacity: 0.6; }
/* Tooltip über der Säule; am linken/rechten Rand nach innen versetzt */
.cc__tip {
  left: calc(var(--cc-gutter) + (100% - var(--cc-gutter) - var(--cc-right)) * var(--x, 0.5));
  top: calc(var(--cc-top) + var(--cc-h) * (1 - var(--y, 0)) - 10px);
}
.cc__tip b { white-space: nowrap; }
.cc__tip.is-start { transform: translate(-14%, -100%); }
.cc__tip.is-end { transform: translate(-86%, -100%); }

.tip {
  position: absolute;
  z-index: var(--z-tip);
  min-width: 170px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--r1);
  background: var(--float);
  font: 400 12px/1.5 var(--f-mono);
  color: var(--ink-2);
  transform: translate(-50%, -100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-1);
}
.tip.is-on { opacity: 1; }
.tip b { display: block; margin-bottom: 4px; font-weight: 500; color: var(--ink); }
.tip .row { display: flex; justify-content: space-between; gap: 16px; }
.tip .row span:last-child { color: var(--ink); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font: 400 11.5px var(--f-mono); color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 6px; border-radius: 1px; vertical-align: -1px; }
.chart-t { padding: 0 14px 12px; }
.chart-t summary { list-style: none; cursor: pointer; font: 500 11.5px var(--f-mono); color: var(--ink-3); }
.chart-t summary::-webkit-details-marker { display: none; }
.chart-t summary::before { content: '+ '; }
.chart-t[open] summary::before { content: '− '; }
.chart-t summary:hover { color: var(--ink); }
.chart-t table { margin-top: 8px; border-collapse: collapse; font: 400 12px var(--f-mono); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.chart-t td,
.chart-t th { padding: 3px 16px 3px 0; text-align: right; font-weight: 400; }
.chart-t th { text-align: left; color: var(--ink-3); }
.chart-t thead th { text-align: right; }
.chart-t thead th:first-child { text-align: left; }

/* Anteilsbalken (gestapelt, 2px Flächenlücke) */
.dist { display: flex; gap: 2px; height: 14px; border-radius: var(--r1); overflow: hidden; background: var(--chart-track); }
.dist i { display: block; height: 100%; min-width: 2px; }
.dist-l { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; margin: 8px 0 0; font: 400 11px var(--f-mono); color: var(--ink-3); }
.sw { display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 1px; vertical-align: -1px; }

/* ---------- Speicherleiste -------------------------------------------------------------------------- */

.savebar {
  position: sticky;
  bottom: 12px;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 10px 14px;
  border: 1px solid var(--line-2);
  border-radius: var(--r2);
  background: var(--raised);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.savebar__note { margin-right: auto; font: 400 12px/1.3 var(--f-mono); color: var(--ink-3); }
.savebar__note.is-dirty { color: var(--amber); }

/* ---------- Kreuzschiene (Plan-Matrix) --------------------------------------------------------------- */

.matrix { width: 100%; min-width: 620px; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.matrix col.matrix__f { width: 34%; }
.matrix thead th { padding: 18px 16px 16px; border-bottom: 1px solid var(--line-2); border-left: 1px solid var(--line); vertical-align: bottom; text-align: left; font-weight: 400; }
.matrix thead th:first-child { border-left: 0; }
.matrix__plan { display: flex; align-items: center; gap: 8px; font: 500 11px/1 var(--f-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-2); }
.matrix__price { display: block; margin-top: 12px; font: 600 32px/1 var(--f-cond); letter-spacing: -0.01em; color: var(--ink); font-variant-numeric: tabular-nums; }
.matrix__per { display: block; margin-top: 6px; font: 400 11.5px/1.3 var(--f-mono); color: var(--ink-3); }
.matrix tbody th { padding: 10px 16px; border-bottom: 1px solid var(--line); text-align: left; font: 400 13.5px/1.35 var(--f-sans); color: var(--ink-2); }
.matrix td { padding: 10px 16px; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line); font: 500 12.5px/1.35 var(--f-mono); color: var(--ink); font-variant-numeric: tabular-nums; }
.matrix tr.matrix__grp th { padding: 18px 16px 8px; }
.matrix tbody tr:hover th { color: var(--ink); }
.matrix tbody tr:hover td { background: var(--hover); }
.matrix .is-current { background: rgba(91, 141, 239, 0.04); }
.matrix thead th.is-current { box-shadow: inset 0 2px 0 var(--pgm); }
.matrix tfoot td { padding: 14px 16px 16px; border-bottom: 0; vertical-align: top; font: var(--t-small); }
.matrix tfoot td:first-child { border-left: 0; color: var(--ink-3); }
.matrix tfoot .btn { width: 100%; }
.matrix__note { margin-top: 8px; font: var(--t-small); color: var(--ink-3); }
.xp { display: inline-block; width: 10px; height: 10px; border-radius: 1px; background: var(--xp-off); box-shadow: inset 0 0 0 1px var(--xp-off-line); vertical-align: middle; }
.xp.on { background: var(--sig); box-shadow: 0 0 0 2px rgba(65, 192, 126, 0.12); }

/* ---------- Bewegung reduzieren -------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
  .toast__prog { display: none; }
}

/* ---------- Schmale Bildschirme -------------------------------------------------------------------- */

@media (max-width: 720px) {
  .fields--2,
  .fields--3 { grid-template-columns: minmax(0, 1fr); }
  /* KPI-Leisten als 2er-Raster mit Haarlinie zwischen den Zeilen */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .kpi__v { font-size: 26px; }
  /* Kreuzschiene kompakt wie auf der Website; der Rest scrollt seitlich im Paneel */
  .matrix { min-width: 540px; }
  .matrix thead th { padding: 14px 8px 12px; }
  .matrix thead th:first-child { padding-left: 12px; }
  .matrix__plan { font-size: 10px; letter-spacing: 0.05em; }
  .matrix__price { margin-top: 8px; font-size: 21px; white-space: nowrap; }
  .matrix__per { font-size: 10px; }
  .matrix tbody th { padding: 9px 12px; font-size: 12.5px; }
  .matrix td { padding: 9px 8px; font-size: 11.5px; }
  .matrix tfoot td { padding: 12px 8px; }
  .matrix tfoot .btn { padding: 0 6px; font-size: 12px; }
  .matrix tfoot .btn .icon { display: none; }
  .search .input { width: 100%; }
  .toasts { right: 12px; left: 12px; width: auto; }
  .kv__row { grid-template-columns: minmax(84px, 110px) 12px minmax(0, 1fr); }
  .stats--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Säulendiagramm: flacher, schmalere Y-Achse – die Schrift bleibt lesbar groß */
  .cc { --cc-h: 200px; --cc-gutter: 44px; --cc-right: 12px; }
  .cc--lg { --cc-h: 220px; }
  .cc--sm { --cc-h: 150px; }
  .cc__tick span { right: calc(100% + 7px); font-size: 10.5px; }
  .cc__x span { font-size: 10.5px; }
  .cc__x small { font-size: 10px; }
  .chart-t { overflow-x: auto; }
}

@media (max-width: 440px) {
  .savebar__note { flex: 1 1 100%; }
  .inline-form { flex-wrap: wrap; }
  .modal__foot .btn { flex: 1 1 auto; }
}
