/* Bausteine-Studio: Bibliothek mit Live-Vorschauen */
#library.bs-library { --bs-ink: #182c3a; --bs-teal: #1d5c55; --bs-gold: #d9b38c; --bs-line: #e1e7e4; --bs-muted: #66777d; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--bs-ink); }
#library.bs-library button { font: inherit; cursor: pointer; margin: 0; min-height: 0; box-shadow: none; text-transform: none; letter-spacing: 0; }
#library.bs-library h2, #library.bs-library h3, #library.bs-library p { margin: 0; }

.bs-head { padding: 2px 0 14px; }
.bs-kicker { font-size: 10.5px; letter-spacing: .16em; font-weight: 700; color: #a27a4e; }
#library.bs-library .bs-head h2 { font-size: 21px; line-height: 1.2; margin: 4px 0 6px; color: var(--bs-ink); font-weight: 700; }
.bs-head p { font-size: 13px; color: var(--bs-muted); line-height: 1.45; }

/* Einfügeposition */
.bs-where { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; padding: 4px; margin-bottom: 12px; border-radius: 12px; background: #eef2ef; border: 1px solid var(--bs-line); }
.bs-where > span { font-size: 11.5px; font-weight: 700; color: var(--bs-muted); padding: 0 6px 0 8px; }
#library.bs-library .bs-where button { flex: 1 1 auto; height: 30px; padding: 0 10px; border-radius: 9px; border: 0; background: transparent; color: #4a5c62; font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
#library.bs-library .bs-where button[aria-checked=true] { background: #fff; color: var(--bs-ink); box-shadow: 0 2px 8px #18302e1c; }

/* Suche und Bereiche */
.bs-search { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px; border-radius: 12px; border: 1px solid #d5ddd9; background: #fff; margin: 0 0 12px !important; font-size: 13px !important; }
.bs-search:focus-within { border-color: var(--bs-teal); box-shadow: 0 0 0 3px #1d5c5520; }
.bs-search span { color: var(--bs-muted); font-size: 16px; }
#library.bs-library .bs-search input { flex: 1; min-width: 0; height: 40px; border: 0 !important; outline: 0; background: transparent !important; font: inherit; font-size: 14px; padding: 0 !important; box-shadow: none !important; color: var(--bs-ink); }
.bs-search em { font-style: normal; font-size: 11px; font-weight: 700; color: var(--bs-teal); background: #e6f0ec; border-radius: 999px; padding: 3px 8px; }
.bs-cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 14px; scrollbar-width: thin; }
#library.bs-library .bs-cats button { flex: none; height: 32px; padding: 0 13px; border-radius: 999px; border: 1px solid var(--bs-line); background: #fff; color: #44565d; font-size: 12.5px; font-weight: 600; }
#library.bs-library .bs-cats button:hover { border-color: #9fbdb2; }
#library.bs-library .bs-cats button[aria-selected=true] { background: var(--bs-ink); border-color: var(--bs-ink); color: #fff; }

/* Pakete */
.bs-packs { margin-bottom: 18px; }
#library.bs-library .bs-packs h3 { font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--bs-ink); }
.bs-packs h3 small { font-weight: 500; color: var(--bs-muted); margin-left: 4px; }
.bs-pack-row { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(170px, 1fr); gap: 8px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: thin; }
#library.bs-library .bs-pack { display: grid; gap: 3px; text-align: left; align-content: start; padding: 12px 13px; border-radius: 13px; border: 1px solid #d9e3de; background: linear-gradient(150deg, #fff, #f2f6f3); color: var(--bs-ink); transition: border-color .15s, transform .15s, box-shadow .15s; }
#library.bs-library .bs-pack:hover { border-color: var(--bs-teal); transform: translateY(-2px); box-shadow: 0 10px 22px #18302e14; }
.bs-pack i { font-style: normal; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 8px; background: var(--bs-ink); color: var(--bs-gold); font-size: 14px; margin-bottom: 5px; }
.bs-pack b { font-size: 13.5px; }
.bs-pack small { font-size: 11.5px; color: var(--bs-muted); line-height: 1.4; }
.bs-pack span { font-size: 11px; font-weight: 700; color: var(--bs-teal); margin-top: 5px; }

/* Karten */
.bs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 14px; }
.bs-card { display: flex; flex-direction: column; border-radius: 14px; border: 1px solid var(--bs-line); background: #fff; overflow: hidden; cursor: pointer; transition: transform .16s, box-shadow .16s, border-color .16s; }
.bs-card:hover { transform: translateY(-3px); box-shadow: 0 16px 34px #18302e1f; border-color: #b7cdc4; }
.bs-card:active { cursor: grabbing; }
.bs-thumb { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: linear-gradient(135deg, #eef2ef, #e3e9e5); border-bottom: 1px solid var(--bs-line); }
.bs-thumb::before { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, #ffffff00 0 40%, #ffffff66 50%, #ffffff00 60% 100%); background-size: 200% 100%; animation: bs-shimmer 1.4s linear infinite; }
.bs-thumb iframe { position: absolute; top: 0; left: 0; width: 900px; height: calc(100% / var(--bs-scale, .3)); border: 0; transform: scale(var(--bs-scale, .3)); transform-origin: 0 0; pointer-events: none; background: transparent; }
.bs-thumb.bs-loaded::before { display: none; }
@keyframes bs-shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .bs-thumb::before { animation: none; } .bs-card, .bs-pack { transition: none; } }
#library.bs-library .bs-star { position: absolute; top: 8px; right: 8px; z-index: 3; width: 30px; height: 30px; border-radius: 50%; border: 0; background: #ffffffe6; color: #9aa7ab; font-size: 15px; line-height: 1; box-shadow: 0 2px 8px #0002; }
#library.bs-library .bs-star[aria-pressed=true] { color: #c99a3d; }
.bs-count { position: absolute; left: 8px; top: 8px; z-index: 3; font-size: 10.5px; font-weight: 700; padding: 4px 8px; border-radius: 999px; background: var(--bs-ink); color: #fff; }
.bs-hover { position: absolute; inset: 0; z-index: 2; display: flex; align-items: flex-end; justify-content: center; gap: 6px; padding: 12px; background: linear-gradient(#18302e00 40%, #18302ecc); opacity: 0; transition: opacity .16s; }
.bs-card:hover .bs-hover, .bs-card:focus-within .bs-hover { opacity: 1; }
#library.bs-library .bs-add { height: 34px; padding: 0 16px; border-radius: 10px; border: 0; background: #fff; color: var(--bs-ink); font-size: 13px; font-weight: 700; }
#library.bs-library .bs-add:hover { background: var(--bs-gold); }
#library.bs-library .bs-zoom { width: 34px; height: 34px; border-radius: 10px; border: 1px solid #ffffff80; background: #ffffff26; color: #fff; font-size: 15px; }
.bs-copy { display: grid; gap: 3px; padding: 11px 13px 13px; }
.bs-cat { display: flex; align-items: center; gap: 6px; font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; color: #8a6a43; }
.bs-cat i { font-style: normal; width: 20px; height: 20px; display: grid; place-items: center; border-radius: 6px; background: #f2ebe1; color: #8a6a43; font-size: 11px; letter-spacing: 0; }
.bs-copy b { font-size: 14.5px; color: var(--bs-ink); }
.bs-copy small { font-size: 12px; color: var(--bs-muted); line-height: 1.4; }
.bs-empty { grid-column: 1 / -1; padding: 22px; text-align: center; border: 1px dashed #c9d5cf; border-radius: 12px; color: var(--bs-muted); font-size: 13px; }
.bs-foot { margin-top: 16px !important; font-size: 12px; color: var(--bs-muted); line-height: 1.5; padding: 10px 12px; border-radius: 10px; background: #f3f1ea; }

/* Beim Ziehen: Vorschau hervorheben */
body.bs-dragging .canvas { outline: 3px dashed #d9b38c; outline-offset: 4px; border-radius: 14px; }

/* Große Vorschau */
#bsPreviewDialog { width: min(1180px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0; border: 0; border-radius: 20px; background: #fbfaf7; box-shadow: 0 30px 90px #0b182040; overflow: hidden; flex-direction: column; font-family: system-ui, -apple-system, "Segoe UI", sans-serif; color: #182c3a; }
#bsPreviewDialog[open] { display: flex; }
#bsPreviewDialog::backdrop { background: #0b1820a6; backdrop-filter: blur(3px); }
.bs-dlg-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 18px 22px; background: linear-gradient(110deg, #182c3a, #1d4a4f); color: #fff; }
.bs-dlg-head h2 { margin: 3px 0; font-size: 21px; color: #fff; }
.bs-dlg-head p { margin: 0; opacity: .8; font-size: 13px; }
.bs-dlg-head .bs-kicker { color: #e7c9a2; text-transform: uppercase; }
#bsPreviewDialog button { font: inherit; cursor: pointer; margin: 0; min-height: 0; box-shadow: none; }
#bsPreviewDialog .bs-dlg-close { width: 36px; height: 36px; border-radius: 10px; border: 1px solid #ffffff40; background: #ffffff1a; color: #fff; padding: 0; }
.bs-dlg-stage { flex: 1; min-height: 0; padding: 16px; background: #e9eeea; overflow: auto; }
.bs-dlg-stage iframe { display: block; width: 100%; height: min(62vh, 640px); border: 0; border-radius: 12px; background: #fff; box-shadow: 0 10px 30px #18302e1f; }
.bs-dlg-foot { display: flex; align-items: center; gap: 12px; padding: 14px 22px; border-top: 1px solid #e1e7e4; background: #fff; }
.bs-dlg-foot small { margin-right: auto; color: #66777d; font-size: 12px; }
#bsPreviewDialog .bs-dlg-add { height: 40px; padding: 0 18px; border-radius: 11px; border: 0; background: #1d5c55; color: #fff; font-weight: 700; white-space: nowrap; }
@media (max-width: 640px) { .bs-dlg-foot { flex-wrap: wrap; } #bsPreviewDialog .bs-dlg-add { width: 100%; } }

/* Zieh-Vorschau */
.bs-card { touch-action: pan-y; user-select: none; }
.bs-ghost { position: fixed; left: 0; top: 0; z-index: 9999; pointer-events: none; display: flex; align-items: center; gap: 8px; padding: 9px 14px 9px 10px; border-radius: 12px; background: #182c3a; color: #fff; font: 600 13px system-ui, -apple-system, "Segoe UI", sans-serif; box-shadow: 0 14px 34px #0b182045; opacity: .92; }
.bs-ghost i { font-style: normal; width: 22px; height: 22px; display: grid; place-items: center; border-radius: 7px; background: #d9b38c; color: #182c3a; }
.bs-ghost.bs-ghost-over { background: #1d5c55; }
body.bs-dragging, body.bs-dragging * { cursor: grabbing !important; }
.bs-shield { position: fixed; z-index: 9998; background: transparent; }
