/* =====================================================================
   Stammbaum und Sammlung im Portal: Einpassen unter die feste Navigation (oben) und die
   Handy-Leiste (mobile-nav.js, unten), dazu die Korrekturen aus Moritz' Runde 7.
   Farben nur über die Tokens (theme.js, Rückfall in marke.css). Manual v1.1: kein Rot, keine
   Schatten, Kontur-Pillen, höchstens drei Schriftgrößen (--s-gross, --s-text, --s-klein).
   ===================================================================== */
:root { --nav-h: 77px; --mnav-h: 0px; }

/* Stammbaum und Sammlung bleiben hell: kein Schalter für Dunkel auf diesen Seiten */
body.sb-app #vl-theme-toggle { display: none !important; }
body.sb-app nav.fixed { background: var(--nav-bg, rgba(247, 244, 242, 0.92)) !important; }
/* theme.js auf main legt rote Verläufe und ein Raster hinter jede Seite (Manual v1.1 verbietet beides). Filmkorn bleibt. */
body.sb-app::before { display: none !important; }

/* Navigation wie im CI-v1.1-Branch (theme.js Abschnitte 4 und 5), bis er hereinkommt. Die :not(#…) heben nur die
   Spezifität über die langen Selektoren aus theme.js auf main (Funnel 800, rotes Profil-Symbol).
   Funnel Display Semibold, gemischte Schreibung, kein Rot außer im Logo */
body.sb-app nav:not(#vl-mobile-nav):not(#sb-x):not(#sb-y) .font-display:not(.vl-logo) { font-family: var(--font-body) !important; font-weight: 600 !important; text-transform: none !important; letter-spacing: 0 !important; }
body.sb-app nav:not(#vl-mobile-nav):not(#sb-x):not(#sb-y) a.font-display:not(.vl-logo) { font-size: 17px !important; color: var(--text-secondary) !important; }
body.sb-app nav:not(#vl-mobile-nav):not(#sb-x):not(#sb-y) a.font-display[aria-current="page"], body.sb-app nav:not(#vl-mobile-nav):not(#sb-x):not(#sb-y) a.font-display:hover { color: var(--text-primary) !important; }
body.sb-app nav:not(#sb-x) .text-primary, body.sb-app nav:not(#sb-x) .material-symbols-outlined { color: var(--text-primary) !important; }
body.sb-app nav #nav-balance { font-size: 17px !important; }
/* Drei Schriftgrößen je Fläche: Navigation und Text der App teilen sich 17 px (t-body), auch das Profil-Symbol */
body.sb-app nav #profile-btn .material-symbols-outlined { font-size: 17px !important; }
@media (max-width: 1360px) { body.sb-app nav:not(#vl-mobile-nav):not(#sb-x):not(#sb-y) .md\:flex.gap-8 { gap: 1.25rem !important; } body.sb-app nav:not(#vl-mobile-nav):not(#sb-x):not(#sb-y) a.font-display:not(.vl-logo) { font-size: 15px !important; } }
@media (max-width: 1100px) { body.sb-app nav:not(#vl-mobile-nav):not(#sb-x):not(#sb-y) .md\:flex.gap-8 { gap: 0.9rem !important; } body.sb-app nav:not(#vl-mobile-nav):not(#sb-x):not(#sb-y) a.font-display:not(.vl-logo) { font-size: 14px !important; } }

/* Hinweis statt Seite (Migration fehlt, kein Booster, keine Firma) */
.sb-hinweis { margin: calc(var(--nav-h) + 64px) auto 0; max-width: 560px; padding: 0 24px; font-size: var(--s-text); line-height: 1.5; color: var(--text-primary); }

/* ---------- Baum: die App füllt den Platz zwischen Navigation und Handy-Leiste ---------- */
body.sb-baum .seite { position: fixed; left: 0; right: 0; top: var(--nav-h); bottom: var(--mnav-h); height: auto; }
body.sb-baum .weg-panel, body.sb-baum .plus-menu { max-height: calc(100dvh - var(--nav-h) - var(--mnav-h) - 24px); }
.zur-link { gap: 6px; }

/* Runde 7, Fehler 1: Namen an Ziel, Richtung, Serie brechen um und werden nie gekürzt oder getrennt */
.baum .knoten .kn-name {
  display: block; -webkit-line-clamp: unset; line-clamp: unset; -webkit-box-orient: initial;
  overflow: visible; text-overflow: clip; white-space: normal;
  hyphens: manual; -webkit-hyphens: manual; overflow-wrap: normal; word-break: normal;
}
/* Ein Name bekommt so viel Breite, wie sein längstes Wort braucht (bis 132 px), statt über den Nachbarn zu laufen.
   Der Baum wird dann breiter und scrollt waagerecht in sich; die Linien folgen der Lage im DOM. */
.baum .trieb { width: auto; min-width: var(--slot); }
.baum .leer-zweig .trieb { width: calc(var(--slot) * 2); }
.baum .k-an { width: max-content; min-width: calc(var(--slot) - 8px); max-width: 132px; height: auto; min-height: 68px; padding: 0 8px; }
.baum .zweig.zu { width: auto; }
.baum .zweig.zu .k-richtung { width: max-content; min-width: calc(var(--slot) * 1.4 - 8px); max-width: 180px; height: auto; min-height: 64px; padding: 6px 10px; }
.baum .k-richtung { height: auto; min-height: 56px; }

/* Runde 7, Fehler 2: Die offene Sammlungs-Leiste darf Plattform und Stamm nicht verdecken.
   Sie liegt im Fluss unter dem Baum, der Baum wird kürzer und scrollt in sich; unten bleibt Luft für den Stamm. */
body.sb-baum .spalte-baum { overflow: hidden; }
body.sb-baum .schublade { position: relative; z-index: 5; max-height: 46%; overflow-y: auto; }
body.sb-baum #baum.baum { scroll-padding-bottom: 24px; }

/* Kampagnen-Filter hinter der Fahne */
#kamp-knopf[aria-pressed="true"] { background: var(--sel-bg, #EDE8E5); border-color: var(--sel-line, #B0ADAC); }
.kamp-blatt { position: fixed; z-index: 48; width: min(360px, calc(100vw - 24px)); display: grid; gap: 12px; padding: 14px 16px 16px;
  border: 1px solid var(--text-primary); border-radius: 20px; background: var(--bg-body); animation: sb-auftritt var(--dur-slow) var(--ease-out) both; }
.kamp-blatt[hidden] { display: none; }
.kb-kopf { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.kb-t { font-size: var(--s-text); font-weight: 600; }
.kamp-blatt .pillen { display: flex; flex-wrap: wrap; gap: 8px; }
@media (max-width: 719px) {
  .kamp-blatt { left: 0; right: 0 !important; top: auto !important; bottom: var(--mnav-h); width: auto; border-radius: 20px 20px 0 0; border-bottom: 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}

/* ---------- Sammlung: normal scrollende Seite unter der Navigation ---------- */
body.sb-sammlung .seite { padding-top: var(--nav-h); padding-bottom: var(--mnav-h); }

/* Fokus sichtbar, nie rot (Portal-Stile setzen sonst einen roten Rahmen) */
body.sb-app .seite :focus-visible, body.sb-app .kamp-blatt :focus-visible { outline: 1px solid var(--text-primary); outline-offset: 2px; }

/* ---------- Handy: Blätter und Leisten enden über der Handy-Leiste und beginnen unter der Navigation ---------- */
@media (max-width: 719px) {
  body.sb-baum .weg-panel { inset: auto 0 auto 0; top: var(--nav-h); bottom: var(--mnav-h); }
  body.sb-baum .leiste { bottom: var(--mnav-h); }
  body.sb-baum .plus-menu { bottom: var(--mnav-h); max-height: calc(100dvh - var(--nav-h) - var(--mnav-h) - 16px); }
  body.sb-baum .frage-blatt { bottom: calc(var(--mnav-h) + 8px); }
  body.sb-app .sb-toast { bottom: calc(var(--mnav-h) + var(--sch-h, 0px) + 16px); }
}
body.sb-app .blatt-wrap { top: var(--nav-h); bottom: var(--mnav-h); }

/* Handy-Leiste: Knopf ohne Schatten (Manual v1.1, wie im CI-Branch), Eingabefelder mit Fokus in Schriftfarbe statt Rot */
body.sb-app #vl-mobile-nav .vlmn-fab { box-shadow: none !important; }
body.sb-app input:focus, body.sb-app textarea:focus, body.sb-app select:focus { outline: 1px solid var(--text-primary) !important; outline-offset: 0 !important; box-shadow: none !important; border-color: var(--text-primary) !important; }

/* ---------- Sammlung: Blätter unter der Navigation, über der Handy-Leiste; der Call deckt alles ---------- */
body.sb-sammlung .pruef, body.sb-sammlung .schnell { top: calc(var(--nav-h) + var(--kopf-h, 190px) + 12px); bottom: calc(var(--mnav-h) + 16px); }
body.sb-sammlung .call { z-index: 130; }
@media (max-width: 719px) {
  body.sb-sammlung .pruef, body.sb-sammlung .schnell { top: var(--nav-h); bottom: var(--mnav-h); }
  body.sb-sammlung .korb.offen .korb-inhalt { bottom: var(--mnav-h); max-height: calc(100dvh - var(--nav-h) - var(--mnav-h) - 16px); }
  body.sb-sammlung .sb-toast { top: calc(var(--nav-h) + var(--kopf-h, 190px) + 8px); bottom: auto; }
}
/* theme.js gibt jedem nav denselben view-transition-name; mit der Handy-Leiste sind es zwei (Konsolenfehler beim Seitenwechsel) */
body.sb-app nav#vl-mobile-nav { view-transition-name: none; }
/* Aktiver Reiter der Handy-Leiste in Schriftfarbe statt Rot (wie im CI-Branch) */
body.sb-app #vl-mobile-nav .vlmn-item.is-aktiv, body.sb-app #vl-mobile-nav .vlmn-item.is-aktiv .material-symbols-outlined, body.sb-app #vl-mobile-nav .vlmn-item.is-aktiv .vlmn-label { color: var(--text-primary) !important; }
body.sb-app #vl-mobile-nav .vlmn-item.is-aktiv .vlmn-label::after { background: var(--text-primary) !important; }

/* Titel brechen nie im Wort um (Sammlung am Handy stand als „SAMMLUN / G“ da): die Titelspalte bekommt ihre Breite */
body.sb-app .sb-titel { overflow-wrap: normal; word-break: normal; white-space: nowrap; }
@media (max-width: 719px) { body.sb-sammlung .kopf { grid-template-columns: max-content minmax(0, 1fr); } }

/* „Nur intern“ (NUR_TEAM, 18.11.2026): am Handy unter dem Titel, sonst liegt die Pille in der Sammlung über „+ Hinzufügen“ */
@media (max-width: 719px) {
  html.vl-nur-intern body.sb-app .sb-titel[data-nur-intern]::after { display: flex; width: max-content; height: 22px; padding: 0 8px; margin: 6px 0 0; }
}
