/* models.talutah.de – dunkle Bühne */

:root {
  --bg: #17171a;
  --surface: #26262b;
  --surface-2: #33333a;
  --border: rgba(255, 255, 255, 0.08);
  --text: #f1efe8;
  --muted: #a3a19a;
  --accent: #7f77dd;
  --accent-soft: rgba(127, 119, 221, 0.22);
  --radius: 12px;
  --panel-width: 340px;
  --tabbar-height: 56px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}
button, input { font: inherit; color: inherit; }

/* Bühne */
.stage { position: fixed; inset: 0; }
/* Screenshot-Schutz: deckt die ganze Seite ab (über allem), solange ein Screenshot droht */
.screen-guard { position: fixed; inset: 0; z-index: 10000; display: grid; place-content: center; gap: 8px; text-align: center; background: var(--bg); color: var(--muted); font-size: 14px; }
.screen-guard strong { font-size: 22px; color: var(--text); }
.screen-guard[hidden] { display: none; }
.stage canvas { display: block; width: 100%; height: 100%; touch-action: none; object-fit: contain; }
.stage[data-bg="transparent"] { background: repeating-conic-gradient(#2a2a2e 0% 25%, #202024 0% 50%) 0 0 / 24px 24px; }
/* Aufnehmen: Rahmen um den Ausschnitt, der aufs Foto/Video kommt (außerhalb abgedunkelt) */
.capture-frame {
  position: absolute; z-index: 1; pointer-events: none;
  outline: 2px dashed rgba(255, 255, 255, 0.55); box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
}
.capture-frame::after {
  content: attr(data-label); position: absolute; right: 6px; bottom: 4px; font-size: 11px; color: rgba(255, 255, 255, 0.7);
}
.stage.no-webgl { display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); }
/* Kopfzeile: Marke, Login und (Desktop) das Menü – leere Fläche lässt Klicks zur Bühne durch */
.topbar {
  position: fixed; top: 10px; left: 16px; right: 16px; z-index: 7;
  display: flex; align-items: center; gap: 12px; pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { font-size: 13px; letter-spacing: 0.04em; color: var(--muted); pointer-events: none; }

/* Twitch-Login (optional) */
.account { position: relative; }
.account-login, .account-chip {
  display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px 0 8px;
  border: 1px solid var(--border); border-radius: 999px; background: rgba(38, 38, 43, 0.85);
  color: var(--text); font-size: 12px; text-decoration: none; cursor: pointer;
}
.account-login:hover, .account-chip:hover { border-color: #9146ff; }
.account-login svg { width: 14px; height: 14px; fill: #9146ff; }
.account-chip { padding-left: 3px; }
.account-chip img { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.account-chip span { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-menu {
  position: absolute; top: calc(100% + 6px); left: 0; min-width: 160px; padding: 6px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}
.account-menu .muted { padding: 4px 8px 6px; font-size: 12px; }
.account-menu button { width: 100%; text-align: left; padding: 7px 8px; border: 0; border-radius: 6px; background: none; cursor: pointer; }
.account-menu button:hover { background: var(--surface-2); }

.round {
  width: 36px; height: 36px; flex: none; border: 0; border-radius: 50%;
  background: var(--surface-2); cursor: pointer; font-size: 20px; line-height: 1;
  display: grid; place-items: center;
}
.round:hover { background: #3d3d45; }

/* Szenen-Leiste (ab zwei Modellen): ein Chip pro Modell unten über der Bühne */
.scene-bar {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 3;
  bottom: calc(16px + env(safe-area-inset-bottom));
  display: flex; gap: 6px; padding: 2px; max-width: calc(100vw - 32px); overflow-x: auto;
}
.scene-bar[hidden] { display: none; }
.scene-chip {
  display: inline-flex; align-items: center; flex: none;
  background: rgba(38, 38, 43, 0.85); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 999px;
}
.scene-chip:has(.scene-name[aria-pressed="true"]) { background: var(--accent-soft); border-color: var(--accent); }
.scene-name { border: 0; background: none; color: inherit; padding: 5px 4px 5px 12px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.scene-remove { border: 0; background: none; color: var(--muted); padding: 5px 10px 5px 6px; cursor: pointer; font-size: 14px; }
.scene-remove:hover { color: var(--text); }

/* Menü: Desktop als Kopfzeile neben dem Login */
.menu {
  display: flex; gap: 2px; padding: 3px; min-width: 0; overflow-x: auto; scrollbar-width: none;
  background: rgba(38, 38, 43, 0.85); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: 999px;
}
.tab { flex: none; border: 0; background: none; padding: 5px 13px; border-radius: 999px; cursor: pointer; color: var(--muted); font-size: 13px; white-space: nowrap; }
.tab:hover { color: var(--text); }
.tab[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }

/* Fenster rechts: Inhalt des gewählten Menüpunkts */
.panel {
  position: fixed; top: 56px; right: 12px; bottom: 12px; width: var(--panel-width);
  display: flex; flex-direction: column; overflow: hidden;
  background: rgba(38, 38, 43, 0.92); backdrop-filter: blur(8px);
  border: 1px solid var(--border); border-radius: var(--radius);
}
.only-mobile { display: none; }
.pane { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; padding: 10px; overflow-y: auto; }
.pane > :first-child, .pane > .needs-vrm > :first-child { margin-top: 0; }
.pane h3 { font-size: 12px; font-weight: 500; color: var(--muted); margin: 16px 0 8px; }
.hint { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; color: var(--muted); font-size: 13px; }
.muted { color: var(--muted); font-size: 13px; }
.needs-vrm.disabled { opacity: 0.35; }
code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; font-size: 12px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface-2);
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 14px;
}
.chip:hover { border-color: rgba(255, 255, 255, 0.2); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.color-chip input { width: 22px; height: 22px; border: 0; padding: 0; background: none; cursor: pointer; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; margin: 12px 0 8px; }
.sliders { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.slider-row { display: grid; grid-template-columns: minmax(0, 1fr) 130px 34px; align-items: center; gap: 8px; padding: 3px 0; font-size: 13px; }
.slider-row .slider-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.slider-row.active .slider-name { color: var(--text); }
.slider-row input { width: 100%; accent-color: var(--accent); }
.hand-sliders { margin: 2px 0 10px; }
.hand-sliders[hidden] { display: none; }
.hand-row, .hand-scale { grid-template-columns: minmax(0, 1fr) 160px; }
.hand-row .slider-name { color: var(--text); }
.hand-scale { display: grid; gap: 8px; font-size: 11px; color: var(--muted); margin-top: 4px; }
.hand-scale .ends { display: flex; justify-content: space-between; }
.slider-row output { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; font-size: 12px; }
.toggle { display: flex; align-items: center; gap: 8px; padding: 4px 0; cursor: pointer; }
.light-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) 44px; align-items: center; gap: 8px; }
.light-row input[type="range"] { width: 100%; accent-color: var(--accent); }
.light-row output { font-variant-numeric: tabular-nums; color: var(--muted); text-align: right; font-size: 12px; }
.color-input { width: 36px; height: 30px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.inline-field { display: flex; align-items: center; gap: 8px; }
.toggle input { accent-color: var(--accent); width: 16px; height: 16px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.prop-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.prop-row { display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 0; border-radius: 8px; }
.prop-row[aria-current="true"] { background: var(--accent-soft); }
.prop-row.hidden-prop .prop-name { color: var(--muted); }
.prop-name { flex: 1; min-width: 0; text-align: left; border: 0; background: none; padding: 6px 8px; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.round.small { width: 30px; height: 30px; font-size: 14px; }
.xyz { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.xyz label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted); }
.xyz input, .number, .select {
  width: 100%; min-width: 0; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
.number { width: 120px; }
.pane hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0 4px; }
.audio-info { margin: 10px 0 0; font-size: 13px; color: var(--text); overflow-wrap: anywhere; }
.link { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 13px; }
.button {
  display: inline-block; border: 1px solid var(--border); background: var(--surface-2);
  border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
.button.primary { width: 100%; margin-top: 20px; background: var(--accent); border-color: var(--accent); }
.capture-buttons { display: grid; gap: 6px; }
.capture-buttons .button { width: 100%; margin-top: 0; }
.button.record.recording { background: #a33b3b; border-color: #d65c5c; }
.rec-indicator {
  position: fixed; top: 96px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 8px; width: max-content; padding: 6px 14px; font-size: 13px;
  background: rgba(38, 38, 43, 0.9); border: 1px solid rgba(214, 92, 92, 0.6); border-radius: 999px;
}
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e05555; animation: blink 1s steps(2, start) infinite; }
@keyframes blink { to { visibility: hidden; } }

/* Modellliste (Menüpunkt Models) */
.list-notice { margin: 4px 0 0; font-size: 11.5px; line-height: 1.4; color: var(--muted); }
#model-list h3, .own-avatar h3 { font-size: 13px; font-weight: 500; color: var(--muted); margin: 18px 0 8px; }
/* Eigener Avatar (angemeldet): Kacheln + Upload-Fenster oben in der Modellliste; Stoff-Auswahl unter „Erweitert“ */
.own-upload .initials { font-size: 34px; }
.own-panel, .inline-popup {
  display: flex; flex-direction: column; gap: 10px; margin-top: 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2);
}
.inline-popup p { margin: 0; }
.own-text { margin: 0; font-size: 13px; line-height: 1.45; white-space: pre-line; color: var(--muted); }
.own-text.warning { color: #ffd59a; }
.own-status { margin: 0; font-size: 13px; }
.own-delete { display: flex; flex-wrap: wrap; gap: 12px; }
.own-pick, .own-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; }
.own-actions .button.primary { width: auto; margin-top: 0; }
.own-file { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.model-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.model-card {
  display: flex; flex-direction: column; gap: 6px; overflow: hidden; padding: 0 0 8px; text-align: center;
  border: 1px solid var(--border); background: var(--surface-2); border-radius: 10px; cursor: pointer;
}
.model-card img, .model-card .initials {
  width: 100%; aspect-ratio: 1; object-fit: cover; display: grid; place-items: center;
  background: #202024; font-size: 22px; color: var(--muted);
}
.model-card .label { font-size: 13px; padding: 0 6px; }
.model-card[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.model-tile { position: relative; display: flex; }
.model-tile .model-card { flex: 1; }
.model-add { position: absolute; top: 6px; right: 6px; background: rgba(23, 23, 26, 0.8); }
.model-add:disabled { opacity: 0.35; cursor: default; }

/* Fortschritt, Meldungen, Drag & Drop */
.progress {
  position: fixed; top: 56px; left: 50%; transform: translateX(-50%); z-index: 5;
  width: max-content; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 10px; padding: 6px 14px; font-size: 13px;
  background: rgba(38, 38, 43, 0.9); border: 1px solid var(--border); border-radius: 999px;
}
.progress-track { width: 140px; height: 4px; overflow: hidden; background: var(--surface-2); border-radius: 2px; }
.progress-bar { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.progress.indeterminate .progress-bar { width: 30% !important; animation: slide 1.2s infinite ease-in-out; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(350%); } }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 20;
  bottom: calc(16px + env(safe-area-inset-bottom)); width: max-content; max-width: calc(100vw - 32px);
  padding: 8px 14px; font-size: 14px;
  background: #3a2a2e; border: 1px solid rgba(255, 120, 120, 0.3); border-radius: 10px;
}
.toast.info { background: var(--surface-2); border-color: var(--accent); }
body[data-scene="multi"] .toast { bottom: calc(64px + env(safe-area-inset-bottom)); }
.drop-hint {
  position: fixed; inset: 12px; z-index: 30; pointer-events: none;
  display: grid; place-items: center; font-size: 18px;
  background: rgba(23, 23, 26, 0.7); border: 2px dashed var(--accent); border-radius: var(--radius);
}

/* Desktop: Bühne neben dem Panel, damit das Modell in der freien Fläche mittig steht */
@media (min-width: 768px) {
  .stage { right: calc(var(--panel-width) + 24px); }
  .scene-bar, .toast, .progress, .rec-indicator { left: calc((100vw - var(--panel-width) - 24px) / 2); }
}

/* Handy: Menü als Leiste unten (seitlich wischbar), Inhalt klappt als Blatt darüber hoch */
@media (max-width: 767px) {
  .only-mobile { display: block; }
  .stage { bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); }
  .menu {
    position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-height) + env(safe-area-inset-bottom));
    align-items: center; padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); border-radius: 0;
    border: 0; border-top: 1px solid var(--border); background: rgba(38, 38, 43, 0.96);
  }
  .menu { gap: 0; }
  .tab { flex: 1 0 auto; padding: 8px 5px; font-size: 12.5px; }
  .panel {
    top: auto; left: 0; right: 0; bottom: calc(var(--tabbar-height) + env(safe-area-inset-bottom)); width: auto; max-height: 55dvh;
    border-radius: var(--radius) var(--radius) 0 0;
  }
  body:not([data-sheet="open"]) .panel { display: none; }
  .toast { bottom: calc(var(--tabbar-height) + 12px + env(safe-area-inset-bottom)); }
  .scene-bar { bottom: calc(var(--tabbar-height) + 12px + env(safe-area-inset-bottom)); }
  body[data-sheet="open"] .scene-bar { display: none; }
  body[data-scene="multi"] .toast { bottom: calc(var(--tabbar-height) + 60px + env(safe-area-inset-bottom)); }
}

.button:disabled { opacity: 0.45; cursor: default; }
#pose-freeze { margin: 4px 0 12px; }

/* Kleidung: Gruppen im Fenster rechts, Teile der Gruppe im Fenster unten (Desktop) bzw. im Blatt darunter (Handy) */
.wardrobe-groups { display: flex; flex-direction: column; gap: 4px; }
.wardrobe-group {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; text-align: left;
  border: 1px solid transparent; background: none; border-radius: 8px; padding: 7px 10px; cursor: pointer;
}
.wardrobe-group:hover { background: var(--surface-2); }
.wardrobe-group[aria-current="true"] { background: var(--accent-soft); border-color: var(--accent); }
.wardrobe-group-worn { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.wardrobe-dock { display: none; }
.wardrobe-dock h3 { margin: 0 0 8px; font-size: 12px; font-weight: 500; color: var(--muted); }
.wardrobe-dock.busy .chip { opacity: 0.6; pointer-events: none; }
.pane .wardrobe-dock { display: block; margin-top: 16px; } /* Handy: im Blatt */
@media (min-width: 768px) {
  body[data-wardrobe="on"] .wardrobe-dock {
    display: block; position: fixed; left: 12px; right: calc(var(--panel-width) + 24px); bottom: 12px; z-index: 4;
    max-height: 40vh; overflow-y: auto;
    padding: 10px 12px; background: rgba(30, 30, 34, 0.94); border: 1px solid var(--border); border-radius: var(--radius);
  }
  body[data-wardrobe="on"] { --bars-lift: calc(var(--wardrobe-height, 0px) + 8px); }
  body[data-wardrobe="on"] .toast { bottom: calc(var(--bars-lift) + 16px); }
  body[data-wardrobe="on"] .scene-bar { bottom: calc(var(--bars-lift) + 16px); }
  body[data-wardrobe="on"][data-scene="multi"] .toast { bottom: calc(var(--bars-lift) + 64px); }
}

/* Animationsstrahl: nur Desktop, nur in den Reitern Posen und Raum (body[data-timeline="on"]). Er liegt ÜBER der Bühne – die Bühne
   behält ihre Größe (Hintergrundbild/-video sitzen in allen Reitern gleich); Szenen-Leiste und Meldungen rücken darüber. */
.timeline { display: none; }
@media (min-width: 768px) {
  /* --bars-lift: so weit rücken Szenen-Leiste und Meldung über ihren normalen Platz (Dock + Abstand) */
  body[data-timeline="on"] { --timeline-height: 118px; --bars-lift: calc(var(--timeline-height) + 8px); }
  body[data-timeline="on"] .timeline {
    display: flex; flex-direction: column; gap: 6px;
    position: fixed; left: 12px; right: calc(var(--panel-width) + 24px); bottom: 12px; z-index: 4;
    padding: 8px 10px; background: rgba(30, 30, 34, 0.94); border: 1px solid var(--border); border-radius: var(--radius);
  }
  /* Eingeklappt nur so breit wie sein Inhalt (unten links) */
  body[data-timeline="on"] .timeline.collapsed { width: fit-content; }
  body[data-timeline="on"] .toast { bottom: calc(var(--bars-lift) + 16px); }
  body[data-timeline="on"] .scene-bar { bottom: calc(var(--bars-lift) + 16px); }
  body[data-timeline="on"][data-scene="multi"] .toast { bottom: calc(var(--bars-lift) + 64px); }
}
/* Breiter Desktop: neben dem eingeklappten Strahl (gut 340 px) ist Platz – die Leisten bleiben an ihrem normalen Platz,
   die Szenen-Leiste wird nur nie so breit, dass sie ihn erreicht (sie lässt sich seitlich wischen) */
@media (min-width: 1400px) {
  body[data-timeline="on"]:has(.timeline.collapsed) { --bars-lift: 0px; }
  body[data-timeline="on"]:has(.timeline.collapsed) .scene-bar { max-width: calc(100vw - var(--panel-width) - 24px - 2 * 370px); }
}
.timeline-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; font-size: 12px; color: var(--muted); }
.timeline-head .tl-spacer { flex: 1; }
.timeline.collapsed .timeline-tracks, .timeline.collapsed .tl-more, .timeline.collapsed .tl-spacer { display: none; }
body[data-strahl="room"] .tl-model-only, body[data-strahl="camera"] .tl-model-only { display: none; } /* Laden/Exportieren gelten für Modell-Spuren */
.tl-hint { font-size: 11px; color: var(--muted); }
/* Aufnehmen > Discord: Einladelink (aus /admin) */
.discord-invite { justify-self: start; color: #aab1ff; font-size: 13px; text-decoration: none; }
.discord-invite:hover { text-decoration: underline; }
/* Posen: Auswahlbox (Shift+Ziehen) für mehrere Gelenkpunkte */
.select-box { position: fixed; z-index: 30; pointer-events: none; border: 1px dashed #ff5c8a; background: rgba(255, 92, 138, 0.12); border-radius: 2px; }
/* Auto-Keyframes: an = rot wie der Aufnahme-Knopf in Blender (man soll sehen, dass jede Änderung Keys schreibt) */
.tl-autokey { display: flex; align-items: center; gap: 5px; padding: 2px 8px 2px 6px; border-radius: 999px; border: 1px solid var(--border); cursor: pointer; user-select: none; }
.tl-autokey input { margin: 0; accent-color: #e5534b; }
.tl-autokey:has(input:checked) { color: #ff8a80; border-color: rgba(229, 83, 75, 0.7); background: rgba(229, 83, 75, 0.14); }
.timeline.collapsed .tl-autokey-text { display: none; } /* eingeklappt nur das Kästchen – rot, solange es an ist */
.timeline.collapsed .tl-autokey { padding: 2px 6px; }
/* Exportieren: Untermenü über dem Knopf (der Strahl liegt unten) */
.tl-export { position: relative; }
.tl-export-menu {
  position: absolute; right: 0; bottom: calc(100% + 6px); z-index: 5; display: flex; flex-direction: column; gap: 2px;
  min-width: 260px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.45);
}
.tl-export-menu[hidden] { display: none; }
.tl-export-menu button {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 10px; border: 0; border-radius: 7px;
  background: none; color: var(--text); font: inherit; font-size: 13px; font-weight: 600; text-align: left; cursor: pointer;
}
.tl-export-menu button small { font-size: 11px; font-weight: 400; color: var(--muted); }
.tl-export-menu button:hover, .tl-export-menu button:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.tl-field { display: flex; align-items: center; gap: 4px; }
.tl-field input { width: 58px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); }
.small-button { padding: 4px 10px; font-size: 12px; }
.small-chip { padding: 3px 10px; font-size: 12px; }
/* Spuren wie im Videoschnitt: EIN Scrollbereich (waagerecht = Zoom, senkrecht = viele Spuren); links stehen die Spurköpfe,
   oben das Lineal. Jede Zeile ist Kopfspalte + (Breite − Kopfspalte) × Zoom breit; der Abspielkopf läuft durch alle Zeilen */
.timeline-tracks {
  --tl-head: 172px;
  position: relative; display: flex; flex-direction: column; max-height: min(32vh, 232px); overflow: auto; overscroll-behavior: contain;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface-2);
}
/* waagerecht ohne sichtbare Scrollleiste (Mausrad, Touchpad), senkrecht eine schmale – Firefox kennt nur „dünn“ für beide */
.timeline-tracks::-webkit-scrollbar { width: 8px; height: 0; }
.timeline-tracks::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.22); border-radius: 4px; }
@supports not selector(::-webkit-scrollbar) { .timeline-tracks { scrollbar-width: thin; scrollbar-color: rgba(255, 255, 255, 0.25) transparent; } }
.tl-row { display: flex; flex: none; min-width: 100%; width: calc(var(--tl-head) + (100% - var(--tl-head)) * var(--tl-zoom, 1)); }
.tl-head {
  position: sticky; left: 0; z-index: 2; flex: 0 0 var(--tl-head); display: flex; align-items: center; gap: 4px; min-width: 0;
  padding: 0 4px 0 8px; background: var(--surface); border-right: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 -1px 0 var(--border);
}
.tl-lane { position: relative; flex: 1 1 auto; min-width: 0; overflow: hidden; cursor: pointer; touch-action: none; box-shadow: inset 0 -1px 0 var(--border); }
.tl-ruler-row { position: sticky; top: 0; z-index: 3; height: 18px; }
.tl-corner { z-index: 4; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.tl-ruler { background: #2b2b31; }
.tl-track { height: 30px; }
.tl-track.active .tl-head { box-shadow: inset 3px 0 0 var(--accent), inset 0 -1px 0 var(--border); }
.tl-track.active .tl-lane { background: rgba(127, 119, 221, 0.08); }
.tl-label {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 4px 2px; border: 0; background: none;
  color: var(--text); font: inherit; font-size: 12px; text-align: left; cursor: pointer;
}
.tl-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tl-label .icon { width: 14px; height: 14px; color: var(--muted); }
.tl-track.active .tl-label, .tl-track.active .tl-label .icon { color: var(--accent); }
.tl-track.active .tl-label { font-weight: 600; }
.tl-save-key {
  flex: none; display: grid; place-items: center; width: 26px; height: 22px; padding: 0; border-radius: 6px;
  border: 1px solid var(--border); background: transparent; color: #f2c14e; cursor: pointer;
}
.tl-save-key:hover { border-color: rgba(242, 193, 78, 0.6); background: rgba(242, 193, 78, 0.12); }
.tl-save-key .icon { width: 15px; height: 15px; }
.tl-tick { position: absolute; top: 0; bottom: 0; width: 1px; background: rgba(255, 255, 255, 0.05); }
.tl-ruler .tl-tick { top: auto; height: 6px; background: rgba(255, 255, 255, 0.3); }
.tl-tick span { position: absolute; bottom: 4px; left: 3px; font-size: 9px; line-height: 1; color: var(--muted); }
.tl-key {
  position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; transform: rotate(45deg);
  background: #f2c14e; border: 1px solid rgba(0, 0, 0, 0.5); cursor: grab;
}
.tl-track[data-kind="room"] .tl-key { background: #6cc4a1; }
.tl-track[data-kind="camera"] .tl-key { background: #e58f6f; }
.tl-key.selected, .tl-track .tl-key.selected { background: #fff; box-shadow: 0 0 0 2px var(--accent); }
.tl-key.dragging { cursor: grabbing; opacity: 0.8; }
/* gesperrt: dunkler Kern + Ring, lässt sich nicht ziehen */
.tl-key.locked { cursor: pointer; outline: 2px solid rgba(0, 0, 0, 0.8); outline-offset: -5px; box-shadow: 0 0 0 1.5px #fff; }
.tl-key.locked.selected { box-shadow: 0 0 0 2px var(--accent), 0 0 0 3.5px #fff; }
.tl-playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); pointer-events: none; }
.tl-ruler .tl-playhead::before {
  content: ""; position: absolute; top: 0; left: -4px; border: 5px solid transparent; border-top: 6px solid var(--accent); border-bottom: 0;
}

/* Posen: Virt-A-Mate-Galerie (Vorschaubilder der Posen eines .var-Pakets) */
.vam-gallery { margin-top: 10px; }
.vam-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vam-head strong { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 6px; max-height: 46vh; overflow-y: auto; padding: 2px; }
.vam-pose {
  display: flex; flex-direction: column; align-items: stretch; padding: 0; overflow: hidden; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
}
.vam-pose:hover { border-color: rgba(255, 255, 255, 0.25); }
.vam-pose[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.vam-pose img, .vam-pose .vam-noimage { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #1d1d21; }
.vam-pose .vam-noimage { display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.vam-pose span { font-size: 11px; color: var(--muted); padding: 2px 4px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Posen: Navigations-Gizmo (Achsen wie Blender) oben rechts auf der Bühne */
.view-gizmo { position: absolute; top: 64px; right: 10px; z-index: 2; display: flex; flex-direction: column; align-items: center; gap: 4px; user-select: none; }
.view-gizmo canvas { display: block; touch-action: none; }
.view-gizmo-ortho {
  border: 1px solid var(--border); background: rgba(38, 38, 43, 0.85); color: var(--muted); border-radius: 999px;
  font-size: 11px; padding: 2px 10px; cursor: pointer;
}
.view-gizmo-ortho:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.25); }
.view-gizmo-ortho[aria-pressed="true"] { color: var(--text); background: var(--accent-soft); border-color: var(--accent); }
/* Kameramodus: Aufnahmekamera / Freie Kamera, oben links auf der Bühne */
.camera-mode { position: absolute; top: 64px; left: 10px; z-index: 2; display: flex; flex-wrap: wrap; gap: 4px; max-width: calc(100vw - 150px); }
.camera-mode .chip { background: rgba(38, 38, 43, 0.85); }
.camera-presets { display: contents; }
.camera-presets .chip { padding: 3px 10px; font-size: 12px; } /* wie .small-chip */
.camera-sep { width: 1px; align-self: stretch; margin: 2px 4px; background: var(--border); }
.camera-mode .chip[aria-pressed="true"] { background: var(--accent-soft); }
.camera-mode .chip[data-mode="free"][aria-pressed="true"] { border-color: #ffc94a; color: #ffc94a; }
body[data-camera="free"] [data-capture="record"], body[data-camera="free"] .video-only { display: none; } /* Video kommt aus der Aufnahmekamera */
@media (max-width: 767px) {
  .camera-mode { top: 60px; left: 6px; }
  .desktop-only { display: none; } /* Handy: Foto/Video immer im Vollbild – kein Aufnahmeformat */
}
@media (max-width: 767px) { .view-gizmo { top: 60px; right: 6px; transform: scale(0.85); transform-origin: top right; } }

/* Bibliothek: Fenster wie ein Datei-Explorer (Pfad, Kacheln mit Vorschau, Laden/Abbrechen) */
.library { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; background: rgba(0, 0, 0, 0.5); }
.library-window {
  display: flex; flex-direction: column; width: min(880px, calc(100vw - 32px)); height: min(640px, calc(100vh - 48px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); overflow: hidden;
}
.library-titlebar { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 8px 16px; font-size: 14px; border-bottom: 1px solid var(--border); }
.library-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.library-path {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px; flex: 1 1 220px; min-width: 0; padding: 2px 6px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
}
.lib-crumb { border: 0; background: none; padding: 3px 6px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.lib-crumb:hover, .lib-crumb.drop { background: var(--accent-soft); }
.lib-sep { color: var(--muted); font-size: 13px; }
.library-admin { display: flex; flex-wrap: wrap; gap: 6px; }
.library-grid {
  flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); align-content: start;
  gap: 6px; padding: 12px; outline: none;
}
.lib-tile { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px 6px; border: 1px solid transparent; border-radius: 10px; user-select: none; }
.lib-tile:hover { background: rgba(255, 255, 255, 0.05); }
.lib-tile[aria-selected="true"] { background: var(--accent-soft); border-color: var(--accent); }
.lib-tile.drop { border-color: var(--accent); background: rgba(255, 255, 255, 0.1); }
.lib-icon { display: grid; place-items: center; width: 88px; height: 88px; }
.lib-icon img, .lib-icon svg { max-width: 100%; max-height: 100%; }
.lib-icon svg { width: 72px; }
.lib-name {
  max-width: 100%; font-size: 12.5px; line-height: 1.3; text-align: center; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.lib-rename { width: 100%; padding: 2px 4px; font-size: 12.5px; text-align: center; background: var(--bg); border: 1px solid var(--accent); border-radius: 4px; }
.lib-empty { grid-column: 1 / -1; padding: 48px 16px; color: var(--muted); text-align: center; }
.library-footer { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border); }
.library-footer #library-status { flex: 1; min-width: 0; font-size: 13px; }
.library-footer .button.primary { width: auto; margin-top: 0; }
@media (max-width: 767px) {
  .library-window { width: 100vw; height: 100dvh; border: 0; border-radius: 0; }
  .lib-icon { width: 72px; height: 72px; }
}

/* Fenster rechts: Boxen – Kopfzeile (Titel links, Icon-Knöpfe rechts) und Inhalt; Hilfe hinter ⓘ. Listen scrollen in
   ihrer Box, die Optionen des gewählten Eintrags darunter bleiben ohne Scrollen sichtbar. */
.pane-stack { display: flex; flex-direction: column; gap: 8px; }
.box { flex: none; padding: 8px 10px 10px; background: rgba(255, 255, 255, 0.03); border: 1px solid var(--border); border-radius: 10px; }
.box-head { display: flex; align-items: center; gap: 6px; min-height: 30px; }
.pane .box-head h3 { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.box-head .spacer { flex: 1; }
.box-head .button { width: auto; margin: 0; flex: none; }
.box > * + * { margin-top: 8px; }
.box > .toggle + .toggle, .box > .toggle + #life-toggles { margin-top: 0; }
.box > .field-row { margin-top: 6px; }
.box .xyz input, .box .number, .box .select { padding: 4px 6px; font-size: 13px; }
.list-scroll .prop-row { padding: 1px 2px 1px 0; }
.list-scroll .prop-name { padding: 4px 8px; font-size: 14px; }
.list-scroll .round.small { width: 26px; height: 26px; }
.list-scroll { display: flex; flex-direction: column; gap: 2px; }
.box-help > p { margin: 0 0 6px; }
.box-help > p:last-child { margin-bottom: 0; }
.box h4.sub { margin: 12px 0 6px; font-size: 12px; font-weight: 500; color: var(--muted); }
.head-tools { display: flex; align-items: center; gap: 4px; }
/* Raum-Auswahl: Liste der eigenen Räume, daneben Neu/Kopie/Umbenennen/Löschen; Umbenennen ersetzt die Liste durch ein Feld */
.room-picker { display: flex; align-items: center; gap: 6px; }
.room-picker .select, .room-rename { flex: 1 1 auto; min-width: 0; }
.room-rename { padding: 4px 6px; font-size: 13px; border-radius: 8px; border: 1px solid var(--accent); background: var(--surface-2); color: var(--text); }
.status { flex: none; font-size: 12px; white-space: nowrap; }
.count { color: var(--muted); font-weight: 400; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn {
  display: inline-grid; place-items: center; flex: none; width: 30px; height: 30px; padding: 0;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: rgba(255, 255, 255, 0.22); }
.icon-btn:disabled { opacity: 0.45; cursor: default; }
.icon-btn[aria-pressed="true"], .icon-btn[aria-expanded="true"] { background: var(--accent-soft); border-color: var(--accent); }
.button .icon { width: 16px; height: 16px; margin-right: 4px; vertical-align: -3px; }
.round .icon { width: 15px; height: 15px; }
/* Segment-Schalter (Links | Rechts, Objekte | Lichter, Anfasser-Arten) */
.seg { display: inline-flex; flex: none; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; }
.seg > button { display: inline-flex; align-items: center; gap: 4px; padding: 5px 9px; border: 0; border-radius: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer; }
.seg > button + button { border-left: 1px solid var(--border); }
.seg > button:hover { color: var(--text); }
.seg > button[aria-pressed="true"], .seg > button[aria-selected="true"] { background: var(--accent-soft); color: var(--text); }
.seg > button[hidden] + button { border-left: 0; }
.seg .icon { width: 16px; height: 16px; }
.seg .count { color: inherit; opacity: 0.75; }
/* Zeilen: Bezeichnung links, Felder rechts */
.field-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 6px; margin-top: 6px; }
.field-label { font-size: 12px; color: var(--muted); }
.field-row .inline-field .number { width: 84px; }
/* Listen-Boxen */
.list-scroll { max-height: 38vh; overflow-y: auto; }
.list-scroll:empty { display: none; }
.pane.split { overflow: hidden; }
.pane.split > .box-options { flex: 0 1 auto; min-height: 0; overflow-y: auto; }
/* Handy: zu wenig Höhe für zwei Bereiche – der ganze Reiter scrollt, die Box unten bekommt ihre volle Höhe */
@media (max-width: 767px) { .pane.split { overflow-y: auto; } .pane.split > .box { flex: none; } .pane.split > .box-options { overflow: visible; } }
#anim-list { max-height: 50vh; overflow-y: auto; }
#room-light-add .chip { display: inline-flex; align-items: center; gap: 2px; padding: 3px 8px; font-size: 12px; }
#room-light-add .chip .icon { width: 15px; height: 15px; }
#pose-pick-hint { margin-bottom: 0; }
@media (max-width: 767px) {
  .list-scroll { max-height: 22dvh; }
  #anim-list { max-height: 26dvh; }
}

/* Reiter Sprites */
.sprite-create { display: flex; gap: 6px; align-items: center; }
.sprite-create .sprite-name { flex: 1 1 auto; min-width: 0; border-color: var(--border); }
.sprite-create .sprite-name:focus { border-color: var(--accent); outline: none; }
.sprite-create .button { width: auto; margin: 0; flex: none; }
.sprite-row { gap: 8px; }
.sprite-preview { flex: none; width: 56px; height: 56px; border-radius: 6px; border: 1px solid var(--border);
  background: repeating-conic-gradient(rgba(255, 255, 255, 0.08) 0 25%, transparent 0 50%) 0 0 / 12px 12px; }
.sprite-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.list-scroll .sprite-label { padding: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sprite-info { font-size: 11px; }
#sprite-fps, #sprite-sharp { justify-self: start; }
button.sprite-row { width: 100%; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
button.sprite-row:hover { background: rgba(255, 255, 255, 0.05); }
.sprite-viewer { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(0, 0, 0, 0.72); }
.sprite-viewer[hidden] { display: none; }
.sprite-viewer-box { display: flex; flex-direction: column; gap: 8px; padding: 10px 12px 12px; max-width: calc(100vw - 16px); max-height: calc(100dvh - 16px);
  overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.sprite-viewer-box .box-head h3 { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 14px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sprite-viewer-body { display: flex; gap: 14px; align-items: flex-start; }
.sprite-viewer-side { width: 300px; display: flex; flex-direction: column; gap: 4px; }
.sprite-viewer-side h4.sub { margin: 6px 0 6px; }
.sprite-viewer-side .chips { display: flex; gap: 4px; margin-bottom: 4px; }
.sprite-layer-list { max-height: 30vh; }
.sprite-layer-list .toggle { padding: 2px 0; font-size: 13px; }
.sprite-compass { display: grid; grid-template-columns: repeat(3, 40px); gap: 4px; }
.sprite-compass.row { grid-template-columns: repeat(2, 40px); }
.sprite-dir { width: 40px; height: 34px; padding: 0; font-size: 18px; justify-content: center; }
.sprite-viewer-buttons { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sprite-viewer-buttons .button { width: auto; margin: 0; }
.sprite-viewer-info { margin: 8px 0 0; font-size: 12px; }
.sprite-viewer-canvas { display: block; flex: none; border-radius: 8px; cursor: pointer; }
.sprite-viewer-canvas[data-bg="checker"] { background: #2a2a30 repeating-conic-gradient(#3a3a42 0 25%, transparent 0 50%) 0 0 / 24px 24px; }
.sprite-viewer-canvas[data-bg="dark"] { background: #17171a; }
.sprite-viewer-canvas[data-bg="light"] { background: #ecebe7; }
.sprite-viewer-canvas[data-bg="green"] { background: #00ff00; }
.sprite-viewer-hint { font-size: 12px; margin: 6px 0 0; }
@media (max-width: 759px) {
  .sprite-viewer-body { flex-direction: column; align-items: center; }
  .sprite-viewer-side { width: 100%; }
}
#sprite-fps, #sprite-sharp { justify-self: start; }
#sprite-mode { width: 100%; }
.sprite-wh { display: flex; align-items: center; gap: 4px; } .sprite-wh .number { width: 64px; }

/* Audio-Spuren im Strahl: Clip mit Wellenform, ziehbar */
.tl-audio .tl-lane { overflow: hidden; }
.tl-audio .tl-label { display: flex; align-items: center; gap: 4px; flex: 1 1 auto; min-width: 0; cursor: default; }
.tl-audio-volume { width: 42px; flex: none; accent-color: var(--accent); }
.tl-clip { position: absolute; top: 3px; bottom: 3px; min-width: 4px; border-radius: 4px; background: rgba(124, 108, 255, 0.55);
  border: 1px solid rgba(160, 150, 255, 0.9); cursor: grab; overflow: hidden; }
.tl-clip canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.tl-clip.dragging { cursor: grabbing; opacity: 0.8; }
.tl-clip.muted { background: rgba(120, 120, 130, 0.35); border-color: rgba(160, 160, 170, 0.6); }

/* Kleidungs-Unterspuren im Strahl (Avatar-Spur aufklappbar) */
.tl-expand { flex: none; width: 16px; padding: 0; border: 0; background: none; color: var(--muted); font-size: 11px; cursor: pointer; }
.tl-expand:hover { color: var(--text); }
.tl-sub .tl-head { padding-left: 24px; }
.tl-sub .tl-label { font-size: 11px; }
.tl-track[data-kind="garment"] .tl-key { background: #e58fcf; }

/* Strahl: Oberkante ziehen = Höhe des Spurbereichs */
.tl-resize { position: absolute; left: 12px; right: 12px; top: -5px; height: 10px; cursor: ns-resize; z-index: 5; touch-action: none; }
.tl-resize::after { content: ""; position: absolute; left: 50%; top: 3px; width: 48px; height: 4px; margin-left: -24px; border-radius: 2px;
  background: rgba(255, 255, 255, 0.18); opacity: 0; transition: opacity 0.15s; }
.tl-resize:hover::after, body.tl-resizing .tl-resize::after { opacity: 1; }
.timeline.collapsed .tl-resize { display: none; }
body.tl-resizing { cursor: ns-resize; user-select: none; }

.garment-gizmo-modes { justify-self: start; }
/* Bibliothek: Kontextmenü (Rechtsklick / lange tippen auf eine Kachel) */
.lib-tile { -webkit-touch-callout: none; }
.lib-menu { position: fixed; z-index: 1000; min-width: 160px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); display: flex; flex-direction: column; }
.lib-menu[hidden] { display: none; }
.lib-menu-item { text-align: left; padding: 7px 10px; border: 0; border-radius: 5px; background: none; color: inherit; font: inherit; font-size: 13px; cursor: pointer; }
.lib-menu-item:hover, .lib-menu-item:focus-visible { background: rgba(255, 255, 255, 0.08); outline: none; }
.lib-menu-item.danger { color: #ff8a8a; }
/* Bibliothek: Ausrichten (Vorschau links, Felder rechts) – liegt über dem Inhalt des Fensters */
.lib-align { position: absolute; inset: 0; z-index: 5; display: grid; grid-template-columns: 1fr 300px; background: var(--surface); }
.lib-align[hidden] { display: none; }
.lib-align-view { position: relative; min-height: 0; background: #15161c; }
.lib-align-view canvas { display: block; width: 100%; height: 100%; }
.lib-align-side { display: flex; flex-direction: column; gap: 8px; padding: 14px; overflow-y: auto; border-left: 1px solid var(--border); }
.lib-align-side h3 { margin: 0; font-size: 15px; }
.lib-align-side .muted { font-size: 12px; margin: 0; }
.lib-align-quick { display: flex; flex-wrap: wrap; gap: 6px; }
.lib-align-actions { margin-top: auto; display: flex; gap: 8px; align-items: center; justify-content: flex-end; }
.lib-align-actions .status, #library-align-status { margin-right: auto; font-size: 12px; }
.lib-align-actions .button.primary { width: auto; margin-top: 0; }
.library-window { position: relative; }
@media (max-width: 700px) { .lib-align { grid-template-columns: 1fr; grid-template-rows: 45% 1fr; } .lib-align-side { border-left: 0; border-top: 1px solid var(--border); } }
#scene-box .scene-length-row { display: flex; gap: 8px; align-items: baseline; font-size: 13px; margin-top: 4px; }
#scene-box .scene-stretch { display: flex; gap: 6px; align-items: center; margin: 6px 0 8px; }
#scene-box .scene-stretch .number { width: 90px; flex: none; }
#scene-box .scene-stretch .button { width: auto; margin: 0; flex: none; }
#scene-box .daytime { margin: 4px 0 8px; }
#scene-box .daytime-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
#scene-box .daytime-row .field-label { width: 72px; flex: none; display: flex; gap: 4px; align-items: center; }
#scene-box .daytime-row input[type="range"] { flex: 1; min-width: 0; }
#scene-box .daytime-value { width: 44px; flex: none; text-align: right; font-variant-numeric: tabular-nums; }
/* Start: Neue Szene / Weitermachen / Szene laden */
.start-dialog { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); padding: 16px; }
.start-dialog[hidden] { display: none; }
.start-window { display: flex; flex-direction: column; gap: 10px; width: min(360px, 100%); padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.start-option { display: flex; flex-direction: column; gap: 3px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.start-option:hover, .start-option:focus-visible { border-color: var(--accent); outline: none; }
.start-option strong { font-size: 15px; }
.start-option .muted { font-size: 12px; }
#scene-box .scene-actions { display: flex; flex-wrap: wrap; gap: 6px; }
#scene-box .scene-actions .button { width: auto; margin: 0; }
.merge-slot { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.merge-buttons { display: flex; gap: 8px; justify-content: flex-end; }
.merge-buttons .button { width: auto; margin: 0; }
.start-load { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.start-load[hidden], .start-load-group[hidden] { display: none; }
.start-load-group { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.start-load-list { display: flex; flex-direction: column; gap: 4px; max-height: 30vh; overflow-y: auto; }
.start-load-list .start-option { padding: 9px 12px; }
.start-load-list .start-option strong { font-size: 14px; }
.start-window:has(.start-load:not([hidden])) > [data-start] { display: none; }
/* Raum-Editor: Grundriss (Ansicht von oben links, Felder rechts) */
.room-plan { position: fixed; inset: 0; z-index: 35; display: grid; place-items: center; background: rgba(0, 0, 0, 0.55); padding: 16px; }
.room-plan[hidden] { display: none; }
.room-plan-window { display: grid; grid-template-columns: 1fr 260px; width: min(1100px, 100%); height: min(720px, calc(100vh - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); }
.room-plan-canvas { width: 100%; height: 100%; display: block; cursor: crosshair; outline: none; touch-action: none; }
.room-plan-side { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-left: 1px solid var(--border); overflow-y: auto; }
.room-plan-side h3 { margin: 0 0 4px; font-size: 15px; }
.room-plan-side .number { width: 72px; }
.room-plan-tools { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.room-plan-actions { margin-top: auto; display: flex; gap: 8px; justify-content: flex-end; }
.room-plan-actions .button.primary { width: auto; margin-top: 0; }
@media (max-width: 700px) { .room-plan-window { grid-template-columns: 1fr; grid-template-rows: 1fr auto; } .room-plan-side { border-left: 0; border-top: 1px solid var(--border); max-height: 45vh; } }
.room-plan-surfaces { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--border); }
.room-plan-surface { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.room-plan-surface .field-label { width: 52px; }
.room-plan-surface .surface-color { width: 30px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; }
.room-plan-surface .surface-file-btn.has-file { border-color: var(--accent); }
.room-plan-surface .number { width: 60px; }
.room-plan-side #room-plan-group { flex: 1 1 auto; min-width: 0; border-color: var(--border); }
.room-plan-doors { display: flex; flex-direction: column; gap: 6px; margin: 4px 0; }
.room-plan-door { display: grid; grid-template-columns: auto 1fr; gap: 4px 6px; align-items: center; padding: 6px; border: 1px solid var(--border); border-radius: 8px; font-size: 12px; }
.room-plan-door .number { width: 60px; }
.room-plan-door select { font-size: 12px; }
.room-plan-door-head { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.room-door-list { display: flex; flex-direction: column; gap: 8px; }
.room-door { display: flex; flex-direction: column; gap: 2px; }
.room-door strong { font-size: 13px; }
.xr-options { display: flex; flex-direction: column; gap: 8px; max-height: 60vh; overflow-y: auto; }
.together-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.together-row #together-join-code { width: 90px; text-transform: uppercase; letter-spacing: 0.2em; }
.together-code { font-size: 22px; font-weight: 700; letter-spacing: 0.25em; color: var(--accent); }
/* „Gemeinsam“: schwebendes Panel – man arbeitet weiter, während man wartet bzw. verbunden ist */
#together-dialog { background: transparent; pointer-events: none; place-items: start center; padding-top: 110px; }
#together-dialog .start-window { pointer-events: auto; width: min(340px, 100%); }
/* Szenen auf dem Server */
.scene-server { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border); }
.scene-server-head { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.scene-server-head strong { flex: 1; font-size: 13px; }
.scene-server-list { display: flex; flex-direction: column; gap: 4px; max-height: 260px; overflow-y: auto; }
.scene-row { display: flex; align-items: center; gap: 4px; padding: 4px 6px; border-radius: 8px; background: var(--surface-2); user-select: none; -webkit-touch-callout: none; cursor: context-menu; }
.scene-row .scene-row-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.scene-row .scene-row-meta { font-size: 11px; color: var(--muted, #8a8fa3); white-space: nowrap; }
.scene-row .icon-btn { width: 28px; height: 28px; }

/* Reiter MCP */
#mcp-box .mcp-endpoint { font-size: 12px; margin: 4px 0 8px; display: flex; gap: 6px; align-items: baseline; flex-wrap: wrap; }
#mcp-box .mcp-endpoint code { user-select: all; word-break: break-all; }
#mcp-box .mcp-log { display: flex; flex-direction: column; gap: 3px; max-height: 50vh; overflow-y: auto; font-size: 12px; }
#mcp-box .mcp-log-row { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 6px; padding: 3px 6px; border-radius: 6px; background: var(--surface-2); }
#mcp-box .mcp-log-row.error { color: #ff8a8a; }
#mcp-box .mcp-log-row span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Gemeinsam als Gast: nur Freie Kamera, Avatar (Augen), VR und Gemeinsam (zum Trennen) – alles andere bis zum Trennen aus */
body[data-together="guest"] #camera-mode [data-mode="shot"],
body[data-together="guest"] #cam-chips,
body[data-together="guest"] #camera-mode .camera-sep,
body[data-together="guest"] #menu,
body[data-together="guest"] #panel,
body[data-together="guest"] #timeline,
body[data-together="guest"] .scene-remove,
body[data-together="guest"] .view-gizmo { display: none !important; }

/* Dynamische Texturen: Auswahl in der Bibliothek, Tauschen am Prop/Raum-Gegenstand */
.dyn-dialog { z-index: 45; }
.dyn-dialog .start-window { width: min(440px, 100%); max-height: 85vh; }
.dyn-list { display: flex; flex-direction: column; gap: 6px; overflow: auto; min-height: 40px; }
.dyn-row { display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: 8px; cursor: pointer; }
.dyn-row:hover { background: var(--surface-2); }
.dyn-row img, .dyn-noimg { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex: none; background: var(--surface-2); display: grid; place-items: center; }
.dyn-box { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.dyn-box[hidden] { display: none; }
.dyn-slot { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dyn-slot .dyn-name { flex: 1 1 120px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dyn-slot .dyn-file { flex: 1 1 100%; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dyn-slot .dyn-select { max-width: 170px; min-width: 0; }
.slider-row.loop-row { grid-template-columns: minmax(0, 1fr) 110px 44px auto; }
.loop-off { display: inline-flex; align-items: center; gap: 3px; font-size: 12px; color: var(--muted); }
.loop-def .number { width: 64px; }
.dps-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.fluid-item + .fluid-item { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.fluid-kind { display: flex; align-items: baseline; gap: 8px; margin: 2px 0 4px; }
.fluid-frames { margin-top: 6px; }
.tl-key.fluid::after {
  content: ""; position: absolute; left: 3px; top: 3px; width: 4px; height: 4px; background: #9be7ff;
}
