/* =============================================================
   Grid Shift – im selben Stil wie die Kurs-Collection:
   weißer Grund, Systemschrift, graue Pillen, schwarze Akzente.
   ============================================================= */

/* Farben und Schrift an einer Stelle */
:root {
  --page: #ffffff;
  --ink: #1d1d1f;
  --muted: #86868b;
  --pill: rgb(236 236 238 / 0.82);
  --field: #f2f2f4;
  --danger: #d70015;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--page);
  background: rgb(244 244 242);;
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
}

button {
  font: inherit;
  color: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid #0a84ff;
  outline-offset: 2px;
}

/* ---------- Pillen (Grundform wie in der Collection) ---------- */

.pill {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 40px;
  padding: 4px;
  background: var(--pill);
  border-radius: 999px;
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
}

.title-pill {
  gap: 10px;
  align-self: flex-start;
  padding: 4px 18px;
  font-size: 15px;
}

.title-pill span {
  color: var(--muted);
}

/* ---------- Linkes Panel ---------- */

#panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 300px;
  flex-shrink: 0;
  padding: 16px 20px 24px;
  overflow-y: auto;
      border-radius: 16px;
    margin: 16px;
    background-color: #ffffff;
    box-shadow: 0 12px 18px rgba(0, 0, 0, 0.2);
}

/* Ist das Panel höher als das Fenster, wird gescrollt statt gequetscht */
#panel > * {
  flex-shrink: 0;
}

#text {
  width: 100%;
  height: 96px;
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  border: none;
  border-radius: 14px;
  background: var(--field);
  resize: vertical;
}

/* ---------- Umschalter (Word/Sentence, Text/Image) ---------- */

.toggle button {
  flex: 1;
  height: 32px;
  border: none;
  border-radius: 999px;
  background: none;
  color: #555;
  cursor: pointer;
}

.toggle button:hover {
  color: var(--ink);
}

.toggle button.active {
  background: var(--ink);
  color: #fff;
}

/* ---------- Slider ---------- */

.sliders {
  display: flex;
  flex-direction: column;
  margin-top: 4px;
}

.sliders label {
  display: flex;
  justify-content: space-between;
  margin-top: 12px;
  font-size: 13px;
}

.sliders label span {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* Beschriftung ist klickbar (setzt auf 0, siehe sketch.js) */
.sliders label {
  cursor: pointer;
  user-select: none;
}

.sliders label:hover span {
  color: var(--ink);
}

/* Schwarze Spur links vom Knopf, graue rechts, weißer Pillen-Knopf.
   Wie weit schwarz geht, setzt sketch.js über --fill. */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  margin: 4px 0 0;
  background: transparent;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--ink) var(--fill, 50%), rgb(0 0 0 / 0.15) var(--fill, 50%));
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 2px;
  background: rgb(0 0 0 / 0.15);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 2px;
  background: var(--ink);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 28px;
  height: 18px;
  margin-top: -7px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.3);
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 18px;
  border: none;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 4px rgb(0 0 0 / 0.3);
}

/* ---------- Buttons ---------- */

.pill-button {
  height: 40px;
  border: none;
  border-radius: 999px;
  background: var(--pill);
  cursor: pointer;
}

.pill-button:hover {
  background: #e2e2e5;
}

.text-button {
  align-self: flex-start;
  padding: 6px 0;
  font-size: 13px;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
}

.text-button:hover {
  color: var(--ink);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 999px;
  cursor: pointer;
}

.icon-button:hover {
  background: rgb(0 0 0 / 0.06);
}

/* aktiv, z. B. wenn das Formelfeld offen ist */
.icon-button[aria-expanded="true"] {
  color: #fff;
  background: var(--ink);
}

/* Pause-Button: zeigt Pause oder Play, je nach Zustand */
.icon-play,
#pause.is-paused .icon-pause {
  display: none;
}

#pause.is-paused .icon-play {
  display: block;
}

.hint {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

kbd {
  padding: 1px 6px;
  font-family: var(--font);
  font-size: 11px;
  color: var(--ink);
  background: var(--field);
  border-radius: 6px;
}

/* ---------- Kurs-Collection ---------- */

.share-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  background: var(--field);
  border-radius: 16px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

.check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--ink);
}

#author,
#course-key {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  font: inherit;
  border: none;
  border-radius: 10px;
  background: #fff;
}

/* ---------- Zeichenfläche ---------- */

#canvas-holder {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

#canvas-holder canvas {
  display: block;
}

/* Schwebende Leiste unten rechts */
.dock {
  position: absolute;
  right: 20px;
  bottom: 20px;
  z-index: 2;
  gap: 2px;
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.08);
}

.divider {
  width: 1px;
  height: 20px;
  margin: 0 6px;
  background: rgb(0 0 0 / 0.12);
}

.segment {
  height: 32px;
  padding: 0 13px;
  border: none;
  border-radius: 999px;
  background: none;
  color: #555;
  cursor: pointer;
}

.segment:hover {
  color: #fff;
  background: var(--ink);
}

/* Meldungen als kleine Pille über der Leiste – leer = unsichtbar */
.status {
  position: absolute;
  right: 20px;
  bottom: 72px;
  z-index: 2;
  max-width: calc(100% - 40px);
  margin: 0;
  padding: 4px 16px;
  font-size: 13px;
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.08);
}

.status:empty {
  display: none;
}

/* ---------- Formelfeld ---------- */

.formula-panel {
  position: absolute;
  left: 20px;
  right: 20px;
  top: 20px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 760px;
  margin: 0 auto;
  padding: 10px;
  background: var(--pill);
  border-radius: 20px;
  box-shadow: 0 4px 24px rgb(0 0 0 / 0.08);
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
}

.formula-panel[hidden] {
  display: none;
}

.formula-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.formula-row label {
  flex-shrink: 0;
  padding-left: 8px;
  white-space: nowrap;
  font-family: var(--mono);
  color: var(--muted);
}

.formula-row input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 14px;
  font-family: var(--mono);
  font-size: 14px;
  border: 2px solid transparent;
  border-radius: 12px;
  background: #fff;
}

/* Fehler in der Formel: roter Rand */
.formula-row input.invalid {
  border-color: var(--danger);
}

.formula-error {
  margin: 0;
  padding: 0 8px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--danger);
}

.formula-error:empty {
  display: none;
}

.formula-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 8px 0;
}

.formula-help {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

.formula-help code {
  font-family: var(--mono);
  color: var(--ink);
}

.formula-footer .text-button {
  flex-shrink: 0;
  padding: 0;
}

/* ---------- Schmale Bildschirme: Panel oben, Bild darunter ---------- */

@media (max-width: 700px) {
  body {
    flex-direction: column;
  }

  #panel {
    width: 100%;
    max-height: 45vh;
    padding: 12px 16px;
  }

  .dock {
    right: 12px;
    bottom: 12px;
  }

  .status {
    right: 12px;
    bottom: 64px;
  }

  .formula-panel {
    left: 12px;
    right: 12px;
    top: 12px;
  }
}
