/* =====================================================================
   Stammbaum · gemeinsame Bauteile (Karten, Pillen, Panel, Blatt), Portal
   Nur hell. Farben nur über die App-Variablen (theme.js, Rückfall in marke.css).
   Manual v1.1: Knöpfe sind Kontur-Pillen, gewählt = Fläche #EDE8E5 (vl-paper) plus Kontur in Schriftfarbe.
   Drei Schriftgrößen: --s-gross (Titel, Unbounded), --s-text, --s-klein. Nichts unter 13 px.
   Layout (Kopf, Brett, Spalten, Leisten) macht jede Variante selbst.
   ===================================================================== */
:root { --s-gross: 40px; --s-text: 17px; --s-klein: 13px; --bk: 150px; --luecke: 24px; }
@media (max-width: 719px) { :root { --s-gross: 24px; --luecke: 16px; } }
body.sb-app { background: var(--bg-body); color: var(--text-primary); font-size: var(--s-text); }

/* ---------- Knöpfe ---------- */
.pille { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border: 1px solid var(--kontur); border-radius: 999px; background: transparent; color: var(--text-primary); font-size: var(--s-text); font-weight: 600; line-height: 1; white-space: nowrap; transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out), border-color var(--dur-base) var(--ease-out); }
.pille:hover:not(:disabled) { border-color: var(--text-primary); }
.pille[aria-pressed="true"] { background: var(--sel-bg, #EDE8E5); color: var(--sel-fg, #0A0708); border-color: var(--sel-line, #B0ADAC); }
.pille.klein { font-size: var(--s-klein); padding: 0 14px; white-space: normal; text-align: left; line-height: 1.25; }
.pille:disabled { opacity: .45; cursor: default; }
.pille.teil { border-color: var(--text-primary); }
.pille .art { font-weight: 400; color: var(--text-secondary); }
.pille[aria-pressed="true"] .art { color: var(--text-secondary); opacity: 1; }
.haupt { background: var(--btn-primary-bg); color: var(--btn-primary-fg); border-color: var(--btn-primary-line); }
.haupt:hover { border-color: var(--text-primary); }
.haupt[aria-disabled="true"] { opacity: .5; }
.icon-knopf { width: 40px; height: 40px; border: 1px solid var(--kontur); border-radius: 999px; background: transparent; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.icon-knopf:hover { border-color: var(--text-primary); }
.schalter { display: inline-flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 16px 0 10px; border: 1px solid var(--kontur); border-radius: 999px; background: transparent; font-size: var(--s-text); font-weight: 600; }
.schalter .spur { width: 30px; height: 18px; border: 1px solid var(--text-primary); border-radius: 999px; position: relative; flex: none; }
.schalter .knauf { position: absolute; top: 3px; left: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--text-primary); transition: transform var(--dur-base) var(--ease-out); }
.schalter[aria-checked="true"] { background: var(--sel-bg, #EDE8E5); color: var(--sel-fg, #0A0708); border-color: var(--sel-line, #B0ADAC); }
.schalter[aria-checked="true"] .spur { border-color: var(--text-primary); }
.schalter[aria-checked="true"] .knauf { background: var(--text-primary); transform: translateX(12px); }
.zahl { font-size: var(--s-klein); font-weight: 400; color: var(--text-secondary); font-variant-numeric: tabular-nums; }

/* ---------- Karten ---------- */
.karte-knopf { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 0; color: inherit; -webkit-user-select: none; user-select: none; position: relative; }
.karte-knopf img { -webkit-user-drag: none; }
.karte-knopf.gezogen { opacity: .35; }
.thumb { position: relative; display: block; width: 100%; aspect-ratio: 9 / 16; border-radius: 20px; overflow: hidden; background: var(--bg-s2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.rahmen { background: var(--bg-s1); border: 1px solid var(--kontur); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.rahmen-typ { font-size: var(--s-klein); color: var(--text-secondary); }
.rahmen-t { font-size: var(--s-text); font-weight: 600; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; overflow: hidden; }
.rahmen-s { font-size: var(--s-klein); color: var(--text-secondary); line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.neu-pille { position: absolute; top: 8px; left: 8px; z-index: 1; background: var(--bg-body); border: 1px solid var(--kontur); border-radius: 999px; padding: 2px 10px; font-size: var(--s-klein); font-weight: 600; line-height: 1.4; color: var(--text-primary); }
.thumb.rahmen .neu-pille { position: static; align-self: flex-start; }
.karte-text { display: block; margin-top: 10px; }
.karte-t { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; font-size: var(--s-klein); font-weight: 600; line-height: 1.35; margin-bottom: 4px; }
.meta { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: var(--s-klein); line-height: 1.4; color: var(--text-secondary); }
.marken { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
.marke { display: inline-flex; align-items: center; gap: 4px; font-size: var(--s-klein); font-weight: 600; color: var(--text-primary); line-height: 1.4; }
.marke[data-status="offen"], .marke[data-status="nein"] { color: var(--text-secondary); font-weight: 400; }
.rest { display: block; margin-top: 8px; }
.balken { display: block; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; }
.balken > span { display: block; height: 100%; background: var(--text-primary); }
.rest-t { display: block; margin-top: 4px; font-size: var(--s-klein); color: var(--text-secondary); }
.karte-knopf[aria-current="true"] .thumb { outline: 2px solid var(--text-primary); outline-offset: 2px; }
.geist { position: fixed; left: 0; top: 0; width: 96px; z-index: 60; pointer-events: none; border-radius: 20px; overflow: hidden; opacity: .92; border: 1px solid var(--text-primary); background: var(--bg-s1); }
.geist .thumb { border-radius: 0; }
.geist .thumb > *:not(img) { display: none; }
body.zieht, body.zieht * { cursor: grabbing !important; -webkit-user-select: none; user-select: none; }

/* ---------- Bereichsnamen ---------- */
.b-name { background: none; border: 0; padding: 2px 6px; margin: -2px -6px; border-radius: 8px; font: inherit; color: inherit; text-align: left; cursor: text; }
.b-name:hover { background: var(--bg-s1); }
.b-feld { font: inherit; color: var(--text-primary); background: var(--bg-s1); border: 1px solid var(--text-primary); border-radius: 8px; padding: 4px 8px; width: 100%; min-width: 0; }

/* ---------- Panel: Prüfkarte und Detail ---------- */
.pruef { background: var(--bg-s1); border: 1px solid var(--kontur); border-radius: 20px; display: flex; flex-direction: column; overflow: hidden; }
.pruef[hidden] { display: none; }
.pruef.auf { animation: sb-auftritt var(--dur-slow) var(--ease-out) both; }
.pruef-innen { flex: 1; overflow-y: auto; padding: 20px; }
.pruef-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); }
.pruef-fuss .offen { font-size: var(--s-klein); color: var(--text-secondary); }
.pruef-kopf { display: flex; gap: 16px; align-items: flex-start; }
.pruef-kopf .thumb { width: 132px; flex: none; }
.pruef-text { flex: 1; min-width: 0; display: grid; gap: 8px; align-content: start; }
.pruef-text .typ { font-size: var(--s-klein); color: var(--text-secondary); }
.pruef-text h2 { margin: 0; font-size: var(--s-text); font-weight: 600; line-height: 1.3; }
.pruef-text p { margin: 0; font-size: var(--s-klein); color: var(--text-secondary); line-height: 1.4; }
.link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; font-size: var(--s-klein); }
.frage { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.frage-t { margin: 0 0 8px; font-size: var(--s-text); font-weight: 600; line-height: 1.3; display: flex; gap: 10px; align-items: baseline; }
.frage-t .nr { color: var(--text-secondary); font-variant-numeric: tabular-nums; min-width: 14px; }
p.klein { margin: 0 0 12px; font-size: var(--s-klein); color: var(--text-secondary); line-height: 1.4; }
.leitplanken { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 4px; font-size: var(--s-klein); color: var(--text-secondary); }
.leitplanken li { display: flex; gap: 8px; align-items: center; }
.pillen { display: flex; flex-wrap: wrap; gap: 8px; }
.pillen.liste { flex-direction: column; align-items: stretch; }
.rg + .rg { margin-top: 14px; }
.serien { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 0 16px; }
.zeile { margin-top: 16px; }
.zeile .et { display: block; font-size: var(--s-klein); color: var(--text-secondary); margin-bottom: 4px; }
.zeile .wert { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: var(--s-text); line-height: 1.35; }
.zeile .wert .klein { font-size: var(--s-klein); color: var(--text-secondary); }
.annahme { margin: 24px 0 0; padding-top: 16px; border-top: 1px solid var(--line); font-size: var(--s-klein); color: var(--text-secondary); line-height: 1.4; }
.kunden-liste { display: grid; gap: 0; }
.kl-zeile { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.kl-zeile:first-child { border-top: 0; padding-top: 4px; }
.kl-zeile.hier .kl-name { text-decoration: none; }
.kl-links { display: grid; gap: 2px; min-width: 0; }
.kl-name { font-size: var(--s-text); font-weight: 600; }
.kl-status, .kl-kette { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: var(--s-klein); color: var(--text-secondary); line-height: 1.4; }

/* ---------- Blatt Hinzufügen ---------- */
.blatt-wrap { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; background: color-mix(in srgb, var(--bg-body) 72%, transparent); }
.blatt-wrap[hidden] { display: none; }
.blatt { width: min(500px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--bg-s1); border: 1px solid var(--kontur); border-radius: 20px; padding: 24px; }
.blatt-kopf { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.h2 { margin: 0; font-size: var(--s-text); font-weight: 600; line-height: 1.3; }
.etikett { display: flex; gap: 8px; align-items: baseline; font-size: var(--s-klein); font-weight: 600; margin-bottom: 8px; }
.feld { width: 100%; height: 48px; border: 1px solid var(--kontur); border-radius: 8px; padding: 0 14px; background: var(--bg-s1); color: var(--text-primary); font-size: var(--s-text); }
.feld::placeholder { color: var(--text-tertiary); }
.blatt-feld { margin-top: 20px; }
.blatt-fuss { margin-top: 24px; display: flex; justify-content: flex-end; }
@media (max-width: 719px) {
  .blatt-wrap { align-items: flex-end; }
  .blatt { width: 100%; max-height: 92dvh; border-radius: 20px 20px 0 0; padding-bottom: 32px; }
  .pruef-kopf .thumb { width: 104px; }
}
