/* Flussdiagramm-Editor */

.fd {
  --fd-akzent: #024f7f;
  --fd-akzent-hell: #e1edf6;
  --fd-rahmen: #c9d4dd;
  --fd-leiste: #fff;
  --fd-schrift: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  position: relative;
  display: flex;
  flex-direction: column;
  height: min(70vh, 600px);
  min-height: 320px;
  margin: 1em 0;
  border: 1px solid var(--fd-rahmen);
  border-radius: 8px;
  overflow: hidden;
  background: #f6f8fa;
  color: #1d2a35;
  font: 15px/1.3 var(--fd-schrift);
  text-align: left;
  white-space: normal;
  container-type: inline-size;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

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

.fd [hidden] {
  display: none !important;
}

.fd-vollversion {
  height: calc(var(--tool__content_height, 100vh) - 112px);
  min-height: 420px;
  margin: 12px 0;
}

.fd-vollbild {
  position: fixed !important;
  inset: 0;
  z-index: 10000;
  height: auto !important;
  margin: 0;
  border: 0;
  border-radius: 0;
}

html.fd-seite-gesperrt,
html.fd-seite-gesperrt body {
  overflow: hidden;
}

/* Leisten */

.fd-hauptleiste {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  background: var(--fd-leiste);
  border-bottom: 1px solid #dde4ea;
  overflow-x: auto;
  scrollbar-width: none;
}

.fd .fd-knopf {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex: none;
  min-width: 44px;
  height: 44px;
  margin: 0;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  box-shadow: none;
  color: #1d3a52;
  font: 14px/1 var(--fd-schrift);
  text-transform: none;
  letter-spacing: normal;
  cursor: pointer;
  touch-action: manipulation;
}

.fd .fd-knopf:hover {
  background: #eef3f7;
}

.fd .fd-knopf:focus-visible {
  outline: 2px solid var(--fd-akzent);
  outline-offset: 1px;
}

.fd .fd-knopf[disabled] {
  opacity: 0.35;
  cursor: default;
  background: transparent;
}

.fd .fd-knopf[aria-pressed="true"],
.fd .fd-knopf.fd-aktiv {
  background: var(--fd-akzent-hell);
  border-color: var(--fd-akzent);
  color: var(--fd-akzent);
}

.fd .fd-knopf > svg {
  width: 22px;
  height: 22px;
  flex: none;
}

.fd-knopf-text {
  white-space: nowrap;
}

/* selbsterklärende Symbole ohne Beschriftung, der Text steht im Tooltip */
.fd-hauptleiste :is([data-aktion="rueckgaengig"], [data-aktion="wiederholen"], [data-aktion="verkleinern"], [data-aktion="allesAnzeigen"], [data-aktion="vergroessern"], [data-aktion="einklappen"], [data-aktion="vollbild"]) .fd-knopf-text {
  display: none;
}

.fd .fd-hauptleiste :is([data-aktion="rueckgaengig"], [data-aktion="wiederholen"], [data-aktion="verkleinern"], [data-aktion="allesAnzeigen"], [data-aktion="vergroessern"], [data-aktion="einklappen"], [data-aktion="vollbild"]) {
  padding: 0;
}

@container (max-width: 860px) {
  .fd-hauptleiste .fd-knopf:not([data-aktion="durchspielen"]) .fd-knopf-text {
    display: none;
  }
  .fd .fd-hauptleiste .fd-knopf:not([data-aktion="durchspielen"]) {
    padding: 0;
  }
}

@container (max-width: 520px) {
  .fd-hauptleiste .fd-knopf-text {
    display: none;
  }
  .fd .fd-hauptleiste .fd-knopf {
    padding: 0;
  }
}

.fd-trenner {
  flex: none;
  width: 1px;
  height: 28px;
  margin: 0 4px;
  background: #dde4ea;
}

.fd-luecke {
  flex: 1;
}

.fd-koerper {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

.fd-symbolleiste {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  background: var(--fd-leiste);
  border-right: 1px solid #dde4ea;
  overflow-y: auto;
}

.fd .fd-symbol {
  flex-direction: column;
  width: 86px;
  height: auto;
  min-height: 60px;
  padding: 6px 2px;
  gap: 3px;
  font-size: 12px;
  touch-action: none;
}

.fd .fd-symbol > svg {
  width: 50px;
  height: 27px;
}

.fd-symbolleiste .fd-trenner {
  width: 60px;
  height: 1px;
  margin: 4px 0;
}

@container (max-width: 640px) {
  .fd-koerper {
    flex-direction: column-reverse;
  }
  .fd-symbolleiste {
    flex-direction: row;
    justify-content: flex-start;
    border-right: 0;
    border-top: 1px solid #dde4ea;
    overflow-x: auto;
    overflow-y: hidden;
  }
  .fd .fd-symbol {
    width: 74px;
  }
  /* zentriert, solange alles passt; sonst von links scrollbar */
  .fd-symbolleiste > :first-child {
    margin-left: auto;
  }
  .fd-symbolleiste > :last-child {
    margin-right: auto;
  }
  .fd-symbolleiste .fd-trenner {
    width: 1px;
    height: 40px;
    margin: 0 2px;
  }
}

.fd-vorschau-form {
  fill: #fff;
  stroke: currentColor;
  stroke-width: 1.8;
}

/* Arbeitsfläche */

.fd-flaeche {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  outline: none;
  touch-action: none;
  background-color: #fff;
  background-image: radial-gradient(circle, #d9e1e7 1px, transparent 1.2px);
  background-size: 20px 20px;
}

.fd-flaeche:focus-visible {
  box-shadow: inset 0 0 0 2px var(--fd-akzent);
}

.fd-anzeige .fd-flaeche {
  touch-action: pan-x pan-y;
  background-image: none;
}

.fd-svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.fd-svg text {
  font-family: var(--fd-schrift);
  font-size: 15px;
  fill: #1a1a1a;
}

.fd-form {
  fill: #fff;
  stroke: #333;
  stroke-width: 1.6;
}

.fd-form-linie {
  fill: none;
  stroke: #333;
  stroke-width: 1.4;
}

.fd-bearbeiten .fd-knoten {
  cursor: grab;
}

.fd-knoten.fd-ausgewaehlt .fd-form {
  stroke: var(--fd-akzent) !important;
  stroke-width: 3 !important;
}

.fd-knoten.fd-verbinden-quelle .fd-form {
  stroke: var(--fd-akzent) !important;
  stroke-width: 3 !important;
  stroke-dasharray: 7 4;
}

.fd-knoten.fd-ziel .fd-form {
  stroke: var(--fd-akzent) !important;
  stroke-width: 3.5 !important;
  fill: var(--fd-akzent-hell) !important;
}

.fd-kante-linie {
  fill: none;
  stroke: #333;
  stroke-width: 1.6;
}

.fd-kante-treffer {
  fill: none;
  stroke: transparent;
  stroke-width: 20;
  pointer-events: stroke;
}

.fd-bearbeiten .fd-kante {
  cursor: pointer;
}

.fd-kante.fd-ausgewaehlt .fd-kante-linie {
  stroke: var(--fd-akzent);
  stroke-width: 2.6;
}

.fd-svg .fd-kante-text {
  font-size: 14px;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4px;
  stroke-linejoin: round;
}

.fd-pfeilspitze {
  fill: #333;
}

.fd-pfeilspitze-akzent {
  fill: var(--fd-akzent);
}

.fd-anfasser,
.fd-kantenende {
  fill: #fff;
  stroke: var(--fd-akzent);
  stroke-width: 2;
}

.fd-anfasser-plus {
  stroke: var(--fd-akzent);
  stroke-width: 1.6;
  pointer-events: none;
}

.fd-anfasser-treffer {
  fill: transparent;
  cursor: crosshair;
}

.fd-ziehlinie {
  fill: none;
  stroke: var(--fd-akzent);
  stroke-width: 2;
  stroke-dasharray: 6 4;
  pointer-events: none;
}

.fd-hilfslinie {
  stroke: #e67e22;
  stroke-width: 1;
  stroke-dasharray: 4 4;
  vector-effect: non-scaling-stroke;
  pointer-events: none;
}

/* Kontextleiste, Menüs, Texteingabe, Hinweise */

.fd-kontextleiste,
.fd-menue {
  position: absolute;
  z-index: 5;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--fd-rahmen);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.16);
}

.fd-menue {
  z-index: 6;
  flex-wrap: wrap;
  max-width: 340px;
}

.fd .fd-menue .fd-symbol {
  width: 104px;
  white-space: normal;
  text-align: center;
  line-height: 1.15;
}

.fd .fd-farbfeld span {
  display: block;
  width: 26px;
  height: 26px;
  border: 2px solid #999;
  border-radius: 50%;
}

.fd-texteingabe {
  position: absolute;
  z-index: 7;
  margin: 0;
  padding: 6px 8px;
  border: 2px solid var(--fd-akzent);
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  color: #1a1a1a;
  font: 16px/1.25 var(--fd-schrift);
  text-align: center;
  resize: none;
  overflow: hidden;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.fd-hinweis {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100% - 24px);
  padding: 8px 14px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: rgba(29, 42, 53, 0.94);
  color: #fff;
  font-size: 14px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

.fd-hinweis button {
  flex: none;
  min-height: 32px;
  margin: 0;
  padding: 0 4px;
  border: 0;
  background: none;
  color: #fccb00;
  font: inherit;
  font-weight: 600;
  text-decoration: underline;
  cursor: pointer;
}

.fd-geist {
  position: fixed;
  z-index: 10001;
  width: 108px;
  height: 58px;
  color: #888;
  pointer-events: none;
  opacity: 0.85;
}

.fd-geist.fd-geist-ok {
  color: #024f7f;
}

.fd-geist svg {
  width: 100%;
  height: 100%;
}

/* Anzeigen als Bild: schlank auf der Seite, Vollansicht bei Bedarf */

.fd-bildmodus {
  min-height: 0;
  margin: 1em auto;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.fd-bildmodus .fd-hauptleiste,
.fd-bildmodus .fd-spielleiste,
.fd-bildmodus .fd-protokoll {
  display: none !important;
}

.fd-bildmodus .fd-flaeche {
  background: none;
  cursor: pointer;
  touch-action: auto;
}

.fd-bildmodus .fd-flaeche:focus-visible {
  box-shadow: 0 0 0 2px var(--fd-akzent);
  border-radius: 4px;
}

.fd .fd-bild-oeffnen {
  position: absolute;
  top: 0;
  z-index: 4;
  display: none;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(29, 42, 53, 0.82);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  cursor: pointer;
}

.fd .fd-bild-oeffnen svg {
  width: 22px;
  height: 22px;
}

.fd-bildmodus.fd-symbol-sichtbar .fd-bild-oeffnen,
.fd-bildmodus .fd-flaeche:focus-visible .fd-bild-oeffnen {
  display: flex;
}

@media (hover: hover) {
  .fd-bildmodus .fd-flaeche:hover .fd-bild-oeffnen {
    display: flex;
  }
}

/* Durchspielen */

.fd {
  --fd-spiel: #b8520e;
  --fd-spiel-hell: #fdebd9;
}

.fd-spielt .fd-symbolleiste {
  display: none;
}

.fd-spielt .fd-hinweis {
  bottom: 96px;
}

.fd-knoten.fd-aktuell .fd-form {
  stroke: var(--fd-spiel) !important;
  stroke-width: 4 !important;
  fill: var(--fd-spiel-hell) !important;
}

.fd-knoten.fd-haengt .fd-form {
  stroke: #c0392b !important;
  stroke-dasharray: 8 4;
}

.fd-knoten.fd-besucht .fd-form {
  stroke-width: 2.2;
}

.fd-kante.fd-zuletzt .fd-kante-linie {
  stroke: var(--fd-spiel);
  stroke-width: 3;
}

.fd-kante.fd-wahl .fd-kante-linie {
  stroke: var(--fd-spiel);
  stroke-width: 2.4;
  stroke-dasharray: 7 4;
}

.fd-spielt .fd-kante.fd-wahl,
.fd-spielt .fd-kante.fd-wahl + * {
  cursor: pointer;
}

.fd-pfeilspitze-spiel {
  fill: var(--fd-spiel);
}

.fd-spielmarke {
  fill: var(--fd-spiel);
}

.fd-zaehler rect {
  fill: var(--fd-spiel);
}

.fd-svg .fd-zaehler text {
  fill: #fff;
  font-size: 12px;
  font-weight: 600;
}

.fd-spielleiste {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.97);
  border-top: 2px solid var(--fd-spiel);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.08);
}

.fd-spiel-knoepfe {
  display: flex;
  gap: 2px;
}

.fd-spiel-text {
  flex: 1 1 180px;
  min-width: 0;
  font-size: 15px;
}

.fd-spiel-hinweis {
  display: block;
  margin-top: 2px;
  color: #6b4a2b;
  font-size: 13px;
}

.fd-spiel-problem {
  color: #a93226;
  font-weight: 600;
}

.fd-spiel-haupte {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fd .fd-spiel-haupt {
  min-width: 96px;
  height: 48px;
  padding: 0 16px;
  background: var(--fd-spiel);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
}

.fd .fd-spiel-haupt:hover {
  background: #9a440b;
}

.fd .fd-spiel-haupt > svg {
  width: 20px;
  height: 20px;
}

.fd-knoten.fd-pruefmarke .fd-form {
  stroke: #b9770e !important;
  stroke-width: 3 !important;
  stroke-dasharray: 6 4;
}

.fd-pruefliste {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  width: min(300px, calc(100% - 16px));
  max-height: calc(100% - 16px);
  background: #fff;
  border: 1px solid var(--fd-rahmen);
  border-left: 4px solid #b9770e;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.fd-pruef-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 2px 12px;
  border-bottom: 1px solid #e3e8ec;
}

.fd-pruefliste ol {
  margin: 0;
  padding: 4px 0;
  overflow-y: auto;
  list-style: none;
  font-size: 14px;
}

.fd-pruefliste li > button,
.fd-pruefliste li > span {
  display: block;
  width: 100%;
  margin: 0;
  padding: 7px 12px;
  border: 0;
  background: none;
  color: inherit;
  border-radius: 0;
  box-shadow: none;
  font: inherit;
  line-height: 1.35;
  text-align: left;
}

@container (max-width: 560px) {
  .fd-pruefliste {
    top: auto;
    left: 8px;
    bottom: 8px;
    width: auto;
    max-height: 45%;
  }
}

.fd-pruefliste li > button {
  cursor: pointer;
}

.fd-pruefliste li > button:hover,
.fd-pruefliste li > button:focus-visible {
  background: #fdf2e0;
}

.fd-pruef-leer {
  margin: 0;
  padding: 10px 12px 12px;
  font-size: 14px;
  line-height: 1.4;
}

.fd-protokoll {
  position: absolute;
  top: 8px;
  right: 8px;
  bottom: 76px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  width: min(280px, calc(100% - 16px));
  background: #fff;
  border: 1px solid var(--fd-rahmen);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.14);
}

.fd-protokoll-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 4px 2px 12px;
  border-bottom: 1px solid #e3e8ec;
}

.fd-protokoll ol {
  flex: 1;
  margin: 0;
  padding: 6px 0;
  overflow-y: auto;
  list-style: none;
  font-size: 14px;
}

.fd-protokoll li {
  display: flex;
  gap: 8px;
  padding: 3px 12px;
}

.fd-protokoll li.fd-aktuell {
  background: var(--fd-spiel-hell);
  font-weight: 600;
}

.fd-nr {
  flex: none;
  min-width: 1.8em;
  color: #7a8790;
  text-align: right;
}

.fd-wahl-text {
  color: var(--fd-spiel);
  white-space: nowrap;
}

/* Ausklappmenü und Dialoge */

.fd-ausklapp {
  position: absolute;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 230px;
  padding: 4px;
  background: #fff;
  border: 1px solid var(--fd-rahmen);
  border-radius: 10px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.fd .fd-ausklapp .fd-knopf {
  justify-content: flex-start;
  width: 100%;
  padding: 0 12px;
  font-size: 15px;
}

.fd-dialog-ebene {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(20, 30, 40, 0.35);
}

.fd-dialog {
  display: flex;
  flex-direction: column;
  width: min(520px, 100%);
  max-height: 100%;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  -webkit-user-select: text;
  user-select: text;
}

.fd-dialog-kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 4px 4px 16px;
  border-bottom: 1px solid #e3e8ec;
}

.fd .fd-dialog h3,
.fd .fd-dialog h4 {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font-family: inherit;
  text-decoration: none;
}

.fd .fd-dialog h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.3;
}

.fd .fd-dialog h3::after,
.fd .fd-dialog h4::after {
  display: none;
}

.fd .fd-dialog h4 {
  margin: 16px 0 6px;
  font-size: 15px;
}

.fd-dialog-inhalt {
  padding: 4px 16px 16px;
  overflow-y: auto;
}

.fd .fd-dialog p {
  margin: 10px 0;
}

.fd-dialog-knoepfe {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.fd .fd-knopf-primaer {
  background: var(--fd-akzent);
  color: #fff;
  padding: 0 16px;
}

.fd .fd-knopf-primaer:hover {
  background: #013a5e;
}

.fd .fd-knopf-rahmen {
  border-color: var(--fd-rahmen);
  padding: 0 14px;
}

.fd-code,
.fd-eingabe {
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border: 1px solid var(--fd-rahmen);
  border-radius: 6px;
  background: #fff;
  color: #1a1a1a;
  font-size: 16px;
  -webkit-user-select: text;
  user-select: text;
}

.fd-code {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.4;
  resize: vertical;
}

.fd-zeile {
  display: flex;
  gap: 8px;
  align-items: center;
}

.fd-zeile .fd-eingabe {
  flex: 1;
  min-width: 0;
  height: 44px;
}

.fd-codewort {
  margin: 6px 0 12px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--fd-akzent);
}

.fd-dialog-meldung {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #eef4f8;
}

.fd-dialog-meldung.fd-fehler {
  background: #fdecea;
  color: #8e2a1f;
}

.fd-dialog-meldung ul {
  margin: 6px 0 0;
  padding-left: 20px;
}

.fd .fd-klein {
  color: #5b6770;
  font-size: 13px;
}

.fd-flaeche.fd-ablage {
  box-shadow: inset 0 0 0 3px var(--fd-akzent);
}

@container (max-width: 900px) {
  .fd-spielleiste .fd-spiel-knoepfe .fd-knopf-text,
  .fd-spielleiste .fd-spiel-ende .fd-knopf-text {
    display: none;
  }
  .fd-spielleiste .fd-knopf {
    padding: 0;
  }
  .fd .fd-spielleiste .fd-spiel-haupt {
    padding: 0 16px;
  }
}

/* sehr schmal (Handy hochkant) */

@container (max-width: 420px) {
  .fd .fd-symbol {
    width: 68px;
    min-height: 54px;
    font-size: 11px;
  }
  .fd .fd-symbol > svg {
    width: 40px;
    height: 22px;
  }
  /* Zoomen geht hier mit zwei Fingern */
  .fd-hauptleiste [data-aktion="verkleinern"],
  .fd-hauptleiste [data-aktion="vergroessern"] {
    display: none;
  }
}
