/* ============ Designer ============ */
.designer-seite { background: var(--bg-2); }
.d-nav-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 8px; color: var(--text); font-size: 14px; }
@media (hover: hover) { .d-nav-link:hover { text-decoration: none; opacity: .7; } }

.designer { padding: calc(var(--nav-h) + 36px) var(--rand) 0; }
.d-kopf { text-align: center; }
.d-kopf h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.08; }
.d-formate { margin-top: 24px; }

/* Karte und Werkzeuge nebeneinander -- beide bleiben stehen, die Werkzeuge scrollen in sich */
.d-arbeit {
  max-width: 1280px; margin: 24px auto 0;
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(290px, 31vw, 380px); gap: 16px; align-items: start;
}

/* ---------- Arbeitsflaeche ---------- */
.d-buehne-bereich { background: #fff; border-radius: var(--radius-gross); padding: 16px 16px 20px; min-width: 0; position: sticky; top: calc(var(--nav-h) + 12px); }
.d-leiste { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.d-leiste .umschalter { margin: 0; }
.d-leiste-rechts { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.d-icon {
  width: 44px; height: 44px; border: 0; border-radius: 50%; background: var(--bg-2);
  font-size: 20px; line-height: 1;
}
.d-icon:disabled { opacity: .35; cursor: default; }
.d-knopf-sekundaer {
  display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 980px; background: var(--bg-2); color: var(--text); font-size: 15px; font-weight: 500;
}
@media (hover: hover) { .d-knopf-sekundaer:hover { background: #e8e8ed; } }
.d-knopf-sekundaer[aria-pressed="true"] { background: var(--text); color: #fff; }

.d-buehne {
  margin-top: 16px; padding: 24px 16px; min-height: 260px;
  display: grid; place-items: center;
  background:
    linear-gradient(45deg, #f2f2f5 25%, transparent 25%, transparent 75%, #f2f2f5 75%) 0 0 / 20px 20px,
    linear-gradient(45deg, #f2f2f5 25%, transparent 25%, transparent 75%, #f2f2f5 75%) 10px 10px / 20px 20px,
    #fafafc;
  border-radius: 18px;
  overflow: hidden;
}
.d-karte {
  position: relative; overflow: hidden; touch-action: none;
  box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 24px 50px -20px rgba(0,0,0,.35);
}
.d-ebene { position: absolute; inset: 0; }
.d-sicher {
  position: absolute; pointer-events: none;
  border: 1px dashed rgba(0, 113, 227, .55);
}
.d-karte.dunkel .d-sicher { border-color: rgba(120, 180, 255, .6); }
.d-linie { position: absolute; pointer-events: none; background: #ff2d75; }
.d-linie-v { left: 50%; top: 0; bottom: 0; width: 1px; }
.d-linie-h { top: 50%; left: 0; right: 0; height: 1px; }

.d-el { position: absolute; cursor: move; -webkit-user-select: none; user-select: none; }
.d-el:focus-visible { box-shadow: none; outline: 2px solid var(--akzent); outline-offset: 2px; border-radius: 2px; }
.d-el-text { white-space: pre; line-height: 1.25; }
/* Nur der Textinhalt -- der Anfasser ist auch ein span und wurde sonst zum verzerrten Oval */
.d-el-text > span:first-child { display: block; }
/* Dreh-Anfasser: ein Punkt ueber dem Element, mit einem Strich verbunden */
.d-dreh-griff {
  position: absolute; left: 50%; top: -34px; width: 22px; height: 22px; margin-left: -11px; cursor: grab;
  display: grid; place-items: center;
}
.d-dreh-griff::before { content: ""; position: absolute; left: 50%; top: 17px; width: 1.5px; height: 16px; margin-left: -.75px; background: var(--akzent); }
.d-dreh-griff::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%; position: relative;
  background: var(--akzent); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
@media (pointer: coarse) {
  .d-dreh-griff { top: -44px; width: 36px; height: 36px; margin-left: -18px; }
  .d-dreh-griff::before { top: 27px; }
  .d-dreh-griff::after { width: 18px; height: 18px; }
}
.d-knopf-sekundaer[aria-pressed="true"]#hochKnopf { background: var(--text); color: #fff; }
.d-el img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }
.d-el img.dehnbar { object-fit: fill; }
.d-el.gewaehlt { outline: 1.5px solid var(--akzent); outline-offset: 1px; }
@media (hover: hover) { .d-el:hover:not(.gewaehlt) { outline: 1px dashed rgba(0, 113, 227, .7); outline-offset: 1px; } }
.d-griff {
  position: absolute; right: -11px; bottom: -11px; width: 22px; height: 22px; cursor: nwse-resize;
  display: grid; place-items: center;
}
.d-griff::after {
  content: ""; width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 2px solid var(--akzent); box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
@media (pointer: coarse) {
  /* Ganz ausserhalb des Elements: sonst verdeckt der Anfasser kleinen Text (Pruefbericht 2, I-04) */
  .d-griff { right: -34px; bottom: -34px; width: 36px; height: 36px; }
  .d-griff::after { width: 18px; height: 18px; }
}

.d-tipp, .d-hinweis-rand { text-align: center; font-size: 13px; color: var(--text-2); margin-top: 12px; }
.d-hinweis-rand { margin-top: 2px; }

/* ---------- 3D-Ansicht ---------- */
.d-3d { margin-top: 16px; padding: 40px 16px 28px; display: flex; flex-direction: column; align-items: center; gap: 22px; background: radial-gradient(circle at 50% 40%, #fff, #ececf0); border-radius: 18px; }
.d-dreh .dreh-seite { aspect-ratio: var(--verh); border-radius: var(--radius); overflow: hidden; box-shadow: 0 30px 60px -20px rgba(0,0,0,.4), 0 0 0 1px rgba(0,0,0,.06); }
.d-dreh .dreh-seite img { display: block; width: 100%; height: 100%; }
.d-klebeseite {
  display: grid; place-items: center; text-align: center;
  background: linear-gradient(180deg, #fbfbfc, #e9e9ec); color: #8e8e93; font-weight: 600; font-size: 15px;
}
.d-klebeseite small { font-weight: 400; }

/* ---------- Panel ---------- */
.d-panel {
  display: flex; flex-direction: column; gap: 12px;
  position: sticky; top: calc(var(--nav-h) + 12px);
  max-height: calc(100vh - var(--nav-h) - 112px); overflow-y: auto; overscroll-behavior: contain;
  border-radius: 22px; scrollbar-width: thin;
}
.d-gruppe { background: #fff; border-radius: 22px; padding: 18px 18px 20px; }
.d-gruppe h2 { font-size: 15px; font-weight: 600; margin-bottom: 12px; letter-spacing: 0; }
.d-vorlagen { display: flex; flex-wrap: wrap; gap: 8px; }
.d-vorlage, .d-aktionen button, .d-umschalt {
  min-height: 40px; padding: 0 14px; border-radius: 980px; border: 1.5px solid var(--linie); background: #fff;
  font-size: 14px; font-weight: 500;
}
.d-vorlage[aria-pressed="true"], .d-umschalt[aria-pressed="true"] { border-color: var(--akzent); box-shadow: 0 0 0 1px var(--akzent) inset; }
@media (pointer: coarse) { .d-vorlage, .d-aktionen button, .d-umschalt { min-height: 44px; } }

.d-farben { display: flex; flex-wrap: wrap; gap: 10px; }
.d-farben .swatch { min-width: 50px; }
.d-farben .swatch i { width: 34px; height: 34px; }
.d-eigene-farbe { cursor: pointer; }
.d-eigene-farbe input, .d-farbe input {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; background: none; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset;
}
.d-eigene-farbe input::-webkit-color-swatch-wrapper, .d-farbe input::-webkit-color-swatch-wrapper { padding: 0; }
.d-eigene-farbe input::-webkit-color-swatch, .d-farbe input::-webkit-color-swatch { border: 0; border-radius: 50%; }

.d-hinzu { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.d-hinzu-knopf {
  display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 14px;
  border: 1.5px solid var(--linie); border-radius: 14px; background: #fff; font-size: 15px; font-weight: 500; cursor: pointer;
}
@media (hover: hover) { .d-hinzu-knopf:hover { border-color: #86868b; } }
.d-hinzu-knopf span { width: 22px; text-align: center; font-weight: 700; color: var(--text-2); }
.d-datei { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.d-datei:focus-visible + * { outline: none; }
label.d-hinzu-knopf:focus-within { box-shadow: var(--fokus); }
.d-symbole { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.d-symbol-knopf {
  width: 52px; height: 44px; border: 1.5px solid var(--linie); border-radius: 12px; background: #fff;
  display: grid; place-items: center; padding: 6px;
}
@media (hover: hover) { .d-symbol-knopf:hover { border-color: #86868b; } }
.d-symbol-knopf img { max-width: 100%; max-height: 26px; }

.d-ebenen { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; }
.d-ebenen button {
  width: 100%; min-height: 40px; padding: 0 12px; text-align: left; border: 0; border-radius: 10px; background: none;
  font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
@media (hover: hover) { .d-ebenen button:hover { background: var(--bg-2); } }
.d-ebenen button[aria-current="true"] { background: #e8f0fe; color: #0b57d0; font-weight: 600; }
.d-leer { color: var(--text-2); font-size: 14px; }

#eigenschaftenInhalt { display: flex; flex-direction: column; gap: 14px; }
#eigenschaftenInhalt .feld > span { font-size: 13px; margin-bottom: 6px; }
#eigenschaftenInhalt textarea { min-height: 64px; }
#eigenschaftenInhalt select {
  width: 100%; font: inherit; font-size: 16px; padding: 11px 13px; border: 1.5px solid var(--linie); border-radius: 12px; background: #fff;
}
.d-reihe { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.d-zahl { display: flex; flex-direction: column; gap: 4px; flex: 1 1 70px; min-width: 70px; position: relative; }
.d-zahl span, .d-farbe span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.d-zahl input { width: 100%; font: inherit; font-size: 16px; padding: 9px 30px 9px 10px; border: 1.5px solid var(--linie); border-radius: 10px; }
.d-zahl em { position: absolute; right: 10px; bottom: 11px; font-style: normal; font-size: 12px; color: var(--text-2); pointer-events: none; }
.d-farbe { display: flex; flex-direction: column; gap: 4px; }
.d-umschalter { gap: 6px; }
.d-ausrichtung { margin: 0; width: 100%; }
.d-ausrichtung button { flex: 1; }
.d-masse .d-zahl { flex-basis: 60px; }
.d-aktionen { display: flex; flex-wrap: wrap; gap: 6px; }
.d-gefahr { color: var(--fehler); }
.d-info { font-size: 13px; color: var(--text-2); }
.d-info.ist-fehler { color: var(--fehler); }

/* ---------- Fuss ---------- */
.d-fuss {
  position: sticky; bottom: 0; z-index: 50; margin: 16px calc(var(--rand) * -1) 0;
  background: rgba(255,255,255,.88); -webkit-backdrop-filter: saturate(180%) blur(20px); backdrop-filter: saturate(180%) blur(20px);
  border-top: 1px solid rgba(0,0,0,.08);
}
.d-fuss-inner { max-width: 1280px; margin: 0 auto; padding: 12px var(--rand); display: flex; align-items: center; gap: 20px; }
/* Die Stueckzahl behaelt ihre Breite, der Preistext gibt nach -- sonst schrumpfte sie im halben Fenster auf null
   und der Preis lag ueber dem Plus-Knopf (Fehler vom 4.10.2026) */
.d-menge { flex: 0 0 auto; }
.d-menge .menge-zeile { justify-content: flex-start; }
.d-gross { max-width: 360px; display: flex; flex-direction: column; gap: 4px; }
.d-gross input { width: 100%; font: inherit; font-size: 16px; min-height: 44px; padding: 10px 13px; border: 1.5px solid var(--linie); border-radius: 12px; }
.d-gross input[aria-invalid="true"] { border-color: var(--fehler); }
.d-preis { flex: 1 1 0; min-width: 0; text-align: right; }
.d-preis .preis { font-size: 24px; }

/* ---------- Dialog ---------- */
.d-dialog {
  position: fixed; z-index: 160; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto;
  background: #fff; border-radius: 22px; box-shadow: 0 30px 80px rgba(0,0,0,.25);
  animation: dialogRein .35s var(--ease);
}
@keyframes dialogRein { from { opacity: 0; transform: translate(-50%, -46%); } }
.d-dialog-inhalt { padding: 16px 24px 24px; display: flex; flex-direction: column; gap: 16px; }
/* Der Abschlussknopf bleibt am unteren Rand des Fensters stehen, auch wenn der Inhalt laenger ist als der Bildschirm */
.d-dialog #absendenKnopf { position: sticky; bottom: 16px; z-index: 2; box-shadow: 0 0 0 12px #fff, 0 -14px 18px 6px rgba(255, 255, 255, .9); }
.d-angaben-gitter { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.d-angaben .hinweis, #angabenLink .hinweis { display: block; margin-top: 6px; }
.d-angaben .hinweis.ist-fehler { color: var(--fehler); }
@media (max-width: 480px) { .d-angaben-gitter { grid-template-columns: 1fr; } }
.d-zusammenfassung { background: var(--bg-2); border-radius: 14px; padding: 14px 16px; font-size: 15px; }
.d-erfolg { align-items: center; text-align: center; }
.d-haken { width: 64px; height: 64px; border-radius: 50%; background: #34c759; color: #fff; font-size: 34px; display: grid; place-items: center; }
.d-erfolg-titel { font-size: 20px; }

/* ---------- Schmal ---------- */
.d-gruppe-auswahl { box-shadow: 0 0 0 2px var(--akzent) inset; }
.d-material button { min-height: 56px; }
.d-material .seg-preis { font-size: 12px; white-space: normal; }
.d-regler { display: flex; flex-direction: column; gap: 6px; }
.d-regler span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.d-regler input { width: 100%; accent-color: var(--akzent); min-height: 32px; }
.d-regler small { font-size: 12px; color: var(--text-2); }
.d-vorschlaege { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.d-farben .d-vorschlaege { width: 100%; padding-top: 4px; }
.d-farben .d-vorschlaege::before { content: "Logofarben"; font-size: 12px; color: var(--text-2); margin-right: 4px; }
.d-farbvorschlag {
  width: 30px; height: 30px; border-radius: 50%; border: 0; padding: 0;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset;
}
@media (pointer: coarse) { .d-farbvorschlag { width: 40px; height: 40px; } }
@media (hover: hover) { .d-farbvorschlag:hover { transform: scale(1.1); } }
.d-logofarben { display: flex; flex-direction: column; gap: 8px; }
.d-logofarben > span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.d-logofarben i { width: 22px; height: 22px; border-radius: 50%; display: inline-block; box-shadow: 0 0 0 1px rgba(0,0,0,.15) inset; }

@media (max-width: 760px), (max-height: 560px) {
  .d-arbeit { grid-template-columns: 1fr; }
  /* Am Handy bleibt die Karte oben stehen, die Werkzeuge laufen darunter durch */
  .d-buehne-bereich {
    top: var(--nav-h); z-index: 20; margin: 0 calc(var(--rand) * -1); padding: 8px 10px 10px;
    border-radius: 0 0 22px 22px; box-shadow: 0 12px 24px -16px rgba(0,0,0,.35);
  }
  .d-buehne { margin-top: 8px; padding: 12px 8px; min-height: 0; }
  .d-hinweis-rand { display: none; }
  .d-panel { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 640px) {
  .designer { padding-top: calc(var(--nav-h) + 24px); }
  .d-leiste .d-seiten { order: 2; width: 100%; }
  .d-formate { width: 100%; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; }
  .d-formate::-webkit-scrollbar { display: none; }
  .d-formate button { flex: none; padding: 0 14px; }
  /* Am Handy klebt die Leiste nicht -- sie wuerde ein Drittel der Arbeitsflaeche verdecken */
  .d-fuss { position: static; margin-top: 12px; }
  .d-preis .preis-info { display: none; }
  .d-fuss-inner { flex-wrap: wrap; gap: 10px; }
  .d-menge { flex-basis: 100%; }
  .d-preis { text-align: left; flex: 1; }
  .d-tipp { display: none; }
}

/* ============ Desktop: der Designer fuellt genau das Fenster (4.10.2026) ============
   Vorher war die Seite bei 1280 x 800 um 224 px zu hoch, die Leiste unten verdeckte die Karte.
   Jetzt: Kopfzeile, Arbeitsflaeche und Abschluss teilen sich 100 % der Hoehe. Die Karte wird aus dem
   freien Platz berechnet; braucht die Werkzeugspalte mehr, scrollt nur sie -- nie die Seite. */
@media (min-width: 761px) and (min-height: 561px) {
  .designer {
    height: 100vh; height: 100dvh;
    padding: calc(var(--nav-h) + 12px) var(--rand) 0;
    display: grid; grid-template-rows: auto minmax(0, 1fr) auto; row-gap: 12px;
  }
  .d-kopf {
    width: 100%; max-width: 1280px; margin: 0 auto;
    display: flex; align-items: center; justify-content: space-between; gap: 16px; text-align: left;
  }
  .d-kopf h1 { font-size: clamp(22px, 2.3vw, 30px); }
  .d-kopf .sektion-sub { display: none; }
  .d-formate { margin: 0; }
  .d-arbeit { margin: 0 auto; width: 100%; height: 100%; min-height: 0; }
  .d-buehne-bereich { position: static; height: 100%; min-height: 0; display: flex; flex-direction: column; padding-bottom: 12px; }
  .d-buehne { flex: 1; min-height: 0; margin-top: 12px; padding: 16px; }
  .d-3d { flex: 1; min-height: 0; margin-top: 12px; padding: 24px 16px 20px; }
  .d-tipp { margin-top: 8px; font-size: 12px; }
  .d-hinweis-rand { display: none; }
  .d-panel { position: static; height: 100%; max-height: none; min-height: 0; }
  .d-fuss { position: static; margin: 0 calc(var(--rand) * -1); }
  .d-fuss-inner { padding-top: 10px; padding-bottom: 10px; }
}
/* Sehr niedrige Fenster (starker Zoom): Hinweiszeile weg, damit die Karte Platz behaelt */
@media (min-width: 761px) and (min-height: 561px) and (max-height: 640px) {
  .d-tipp { display: none; }
  .designer { row-gap: 8px; padding-top: calc(var(--nav-h) + 8px); }
}

/* Werkzeug-Spalten: schmal liegen beide untereinander wie bisher */
.d-spalte { display: contents; }

/* Breite Fenster: zwei feste Spalten nebeneinander -- links bearbeiten, rechts Aussehen. Jede scrollt
   fuer sich, falls ein langes Element (Text bearbeiten) mehr Platz braucht; die Seite scrollt nie.
   ACHTUNG (4.10.2026): Ein erster Versuch mit CSS-Mehrspalten (column-span) liess Chrome beim
   Auswaehlen eines Elements haengen -- deshalb feste Container statt Mehrspalten-Layout. */
@media (min-width: 960px) and (min-height: 561px) {
  .d-arbeit { grid-template-columns: minmax(0, 1fr) clamp(440px, 46vw, 620px); grid-template-rows: minmax(0, 1fr); }
  .d-panel { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: minmax(0, 1fr); gap: 12px; overflow: hidden; }
  /* Rechte Spalte: ist ein Element ausgewaehlt, zeigt sie dessen Eigenschaften statt der Karteneinstellungen */
  .d-panel:has(#eigenschaften:not([hidden])) #materialGruppe,
  .d-panel:has(#eigenschaften:not([hidden])) #hgGruppe { display: none; }
  .d-spalte { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow-y: auto; overscroll-behavior: contain; border-radius: 22px; scrollbar-width: thin; }
}
@media (min-width: 761px) and (min-height: 561px) {
  .d-gruppe { padding: 14px 14px 16px; }
  .d-gruppe h2 { margin-bottom: 8px; }
  .d-ebenen { max-height: 160px; }
}

/* Ausgewaehltes steht schmal zuoberst, obwohl es im HTML in der rechten Spalte liegt */
#eigenschaften { order: -1; }
.d-gruppe-kopf { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.d-gruppe-kopf h2 { margin: 0 !important; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-gruppe-kopf .link-knopf { min-height: 32px; font-size: 14px; flex: none; }
@media (min-width: 761px) and (min-height: 561px) {
  #eigenschaftenInhalt { gap: 10px; }
  #eigenschaftenInhalt textarea { min-height: 52px; }
  .d-aktionen button { min-height: 34px; padding: 0 10px; font-size: 13px; }
}

/* Desktop mit Maus: etwas dichtere Werkzeuge, damit beide Spalten ohne Scrollen reichen
   (gemessen 1280 x 800: links 124 px, rechts mit Text 117 px zu lang) */
@media (min-width: 960px) and (min-height: 561px) and (pointer: fine) {
  .d-gruppe { padding: 12px 12px 14px; }
  .d-gruppe h2 { margin-bottom: 6px; font-size: 14px; }
  .d-spalte, .d-panel { gap: 10px; }
  .d-hinzu { gap: 6px; }
  .d-hinzu-knopf { min-height: 40px; font-size: 14px; }
  .d-symbole { margin-top: 6px; gap: 6px; }
  .d-symbol-knopf { height: 38px; width: 46px; }
  #panelMeldung:empty { display: none; }
  .d-vorlage { min-height: 34px; font-size: 13px; }
  .d-ebenen { max-height: 112px; }
  .d-ebenen button { min-height: 34px; font-size: 13px; }
  .d-farben { gap: 8px; }
  #eigenschaftenInhalt { gap: 8px; }
  #eigenschaftenInhalt .feld > span { margin-bottom: 3px; font-size: 12px; }
  #eigenschaftenInhalt select { padding: 7px 10px; font-size: 15px; }
  #eigenschaftenInhalt textarea { min-height: 44px; padding: 8px 10px; font-size: 15px; }
  .d-zahl input { padding: 6px 26px 6px 8px; font-size: 15px; }
  .d-zahl em { bottom: 8px; }
  .d-umschalt { min-height: 32px; font-size: 13px; padding: 0 10px; }
  .d-ausrichtung button { min-height: 32px; font-size: 13px; }
  .d-aktionen { gap: 4px; }
  .d-aktionen button { min-height: 30px; padding: 0 9px; }
  .d-farbe input, .d-eigene-farbe input { width: 30px; height: 30px; }
}

/* Auch einspaltig ist die Arbeitsflaeche fest begrenzt -- sonst wuchs sie mit dem Inhalt und die Seite scrollte */
@media (min-width: 761px) and (min-height: 561px) {
  .d-arbeit { grid-template-rows: minmax(0, 1fr); }
  .d-panel { overflow-y: auto; }
}
/* Niedrige Fenster (z. B. 1280 x 720 = Full HD mit 150 % Zoom): weniger Luft */
@media (min-width: 761px) and (min-height: 561px) and (max-height: 760px) {
  .d-tipp { display: none; }
  .designer { row-gap: 8px; padding-top: calc(var(--nav-h) + 8px); }
  .d-kopf h1 { font-size: 22px; }
  .d-formate button { min-height: 34px; }
  .d-buehne { margin-top: 8px; padding: 10px; }
  .d-leiste .d-icon { width: 38px; height: 38px; }
  .d-leiste .d-knopf-sekundaer { min-height: 38px; }
  .d-leiste .umschalter button { min-height: 34px; }
  .d-fuss-inner { padding-top: 6px; padding-bottom: 6px; }
  .d-fuss .preis { font-size: 20px; }
}
@media (min-width: 960px) and (min-height: 561px) and (max-height: 760px) and (pointer: fine) {
  .d-gruppe { padding: 10px 12px 12px; }
  .d-hinzu-knopf { min-height: 36px; }
  .d-symbol-knopf { height: 34px; }
  .d-ebenen { max-height: 92px; }
  .d-material button { min-height: 46px; }
  .d-farben .swatch i { width: 28px; height: 28px; }
}

/* ============ Eigenschaften kompakt (4.10.2026) ============ */
.d-zeile { display: flex; align-items: center; gap: 6px; min-width: 0; }
.d-zeile.d-umbruch { flex-wrap: wrap; justify-content: space-between; }
.d-zeile select { flex: 1 1 auto; min-width: 0; }
.d-zeilen-name { font-size: 12px; font-weight: 600; color: var(--text-2); }
#eigenschaftenInhalt textarea { width: 100%; font: inherit; font-size: 15px; padding: 8px 10px; border: 1.5px solid var(--linie); border-radius: 10px; resize: vertical; }
#eigenschaftenInhalt textarea:focus, #eigenschaftenInhalt select:focus { outline: none; border-color: var(--akzent); box-shadow: var(--fokus); }
.d-wert {
  display: flex; align-items: center; gap: 3px; flex: 1 1 0; min-width: 58px;
  border: 1.5px solid var(--linie); border-radius: 10px; padding: 0 7px; background: #fff;
}
.d-wert:focus-within { border-color: var(--akzent); box-shadow: var(--fokus); }
.d-wert span { font-size: 12px; font-weight: 600; color: var(--text-2); }
.d-wert input { width: 100%; min-width: 0; border: 0; padding: 7px 0; font: inherit; font-size: 15px; background: none; -moz-appearance: textfield; appearance: textfield; }
.d-wert input::-webkit-inner-spin-button, .d-wert input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.d-wert input:focus { outline: none; }
.d-wert em { font-style: normal; font-size: 11px; color: var(--text-2); }
.d-masse .d-wert { min-width: 0; }
.d-farbe-mini { flex: none; display: grid; place-items: center; cursor: pointer; }
.d-farbe-mini input {
  width: 34px; height: 34px; padding: 0; border: 0; border-radius: 50%; overflow: hidden; background: none; cursor: pointer;
  box-shadow: 0 0 0 1.5px var(--linie);
}
.d-farbe-mini input::-webkit-color-swatch-wrapper { padding: 0; }
.d-farbe-mini input::-webkit-color-swatch { border: 0; border-radius: 50%; }
.d-werkzeuge { justify-content: space-between; }
.d-knopfgruppe { display: inline-flex; border: 1.5px solid var(--linie); border-radius: 10px; overflow: hidden; }
.d-knopfgruppe button { width: 36px; height: 34px; border: 0; background: #fff; font-size: 14px; display: grid; place-items: center; }
.d-knopfgruppe button + button { border-left: 1px solid var(--linie); }
.d-knopfgruppe button[aria-pressed="true"] { background: #e8f0fe; color: #0b57d0; }
.d-knopfgruppe svg, .d-aktionen svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.d-aktionen { display: flex; gap: 6px; flex-wrap: nowrap; }
.d-aktionen button { flex: 1; min-height: 34px; padding: 0; display: grid; place-items: center; border-radius: 10px; }
.d-aktionen .d-gefahr { color: var(--fehler); }
.d-info { margin: 0; }
@media (pointer: coarse) {
  .d-knopfgruppe button { width: 44px; height: 44px; }
  .d-aktionen button { min-height: 44px; }
  .d-wert input { padding: 11px 0; }
  .d-farbe-mini input { width: 40px; height: 40px; }
}

/* ============ Eigene Farbe: beschrifteter Knopf + Farbcode (4.10.2026) ============ */
.d-eigene { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.d-farben .d-eigene { flex: 1 1 100%; }
.d-eigene-knopf {
  position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  min-height: 34px; padding: 0 12px 0 6px; border: 1.5px solid var(--linie); border-radius: 980px; background: #fff;
  font-size: 13px; font-weight: 500; white-space: nowrap;
}
@media (hover: hover) { .d-eigene-knopf:hover { border-color: #86868b; } }
.d-eigene-knopf:focus-within { border-color: var(--akzent); box-shadow: var(--fokus); }
/* Der echte Farbwaehler liegt unsichtbar ueber dem ganzen Knopf -- ein Klick irgendwo darauf oeffnet ihn */
.d-eigene-knopf input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.d-eigene-knopf i { width: 22px; height: 22px; border-radius: 50%; flex: none; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #d2d2d7; }
.d-hex {
  flex: 1 1 0; min-width: 0; max-width: 104px; min-height: 34px; padding: 0 10px;
  border: 1.5px solid var(--linie); border-radius: 10px; font: inherit; font-size: 13px;
  font-variant-numeric: tabular-nums; text-transform: uppercase; letter-spacing: .03em;
}
.d-hex:focus { outline: none; border-color: var(--akzent); box-shadow: var(--fokus); }
.d-hex[aria-invalid="true"] { border-color: var(--fehler); }
.d-haken { display: flex; align-items: center; gap: 8px; width: 100%; font-size: 13px; cursor: pointer; min-height: 32px; }
.d-haken input { width: 18px; height: 18px; accent-color: var(--akzent); }
.d-farben .d-info { width: 100%; font-size: 12px; }
.d-hilfe, .d-hilfe-immer { font-size: 12px; color: var(--text-2); margin: -4px 0 8px; line-height: 1.35; }
.d-hilfe-immer { margin: 0; font-size: 13px; }
.d-gruppe-leer { border: 1.5px solid var(--linie); }
/* Deine Angaben: ein schlichtes Formular fuer die Texte der Karte */
.d-schnell { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.d-schnell input {
  width: 100%; min-height: 36px; padding: 6px 11px; font: inherit; font-size: 15px; color: var(--text);
  border: 1.5px solid var(--linie); border-radius: 10px; background: #fff;
}
.d-schnell input:focus { outline: none; border-color: var(--akzent); box-shadow: var(--fokus); }
.d-schnell-logo {
  display: flex; align-items: center; justify-content: center; min-height: 36px; padding: 0 12px; cursor: pointer;
  border: 1.5px dashed var(--akzent); border-radius: 10px; color: var(--akzent); font-size: 14px; font-weight: 500;
}
@media (hover: hover) { .d-schnell-logo:hover { background: rgba(0, 113, 227, .06); } }
/* Zahlenfelder: zugeklappt, bis jemand sie braucht */
.d-fein > summary { cursor: pointer; font-size: 13px; color: var(--text-2); padding: 4px 0; list-style-position: inside; }
.d-fein[open] > summary { margin-bottom: 6px; }
.d-fein > .d-zeile + .d-zeile { margin-top: 6px; }
/* Vier Masse passen nicht in eine Zeile (die Werte waren nicht mehr lesbar): zwei mal zwei */
.d-masse:has(> :nth-child(4)) { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
/* Ragt ein Text oder Logo ueber den Kartenrand, wird es dort abgeschnitten -- deutlich zeigen */
.d-el.d-el-aus { outline: 2px dashed var(--fehler) !important; outline-offset: 1px; }
.d-pruefung { list-style: none; margin: 0; padding: 12px 14px; border-radius: 14px; background: #fff8e6; font-size: 14px; display: flex; flex-direction: column; gap: 6px; }
.d-pruefung li { padding-left: 22px; position: relative; }
.d-pruefung li::before { content: "!"; position: absolute; left: 0; top: 1px; width: 16px; height: 16px; border-radius: 50%; background: #b25000; color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.d-pruefung li.ernst { color: var(--fehler); }
.d-pruefung li.ernst::before { background: var(--fehler); }
.d-dialog .feld textarea { min-height: 64px; }
/* Erklaerzeilen kosten Hoehe: bei niedrigen Fenstern weichen sie, damit alles ohne Scrollen passt */
@media (min-width: 761px) and (min-height: 561px) and (max-height: 860px) { .d-hilfe { display: none; } }
@media (pointer: coarse) { .d-eigene-knopf, .d-hex { min-height: 44px; } }

/* Sehr niedrige Fenster (1024 x 640 = 1280 x 800 mit 125 % Zoom): gemessen 127 und 68 px zu lang.
   Hinweise und Platzhalter weichen, Listen werden kuerzer -- die Bedienelemente bleiben alle da. */
@media (min-width: 960px) and (min-height: 561px) and (max-height: 680px) {
  #leerHinweis { display: none; }
  .d-farben .d-info, .d-material .seg-preis { display: none; }
  .d-material button { min-height: 36px; }
  .d-farben .swatch { font-size: 11px; min-width: 44px; }
  .d-farben .swatch i { width: 26px; height: 26px; }
  .d-ebenen { max-height: 62px; }
  .d-vorlage { min-height: 30px; }
  .d-gruppe { padding: 8px 10px 10px; }
  .d-hinzu-knopf { min-height: 32px; }
  .d-symbol-knopf { height: 32px; }
}

/* Schriftgroesse braucht Platz fuer drei Stellen plus Einheit */
.d-zeile select + .d-wert { flex: 0 0 92px; }

/* Zwei Materialien teilen sich die Breite (das Raster hatte noch drei Spalten -- die Knoepfe waren zu schmal fuer ihren Text) */
.d-material { grid-template-columns: 1fr 1fr; }

/* Lange Texte in der Elementliste werden gekuerzt, nicht seitlich gescrollt */
.d-ebenen { overflow-x: hidden; }

/* Drehung: Winkelfeld und der Knopf fuer die Vierteldrehung in einer Zeile */
.d-drehung { display: flex; align-items: center; gap: 6px; }
.d-drehung .d-wert { flex: 0 0 96px; }
.d-drehung .d-umschalt { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.d-drehung .d-umschalt svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ============ Handy: erst das Wichtige, Abschluss immer erreichbar (Praxistest 6.10.2026) ============
   Reihenfolge unter der Karte: Angaben bzw. ausgewaehltes Element, dann "Auf die Karte setzen", dann der Rest.
   Die Abschlussleiste bleibt am unteren Rand stehen -- vorher lag sie 2,4 Bildschirme weiter unten. */
@media (max-width: 760px), (max-height: 560px) {
  .d-panel { display: flex; flex-direction: column; gap: 12px; }
  #eigenschaften, #leerHinweis { order: 1; }
  #hinzuGruppe { order: 2; }
  #materialGruppe { order: 3; }
  #hgGruppe { order: 4; }
  .d-panel .d-gruppe { order: 5; }
  .d-panel #eigenschaften, .d-panel #leerHinweis { order: 1; }
  .d-panel #hinzuGruppe { order: 2; }
  .d-panel #materialGruppe { order: 3; }
  .d-panel #hgGruppe { order: 4; }
  .designer { padding-bottom: 0; }
  .d-fuss { position: sticky; bottom: 0; z-index: 30; margin-top: 12px; box-shadow: 0 -8px 24px -16px rgba(0, 0, 0, .35); }
  .d-fuss-inner { flex-wrap: nowrap; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); }
  .d-menge { flex: 0 0 auto; }
  .d-menge #dMehr, .d-fuss .artikel-nr { display: none; }
  .d-menge .stepper button { width: 30px; }
  .d-menge .stepper input { width: 32px; padding: 0; }
  .d-gross input { width: 130px; }
  .d-preis { flex: 1 1 0; min-width: 0; text-align: right; }
  .d-fuss .preis { font-size: 18px; white-space: nowrap; }
  .d-fuss .btn { padding: 0 12px; font-size: 13px; white-space: nowrap; }
  .d-fuss .preis { font-size: 17px; }
}

/* Niedrige Fenster: Material als schlanke Auswahl, damit "Deine Angaben" und die Kartenfarbe gemeinsam Platz haben */
@media (min-width: 960px) and (min-height: 561px) and (max-height: 900px) {
  .d-material .seg-preis { display: none; }
  .d-material button { min-height: 38px; }
  .d-schnell input, .d-schnell-logo { min-height: 34px; }
  .d-schnell { gap: 5px; margin-top: 6px; }
  #materialGruppe h2, #hgGruppe .d-hilfe, #hgGruppe .d-info { display: none; }
}

@media (min-width: 960px) and (min-height: 561px) and (max-height: 760px) { #leerHinweis .d-hilfe-immer { display: none; } }
@media (min-width: 960px) and (min-height: 561px) and (max-height: 760px) { .d-schnell input, .d-schnell-logo { min-height: 30px; font-size: 14px; } .d-schnell { gap: 4px; } }

/* iOS zoomt in jedes Feld mit weniger als 16 px Schrift hinein und bleibt gezoomt (Pruefbericht 2) */
@media (pointer: coarse), (max-width: 760px), (max-height: 560px) {
  .designer input, .designer select, .designer textarea, .d-dialog input, .d-dialog textarea { font-size: 16px !important; }
}

/* ============ Handy im Querformat: Karte links, Werkzeuge rechts ============
   Breit, aber niedrig. Die Karte bleibt links stehen und nutzt die Hoehe, die Werkzeuge scrollen rechts daneben,
   die Abschlussleiste bleibt unten. Ueberschrift und Tipp-Zeile entfallen -- jede Zeile Hoehe zaehlt. */
@media (max-height: 560px) and (min-width: 600px) {
  .designer { padding-top: calc(var(--nav-h) + 8px); }
  .d-kopf { display: flex; align-items: center; margin-bottom: 6px; }
  .d-kopf h1, .d-kopf .sektion-sub { display: none; }
  .d-formate { width: 100%; margin-top: 0; }
  .d-formate button { min-height: 34px; height: 34px; font-size: 13px; }
  .d-arbeit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(250px, 36%); gap: 12px; align-items: start; }
  .d-buehne-bereich { position: sticky; top: calc(var(--nav-h) + 8px); z-index: 20; margin: 0; padding: 8px 10px 10px; border-radius: 22px; box-shadow: none; }
  .d-leiste { flex-wrap: wrap; gap: 4px 6px; }
  .d-leiste .d-seiten { order: 0; width: auto; }
  .d-leiste .d-seiten button, .d-leiste .d-knopf-sekundaer { min-height: 34px; height: 34px; padding: 0 10px; font-size: 13px; }
  .d-leiste .d-icon { width: 34px; height: 34px; min-height: 34px; }
  .d-leiste-rechts { gap: 4px; }
  .d-buehne { margin-top: 6px; padding: 8px; min-height: 0; }
  .d-tipp, .d-hinweis-rand { display: none; }
  .d-panel { position: static; max-height: none; overflow: visible; min-width: 0; }
  .d-hinzu-knopf { min-width: 0; }
  .d-fuss-inner { padding-top: 5px; padding-bottom: calc(5px + env(safe-area-inset-bottom)); }
  .d-fuss .btn { min-height: 38px; height: 38px; }
  .d-fuss .preis-info { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
/* Kleine Handys quer (z. B. 667 px breit): die Werkzeugzeile bleibt einzeilig und laesst sich seitlich wischen --
   eine zweite Zeile wuerde der Karte die Hoehe nehmen */
@media (max-height: 560px) and (min-width: 600px) and (max-width: 780px) {
  .d-leiste { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .d-leiste::-webkit-scrollbar { display: none; }
  .d-leiste > * { flex: 0 0 auto; }
}

/* ============ Handy hochkant: Karte gross, Werkzeuge in einer Leiste unten (MOBILE-KONZEPT.md, Stufe 4) ============
   Vorher (414 x 719): Seite 1954 px hoch, sieben Werkzeugbloecke untereinander, Karte begann bei 361 px.
   Jetzt steht immer nur ein Werkzeug unter der Karte; gewaehlt wird in der Leiste ueber dem Abschluss.
   Die Seite scrollt weiterhin normal -- kein fester Fensteraufbau, der in Safari anders rechnen koennte. */
.d-werkzeugleiste { display: none; }
@media (max-width: 599px) {
  /* Die Ueberschrift bleibt fuer Vorleseprogramme, belegt aber keine Hoehe mehr */
  .d-kopf h1 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .d-kopf .sektion-sub { display: none; }
  .designer { padding-top: calc(var(--nav-h) + 4px); }
  .d-formate { margin-top: 0; }
  .d-arbeit { margin-top: 4px; gap: 8px; }
  .d-leiste { gap: 6px; }
  .d-buehne-bereich { padding-bottom: 6px; }
  .d-buehne { padding: 4px 0; }
  .d-panel[data-werkzeug="angaben"] .d-gruppe[data-w]:not([data-w="angaben"]),
  .d-panel[data-werkzeug="hinzu"] .d-gruppe[data-w]:not([data-w="hinzu"]),
  .d-panel[data-werkzeug="farbe"] .d-gruppe[data-w]:not([data-w="farbe"]),
  .d-panel[data-werkzeug="vorlage"] .d-gruppe[data-w]:not([data-w="vorlage"]),
  .d-panel[data-werkzeug="elemente"] .d-gruppe[data-w]:not([data-w="elemente"]),
  .d-panel.hat-auswahl .d-gruppe[data-w] { display: none; }
  .d-ebenen { max-height: none; }
  /* Gleich hoch bei jedem Werkzeug: sonst springt die Seite beim Wechsel auf ein kurzes Werkzeug */
  .d-panel { min-height: 300px; justify-content: flex-start; }
  .d-werkzeugleiste {
    display: flex; gap: 4px; padding: 6px 8px 0; max-width: 1280px; margin: 0 auto;
  }
  .d-werkzeugleiste button {
    flex: 1 1 0; min-width: 0; min-height: 44px; padding: 0 2px; border: 0; border-radius: 12px; background: none;
    font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .d-werkzeugleiste button[aria-pressed="true"] { background: var(--text); color: #fff; }
  .d-fuss-inner { padding-top: 6px; }

  /* Produkt-Reiter: zwei Zeilen mit je zwei Reitern statt einer Zeile zum Wischen (Pruefbericht 2, I-11; D-133) */
  .d-formate { display: grid; grid-template-columns: 1fr 1fr; width: 100%; overflow: visible; border-radius: 24px; }
  .d-formate button { padding: 0 8px; min-width: 0; }

  /* Jedes Werkzeug passt zwischen Karte und Leiste (gemessen 414 x 719: 178 px frei) -- Rueckmeldung Inhaber 9.10.2026.
     Der Titel steht schon in der Leiste, die Erklaerzeilen weichen, Felder stehen zu zweit nebeneinander. */
  .d-panel .d-gruppe[data-w] { padding: 8px; }
  .d-panel .d-gruppe[data-w] > h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .d-panel .d-gruppe[data-w] .d-hilfe, .d-panel .d-gruppe[data-w] .d-hilfe-immer, #panelMeldung:empty { display: none; }
  .d-schnell { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 0; }
  .d-schnell input, .d-schnell-logo { min-height: 44px; min-width: 0; }
  .d-schnell > :last-child:nth-child(odd) { grid-column: 1 / -1; }
  .d-hinzu { gap: 6px; }
  .d-hinzu-knopf { min-height: 44px; min-width: 0; }
  .d-symbole { margin-top: 6px; }
  .d-farben { gap: 6px; }
  .d-farben .swatch { min-width: 0; width: 46px; font-size: 11px; }
  .d-farben .d-info { margin-top: -2px; }
  .d-ebenen { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 6px; }
  .d-ebenen li { min-width: 0; }
  .d-ebenen button { min-height: 44px; }
}
/* Schmale Handys: fuenf Beschriftungen brauchen jede Breite ("Hinzufuegen" wurde bei 375 px gekuerzt) */
@media (max-width: 399px) {
  .d-werkzeugleiste { gap: 2px; padding-left: 4px; padding-right: 4px; }
  .d-werkzeugleiste button { font-size: 12px; padding: 0; }
}
/* Niedrige Handys (z. B. 375 x 553): Karte, Werkzeugleiste und Abschluss fuellen den Bildschirm schon allein --
   die Karte bleibt dort nicht stehen, damit das Werkzeug beim Scrollen ganz zu sehen ist */
@media (max-width: 599px) and (max-height: 619px) {
  .d-buehne-bereich { position: static; }
}

/* Logo: die Automatik sagt, was sie getan hat, und laesst sich mit einem Tipp zuruecknehmen (D-134) */
.d-info.d-auto { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px; border-radius: 12px; background: #e8f0fe; color: var(--text); }
.d-info.d-auto .link-knopf { flex: none; min-height: 44px; font-weight: 600; }

/* Ausgewaehltes Element am Handy: ein Satz zur Bedienung und beschriftete Knoepfe statt nur Symbole
   (Rueckmeldung Inhaber 9.10.2026: Auswaehlen, Verschieben, Aendern ist nicht intuitiv) */
.d-auswahl-tipp, .d-aktionen button span { display: none; }
@media (max-width: 599px) {
  .d-auswahl-tipp { display: block; margin: 0 0 8px; font-size: 12px; line-height: 1.35; color: var(--text-2); }
  .d-aktionen button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: 52px; min-width: 0; padding: 4px 0; }
  .d-aktionen button span { display: block; font-size: 11px; line-height: 1.2; text-align: center; }
  .d-aktionen { align-items: stretch; }
}
