/* 3D-Ansicht (js/3d/): Bühne, Beschriftungen, Zeiger je Werkzeug, Aktionsknöpfe an der Pille.
   Gilt für das Studio (app/index.html) und den 3D-Tab des Planers (index.html#ansicht3d). */
.studio-buehne { position: relative; flex: 1; min-width: 0; min-height: 0; overflow: hidden; cursor: default; touch-action: none; }
.studio-buehne canvas { display: block; outline: none; }
.studio-buehne.zieht { cursor: grabbing; }
.studio-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.studio-label { position: absolute; left: 0; top: 0; white-space: nowrap; font: 600 11px/1 var(--font-num); will-change: transform; }
.studio-label-stack { background: var(--stackfarbe, #e8e8ea); color: #0B0B0D; padding: 3px 8px; border-radius: 999px; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
.studio-label-stack.gewaehlt { outline: 2px solid var(--accent); outline-offset: 1px; }
.studio-label-stack { pointer-events: auto; cursor: grab; user-select: none; }
.studio-label-stack.nur-klick { cursor: pointer; }
.studio-buehne.zieht .studio-label-stack { cursor: grabbing; }
/* Drehpunkt beim Drehen der Ansicht */
.studio-drehpunkt { width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 0 0 3px rgba(76,125,255,.3); margin-top: 5px; }
.studio-buehne.dreht { cursor: move; }
.studio-label-geist { background: var(--accent); color: #fff; padding: 3px 8px; border-radius: 999px; font-weight: 600; }
.studio-label-geist.rot { background: var(--bad); }
.studio-label-stack.aus { opacity: .4; }
.studio-label-raum { color: rgba(255,255,255,.75); font-weight: 500; transform-origin: 0 100%; }
.studio-hinweis { position: absolute; left: 12px; bottom: 10px; right: 12px; font-size: 11.5px; color: var(--muted); pointer-events: none; text-shadow: 0 1px 2px #000; }
/* Diamond-Loader (Loading UI) in der Ladeanzeige der 3D-Ansicht: acht Pixel auf einer Raute, nacheinander aufblitzend; Farbe = Textfarbe */
.studio-laden { display: flex; align-items: center; gap: 9px; }
.diamant { width: 20px; height: 20px; flex: none; fill: currentColor; }
.diamant rect { opacity: 0; animation: spin-pixel .8s ease-in-out infinite; }
.diamant .pixel-2 { animation-delay: .1s; } .diamant .pixel-3 { animation-delay: .2s; } .diamant .pixel-4 { animation-delay: .3s; }
.diamant .pixel-5 { animation-delay: .4s; } .diamant .pixel-6 { animation-delay: .5s; } .diamant .pixel-7 { animation-delay: .6s; } .diamant .pixel-8 { animation-delay: .7s; }
@keyframes spin-pixel { 0% { opacity: 0; } 1% { opacity: 1; } 100% { opacity: 0; } }
.studio-laden { position: absolute; left: 50%; transform: translateX(-50%); top: 10px; font-size: 12px; color: var(--ink2); background: rgba(20,20,23,.8); border: 1px solid var(--line2); border-radius: 999px; padding: 3px 11px; pointer-events: none; }

/* Zeiger je Werkzeug */
.studio-buehne[data-werkzeug="rotieren"] { cursor: grab; }
.studio-buehne[data-werkzeug="hand"] { cursor: grab; }
.studio-buehne[data-werkzeug="zoom"] { cursor: zoom-in; }
.studio-buehne[data-werkzeug="verschieben"] { cursor: move; }
.studio-buehne[data-werkzeug="drehen"], .studio-buehne[data-werkzeug="kippen"], .studio-buehne[data-werkzeug="radierer"] { cursor: crosshair; }
.studio-buehne.dreht { cursor: grabbing !important; }

/* Aktionsknöpfe an der Pille (Strg + Maus über der Pille): springen nacheinander heraus */
.pillen-aktionen { position: absolute; left: 50%; top: calc(100% + 6px); transform: translateX(-50%); display: flex; gap: 4px; padding: 4px;
  background: rgba(14,14,18,.9); border: 1px solid var(--line2); border-radius: 999px; box-shadow: 0 8px 20px -8px rgba(0,0,0,.8); }
/* unsichtbare Brücke über der Lücke zwischen Pille und Knöpfen: die Maus bleibt „drin“ */
.pillen-aktionen::before { content: ""; position: absolute; left: -8px; right: -8px; top: -12px; height: 12px; }
.pillen-knopf { width: 26px; height: 26px; padding: 0; justify-content: center; border-radius: 50%; background: var(--panel2); border-color: transparent; color: var(--ink2); }
.pillen-knopf svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.pillen-knopf:hover { background: var(--accent); color: #fff; }
.pillen-aktionen.neu { animation: pille-auf .22s cubic-bezier(.2,.9,.3,1.3) both; }
.pillen-aktionen.neu .pillen-knopf { animation: knopf-auf .32s cubic-bezier(.2,.9,.3,1.4) both; }
.pillen-aktionen.neu .pillen-knopf:nth-child(2) { animation-delay: .03s; }
.pillen-aktionen.neu .pillen-knopf:nth-child(3) { animation-delay: .06s; }
.pillen-aktionen.neu .pillen-knopf:nth-child(4) { animation-delay: .09s; }
.pillen-aktionen.neu .pillen-knopf:nth-child(5) { animation-delay: .12s; }
.pillen-aktionen.weg { animation: pille-zu .15s ease both; }
@keyframes pille-auf { from { opacity: 0; transform: translateX(-50%) translateY(-6px) scale(.6); } to { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); } }
@keyframes knopf-auf { from { opacity: 0; transform: scale(.3); } to { opacity: 1; transform: scale(1); } }
@keyframes pille-zu { to { opacity: 0; transform: translateX(-50%) translateY(-4px) scale(.8); } }
.ohne-animation .pillen-aktionen, .ohne-animation .pillen-knopf { animation: none !important; }

/* 3D-Ansicht des Planers: eigener Tab (index.html#ansicht3d) und über dem Planer (Knopf „3D-Ansicht“, .drei-voll).
   Oben die Werkzeugleiste (wie im Studio, Aussehen wie Blender), rechts die Boxen-Palette, unten der Hinweis aus js/3d/. */
.drei-mitte { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0; }
.drei-raum { position: relative; flex: 1; min-width: 0; min-height: 0; display: flex; border-radius: 12px; overflow: hidden; }

/* Über dem Planer: das ganze Fenster, Planer bleibt darunter stehen */
.drei-voll { position: fixed; inset: 0; z-index: 800; display: flex; flex-direction: column; background: #0b0b0e; }
.drei-voll .drei-raum { border-radius: 0; }
body.drei-offen { overflow: hidden; }
/* Planer darunter stilllegen: keine Klicks, kein Fokus, keine Tastatur (die Tasten gehören der 3D-Ansicht) */
body.drei-offen .seite, body.drei-offen .fuss { visibility: hidden; }

/* Kopfleiste: Marke, Werkzeuge, Bearbeiten, Ansichten, rechts Palette/Fenster/Zurück */
.drei-kopf { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 6px 10px; background: rgba(14,14,18,.94);
  border-bottom: 1px solid var(--line2); box-shadow: 0 6px 18px -12px #000; }
.drei-voll .drei-kopf { padding: 7px 12px; }
.drei-marke { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.drei-marke img { border-radius: 5px; display: block; }
.drei-projekt { max-width: 190px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drei-gruppe { display: flex; align-items: center; gap: 2px; padding-left: 8px; margin-left: 2px; border-left: 1px solid var(--line2); }
.drei-rechts { display: flex; align-items: center; gap: 2px; margin-left: auto; padding-left: 8px; border-left: 1px solid var(--line2); }
.drei-knopf { display: inline-flex; align-items: center; justify-content: center; gap: 5px; height: 30px; min-width: 30px; padding: 0 6px;
  background: transparent; border: 1px solid transparent; border-radius: 7px; color: var(--ink2); cursor: pointer; }
.drei-knopf svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.drei-knopf.breit { padding: 0 9px; font-size: 12px; }
.drei-knopf:hover { background: var(--panel2); color: var(--ink); }
.drei-knopf.aktiv, .drei-knopf[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.drei-knopf.aktiv:hover { background: var(--accent); }
.drei-text { font-size: 12px; }
.drei-zurueck { background: var(--panel2); border-color: var(--line2); color: var(--ink); font-weight: 600; }
.drei-zurueck:hover { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Fläche + Boxen-Palette */
.drei-koerper { flex: 1; display: flex; min-height: 0; min-width: 0; }
.drei-koerper.ohne-palette .drei-palette { display: none; }
/* Rechte Leiste: schwebt als durchsichtige Glasfläche am rechten Rand, die oberste Zeile bleibt frei (nur Palette / Fenster / Zurück) */
.drei-palette { position: absolute; right: 12px; top: 58px; bottom: 12px; z-index: 5; width: 252px; display: flex; flex-direction: column; min-height: 0; overflow: hidden;
  background: rgba(18,18,24,.66); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,.08); border-radius: 14px; box-shadow: 0 14px 34px -14px #000; }

/* Werkzeugleiste links (senkrecht, nur Symbole): Auswählen, Rotieren, Hand, Zoom, Verschieben, Drehen */
/* Alles schwebt über der 3D-Fläche, keine feste Leiste: Wasserzeichen oben links, Werkzeuge links, Aktionen oben mittig, Palette/Fenster/Zurück oben rechts */
.drei-koerper { position: relative; }
.drei-leiste { position: absolute; left: 12px; top: 84px; bottom: 44px; z-index: 5; pointer-events: none; }
/* eine Spalte, bei zu wenig Höhe läuft sie in eine zweite über; die Gruppen lösen sich auf, die Knöpfe sind direkte Kinder */
.drei-leiste-spalte { display: flex; flex-direction: column; flex-wrap: wrap; align-content: flex-start; gap: 4px; max-height: 100%; }
.drei-leiste .drei-gruppe { display: contents; }
.drei-leiste-abstand { width: 30px; height: 8px; flex: none; }
.drei-leiste .drei-knopf { pointer-events: auto; width: 34px; height: 34px; min-width: 34px; padding: 0; border-radius: 10px; background: rgba(18,18,24,.6); border: 1px solid rgba(255,255,255,.07);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.drei-leiste .drei-knopf svg { width: 19px; height: 19px; }
.drei-leiste .drei-text { font-size: 11px; letter-spacing: -.02em; }
/* Stack drehen ±15°: Drehpfeil mit der Gradzahl darunter */
.drei-dreh { display: flex; flex-direction: column; align-items: center; gap: 0; font-size: 9.5px; font-weight: 600; line-height: 1; letter-spacing: -.01em; }
.drei-leiste .drei-dreh svg { width: 16px; height: 16px; }
.drei-leiste-abstand { width: 34px; }
.drei-leiste .drei-knopf:hover { background: rgba(48,48,58,.8); }
.drei-leiste .drei-knopf.aktiv { background: var(--accent); border-color: var(--accent); }
.drei-marke { position: absolute; left: 16px; top: 12px; z-index: 4; display: flex; align-items: center; gap: 9px; font-size: 16px; color: #fff; pointer-events: none; user-select: none;
  text-shadow: 0 1px 6px rgba(0,0,0,.7); }
.drei-marke img { border-radius: 6px; display: block; width: 30px; height: 30px; filter: brightness(1.25); }
.drei-marke b { font-weight: 700; }
.drei-projekt { font-weight: 400; color: rgba(255,255,255,.45); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drei-aktionen { position: absolute; top: 10px; left: calc((100% - 252px) / 2); transform: translateX(-50%); z-index: 5; }
.drei-koerper.ohne-palette .drei-aktionen { left: 50%; }
.drei-aktionen .drei-gruppe, .drei-koerper > .drei-rechts { display: flex; gap: 2px; margin: 0; border: 0; padding: 4px; background: rgba(18,18,24,.62); border-radius: 12px;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); box-shadow: 0 6px 18px -10px #000; }
.drei-koerper > .drei-rechts { position: absolute; top: 10px; right: 12px; z-index: 6; }

/* Abschnitte der rechten Leiste: Kopfzeile mit Pfeil (einklappbar), darunter der Inhalt */
.drei-sek { display: flex; flex-direction: column; min-height: 0; border-bottom: 1px solid var(--line2); }
.drei-sek-ebenen { flex: 0 1 auto; max-height: 52%; }
.drei-sek-boxen { flex: 1 1 0; border-bottom: 0; }
.drei-sek.zu { flex: none; }
.drei-sek-kopf { display: flex; align-items: center; gap: 7px; width: 100%; padding: 8px 10px; background: rgba(0,0,0,.16); border: 0; border-radius: 0; color: var(--ink);
  font-size: 12.5px; text-align: left; cursor: pointer; flex: none; }
.drei-sek-kopf:hover { background: rgba(255,255,255,.04); }
.drei-sek-kopf b { font-weight: 600; letter-spacing: .01em; }
.drei-sek-pfeil { width: 10px; color: var(--muted); font-size: 10px; }
.drei-sek-zahl { margin-left: auto; color: var(--muted); font-size: 11px; font-weight: 400; }
.drei-sek-rumpf { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; padding-top: 6px; }
.drei-sek.zu .drei-sek-rumpf { display: none; }
.drei-pal-boxen { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.drei-ebenen { flex: 1; min-height: 0; display: flex; flex-direction: column; padding: 0 6px 6px; }
.drei-ebenen .drei-eb-liste { flex: 1; min-height: 0; }
.drei-eb { border-radius: 7px; padding: 4px 6px 4px 3px; }
.drei-eb-box { border-radius: 6px; }
/* lose Boxen: eigener Abschnitt unter den Stacks, mit Trennlinie und Überschrift */
.drei-eb-trenner { display: flex; align-items: center; justify-content: space-between; margin: 8px 6px 2px; padding: 8px 4px 3px; border-top: 1px solid var(--line2);
  font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
.drei-eb.lose { cursor: grab; }
.drei-eb.lose .drei-eb-name { font-style: italic; color: var(--ink2); }
.drei-pal-kopf { display: flex; align-items: baseline; justify-content: space-between; gap: 6px; padding: 9px 11px 5px; }
.drei-pal-suche { margin: 0 9px 6px; padding: 5px 8px; font-size: 12px; background: var(--panel2); border: 1px solid var(--line2); border-radius: 6px; color: var(--ink); }
.drei-pal-suche:focus { outline: none; border-color: var(--accent); }
.drei-pal-liste { flex: 1; min-height: 0; overflow: auto; overflow-x: hidden; padding: 0 14px 10px 6px; }
.drei-pal-gruppe { padding: 8px 5px 3px; font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.drei-pal-item { display: flex; align-items: center; gap: 7px; padding: 4px 8px 4px 6px; border-radius: 6px; cursor: grab; user-select: none; }
.drei-pal-item:hover { background: var(--panel2); }
.drei-pal-item:active { cursor: grabbing; }
.drei-pal-bild { width: 26px; height: 26px; flex: none; }
.drei-pal-name { flex: 1; min-width: 0; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.drei-pal-mass { flex: none; max-width: 74px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.drei-pal-leer { padding: 8px 6px; }

/* Ebenen: je Stack eine Zeile (Boxen aufklappbar, auf andere Zeilen ziehbar) */
.drei-eb-liste { overflow-y: auto; overflow-x: hidden; padding: 0 0 4px; }
.drei-eb { display: flex; align-items: center; gap: 6px; padding: 3px 8px 3px 4px; cursor: pointer; user-select: none; border-radius: 0; }
.drei-eb:hover { background: rgba(255,255,255,.04); }
.drei-eb.gewaehlt { background: rgba(76,125,255,.28); }
.drei-eb.teil { background: rgba(76,125,255,.12); }
.drei-eb.ziel { background: rgba(76,125,255,.4); outline: 1px dashed var(--accent); outline-offset: -1px; }
.drei-eb.aus .drei-eb-name { opacity: .45; }
.drei-eb-klapp { width: 18px; height: 20px; padding: 0; justify-content: center; background: transparent; border: 0; color: var(--muted); font-size: 10px; cursor: pointer; }
.drei-eb-punkt { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.drei-eb-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.drei-eb-feld { flex: 1; min-width: 0; padding: 1px 6px; font-size: 12px; border-radius: 4px; background: #2b3a63; border: 1px solid var(--accent); color: var(--ink); }
.drei-eb-zahl { color: var(--muted); font-size: 10.5px; flex: none; }
.drei-eb-symbol { width: 22px; height: 22px; padding: 0; display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 0; border-radius: 5px; color: var(--ink2); opacity: .7; cursor: pointer; }
.drei-eb-symbol:hover { opacity: 1; background: rgba(255,255,255,.06); }
.drei-eb-symbol.an { color: var(--warn, #e0a030); opacity: 1; }
.drei-eb-symbol svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.drei-eb-kinder { padding: 2px 8px 6px 20px; border-left: 1px solid var(--line2); margin-left: 17px; }
.drei-eb-box { display: flex; justify-content: space-between; gap: 6px; padding: 2px 6px; border-radius: 4px; cursor: grab; color: var(--ink2); font-size: 12px; }
.drei-eb-box:hover { background: rgba(255,255,255,.04); }
.drei-eb-box.gewaehlt { background: rgba(76,125,255,.28); color: #fff; }
.drei-eb-box-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Untermenü im Rechtsklick-Menü (fährt seitlich aus) */
.drei-menue-hat-unter { position: relative; }
.drei-menue-unter { display: none; position: absolute; left: calc(100% - 3px); top: -5px; z-index: 910; min-width: 210px; max-height: 60vh; overflow: auto; padding: 4px;
  background: #18181d; border: 1px solid rgba(255,255,255,.12); border-radius: 8px; box-shadow: 0 18px 40px -18px #000, 0 2px 8px rgba(0,0,0,.5); }
.drei-menue-unter.links { left: auto; right: calc(100% - 3px); }
.drei-menue-hat-unter:hover > .drei-menue-unter, .drei-menue-hat-unter:focus-within > .drei-menue-unter { display: block; }
.drei-menue-hat-unter:hover > .drei-menue-eintrag { background: var(--panel2); }
.drei-menue-unter .drei-menue-eintrag { justify-content: flex-start; gap: 8px; }
.drei-menue-haken { width: 12px; flex: none; color: var(--accent); }
.drei-menue-unter .drei-menue-eintrag:hover:not(:disabled) .drei-menue-haken { color: #fff; }

.drei-koerper:not(.ohne-palette) .studio-hinweis { right: 282px; }

/* Gradzahl am Winkelmesser (Werkzeug „Drehen“) */
.studio-label-winkel { background: rgba(12,15,24,.9); color: #fff; border: 1.5px solid var(--accent); padding: 4px 10px; border-radius: 999px;
  font: 700 15px/1 var(--font-num); box-shadow: 0 3px 12px rgba(0,0,0,.55); pointer-events: none; }
.studio-label-winkel.rastet { border-color: #4cd68b; color: #4cd68b; }

/* Blasen über den Stacks sind erstmal weg: Stacks wählt man über die Ebenen rechts oder direkt an den Boxen */
.studio-label-stack { display: none !important; }

/* Rechtsklick-Menü in der 3D-Ansicht (wie im Studio) */
.drei-menue { position: fixed; z-index: 900; min-width: 214px; padding: 4px; background: #18181d; border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; box-shadow: 0 18px 40px -18px #000, 0 2px 8px rgba(0,0,0,.5); }
.drei-menue-kopf { padding: 5px 9px 6px; font-size: 11.5px; color: var(--muted); border-bottom: 1px solid var(--line2); margin-bottom: 4px;
  max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drei-menue-eintrag { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: 100%; padding: 6px 9px;
  background: transparent; border: 0; border-radius: 5px; color: var(--ink); font-size: 12.5px; text-align: left; cursor: pointer; }
.drei-menue-eintrag:hover:not(:disabled) { background: var(--accent); color: #fff; }
.drei-menue-eintrag:disabled { opacity: .5; cursor: default; }
.drei-menue-taste { font-size: 11px; color: var(--muted); }
.drei-menue-eintrag:hover:not(:disabled) .drei-menue-taste { color: rgba(255,255,255,.8); }
.drei-menue-trenner { height: 1px; margin: 4px 6px; background: var(--line2); }

/* Auswahl-Rechteck (Werkzeug „Auswählen“): mit der linken Taste auf der leeren Fläche aufziehen */
.drei-marquee { position: absolute; z-index: 6; pointer-events: none; border: 1px dashed var(--accent); background: rgba(76,125,255,.12); }
.studio-buehne.zieht-auswahl { cursor: crosshair; }

/* Schmale Fenster: Leiste umbrechen, Palette schmaler */
@media (max-width: 900px) {
  .drei-palette { width: 178px; }
  .drei-marke .drei-projekt { display: none; }
  .drei-ansichten .drei-knopf.breit { padding: 0 6px; }
}

