/* Editor (Arbeitsmodus) -- design-erstellen.kukanilea.de
   Raster nach webtool-workspace-contract.md: ab 960 px Leiste, Panel und
   Buehne nebeneinander, darunter Buehne voll, Werkzeugleiste unten, Panel
   als Blatt. Die Hoehenkette traegt an JEDEM Glied min-height: 0 -- sonst
   setzt die Flexbox-Mindestgroesse die Inhaltshoehe durch. */

.ed, .ed-dialog, .ed-popover {
  /* Eingabeschrift: ein Owner. iOS Safari zoomt beim Antippen in jedes Feld
     unter 16 px und verschiebt die Ansicht -- bei grobem Zeiger deshalb 16 px. */
  --ed-eingabe: 15px; --ed-eingabe-klein: 14px; --ed-eingabe-name: inherit;
  --ed-grund: #f2f3f7;
  --ed-flaeche: #ffffff;
  --ed-flaeche-2: #f7f7fb;
  --ed-linie: #e3e5ec;
  --ed-linie-2: #cfd3de;
  --ed-text: #111827;
  --ed-text-2: #4b5563;
  --ed-text-3: #6b7280;
  --ed-akzent: #6d28d9;
  --ed-akzent-hell: #ede9fe;
  --ed-akzent-text: #5b21b6;
  --ed-gefahr: #b91c1c;
  --ed-ok: #15803d;
  --buehne-grund: #e9ebf1;
  --ed-schatten: 0 10px 30px -12px rgba(17, 24, 39, .28), 0 2px 6px rgba(17, 24, 39, .08);
  --leiste-h: 0px;

}

.ed {
  flex: 1; min-height: 0;
  flex-direction: column;
  background: var(--ed-grund);
  color: var(--ed-text);
  font-size: 14px;
  line-height: 1.4;
  user-select: none;
  -webkit-user-select: none;
}

@media (prefers-color-scheme: dark) {
  .ed, .ed-dialog, .ed-popover {
    --ed-grund: #16161d;
    --ed-flaeche: #1f1f28;
    --ed-flaeche-2: #262632;
    --ed-linie: #30303d;
    --ed-linie-2: #41414f;
    --ed-text: #ecebf5;
    --ed-text-2: #b9b7cc;
    --ed-text-3: #9592ad;
    --ed-akzent: #a78bfa;
    --ed-akzent-hell: #2e2550;
    --ed-akzent-text: #c4b5fd;
    --buehne-grund: #0f0f14;
    --ed-schatten: 0 12px 32px -12px rgba(0, 0, 0, .6);
  }
}

.ed input, .ed textarea, .ed select { user-select: text; -webkit-user-select: text; }
.ed button { font: inherit; color: inherit; }
.ed .sym { display: block; flex: 0 0 auto; }

/* ── Kopfzeile ── */
.ed-kopf {
  display: flex; align-items: center; gap: 10px;
  min-height: 54px; padding: 6px 12px;
  background: var(--ed-flaeche); border-bottom: 1px solid var(--ed-linie);
}
.ed-marke { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 700; padding: 6px 8px; border-radius: 10px; min-height: 44px; background: none; border: 0; cursor: pointer; }
.ed-marke:hover { background: var(--ed-flaeche-2); }
.ed-marke img { width: 26px; height: 26px; }
.ed-trenner { width: 1px; height: 24px; background: var(--ed-linie); flex: 0 0 auto; }
.ed-name {
  font: inherit; font-size: var(--ed-eingabe-name); font-weight: 600; color: var(--ed-text); background: transparent;
  border: 1px solid transparent; border-radius: 8px; padding: 7px 10px; min-height: 40px;
  width: clamp(120px, 22vw, 280px); min-width: 0;
}
.ed-name:hover { border-color: var(--ed-linie); }
.ed-name:focus { border-color: var(--ed-akzent); outline: 3px solid var(--ed-akzent-hell); }
.ed-speicher { font-size: 12px; color: var(--ed-text-3); white-space: nowrap; display: flex; align-items: center; gap: 4px; }
.ed-speicher[data-zustand="fehler"] { color: var(--ed-gefahr); font-weight: 600; }
.ed-kopf-mitte { display: flex; gap: 2px; margin-left: 4px; }
.ed-kopf-rechts { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.ed-knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; min-width: 40px; padding: 0 12px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; cursor: pointer; font-weight: 600; white-space: nowrap;
}
.ed-knopf:hover:not(:disabled) { background: var(--ed-flaeche-2); }
.ed-knopf:disabled { opacity: .4; cursor: default; }
.ed-knopf.nur-symbol { padding: 0; width: 40px; }
.ed-knopf.umriss { border-color: var(--ed-linie-2); }
.ed-knopf.primaer { background: var(--ed-akzent); color: #fff; }
.ed-knopf.primaer:hover:not(:disabled) { background: var(--ed-akzent-text); }
@media (prefers-color-scheme: dark) { .ed-knopf.primaer { color: #16161d; } }
.ed-knopf[aria-pressed="true"], .ed-knopf.ist-aktiv { background: var(--ed-akzent-hell); color: var(--ed-akzent-text); }
.ed-abzeichen { min-width: 18px; height: 18px; border-radius: 9px; background: #f59e0b; color: #1f1300; font-size: 11px; font-weight: 800; display: inline-grid; place-items: center; padding: 0 5px; }
.ed-abzeichen.ok { background: #16a34a; color: #fff; }

/* ── Koerper ── */
.ed-koerper { flex: 1; min-height: 0; display: flex; }
.ed-leiste {
  flex: 0 0 76px; display: flex; flex-direction: column; gap: 2px; padding: 8px 6px;
  background: var(--ed-flaeche); border-right: 1px solid var(--ed-linie); overflow-y: auto;
}
.ed-leiste-knopf {
  display: grid; justify-items: center; gap: 4px; padding: 9px 2px; border-radius: 12px;
  background: none; border: 0; cursor: pointer; font-size: 10.5px; font-weight: 600; color: var(--ed-text-2);
  min-height: 56px; letter-spacing: -.01em; max-width: 100%; overflow-wrap: anywhere; hyphens: auto;
}
.ed-leiste-knopf:hover { background: var(--ed-flaeche-2); color: var(--ed-text); }
.ed-leiste-knopf[aria-selected="true"] { background: var(--ed-akzent-hell); color: var(--ed-akzent-text); }

.ed-panel {
  flex: 0 0 340px; min-height: 0; display: flex; flex-direction: column;
  background: var(--ed-flaeche); border-right: 1px solid var(--ed-linie);
}
.ed-panel[data-zu] { display: none; }
.ed-panel-kopf { display: flex; align-items: center; gap: 8px; padding: 12px 14px 8px; }
.ed-panel-kopf h2 { font-size: 16px; margin: 0; flex: 1; }
.ed-panel-inhalt { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 14px 24px; overscroll-behavior: contain; }
.ed-abschnitt { margin: 14px 0 0; }
.ed-abschnitt > h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ed-text-3); margin: 0 0 8px; font-weight: 700; }
.ed-hinweis { font-size: 12.5px; color: var(--ed-text-3); margin: 6px 0 0; line-height: 1.45; }

.ed-arbeit { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; }

/* ── Kontextleiste ── */
.ed-kontext {
  min-height: 52px; display: flex; align-items: center; gap: 4px; padding: 6px 10px;
  background: var(--ed-flaeche); border-bottom: 1px solid var(--ed-linie);
  overflow-x: auto; scrollbar-width: thin;
}
.ed-kontext-gruppe { display: flex; align-items: center; gap: 2px; padding: 0 4px; }
.ed-kontext-gruppe + .ed-kontext-gruppe { border-left: 1px solid var(--ed-linie); }
.ed-kontext-leer { color: var(--ed-text-3); font-size: 13px; padding: 0 6px; white-space: nowrap; }
.ed-farbknopf { width: 40px; height: 40px; border-radius: 10px; border: 0; background: none; display: grid; place-items: center; cursor: pointer; }
.ed-farbknopf:hover { background: var(--ed-flaeche-2); }
.ed-farbknopf i { width: 24px; height: 24px; border-radius: 50%; display: block; border: 1px solid rgba(0,0,0,.12); background: var(--f, #000); }
.ed-farbknopf i.verlauf { background: var(--f); }
.ed-schriftknopf { min-width: 150px; justify-content: space-between; border: 1px solid var(--ed-linie-2); }
.ed-zahl { display: inline-flex; align-items: center; border: 1px solid var(--ed-linie-2); border-radius: 10px; overflow: hidden; }
.ed-zahl input { width: 52px; border: 0; background: transparent; color: inherit; font: inherit; font-weight: 600; text-align: center; min-height: 38px; padding: 0; }
.ed-zahl input:focus { outline: none; background: var(--ed-akzent-hell); }
.ed-zahl button { width: 32px; min-height: 38px; border: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
.ed-zahl button:hover { background: var(--ed-flaeche-2); }

/* ── Buehne ── */
.ed-buehne {
  flex: 1; min-height: 0; position: relative; overflow: hidden; touch-action: none;
  background: var(--buehne-grund); outline: none;
}
.ed-buehne.ist-schwenkbereit { cursor: grab; }
.ed-leinwand { position: absolute; left: 0; top: 0; display: block; }
.ed-ueber { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }

.ed-rahmen {
  position: absolute; left: 0; top: 0; transform-origin: center;
  border: 1.5px solid var(--ed-akzent); border-radius: 1px; pointer-events: none;
  box-shadow: 0 0 0 1px rgba(255,255,255,.6);
}
.ed-rahmen.ist-gesperrt { border-style: dashed; }
.ed-griff {
  position: absolute; width: 14px; height: 14px; background: #fff;
  border: 1.5px solid var(--ed-akzent); border-radius: 50%;
  pointer-events: auto; touch-action: none; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.ed-griff::before { content: ""; position: absolute; inset: -12px; }
@media (pointer: coarse) {
  .ed-griff { width: 18px; height: 18px; }
  .ed-griff::before { inset: -14px; }
  /* Ziele fuer den Finger mindestens 44 px (Qualitaetsvertrag, WCAG 2.5.5) */
  .ed-kontext .ed-knopf, .ed-dialog .ed-knopf, .ed-popover .ed-knopf { min-height: 44px; min-width: 44px; }
  .ed-kontext .ed-farbknopf { width: 44px; height: 44px; }
  .ed-zahl input { min-height: 44px; }
  .ed-zahl button { width: 44px; min-height: 44px; }
  .ed-kontext { min-height: 58px; }
}
.ed-griff-nw { left: -8px; top: -8px; cursor: nwse-resize; }
.ed-griff-ne { right: -8px; top: -8px; cursor: nesw-resize; }
.ed-griff-se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.ed-griff-sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.ed-griff-n, .ed-griff-s { left: 50%; width: 22px; height: 8px; border-radius: 4px; margin-left: -11px; cursor: ns-resize; }
.ed-griff-n { top: -5px; } .ed-griff-s { bottom: -5px; }
.ed-griff-e, .ed-griff-w { top: 50%; width: 8px; height: 22px; border-radius: 4px; margin-top: -11px; cursor: ew-resize; }
.ed-griff-e { right: -5px; } .ed-griff-w { left: -5px; }
.ed-dreh {
  left: 50%; bottom: -46px; top: auto; width: 30px; height: 30px; margin-left: -15px;
  display: grid; place-items: center; color: var(--ed-text); cursor: grab;
  transform: rotate(var(--gegendrehung, 0deg));
}
.ed-dreh svg { width: 16px; height: 16px; }
.ed-schloss { display: none; position: absolute; right: -10px; top: -10px; width: 22px; height: 22px; border-radius: 50%; background: var(--ed-akzent); color: #fff; place-items: center; }
.ed-schloss svg { width: 13px; height: 13px; }
.ed-rahmen.ist-gesperrt .ed-schloss { display: grid; }
.ed-rahmen.ohne-ecken .ed-griff-nw, .ed-rahmen.ohne-ecken .ed-griff-ne,
.ed-rahmen.ohne-ecken .ed-griff-se, .ed-rahmen.ohne-ecken .ed-griff-sw,
.ed-rahmen.ohne-seiten .ed-griff-n, .ed-rahmen.ohne-seiten .ed-griff-s,
.ed-rahmen.ohne-seiten .ed-griff-e, .ed-rahmen.ohne-seiten .ed-griff-w,
.ed-rahmen.nur-waagerecht .ed-griff-n, .ed-rahmen.nur-waagerecht .ed-griff-s,
.ed-rahmen.ohne-drehen .ed-dreh, .ed-rahmen.ist-gesperrt .ed-griff { display: none; }
.ed-rahmen.ist-ziehend .ed-griff { opacity: 0; }
.ed-masse {
  position: absolute; left: 0; top: 0; z-index: 6; pointer-events: none;
  background: #111827; color: #fff; font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 6px;
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.ed-texteingabe {
  position: absolute; left: 0; top: 0; z-index: 5; transform-origin: center;
  background: transparent; border: 0; margin: 0; padding: 0; resize: none; overflow: hidden;
  white-space: pre-wrap; overflow-wrap: break-word; word-break: normal;
  outline: 1.5px dashed var(--ed-akzent); outline-offset: 2px;
  user-select: text; -webkit-user-select: text;
  /* Die Breite ist die des Textkastens, auch wenn er (gezoomt oder skaliert)
     breiter ist als die Buehne -- sonst bricht der Text beim Bearbeiten
     anders um als im Ergebnis. */
  max-inline-size: none;
}
.ed-ablage-hinweis {
  position: absolute; inset: 12px; border: 2px dashed var(--ed-akzent); border-radius: 18px;
  display: grid; place-items: center; background: rgba(109, 40, 217, .06); pointer-events: none;
  font-weight: 700; color: var(--ed-akzent-text); font-size: 16px;
}
.ed-ladeanzeige {
  position: absolute; left: 50%; top: 16px; transform: translateX(-50%); z-index: 8;
  background: var(--ed-flaeche); border: 1px solid var(--ed-linie); border-radius: 999px;
  padding: 8px 16px; font-weight: 600; box-shadow: var(--ed-schatten); display: flex; gap: 10px; align-items: center;
}

/* ── Fusszeile der Buehne: Seiten, Zoom, Rechtliches ── */
.ed-fuss {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 10px;
  background: var(--ed-flaeche); border-top: 1px solid var(--ed-linie);
}
.ed-seiten { display: flex; gap: 6px; align-items: center; overflow-x: auto; flex: 1; min-width: 0; padding: 2px; }
.ed-seite {
  flex: 0 0 auto; height: 40px; border-radius: 6px; border: 2px solid transparent; padding: 0; background: var(--ed-flaeche-2);
  cursor: pointer; position: relative; overflow: hidden; display: grid; place-items: center;
}
.ed-seite canvas { display: block; height: 36px; width: auto; }
.ed-seite[aria-current="true"] { border-color: var(--ed-akzent); }
.ed-seite-nr { position: absolute; left: 2px; bottom: 1px; font-size: 10px; font-weight: 700; background: rgba(255,255,255,.85); color: #111; border-radius: 3px; padding: 0 3px; }
.ed-zoom { display: flex; align-items: center; gap: 2px; }
.ed-zoom-wert { min-width: 56px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; border: 0; background: none; cursor: pointer; min-height: 40px; border-radius: 8px; }
.ed-zoom-wert:hover { background: var(--ed-flaeche-2); }
.ed-recht { display: flex; gap: 10px; font-size: 12px; white-space: nowrap; }
.ed-recht a { color: var(--ed-text-3); text-decoration: none; }
.ed-recht a:hover { color: var(--ed-akzent); text-decoration: underline; }

/* ── Bausteine in Panels ── */
.ed-raster { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.ed-raster-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.ed-raster-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.ed-kachel {
  aspect-ratio: 1; border-radius: 12px; border: 1px solid var(--ed-linie); background: var(--ed-flaeche-2);
  display: grid; place-items: center; cursor: pointer; padding: 6px; color: var(--ed-text); min-width: 0;
}
.ed-kachel:hover { border-color: var(--ed-akzent); background: var(--ed-akzent-hell); }
.ed-kachel svg { max-width: 72%; max-height: 72%; }
.ed-kachel img, .ed-kachel canvas { max-width: 100%; max-height: 100%; border-radius: 6px; display: block; }
.ed-kachel-bild { aspect-ratio: auto; padding: 0; overflow: hidden; background: var(--ed-flaeche-2); }
.ed-raster-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.ed-kachel-text { display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 4px; aspect-ratio: auto; min-height: 64px; font-size: 12px; font-weight: 600; color: var(--ed-text-2); }
.ed-kachel-text svg { max-width: none; max-height: none; }
.ed-kachel-sticker img { width: 70%; height: 70%; object-fit: contain; border-radius: 0; }

/* Datenraster fuer Tabelle und Diagramm */
.ed-datenraster-wrap { max-height: 46dvh; overflow: auto; border: 1px solid var(--ed-linie); border-radius: 8px; }
.ed-datenraster { border-collapse: collapse; width: 100%; }
.ed-datenraster td { border-bottom: 1px solid var(--ed-linie); padding: 0; }
.ed-datenraster td + td { border-left: 1px solid var(--ed-linie); }
.ed-datenraster td:last-child { width: 40px; text-align: center; border-left: 0; }
.ed-datenraster input { width: 100%; min-width: 90px; border: 0; padding: 9px 10px; font: inherit; font-size: var(--ed-eingabe-klein); background: transparent; color: var(--ed-text); }
.ed-datenraster input:focus { outline: 2px solid var(--ed-akzent); outline-offset: -2px; background: var(--ed-akzent-hell); }
.ed-datenraster input.kopf { font-weight: 700; background: var(--ed-flaeche-2); }
.ed-datenraster input.abschnitt { font-weight: 700; color: var(--ed-akzent-text, var(--ed-akzent)); }
.ed-datenraster input[readonly] { color: var(--ed-text-2); cursor: default; }
.ed-datenraster input[aria-invalid] { outline: 2px solid #dc2626; outline-offset: -2px; background: rgba(220, 38, 38, .08); }
/* Beim seitlichen Blaettern bleibt die erste Spalte stehen -- man sieht, in
   welcher Zeile man schreibt; beim Blaettern nach unten ebenso die Kopfzeile. */
.ed-datenraster td:first-child { position: sticky; left: 0; z-index: 1; background: var(--ed-flaeche); box-shadow: 1px 0 0 var(--ed-linie); }
.ed-datenraster tr:first-child td:has(> input.kopf) { position: sticky; top: 0; z-index: 2; background: var(--ed-flaeche-2); }
.ed-datenraster tr:first-child td:first-child:has(> input.kopf) { z-index: 3; }
.ed-datenraster td:last-child { position: static; box-shadow: none; }
.ed-fehlertext { color: #dc2626; font-size: 13px; font-weight: 600; margin: 6px 0 0; }
.ed-fehlertext:empty { display: none; }
.ed-serie-intro { margin: 0 0 14px; }
.ed-serie-quellen { display: flex; flex-wrap: wrap; gap: 8px; margin: -2px 0 12px; }
.ed-serie-quellen .ed-knopf { flex: 1 1 180px; justify-content: center; }
.ed-serie-nummern { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 2px 0 10px; font-size: 13px; color: var(--ed-text-2); }
.ed-serie-nummern input { width: 64px; min-height: 36px; padding: 6px 8px; border: 1px solid var(--ed-linie-2); border-radius: 8px; font: inherit; font-size: var(--ed-eingabe); color: var(--ed-text); background: var(--ed-flaeche-2); }
.ed-serie-nummern input:focus { border-color: var(--ed-akzent); outline: 3px solid var(--ed-akzent-hell); outline-offset: 0; }
@media (pointer: coarse) { .ed-serie-nummern input { min-height: 44px; } }
.ed-ideen { margin: -4px 0 12px; gap: 6px; }
.ed-chip-klein { font-size: 12.5px; padding: 5px 10px; min-height: 32px; }
@media (pointer: coarse) { .ed-chip-klein { min-height: 44px; } }
@media (prefers-color-scheme: dark) { .ed-fehlertext { color: #f87171; } .ed-datenraster input[aria-invalid] { outline-color: #f87171; } }
.ed-buehne.ist-zeichnend { cursor: crosshair; }
.ed-kachel-bild img { width: 100%; height: 100%; object-fit: cover; border-radius: 0; }
.ed-breit {
  width: 100%; display: flex; align-items: center; gap: 10px; text-align: left; justify-content: flex-start;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--ed-linie); background: var(--ed-flaeche-2);
  cursor: pointer; min-height: 48px; margin-bottom: 8px;
}
.ed-breit:hover { border-color: var(--ed-akzent); }
.ed-breit-primaer { background: var(--ed-akzent); color: #fff; border-color: transparent; justify-content: center; font-weight: 700; }
.ed-breit-primaer:hover { background: var(--ed-akzent-text); }
@media (prefers-color-scheme: dark) { .ed-breit-primaer { color: #16161d; } }
.ed-textvorlage { display: block; width: 100%; text-align: left; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--ed-linie); background: var(--ed-flaeche-2); cursor: pointer; margin-bottom: 8px; color: var(--ed-text); }
.ed-textvorlage:hover { border-color: var(--ed-akzent); }
.ed-suche { position: relative; margin: 4px 0 10px; }
.ed-suche input { width: 100%; font: inherit; font-size: var(--ed-eingabe); padding: 10px 12px 10px 36px; min-height: 44px; border-radius: 12px; border: 1px solid var(--ed-linie-2); background: var(--ed-flaeche-2); color: var(--ed-text); }
.ed-suche input:focus { border-color: var(--ed-akzent); outline: 3px solid var(--ed-akzent-hell); }
.ed-suche .sym { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ed-text-3); }
.ed-chips { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 10px; }
.ed-chip { border: 1px solid var(--ed-linie-2); background: var(--ed-flaeche); border-radius: 999px; padding: 6px 12px; min-height: 36px; font-size: 13px; font-weight: 600; cursor: pointer; }
.ed-chip[aria-pressed="true"] { background: var(--ed-text); color: var(--ed-flaeche); border-color: var(--ed-text); }
.ed-feld { display: grid; gap: 4px; margin-bottom: 10px; font-size: 12.5px; font-weight: 600; color: var(--ed-text-2); }
.ed-feld input, .ed-feld select, .ed-feld textarea {
  font: inherit; font-size: var(--ed-eingabe); font-weight: 500; color: var(--ed-text); background: var(--ed-flaeche-2);
  border: 1px solid var(--ed-linie-2); border-radius: 10px; padding: 9px 11px; min-height: 44px; min-width: 0; width: 100%;
}
.ed-feld textarea { min-height: 72px; resize: vertical; }
.ed-feld input:focus, .ed-feld select:focus, .ed-feld textarea:focus { border-color: var(--ed-akzent); outline: 3px solid var(--ed-akzent-hell); outline-offset: 0; }
.ed-regler { display: grid; grid-template-columns: 1fr 56px; gap: 4px 10px; align-items: center; margin-bottom: 12px; }
.ed-regler label { grid-column: 1 / -1; font-size: 12.5px; font-weight: 600; color: var(--ed-text-2); display: flex; justify-content: space-between; }
.ed-regler input[type="range"] { width: 100%; accent-color: var(--ed-akzent); min-height: 32px; }
.ed-regler input[type="number"] { font: inherit; font-size: var(--ed-eingabe-klein); font-weight: 600; width: 56px; min-height: 36px; border-radius: 8px; border: 1px solid var(--ed-linie-2); background: var(--ed-flaeche-2); color: var(--ed-text); text-align: center; }
.ed-schalter { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; font-weight: 600; min-height: 44px; }
.ed-schalter input { width: 40px; height: 22px; accent-color: var(--ed-akzent); }
.ed-leerzustand { text-align: center; color: var(--ed-text-3); padding: 24px 8px; font-size: 13.5px; }

/* Ebenen */
.ed-ebenen { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.ed-ebene { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 8px; border-radius: 10px; border: 1px solid transparent; background: var(--ed-flaeche-2); min-height: 48px; cursor: pointer; }
.ed-ebene[aria-selected="true"] { border-color: var(--ed-akzent); background: var(--ed-akzent-hell); }
.ed-ebene-bild { width: 36px; height: 36px; flex: 0 0 36px; border-radius: 6px; background: var(--ed-flaeche); display: grid; place-items: center; overflow: hidden; border: 1px solid var(--ed-linie); }
.ed-ebene-bild canvas { max-width: 100%; max-height: 100%; }
.ed-ebene-waehlen { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; min-height: 40px; }
.ed-ebene-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.ed-ebene .ed-knopf { min-width: 36px; min-height: 36px; width: 36px; padding: 0; }

/* Entwuerfe und Vorlagen */
.ed-entwuerfe { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 12px; }
.ed-entwurf { border: 2px solid transparent; border-radius: 12px; padding: 0; background: var(--ed-flaeche-2); cursor: pointer; overflow: hidden; display: block; }
.ed-entwurf:hover, .ed-entwurf:focus-visible { border-color: var(--ed-akzent); }
.ed-entwurf canvas { display: block; width: 100%; height: auto; }

/* ── Popover und Blatt ── */
.ed-popover, .ed-dialog { font-size: 14px; line-height: 1.4; font-family: var(--font-sans); }
.ed-popover button, .ed-dialog button { font: inherit; color: inherit; }
.ed-popover .sym, .ed-dialog .sym { display: block; flex: 0 0 auto; }
.ed-popover {
  position: fixed; z-index: 60; min-width: 240px; max-width: min(360px, calc(100vw - 16px));
  max-height: min(70vh, 560px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--ed-flaeche); color: var(--ed-text); border: 1px solid var(--ed-linie); border-radius: 16px;
  box-shadow: var(--ed-schatten); padding: 12px;
}
.ed-popover h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ed-text-3); margin: 12px 0 8px; }
.ed-popover h3:first-child { margin-top: 2px; }
.ed-farben { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.ed-farbe { aspect-ratio: 1; border-radius: 50%; border: 1px solid rgba(0,0,0,.14); background: var(--f); cursor: pointer; padding: 0; min-width: 24px; }
.ed-farbe[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ed-flaeche), 0 0 0 4px var(--ed-akzent); }
.ed-farbe-plus { display: grid; place-items: center; background: conic-gradient(from 0deg, #f43f5e, #f59e0b, #84cc16, #06b6d4, #6366f1, #d946ef, #f43f5e); color: #fff; }
.ed-farbe-transparent { background: linear-gradient(135deg, #fff 45%, #ef4444 45%, #ef4444 55%, #fff 55%); }
.ed-hexzeile { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.ed-hexzeile input[type="text"] { flex: 1; font: inherit; font-family: var(--font-mono); padding: 8px 10px; min-height: 40px; border-radius: 10px; border: 1px solid var(--ed-linie-2); background: var(--ed-flaeche-2); color: var(--ed-text); min-width: 0; }
.ed-hexzeile input[type="color"] { width: 44px; height: 40px; border: 0; background: none; padding: 0; cursor: pointer; }
.ed-schriftliste { display: grid; gap: 2px; margin-top: 6px; }
.ed-schrift { display: flex; justify-content: space-between; align-items: center; gap: 8px; text-align: left; padding: 8px 10px; border-radius: 10px; border: 0; background: none; cursor: pointer; font-size: 18px; min-height: 44px; color: var(--ed-text); }
.ed-schrift:hover { background: var(--ed-flaeche-2); }
.ed-schrift[aria-pressed="true"] { background: var(--ed-akzent-hell); }
.ed-schrift small { font-family: var(--font-sans); font-size: 11px; color: var(--ed-text-3); }
.ed-menue { display: grid; gap: 2px; min-width: 220px; }
.ed-menue button { display: flex; align-items: center; gap: 10px; text-align: left; border: 0; background: none; padding: 9px 10px; border-radius: 10px; cursor: pointer; min-height: 40px; }
.ed-menue button:hover { background: var(--ed-flaeche-2); }
@media (pointer: coarse) { .ed-menue button { min-height: 44px; } }
.ed-menue kbd { margin-left: auto; font-size: 11px; color: var(--ed-text-3); font-family: var(--font-sans); }
.ed-menue hr { border: 0; border-top: 1px solid var(--ed-linie); margin: 4px 0; }

/* ── Dialoge ── */
.ed-dialog {
  border: 0; border-radius: 20px; padding: 0; max-width: min(640px, calc(100vw - 24px)); width: 100%;
  background: var(--ed-flaeche); color: var(--ed-text); box-shadow: 0 30px 80px -20px rgba(0,0,0,.5);
}
.ed-dialog::backdrop { background: rgba(15, 15, 30, .45); backdrop-filter: blur(2px); }
.ed-dialog-kopf { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.ed-dialog-kopf h2 { margin: 0; font-size: 19px; flex: 1; }
.ed-dialog-inhalt { padding: 8px 20px 4px; max-height: min(70vh, 640px); overflow-y: auto; }
.ed-dialog-fuss { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px 18px; flex-wrap: wrap; }
.ed-optionen { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 6px 0 14px; }
.ed-option { display: grid; gap: 2px; text-align: left; padding: 12px; border-radius: 12px; border: 1.5px solid var(--ed-linie); background: var(--ed-flaeche-2); cursor: pointer; min-height: 64px; }
.ed-option strong { font-size: 14px; }
.ed-option span { font-size: 12px; color: var(--ed-text-3); }
.ed-option[aria-pressed="true"] { border-color: var(--ed-akzent); background: var(--ed-akzent-hell); }
/* Auf dem hellen Akzentgrund reicht text-3 nicht (4,07:1 bei 12 px, axe) */
.ed-option[aria-pressed="true"] span { color: var(--ed-text-2); }
.ed-kasten { border-radius: 12px; background: var(--ed-flaeche-2); padding: 12px 14px; margin: 8px 0; font-size: 13.5px; }
.ed-kasten.warnung { background: #fff7ed; color: #7c2d12; }
.ed-kasten.ok { background: #f0fdf4; color: #14532d; }
@media (prefers-color-scheme: dark) {
  .ed-kasten.warnung { background: #3b2410; color: #fed7aa; }
  .ed-kasten.ok { background: #0f2e1b; color: #bbf7d0; }
}
.ed-befunde { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.ed-befund { display: grid; grid-template-columns: 22px 1fr; gap: 4px 10px; padding: 12px; border-radius: 12px; background: var(--ed-flaeche-2); }
.ed-befund strong { font-size: 14px; }
.ed-befund p { grid-column: 2; margin: 0; font-size: 13px; color: var(--ed-text-2); }
.ed-befund .ed-befund-aktion { grid-column: 2; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.ed-befund-warnung .sym { color: #d97706; } .ed-befund-fehler .sym { color: var(--ed-gefahr); } .ed-befund-ok .sym { color: var(--ed-ok); }

/* ── Schmale Breiten: Buehne voll, Leiste unten, Panel als Blatt ── */
@media (max-width: 959px) {
  .ed-kopf { gap: 6px; padding: 6px 8px; }
  .ed-marke span, .ed-speicher-text, .ed-kopf .ed-knopf .lang { display: none; }
  .ed-name { width: auto; flex: 1 1 80px; }
  .ed-koerper { flex-direction: column; }
  .ed-leiste {
    order: 3; flex: 0 0 auto; flex-direction: row; justify-content: space-around; overflow-x: auto; overflow-y: hidden;
    border-right: 0; border-top: 1px solid var(--ed-linie); padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
  }
  .ed-leiste { justify-content: flex-start; gap: 0; scrollbar-width: none; }
  .ed-leiste-knopf { min-width: 66px; min-height: 54px; padding: 6px 4px; white-space: nowrap; hyphens: manual; font-size: 11px; flex: 0 0 auto; }
  .ed-kopf [data-breit] { display: none; }
  .ed-name { flex: 1 1 60px; min-width: 60px; width: auto; padding: 6px 6px; }
  .ed-kopf-mitte { margin-left: 0; }
  .ed-kopf .ed-knopf.primaer { padding: 0; width: 44px; }
  .ed-panel {
    position: fixed; left: 0; right: 0; bottom: var(--leiste-h); z-index: 30;
    max-height: 56dvh; border-right: 0; border-top: 1px solid var(--ed-linie);
    border-radius: 18px 18px 0 0; box-shadow: 0 -18px 40px -24px rgba(0,0,0,.45);
  }
  .ed-panel-kopf::before { content: ""; position: absolute; left: 50%; top: 6px; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--ed-linie-2); }
  .ed-panel-kopf { position: relative; padding-top: 18px; }
  .ed-arbeit { order: 1; }
  .ed-fuss { gap: 6px; min-height: 48px; }
  .ed-recht { display: none; }
  .ed-panel.mit-recht .ed-recht-im-panel { display: flex; }
  .ed-popover { left: 0 !important; right: 0; bottom: var(--leiste-h); top: auto !important; max-width: none; border-radius: 18px 18px 0 0; max-height: 50dvh; }
}
@media (min-width: 960px) {
  .ed-panel-zu-knopf-mobil { display: none; }
}
@media (min-width: 960px) and (max-width: 1279px) {
  .ed-panel { flex-basis: 300px; }
}

@media (pointer: coarse) {
  .ed, .ed-dialog, .ed-popover { --ed-eingabe: 16px; --ed-eingabe-klein: 16px; --ed-eingabe-name: 16px; }
}

/* Fingerziele mindestens 44 px (Qualitaetsvertrag, WCAG 2.5.5). Am Dateiende:
   ein Media Query erhoeht keine Spezifitaet -- weiter oben verlor dieser Block
   gegen jede spaetere Grundregel (Chips 36 px, Zoomwert, Seiten, Ebenen), und
   das Namensfeld gegen die globale input[type="text"]-Regel aus styles.css. */
@media (pointer: coarse) {
  .ed-chip { min-height: 44px; }
  .ed-regler input[type="number"], .ed-regler input[type="range"] { min-height: 44px; }
  .ed-kopf .ed-knopf, .ed-seiten .ed-knopf, .ed-zoom .ed-knopf, .ed-panel-kopf .ed-knopf { min-height: 44px; min-width: 44px; }
  .ed-zoom .ed-zoom-wert { min-height: 44px; }
  .ed-seiten .ed-seite { height: 44px; min-width: 44px; }
  .ed-seiten .ed-seite canvas { height: 40px; }
  .ed-kopf .ed-name { min-height: 44px; }
  .ed-ebene .ed-knopf { min-width: 44px; min-height: 44px; width: 44px; }
  .ed-ebene .ed-ebene-waehlen { min-height: 44px; }
  .ed-hexzeile input[type="text"] { min-height: 44px; }
  .ed-datenraster input { min-height: 44px; }
  .ed-hexzeile input[type="color"] { height: 44px; }
  /* Tastenkuerzel helfen am Telefon niemandem */
  .ed-menue kbd { display: none; }
  #editor input[type="color"] { min-width: 44px; min-height: 44px; }
  /* Farbfelder: acht je Reihe, damit Graustufen und Farbtoene geordnet
     bleiben -- auf 390 px sind das 40 px. Die Trefferflaeche reicht deshalb
     bis in die Luecke (46 px), wie bei den Anfassern. */
  .ed-farbe { position: relative; }
  /* inset ab der Innenkante: 1 px Rahmen + 3 px = halbe Luecke von 6 px */
  .ed-farbe::before { content: ""; position: absolute; inset: -4px; border-radius: 50%; }
}
