/* Baum-Editor im Build-Planer (js/planer-baum.js): Klassen be-* im Dialog .pl-dialog--baum.
   Farben, .btn, .pl-ik, .pl-chip, .pl-suche und .tt kommen aus style.css und planer.css. */
.pl-dialog--baum.be { width: min(1640px, calc(100vw - 24px)); height: calc(100dvh - 24px); max-height: none; }
.be .pl-dialog-kopf { padding-top: 8px; padding-bottom: 6px; }

/* ---------- Leiste über dem Baum: Suche, Zähler, Werkzeuge ---------- */
.be-leiste { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); }
.be-suche { flex: 1 1 200px; max-width: 320px; }
.be-suche input { min-height: 38px; padding-top: 6px; padding-bottom: 6px; font-size: 15px; }
.be-treffer { display: flex; align-items: center; gap: 6px; font-size: 13px; color: #cdbfae; white-space: nowrap; font-variant-numeric: tabular-nums; }
.be-treffer .pl-ik { width: 30px; height: 30px; font-size: 18px; }
.be-zaehler { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.be-z { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 10px; border: 1px solid var(--line-soft); border-radius: 6px; background: rgba(0, 0, 0, .28); white-space: nowrap; }
.be-z small { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--muted); }
.be-z b { font: 700 17px/1.2 var(--font-title); color: #f1e2cf; font-variant-numeric: tabular-nums; }
.be-z i { font-style: normal; font-size: 12.5px; color: var(--muted); }
.be-z.warn { border-color: #7a3a32; background: rgba(120, 40, 30, .22); }
.be-z.warn b { color: #f0b9b1; }
.be-werkzeug { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.be-werkzeug .btn--sm { min-height: 34px; white-space: nowrap; }
.be-werkzeug .btn:disabled { opacity: .4; cursor: default; filter: none; }
.be-zoom { display: inline-flex; gap: 4px; }
.be-zoom .pl-ik { width: 34px; height: 34px; font-size: 18px; }
.be-seite-knopf[aria-expanded="true"] { border-color: var(--accent); color: #fbe6cf; background: #3b2410; }
.be-wahlen { flex: 1 1 100%; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.be-wahlen[hidden] { display: none; }
.be-wahlgruppe { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.be-wahlgruppe > small { font-size: 12.5px; color: var(--muted); }
.be-wahlgruppe .pl-chip { min-height: 30px; }
.be-knapp { display: none; }   /* kurze Beschriftung, nur am Handy */
.be-wahlgruppe [data-be-modus="1"][aria-pressed="true"] { border-color: #e2683f; }
.be-wahlgruppe [data-be-modus="2"][aria-pressed="true"] { border-color: #62c07a; }

.be-meldung { flex: none; display: grid; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line-soft); background: rgba(200, 121, 47, .09); font-size: 13.5px; color: #e6d6c2; }
.be-meldung p { margin: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; }

/* ---------- Mitte: Baum und Seitenleiste ---------- */
.be-mitte { flex: 1; min-height: 0; display: flex; position: relative; }
.be-flaeche { flex: 1 1 0; min-width: 0; position: relative; }
.be-flaeche .baum:focus-visible { outline-offset: -2px; }
.be-seite { flex: none; width: 310px; min-height: 0; display: flex; flex-direction: column; border-left: 1px solid var(--line-soft); background: rgba(0, 0, 0, .22); }
.be-seite[hidden] { display: none; }
.be-reiter { flex: none; display: flex; align-items: stretch; border-bottom: 1px solid var(--line-soft); }
.be-reiter [role="tab"] { flex: 1 1 0; min-width: 0; padding: 10px 8px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font: 600 13.5px var(--font-ui); cursor: pointer; }
.be-reiter [role="tab"]:hover { color: #e6d6c2; }
.be-reiter [role="tab"][aria-selected="true"] { color: #fbe6cf; border-bottom-color: var(--accent); }
.be-seite-zu { display: none; align-self: center; margin: 0 6px; }
.be-seite-inhalt { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 12px 14px; }
.be-seite-info { margin: 0 0 10px; font-size: 12.5px; line-height: 1.45; color: var(--muted); }
.be-seite-leer { margin: 18px 4px; font-size: 14px; color: var(--muted); text-align: center; }
.be-seite-inhalt h3 { margin: 12px 0 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--gold); }
.be-seite-inhalt h3:first-child { margin-top: 0; }
.be-seite-inhalt h3 small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.be-werte, .be-punkte { list-style: none; margin: 0; padding: 0; }
.be-werte li { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(255, 255, 255, .05); font-size: 13.5px; line-height: 1.35; color: #b9c2f2; }
.be-werte li span { min-width: 0; overflow-wrap: anywhere; }
.be-werte li small { flex: none; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.be-punkt { display: flex; align-items: center; gap: 9px; width: 100%; padding: 5px 4px; border: 0; border-radius: 4px; background: transparent; color: #e6d6c2; font: inherit; font-size: 13.5px; line-height: 1.3; text-align: left; cursor: pointer; }
.be-punkt:hover { background: rgba(200, 121, 47, .14); }
.be-punkt i { flex: none; width: 28px; height: 28px; border-radius: 50%; background-repeat: no-repeat; box-shadow: 0 0 0 1px rgba(200, 160, 90, .5); }
.be-punkt span { min-width: 0; overflow-wrap: anywhere; }
.be-punkt small { display: block; font-size: 12px; color: #9aa3d6; }

/* ---------- Im Baum: kurze Meldung, Info-Leiste (Finger), Auswahlfenster ---------- */
.be-kurz { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 4; max-width: calc(100% - 24px); padding: 7px 14px; border-radius: 99px; border: 1px solid var(--line); background: rgba(11, 10, 9, .94); color: #f1e2cf; font-size: 13.5px; text-align: center; opacity: 0; pointer-events: none; transition: opacity .15s; }
.be-kurz.sichtbar { opacity: 1; }
.be-info { position: absolute; left: 8px; right: 8px; bottom: 8px; z-index: 4; max-width: 520px; margin: 0 auto; max-height: 58%; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 8px; background: rgba(15, 13, 11, .97); box-shadow: 0 8px 28px rgba(0, 0, 0, .6); overflow: hidden; }
.be-info-tt { min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.be-info-tt .tt { width: 100%; min-width: 0; max-width: none; border: 0; box-shadow: none; background: transparent; }
.be-info-fuss { flex: none; display: flex; align-items: center; gap: 8px; padding: 8px; border-top: 1px solid var(--line-soft); background: rgba(0, 0, 0, .3); }
.be-info-text { flex: 1 1 auto; min-width: 0; font-size: 13.5px; line-height: 1.3; color: #cdbfae; }
.be-info-fuss .btn { flex: none; min-height: 44px; padding-left: 18px; padding-right: 18px; }
.be-info-fuss .pl-ik { width: 44px; height: 44px; }

.be-wahl { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 5; width: min(520px, calc(100% - 20px)); max-height: calc(100% - 20px); display: flex; flex-direction: column; border: 1px solid #6b5230; border-radius: 8px; background: #14110e; box-shadow: 0 12px 40px rgba(0, 0, 0, .75); }
.be-wahl h3 { flex: none; display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line-soft); font: 700 16px/1.25 var(--font-title); color: #f1e2cf; }
.be-wahl h3 i { flex: none; width: 32px; height: 32px; border-radius: 50%; background-repeat: no-repeat; }
.be-wahl h3 span { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.be-wahl > p { flex: none; margin: 0; padding: 8px 14px 4px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.be-wahl ul { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; margin: 0; padding: 6px 10px 10px; display: grid; gap: 6px; }
.be-wahl-knopf { display: block; width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 6px; background: rgba(0, 0, 0, .3); color: #b9c2f2; font: inherit; font-size: 14px; line-height: 1.4; text-align: left; cursor: pointer; }
.be-wahl-knopf b { color: #f1e2cf; }
.be-wahl-knopf:hover:not(:disabled) { border-color: var(--accent); background: rgba(200, 121, 47, .1); }
.be-wahl-knopf[aria-pressed="true"] { border-color: var(--gold); background: rgba(201, 164, 92, .16); color: #e8ecff; }
.be-wahl-knopf:disabled { opacity: .45; cursor: default; }
.be-wahl-knopf small { display: block; margin-top: 2px; font-size: 12px; color: #d9a79f; }
.be-wahl-fuss { flex: none; display: flex; justify-content: flex-end; padding: 8px 10px; border-top: 1px solid var(--line-soft); }

.be-fuss > span { font-size: 13px; }

/* ---------- Handy ---------- */
@media (max-width: 700px) {
  .pl-dialog--baum.be { width: 100vw; height: 100dvh; }
  .be .pl-dialog-kopf h2 { font-size: 16px; }
  .be-leiste { gap: 6px 8px; padding: 6px 8px; }
  .be-suche { flex: 1 1 100%; max-width: none; }
  .be-suche input { font-size: 16px; min-height: 40px; }
  .be-treffer { flex: 1 1 100%; justify-content: space-between; }
  .be-treffer .pl-ik { width: 40px; height: 36px; }
  /* Zähler: alle in einer Zeile, Beschriftung über der Zahl */
  .be-zaehler { margin-left: 0; flex: 1 1 100%; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
  .be-z { display: flex; flex-wrap: wrap; justify-content: center; align-items: baseline; gap: 0 4px; padding: 3px 3px 4px; }
  .be-z small { flex: 0 0 100%; text-align: center; font-size: 10px; letter-spacing: .02em; line-height: 1.3; }
  .be-z b { font-size: 15px; }
  .be-z i { font-size: 11px; }
  .be-werkzeug { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -8px; padding: 0 8px; }
  .be-werkzeug::-webkit-scrollbar { display: none; }
  .be-werkzeug .btn--sm { flex: none; min-height: 38px; padding-left: 10px; padding-right: 10px; font-size: 13px; }
  .be-werkzeug [data-be-leeren] { order: 9; }   /* selten gebraucht: ans Ende der Reihe (wischen) */
  .be-zoom { display: none; }   /* am Handy zoomt man mit zwei Fingern */
  /* Set und Attribut (PoE 2): je ein Umschalter, der beim Antippen zur nächsten Wahl springt */
  .be-wahlen { flex-wrap: nowrap; gap: 6px 14px; overflow-x: auto; scrollbar-width: none; }
  .be-wahlen::-webkit-scrollbar { display: none; }
  .be-wahlgruppe { flex: none; flex-wrap: nowrap; }
  .be-lang { display: none; }
  .be-knapp { display: inline; }
  .be-wahlgruppe .pl-chip { min-height: 36px; }
  .be-wahlgruppe .pl-chip[aria-pressed="false"] { display: none; }
  .be-wahlgruppe .pl-chip::after { content: '↻'; opacity: .65; }
  .be-meldung { padding: 6px 10px; font-size: 13px; }
  .be-seite { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; width: auto; height: 68%; border-left: 0; border-top: 1px solid var(--line); background: #14110e; box-shadow: 0 -10px 30px rgba(0, 0, 0, .6); }
  .be-seite-zu { display: inline-grid; }
  .be-reiter [role="tab"] { padding: 12px 8px; }
  .be-punkt { padding: 8px 4px; }
  .be-fuss > span { display: none; }
  .be .be-fuss { padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); gap: 6px; }
  .be .be-fuss .btn { flex: 1 1 0; min-height: 42px; }
  .be-info { left: 6px; right: 6px; bottom: 6px; max-height: 62%; }
}
@media (prefers-reduced-motion: reduce) { .be-kurz { transition: none; } }

/* ---------- Baum direkt im Abschnitt „Passivbaum“ des Planers (be--inline): sofort sichtbar, ohne Dialog ---------- */
.be [hidden] { display: none !important; }   /* außerhalb des Dialogs greift .pl-dialog [hidden] nicht */
.pl-baum-platz { min-height: calc(clamp(420px, 68vh, 660px) + 56px); }   /* hält den Platz frei, bis der Baum geladen ist */
.pl-baum-platz:last-child { overflow: hidden; border-radius: 0 0 6px 6px; }
.pl-abschnitt--baum > .pl-koerper { border-top: 1px solid var(--line-soft); }
.pl-abschnitt--baum .pl-notables:last-child { margin-bottom: 0; }
.pl-abschnitt--baum .pl-aktionen { align-items: center; }
.pl-abschnitt--baum .pl-aktionen + .pl-baum-import { margin-top: 12px; }
.be--inline { display: flex; flex-direction: column; }
.be--inline .be-leiste { padding: 10px 16px; }
.be--inline .be-meldung { padding: 8px 16px; }
.be--inline .be-mitte { flex: none; height: clamp(420px, 68vh, 660px); }
.be--inline .tree-wrap { flex: 1; min-height: 0; margin: 0; border: 0; border-radius: 0; }
.be--inline .baum { width: 100%; height: 100%; }
.be-fuss--inline { margin: 0; padding: 8px 16px; border-top: 1px solid var(--line-soft); background: rgba(0, 0, 0, .18); font-size: 13px; line-height: 1.45; color: var(--muted); }
.be-fuss--inline span { color: #f0a79b; }
.be-oeffner { display: none; }

/* ---------- Roter Puls am Start (baum.js legt das Element über den Punkt) ---------- */
.baum-puls { position: absolute; left: 0; top: 0; z-index: 2; box-sizing: border-box; border-radius: 50%; border: 2px solid #ff4d3a; box-shadow: 0 0 12px 1px rgba(255, 77, 58, .65), inset 0 0 10px rgba(255, 77, 58, .35); pointer-events: none; will-change: transform; }
.baum-puls::before, .baum-puls::after { content: ''; position: absolute; inset: -2px; border-radius: 50%; border: 2px solid #ff4d3a; opacity: 0; animation: baum-puls 1.8s cubic-bezier(.2, .6, .35, 1) infinite; }
.baum-puls::after { animation-delay: .9s; }
@keyframes baum-puls { 0% { transform: scale(1); opacity: .95; } 100% { transform: scale(2.3); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .baum-puls::before, .baum-puls::after { animation: none; } }

/* Handy: der Baum im Abschnitt ist eine Vorschau, Antippen öffnet den großen Editor */
@media (max-width: 700px) {
  .pl-baum-platz { min-height: calc(max(300px, 46vh) + 48px); }
  .be--inline .be-leiste { padding: 8px 12px; }
  .be--inline .be-suche, .be--inline .be-treffer, .be--inline .be-werkzeug, .be--inline .be-wahlen, .be-fuss--inline { display: none; }
  .be--inline .be-mitte { height: max(300px, 46vh); }
  .be--inline .be-oeffner { display: flex; align-items: flex-end; justify-content: center; position: absolute; inset: 0; z-index: 3; margin: 0; padding: 0 12px 14px; border: 0; border-radius: 0; background: transparent; cursor: pointer; -webkit-tap-highlight-color: transparent; }
  .be--inline .be-oeffner span { display: inline-flex; align-items: center; min-height: 44px; padding: 0 20px; border-radius: 99px; border: 1px solid #b0652a; background: linear-gradient(180deg, #8a4a1c, #5c2f10); color: #fbe6cf; font: 600 15px/1.2 var(--font-ui); box-shadow: 0 4px 18px rgba(0, 0, 0, .65); }
  .be--inline .be-oeffner:focus-visible { outline-offset: -3px; }
  .be--inline .baum-hinweis, .be--inline .baum-fertig { display: none; }
}
