:root {
  --hintergrund: #141d2b;
  --karte: #1e2a3c;
  --rahmen: #33415a;
  --text: #e6ebf2;
  --text-leise: #d1d8e2;
  --akzent: #5aa9ff;
  --border-radius: 5px;
}

* { box-sizing: border-box; }

* {
  scrollbar-width: thin;
  scrollbar-color: var(--rahmen) transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--hintergrund);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

.app {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  padding: 20px;
}

.buehne {
  flex: 1 1 0;
  min-width: 0;
}

.bild {
  position: relative;
  width: min(100%, calc((100vh - 40px) * 800 / 670));
}

#simulation {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  touch-action: none;
}

@media (max-width: 900px) {
  .app { flex-direction: column; align-items: stretch; padding: 12px; }
  .panel, .buehne { flex: none; }
}

.panel {
  flex: 0 0 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 10px;
  background: var(--karte);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.panel h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

#regler {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.steuerung {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px;
  background: var(--hintergrund);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
}

.steuerung label {
  font-weight: 500;
}

.regler-zeile {
  display: flex;
  align-items: center;
  gap: 12px;
}

.regler-spur {
  flex: 1;
  min-width: 0;
}

.zahl-feld {
  display: flex;
  flex: 0 0 auto;
  background: var(--karte);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
  overflow: hidden;
}

.zahl-feld:focus-within {
  border-color: var(--akzent);
}

.zahl-eingabe {
  box-sizing: content-box;
  padding: 6px 12px 6px 8px;
  background: transparent;
  color: var(--text);
  border: 0;
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
}

.stepper {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--rahmen);
}

.stepper button {
  flex: 1;
  width: 26px;
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-leise);
  border: 0;
  cursor: pointer;
}

.stepper button + button {
  border-top: 1px solid var(--rahmen);
}

.stepper button:hover {
  background: var(--rahmen);
  color: var(--text);
}

.stepper svg {
  width: 10px;
  height: 6px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* 9 px = halbe Daumenbreite, damit die Marken unter der Daumenmitte liegen */
.skala {
  position: relative;
  height: 30px;
  margin: 0 9px;
  color: var(--text-leise);
  font-size: 12px;
}

.marke {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.marke::before {
  content: '';
  display: block;
  width: 1px;
  height: 6px;
  margin: 0 auto 2px;
  background: var(--text-leise);
}

.marke.kurz::before {
  height: 3px;
  margin-bottom: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  margin: 8px 0px 0px 0px;
  border-radius: 3px;
  background: var(--rahmen);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--akzent);
  border: 3px solid var(--hintergrund);
  box-shadow: 0 0 0 1px var(--akzent);
}

input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--akzent);
  border: 3px solid var(--hintergrund);
  box-shadow: 0 0 0 1px var(--akzent);
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(90, 169, 255, 0.4);
}

input[type="range"]:focus-visible::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(90, 169, 255, 0.4);
}

.icon-leiste {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.icon-button {
  flex: 1 1 0;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--hintergrund);
  color: var(--text-leise);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: var(--text);
  border-color: var(--akzent);
  outline: none;
}

.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
}

.modal-stapel {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(340px, calc(100vw - 40px));
  pointer-events: none;
}

.modal {
  position: relative;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 40px);
  overflow: hidden;
  pointer-events: auto;
  padding: 12px 10px 16px 14px;
  background: var(--karte);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.modal h2 {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 600;
}

.modal-schliessen {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: var(--text-leise);
  border: 0;
  border-radius: var(--border-radius);
  cursor: pointer;
}

.modal-schliessen:hover {
  color: var(--text);
  background: var(--rahmen);
}

.modal-schliessen svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.modal-text {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--rahmen) transparent;
  color: var(--text-leise);
  font-size: 13px;
  padding-right: 6px;
}

.modal-text p {
  margin: 0 0 8px;
}

.modal-text p:last-child,
.modal-text ul:last-child {
  margin-bottom: 0;
}

.modal-text ul {
  margin: 0;
  padding-left: 18px;
}

.modal-text li + li {
  margin-top: 6px;
}

.modal-text strong {
  color: var(--text);
}

/* Formel in der Vorlage nicht als LaTeX, sondern mit Unicode und sub/sup */
.modal-text .formel {
  margin: 10px 0;
  padding: 6px 8px;
  text-align: center;
  color: var(--text);
  background: var(--hintergrund);
  border: 1px solid var(--rahmen);
  border-radius: var(--border-radius);
}

.modal-fortschritt {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--rahmen);
}

.modal-fortschritt span {
  display: block;
  height: 100%;
  background: var(--akzent);
  transform-origin: left center;
}
