/* RM1 Rechte-Matrix: Übersicht je Person und Matrix (Zeilen = Rechte, Spalten = Rolle und Einzelregel). Ab 900 px drei Spalten, darunter untereinander. */
.rm-zurueck { margin: 0 0 4px; font-size: 14px; }
.rm-zurueck a::before { content: "‹ "; }
.rm-name { overflow-wrap: anywhere; }
.rm-lead { max-width: 68ch; margin: 0 0 20px; color: var(--muted); }

/* Übersicht */
.rm-personen { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--rule); }
.rm-person { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr) auto; gap: 12px 20px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--hairline); }
.rm-p-wer { display: flex; flex-direction: column; min-width: 0; }
.rm-p-name { font-weight: 600; overflow-wrap: anywhere; }
.rm-p-rolle, .rm-p-keine { color: var(--muted); font-size: 14px; }
.rm-chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; }
.rm-chip { display: inline-flex; gap: 4px; align-items: center; padding: 2px 10px; border: 1px solid var(--rule); border-radius: 999px; background: var(--surface); font-size: 13.5px; max-width: 100%; overflow-wrap: anywhere; }
.rm-chip.is-plus { border-color: var(--ok); color: var(--ok); }
.rm-chip.is-minus { border-color: var(--crit); color: var(--crit); }
@media (max-width: 720px) {
  .rm-person { grid-template-columns: minmax(0, 1fr); }
  .rm-person .btn { justify-self: start; min-height: 44px; }
}

/* Matrix */
.rm-form { margin-top: 12px; }
.rm-gruppe { margin: 0 0 16px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); }
.rm-gruppe > summary { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 0 16px; cursor: pointer; font-weight: 700; list-style: none; }
.rm-gruppe > summary::-webkit-details-marker { display: none; }
.rm-gruppe > summary::before { content: ""; width: 8px; height: 8px; margin-right: 4px; border-right: 2px solid var(--ink); border-bottom: 2px solid var(--ink); transform: rotate(-45deg); transition: transform 160ms var(--ease-out); flex: none; }
.rm-gruppe[open] > summary::before { transform: rotate(45deg); }
.rm-g-titel { flex: 1; }
.rm-g-zahl { color: var(--brand); font-size: 14px; font-weight: 600; }
.rm-kopf { display: grid; grid-template-columns: minmax(0, 1fr) 7rem minmax(0, 19rem); gap: 16px; padding: 6px 16px; border-top: 1px solid var(--hairline); color: var(--muted); font-size: 13px; font-weight: 600; }
.rm-zeilen { list-style: none; margin: 0; padding: 0; }
.rm-zeile { display: grid; grid-template-columns: minmax(0, 1fr) 7rem minmax(0, 19rem); grid-template-areas: "recht std wahl" "recht std erg"; gap: 4px 16px; align-items: center; padding: 10px 16px; border-top: 1px solid var(--hairline); }
.rm-zeile[hidden] { display: none; }
.rm-recht { grid-area: recht; display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; min-width: 0; }
.rm-titel { overflow-wrap: anywhere; }
.rm-std { grid-area: std; }
.rm-wahl { grid-area: wahl; }
.rm-ergebnis { grid-area: erg; margin: 0; font-size: 13.5px; color: var(--muted); }
.rm-zeile.is-eigen { background: #f2f3fd; box-shadow: inset 3px 0 0 var(--brand); }
.rm-zeile.is-geaendert .rm-ergebnis::after { content: " · nicht gespeichert"; color: var(--warn); }
.rm-tarif { padding: 0 8px; border: 1px solid var(--violet); border-radius: 999px; color: var(--violet); font-size: 12.5px; }
.rm-wert { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.rm-wert.is-ja { color: var(--ok); }
.rm-wert.is-ja::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--ok); }
.rm-wert.is-nein { color: var(--muted); }
.rm-wert.is-nein::before { content: ""; width: 10px; height: 2px; background: var(--muted); }
.rm-grund { color: var(--muted); }

/* Dreifach-Schalter: echte Optionsfelder, je Feld mindestens 44 px. */
fieldset.rm-wahl { display: flex; gap: 0; margin: 0; padding: 0; border: 0; min-width: 0; }
.rm-opt { position: relative; flex: 1 1 0; display: flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 10px; border: 1px solid var(--control); background: var(--surface); cursor: pointer; font-size: 14px; text-align: center; transition: background-color 150ms var(--ease-out), border-color 150ms var(--ease-out); }
.rm-opt + .rm-opt { margin-left: -1px; }
.rm-opt:first-of-type { border-radius: 6px 0 0 6px; }
.rm-opt:last-of-type { border-radius: 0 6px 6px 0; }
.rm-opt input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.rm-opt:has(input:checked) { z-index: 1; border-color: var(--brand); background: #e3e6fc; font-weight: 700; box-shadow: inset 0 0 0 1px var(--brand); }
.rm-opt:has(input[value="ja"]:checked) { border-color: var(--ok); background: #e3f3eb; box-shadow: inset 0 0 0 1px var(--ok); }
.rm-opt:has(input[value="nein"]:checked) { border-color: var(--crit); background: #fbe9e7; box-shadow: inset 0 0 0 1px var(--crit); }
.rm-opt:has(input:checked) span::before { content: "✓ "; }
.rm-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; z-index: 2; }
.rm-opt.is-aus { cursor: not-allowed; color: var(--muted); background: repeating-linear-gradient(135deg, var(--surface) 0 6px, #f1f2f8 6px 8px); }
.rm-opt.is-aus input { cursor: not-allowed; }
.rm-fest { color: var(--muted); font-size: 14px; }

/* Vorschau und Aktionsleiste */
.rm-vorschau { margin: 0 0 20px; padding: 16px 20px; border: 1px solid var(--brand); border-radius: 8px; background: #f2f3fd; }
.rm-vorschau:focus { outline: 2px solid var(--focus); outline-offset: 2px; }
.rm .rm-vorschau h2, .sheet .rm .rm-vorschau h2 { margin: 0 0 8px; font-size: 18px; overflow-wrap: anywhere; }
.rm-liste { margin: 0 0 12px; padding-left: 20px; }
.rm-liste li { margin: 4px 0; }
.rm-v-gruppe { color: var(--muted); font-size: 13.5px; }
.rm-v-wechsel, .rm-v-wirkung { margin-left: 8px; }
.rm-plus { color: var(--ok); }
.rm-minus { color: var(--crit); }
.rm-aktionen { display: flex; flex-wrap: wrap; gap: 8px; }
.rm-v-hinweis { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.rm-leiste { position: sticky; bottom: 0; z-index: 3; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin: 8px 0 0; padding: 12px 16px; border: 1px solid var(--rule); border-radius: 8px; background: var(--surface); box-shadow: 0 -4px 12px rgba(16, 19, 52, 0.08); }
.rm-offen { flex: 1 1 12rem; margin: 0; font-weight: 600; }
.rm-offen:empty::before { content: "Keine offenen Änderungen"; font-weight: 400; color: var(--muted); }
.rm-leiste .btn, .rm-aktionen .btn { min-height: 44px; }

@media (max-width: 900px) {
  .rm-kopf { display: none; }
  .rm-zeile { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "recht std" "wahl wahl" "erg erg"; gap: 8px 12px; }
  .rm-std::before { content: "Rolle: "; color: var(--muted); font-size: 13px; }
  .rm-std .visually-hidden { display: none; }
}
@media (max-width: 720px) {
  /* Platz für den runden Hilfe-Knopf unten rechts, der sonst den letzten Knopf der Leiste verdeckt. */
  .rm-leiste { padding-right: 64px; }
}
@media (max-width: 480px) {
  .rm-gruppe > summary, .rm-zeile, .rm-kopf { padding-left: 12px; padding-right: 12px; }
  .rm-vorschau { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .rm-gruppe > summary::before, .rm-opt { transition: none; }
}
