/* =====================================================================
   Stammbaum · Runde 4 · Baum (gemeinsam für alle Baum-Varianten)
   Nur hell, Farben über App-Variablen. Linien haarfein (1 px), der Weg 2 px.
   Schrift: Ziel 16 px Semibold, alles andere 13 px. Beschriftungen stehen
   zwischen den Linien, nie auf ihnen.
   ===================================================================== */
.baum { --slot: 104px; position: relative; overflow-x: auto; overflow-y: hidden; scrollbar-width: thin; }
.baum-innen { position: relative; display: flex; flex-direction: column; align-items: center; width: max-content; min-width: 100%; padding: 8px 24px 16px; }
.baum-linien { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.baum-linien path { fill: none; stroke: var(--kontur); stroke-width: 1; transition: stroke var(--dur-base) var(--ease-out), opacity var(--dur-base) var(--ease-out); }
.baum.hat-weg .baum-linien path { opacity: .35; }
.baum.hat-weg .baum-linien path.weg { stroke: var(--text-primary); stroke-width: 2; opacity: 1; }

.krone { position: relative; display: flex; align-items: flex-end; gap: 48px; }
.plat, .ast, .zweig, .trieb { position: relative; display: flex; flex-direction: column; align-items: center; }
.zweige { display: flex; align-items: flex-end; gap: 16px; }
.triebe { display: flex; align-items: flex-end; }
.trieb { width: var(--slot); }
.leer-zweig .trieb { width: calc(var(--slot) * 2); }
.blaetter { display: flex; flex-direction: column-reverse; align-items: center; gap: 10px; padding-bottom: 12px; }

/* ---------- Knoten (Beschriftungen) ---------- */
.knoten { position: relative; z-index: 1; background: var(--bg-body); text-align: center; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 8px; transition: opacity var(--dur-base) var(--ease-out); }
.kn-name { font-size: var(--s-klein); font-weight: 600; line-height: 1.3; hyphens: auto; -webkit-hyphens: auto; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kn-unter { display: inline-flex; align-items: center; gap: 6px; font-size: var(--s-klein); color: var(--text-secondary); line-height: 1.3; white-space: nowrap; max-width: 100%; }
.spur { display: inline-flex; gap: 3px; }
.spur i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-secondary); }
.k-an { width: calc(var(--slot) - 8px); height: 68px; margin-bottom: 28px; padding: 0 4px; }
.k-an .kn-name { -webkit-line-clamp: 3; }
.k-an.leer { visibility: hidden; }
.k-richtung { height: 56px; margin-bottom: 32px; padding: 0 4px; width: 0; min-width: 100%; }
.k-richtung.leer { visibility: hidden; }
.k-ziel { min-height: 52px; margin-bottom: 36px; padding: 4px 8px; width: 0; min-width: 100%; }
.k-ziel .kn-name { font-size: var(--s-text); -webkit-line-clamp: 2; }
.k-ziel .kn-unter { white-space: normal; text-align: center; }
.k-ziel.kahl .kn-unter { color: var(--text-primary); }
.k-wurzel { max-width: 560px; padding: 8px 16px 0; }
.k-wurzel .kn-name { font-size: var(--s-text); font-weight: 600; -webkit-line-clamp: 3; }
.k-wurzel .kn-unter { order: -1; margin-bottom: 2px; }
.knoten.gewaehlt { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.baum.hat-weg .knoten:not(.weg), .baum.hat-weg .blatt:not(.weg), .baum.hat-weg .knospe, .baum.hat-weg .luecke-blatt { opacity: .3; }

/* ---------- Blätter = geplante Videos ---------- */
/* .blatt heißt auch das Hinzufügen-Blatt in ui.css: im Baum alles davon zurücknehmen */
.baum .blatt { width: auto; max-height: none; overflow: visible; border-radius: 0; display: flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; padding: 0; color: inherit; transition: opacity var(--dur-base) var(--ease-out); }
.b-bild { position: relative; display: block; aspect-ratio: 9 / 16; border-radius: 20px; overflow: hidden; background: var(--bg-s2); }
.blatt.gross .b-bild { width: calc(var(--slot) - 16px); }
.blatt.klein .b-bild { width: min(calc(var(--slot) * .5), 72px); border-radius: 12px; }
.b-bild img { width: 100%; height: 100%; object-fit: cover; }
.blatt.ohne-bild .b-bild { background: var(--bg-s1); border: 1px solid var(--kontur); display: flex; align-items: center; justify-content: center; }
.b-leer-i { display: inline-flex; color: var(--text-secondary); }
.b-leer-titel { display: none; }
/* Titel im Blatt ohne Bild nur, wenn das Blatt wirklich breit ist (misst die echte Breite, auch wenn eine Variante den Baum nachträglich verkleinert) */
.blatt.gross.ohne-bild .b-bild { container-type: inline-size; flex-direction: column; }
@container (min-width: 112px) {
  .b-leer-titel { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--s-klein); font-weight: 600; line-height: 1.3; text-align: center; padding: 0 12px; margin-top: 12px; }
}
.kn-bild .b-leer-i { width: 100%; height: 100%; align-items: center; justify-content: center; }
.b-leer-t { font-size: var(--s-klein); font-weight: 600; line-height: 1.25; text-align: center; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.blatt.klein .b-leer-t { -webkit-line-clamp: 3; font-weight: 400; }
.b-nr { position: absolute; top: 6px; left: 6px; z-index: 1; width: 24px; height: 24px; border-radius: 50%; background: var(--invers-bg); color: var(--invers-fg); font-size: var(--s-klein); font-weight: 600; line-height: 24px; text-align: center; font-variant-numeric: tabular-nums; }
.blatt.ohne-bild .b-nr { top: 6px; left: 6px; }
.b-chip { position: absolute; left: 6px; right: 6px; bottom: 6px; background: var(--bg-body); border-radius: 999px; font-size: var(--s-klein); line-height: 1.5; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blatt.klein .b-chip { display: none; }
.b-wann { font-size: var(--s-klein); color: var(--text-secondary); line-height: 1.2; font-variant-numeric: tabular-nums; }
.blatt:hover .b-bild, .blatt:focus-visible .b-bild { outline: 1px solid var(--text-primary); outline-offset: 2px; }
.blatt.weg .b-bild { outline: 2px solid var(--text-primary); outline-offset: 2px; }

/* ---------- Knospen = geprüfte Ideen aus der Sammlung, noch nicht eingeplant ---------- */
.knospen { display: flex; gap: 6px; align-items: flex-end; justify-content: center; }
.knospe { background: none; border: 0; padding: 0; }
.kn-bild { display: block; width: min(calc(var(--slot) * .36), 52px); aspect-ratio: 9 / 16; border-radius: 10px; overflow: hidden; border: 1px dashed var(--text-secondary); background: var(--bg-s1); }
.kn-bild img { width: 100%; height: 100%; object-fit: cover; opacity: .75; }
.kn-bild .b-leer-t { font-size: var(--s-klein); -webkit-line-clamp: 3; padding: 4px; font-weight: 400; }
.knospe:hover .kn-bild { border-style: solid; border-color: var(--text-primary); }
.kn-mehr { font-size: var(--s-klein); color: var(--text-secondary); align-self: center; }

/* ---------- Lücke = kahler Zweig ---------- */
.luecke-blatt { width: min(calc(var(--slot) - 16px), 112px); aspect-ratio: 9 / 16; border: 1px dashed var(--text-secondary); border-radius: 20px; background: transparent; display: flex; align-items: center; justify-content: center; padding: 10px; text-align: center; font-size: var(--s-klein); line-height: 1.3; color: var(--text-secondary); }
button.luecke-blatt:not(:disabled):hover { border-color: var(--text-primary); color: var(--text-primary); }
.luecke-blatt:disabled { cursor: default; }
.luecke-blatt.still { opacity: .8; }

/* ---------- Plus am Ast (nur wo die Variante es einschaltet) ----------
   Sitzt am Knoten selbst und kostet keine Breite: an der Richtung (neue Serie oder neuer Anlass),
   am Ziel (neue Richtung), an der Wurzel (neues Ziel, nur solange es weniger als drei gibt). */
.plus { flex: none; width: 28px; height: 28px; border-radius: 999px; border: 1px dashed var(--text-secondary); background: var(--bg-body); display: inline-flex; align-items: center; justify-content: center; gap: 4px; color: var(--text-primary); font-size: var(--s-klein); font-weight: 600; }
.plus:hover, .plus:focus-visible { border-style: solid; border-color: var(--text-primary); }
.k-richtung .plus, .k-ziel .plus { position: absolute; top: -14px; right: -6px; z-index: 2; }
.plus-ziel { width: auto; height: 36px; padding: 0 14px; margin-top: 10px; }
@media (max-width: 719px) { .plus { width: 40px; height: 40px; } .k-richtung .plus, .k-ziel .plus { top: -20px; right: -10px; } }

/* ---------- Die nächsten fünf (Leiste) ---------- */
.n5-leiste { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.n5-leiste::-webkit-scrollbar { display: none; }
.n5 { flex: none; display: flex; align-items: center; gap: 10px; max-width: 240px; min-height: 48px; padding: 6px 14px 6px 6px; border: 1px solid var(--kontur); border-radius: 999px; background: var(--bg-s1); text-align: left; }
.n5:hover { border-color: var(--text-primary); }
.n5 .b-nr { position: static; flex: none; }
.n5-text { display: grid; min-width: 0; }
.n5-datum { font-size: var(--s-klein); color: var(--text-secondary); line-height: 1.3; }
.n5-titel { font-size: var(--s-klein); font-weight: 600; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.n5-leer { margin: 0; font-size: var(--s-klein); color: var(--text-secondary); }

/* ---------- Seitenpanel Weg und Lücke ---------- */
.weg-panel { background: var(--bg-s1); border: 1px solid var(--kontur); border-radius: 20px; overflow: hidden; display: flex; flex-direction: column; }
.weg-panel[hidden] { display: none; }
.weg-panel.auf { animation: sb-auftritt var(--dur-slow) var(--ease-out) both; }
.weg-innen { overflow-y: auto; padding: 20px; }
.weg-kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.weg-liste { list-style: none; margin: 0; padding: 0; }
.weg-liste li { position: relative; display: grid; gap: 2px; padding: 0 0 18px 20px; border-left: 1px solid var(--kontur); margin-left: 5px; }
.weg-liste li::before { content: ""; position: absolute; left: -5px; top: 4px; width: 9px; height: 9px; border-radius: 50%; background: var(--text-primary); }
.weg-liste li:last-child { border-left-color: transparent; padding-bottom: 0; }
.weg-liste .et { font-size: var(--s-klein); color: var(--text-secondary); }
.weg-liste .wert { font-size: var(--s-text); font-weight: 600; line-height: 1.35; }
.weg-liste .klein-zeile { font-size: var(--s-klein); color: var(--text-secondary); }
.weg-herkunft { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; grid-template-columns: 64px 1fr; gap: 6px 12px; align-items: center; font-size: var(--s-klein); }
.weg-herkunft .et { grid-column: 1 / -1; color: var(--text-secondary); }
.weg-knospen { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.weg-knospe { background: none; border: 0; padding: 0; text-align: left; display: grid; gap: 6px; font-size: var(--s-klein); font-weight: 600; line-height: 1.3; }
.weg-knospe:hover .thumb { outline: 1px solid var(--text-primary); outline-offset: 2px; }

@media (max-width: 719px) {
  .baum-innen { padding: 8px 16px 16px; }
  .krone { gap: 24px; }
  .zweige { gap: 8px; }
}

/* ---------- Aufklappen (Runde 5) ---------- */
.kn-kopf { display: inline-flex; align-items: center; gap: 4px; max-width: 100%; min-width: 0; }
.kn-kopf .kn-name { min-width: 0; }
.kn-klapp { flex: none; width: 24px; height: 24px; border: 0; border-radius: 999px; background: transparent; display: inline-flex; align-items: center; justify-content: center; color: var(--text-secondary); padding: 0; }
.kn-klapp:hover, .kn-klapp:focus-visible { color: var(--text-primary); background: var(--bg-s2); }
.k-ziel, .k-richtung { cursor: pointer; }
.zweig.zu { width: calc(var(--slot) * 1.4); }
.ast.zu { width: max(180px, calc(var(--slot) * 1.8)); }
.zweig.zu .k-richtung, .ast.zu .k-ziel { margin-bottom: 0; }
.zweig.zu { padding-top: 8px; }
.zweig.zu .k-richtung { margin-bottom: 32px; border: 1px dashed var(--kontur); border-radius: 12px; height: 64px; }
.ast.zu .k-ziel { margin-bottom: 36px; border: 1px dashed var(--kontur); border-radius: 16px; min-height: 64px; padding: 8px 12px; }
.zweig.zu .k-richtung:hover, .ast.zu .k-ziel:hover { border-style: solid; border-color: var(--text-primary); }
.baum-linien.warten { opacity: 0; transition: none; }
.baum-linien { transition: opacity var(--dur-base) var(--ease-out); }
@media (max-width: 719px) { .kn-klapp { width: 32px; height: 32px; } }
/* Offene Richtung: Pfeil nur beim Überfahren oder Fokus, damit der Name die volle Breite hat */
.k-richtung:not(.zu) .kn-klapp { position: absolute; left: -8px; top: -12px; z-index: 2; background: var(--bg-body); border: 1px solid var(--kontur); opacity: .5; transition: opacity var(--dur-fast) var(--ease-out); }
.k-richtung:not(.zu):hover .kn-klapp, .k-richtung:not(.zu) .kn-klapp:focus-visible, .k-richtung:not(.zu):focus-within .kn-klapp { opacity: 1; }
@media (hover: none), (max-width: 719px) { .k-richtung:not(.zu) .kn-klapp { opacity: 1; } }

/* =====================================================================
   Runde 6 · Plattformen, Wurzeln, Zielstand, Serieninfo, Zweitverwertung, Kampagne, Einplanen
   ===================================================================== */
.ziele { display: flex; align-items: flex-end; gap: 28px; }
.plat { min-width: 200px; }
.plat.zu { width: max(200px, calc(var(--slot) * 1.9)); }
.ast { min-width: 152px; }
.k-ziel .kn-name { -webkit-line-clamp: 3; }
.baum.mit-balken .ast { min-width: 168px; }
.leer-ziele { width: 160px; }

/* Plattform-Knoten */
.k-konto { min-height: 64px; margin-bottom: 32px; padding: 6px 12px; width: 0; min-width: 100%; cursor: pointer; border: 1px solid var(--kontur); border-radius: 16px; background: var(--bg-body); }
.k-konto .kn-kopf { gap: 6px; justify-content: center; }
.k-plat-i { display: inline-flex; flex: none; }
.k-konto .kn-name { font-size: var(--s-text); -webkit-line-clamp: 2; }
.k-konto .kn-unter { white-space: normal; text-align: center; }
.k-konto.kahl .kn-unter { color: var(--text-primary); }
.plat.zu .k-konto { border-style: dashed; }
.k-konto:hover { border-style: solid; border-color: var(--text-primary); }
.k-konto .plus, .k-stamm .plus-an { position: absolute; top: -14px; right: -6px; z-index: 2; }
.plus-ziel-an { top: -14px; right: -6px; }
@media (max-width: 719px) { .k-konto .plus { top: -20px; right: -10px; } }

/* Stamm */
.k-stamm { padding: 6px 24px; margin-bottom: 20px; border: 1px solid var(--text-primary); border-radius: 999px; max-width: 560px; }
.k-stamm .kn-name { font-size: var(--s-text); }
.k-stamm .kn-unter.satz { white-space: normal; text-align: center; }
.plus-konto { width: auto; height: 36px; padding: 0 14px; margin-top: 8px; }

/* Wurzeln: Grundimage und Zielgruppen */
.wurzeln { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: center; gap: 12px 16px; max-width: 100%; }
.baum.mit-zg .k-wurzel { max-width: 224px; width: 224px; }
.k-zg { width: 152px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 12px; }
.k-zg.kurz { border: 1px dashed var(--text-primary); }
.k-zg .kn-unter { white-space: normal; text-align: center; }
.kurz-t { color: var(--text-primary); font-weight: 600; }
.w-zeile { white-space: normal; text-align: center; margin-top: 2px; }
.k-wurzel { cursor: default; }

/* Zielstand am Ziel-Knoten (nie Rot, nie 100 % vor dem Erreichen) */
.z-balken { position: relative; display: block; width: min(150px, 80%); height: 4px; margin: 10px 0 6px; border-radius: 2px; background: var(--line); }
.z-balken i { display: block; height: 100%; border-radius: 2px; background: var(--text-primary); }
.z-balken b { position: absolute; top: -4px; width: 1px; height: 12px; background: var(--text-primary); }
.z-zeile { font-size: var(--s-klein); line-height: 1.3; color: var(--text-secondary); text-align: center; margin-bottom: 2px; }
.z-status { display: inline-flex; align-items: center; margin: 4px 0 2px; padding: 0 10px; min-height: 22px; border: 1px solid var(--text-primary); border-radius: 999px; font-size: var(--s-klein); font-weight: 600; line-height: 1.2; }
.z-status[data-status="hinter"] { border-style: dashed; }
.z-status[data-status="erreicht"] { background: var(--sel-bg, #EDE8E5); color: var(--sel-fg, #0A0708); }

/* Serieninfo */
.kn-info { font-size: var(--s-klein); line-height: 1.3; color: var(--text-secondary); text-align: center; white-space: normal; max-width: 100%; }
.k-an.mit-info { height: auto; min-height: 68px; padding: 4px; }

/* Zweitverwertung */
.b-zweit { position: absolute; top: 6px; right: 6px; z-index: 1; width: 24px; height: 24px; border-radius: 50%; background: var(--bg-body); display: flex; align-items: center; justify-content: center; }
.baum-linien path.zweit { stroke: var(--text-secondary); stroke-dasharray: 2 4; }
.baum.hat-weg .baum-linien path.zweit.weg { stroke: var(--text-primary); stroke-width: 2; stroke-dasharray: 3 5; opacity: 1; }

/* Kampagne als Filter */
.gedimmt { opacity: .3; }
.baum-linien path.gedimmt { opacity: .3; }

/* Panel: Fuß und Einplanen */
.weg-panel { max-height: 100%; }
.weg-innen { flex: 1; min-height: 0; }
.weg-fuss { flex: none; border-top: 1px solid var(--line); padding: 12px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--bg-s1); }
.weg-fuss .offen { font-size: var(--s-klein); color: var(--text-secondary); }
.weg-panel .frage:first-of-type { margin-top: 20px; }
.ep-idee { display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: start; }
.ep-idee .thumb { width: 72px; border-radius: 12px; }
.ep-idee strong { font-size: var(--s-text); font-weight: 600; line-height: 1.3; }
.ep-idee .klein { margin: 4px 0 0; }
.ep-zeile { margin-top: 10px; }
.ep-claude { margin-bottom: 14px; }
.ep-feld { margin-bottom: 14px; }
.ep-vorschlag { font-weight: 400; color: var(--text-secondary); }
.feld.ta { height: auto; min-height: 72px; padding: 10px 14px; line-height: 1.4; resize: vertical; font-family: var(--font-body); }
input.feld[type="date"] { max-width: 220px; }
.vorschlag-band { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 0 0 12px; padding: 6px 6px 6px 16px; border: 1px dashed var(--text-secondary); border-radius: 999px; font-size: var(--s-klein); font-weight: 600; }
.zeile .wert.auch { align-items: flex-start; flex-wrap: nowrap; gap: 8px; margin-top: 4px; }
.zeile .wert.auch .klein { display: block; }
.zeile .wert.auch .sb-icon { margin-top: 4px; }
.weg-liste .klein-zeile { line-height: 1.35; }

/* Verlauf */
.verlauf-kopf { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.verlauf-liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; font-size: var(--s-klein); }
.verlauf-liste li { display: grid; gap: 1px; }
.verlauf-liste .v-wer, .verlauf-liste .leer { color: var(--text-secondary); }
.verlauf-liste .zurueck .v-text { color: var(--text-secondary); }

/* Schmale Beiträge: der Status steht im Panel, der Chip nur, wenn er ganz hineinpasst */
.b-bild { container-type: inline-size; }
@container (max-width: 99px) { .b-chip { display: none; } }
.k-ziel.mit-info { margin-bottom: 30px; }
.k-wurzel .kn-name { hyphens: manual; -webkit-hyphens: manual; }
.baum.mit-serie .k-an .kn-unter { white-space: normal; text-align: center; justify-content: center; }
.baum.mit-serie .k-an.mit-info .kn-name { -webkit-line-clamp: 2; }
.kn-info { overflow-wrap: anywhere; }
