/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  overflow-x: hidden;
  scrollbar-width: none;
}

/* ── Variablen ───────────────────────────────────────────────────── */
:root {
  --ui-width: 300px;
  --radius: 6px;
  --border: 1px solid rgb(191, 191, 191);
  --color1: rgb(255, 255, 255);
  --color2: rgb(241, 241, 241);
  --color3: rgb(192, 192, 192);
  --color4: rgb(82, 82, 82);
  --color5: rgb(0, 0, 0);
  --transition: 0.3s ease;

  --font-size1: 1.5rem;
  --font-size2: 1.2rem;
  --font-size3: 1rem;
  --font-size4: 0.8rem;
  --font-size5: 0.7rem;
}

/* ── Fonts ───────────────────────────────────────────────────────── */
@font-face {
  font-family: "Apfel";
  src: url("../fonts/ApfelGrotezk-Regular.otf") format("opentype");
  font-weight: 100;
  font-display: swap;
}
@font-face {
  font-family: "Apfel";
  src: url("../fonts/ApfelGrotezk-Mittel.otf") format("opentype");
  font-weight: 200;
  font-display: swap;
}
@font-face {
  font-family: "Apfel";
  src: url("../fonts/ApfelGrotezk-Fett.otf") format("opentype");
  font-weight: 300;
  font-display: swap;
}
@font-face {
  font-family: "Apfel";
  src: url("../fonts/ApfelGrotezk-Satt.otf") format("opentype");
  font-weight: 400;
  font-display: swap;
}

/* ── Base ────────────────────────────────────────────────────────── */
body {
  background: var(--color2);
  overflow: hidden;
  font-family: "Apfel", sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Typografie ──────────────────────────────────────────────────── */
h1 {
  font-size: var(--font-size1);
  font-weight: 300;
  text-transform: uppercase;
  line-height: 1.6rem;
  text-align: center;
  overflow-y: hidden;
}

h2 {
  font-size: var(--font-size3);
  font-weight: 300;
  line-height: var(--font-size2);
  text-align: center;
  overflow-y: hidden;

}

h3 {
  font-size: var(--font-size4);
  line-height: 0.9rem;
  font-weight: 200;
  margin-bottom: 0.5rem;
  overflow-y: hidden;
  
}

h4 {
  font-size: var(--font-size5);
  line-height: 1.3rem;
  font-weight: 100;
  color: var(--color4);
}

p {
  font-size: var(--font-size4);
  line-height: 0.9rem;
  font-weight: 100;
  overflow-y: hidden;
}

p strong {
  font-weight: 200;
  overflow-y: hidden;
}

em {
  font-weight: 100;
  font-style: normal;
  overflow-y: hidden;
}

a,
a:visited {
  color: blue;
  text-decoration: none;
  overflow-y: hidden;
}

/* ── Canvas ──────────────────────────────────────────────────────── */
#canvasWrapper {
  position: relative;
  width: 100%;
  height: 100%;
}

canvas#three {
  display: block;
  width: calc(100vw - var(--ui-width));
  height: 100vh;
  -webkit-transition: width var(--transition);
  transition: width var(--transition);
}

#overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
}

/* ── Status ──────────────────────────────────────────────────────── */
#status {
  position: fixed;
  top: 20px;
  left: 50%;
  -webkit-transform: translateX(-50%);
  transform: translateX(-50%);
  color: var(--color2);
  font-size: 13px;
  letter-spacing: 0.04em;
  -webkit-transition: opacity 1s;
  transition: opacity 1s;
  white-space: nowrap;
  pointer-events: none;
}

/* ── Toggle Button ───────────────────────────────────────────────── */
#toggleBtn {
  position: fixed;
  top: 0;
  right: var(--ui-width);
  
  width: 30px;
  height: 35px;
  margin-top: -0.2rem;
  z-index: 10;

  display: -webkit-flex;
  display: flex;

  -webkit-align-items: center;
  align-items: center;

  -webkit-justify-content: center;
  justify-content: center;

  cursor: pointer;

  background-color: rgba(223, 223, 223, 0.739);
  border: none;
  border-radius: 0 0 0 8px;
  color: var(--color1);
  font-size: var(--font-size3);

  -webkit-transition: right var(--transition);
  transition: right var(--transition);
}

/* ── UI Panel ────────────────────────────────────────────────────── */
#ui {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--ui-width);
  height: 100vh;

  display: -webkit-flex;
  display: flex;
  
  -webkit-flex-direction: column;
  flex-direction: column;
  background-color: var(--color1);
  padding: var(--font-size3);
  overflow-y: auto;
  -webkit-transition: -webkit-transform var(--transition);
  transition: transform var(--transition);
}

#ui.collapsed {
  -webkit-transform: translateX(300px);
  transform: translateX(300px);
}

/* ── Context Blocks ──────────────────────────────────────────────── */
.context {
  width: 100%;
  margin-bottom: 0.5rem;
  padding-bottom: var(--font-size5);
  border-bottom: var( --border);
  font-weight: 200;
  font-size: var(--font-size4);
  overflow-y: hidden;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.button {
  background-color: var(--color2);
  border: var(--border);
  color: var(--color5);
  padding: 2px 5px;
  margin-bottom: 0.2rem;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: var(--font-size5);
  height: 1.3rem;
  font-weight: 100;
  font-family: "Apfel", sans-serif;
  width: 49.35%;
  text-align: center;
  -webkit-transition: background-color 0.2s;
  transition: background-color 0.2s;
  /* iOS tap highlight entfernen */
  -webkit-tap-highlight-color: transparent;

  -webkit-appearance: none;
  appearance: none;
  line-height: normal;   
}

.button:hover {
  background-color:var(--color3);
}

.buttonbig {
  width: 100%;
}

.legalbutton {
  background-color: var(--color1);
  border: none;
  font-size: var(--font-size5);
  font-weight: 100;
  font-family: "Apfel", sans-serif;
  color: var(--color4);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── Record Button aktiv ─────────────────────────────────────────── */
#recordBtn.recording {
  background-color: rgb(255, 186, 179);
  color: rgb(170, 21, 21);
  border: 1px solid rgb(170, 21, 21);
}

/* ── Range Slider ────────────────────────────────────────────────── */
.range {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 10px;
  margin-top: 5px;
  margin-bottom: 5px;
  background: var(--color4);
  outline: none;
  border: none;
  cursor: pointer;
  overflow: visible;
}

/* Webkit (Chrome, Safari, Edge) */
/* ── Slider Thumb Zentrierung Safari ─────────────────────────────── */
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  background: var(--color4);
  cursor: pointer;
  border: none;
  margin-top: -1px;  
  border-radius: 50%;         /* ← Safari thumb sitzt zu tief */
}

.range::-webkit-slider-runnable-track {
  height: 10px;
  background: var(--color3);
  display: flex;              /* ← Safari braucht das für vertikale Zentrierung */
  align-items: center;
  
}

/* Firefox */
.range::-moz-range-thumb {
  width: 15px;
  height: 15px;
  background: var(--color4);
  cursor: pointer;
  border: none;
  -webkit-appearance : none;
}

.range::-moz-range-track {
  height: 10px;
  background: var(--color3);
}

/* IE / Edge Legacy */
.range::-ms-thumb {
  width: 15px;
  height: 15px;
  background: var(--color4);
  cursor: pointer;
  border: none;
}

.range::-ms-track {
  height: 10px;
  border-radius: 50%;
  background: var(--color3);
  border-color: transparent;
  color: transparent;
}

/* ── Color Input ─────────────────────────────────────────────────── */
#bgColor, #modellFarbe {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  border: var(--border);
  border-radius: var(--radius); /* statt none → verhindert oval */
  width: 100%;
  height: 25px;
  cursor: pointer;
  background: none;
  padding: 0;
  overflow: hidden; /* clipt den inneren Swatch */
}

/* iOS Safari: der Farbswatch selbst */
#bgColor::-webkit-color-swatch-wrapper,
#modellFarbe::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: var(--radius);
}

#bgColor::-webkit-color-swatch,
#modellFarbe::-webkit-color-swatch {
  border: none;
  border-radius: var(--radius);
}

/* Firefox */
#bgColor::-moz-color-swatch,
#modellFarbe::-moz-color-swatch {
  border: none;
  border-radius: var(--radius);
}


#blurWrapper { display: none; }

/* ── File Input ──────────────────────────────────────────────────── */
#fileInput {
  display: none;
}

/* ── Legal Modal ─────────────────────────────────────────────────── */
#legalModal {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  width: var(--ui-width);
  height: 100vh;
  background: var(--color1);
  z-index: 100;
  overflow-y: auto;
  padding: var(--font-size1);
  -webkit-box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

#helpModal {
  display: none;
  position: fixed;
  top: 0;
  right: var(--ui-width);
  width: var(--ui-width);
  height: 100vh;
  z-index: 100;
  background: var(--color2);
  border-right: var(--border);
  overflow-y: auto;
  padding: var(--font-size1);
  -webkit-box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
}

#helpModal.open{
  display: block;
}

#legalModal.open {
  display: block;
}


#legalClose, #helpClose {
  position: -webkit-sticky;
  position: sticky;
  top: 0;
  float: right;
  background: none;
  border: none;
  font-size: var(--font-size2);
  cursor: pointer;
}

#legalContent p {
  margin-bottom: var(--font-size3);
}
#helpContent p {
  margin-bottom: var(--font-size3);
}

#legalContent h3 {
  margin-bottom: var(--font-size3);
}
#helpContent h3 {
  margin-bottom: var(--font-size4);
}

#legalContent li {
  font-size: var(--font-size4);
  line-height: 0.9rem;
  font-weight: 100;
}
#helpContent li {
  font-size: var(--font-size4);
  line-height: 0.9rem;
  font-weight: 100;
}

#legalContent ul {
  margin-left: var(--font-size4);
}
#helpContent ul {
  margin-left: var(--font-size4);
}

#legalContent hr {
  border: 0;
  border-top:var(--border);
  margin: 2rem 0;
}

#helpContent hr {
  border: 0;
  border-top: var(--border);
  margin: var(--font-size3) 0;
}

/* ── Export Modal ────────────────────────────────────────────────── */
#exportModal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
}

#exportModal.open {
  display: -webkit-flex;
  display: flex;
}

#exportContent {
  background: var(--color1);
  border-radius: var(--radius);
  padding: var(--font-size1);
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 220px;
}

input:disabled {
  opacity: 0.2;
  cursor: not-allowed;
  pointer-events: none;
}




/* ── Thumbnails ────────────────────────────────────────────────── */

 
#thumbnailReihe {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 6px;
}

.thumb-wrap {
  position: relative;
  width: 58px;
  height: 58px;
  cursor: grab;
  border-radius: var(--radius);
  overflow: visible;
}

.thumb-wrap.dragging {
  opacity: 0.4;
}

.thumb-wrap img {
  width: 58px;
  height: 58px;
  object-fit: cover;
  border-radius: var(--radius);
  display: block;
}

.thumb-delete {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius);
  background: var(--color3);
  color: var(--color2);
  border: none;
  font-size: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.infowrapper{
  display: flex;
  justify-content: space-between;
  padding-inline: 10px;
}

/* ── Mobile ──────────────────────────────────────────────────────── */
@media (max-width: 768px) {


  #toggleBtn {
    -webkit-transition: right 0.26s ease;
    transition: right 0.26s ease;
  }

  .button{
    width: 49%;
  }

  .buttonbig {
    width: 100%;
  }
}

/* ── Safari only ─────────────────────────────────────────────────── */
@media (min-width: 769px) {
  @supports (-webkit-hyphens: none) {
    .button {
      padding-top: 3px;
      padding-bottom: 3px;
    }

    .range::-webkit-slider-thumb {
      margin-top: 0.5px;
    }

    .thumb-delete {
      position: absolute;
      top: -6px;
      right: -6px;
      width: 18px;
      height: 18px;
      border-radius: var(--radius);
      background: var(--color3);
      color: var(--color2);
      border: none;
      font-size: 13px;
      padding-bottom: 2px;
      line-height: 0.2;
    }
  }
}