:root {
  --bg: #0e0f12; --panel: #17181d; --panel2: #1d1f26; --border: #2a2c33;
  --text: #e8e8ea; --muted: #9a9ca6; --accent: #0a5c6d; --btn: #063c48; --accent-text: #45a8ba; --green: #4caf7d; --red: #d95757;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, "Helvetica Neue", sans-serif; min-height: 100vh; }

.topbar { display: flex; align-items: baseline; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.topbar h1 { font-size: 18px; letter-spacing: .04em; }
.topbar h1 span { color: var(--accent-text); }
.topbar .sub { color: var(--muted); font-size: 12px; flex: 1; }
.topbar button { padding: 6px 12px; font-size: 12px; }

.layout { display: grid; grid-template-columns: 1fr 300px; min-height: calc(100vh - 53px); }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } .sidebar { max-height: 40vh; } }

/* ---------- Sidebar (Presets) ---------- */
.sidebar { border-left: 1px solid var(--border); overflow-y: auto; padding: 12px; background: var(--panel); }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.tabs button { background: var(--panel2); color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px; font-size: 12px; cursor: pointer; }
.tabs button.active { background: var(--accent); color: #e9fffb; border-color: var(--accent); font-weight: 600; }
.tabs button.tab-accent { border-color: var(--accent); color: var(--accent); font-weight: 600; }
.tabs button.tab-accent.active { background: var(--accent); color: #e9fffb; }
.sizebar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.sizebar select { width: auto; padding: 4px 8px; }
details.cat { margin-bottom: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--panel2); }
details.cat summary { cursor: pointer; padding: 8px 10px; font-size: 12px; font-weight: 600; color: var(--text); list-style: none; }
details.cat summary::before { content: "▸ "; color: var(--accent-text); }
details.cat[open] summary::before { content: "▾ "; }
.preset-item { display: block; width: 100%; text-align: left; background: transparent; border: none; border-top: 1px solid var(--border); color: var(--muted); padding: 7px 12px; font-size: 12.5px; cursor: pointer; }
.preset-item:hover { color: var(--text); background: #23252d; }
.section-label { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--accent-text); margin: 12px 0 6px 2px; }

/* ---------- Main ---------- */
.main { padding: 16px 20px 80px; overflow-x: hidden; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
input, select, textarea { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 9px 11px; font: inherit; width: 100%; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
button { background: var(--btn); color: #e9fffb; border: none; border-radius: 6px; padding: 9px 16px; font: inherit; font-weight: 600; cursor: pointer; }
button:hover:not(:disabled):not(.ghost):not(.mini):not(.cancelbtn) { background: var(--accent); }
button:disabled { opacity: .45; cursor: default; }
button.ghost { background: transparent; color: var(--text); border: 1px solid var(--border); }
button.small { padding: 6px 11px; font-size: 12.5px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
/* Werkzeug-Reihe ÜBER dem Prompt-Fenster, RECHTSBÜNDIG (Tobias 23.08.):
   „⚙ Umbauen" schliesst rechts buendig mit dem Editor ab, die anderen laufen nach links weiter. */
.toolrow-top { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin: 6px 0 8px; }
.minisel { width: auto; font-size: 12px; padding: 5px 8px; }
.smartedit { display: flex; gap: 8px; margin-top: 10px; }
.smartedit input, .smartedit textarea { flex: 1; }
.smartedit { align-items: flex-start; }

.status { font-size: 13px; color: var(--muted); margin-top: 8px; min-height: 18px; }
.status.ok { color: var(--green); } .status.err { color: var(--red); }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.cost { font-size: 12px; color: var(--accent); }

.genrow { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.genrow > div { min-width: 150px; flex: 1; }
.genrow .btncell { flex: 0; min-width: auto; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--cardw, 220px), 1fr)); gap: 12px; margin-top: 14px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.card img { width: 100%; display: block; }
.card .meta { padding: 8px 10px; font-size: 11.5px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.card a { color: var(--accent-text); text-decoration: none; font-weight: 600; }
/* Galerie-Karte v2 (28.09.2026, Tobias): Kopfzeile Modell · Maße · Qualität / Uhrzeit / Dateiname, echte Knöpfe darunter */
.card .ckopf { padding: 8px 10px 6px; }
.card .ctitel { font-size: 13.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.card .cinfo { font-size: 12px; color: var(--muted); margin-top: 1px; }
.card .cname { font-size: 11.5px; color: var(--accent-text); overflow-wrap: anywhere; line-height: 1.3; margin-top: 2px; cursor: copy; }
.card .cname:hover { text-decoration: underline; }
.card .cbtns { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; padding: 8px 10px 10px; }
.card button.cbtn { height: 42px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 2px 3px; background: var(--panel2); border: 1px solid var(--border); border-radius: 6px; color: var(--text); font-size: 11.5px; font-weight: 500; line-height: 1.1; cursor: pointer; }
.card button.cbtn:hover { border-color: var(--accent-text); color: var(--accent-text); }
.card .cbtn .ci { font-size: 17px; line-height: 1; }
.gallery.klein .cbtn .cl { display: none; }
.gallery.klein .cbtn { height: 32px; }
.gallery.klein .cbtns { grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 4px; padding: 6px; }
/* Großansicht: Aktionsknöpfe in der Kopfleiste (28.09.2026) */
#fwAkt { display: flex; gap: 4px; flex-wrap: wrap; }
#fwAkt .mini { font-size: 12px; padding: 4px 8px; }

/* ---------- Referenz-Slots ---------- */
.dropzone { border: 2px dashed var(--border); border-radius: 8px; min-height: 140px; display: flex; align-items: center; justify-content: center; padding: 18px; text-align: center; color: var(--muted); font-size: 13px; cursor: pointer; }
.dropzone.over { border-color: var(--accent-text); color: var(--accent-text); background: #0f2320; }
.slot { display: flex; gap: 10px; align-items: center; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 8px; margin-bottom: 6px; }
.slot img { width: 56px; height: 56px; object-fit: cover; border-radius: 6px; flex-shrink: 0; }
.slotmid { flex: 1; min-width: 0; }
.slotname { font-size: 12px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slotnote { margin-top: 4px; font-size: 12px; padding: 5px 8px; }
.slotstatus { font-size: 11px; color: var(--green); margin-top: 3px; min-height: 13px; }
.slotbtns { display: flex; flex-direction: column; gap: 3px; }
button.mini { background: transparent; border: 1px solid var(--border); color: var(--muted); border-radius: 5px; padding: 2px 7px; font-size: 11px; cursor: pointer; }
button.mini:hover { color: var(--text); border-color: var(--accent); }
.badge { display: inline-block; font-size: 10px; font-weight: 700; letter-spacing: .05em; color: #e9fffb; background: var(--accent); border-radius: 4px; padding: 1px 6px; margin-bottom: 3px; }
.badge.dim { background: var(--border); color: var(--muted); }

/* ---------- Lightbox + Kontextmenü ---------- */
#lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); display: none; align-items: center; justify-content: center; z-index: 90; cursor: zoom-out; }
#lightbox.open { display: flex; }
#lightbox img { max-width: 94vw; max-height: 90vh; border-radius: 8px; box-shadow: 0 8px 40px rgba(0,0,0,.6); }
#lbCounter { position: fixed; bottom: 14px; left: 0; right: 0; text-align: center; color: var(--muted); font-size: 13px; }
#visModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 85; overflow-y: auto; padding: 40px 16px; }
#visModal.open { display: flex; }
#visModal .preset-item { border: 1px solid var(--border); border-radius: 6px; margin-bottom: 6px; }
#ctxmenu { position: fixed; z-index: 95; background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 4px; display: none; min-width: 240px; box-shadow: 0 6px 24px rgba(0,0,0,.5); }
#ctxmenu.open { display: block; }
#ctxmenu button { display: block; width: 100%; text-align: left; background: transparent; border: none; color: var(--text); padding: 8px 10px; font-size: 13px; border-radius: 5px; cursor: pointer; }
#ctxmenu button:hover { background: var(--accent); color: #e9fffb; }
.card img { cursor: zoom-in; }

/* ---------- Character Studio ---------- */
#csModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 80; overflow-y: auto; padding: 40px 16px; }
#csModal.open { display: flex; }
.csbox { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; width: 100%; max-width: 640px; }
.cshead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.csrow { display: grid; grid-template-columns: 130px 1fr; gap: 10px; align-items: center; margin-bottom: 7px; }
.csrow label { margin: 0; }
.csinp { display: flex; gap: 6px; }
.csinp input { flex: 1; padding: 7px 10px; font-size: 13px; }
.csinp .mini { flex-shrink: 0; font-size: 13px; padding: 4px 9px; }

/* ---------- Login ---------- */
#login { max-width: 420px; margin: 60px auto; }
.hidden { display: none !important; }

/* ---------- CodeMirror dark theme + prompt-mode tokens ---------- */
.CodeMirror { background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 8px; height: 580px; font: 13.5px/1.6 "SF Mono", Menlo, monospace; }
.CodeMirror-cursor { border-left: 1px solid var(--accent); }
.CodeMirror-selected { background: #2c3040 !important; }
.CodeMirror-gutters { background: var(--panel); border-right: 1px solid var(--border); }
.CodeMirror-linenumber { color: #4a4d58; }
.cm-comment-section { color: var(--accent-text); font-weight: 700; }
.cm-comment-header { color: var(--accent-text); }
.cm-comment { color: #6b6e7a; font-style: italic; }
.cm-parameter { color: #c792ea; }
.cm-weight-value, .cm-weight-block { color: #f78c6c; }
.cm-negative-prompt { color: var(--red); }
.cm-aspect-ratio, .cm-camera-setting, .cm-number, .cm-technical-term { color: #82aaff; }
.cm-emphasis, .cm-keyword-quality { color: #ffcb6b; }
.cm-keyword-video, .cm-keyword-movement, .cm-keyword-temporal { color: #89ddff; }
.cm-keyword-lighting { color: #ffd580; }
.cm-keyword-grading, .cm-keyword-color { color: #f07178; }
.cm-keyword-camera, .cm-keyword-composition { color: #80cbc4; }
.cm-keyword-film { color: #c3e88d; }
.cm-keyword-style { color: #b2ccd6; }
.cm-keyword-subject, .cm-keyword-location { color: #a6accd; }
.cm-variable { color: #c792ea; }

/* ---------- Arbeitsfläche: linke Spalte (Editor+Refs) · Splitter · rechte Spalte (Preview+Image+Video) ---------- */
.workspace { display: flex; align-items: flex-start; margin-bottom: 14px; }
.colL { flex: 1; min-width: 320px; display: flex; flex-direction: column; gap: 14px; }
.colR { width: 380px; flex: none; display: flex; flex-direction: column; gap: 14px; }
.colL .panel, .colL details.panel, .colR .panel, .colR details.panel { margin-bottom: 0; }
.splitter { width: 12px; align-self: stretch; cursor: col-resize; flex: none; position: relative; }
.splitter::after { content: ""; position: absolute; left: 5px; top: 0; bottom: 0; width: 2px; background: var(--border); border-radius: 2px; }
.splitter:hover::after { background: var(--accent); }
.colR .genrow > div { min-width: 120px; }
.panel > label[draggable], details.panel > summary[draggable] { cursor: grab; }
.CodeMirror { resize: vertical; min-height: 220px; }
@media (max-width: 1100px) { .workspace { flex-direction: column; } .colR { width: 100%; } .splitter { display: none; } }

/* ---------- Umbau-Runde 2 (19.08.) ---------- */
/* Panel-Überschriften in Akzentfarbe, Module zuklappbar */
.panel > label:first-child, details.panel > summary { color: var(--accent-text); font-weight: 700; }
details.panel > summary { list-style: none; cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 8px; }
details.panel > summary::before { content: "▾ "; }
details.panel:not([open]) > summary::before { content: "▸ "; }
details.panel:not([open]) { padding: 10px 14px; }
details.panel:not([open]) > summary { margin-bottom: 0; }
.sumhint { color: var(--muted); font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; margin-left: 6px; }
.accentbtn { background: transparent; border: 1px solid var(--accent-text); color: var(--accent-text); border-radius: 6px; }
.accentbtn:hover { background: var(--accent); color: #e9fffb; }
#prevImg { width: 100%; border-radius: 8px; cursor: zoom-in; display: block; }

/* Schwebendes, frei verschieb- und skalierbares Ansichtsfenster mit Zoom */
#floatWin { position: fixed; top: 70px; left: 70px; width: 620px; height: 660px; min-width: 300px; min-height: 260px; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; display: none; flex-direction: column; z-index: 95; resize: both; overflow: hidden; box-shadow: 0 12px 48px rgba(0,0,0,.65); }
#floatWin.open { display: flex; }
#fwBar { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: move; user-select: none; }
#fwTitle { font-weight: 700; color: var(--accent-text); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
#fwInfo { flex: 1; color: var(--muted); font-size: 12px; }
#fwView { flex: 1; overflow: hidden; position: relative; background: #000; display: flex; align-items: center; justify-content: center; cursor: grab; }
#fwView:active { cursor: grabbing; }
#fwImg { max-width: 100%; max-height: 100%; user-select: none; }

/* Vision-Knopf am Referenz-Slot: sichtbar statt unscheinbar */
button.mini[data-a="vis"] { background: var(--accent); border-color: var(--accent); color: #e9fffb; font-size: 14px; padding: 5px 10px; }
button.mini[data-a="vis"]:hover { background: var(--accent-text); border-color: var(--accent-text); color: #06272e; }

/* Abbrechen-Zustand im Generier-Knopf */
button.cancelbtn { background: var(--red) !important; color: #fff !important; border-color: var(--red) !important; }

/* Grid-Extraktion */
#gridxModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 88; overflow-y: auto; padding: 40px 16px; }
#gridxModal.open { display: flex; }
.gxcell { border: 1px dashed rgba(255,255,255,.45); cursor: pointer; }
.gxcell:hover { background: rgba(69,168,186,.28); border-color: var(--accent-text); border-style: solid; }

#slotPickModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#slotPickModal.open { display: flex; }
#psModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#psModal.open { display: flex; }
#cropModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#cropModal.open { display: flex; }
#dressModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#dressModal.open { display: flex; }
/* 12.10.: Mess-Fenster der Lichtmessung (Bau 2) hatte kein Overlay-CSS → stand als Geister-Fenster am Seitenende */
#lmModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 95; overflow-y: auto; padding: 40px 16px; }
#lmModal.open { display: flex; }
/* 12.10.: dito die Video-Werkzeuge aus Bau 3 (Seedance 2.5 Director, Sound for Video) */
#sdModal, #sfvModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 86; overflow-y: auto; padding: 40px 16px; }
#sdModal.open, #sfvModal.open { display: flex; }
#idrModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#idrModal.open { display: flex; }
#tpzModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#tpzModal.open { display: flex; }
#enhModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#enhModal.open { display: flex; }
#sktModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#sktModal.open { display: flex; }
#dressModal .dsrow { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
#dressModal .dsrow img { width: 64px; height: 64px; object-fit: cover; border-radius: 6px; flex: 0 0 auto; }
#dressModal .dsmain { flex: 1; min-width: 0; }
#dressModal .dsname { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 4px; }
#dressModal .dsctl { display: flex; gap: 6px; margin-bottom: 4px; }
#dressModal .dsowner { flex: 1; font-size: 11px; }
#dressModal .dsdesc { width: 100%; min-height: 34px; font-size: 10.5px; font-family: inherit; resize: vertical; }
/* Nacht-Bau-Fenster 21./22.08. — Overlay-CSS fehlte seit dem Bau (Tobias-Fund 24.08.):
   ohne position:fixed + display:none kleben sie als normale Bloecke am Seitenende */
#poseGridModal, #projPickModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#rlModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#rlModal.open { display: flex; }
#ssModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#ssModal.open { display: flex; }
#blModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 84; overflow-y: auto; padding: 40px 16px; }
#blModal.open { display: flex; }
/* 🖊 Markieren & Bearbeiten v3 (28.09.2026): frei schwebendes, großes Fenster wie 🧊 3D — Kopfzeile ziehen,
   Ecke skalieren; --mnfs = Schriftgröße aller Bedienelemente, wächst mit der Fensterbreite (malen.js) */
#mnModal { --mnfs: 14px; position: fixed; top: 40px; left: 60px; width: min(1500px, 94vw); height: 88vh; min-width: 720px; min-height: 480px; max-width: 98vw; max-height: 96vh; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; display: none; z-index: 93; resize: both; overflow: hidden; box-shadow: 0 12px 48px rgba(0,0,0,.65); font-size: var(--mnfs); }
#mnModal.open { display: flex; }
#mnModal::after { content: ''; position: absolute; right: 3px; bottom: 3px; width: 14px; height: 14px; background: repeating-linear-gradient(135deg, transparent 0 3px, var(--accent-text) 3px 5px); border-radius: 2px; pointer-events: none; }
#mnModal .csbox { position: relative; width: 100%; height: 100%; max-width: none !important; box-shadow: none; border: none; display: flex; flex-direction: column; overflow: hidden; padding: 12px 16px 14px; }
#mnModal .cshead { cursor: grab; user-select: none; margin-bottom: 8px; }
#mnModal .cshead b { font-size: calc(var(--mnfs) + 2px); }
#mnModal .hint, #mnModal .status, #mnModal label, #mnModal input, #mnModal select, #mnModal textarea, #mnModal button.mini, #mnModal .accentbtn, #mnModal .minisel { font-size: var(--mnfs); }
#mnModal .mnhint { margin: 0 0 8px; line-height: 1.4; }
#mnModal button.mini { padding: 5px 11px; }
#mnModal .accentbtn { padding: 6px 14px; }
#mnModal .mnrow { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
#mnModal .mnlabel { display: flex; align-items: center; gap: 6px; margin: 0; text-transform: none; letter-spacing: 0; color: var(--text); }
#mnModal input[type=radio], #mnModal input[type=checkbox] { width: auto; margin: 0; }
#mnModal #mnZusatz { padding: 6px 10px; }
#mnWrap { flex: 1 1 auto; min-height: 120px; display: flex; background: #191919; border-radius: 8px; overflow: auto; scrollbar-gutter: stable both-edges; }
#mnTexte { display: none; max-height: 22%; overflow: auto; margin: 6px 0 0; padding: 4px 8px; background: var(--panel2); border-radius: 6px; color: var(--text); line-height: 1.35; }
#mnTexte .mnanw { padding: 2px 0; }
#mnTexte .mnanw b { color: var(--accent-text); }
#mnTextPop { display: none; position: absolute; left: 20px; top: 80px; width: min(440px, 80%); z-index: 5; background: var(--panel2); border: 1px solid var(--accent); border-radius: 10px; padding: 10px 12px; box-shadow: 0 10px 36px rgba(0,0,0,.6); }
#mnTextPop.open { display: block; }
#mnTextPop .mntp-kopf { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
#mnTextPop textarea { width: 100%; resize: vertical; min-height: 64px; line-height: 1.4; padding: 8px 10px; font-family: inherit; }
#pqModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 86; overflow-y: auto; padding: 40px 16px; }
#pqModal.open { display: flex; }
/* 360° Character Sheet (03.09.): 6 Einzel-Ansichten + lokaler Sheet-Bau */
#cr360Modal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 86; overflow-y: auto; padding: 40px 16px; }
#cr360Modal.open { display: flex; }
#upresModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 86; overflow-y: auto; padding: 40px 16px; }
#upresModal.open { display: flex; }
/* 🧊 3D: frei schwebendes Fenster ÜBER der App (kein Overlay) — Kopfzeile ziehen, Ecke skalieren */
#bnModal { position: fixed; top: 56px; left: 72px; width: min(1080px, 92vw); height: 76vh; min-width: 660px; min-height: 420px; max-width: 98vw; max-height: 96vh; background: var(--panel); border: 1px solid var(--accent); border-radius: 10px; display: none; z-index: 92; resize: both; overflow: hidden; box-shadow: 0 12px 48px rgba(0,0,0,.65); }
#bnModal.open { display: flex; }
#bnModal .csbox { width: 100%; max-width: none !important; box-shadow: none; border: none; display: flex; flex-direction: column; overflow-y: auto; }
#bnModal .cshead { cursor: grab; user-select: none; }
#poseGridModal.open, #projPickModal.open { display: flex; }
#psModal .psrow { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); }
#psModal .psrow img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; }
#psModal .psrow select { flex: 0 0 auto; }
/* Location Builder: schwebendes Fenster statt Overlay — Hintergrund bleibt sichtbar/bedienbar,
   Fenster bleibt bei Preview offen und ist am Kopf frei verschiebbar (Tobias' Preview-Durchklick-Workflow) */
#lbModal { position: fixed; inset: 0; background: transparent; pointer-events: none; display: none; align-items: flex-start; justify-content: center; z-index: 84; padding: 40px 16px; }
#lbModal.open { display: flex; }
#lbModal .csbox { pointer-events: auto; border: 1px solid var(--accent); box-shadow: 0 12px 48px rgba(0,0,0,.6); max-height: 84vh; overflow-y: auto; }
#lbModal .cshead { cursor: move; position: sticky; top: 0; background: var(--panel); z-index: 2; }
/* Posen-Bibliothek: gleiches schwebendes Fenster-Muster */
#poseLib { position: fixed; inset: 0; background: transparent; pointer-events: none; display: none; align-items: flex-start; justify-content: center; z-index: 85; padding: 40px 16px; }
#poseLib.open { display: flex; }
#poseLib .csbox { pointer-events: auto; border: 1px solid var(--accent); box-shadow: 0 12px 48px rgba(0,0,0,.6); max-height: 84vh; overflow-y: auto; max-width: 720px; }
#poseLib .cshead { cursor: move; position: sticky; top: 0; background: var(--panel); z-index: 2; }
.posecard { border: 1px solid var(--border); border-radius: 8px; background: var(--panel2); padding: 6px; width: 148px; display: flex; flex-direction: column; gap: 4px; }
.posecard img { width: 100%; height: 150px; object-fit: cover; border-radius: 6px; cursor: pointer; background: #000; }
.posecard .pname { font-size: 11px; font-weight: 600; }
.posecard .pkat { font-size: 10px; color: var(--muted); }
.posechip { font-size: 11px; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--panel2); cursor: pointer; }
.posechip.act { border-color: var(--accent-text); color: var(--accent-text); }

#projWin { position: fixed; right: 24px; bottom: 24px; width: 380px; height: 520px; max-height: 96vh; overflow-y: auto; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; z-index: 70; display: none; box-shadow: 0 12px 40px rgba(0,0,0,.5); }
#projWin.open { display: block; }
#projHead { display: flex; align-items: center; gap: 8px; padding: 14px 12px; border-bottom: 1px solid var(--border); cursor: move; position: sticky; top: 0; background: var(--panel); border-radius: 12px 12px 0 0; }
#projWin, #lbModal .csbox, #poseLib .csbox { cursor: move; }
#projWin input, #projWin textarea, #projWin button, #projWin select, #projWin img,
#lbModal .csbox input, #lbModal .csbox textarea, #lbModal .csbox button, #lbModal .csbox select,
#poseLib .csbox input, #poseLib .csbox button, #poseLib .csbox img { cursor: auto; }
#lbModal .cshead, #poseLib .cshead { padding-top: 14px; padding-bottom: 14px; }

details.toolscat { border-color: var(--accent); margin-bottom: 10px; }
details.toolscat > summary { color: var(--accent-text); font-size: 13px; }
/* 31.08.: Slideshow-Zugang als gruener Knopf in Ordner-Optik (rechte Leiste) */
.toolsbtn { display: block; width: 100%; text-align: left; background: var(--panel); border: 1px solid var(--accent); border-radius: 8px; color: var(--accent-text); font-size: 13px; padding: 8px 12px; margin-bottom: 10px; cursor: pointer; }
.toolsbtn:hover { filter: brightness(1.15); }

#projWin { resize: both; min-width: 320px; min-height: 200px; max-width: 96vw; }
/* Sichtbarer Anfasser unten rechts (der Browser-Griff verschwindet hinter border-radius/overflow) */
#projWin::after { content: ''; position: sticky; float: right; bottom: 2px; right: 2px; width: 14px; height: 14px; margin-top: -14px;
  background: linear-gradient(135deg, transparent 45%, var(--accent-text) 45%, var(--accent-text) 55%, transparent 55%, transparent 70%, var(--accent-text) 70%, var(--accent-text) 80%, transparent 80%);
  opacity: .6; pointer-events: none; }

#genBtn.genactive, #btnPreview.genactive { background: #7a4a00; border-color: #e0a437; color: #ffe4b0; }
#genBtn { position: relative; }
#genAbortX { position: absolute; top: 2px; left: 4px; font-size: 10px; line-height: 1; opacity: .75; cursor: pointer; padding: 2px 3px; border-radius: 3px; }
#genAbortX:hover { opacity: 1; background: rgba(0,0,0,.35); }
#genBtn.genactive::after { content: " · läuft…"; font-weight: 400; }

/* Upscale und Enhance (Topaz-Vollkatalog, 26.08.) — Geister-Fenster-Lehre: Overlay-CSS Pflicht */
#upeModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 85; overflow-y: auto; padding: 40px 16px; }
#upeModal.open { display: flex; }
.upebtn { background: #1e6f3e; color: #eafff1; border: 1px solid #2c8a50; border-radius: 8px; cursor: pointer; }
.upebtn:hover { background: #27884d; }
.upechip { border-color: #2c8a50; }
/* UpE-Fenster frei skalierbar (Tobias 26.08.): Ziehgriff unten rechts, bis Vollbild */
#upeBox { width: min(880px, 96vw); max-width: 98vw; max-height: 96vh; min-width: 660px; min-height: 420px; resize: both; overflow: auto; }
#upeBox::after { content: ''; position: sticky; float: right; bottom: 2px; width: 14px; height: 14px; background: repeating-linear-gradient(135deg, transparent 0 3px, #2c8a50 3px 5px); border-radius: 2px; pointer-events: none; }
/* Video-Großansicht (26.08., Fenster-Standard) */
/* Fenster-Standard fuer Alt-Fenster (winstd.js): frei skalierbar bis ~Vollbild, Griff-Indikator unten rechts */
.csbox.winstd { resize: both; overflow: auto; max-width: 98vw !important; max-height: 96vh !important; min-width: 340px; min-height: 180px; }
.csbox.winstd::after { content: ''; position: sticky; float: right; bottom: 2px; width: 14px; height: 14px; background: repeating-linear-gradient(135deg, transparent 0 3px, var(--accent-text, #45a8ba) 3px 5px); border-radius: 2px; pointer-events: none; }

#upeViewModal { position: fixed; inset: 0; background: rgba(0,0,0,.78); display: none; align-items: flex-start; justify-content: center; z-index: 95; overflow-y: auto; padding: 30px 16px; }
#upeViewModal.open { display: flex; }
#upeViewBox { width: min(1400px, 96vw); max-width: 98vw; max-height: 96vh; min-width: 520px; min-height: 340px; resize: both; overflow: auto; }

#vidViewModal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: none; align-items: flex-start; justify-content: center; z-index: 90; overflow-y: auto; padding: 30px 16px; }
#vidViewModal.open { display: flex; }
#vidViewBox { width: min(1200px, 94vw); max-width: 98vw; max-height: 96vh; min-width: 480px; min-height: 320px; resize: both; overflow: auto; }

/* 🧊 OBJEKT-BIBLIOTHEK in der 3D-Bühne (15.09.2026) — Kacheln im schmalen rechten Streifen */
.objliste { display: flex; flex-direction: column; gap: 4px; margin: 4px 0; }
.objkachel { display: flex; gap: 6px; align-items: flex-start; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 6px; padding: 4px; }
.objkachel img { width: 48px; height: 48px; flex: none; object-fit: cover; border-radius: 4px; background: #f0f0f0; }
.objkachel .objleer { width: 48px; height: 48px; flex: none; display: flex; align-items: center; justify-content: center; border-radius: 4px; background: #333; color: var(--muted); font-size: 11px; }
.objtext { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.objname { font-size: 11.5px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.objzeile { display: flex; gap: 4px; align-items: center; }
.objzeile .objhoehe { width: 58px; font-size: 11px; padding: 2px 4px; }
.objslots { display: flex; gap: 4px; flex-wrap: wrap; margin: 2px 0; }
.objslot { width: 40px; height: 40px; padding: 0; overflow: hidden; border: 1px solid var(--border); border-radius: 4px; background: #222; cursor: pointer; color: var(--muted); }
.objslot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.objslot:hover { border-color: var(--accent, #45a8ba); }
/* Grundstock-Fenster (15.09.2026): freie CC0-Objekte aus public/objekte/ als Kachelraster.
   Liegt UEBER der 3D-Buehne (#bnModal hat z-index 92), deshalb 96. */
#gsModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 96; overflow-y: auto; padding: 40px 16px; }
#gsModal.open { display: flex; }
.gsraster { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.gskachel { display: flex; flex-direction: column; gap: 3px; background: rgba(255,255,255,.04); border: 1px solid var(--border); border-radius: 8px; padding: 6px; }
.gskachel .gsbild { width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 5px; background: #f0f0f0; display: block; }
.gskachel .gsname { font-size: 12px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gskachel .gsklein { font-size: 10.5px; line-height: 1.25; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsknoepfe { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 2px; }
.gsknoepfe .mini { font-size: 10.5px; padding: 2px 5px; }
.gsfertig { font-size: 10.5px; color: var(--muted); padding: 2px 0; }

/* Anziehen v2 (21.09.2026): Sitz-Feld fuer Accessoires */
.dsrow .dssitz { width: 100%; font-size: 13px; line-height: 1.35; padding: 6px 8px; min-height: 50px; box-sizing: border-box; resize: vertical; }
.dsrow .dsquelle { width: auto; }

/* 📝 PROMPT ZUM BILD (24.09.2026) — Fenster + Slot-Knopf, wenn ein Prompt gefunden wurde */
#paModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 96; overflow-y: auto; padding: 40px 16px; }
#paModal.open { display: flex; }
#paModal .paItem { border-top: 1px solid var(--border); padding: 10px 0 6px; }
#paModal .paMeta { font-size: 12px; color: var(--text); margin-bottom: 2px; word-break: break-word; }
#paModal .paQuelle { font-size: 11px; color: var(--muted); margin-bottom: 6px; }
#paModal .paText { width: 100%; min-height: 240px; font-size: 12px; line-height: 1.45; font-family: inherit; resize: vertical; box-sizing: border-box; }
#paModal .paBtns { display: flex; gap: 8px; margin-top: 6px; align-items: center; }
.slotbtns .mini.pfund { background: var(--accent); color: #fff; border-color: var(--accent-text); }
/* 17.10.: 📐 Kamerawinkel-Fenster (Bild-Grids, ersetzt das Dropdown „Winkel …") — Overlay-CSS Pflicht fuer per JS erzeugte Fenster */
#kwModal { position: fixed; inset: 0; background: rgba(0,0,0,.7); display: none; align-items: flex-start; justify-content: center; z-index: 86; overflow-y: auto; padding: 40px 16px; }
#kwModal.open { display: flex; }
#kwModal .kwmodes { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 4px 0 6px; }
#kwModal .kwmodes button { padding: 9px 16px; font-size: 13.5px; font-weight: 600; background: transparent; color: var(--muted); border: 2px solid var(--border); border-radius: 10px; }
#kwModal .kwmodes button.on { background: var(--accent); color: #fff; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,255,255,.08) inset; }
#kwModal .kwmodeline { font-size: 12.5px; color: var(--text); background: var(--panel2); border-left: 4px solid var(--accent); padding: 6px 10px; border-radius: 6px; margin-bottom: 10px; }
#kwModal .kwgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
#kwModal .kwgroup { grid-column: 1 / -1; font-size: 12px; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; margin: 6px 0 0; padding-top: 6px; border-top: 1px solid var(--border); }
#kwModal .kwtile { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--panel2); cursor: pointer; text-align: left; padding: 0; }
#kwModal .kwtile:hover { border-color: var(--accent); }
#kwModal .kwtile img, #kwModal .kwtile .kwph { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
#kwModal .kwtile .kwph { display: flex; align-items: center; justify-content: center; font-size: 26px; color: var(--muted); }
#kwModal .kwtile .kwname { padding: 5px 7px 0; font-size: 12px; font-weight: 600; }
#kwModal .kwtile .kwsub { padding: 0 7px 6px; font-size: 10.5px; color: var(--muted); }
