/*
  Blechmodul-Werkbank (Designuebergabe 25.09.2026): feste Zonen statt
  Schwebefelder.

  WARUM EINE EIGENE DATEI
  -----------------------
  blech-modul.css traegt die Formensprache der einzelnen Bausteine (Knopf,
  Liste, Feld, Skizze ...). Diese Datei ordnet sie in ZONEN an und wird
  danach geladen (base.html): Kopf 44 / Befehlszeile 52 / Liste - Buehne -
  Panel / Fuss 56, am Handy Teil oben und ein Bottom Sheet mit drei
  Rasthoehen. Die Klassen der Bausteine bleiben (Vertraege der DOM-Tests),
  die Zonen kommen als eigene Klassen dazu (bm-werkbank, bm-zone-*,
  bm-befehlszeile, bm-modusleiste, bm-fuss, bm-sheet-*).

  Die Seite rollt nie (overflow: hidden an der Huelle); Liste und Panel
  rollen intern. Absolut positionierte Kinder mit `grid-area: buehne`
  (Flaeche 2D, Skizze, Abwicklung, Rueckfragen, Einfuehrung) haben den
  Buehnenbereich als Bezug - sie uebernehmen die Buehne, nicht die Seite.

  Zwischenbreiten (data-breite am Editor, blechModulWerkbank.breiteStufe):
    s < 768 Handy | m 768-1179 Befehle nur Icon | l 1180-1359 Befehle mit
    Wort, Moduswerkzeuge nur Icon | xl 1360-1599 alles mit Wort | xxl >= 1600.
*/

/* ==========================================================================
   1. Huelle im Blechmodus: Kopf als Balken, Inhalt zwischen Kopf und Fuss
   ========================================================================== */
.ai-werkbank.ai-dialog-blech > .ai-dialog-kopf {
    top: 0;
    left: 0;
    right: 0;
    height: var(--ai-kopf-hoehe);
    padding: 0 8px 0 12px;
    align-items: center;
    flex-wrap: nowrap;
    background: var(--bm-kopf-bg);
    border-bottom: 1px solid var(--bm-trenner);
    pointer-events: auto;
}

.ai-werkbank.ai-dialog-blech .ai-kopf-links,
.ai-werkbank.ai-dialog-blech .ai-kopf-rechts {
    min-height: 0;
    height: calc(var(--ai-kopf-hoehe) - 1px);
    padding: 0;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.ai-werkbank.ai-dialog-blech .ai-dialog-kopf h2 {
    font-size: var(--bm-t-15);
}

/* Die Phasen bleiben im Balken (nicht in eine zweite Zeile umbrechen). */
.ai-werkbank.ai-dialog-blech .ai-dialog-schritte.nocad-progress {
    order: 0;
    flex: 0 1 auto;
    flex-basis: auto;
}

/* Die Seiten beginnen unter dem Kopf-Balken (nicht mehr unter einem Schwebefeld). */
.ai-werkbank.ai-dialog-blech .bm-schnellteile {
    margin-top: 16px;
}

.ai-werkbank.ai-dialog-blech .bm-textweg-halter {
    padding: 48px 16px 24px;
}

/* Uebergabe "Ihr Teil aus der Beschreibung" (26.09.2026: Christian "sieht furchtbar aus" -
   Text klebte am Rand, der Hauptknopf hatte gar keine Gestaltung). */
.ai-werkbank.ai-dialog-blech .bm-textweg {
    gap: 16px;
    padding: 28px 32px;
    border: 1px solid var(--bm-trenner);
    border-radius: 16px;
    background: var(--bm-liste-bg, #17151d);
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
    color: var(--text-primary, #f2f3f5);
}

.ai-werkbank.ai-dialog-blech .bm-textweg > .bm-feld-titel {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
}

.ai-werkbank.ai-dialog-blech .bm-textweg .bm-feld-hilfe {
    margin: 0;
    color: var(--bm-text-3);
    font-size: 0.95rem;
    line-height: 1.5;
}

.ai-werkbank.ai-dialog-blech .bm-textweg-vermerkkasten,
.ai-werkbank.ai-dialog-blech .bm-textweg-hinweiskasten {
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    font-size: 0.9rem;
}

.ai-werkbank.ai-dialog-blech .bm-textweg-wahl {
    flex: 1 1 180px;
    color: var(--bm-text-3);
}

.ai-werkbank.ai-dialog-blech .bm-textweg-wahl select,
.ai-werkbank.ai-dialog-blech .bm-textweg-wahl input {
    width: 100%;
}

.ai-werkbank.ai-dialog-blech .bm-textweg-knoepfe {
    margin-top: 4px;
    padding-top: 16px;
    border-top: 1px solid var(--bm-trenner);
}

.ai-werkbank.ai-dialog-blech .bm-textweg-knoepfe button {
    padding: 0 20px;
    border-radius: var(--ai-knopf-radius, 10px);
    font-size: var(--bm-t-14, 14px);
}

/* Hauptknopf wie ueberall im Blechmodul: gelber Marken-Verlauf, dunkle Schrift. */
.ai-werkbank.ai-dialog-blech .bm-textweg-knoepfe .bm-textweg-editor {
    order: 2;
    border: 0;
    background: var(--bm-cta-bg);
    color: var(--bm-cta-text);
    font-weight: 600;
}

.ai-werkbank.ai-dialog-blech .bm-textweg-status {
    margin: 0;
    color: var(--bm-text-3);
    font-size: 0.9rem;
}

.ai-werkbank.ai-dialog-blech .ai-dialog .nocad-progress__bar,
.ai-werkbank.ai-dialog-blech .nocad-progress__bar {
    padding-block: 3px;
}

/* Inhalt beginnt unter dem Kopf; ohne eigenen Fuss endet er ueber dem Fuss der Huelle. */
.ai-werkbank.ai-dialog-blech > .ai-dialog-inhalt {
    top: var(--ai-kopf-hoehe);
    bottom: var(--bm-fuss-hoehe);
}

.ai-werkbank.ai-dialog-blech.bm-editor-modus > .ai-dialog-inhalt,
.ai-werkbank.ai-dialog-blech.bm-frei-modus > .ai-dialog-inhalt {
    bottom: 0;
}

/* Der Editor und das freie Zeichnen fuehren ihren Fuss selbst (Zurueck steht dort). */
.ai-werkbank.ai-dialog-blech.bm-editor-modus > .ai-dialog-fuss,
.ai-werkbank.ai-dialog-blech.bm-frei-modus > .ai-dialog-fuss {
    display: none;
}

/* Schnellteile und Uebergabe: der Fuss der Huelle als Leiste ueber die ganze Breite
   (nichts liegt mehr ueber den Kacheln). */
.ai-werkbank.ai-dialog-blech > .ai-dialog-fuss {
    left: 0;
    right: 0;
    bottom: 0;
    height: var(--bm-fuss-hoehe);
    max-width: none;
    padding: 0 12px;
    align-items: center;
    background: var(--bm-fuss-bg);
    border: 0;
    border-top: 1px solid var(--bm-trenner);
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.ai-werkbank.ai-dialog-blech > .ai-dialog-status:not(:empty) {
    bottom: calc(var(--bm-fuss-hoehe) + 8px);
}

.ai-werkbank.ai-dialog-blech .bm-editor-halter {
    position: absolute;
    inset: 0;
}

/* "Von vorne beginnen": der Knopf in der Rueckfrage ist zerstoerend - rot. */
.ai-werkbank #ai-neu-ja {
    background: var(--ai-rolle-fehler);
    border-color: var(--ai-rolle-fehler);
    color: #ffffff;
}

/* Menue "⋯" (Handy): am Desktop verborgen. */
.ai-werkbank .ai-kopf-menue-knopf {
    display: none;
}

/* Server-Vorschau: Sekundenzaehler, Satz zur Dauer, Weg zurueck. */
.ai-werkbank .ai-vorschau-sekunden {
    font-variant-numeric: tabular-nums;
    color: var(--bm-text-3);
}

.ai-werkbank .ai-vorschau-sekunden:empty {
    display: none;
}

.ai-werkbank .ai-vorschau-dauer {
    display: block;
    flex-basis: 100%;
    margin-top: 4px;
    font-size: var(--bm-t-13);
    color: var(--bm-text-3);
}

.ai-werkbank .ai-vorschau-abbrechen {
    margin-top: 8px;
    min-height: var(--ai-touch);
}

#ai-vorschau-laeuft:not([hidden]) {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

/* ==========================================================================
   2. Editor: Grid mit festen Zonen
   ========================================================================== */
.bm-editor.bm-werkbank {
    --bm-liste-spalte: var(--bm-liste-leiste);
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: var(--bm-liste-spalte) minmax(0, 1fr) var(--ai-panel-breite);
    grid-template-rows: var(--bm-befehl-hoehe) minmax(0, 1fr) var(--bm-fuss-hoehe);
    grid-template-areas:
        "befehl befehl befehl"
        "liste buehne panel"
        "fuss fuss fuss";
    overflow: hidden;
    background: var(--bm-buehne-bg);
    color: var(--text-primary);
    font-family: var(--bm-schrift);
}

.bm-editor.bm-werkbank[data-liste="offen"] {
    --bm-liste-spalte: var(--bm-liste-breite);
}

/* --- Befehlszeile (EINE, mit Gruppen) ---------------------------------------- */
.bm-editor.bm-werkbank > .bm-befehlszeile {
    grid-area: befehl;
    position: relative;
    inset: auto;
    z-index: 3;
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    align-items: center;
    gap: 0;
    min-width: 0;
    padding: 0 8px;
    background: var(--bm-befehl-bg);
    border-bottom: 1px solid var(--bm-trenner);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    pointer-events: auto;
}

.bm-editor.bm-werkbank > .bm-befehlszeile[hidden] {
    display: none;
}

.bm-editor.bm-werkbank > .bm-befehlszeile::-webkit-scrollbar {
    display: none;
}

.bm-befehlszeile > .bm-werkzeugleiste {
    flex: 0 0 auto;
    gap: 2px;
    padding: 0 6px;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    overflow: visible;
}

.bm-befehlszeile > .bm-werkzeugleiste + .bm-werkzeugleiste {
    border-left: 1px solid var(--bm-trenner);
}

.bm-befehlszeile > .bm-werkzeugleiste[hidden] {
    display: none;
}

/* Tipps und "?" rechts in der Befehlszeile. */
.bm-befehlszeile > .bm-assistent {
    position: static;
    margin-left: auto;
    padding: 0 0 0 8px;
    background: none;
    border: 0;
    border-left: 1px solid var(--bm-trenner);
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

/* --- Moduswechsel-Leiste (violett): 2D hat die Buehne ------------------------- */
.bm-modusleiste {
    grid-area: befehl;
    z-index: 3;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 0 8px 0 16px;
    background: var(--bm-modus-bg);
    border-bottom: 1px solid var(--bm-modus-rand);
    box-shadow: inset 0 -2px 0 rgba(158, 39, 251, 0.35);
    color: var(--text-primary);
}

.bm-modusleiste[hidden] {
    display: none;
}

.bm-modus-kopf {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.bm-modus-titel {
    margin: 0;
    font-size: var(--bm-t-14);
    font-weight: 600;
    white-space: nowrap;
}

.bm-modus-hilfe {
    margin: 0;
    overflow: hidden;
    font-size: var(--bm-t-12);
    color: var(--bm-text-3);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bm-modus-hilfe[hidden],
.bm-modus-werkzeuge[hidden],
.bm-modus-knoepfe > [hidden] {
    display: none;
}

.bm-modus-werkzeuge {
    display: flex;
    gap: 2px;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.bm-modus-knoepfe {
    display: flex;
    gap: 8px;
    margin-left: auto;
    flex: 0 0 auto;
}

/* --- Liste "Ihr Teil" links (einklappbar) ------------------------------------- */
.bm-editor.bm-werkbank > .bm-zone-liste {
    grid-area: liste;
    position: relative;
    z-index: 2;
    display: flex;
    min-width: 0;
    min-height: 0;
    background: var(--bm-liste-bg);
    border-right: 1px solid var(--bm-trenner);
}

.bm-zone-liste[data-offen="nein"] > .bm-merkmalsliste,
.bm-zone-liste[data-offen="ja"] > .bm-listenleiste {
    display: none;
}

.bm-listenleiste {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    padding: 8px 0;
    overflow-y: auto;
}

.bm-listenleiste .bm-icon {
    width: 20px;
    height: 20px;
}

.bm-listenleiste .bm-zaehler[hidden] {
    display: none;
}

.bm-zaehler-zahl {
    position: absolute;
    right: 2px;
    bottom: 2px;
    min-width: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background: #2a2f36;
    color: var(--text-primary);
    font-size: 10px;
    line-height: 16px;
    text-align: center;
}

/* Roter Punkt: etwas muss geaendert werden; gelber Punkt: Beispielwert offen. */
.bm-listenleiste[data-punkt="fehler"] > .bm-liste-umschalter::after,
.bm-listenleiste[data-punkt="beispiel"] > .bm-liste-umschalter::after {
    content: "";
    position: absolute;
    top: 6px;
    right: 6px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--ai-rolle-fehler);
}

.bm-listenleiste[data-punkt="beispiel"] > .bm-liste-umschalter::after {
    background: var(--ai-rolle-hinweis);
}

.bm-editor.bm-werkbank .bm-zone-liste > .bm-merkmalsliste {
    position: relative;
    inset: auto;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    padding: 10px 12px 16px;
    overflow: auto;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.bm-liste-kopf {
    position: sticky;
    top: -10px;
    z-index: 1;
    margin: -10px -12px 6px;
    padding: 6px 6px 6px 12px;
    background: var(--bm-liste-bg);
}

.bm-liste-kopf .bm-feld-titel {
    margin: 0;
    font-size: var(--bm-t-14);
}

.bm-liste-zu {
    min-width: var(--ai-touch);
    min-height: var(--ai-touch);
    padding: 0;
    color: var(--bm-text-3);
}

.bm-liste-zu .bm-icon {
    width: 18px;
    height: 18px;
}

/* --- Buehne ------------------------------------------------------------------- */
.bm-editor.bm-werkbank > .bm-editor-buehne {
    grid-area: buehne;
    position: relative;
    inset: auto;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    background: var(--bm-buehne-bg);
}

.bm-werkbank .bm-editor-buehne > .bm-ansicht,
.bm-werkbank .bm-ansicht-buehne {
    position: absolute;
    inset: 0;
}

.bm-werkbank .bm-ansicht-meldung {
    top: 16px;
}

.bm-werkbank .bm-ansicht-hinweis {
    top: auto;
    right: auto;
    bottom: 64px;
    left: 50%;
    transform: translateX(-50%);
}

.bm-werkbank .bm-ansicht-vorschau,
.bm-editor.bm-werkbank .bm-ansicht-vorschau {
    top: 10px;
    right: 12px;
    bottom: auto;
    left: auto;
    max-width: 260px;
    text-align: right;
}

.bm-werkbank .bm-ansicht-liste {
    left: 12px;
    bottom: 12px;
    width: 230px;
    max-height: 45%;
}

/* Draufsicht, wenn WebGL fehlt: die Zeichnung fuellt die Buehne. */
.bm-draufsicht {
    position: absolute;
    inset: 48px 16px 16px;
    width: calc(100% - 32px);
    height: calc(100% - 64px);
}

.bm-draufsicht[hidden] {
    display: none;
}

.bm-draufsicht-kante {
    fill: none;
    stroke: var(--bm-linie);
    stroke-width: 1.5;
    vector-effect: non-scaling-stroke;
}

.bm-draufsicht-kante.bm-draufsicht-rund {
    stroke: var(--bm-linie-2);
    stroke-dasharray: 3 3;
}

/* Verkleinern, Vergroessern, Ganzes Teil - unten rechts auf der Buehne. */
.bm-buehne-knoepfe {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 4;
    display: flex;
    gap: 6px;
}

/* Masszahlen am Teil (3D): Laschenlaenge und Winkel. */
.bm-masse-3d .bm-mass-zahl.bm-mass-lasche {
    border-color: var(--bm-mass-x);
}

.bm-masse-3d .bm-mass-zahl.bm-mass-winkel {
    border-color: var(--bm-mass-y);
    border-radius: 999px;
}

.bm-masse-3d .bm-mass-zahl.bm-mass-beispiel {
    border-style: dashed;
    border-color: #b9a300;
    color: #5b6470;
    font-style: italic;
}

/* Masszahlen: die Zahl bleibt klein, die Trefferflaeche ist 44 px hoch. */
.bm-werkbank .bm-mass-zahl::after,
.bm-werkbank-frei .bm-mass-zahl::after {
    inset: -13px -8px;
}

.bm-mass-zahl[data-ausgewichen="1"] {
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 1px 3px rgba(28, 33, 38, 0.2);
}

/* --- Panel rechts (Eigenschaften der Auswahl, sonst Grundblech) --------------- */
.bm-editor.bm-werkbank > .bm-zone-panel {
    grid-area: panel;
    position: relative;
    z-index: 2;
    min-width: 0;
    min-height: 0;
    overflow: auto;
    background: var(--bm-liste-bg);
    border-left: 1px solid var(--bm-trenner);
}

.bm-editor.bm-werkbank .bm-zone-panel > .bm-eigenschaften,
.bm-editor.bm-werkbank .bm-zone-panel > .bm-grundpanel {
    position: relative;
    inset: auto;
    width: auto;
    max-width: none;
    max-height: none;
    padding: 14px 14px 16px;
    overflow: visible;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.bm-grundpanel[hidden] {
    display: none;
}

.bm-grund-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    margin: 0 0 10px;
    font-size: var(--bm-t-13);
}

.bm-grund-info dt {
    font-weight: 400;
    color: var(--bm-text-3);
}

.bm-grund-info dd {
    margin: 0;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bm-grund-aktionen {
    flex-direction: column;
}

.bm-zone-panel > .bm-leisten-meldungen {
    margin: 0;
    padding: 10px 14px;
    border-bottom: 1px solid var(--bm-trenner);
}

.bm-zone-panel > .bm-leisten-meldungen[hidden] {
    display: none;
}

.bm-meldung.bm-meldung-vorschlag {
    color: var(--bm-link);
    border-left-color: var(--bm-link);
}

/* Zahl mit Einheit rechts; Beispielwert gestrichelt gelb, grau kursiv. */
.bm-werkbank .bm-zahl.bm-ist-beispiel {
    border-style: dashed;
    border-color: var(--bm-beispiel);
    color: var(--bm-text-3);
    font-style: italic;
}

.bm-werkbank .bm-zahl[aria-invalid="true"] {
    border-color: var(--ai-rolle-fehler);
}

/* --- Fuss: Zurueck · Hinweiszeile · genau ein Status · Preis · Hauptaktion --- */
.bm-editor.bm-werkbank > .bm-fuss {
    grid-area: fuss;
    position: relative;
    inset: auto;
    z-index: 3;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    min-width: 0;
    max-width: none;
    padding: 0 12px;
    background: var(--bm-fuss-bg);
    border: 0;
    border-top: 1px solid var(--bm-trenner);
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    font-size: var(--bm-t-13);
}

.bm-fuss > .bm-geostatus,
.bm-fuss > .bm-preiszustand,
.bm-fuss > .bm-beispiel-offen {
    display: none !important;
}

.bm-fuss > .bm-fuss-zurueck {
    flex: 0 0 auto;
}

.bm-fuss > .bm-fuss-zurueck[hidden],
.bm-fuss > [hidden] {
    display: none;
}

.bm-editor.bm-werkbank .bm-fuss > .bm-hinweisstapel {
    position: relative;
    inset: auto;
    left: auto;
    bottom: auto;
    transform: none;
    display: block;
    flex: 1 1 auto;
    width: auto;
    max-width: none;
    min-width: 0;
}

.bm-fuss .bm-hinweisstapel > .bm-editor-hinweis,
.bm-fuss .bm-hinweisstapel > .bm-kontext {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--bm-text-3);
    font-size: var(--bm-t-13);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bm-fuss .bm-hinweisstapel > .bm-editor-hinweis[data-art="warnung"] {
    color: var(--ai-rolle-hinweis);
}

.bm-fuss .bm-hinweisstapel > .bm-editor-hinweis[data-art="fehler"] {
    color: var(--ai-rolle-fehler);
}

.bm-fuss .bm-hinweisstapel[data-vorrang="kontext"] > .bm-editor-hinweis,
.bm-fuss .bm-hinweisstapel[data-vorrang="hinweis"] > .bm-kontext {
    display: none;
}

.bm-status {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 8px;
    min-height: var(--ai-touch);
    padding: 4px 14px;
    border: 1px solid var(--bm-trenner);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
    font: inherit;
    font-size: var(--bm-t-13);
    white-space: nowrap;
    cursor: default;
}

.bm-status[data-art="fehler"],
.bm-status[data-art="beispiel"] {
    cursor: pointer;
}

.bm-status-punkt {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bm-text-4);
}

.bm-status[data-art="bereit"] .bm-status-punkt {
    background: var(--ai-rolle-bestaetigung);
}

.bm-status[data-art="fehler"] .bm-status-punkt {
    background: var(--ai-rolle-fehler);
}

.bm-status[data-art="fehler"] {
    border-color: rgba(245, 87, 108, 0.5);
}

.bm-status[data-art="beispiel"] .bm-status-punkt,
.bm-status[data-art="anfrage"] .bm-status-punkt {
    background: var(--ai-rolle-hinweis);
}

/* Wird geprueft: Kreisel statt Punkt. */
.bm-status[data-art="laeuft"] .bm-status-punkt {
    flex-basis: 12px;
    width: 12px;
    height: 12px;
    background: none;
    border: 2px solid rgba(255, 255, 255, 0.25);
    border-top-color: var(--ai-rolle-auswahl);
    animation: bm-kreisel 0.9s linear infinite;
}

@keyframes bm-kreisel {
    to { transform: rotate(360deg); }
}

.bm-fuss-preis {
    flex: 0 0 auto;
    color: var(--bm-text-3);
    white-space: nowrap;
}

.bm-fuss-preis:empty {
    display: none;
}

.bm-fuss-preis[data-art="veraltet"] {
    color: var(--text-primary);
    font-weight: 600;
}

.bm-fuss .bm-anfrage-weiter,
.bm-fuss .bm-eingabe-ungueltig {
    flex: 0 0 auto;
    min-height: var(--ai-touch);
}

.bm-fuss .bm-hauptaktion {
    flex: 0 0 auto;
}

/* --- Modi: Flaeche 2D und Abwicklung uebernehmen die Buehne -------------------- */
.bm-editor.bm-werkbank > .bm-flaeche2d,
.bm-editor.bm-werkbank > .bm-abwicklung {
    grid-area: buehne;
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    width: auto;
    max-width: none;
    max-height: none;
    padding: 12px 16px;
    transform: none;
    overflow: hidden;
    background: var(--bm-buehne-bg);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    color: var(--ai-text-auf-hell);
}

.bm-editor.bm-werkbank > .bm-flaeche2d[hidden],
.bm-editor.bm-werkbank > .bm-abwicklung[hidden] {
    display: none;
}

/* Im Modus gehoert die Buehne dem Modus: die Bedienteile der 3D-Ansicht treten zurueck. */
.bm-werkbank:not([data-modus="3d"]) .bm-ansicht-liste,
.bm-werkbank:not([data-modus="3d"]) .bm-buehne-knoepfe,
.bm-werkbank:not([data-modus="3d"]) .bm-ziehpfeil,
.bm-werkbank:not([data-modus="3d"]) .bm-masse-3d {
    display: none;
}

/* Titel und Schliessen stehen in der Moduswechsel-Leiste. */
.bm-werkbank > .bm-flaeche2d > .bm-feld-kopf,
.bm-werkbank > .bm-abwicklung > .bm-feld-kopf {
    display: none;
}

.bm-werkbank .bm-f2d-leinwand {
    flex: 1 1 auto;
    min-height: 0;
}

.bm-werkbank .bm-f2d-leinwand > .bm-f2d {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: none;
}

.bm-werkbank .bm-abwicklung > .bm-abw {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
    max-height: none;
}

.bm-werkbank > .bm-flaeche2d .bm-f2d-hilfe,
.bm-werkbank > .bm-abwicklung .bm-legende {
    color: var(--ai-text-auf-hell-sekundaer);
}

.bm-werkbank > .bm-flaeche2d > .bm-aktionen {
    position: absolute;
    right: 16px;
    bottom: 12px;
    margin: 0;
}

.bm-werkbank > .bm-flaeche2d > .bm-f2d-hilfe {
    margin-right: 240px;
}

/* Skizze (Ausschnitt, Umriss): die Buehne, eigene Werkzeuge oben. */
.bm-editor.bm-werkbank > .bm-skizze-halter {
    grid-area: buehne;
    position: absolute;
    inset: 0;
    z-index: 6;
    width: auto;
    transform: none;
}

.bm-editor.bm-werkbank > .bm-skizze-halter[hidden] {
    display: none;
}

.bm-werkbank .bm-skizze-halter > .bm-skizze {
    height: 100%;
    padding: 8px 12px;
    border: 0;
    border-radius: 0;
    background: var(--bm-modus-bg);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.bm-werkbank .bm-skizze-halter .bm-skizze > .bm-feld-kopf,
.bm-werkbank .bm-skizze-halter .bm-sk-abbrechen,
.bm-werkbank .bm-skizze-halter .bm-sk-uebernehmen {
    display: none;
}

/* Rueckfragen und Band auf der Buehne. */
.bm-editor.bm-werkbank > .bm-loeschen,
.bm-editor.bm-werkbank > .bm-rueckfrage {
    grid-area: buehne;
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 12;
    width: min(420px, calc(100% - 32px));
    max-height: calc(100% - 32px);
    overflow: auto;
    padding: 16px 18px;
    transform: translate(-50%, -50%);
    background: #1a1d22;
    border: 1px solid var(--bm-trenner);
    border-radius: var(--ai-feld-radius);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.bm-editor.bm-werkbank > .bm-rueckfrage[hidden],
.bm-editor.bm-werkbank > .bm-loeschen[hidden] {
    display: none;
}

.bm-rueckfrage .bm-konflikt-laden {
    min-height: var(--ai-touch);
    background: var(--bm-cta-bg);
    border: 0;
    color: var(--bm-cta-text);
    font-weight: 600;
}

.bm-editor.bm-werkbank > .bm-band {
    grid-area: buehne;
    position: absolute;
    top: 12px;
    left: 50%;
    z-index: 11;
    display: flex;
    align-items: center;
    gap: 12px;
    max-width: calc(100% - 32px);
    padding: 8px 10px 8px 14px;
    transform: translateX(-50%);
    background: #fff8d6;
    border: 1px solid #e8d34a;
    border-radius: var(--ai-knopf-radius);
    box-shadow: 0 6px 18px rgba(28, 33, 38, 0.18);
    color: #3b3413;
    font-size: var(--bm-t-13);
}

.bm-editor.bm-werkbank > .bm-band[hidden] {
    display: none;
}

.bm-band .bm-band-erneut {
    min-height: var(--ai-touch);
    border-color: #b9a300;
    background: #ffffff;
    color: #3b3413;
}

/* Einfuehrung als Karte auf der Buehne. */
.bm-editor.bm-werkbank > .bm-einfuehrung {
    grid-area: buehne;
}

/* Handy-Teile sind am Desktop unsichtbar. */
.bm-werkbank > .bm-sheet-griff,
.bm-werkbank > .bm-sheet-flaeche {
    display: none;
}

/* --- Zwischenbreiten ---------------------------------------------------------- */
.bm-editor.bm-werkbank[data-breite="m"] .bm-modus-hilfe,
.bm-editor.bm-werkbank[data-breite="m"] .bm-fuss-preis {
    display: none;
}

/* Niedrige Fenster: Kopf, Befehlszeile und Fuss bleiben, die Buehne verliert Hoehe. */
@media (max-height: 640px) {
    .bm-editor.bm-werkbank {
        grid-template-rows: 50px minmax(0, 1fr) 52px;
    }
}

/* ==========================================================================
   3. Grundblech frei zeichnen: dieselben Zonen
   ========================================================================== */
.bm-frei.bm-werkbank-frei {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) var(--ai-panel-breite);
    grid-template-rows: auto minmax(0, 1fr) var(--bm-fuss-hoehe);
    grid-template-areas:
        "befehl befehl"
        "buehne panel"
        "fuss fuss";
    gap: 0;
    min-height: 0;
    background: var(--bm-buehne-bg);
}

.bm-frei.bm-werkbank-frei > .bm-frei-modusleiste {
    grid-area: befehl;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 6px;
    min-height: var(--bm-befehl-hoehe);
    padding: 3px 8px 3px 16px;
    overflow-x: auto;
    scrollbar-width: none;
}

.bm-frei-modusleiste::-webkit-scrollbar {
    display: none;
}

.bm-frei-modusleiste > .bm-feld-kopf {
    display: none;
}

.bm-frei-modusleiste > .bm-modus-titel {
    flex: 0 0 auto;
    margin-right: 8px;
}

.bm-frei-modusleiste > .bm-sk-werkzeuge {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 2px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

/* Auf dem leeren Blatt reichen 15°-Raster und Fangen (die uebrigen bleiben an). */
.bm-frei-modusleiste > .bm-sk-fangen {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 2px 10px;
    padding-left: 8px;
    border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.bm-frei-modusleiste > .bm-sk-fangen legend,
.bm-frei-modusleiste .bm-sk-fang:not(.bm-sk-fang-winkel):not(:has(input[data-fang="endpunkt"])) {
    display: none;
}

.bm-frei-modusleiste > .bm-sk-fuss {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin-left: auto;
    gap: 6px;
}

/* Auf dem leeren Blatt ersetzt "Letzter Punkt zurueck" das allgemeine Rueckgaengig
   (Strg+Z wirkt weiter). */
.bm-frei-modusleiste > .bm-sk-fuss .bm-sk-rueckgaengig {
    display: none;
}

/* Zwischenbreiten: unter 1440 px Werkzeuge nur als Icon (Name im Tooltip und
   aria-label), unter 1360 px ohne Titel - die Leiste bleibt eine Zeile; was
   nicht passt, wischt im Streifen (Knopfsystem 28.09.2026, Befund 9: ab 1440
   mit Wort). */
@media (max-width: 1439.98px) {
    .bm-frei-modusleiste .bm-sk-werkzeug .bm-werkzeug-text {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
    }
}

@media (max-width: 1359px) {
    .bm-frei-modusleiste > .bm-modus-titel {
        display: none;
    }
}

.bm-frei.bm-werkbank-frei > .bm-frei-zeichnung {
    grid-area: buehne;
    position: relative;
    display: flex;
    min-width: 0;
    min-height: 0;
}

.bm-frei.bm-werkbank-frei .bm-frei-zeichnung > .bm-skizze {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    background: var(--bm-buehne-bg);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.bm-frei.bm-werkbank-frei .bm-sk-koerper {
    flex: 1 1 auto;
}

.bm-frei.bm-werkbank-frei .bm-sk-svg {
    border-radius: 0;
}

/* Fadenkreuz exakt am Zeiger: der Systemzeiger ist aus (leeres Blatt). */
.bm-sk-blatt .bm-sk-svg {
    cursor: none;
}

.bm-sk-blatt .bm-sk-svg.bm-sk-verschieben {
    cursor: grab;
}

.bm-sk-blatt .bm-sk-fadenkreuz {
    stroke: var(--bm-fadenkreuz);
}

.bm-sk-zeigerinfo[data-rast]::after {
    content: " · " attr(data-rast);
    color: #d6b3f8;
    font-weight: 500;
}

.bm-sk-segment.bm-sk-fehler {
    stroke: var(--ai-rolle-fehler);
    stroke-width: 4;
}

.bm-frei.bm-werkbank-frei > .bm-frei-panel {
    grid-area: panel;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 14px;
    overflow: auto;
    background: var(--bm-liste-bg);
    border-left: 1px solid var(--bm-trenner);
    color: var(--text-primary);
}

.bm-frei-panel > .bm-sk-seite {
    flex: 0 0 auto;
    overflow: visible;
}

.bm-frei-panel .bm-frei-felder {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding-top: 12px;
    border-top: 1px solid var(--bm-trenner);
}

.bm-frei-panel .bm-frei-wahl select,
.bm-frei-panel .bm-frei-wahl input,
.bm-frei-panel .bm-frei-wahl input.bm-frei-menge {
    width: 100%;
    min-width: 0;
}

.bm-frei-panel > .bm-sk-legende,
.bm-frei-panel > .bm-sk-meldungen {
    margin: 0;
}

/* Ueber der Kantgrenze (26.09.2026): nur flache Teile, keine Laschen. */
.bm-frei-dicke-hinweis {
    margin: -4px 0 0;
    padding: 6px 8px;
    border-left: 3px solid var(--ai-rolle-hinweis);
    border-radius: 4px;
    background: rgba(214, 150, 40, 0.12);
    font-size: 13px;
    line-height: 1.4;
}

.bm-frei-dicke-hinweis[hidden] {
    display: none;
}

.bm-frei.bm-werkbank-frei > .bm-frei-leiste {
    grid-area: fuss;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 0 12px;
    background: var(--bm-fuss-bg);
    border: 0;
    border-top: 1px solid var(--bm-trenner);
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
}

.bm-frei-leiste > .bm-sk-hilfe {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--bm-text-3);
    white-space: nowrap;
    text-overflow: ellipsis;
}

.bm-frei-leiste > .bm-frei-status {
    flex: 0 1 auto;
}

.bm-frei-leiste > .bm-frei-knoepfe {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin-left: 0;
}

.bm-frei.bm-werkbank-frei > .bm-sheet-griff,
.bm-frei.bm-werkbank-frei > .bm-sheet-flaeche {
    display: none;
}

/* ==========================================================================
   4. Startseite und Galerie
   ========================================================================== */
/* Drei gleichrangige Karten, Katalog als Textlink darunter. */
.ai-werkbank #ai-start-wege:not(.ai-start-karten-eine) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
}

/* ==========================================================================
   5. Schnellteile am Handy: Buchstaben am Bild, Masse als Liste
   ========================================================================== */
.bm-mass-marke {
    position: absolute;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    min-width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    transform: translate(-50%, -50%);
    border: 2px solid #2b5fad;
    border-radius: 50%;
    background: #ffffff;
    color: #1c2126;
    font: 700 13px/1 var(--bm-schrift);
    pointer-events: auto;
    cursor: pointer;
}

/* 44-px-Trefferflaeche, die Marke selbst bleibt klein. */
.bm-mass-marke::after {
    content: "";
    position: absolute;
    inset: -7px;
}

.bm-mass-marke.bm-mass-hervor {
    border-color: var(--ai-rolle-auswahl);
    background: var(--ai-rolle-auswahl);
    color: #ffffff;
}

.bm-schnellteil-masse .bm-mass-hervor .pk-masslinie,
.bm-schnellteil-masse .bm-mass-hervor .pk-hilfslinie {
    stroke: var(--ai-rolle-auswahl);
    stroke-width: 3;
}

.bm-schnellteil-masse .bm-mass-hervor .pk-masspfeil {
    fill: var(--ai-rolle-auswahl);
}

.bm-schnellteil-massliste {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bm-schnellteil-masszeile {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: var(--ai-touch);
    padding: 4px 8px;
    border: 1px solid transparent;
    border-radius: var(--ai-knopf-radius);
}

.bm-schnellteil-masszeile.bm-mass-hervor {
    border-color: var(--ai-rolle-auswahl);
    background: var(--ai-rolle-auswahl-weich);
}

.bm-mass-marke.bm-mass-marke-liste {
    position: static;
    transform: none;
    cursor: default;
}

.bm-mass-marke.bm-mass-marke-liste::after {
    content: none;
}

.bm-schnellteil-massname {
    font-size: var(--bm-t-14);
}

.bm-schnellteil-massliste .pk-mass.bm-schnellteil-mass-liste {
    position: relative;
    transform: none;
    min-height: var(--ai-touch);
}

/* In der Liste ist die Zeile selbst 44 px hoch - keine vergroesserte Trefferflaeche,
   sie laege sonst ueber den Nachbarfeldern. */
.bm-schnellteil-massliste .bm-schnellteil-mass-liste::after {
    content: none;
}

.bm-schnellteil-massliste .pk-mass.bm-schnellteil-mass-liste {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 10px;
}

.bm-schnellteil-massliste input.pk-mass-eingabe[type="text"] {
    width: 4.5em;
    min-width: 0;
    height: 36px;
    min-height: 0;
    padding: 0 4px;
    border: 0;
    background: transparent;
    color: inherit;
    font-size: 16px;
    text-align: right;
}

/* ==========================================================================
   6. Handy (< 768 px): Teil oben, Bottom Sheet mit drei Rasthoehen
   ========================================================================== */
@media (max-width: 767px) {
    /* Kopf: ein Balken mit "⋯" - er liegt ueber dem Inhalt, nie darauf. */
    .ai-werkbank > .ai-dialog-kopf {
        top: 0;
        left: 0;
        right: 0;
        height: calc(var(--ai-kopf-hoehe) + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) 4px 0 8px;
        align-items: center;
        flex-wrap: nowrap;
        gap: 6px;
        background: var(--bm-kopf-bg);
        border-bottom: 1px solid var(--bm-trenner);
        pointer-events: auto;
    }

    .ai-werkbank .ai-kopf-links {
        flex: 1 1 auto;
        min-width: 0;
        min-height: 0;
        height: var(--ai-kopf-hoehe);
        padding: 0;
        background: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    .ai-werkbank .ai-dialog-schritte.nocad-progress {
        order: 0;
        flex: 1 1 auto;
        flex-basis: auto;
        justify-content: flex-start;
    }

    .ai-werkbank .ai-kopf-menue-knopf {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex: 0 0 auto;
        width: var(--ai-touch);
        min-width: var(--ai-touch);
        height: var(--ai-touch);
        min-height: var(--ai-touch);
        margin-left: auto;
    }

    /* Das Menue: die Knoepfe des rechten Kopfs als Liste unter dem Balken. */
    .ai-werkbank .ai-kopf-rechts {
        display: none;
    }

    .ai-werkbank.ai-kopf-menue-offen .ai-kopf-rechts {
        position: absolute;
        top: calc(100% + 4px);
        right: 8px;
        z-index: 40;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 2px;
        width: min(280px, calc(100vw - 16px));
        min-height: 0;
        height: auto;
        padding: 6px;
        background: #1a1d22;
        border: 1px solid var(--bm-trenner);
        border-radius: 12px;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
    }

    .ai-werkbank.ai-kopf-menue-offen .ai-kopf-rechts .ai-dialog-neu,
    .ai-werkbank.ai-kopf-menue-offen .ai-kopf-rechts .ai-dialog-info {
        display: flex;
        flex-direction: column;
        width: 100%;
    }

    .ai-werkbank.ai-kopf-menue-offen .ai-dialog-neu-text {
        display: inline;
    }

    .ai-werkbank.ai-kopf-menue-offen .ai-dialog-info-knopf::after,
    .ai-werkbank.ai-kopf-menue-offen #ai-dialog-schliessen::after {
        content: attr(aria-label);
        font-size: 14px;
    }

    .ai-werkbank.ai-kopf-menue-offen .ai-dialog-neu .ai-neu-frage,
    .ai-werkbank.ai-kopf-menue-offen .ai-dialog-info .ai-gut-zu-wissen {
        position: static;
        width: auto;
        margin-top: 4px;
    }

    .ai-werkbank > .ai-dialog-inhalt {
        padding-top: calc(var(--ai-kopf-hoehe) + env(safe-area-inset-top) + 14px);
        /* Der Inhalt endet ueber dem Fuss - nichts liegt unter der Leiste
           (je Schritt so hoch wie dessen Fuss: Pruefen mit Haken, Preis mit zwei Knoepfen). */
        bottom: calc(72px + env(safe-area-inset-bottom));
        padding-bottom: 16px;
    }

    .ai-werkbank.ai-dialog-vorschau > .ai-dialog-inhalt {
        bottom: calc(150px + env(safe-area-inset-bottom));
    }

    .ai-werkbank.ai-dialog-preis > .ai-dialog-inhalt {
        bottom: calc(180px + env(safe-area-inset-bottom));
    }

    /* Zeichner und Loch-Editor fuellen das Fenster selbst (ai-werkbank.css). */
    .ai-werkbank.ai-dialog-kette > .ai-dialog-inhalt,
    .ai-werkbank.ai-dialog-loch > .ai-dialog-inhalt {
        bottom: 0;
        padding-bottom: 0;
    }

    .ai-werkbank.ai-dialog-blech > .ai-dialog-inhalt {
        top: calc(var(--ai-kopf-hoehe) + env(safe-area-inset-top));
        bottom: calc(var(--bm-fuss-hoehe) + env(safe-area-inset-bottom));
        padding-top: 0;
    }

    .ai-werkbank.ai-dialog-blech.bm-editor-modus > .ai-dialog-inhalt,
    .ai-werkbank.ai-dialog-blech.bm-frei-modus > .ai-dialog-inhalt {
        bottom: 0;
    }

    .ai-werkbank.ai-dialog-blech > .ai-dialog-fuss {
        height: auto;
        min-height: var(--bm-fuss-hoehe);
        padding: 6px 10px max(6px, env(safe-area-inset-bottom));
    }

    .ai-werkbank.ai-dialog-blech .bm-schnellteile {
        margin-top: 12px;
        margin-bottom: 16px;
    }

}

/* Handy-Fassung: an der Klasse bm-handy (der Editor setzt sie aus derselben
   Medienabfrage wie die Werkbank, < 768 px) - Aussehen und Verhalten laufen
   nie auseinander (wie T16). */
/* --- Editor am Handy: Grid mit Sheet -------------------------------------- */
.bm-editor.bm-werkbank.bm-handy {
    /* Teil oben: mindestens 45 % der Hoehe (46 dvh, damit Rundung nie darunter faellt). */
    --bm-sheet-buehne: 46dvh;
    display: grid;
    gap: 0;
    padding: 0;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--bm-sheet-buehne) 28px auto minmax(0, 1fr) auto;
    grid-template-areas:
        "buehne"
        "griff"
        "befehl"
        "inhalt"
        "fuss";
}

.bm-editor.bm-werkbank.bm-handy[data-sheet="klein"] {
    grid-template-rows: minmax(0, 1fr) 28px auto 0 auto;
}

.bm-editor.bm-werkbank.bm-handy[data-sheet="gross"],
.bm-editor.bm-werkbank.bm-handy.bm-tastatur-offen {
    grid-template-rows: 96px 28px auto minmax(0, 1fr) auto;
}

/* Tastatur offen: der Editor endet ueber der Tastatur (visualViewport). */
.bm-editor.bm-werkbank.bm-handy.bm-tastatur-offen {
    bottom: var(--bm-tastatur, 0px);
}

.bm-editor.bm-werkbank.bm-handy > .bm-editor-buehne {
    grid-area: buehne;
    position: relative;
    inset: auto;
    bottom: auto;
}

.bm-editor.bm-werkbank.bm-handy > .bm-sheet-flaeche {
    display: block;
    grid-row: 2 / -1;
    grid-column: 1;
    z-index: 1;
    background: var(--bm-befehl-bg);
    border-radius: var(--bm-sheet-radius);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.35);
}

.bm-editor.bm-werkbank.bm-handy > .bm-sheet-griff {
    display: block;
    grid-area: griff;
    position: relative;
    top: -8px;
    z-index: 4;
    width: 100%;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
}

.bm-editor.bm-werkbank.bm-handy > .bm-sheet-griff::before {
    content: "";
    display: block;
    width: 40px;
    height: 5px;
    margin: 0 auto;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.35);
}

.bm-editor.bm-werkbank.bm-handy > .bm-befehlszeile {
    grid-area: befehl;
    position: relative;
    z-index: 2;
    order: 0;
    align-self: stretch;
    max-width: none;
    padding: 0 6px 4px;
    background: none;
    border: 0;
}

.bm-editor.bm-werkbank.bm-handy .bm-befehlszeile .bm-wz-rueckgaengig .bm-werkzeug-text,
.bm-editor.bm-werkbank.bm-handy .bm-befehlszeile .bm-wz-wiederholen .bm-werkzeug-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
}

.bm-editor.bm-werkbank.bm-handy .bm-befehlszeile > .bm-assistent {
    order: 0;
    flex: 0 0 auto;
    margin-left: 0;
}

.bm-editor.bm-werkbank.bm-handy > .bm-modusleiste {
    grid-area: befehl;
    z-index: 2;
    flex-wrap: wrap;
    gap: 6px;
    padding: 4px 10px 6px;
}

/* Inhalt: Liste oder Eigenschaften (scrollt allein). */
.bm-editor.bm-werkbank.bm-handy > .bm-zone-liste,
.bm-editor.bm-werkbank.bm-handy > .bm-zone-panel {
    grid-area: inhalt;
    z-index: 2;
    min-height: 0;
    background: none;
    border: 0;
}

.bm-editor.bm-werkbank.bm-handy[data-sheet="klein"] > .bm-zone-liste,
.bm-editor.bm-werkbank.bm-handy[data-sheet="klein"] > .bm-zone-panel {
    display: none;
}

.bm-editor.bm-werkbank.bm-handy > .bm-zone-panel {
    display: none;
}

.bm-editor.bm-werkbank.bm-handy.bm-auswahl-offen > .bm-zone-panel {
    display: block;
}

.bm-editor.bm-werkbank.bm-handy.bm-auswahl-offen > .bm-zone-liste {
    display: none;
}

.bm-editor.bm-werkbank.bm-handy .bm-zone-liste > .bm-listenleiste {
    display: none;
}

.bm-editor.bm-werkbank.bm-handy .bm-zone-liste > .bm-merkmalsliste {
    display: block;
    order: 0;
    max-height: none;
    margin: 0;
    padding: 4px 12px 12px;
}

.bm-editor.bm-werkbank.bm-handy .bm-liste-zu {
    display: none;
}

.bm-editor.bm-werkbank.bm-handy .bm-zone-panel > .bm-eigenschaften {
    order: 0;
    max-height: none;
    margin: 0;
    padding: 4px 12px 12px;
}

.bm-editor.bm-werkbank.bm-handy .bm-zone-panel > .bm-grundpanel {
    display: none;
}

/* Fuss im Sheet: Hinweiszeile ueber Status und Hauptaktion (bleibt stehen). */
.bm-editor.bm-werkbank.bm-handy > .bm-fuss {
    grid-area: fuss;
    z-index: 2;
    flex-wrap: wrap;
    gap: 6px 8px;
    order: 0;
    padding: 6px 10px max(10px, env(safe-area-inset-bottom));
    background: var(--bm-fuss-bg);
}

.bm-editor.bm-werkbank.bm-handy .bm-fuss > .bm-hinweisstapel {
    order: -1;
    flex: 1 0 100%;
}

.bm-editor.bm-werkbank.bm-handy .bm-fuss .bm-hinweisstapel > .bm-editor-hinweis,
.bm-editor.bm-werkbank.bm-handy .bm-fuss .bm-hinweisstapel > .bm-kontext {
    white-space: normal;
    font-size: var(--bm-t-12);
}

.bm-editor.bm-werkbank.bm-handy .bm-fuss > .bm-fuss-preis {
    display: none;
}

.bm-editor.bm-werkbank.bm-handy .bm-fuss > .bm-fuss-zurueck,
.bm-editor.bm-werkbank.bm-handy .bm-fuss .bm-hauptaktion,
.bm-editor.bm-werkbank.bm-handy .bm-fuss .bm-anfrage-weiter,
.bm-editor.bm-werkbank.bm-handy .bm-fuss .bm-eingabe-ungueltig,
.bm-editor.bm-werkbank.bm-handy .bm-status {
    min-height: var(--ai-touch);
}

.bm-editor.bm-werkbank.bm-handy .bm-fuss .bm-hauptaktion {
    margin-left: auto;
}

/* Der Vorschau-Vermerk unten links (oben rechts steht "Ganzes Teil"). */
.bm-editor.bm-werkbank.bm-handy .bm-ansicht-vorschau {
    top: auto;
    right: auto;
    bottom: 6px;
    left: 8px;
    max-width: calc(100% - 16px);
    font-size: 10px;
    text-align: left;
}

/* Werkzeugleiste: Formen, Bearbeitungen, Ansicht, Verlauf, dann Tipps (wie am Desktop). */
.bm-editor.bm-werkbank.bm-handy .bm-befehlszeile > .bm-werkzeugleiste {
    order: 0;
}

.bm-editor.bm-werkbank.bm-handy .bm-befehlszeile > .bm-assistent {
    order: 1;
}

.bm-editor.bm-werkbank.bm-handy .bm-liste-kopf {
    background: var(--bm-befehl-bg);
}

.bm-editor.bm-werkbank.bm-handy .bm-status {
    flex: 1 1 0;
    min-width: 0;
    white-space: normal;
    line-height: 1.2;
    text-align: left;
    border-radius: 14px;
}

/* Flaeche 2D am Handy: der Knopf unter dem Hinweis, nicht darueber. */
.bm-editor.bm-werkbank.bm-handy > .bm-flaeche2d > .bm-aktionen {
    position: static;
    margin: 6px 0 0;
}

.bm-editor.bm-werkbank.bm-handy > .bm-flaeche2d > .bm-f2d-hilfe {
    margin-right: 0;
    font-size: var(--bm-t-12);
}

/* Buehnenknoepfe: nur "Ganzes Teil", oben rechts. */
.bm-editor.bm-werkbank.bm-handy .bm-buehne-knoepfe {
    top: 8px;
    right: 8px;
    bottom: auto;
}

.bm-editor.bm-werkbank.bm-handy .bm-buehne-minus,
.bm-editor.bm-werkbank.bm-handy .bm-buehne-plus {
    display: none;
}

/* Modi am Handy: die Buehne gehoert dem Modus, das Sheet bleibt. */
.bm-editor.bm-werkbank.bm-handy > .bm-flaeche2d,
.bm-editor.bm-werkbank.bm-handy > .bm-abwicklung {
    padding: 8px;
}

.bm-editor.bm-werkbank.bm-handy > .bm-loeschen,
.bm-editor.bm-werkbank.bm-handy > .bm-rueckfrage {
    width: calc(100% - 20px);
}

.bm-editor.bm-werkbank.bm-handy > .bm-einfuehrung {
    width: calc(100% - 20px);
}

/* --- Freies Zeichnen am Handy (nur mit Freigabe): Blatt oben, Sheet unten -- */
.bm-frei.bm-werkbank-frei.bm-handy {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: var(--bm-sheet-buehne, 46dvh) 28px auto minmax(0, 1fr) auto;
    grid-template-areas:
        "buehne"
        "griff"
        "befehl"
        "panel"
        "fuss";
}

.bm-frei.bm-werkbank-frei.bm-handy[data-sheet="klein"] {
    grid-template-rows: minmax(0, 1fr) 28px auto 0 auto;
}

.bm-frei.bm-werkbank-frei.bm-handy[data-sheet="gross"],
.bm-frei.bm-werkbank-frei.bm-handy.bm-tastatur-offen {
    grid-template-rows: 96px 28px auto minmax(0, 1fr) auto;
}

.bm-frei.bm-werkbank-frei.bm-handy.bm-tastatur-offen {
    bottom: var(--bm-tastatur, 0px);
}

.bm-frei.bm-werkbank-frei.bm-handy > .bm-sheet-flaeche {
    display: block;
    grid-row: 2 / -1;
    grid-column: 1;
    background: var(--bm-befehl-bg);
    border-radius: var(--bm-sheet-radius);
    box-shadow: 0 -10px 28px rgba(0, 0, 0, 0.35);
}

.bm-frei.bm-werkbank-frei.bm-handy > .bm-sheet-griff {
    display: block;
    grid-row: 2;
    grid-column: 1;
    position: relative;
    top: -8px;
    z-index: 4;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border: 0;
    background: transparent;
    touch-action: none;
}

.bm-frei.bm-werkbank-frei.bm-handy > .bm-sheet-griff::before {
    content: "";
    display: block;
    width: 40px;
    height: 5px;
    margin: 0 auto;
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.35);
}

.bm-frei.bm-werkbank-frei.bm-handy > .bm-frei-modusleiste {
    z-index: 2;
    padding: 0 8px 4px;
    background: none;
    border: 0;
    box-shadow: none;
}

.bm-frei.bm-werkbank-frei.bm-handy > .bm-frei-modusleiste > .bm-modus-titel {
    display: none;
}

.bm-frei.bm-werkbank-frei.bm-handy > .bm-frei-panel {
    z-index: 2;
    padding: 6px 12px;
    background: none;
    border: 0;
}

.bm-frei.bm-werkbank-frei.bm-handy[data-sheet="klein"] > .bm-frei-panel {
    display: none;
}

.bm-frei.bm-werkbank-frei.bm-handy > .bm-frei-leiste {
    z-index: 2;
    flex-wrap: wrap;
    padding: 6px 10px max(10px, env(safe-area-inset-bottom));
}

.bm-frei.bm-werkbank-frei.bm-handy .bm-frei-leiste > .bm-sk-hilfe {
    flex: 1 0 100%;
    white-space: normal;
}

/* Laenge/Richtung als Felder mit "Punkt setzen" im Sheet (nicht ueber dem Blatt). */
.bm-frei.bm-werkbank-frei.bm-handy .bm-sk-masse {
    position: static;
    padding: 0;
    border: 0;
    background: none;
}

.bm-frei.bm-werkbank-frei.bm-handy .bm-sk-masse .bm-zahl,
.bm-frei.bm-werkbank-frei.bm-handy .bm-sk-masse button,
.bm-frei.bm-werkbank-frei.bm-handy .bm-frei-knoepfe button,
.bm-frei.bm-werkbank-frei.bm-handy .bm-sk-fuss button,
.bm-frei.bm-werkbank-frei.bm-handy .bm-sk-werkzeug {
    min-height: var(--ai-touch);
}

.bm-frei.bm-werkbank-frei.bm-handy input,
.bm-frei.bm-werkbank-frei.bm-handy select {
    font-size: 16px;
}

@media (max-width: 767px) {
    /* Schnellteile am Handy: Bild mit Buchstaben, darunter die Liste. */
    .bm-schnellteil-massliste {
        margin-top: 6px;
    }
}

/* Niedrige Fenster mit Finger (Querformat): 44-px-Trefferflaeche der Massfelder am Bild
   auch in der Desktop-Fassung. */
@media (max-height: 460px) {
    .bm-schnellteil-mass::after {
        content: "";
        position: absolute;
        inset: -11px -4px;
    }
}

/* Querformat am Handy (unter 768 px Breite, z. B. 667 x 375): Teil links, das Sheet ist
   die rechte Spalte. 844 x 390 ist laut T16 die Desktop-Fassung (Kantenwahl frei). */
@media (max-height: 460px) {
    .bm-editor.bm-werkbank.bm-handy,
    .bm-editor.bm-werkbank.bm-handy[data-sheet="klein"],
    .bm-editor.bm-werkbank.bm-handy[data-sheet="gross"] {
        grid-template-columns: 56% minmax(0, 1fr);
        grid-template-rows: auto minmax(0, 1fr) auto;
        grid-template-areas:
            "buehne befehl"
            "buehne inhalt"
            "buehne fuss";
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .bm-editor.bm-werkbank.bm-handy > .bm-sheet-flaeche {
        grid-row: 1 / -1;
        grid-column: 2;
        border-radius: 0;
    }

    .bm-editor.bm-werkbank.bm-handy > .bm-sheet-griff {
        display: none;
    }

    .bm-editor.bm-werkbank.bm-handy[data-sheet="klein"] > .bm-zone-liste,
    .bm-editor.bm-werkbank.bm-handy[data-sheet="klein"] > .bm-zone-panel {
        display: block;
    }

    .bm-editor.bm-werkbank.bm-handy:not(.bm-auswahl-offen)[data-sheet="klein"] > .bm-zone-panel {
        display: none;
    }

    .bm-editor.bm-werkbank.bm-handy.bm-auswahl-offen[data-sheet="klein"] > .bm-zone-liste {
        display: none;
    }
}

/* Reduzierte Bewegung: kein Kreisel, keine Uebergaenge. */
@media (prefers-reduced-motion: reduce) {
    .bm-status[data-art="laeuft"] .bm-status-punkt {
        animation: none;
    }
}

/* Sichtbarer Fokus ueberall in den Zonen (3 px violett). */
.bm-werkbank button:focus-visible,
.bm-werkbank input:focus-visible,
.bm-werkbank select:focus-visible,
.bm-werkbank-frei button:focus-visible,
.bm-werkbank-frei input:focus-visible,
.bm-werkbank-frei select:focus-visible,
.bm-mass-marke:focus-visible,
.ai-werkbank .ai-kopf-menue-knopf:focus-visible {
    outline: 3px solid var(--ai-rolle-auswahl);
    outline-offset: 2px;
}

/* Ansichten wie in SolidWorks + schwarze Kanten (26.09.2026): oben links auf der Buehne. */
.bm-editor .bm-blicke {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 3;
    display: flex;
    gap: 6px;
}

.bm-editor .bm-blicke .bm-blick-kanten {
    margin-left: 6px;
}

.bm-editor[data-modus]:not([data-modus="3d"]) .bm-blicke,
.bm-editor.bm-handy .bm-blicke {
    display: none;
}

/* Ladeanzeige "Grundblech wird erzeugt" (26.09.2026). */
.bm-lade {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(18, 16, 24, 0.72);
    color: #f2f3f5;
    text-align: center;
}

.ai-schritt .bm-lade,
#ai-schritt-formular > .bm-lade {
    position: fixed;
    top: var(--ai-kopf-hoehe, 44px);
}

.bm-frei-lade {
    display: none;
}

.bm-frei-laedt .bm-frei-lade {
    display: flex;
}

.bm-lade-kreis {
    width: 42px;
    height: 42px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #f6e760;
    border-radius: 50%;
    animation: bm-lade-dreh 0.9s linear infinite;
}

.bm-lade-text {
    margin: 0;
    max-width: 420px;
    padding: 0 16px;
    font-size: 15px;
    line-height: 1.5;
}

@keyframes bm-lade-dreh {
    to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
    .bm-lade-kreis { animation-duration: 3s; }
}

/* Profil linear austragen (27.09.2026): Abschnitt im Panel, Seitenwahl, Vorschau. */
.bm-frei-austragen {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--bm-trenner, rgba(255, 255, 255, 0.08));
}

.bm-frei-austragen[hidden],
.bm-frei-austragen-felder[hidden],
.bm-frei-austragen-knopf[hidden] {
    display: none;
}

.bm-frei-austragen-knopf {
    width: 100%;
    margin-top: 8px;
}

.bm-frei-austragen-felder {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 8px;
}

.bm-frei-panel .bm-frei-austragen-felder .bm-frei-wahl input.bm-frei-laenge {
    width: 100%;
    text-align: right;
}

.bm-frei-seite-name {
    color: var(--text-secondary, #a8adb4);
    font-size: 0.9em;
    font-weight: 600;
}

.bm-frei-seiten {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
}

.bm-frei-seite {
    min-width: 0;
    padding-left: 4px;
    padding-right: 4px;
}

.bm-frei-seite[aria-pressed="true"] {
    background: var(--ai-rolle-auswahl-weich, rgba(158, 39, 251, 0.2));
    border-color: var(--ai-rolle-auswahl, #9e27fb);
}

/* Blechstreifen in der Zeichnung */
.bm-sk-zusatz .bm-frei-streifen {
    fill: rgba(158, 39, 251, 0.22);
    stroke: #9e27fb;
    stroke-width: 1;
    vector-effect: non-scaling-stroke;
    pointer-events: none;
}
