/* Stencil-Font für Text-Masken (offene Punzen -> keine toten Bereiche) */
@font-face {
  font-family: "Black Ops One";
  src: url("lib/BlackOpsOne-Regular.ttf") format("truetype");
  font-display: block;
}

:root {
  --panel: #14140f;
  --panel-2: #1e1e18;
  --ink: #f4f1e8;
  --muted: #9a968a;
  --line: #33322b;
  --accent-a: rgb(50, 85, 164);   /* wird per JS auf Farbe A gesetzt */
  --accent-b: rgb(241, 80, 96);   /* wird per JS auf Farbe B gesetzt */
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #0c0c09;
  color: var(--ink);
}

#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Steuerpanel ---------- */
#controls {
  width: 320px;
  min-width: 320px;
  height: 100%;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: margin-left .22s ease;
}
body:not(.left-open) #controls { margin-left: -321px; }

.sub { margin: 10px 0 0; font-size: 11px; color: var(--muted); letter-spacing: 0.4px; }

#panel { padding: 20px 20px 20px; flex: 1; }

/* ---------- Reiter der linken Leiste ---------- */
#tabs {
  display: flex;
  flex: none;
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tab {
  flex: 1 1 0;
  min-width: 0;
  padding: 15px 4px 13px;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font: inherit;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.9px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.tab:hover { color: var(--ink); background: rgba(255,255,255,0.03); border-color: transparent; }
.tab.is-active { color: var(--ink); border-bottom-color: var(--accent-a); }

.pane { display: none; }
.pane.is-active { display: block; }

.group { margin-top: 18px; }
.group > .glabel {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
  margin: 0 0 8px;
}

/* Meta-Abschnitt (z.B. "Pilz" / "Umgebung") — selbes Design wie der App-Titel:
   Überschrift + zweifarbiger Balken darunter. Fasst mehrere .group zusammen. */
.mega { margin-top: 30px; padding-top: 22px; border-top: 1px solid var(--line); }
.mega:first-child { margin-top: 0; padding-top: 0; border-top: none; }
.mega > .megalabel {
  margin: 0;
  font-size: 17px;
  letter-spacing: 0.5px;
  color: var(--ink);
}
/* Der Farbbalken erscheint bewusst nur an EINER Stelle (unter "Farben") — */
/* per .barred-Klasse an-/abschaltbar, nicht automatisch bei jeder Mega-Überschrift. */
.mega > .megalabel.barred::after {
  content: "";
  display: block;
  width: 34px;
  height: 5px;
  margin-top: 9px;
  background: linear-gradient(90deg, var(--accent-a) 0 50%, var(--accent-b) 50% 100%);
}
.mega > .group:first-of-type { margin-top: 20px; }

.ctrl { margin: 12px 0; }
.ctrl label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  margin-bottom: 5px;
}
.ctrl label .val { color: var(--accent-b); font-variant-numeric: tabular-nums; }

/* ⓘ-Info-Icon neben jedem Regler */
.info {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px; height: 15px;
  margin-left: 6px;
  border-radius: 50%;
  border: 1px solid var(--muted);
  color: var(--muted);
  font-size: 10px;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  cursor: help;
  vertical-align: middle;
  transition: color .12s, border-color .12s;
  user-select: none;
}
.info:hover { color: var(--accent-a); border-color: var(--accent-a); }

/* Schwebender Tooltip (an body gehängt, wird nicht abgeschnitten) */
#tip {
  position: fixed;
  z-index: 9999;
  max-width: 250px;
  padding: 10px 12px;
  background: #0a0a07;
  color: var(--ink);
  border: 1px solid var(--accent-a);
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.45;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
  pointer-events: none;
  opacity: 0;
  transform: translateY(3px);
  transition: opacity .12s, transform .12s;
}
#tip.show { opacity: 1; transform: translateY(0); }

/* p5 Slider */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  background: var(--line);
  border-radius: 3px;
  outline: none;
  margin: 6px 0;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--ink);
  border: 2px solid var(--accent-a);
  cursor: pointer;
}

select, input[type="text"] {
  width: 100%;
  padding: 7px 8px;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
input[type="text"] { cursor: text; letter-spacing: 1px; }
input[type="text"]:focus { outline: none; border-color: var(--accent-a); }

.dropzone {
  border: 2px dashed var(--line);
  border-radius: 8px;
  padding: 16px 10px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  cursor: copy;
  transition: border-color .12s, color .12s, background .12s;
  line-height: 1.5;
}
.dropzone small { font-size: 10px; opacity: 0.7; }
.dropzone:hover { border-color: var(--accent-a); color: var(--ink); }
.dropzone.over {
  border-color: var(--accent-b);
  color: var(--ink);
  background: rgba(255,255,255,0.04);
}

/* Auswahl als Symbolleiste (Ursprung / Maskenart) — eine oder zwei Zeilen */
.iconbar { display: grid; gap: 6px; margin-top: 2px; }
.iconbtn {
  flex: none;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 0;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  cursor: pointer;
  transition: color .12s, border-color .12s, background .12s;
}
.iconbtn svg {
  display: block;
  width: 19px; height: 19px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.iconbtn:hover { color: var(--ink); border-color: var(--accent-a); }
.iconbtn.is-active {
  color: #fff;
  background: var(--accent-a);
  border-color: var(--accent-a);
}

.swatches { display: flex; gap: 10px; flex-wrap: nowrap; }
.swatches .ctrl { flex: 1 1 0; min-width: 0; }
.swatches .ctrl label { white-space: nowrap; }
.chip {
  display: inline-block; width: 11px; height: 11px;
  border-radius: 3px; vertical-align: middle; margin-right: 6px;
  border: 1px solid rgba(255,255,255,0.15);
}

.btnrow { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
button.wide { flex: 1 1 100%; min-width: 0; }
.btnrow button.wide + .info { flex: none; margin-left: 0; }
.btnrow:has(> button.wide + .info) > button.wide { flex: 1 1 0; }

/* Fuß jeder Reiter-Ansicht: „Diese Ansicht zurücksetzen“ */
.panefoot {
  margin-top: 28px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.panefoot button { width: 100%; font-size: 11px; color: var(--muted); }
.panefoot button:hover { color: var(--ink); }
button {
  flex: 1;
  min-width: 90px;
  padding: 10px 8px;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 7px;
  font: inherit; font-size: 12px;
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
button:hover { border-color: var(--accent-a); }
button.primary {
  background: var(--accent-a);
  border-color: var(--accent-a);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { filter: brightness(1.1); }

#controls footer {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
}
.hint { margin: 0; font-size: 11px; color: var(--muted); line-height: 1.5; }

/* ---------- Rechtes Panel (Format & Export, einklappbar) ---------- */
#controls-right {
  width: 320px;
  min-width: 320px;
  height: 100%;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transition: margin-right .22s ease;
}
body:not(.right-open) #controls-right { margin-right: -321px; }

#controls-right header {
  padding: 22px 20px 16px;
  border-bottom: 1px solid var(--line);
}
#controls-right h1 { margin: 0; font-size: 20px; letter-spacing: 0.5px; line-height: 1; }
#panel-right { padding: 8px 20px 24px; }

/* ---------- Bühne: dünne Titelleiste oben + Canvas darunter ---------- */
#stage {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Anfasser an den Innenkanten der Bühne: Klick klappt die Leiste ein/aus.
   Ist die Leiste eingeklappt, bleibt der Griff am Bildschirmrand sichtbar. */
.edge {
  position: absolute;
  top: 0; bottom: 0;
  width: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  transition: background .15s;
}
.edge-left { left: 0; }
.edge-right { right: 0; }
.edge:hover { background: rgba(255,255,255,0.05); }
.edge .grip {
  width: 4px;
  height: 44px;
  border-radius: 3px;
  background: var(--line);
  transition: background .15s, height .15s;
}
.edge:hover .grip,
body:not(.left-open) .edge-left .grip,
body:not(.right-open) .edge-right .grip {
  height: 72px;
  background: linear-gradient(180deg, var(--accent-a), var(--accent-b));
}
/* Eingeklappt = deutlicher „Reinholen“-Griff am Rand */
body:not(.left-open) .edge-left,
body:not(.right-open) .edge-right { background: rgba(255,255,255,0.04); }

/* Mauszeiger zeigt, wohin die Leiste wandert */
body.left-open .edge-left { cursor: w-resize; }
body:not(.left-open) .edge-left { cursor: e-resize; }
body.right-open .edge-right { cursor: e-resize; }
body:not(.right-open) .edge-right { cursor: w-resize; }

#topbar {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  height: 50px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
#topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
#topbar h1 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
#topbar .titlebar {
  flex: none;
  width: 32px;
  height: 5px;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--accent-a) 0 50%, var(--accent-b) 50% 100%);
}
/* Aktionen sitzen mittig in der Leiste (mittlere Grid-Spalte) */
#topbar-actions { display: flex; gap: 8px; }
#topbar-actions button {
  flex: none;
  min-width: 0;
  padding: 7px 14px;
  font-size: 11px;
}
/* Tempo-Regler kompakt am rechten Ende der Leiste */
#topbar-speed {
  justify-self: end;
  display: flex;
  align-items: center;
  min-width: 0;
  width: 200px;
}
#topbar-speed .ctrl {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
#topbar-speed .ctrl label {
  flex: none;
  margin: 0;
  gap: 6px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}
#topbar-speed input[type="range"] { flex: 1 1 0; min-width: 0; margin: 0; }

#canvas-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow: hidden;
}
#canvas-wrap canvas {
  box-shadow: 0 12px 48px rgba(0,0,0,0.5);
  border-radius: 2px;
  max-height: 100%;
  max-width: 100%;
}
#canvas-wrap canvas.dragging {
  outline: 3px dashed var(--accent-a);
  outline-offset: -3px;
}
