.zt-app {
  margin: 6px 0 22px;
  padding-top: 18px;
  border-top: 1px solid #d2d9e3;
  -webkit-user-select: none;
  user-select: none;
}

/* ---------- obere Aktionsleiste ---------- */

.zt-actionbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid #d7dee8;
  border-radius: 11px 11px 0 0;
  background: #f0f3f6;
}

.zt-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zt-group + .zt-group {
  padding-left: 12px;
  border-left: 1px solid #d0d8e4;
}

.zt-group-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #7c8aa0;
  margin-right: 2px;
}

.zt-spacer {
  flex: 1 1 auto;
}

/* ---------- Arbeitsbereich: links Werkzeuge, Mitte Blatt, rechts Ebenen ---------- */

.zt-workspace {
  display: grid;
  grid-template-columns: 138px minmax(0, 1fr) 196px;
  /* Zweite Zeile: der Kasten unter der Zeichenflaeche. Die Seitenspalten
     laufen ueber beide Zeilen durch. */
  grid-template-rows: auto auto;
  border: 1px solid #d7dee8;
  border-top: 0;
  border-radius: 0 0 11px 11px;
  overflow: hidden;
}

.zt-side,
.zt-layers {
  background: #f7f9fb;
  padding: 12px 10px;
}

.zt-side {
  border-right: 1px solid #d7dee8;
}

.zt-layers {
  border-left: 1px solid #d7dee8;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.zt-panel-title {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #7c8aa0;
}

.zt-panel + .zt-panel {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #dde3ec;
}

/* ---------- Werkzeuge ---------- */

.zt-tool-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.zt-tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 36px;
  padding: 0;
  border: 1px solid #c7cfdb;
  border-radius: 9px;
  background: #ffffff;
  color: #314663;
  cursor: pointer;
}

.zt-tool-btn svg {
  width: 18px;
  height: 18px;
  display: block;
  pointer-events: none;
}

.zt-tool-btn:hover {
  border-color: #99a6b8;
}

.zt-tool-btn[aria-pressed="true"] {
  background: #C02318;
  border-color: #C02318;
  color: #ffffff;
}

.zt-tool-btn:focus-visible,
.zt-swatch:focus-visible,
.zt-action-btn:focus-visible,
.zt-text-input:focus-visible,
.zt-range:focus-visible,
.zt-color-input:focus-visible,
.zt-select:focus-visible,
.zt-layer-name:focus-visible,
.zt-layer-eye:focus-visible,
.zt-mini-btn:focus-visible {
  outline: 2px solid rgba(192, 35, 24, 0.35);
  outline-offset: 1px;
}

/* ---------- Farben ---------- */

.zt-swatches {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  margin-bottom: 8px;
}

.zt-swatch {
  width: 100%;
  height: 22px;
  padding: 0;
  border: 1px solid rgba(36, 50, 75, 0.25);
  border-radius: 6px;
  cursor: pointer;
}

.zt-swatch[aria-pressed="true"] {
  box-shadow: 0 0 0 2px #f7f9fb, 0 0 0 4px #24324b;
}

.zt-color-input {
  width: 100%;
  height: 28px;
  padding: 0;
  border: 1px solid #c7cfdb;
  border-radius: 6px;
  background: #ffffff;
  cursor: pointer;
}

/* ---------- Strichstärke ---------- */

.zt-range {
  width: 100%;
  accent-color: #C02318;
  cursor: pointer;
}

.zt-size-value {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #314663;
  font-variant-numeric: tabular-nums;
}

/* ---------- Textfeld ---------- */

.zt-text-input {
  width: 100%;
  height: 32px;
  padding: 0 9px;
  border: 1px solid #c7cfdb;
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-size: 0.84rem;
}

.zt-text-input[hidden] {
  display: none;
}

/* ---------- Schaltflächen ---------- */

.zt-action-btn {
  height: 34px;
  padding: 0 13px;
  border: 1px solid #c7cfdb;
  border-radius: 999px;
  background: #ffffff;
  color: #314663;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.zt-action-btn:hover:not(:disabled) {
  background: #e7ecf2;
}

.zt-action-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.zt-action-btn.is-primary {
  border-color: #C02318;
  color: #C02318;
}

.zt-action-btn.is-primary:hover:not(:disabled) {
  background: rgba(192, 35, 24, 0.08);
}

.zt-zoom-group {
  gap: 2px;
}

.zt-zoom-btn {
  width: 34px;
  padding: 0;
  font-size: 1rem;
  line-height: 1;
}

.zt-zoom-level {
  min-width: 56px;
  padding: 0 8px;
  font-variant-numeric: tabular-nums;
}

.zt-select {
  height: 34px;
  padding: 0 6px;
  border: 1px solid #c7cfdb;
  border-radius: 8px;
  background: #ffffff;
  color: #314663;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.zt-select:disabled {
  opacity: 0.4;
  cursor: default;
}

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

/* Die Bühne ist der Tisch, die Leinwand das Blatt darauf. Der Tisch ist
   einfarbig und etwas dunkler - so ist auf einen Blick zu sehen, wo das
   Blatt aufhört. Beim Herauszoomen wird der Tisch ringsum sichtbar. */
.zt-stage {
  position: relative;
  background: #e2e7ee;
  /* Die Bühne behält bei jeder Zoomstufe dieselbe Höhe - sie ergibt sich aus
     ihrer eigenen Breite (Grid-Spalte), nicht aus der aktuellen Grösse des
     Canvas darin. Ohne das würde die Fläche beim Hineinzoomen den ganzen
     Bereich darunter (Ebenen, Seite) mit nach unten schieben.
     Muss zu WIDTH/HEIGHT in zeichentool.js passen. */
  aspect-ratio: 2400 / 1500;
  /* auto statt hidden: bei Zoom > 100% wächst die Zeichenfläche über die
     Bühne hinaus, dann übernimmt das Scrollen das Verschieben des
     Ausschnitts. Bei 100% ändert sich optisch nichts. */
  overflow: auto;
}

/* Das Karomuster sitzt jetzt auf der Leinwand selbst und nicht mehr auf der
   Bühne dahinter: Karos bedeuten damit "hier kann gezeichnet werden". */
.zt-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
  background:
    linear-gradient(45deg, #eef1f5 25%, transparent 25%, transparent 75%, #eef1f5 75%),
    linear-gradient(45deg, #eef1f5 25%, #ffffff 25%, #ffffff 75%, #eef1f5 75%);
  background-size: 18px 18px;
  background-position: 0 0, 9px 9px;
  /* Die Kontur liegt bewusst INNEN (negativer Versatz): bei 100 % füllt das
     Blatt die Bühne genau aus, ein aussen liegender Rahmen würde vom
     overflow der Bühne abgeschnitten und wäre unsichtbar. So bleibt die
     Grenze bei jeder Zoomstufe erkennbar. */
  outline: 1px solid #9aabc0;
  outline-offset: -1px;
}

.zt-canvas.is-text {
  cursor: text;
}

/* Mit gedrückter mittlerer Taste wird der Ausschnitt verschoben - der
   Greifzeiger gilt dann vor allen werkzeugabhängigen Zeigern. */
.zt-canvas.is-panning,
.zt-canvas.is-panning.is-text,
.zt-canvas.is-panning.is-move {
  cursor: grabbing;
}

/* Vorschau aufs Ausschneiden: liegt deckungsgleich über der Zeichenfläche
   und im selben gescrollten Inhalt, damit sie beim Zoomen mitgeht. */
.zt-preview-layer {
  position: absolute;
  pointer-events: none;
  z-index: 2;
}

/* Während der Vorschau tritt der Auswahlrahmen zurück - sonst konkurrieren
   zwei rote Markierungen um dieselbe Aufmerksamkeit. */
.zt-select-box.is-muted {
  opacity: 0.15;
}

/* ---------- Rechtsklick-Menü ---------- */

.zt-context-menu {
  position: fixed;
  z-index: 60;
  min-width: 232px;
  padding: 5px;
  border: 1px solid #d7dee8;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(36, 50, 75, 0.20);
}

.zt-context-item {
  display: flex;
  align-items: center;
  gap: 18px;
  width: 100%;
  padding: 6px 9px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #24324b;
  font: inherit;
  font-size: 0.8rem;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.zt-context-item span {
  margin-left: auto;
  color: #9aabc0;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.zt-context-item:hover:not(:disabled),
.zt-context-item:focus-visible {
  background: rgba(192, 35, 24, 0.08);
  color: #C02318;
  outline: none;
}

.zt-context-item:hover:not(:disabled) span {
  color: #C02318;
}

.zt-context-item:disabled {
  opacity: 0.35;
  cursor: default;
}

.zt-context-sep {
  height: 1px;
  margin: 4px 7px;
  background: #e4e9f0;
}

/* ---------- Ebenen ---------- */

.zt-layer-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column-reverse;
  gap: 5px;
}

.zt-layer {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 5px;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #ffffff;
}

.zt-layer.is-active {
  border-color: #C02318;
  box-shadow: inset 3px 0 0 #C02318;
}

.zt-layer.is-hidden .zt-layer-name {
  opacity: 0.45;
  text-decoration: line-through;
}

.zt-layer-eye {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #52627d;
  cursor: pointer;
}

.zt-layer-eye svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.zt-layer-name {
  flex: 1 1 auto;
  min-width: 0;
  padding: 2px 4px;
  border: 0;
  background: transparent;
  color: #24324b;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zt-layer-count {
  flex: 0 0 auto;
  font-size: 0.68rem;
  color: #8ea0b6;
  font-variant-numeric: tabular-nums;
}

.zt-layer-actions {
  display: flex;
  gap: 4px;
  margin-top: 2px;
}

.zt-mini-btn {
  flex: 1 1 auto;
  height: 28px;
  padding: 0 6px;
  border: 1px solid #c7cfdb;
  border-radius: 7px;
  background: #ffffff;
  color: #314663;
  font: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
}

.zt-mini-btn:hover:not(:disabled) {
  background: #e7ecf2;
}

.zt-mini-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* ---------- Statuszeile ---------- */

.zt-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}

.zt-hint {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.zt-meta {
  margin: 0;
  font-size: 0.78rem;
  color: #7c8aa0;
  font-variant-numeric: tabular-nums;
}

/* ---------- Tastenkürzel-Liste ---------- */

.zt-keys {
  display: grid;
  grid-template-columns: minmax(120px, max-content) 1fr;
  gap: 6px 16px;
  margin: 10px 0 18px;
  align-items: baseline;
}

.zt-keys dt {
  margin: 0;
  white-space: nowrap;
}

.zt-keys dd {
  margin: 0;
  color: var(--muted);
}

.zt-keys kbd {
  display: inline-block;
  min-width: 1.5em;
  padding: 2px 6px;
  border: 1px solid #c7cfdb;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #ffffff;
  color: #24324b;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
}

/* ---------- schmale Bildschirme ---------- */

@media (max-width: 900px) {
  .zt-workspace {
    grid-template-columns: 1fr;
  }

  .zt-side {
    border-right: 0;
    border-bottom: 1px solid #d7dee8;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
  }

  .zt-panel + .zt-panel {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
  }

  .zt-layers {
    border-left: 0;
    border-top: 1px solid #d7dee8;
  }

  .zt-layer-list {
    flex-direction: column-reverse;
  }

  .zt-keys {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .zt-keys dd {
    margin-bottom: 8px;
  }
}

@media (max-width: 620px) {
  .zt-actionbar {
    gap: 8px;
    padding: 9px 10px;
  }

  .zt-group + .zt-group {
    padding-left: 8px;
  }

  .zt-group-label {
    display: none;
  }

  .zt-spacer {
    display: none;
  }
}

/* ---------- Objektliste je Ebene ---------- */

/* Die Objektzahl ist jetzt ein Schalter, der die Liste auf- und zuklappt. */
.zt-layer-count {
  flex: 0 0 auto;
  min-width: 20px;
  padding: 1px 5px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  font: inherit;
  font-size: 0.68rem;
  color: #8ea0b6;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.zt-layer-count:hover,
.zt-layer-count:focus-visible {
  color: #24324b;
  border-color: #d7dee8;
  background: #ffffff;
}

.zt-layer-count.is-open {
  color: #C02318;
  border-color: rgba(192, 35, 24, 0.35);
  background: rgba(192, 35, 24, 0.05);
}

.zt-object-wrap {
  margin: -2px 0 2px 8px;
  padding: 4px 0 4px 8px;
  border-left: 1px solid #d7dee8;
}

.zt-object-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 190px;
  overflow-y: auto;
}

.zt-object {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 4px 3px 6px;
  border-radius: 6px;
  border-left: 3px solid transparent;
  font-size: 0.72rem;
  color: #4a5c74;
}

/* Randfarbe kommt inline aus groupHue() - dieselbe Gruppe teilt denselben Ton. */
.zt-object.is-grouped {
  background: rgba(31, 95, 168, 0.05);
}

/* pan-y statt none: die Objektliste muss auf dem Touchgerät scrollbar
   bleiben. Das Ziehen auf eine andere Ebene ist damit Maus und Stift
   vorbehalten. */
.zt-object {
  cursor: grab;
  touch-action: pan-y;
}

.zt-object:hover {
  background: #ffffff;
}

/* Zeile, die gerade auf eine andere Ebene gezogen wird. */
.zt-object.is-dragging {
  opacity: 0.4;
  cursor: grabbing;
}

/* Ebene (oder ihre Objektliste), auf der die Zeile landen würde. */
.zt-layer.is-drop,
.zt-object-wrap.is-drop {
  border-color: #C02318;
  background: rgba(192, 35, 24, 0.07);
}

.zt-object-wrap.is-drop {
  border-left-color: #C02318;
}

/* Der Zettel, der am Zeiger hängt und sagt, was gerade wandert. */
.zt-drag-badge {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  padding: 3px 8px;
  border: 1px solid #C02318;
  border-radius: 7px;
  background: #ffffff;
  color: #C02318;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(36, 50, 75, 0.18);
}

/* Was auf der Fläche gewählt ist, wird hier mitmarkiert. Der linke Rand
   gehört der Gruppenfarbe, darum ein eigener Ring statt eines Balkens. */
.zt-object.is-selected {
  background: rgba(192, 35, 24, 0.07);
  box-shadow: inset 0 0 0 1px rgba(192, 35, 24, 0.4);
}

.zt-object.is-selected:hover {
  background: rgba(192, 35, 24, 0.1);
}

.zt-object.is-selected .zt-object-label {
  color: #C02318;
  font-weight: 600;
}

.zt-object.is-selected .zt-object-nr {
  color: rgba(192, 35, 24, 0.65);
}

/* Die Ebene, auf der die Auswahl liegt. Der kräftige rote Rahmen bleibt der
   aktiven Ebene vorbehalten - hier nur derselbe Balken in leiser. */
.zt-layer.has-selection:not(.is-active) {
  background: rgba(192, 35, 24, 0.04);
  box-shadow: inset 3px 0 0 rgba(192, 35, 24, 0.35);
}

.zt-object-dot {
  flex: 0 0 auto;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid rgba(36, 50, 75, 0.18);
  background: #ffffff;
}

/* Radierer und Bild tragen keine Strichfarbe, darum ein eigenes Zeichen. */
.zt-object-dot.is-eraser {
  background: repeating-linear-gradient(45deg, #ffffff 0 2px, #c8d2df 2px 4px);
}

.zt-object-dot.is-image {
  border-radius: 2px;
  background: linear-gradient(135deg, #dbe6f3 0%, #b9cbe0 100%);
}

.zt-object-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.zt-object-nr {
  flex: 0 0 auto;
  font-size: 0.66rem;
  color: #9aabc0;
  font-variant-numeric: tabular-nums;
}

.zt-object-del {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #9aabc0;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.zt-object:hover .zt-object-del,
.zt-object-del:focus-visible {
  opacity: 1;
}

.zt-object-del:hover,
.zt-object-del:focus-visible {
  background: rgba(192, 35, 24, 0.08);
  color: #C02318;
}

.zt-object-empty {
  margin: 0;
  padding: 2px 4px;
  font-size: 0.7rem;
  color: #9aabc0;
}

/* Zeichenfläche hebt sich ab, während eine Bilddatei darüber schwebt. */
.zt-canvas.is-drop {
  outline: 2px dashed rgba(192, 35, 24, 0.55);
  outline-offset: -4px;
}

/* ---------- Objekte verschieben ---------- */

/* Der Auswahlrahmen liegt als eigenes Element ueber der Flaeche - dadurch
   erscheint er weder im PNG-Export noch im aufgenommenen Video. */
.zt-select-box {
  position: absolute;
  pointer-events: none;
  border: 1px solid #C02318;
  border-radius: 3px;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75), 0 0 0 3px rgba(192, 35, 24, 0.14);
  z-index: 5;
}

/* Eine ganze Gruppe (statt einer spontanen Mehrfachauswahl) bekommt eine
   gestrichelte Kontur plus Schildchen - auf einen Blick unterscheidbar.
   --group-color(-soft) kommt aus groupHue() in JS und ist derselbe Ton wie
   der Rand dieser Gruppe in der Ebenenliste. */
.zt-select-box.is-group {
  border-style: dashed;
  border-color: var(--group-color, #C02318);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75), 0 0 0 3px var(--group-color-soft, rgba(192, 35, 24, 0.14));
}

.zt-select-box.is-group .zt-select-handle {
  border-color: var(--group-color, #C02318);
}

.zt-select-group-badge {
  position: absolute;
  left: -1px;
  top: -20px;
  padding: 1px 6px;
  border-radius: 4px 4px 0 0;
  background: var(--group-color-badge, #C02318);
  color: #ffffff;
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
  pointer-events: none;
}

.zt-canvas.is-move { cursor: default; }
.zt-canvas.is-move.is-grab { cursor: grab; }
.zt-canvas.is-move.is-grabbing { cursor: grabbing; }

/* Griffe an den Ecken des Auswahlrahmens zum Vergroessern und Verkleinern.
   Der Rahmen selbst laesst Klicks durch, die Griffe fangen sie ab. */
.zt-select-handle {
  position: absolute;
  width: 11px;
  height: 11px;
  background: #ffffff;
  border: 1px solid #C02318;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(28, 46, 72, 0.25);
  pointer-events: auto;
  touch-action: none;
}

.zt-select-handle:hover,
.zt-select-handle:focus-visible {
  background: #C02318;
}

.zt-select-handle.is-nw { left: -6px; top: -6px; cursor: nwse-resize; }
.zt-select-handle.is-ne { right: -6px; top: -6px; cursor: nesw-resize; }
.zt-select-handle.is-sw { left: -6px; bottom: -6px; cursor: nesw-resize; }
.zt-select-handle.is-se { right: -6px; bottom: -6px; cursor: nwse-resize; }

@media (pointer: coarse) {
  .zt-select-handle { width: 15px; height: 15px; }
  .zt-select-handle.is-nw { left: -8px; top: -8px; }
  .zt-select-handle.is-ne { right: -8px; top: -8px; }
  .zt-select-handle.is-sw { left: -8px; bottom: -8px; }
  .zt-select-handle.is-se { right: -8px; bottom: -8px; }
}

/* ---------- Punkte bearbeiten (Doppelklick) ----------
   Eigene Ebene über der Fläche, ein Griff pro Stützpunkt. Blau statt Rot,
   damit sich "einzelne Punkte ziehen" klar von "ganze Form skalieren"
   unterscheidet. */
.zt-vertex-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 6;
}

.zt-vertex-handle {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #1f5fa8;
  box-shadow: 0 1px 2px rgba(28, 46, 72, 0.3);
  cursor: move;
  pointer-events: auto;
  touch-action: none;
}

.zt-vertex-handle:hover,
.zt-vertex-handle:active {
  background: #1f5fa8;
}

@media (pointer: coarse) {
  .zt-vertex-handle {
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
  }
}

/* Rahmen zeigt an, dass der Magnet greift und das Verhaeltnis gehalten wird. */
.zt-select-box.is-snapped {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.75), 0 0 0 4px rgba(192, 35, 24, 0.3);
}

.zt-select-box.is-snapped .zt-select-handle {
  background: #C02318;
}

/* ---------- Drehgriff ---------- */

.zt-select-rotate {
  position: absolute;
  left: 50%;
  top: -26px;
  width: 13px;
  height: 13px;
  margin-left: -6.5px;
  border: 1px solid #C02318;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(28, 46, 72, 0.25);
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
}

.zt-select-rotate::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 12px;
  width: 1px;
  height: 13px;
  margin-left: -0.5px;
  background: #C02318;
}

.zt-select-rotate:hover { background: #C02318; }
.zt-select-rotate:active { cursor: grabbing; }

@media (pointer: coarse) {
  .zt-select-rotate { width: 17px; height: 17px; margin-left: -8.5px; top: -32px; }
  .zt-select-rotate::before { top: 16px; height: 16px; }
}

/* ---------- Vollbild ---------- */

/* Im Vollbild fuellt der Arbeitsbereich den Schirm: die Flaeche waechst mit,
   Werkzeuge und Ebenen bleiben daneben stehen. */
.zt-app.is-fullscreen {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  padding: 10px;
  background: #ffffff;
  border-radius: 0;
}

.zt-app.is-fullscreen .zt-workspace {
  flex: 1 1 auto;
  min-height: 0;
}

.zt-app.is-fullscreen .zt-stage {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Die Flaeche behaelt ihr Seitenverhaeltnis und passt sich in die Hoehe ein.
   object-fit greift bei einem Canvas nicht aufs Layout, darum max-width/height. */
.zt-app.is-fullscreen .zt-canvas {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
}

.zt-app.is-fullscreen .zt-side,
.zt-app.is-fullscreen .zt-layers {
  overflow-y: auto;
}

/* Umschalter: wirkt die Farbe auf die Linie oder auf die Flaeche?
   Der Punkt davor zeigt jeweils die Farbe, die dort gerade gilt. */
.zt-target-switch {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 8px;
}

.zt-target-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #ffffff;
  font: inherit;
  font-size: 0.75rem;
  color: #4a5c74;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.zt-target-btn:hover { border-color: #99a6b8; }

.zt-target-dot {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  border: 1px solid rgba(36, 50, 75, 0.28);
  background: #24324b;
}

/* Keine Fuellung: durchgestrichener Kreis */
.zt-target-dot.is-empty::after {
  background: linear-gradient(to bottom right,
    transparent calc(50% - 1px), rgba(192, 35, 24, 0.8) calc(50% - 1px),
    rgba(192, 35, 24, 0.8) calc(50% + 1px), transparent calc(50% + 1px));
}

.zt-target-label { flex: 1 1 auto; }

.zt-target-btn.is-on {
  border-color: #C02318;
  background: rgba(192, 35, 24, 0.06);
  color: #C02318;
  font-weight: 700;
}

.zt-fill-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 5px 8px;
  border: 1px solid #d7dee8;
  border-radius: 7px;
  background: #ffffff;
  font: inherit;
  font-size: 0.72rem;
  color: #4a5c74;
  cursor: pointer;
}

.zt-fill-btn:hover:not(:disabled) { border-color: #C02318; color: #24324b; }

.zt-fill-btn:disabled { opacity: 0.4; cursor: default; }

/* Aufgezogener Auswahlrahmen fuer mehrere Objekte */
.zt-marquee {
  position: absolute;
  pointer-events: none;
  border: 1px solid #C02318;
  background: rgba(192, 35, 24, 0.07);
  border-radius: 2px;
  z-index: 6;
}

/* ---------- Speichern: Diskette mit Formatliste ---------- */

.zt-save {
  position: relative;
}

.zt-save-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.zt-save-btn svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}

.zt-save-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 210px;
  padding: 5px;
  border: 1px solid #d7dee8;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(28, 46, 72, 0.16);
  z-index: 20;
}

.zt-save-menu[hidden] { display: none; }

.zt-save-item {
  display: block;
  width: 100%;
  padding: 7px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  font: inherit;
  font-size: 0.8rem;
  color: #314663;
  text-align: left;
  cursor: pointer;
}

.zt-save-item:hover,
.zt-save-item:focus-visible {
  background: rgba(192, 35, 24, 0.07);
  color: #C02318;
}

.zt-save-sep {
  height: 1px;
  margin: 4px 8px;
  background: #e3e8ef;
}

/* Farbfenster, das am angeklickten Punkt aufgeht */
.zt-target-switch { position: relative; }

.zt-color-pop {
  position: absolute;
  left: 0;
  min-width: 186px;
  z-index: 30;
  padding: 8px;
  border: 1px solid #c7cfdb;
  border-radius: 10px;
  background: #ffffff;
  box-shadow: 0 10px 26px rgba(28, 46, 72, 0.18);
}

.zt-color-pop[hidden] { display: none; }

.zt-color-pop .zt-swatches {
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 8px;
}

.zt-color-pop .zt-swatch { height: 26px; }

.zt-color-pop .zt-fill-btn { margin-top: 6px; }

/* Video-Einstellung im Speichern-Menue */
.zt-save-video {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 6px;
}

.zt-save-video-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #7c8aa0;
}

.zt-save-video .zt-select {
  height: 28px;
  flex: 0 0 auto;
  font-size: 0.78rem;
}

#ztVideo.zt-save-item {
  width: 100%;
  text-align: left;
}

#ztVideo.zt-save-item:disabled {
  opacity: 0.4;
  cursor: default;
  background: transparent;
  color: #314663;
}

/* Knopf, der nur ein Symbol traegt (Vollbild) */
.zt-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  padding: 0;
}

.zt-icon-btn svg {
  width: 17px;
  height: 17px;
  display: block;
}

/* Hinein: Pfeile nach aussen. Heraus: Pfeile nach innen. */
.zt-icon-btn .zt-fs-out { display: none; }
.zt-icon-btn[aria-pressed="true"] .zt-fs-in { display: none; }
.zt-icon-btn[aria-pressed="true"] .zt-fs-out { display: block; }

/* Wiedergabe-Knopf in der Video-Zeile des Speichern-Menues */
.zt-save-play {
  flex: 0 0 auto;
  width: 30px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid #c7cfdb;
  border-radius: 7px;
  background: #ffffff;
  color: #314663;
  cursor: pointer;
}

.zt-save-play:hover:not(:disabled) {
  border-color: #C02318;
  color: #C02318;
}

.zt-save-play:disabled {
  opacity: 0.4;
  cursor: default;
}

.zt-save-play svg {
  width: 15px;
  height: 15px;
  display: block;
}

/* Laeuft die Wiedergabe, zeigt der Knopf das Pausensymbol. */
.zt-save-play .zt-play-off { display: none; }
.zt-save-play[aria-pressed="true"] .zt-play-on { display: none; }
.zt-save-play[aria-pressed="true"] .zt-play-off { display: block; }
.zt-save-play[aria-pressed="true"] { border-color: #C02318; color: #C02318; }

/* Umschalter fuer die Radierer-Art, nur sichtbar wenn der Radierer aktiv ist */
.zt-eraser-mode { margin-top: 8px; }
.zt-eraser-mode[hidden] { display: none; }

/* Deckkraft: durchgehender Regler, der Wert steht rechts daneben.
   Ohne Beschriftung - das Fenster ist schmal, und der Regler erklaert sich. */
.zt-alpha-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.zt-alpha-range {
  flex: 1 1 auto;
  min-width: 0;
  height: 18px;
}

.zt-alpha-value {
  flex: 0 0 auto;
  min-width: 32px;
  text-align: right;
  font-size: 0.7rem;
  font-weight: 700;
  color: #314663;
  font-variant-numeric: tabular-nums;
}

/* Der Punkt zeigt Farbe und Deckkraft. Das Karo liegt zuunterst, die Farbe
   als eigene Ebene darueber - so scheint es bei geringer Deckkraft durch,
   bleibt bei voller Deckkraft aber unsichtbar. */
.zt-target-dot {
  position: relative;
  background-color: #ffffff;
  background-image:
    linear-gradient(45deg, #dfe5ee 25%, transparent 25%, transparent 75%, #dfe5ee 75%),
    linear-gradient(45deg, #dfe5ee 25%, #ffffff 25%, #ffffff 75%, #dfe5ee 75%);
  background-size: 8px 8px;
  background-position: 0 0, 4px 4px;
  overflow: hidden;
}

.zt-target-dot::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--dot-color, transparent);
}



.zt-mirror-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 1px solid #c7cfdb;
  border-radius: 8px;
  background: #ffffff;
  color: #314663;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.zt-mirror-btn svg { width: 17px; height: 17px; display: block; }

.zt-mirror-btn:hover:not(:disabled) { border-color: #C02318; color: #C02318; }

.zt-mirror-btn:disabled { opacity: 0.35; cursor: default; }

/* ---------- Kasten unter der Zeichenflaeche ---------- */

.zt-side { grid-column: 1; grid-row: 1 / 3; }
.zt-stage { grid-column: 2; grid-row: 1; }
.zt-canvas-bar { grid-column: 2; grid-row: 2; }
.zt-layers { grid-column: 3; grid-row: 1 / 3; }

.zt-canvas-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  row-gap: 6px;
  padding: 7px 8px;
  background: #f7f9fb;
  border-top: 1px solid #d7dee8;
}

/* Beschriftung und die zugehörigen Felder bleiben beim Umbruch zusammen. */
.zt-bar-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zt-canvas-bar-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #7c8aa0;
}

/* Im Vollbild soll die Flaeche wachsen, der Kasten aber schmal bleiben. */
.zt-app.is-fullscreen .zt-canvas-bar { flex: 0 0 auto; }
/* Groessenfelder im Kasten unter der Zeichenflaeche */
.zt-size-fields {
  display: flex;
  align-items: center;
  gap: 6px;
}

.zt-size-field {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.72rem;
  color: #7c8aa0;
}

.zt-size-field span {
  font-weight: 700;
}

.zt-size-field input {
  /* Vier Ziffern passen bequem hinein; schmaler gehalten, damit der ganze
     Kasten samt Spiegeln und Vereinen in eine Zeile passt. */
  width: 56px;
  height: 26px;
  padding: 0 5px;
  border: 1px solid #c7cfdb;
  border-radius: 7px;
  background: #ffffff;
  color: #314663;
  font: inherit;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
}

.zt-size-field input:focus-visible {
  outline: 2px solid rgba(192, 35, 24, 0.35);
  outline-offset: 1px;
}

.zt-size-field input:disabled {
  opacity: 0.4;
  background: #f2f5f8;
}

.zt-bar-sep {
  width: 1px;
  height: 20px;
  background: #d7dee8;
  margin: 0 1px;
}

/* ---------- Texteingabe auf der Zeichenfläche ----------
   Liegt genau dort, wo der Text hinkommt, und trägt dieselbe Schrift.
   Schriftgrösse, Farbe und Position setzt das Skript. */

.zt-textedit {
  position: absolute;
  z-index: 8;
  min-width: 60px;
  max-width: 90%;
  padding: 0 2px;
  border: 0;
  border-bottom: 1px dashed rgba(192, 35, 24, 0.6);
  border-radius: 0;
  background: rgba(255, 255, 255, 0.72);
  outline: none;
  white-space: pre;
}

.zt-textedit::placeholder { color: #9aabc0; }

/* ---------- Kürzelblatt ----------
   Der Inhalt wird vom Skript aus T.helpGroups gebaut, damit die Liste nicht
   in zeichnen.html und draw.html doppelt gepflegt werden muss. */

.zt-help-back {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(23, 33, 48, 0.42);
}

.zt-help {
  width: min(760px, 100%);
  max-height: min(86vh, 860px);
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 18px 48px rgba(23, 33, 48, 0.28);
  overflow: hidden;
}

.zt-help-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 18px;
  border-bottom: 1px solid #e4e9f0;
}

.zt-help-head h2 {
  margin: 0;
  font-size: 1rem;
  color: #24324b;
}

.zt-help-x {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 1px solid #d7dee8;
  border-radius: 8px;
  background: #ffffff;
  color: #52627d;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.zt-help-x:hover {
  border-color: #C02318;
  color: #C02318;
}

/* Zwei Spalten, damit die Liste ohne langes Scrollen auf einen Blick passt. */
.zt-help-body {
  padding: 2px 18px 14px;
  overflow-y: auto;
  columns: 2;
  column-gap: 30px;
}

@media (max-width: 660px) {
  .zt-help-body { columns: 1; }
}

.zt-help-group {
  break-inside: avoid;
  margin-top: 15px;
}

.zt-help-group h3 {
  margin: 0 0 5px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: #7c8aa0;
}

.zt-help-row {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(0, 1fr);
  gap: 3px 10px;
  align-items: baseline;
  padding: 3px 0;
}

.zt-help-keys { white-space: nowrap; }

.zt-kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #d7dee8;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #f7f9fb;
  color: #24324b;
  font-family: inherit;
  font-size: 0.74rem;
  font-weight: 700;
  white-space: nowrap;
}

.zt-kbd-oder {
  margin: 0 3px;
  color: #9aabc0;
  font-size: 0.72rem;
}

.zt-help-text {
  color: #52627d;
  font-size: 0.8rem;
  line-height: 1.4;
}

.zt-help-note {
  margin: 0;
  padding: 10px 18px 14px;
  border-top: 1px solid #e4e9f0;
  color: #7c8aa0;
  font-size: 0.76rem;
  line-height: 1.5;
}
