:root {
  /* Farben */
  --scene-bg      : #d6d6d6;
  --color-bg      : #999999;
  --color-surface : #6e6e6e;
  --color-primary : #494949;
  --color-text    : #ffffff;
  --color-border  : #afafaf;
  --color-disabled: #555555;
  --ripple-size   : 128px; /* Spinner-Größe */
}

/* Globales Reset */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg); z-index: 9999;
  color: var(--color-text, #111);
  font-family: "Segoe UI", sans-serif;
}


/* --- Autostart Overlay (aus autostart.css migriert) --- */
#autostart-overlay{
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  background: var(--scene-bg);
  z-index: 9999;
}
#autostart-logo{ max-width: 200px; margin-bottom: 24px; }

.autostart-loading-bar{
  width: 50%;
  max-width: 400px;
  height: 12px;
  background: var(--color-border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 16px;
}
.autostart-loading-fill,
#progress-bar{
  width: 0%;
  height: 100%;
  background: var(--color-text);
  border-radius: 6px;
  transition: width .5s ease;
}

/* Start-Button: textfarbener Hintergrund, schwarze Schrift, leichter Schatten */
#start-compute-btn{
  margin-top: 20px;
  width: auto;
  background: var(--color-text);
  color: #000;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,.12);
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
}
#start-compute-btn,
.autostart-text{
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
}
#start-compute-btn:hover{ box-shadow: 0 3px 10px rgba(0,0,0,.16); }
#start-compute-btn:active{ box-shadow: 0 1px 4px rgba(0,0,0,.12); }
#start-compute-btn:disabled{ opacity: .6; cursor: default; box-shadow: none; }

.autostart-text{
  margin-top: 10px;
  color: var(--color-text);
  font-family: system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial,sans-serif;
}

/* ----- Aufteilung Canvas & UI-Elemente ----- */

#container {
  display: flex;
  width: 100vw;
  height: 100vh;
  position: relative;
  flex-direction: row;
}

/* 3D-Canvas */
canvas#three-canvas {
  width: 66.66vw;
  height: 100vh;
  display: block;
  background: var(--color-bg);
  position: relative;
  z-index: 1;
}

/* UI-Sidebar */
#overlay {
  width: 33.33vw;
  height: 100vh;
  padding: 64px 24px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: auto;
  box-sizing: border-box;
}

/* Portrait: Layout vertikal stapeln */
@media (max-aspect-ratio: 1/1) {
  #container {
    flex-direction: column;
  }

  canvas#three-canvas {
    width: 100vw;
    height: 66.66vh;
  }

  #overlay {
    width: 100vw;
    height: 33.33vh;
    padding: 24px;
  }
}

/* ----- Aufteilung Canvas & UI-Elemente ENDE ----- */

/* Labels */
label {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text);
}

/* Range-Slider Basis */
input[type=range] {
  -webkit-appearance: none;
  -moz-appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 2px;
  background: var(--color-surface);
  cursor: default;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 5px;
  height: 20px;
  border-radius: 9px;
  background: var(--color-primary);
  cursor: pointer;
  margin-top: -7px;
  border: none;
}
input[type=range]::-moz-range-thumb {
  width: 5px;
  height: 20px;
  border-radius: 9px;
  background: var(--color-primary);
  cursor: pointer;
  border: none;
}
input[type=range]::-ms-thumb {
  width: 5px;
  height: 20px;
  border-radius: 9px;
  background: var(--color-primary);
  cursor: pointer;
  border: none;
}

/* Zahleneingabe */
input[type=number] {
  width: 50px;
  padding: 5px;
  background: var(--color-surface);
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--color-text);
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: textfield;
  cursor: text;
}
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
  appearance: none;
  margin: 0;
}
input[type=number]:focus {
  border: 1px solid var(--color-text);
  outline: none;
}

/* Range + Number inline */
.range-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Switch statt Checkbox */
input[type=checkbox] {
  position: relative;
  width: 45px;
  height: 20px;
  appearance: none;
  background: var(--color-surface);
  border-radius: 10px;
  cursor: pointer;
  outline: none;
  transition: background 0.2s;
}
input[type=checkbox]::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--color-bg);
  border-radius: 8px;
  transition: left 0.2s;
}
input[type=checkbox]:checked {
  background: var(--color-primary);
}
input[type=checkbox]:checked::before {
  left: calc(100% - 18px);
}

/* Checkbox-Label und Switch auf eine Zeile, Abstand und Ausrichtung */
.checkbox-field {
  display: flex;
  justify-content: space-between;
  align-items: center;
}


/* Text-Input ohne Hover, 1px Border bei Fokus */
input[type=text] {
  width: 100%;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid transparent;
  border-radius: 5px;
  color: var(--color-text);
  cursor: text;
}
input[type=text]:focus {
  border: 1px solid var(--color-text);
  outline: none;
}

/* File-Upload als Button mit dynamischem Label */
input[type=file] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
  overflow: hidden;
}

.file-upload-button {
  display: inline-block;
  width: 100%;
  text-align: center;
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 8px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.file-upload-button:hover {
  border-color: var(--color-text);
}
.file-upload-button:active {
  border-color: var(--color-primary);
}

.file-upload-container {
  position: relative;
}

/* Positioniere das X oben rechts über dem Button */
.clear-stl-btn {
  position: absolute;
  top: -12px;
  right: 10px;
  transform: translate(50%, -50%);
  padding: 2px;
  background:transparent;
  border: none;
  cursor: pointer;
  color: var(--color-surface);
}
.clear-stl-btn:hover {
  color: var(--color-primary);
}


/* Buttons */
button {
  background: var(--color-primary);
  color: var(--color-text);
  border: none;
  padding: 10px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  width: 100%;
}
button:disabled {
  background: var(--color-disabled);
  cursor: not-allowed;
}

/* Save-Link */
a {
  color: var(--color-text);
  text-decoration: underline;
  font-size: 13px;
  display: block;
  text-align: center;
  cursor: pointer;
}

/* Spinner im Canvas */
.ripple-spinner {
  position: absolute;
  bottom: 20px;
  right: calc(33.333% + 40px); /* Landscape: rechts neben Canvas */
  width: var(--ripple-size);
  height: var(--ripple-size);
  pointer-events: none;
  z-index: 9999;
}

.ripple-spinner div {
  position: absolute;
  width: 100%;
  height: 100%;
  border: 4px solid var(--color-border);
  border-radius: 50%;
  opacity: 0;
  animation: ripple 1.5s ease-out infinite;
}

.ripple-spinner div:nth-child(1) { animation-delay: 0s; }
.ripple-spinner div:nth-child(2) { animation-delay: 0.5s; }
.ripple-spinner div:nth-child(3) { animation-delay: 1s; }

@keyframes ripple {
  0%   { transform: scale(0.1); opacity: 1; }
  100% { transform: scale(1);   opacity: 0; }
}

/* Portrait-Modus: Spinner unten rechts im Canvas */
@media (max-aspect-ratio: 1/1) {
  .ripple-spinner {
    top: auto;
    bottom: 33.33vh; /* Canvas endet hier */
    left: auto;
    right: 20px;
  }
}

/* Cursor-Stile */
input[type=checkbox], button, a { cursor: pointer; }
input[type=text], input[type=number], textarea { cursor: text; }

/* Konfigurations-Menü */
.config-menu-container {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 100;
}

/* Button-Style */
#configMenuButton {
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
}

/* zwingt das Verstecken */
.hidden {
  display: none !important;
}

/* Portrait-Modus: Button innerhalb des Overlay platzieren */
@media (max-aspect-ratio: 1/1) {
  .config-menu-container {
    position: static;
    align-self: flex-end;
    margin-bottom: auto;
    padding-top: 0;
  }
}

/* Buttons nicht in voller Breite */
.nowrap-button {
  white-space: nowrap;
  width: auto;
}

/* Dropdown unterhalb und links am Button, Hintergrund = Rahmenfarbe, Schatten + Rahmen */
#configMenuDropdown {
  position: absolute;
  top: calc(100% - 4px);
  right: 0;
  background: var(--color-border);
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
}

/* Entfernt den Rahmen um den Drei-Punkte-Button */
#overlay > .config-menu-container {
  border: none !important;
}


.range-with-value {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.range-with-value .slider {
  flex: 3;       /* Slider erhält 3 Teile des verfügbaren Platzes */
  min-width: 0;  /* verhindert Überlauf */
}

.range-with-value .slider-value {
  flex: 1;       /* Textfeld erhält 1 Teil des verfügbaren Platzes */
  width: auto;   /* damit flex korrekt greift */
  max-width: 3rem; /* opt. für 6-stelligen Platzbedarf */
}

.accordion-group {
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  border-radius: 4px;
  margin-bottom: 0.5rem;
  overflow: hidden; /* damit abgerundete Ecken auch den Shadow-Effekt beibehalten */
}

.accordion-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-surface);
  padding: 0.5rem 1rem;
  border: none;
  width: 100%;
  cursor: pointer;
}

.accordion-icon {
  display: inline-block;      /* macht den Span sichtbar */
  width: 1rem;                /* Platz für das Symbol */
  font-size: 1rem;            /* Pfeil-Größe */
  color: var(--color-text);   /* damit er sich abhebt */
  text-align: center;
  transition: transform 0.2s;
}

/* Optional: Schatten für den Content-Bereich */
.accordion-content {
  background: var(--color-bg);
  padding: 0.5rem 1rem;
}


/* ===== Verschachtelte Accordion-Subgruppen (an das Verhalten der ersten Stufe angepasst) ===== */
.accordion-subgroup {
  overflow: hidden;                     /* Rundungen sauber maskieren */
  margin-top: 0.5rem;
  border-radius: 4px;                   /* Gleiche Rundung wie Hauptgruppe */
  box-shadow: 0 2px 8px rgba(0,0,0,0.3); /* Leichter innerer Schatten für Tiefe */
}

/* Toggle-Button der Subgruppe */
.accordion-subgroup > .accordion-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--color-surface);
  padding: 0.5rem 1rem;
  border: none;
  width: 100%;
  cursor: pointer;
  border-radius: 4px 4px 0 0;           /* Obere Ecken abgerundet */
}

/* Content-Bereich der Subgruppe */
.accordion-subgroup .accordion-content {
  background: var(--color-bg);
  padding: 0.5rem 1rem;
  border-radius: 0 0 4px 4px;           /* Untere Ecken abgerundet */
}


/* ================================ */
/* Rahmen um jeden einzelnen Parameter */
/* ================================ */
.input-field {
  border: 1px solid var(--color-border);
  padding: 0.5rem;        /* Innenabstand passend zu restlichen Abständen */
  margin-bottom: 0.5rem;  /* Abstand nach unten zum nächsten Feld */
  border-radius: 4px;     /* gleiche Rundung wie bei Gruppen */
}

/* Optional: Wenn du die Abstände zwischen Label und Control noch angleichen willst */
.input-field > label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.875rem;
}


/* ------- Popup Confirm Download -------- */
/* Modal-Hintergrund */
.modal {
  display: none;             /* standard versteckt */
  position: fixed;
  top: 0; left: 0;
  width: 100%;  height: 100%;
  background: rgba(0,0,0,0.5);
  justify-content: center;
  align-items: center;
  z-index: 1000;
}
.modal.active {
  display: flex;             /* sichtbar, wenn aktiv */
}

/* Inhalt-Box */
.modal-content {
  background: var(--color-bg);
  padding: 1.5rem;
  border-radius: 0.5rem;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
  display: flex;             /* Flex für Button-Gap */
  flex-direction: column;
  align-items: center;
}

/* Busy-Overlay im Modal */
.modal-breathe-overlay{
  position: absolute;
  inset: 0;
}
.modal-breathe-card{
  position: absolute;
  left: 50%;
  top: 80%;
  transform: translate(-50%, -50%);
  display: inline-block;
  padding: 20px 24px;
  border-radius: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  text-align: center;
  line-height: 1.35;
  font-size: 1rem;
  max-width: 560px;
  min-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
}
.modal-content.is-hidden{ visibility: hidden; }


/* Text im Modal */
.modal-content p {
  margin-bottom: 1.5rem;
}

/* Einheitliches Styling für beide Modal-Buttons */
.modal-content button {
  margin: 0.5rem 0;          /* oben/unten Abstand */
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.25rem;
  cursor: pointer;
  background: var(--color-primary);
  color: var(--color-text);
  width: 100%;               /* volle Breite, optional */
  max-width: 200px;
}


/* Abstand zwischen den dl-Buttons */
#dl-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem; /* hier den gewünschten Abstand einstellen */
}

/* Download-Checkbox + Label komplett verstecken */
input[type="checkbox"][name^="(dl-"],
input[type="checkbox"][name^="(dl-"] + label {
  display: none !important;
}

/* gesamte Download-Zeile ausblenden */
.input-field:has(> input[id^="(dl-"]),
.input-wrapper:has(> input[id^="(dl-"]),
.form-group:has(> input[id^="(dl-"]),
li:has(> input[id^="(dl-"]) {
  display: none !important;
}



/* === Choice-UI (kompakt, beschriftet) === */

.choice-group{
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: .5rem .75rem;
  margin-bottom: .5rem;
  box-shadow: none;
}

/* === Text Gruppenname (exakt wie andere Parameter-Labels) === */
.choice-label{
font-size: 0.875rem;      /* gleiche Größe */
  font-weight: 400;       /* nicht fett */
  line-height: 1rem;      /* gleiche Zeilenhöhe */
  color: var(--color-text);
  margin-bottom: .35rem;
  letter-spacing: .02em;     /* gleiche Laufweite */
}

/* Container für Parameter */
.choice-options{
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px,1fr));
  gap: .5rem .75rem;
}

.choice-pill{
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  color: var(--color-text);   /* === Text Parameter === */
}

.choice-group .choice-pill input[type="checkbox"]{
  position: absolute;
  width:1px; height:1px;
  margin:-1px; padding:0; border:0;
  clip:rect(0 0 0 0); overflow:hidden; white-space:nowrap;
}

.choice-pill span{
  display: inline-flex;
  align-items: center;
}

/* === Choice Pills unangewählt === */
.choice-pill span::before{
  content:"";
  width:.9rem; height:.9rem; margin-right:.45rem;
  border-radius:50%;
  background: var(--color-text);

}

/* === Choice Pills angewählt === */
.choice-pill input[type="checkbox"]:checked + span::before{
  background: var(--color-text);
  border: 4px solid var(--color-primary);
  
}

/* DISABLED MODE der UI-Abhängigkeiten */

.input-field.is-disabled label,
.input-field.is-disabled input,
.input-field.is-disabled .slider-value {
  opacity: .5;             /* halbtransparent */
}
/* keine Änderung an Hintergrund / Border */




/* === COLOUR PICKER === */

.input-field.has-color{
  display: flex;
  align-items: center;
  gap: .75rem;
}

/* Label links nimmt den freien Raum */
.input-field.has-color > label{
  flex: 1 1 auto;
}

/* Der Color-Block rutscht nach rechts */
.input-field.has-color .color-field{
  margin-left: auto;
  display: inline-flex;
  align-items: center;
}

/* Der klickbare Farbfleck */
.color-chip{
  inline-size: 2.25rem;
  block-size: 1.25rem;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  cursor: pointer;
}

/* Versteckter nativer Farbwähler (aus deiner letzten Version) */
.sr-only{
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}


/* CFG-Button: volle Breite im Accordion + Luft */
.cfg-btn{
  display: block;
  width: 100%;
  margin: .5rem 0;
  white-space: normal;    /* lange Titel umbrechen */
  padding: 12px;          /* etwas mehr Fingerfläche */
}

/* In Choice-Grids ganze Zeile belegen */
.choice-options .cfg-btn{
  grid-column: 1 / -1;
}

/* Konsistente Abstände im Accordion-Content */
.accordion-content .cfg-btn{
  margin: .5rem 0;
}
