.color-select-mobile {
    position: absolute;
    opacity: 0;
    pointer-events: none;
    width: 1px;
    height: 1px;
}

.mobile-stroke-select {
    background: #202124;
    color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    padding: 6px 8px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.mobile-stroke-select:focus {
    border-color: #1a73e8;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

button, [role="button"] {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #525659;
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Thumbnail Sidebar */
.thumbnail-sidebar {
    position: fixed;
    left: -250px;
    /* Höhen von Toolbar/Statusbar werden per JS gemessen (passt sich an 36px-Toolbar UND
       wechselnde/ausgeblendete Statusbar an). Fallback-Werte falls JS noch nicht lief. */
    top: var(--app-toolbar-h, 36px);
    bottom: max(var(--app-statusbar-h, 24px), env(safe-area-inset-bottom));
    width: 250px;
    background: #323639;
    box-shadow: 2px 0 8px rgba(0,0,0,0.3);
    z-index: 100;
    transition: left 0.3s ease;
    display: flex;
    flex-direction: column;
}

.thumbnail-sidebar.open {
    left: 0;
}

.thumbnail-header {
    padding: 4px 8px;
    background: #202124;
    display: flex;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
    gap: 4px;
}

.sidebar-tabs {
    display: flex;
    align-items: center;
    flex: 1;
    gap: 2px;
}

.sidebar-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #9aa0a6;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px 4px 0 0;
    padding: 0;
    transition: color 0.15s, border-color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-tab svg {
    width: 18px;
    height: 18px;
}

.sidebar-tab:hover {
    color: #e8eaed;
}

.sidebar-tab.active {
    color: #8ab4f8;
    border-bottom-color: #8ab4f8;
}

.sidebar-close-btn {
    background: transparent;
    border: none;
    color: #9aa0a6;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 0;
    flex-shrink: 0;
    -webkit-tap-highlight-color: transparent;
}

.sidebar-close-btn svg {
    width: 16px;
    height: 16px;
}

.sidebar-close-btn:hover {
    color: #e8eaed;
    background: rgba(255,255,255,0.1);
}

/* Panel-Sub-Header */
.sidebar-panel-header {
    padding: 5px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    flex-shrink: 0;
}

.sidebar-panel-header span {
    color: #e8eaed;
    font-size: 12px;
    font-weight: 500;
}

.history-count-badge {
    color: #9aa0a6;
    font-weight: 400;
}

.sidebar-panel-header button {
    background: transparent;
    border: none;
    color: #9aa0a6;
    cursor: pointer;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.sidebar-panel-header button svg {
    width: 16px;
    height: 16px;
}

.sidebar-panel-header button:hover {
    color: #8ab4f8;
    background: rgba(138, 180, 248, 0.12);
}

/* Panels */
.sidebar-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
}

.sidebar-panel.active {
    display: flex;
}

/* Platzhalter */
.sidebar-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9aa0a6;
    font-size: 13px;
    padding: 24px;
    text-align: center;
}

.thumbnail-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.thumbnail-item {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    transition: all 0.2s;
    background: #202124;
    padding: 8px;
    position: relative;
}

.thumbnail-item:hover {
    border-color: rgba(138, 180, 248, 0.5);
}

.thumbnail-item.active {
    border-color: #8ab4f8;
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.3);
}

.thumbnail-item canvas {
    width: 100%;
    display: block;
    border-radius: 2px;
}

.thumbnail-page-number {
    text-align: center;
    color: #e8eaed;
    font-size: 12px;
    margin-top: 4px;
}

.thumbnail-container::-webkit-scrollbar {
    width: 8px;
}

.thumbnail-container::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
}

.thumbnail-container::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}

.thumbnail-container::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

.toolbar {
    background: #323639;
    padding: 0px 5px;
    padding-top: max(0px, env(safe-area-inset-top));
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
    flex-shrink: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    position: sticky;
    top: 0;
    z-index: 10000;
    min-height: 36px;
}



.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0px;
    flex-shrink: 0;
}

.toolbar-group-left {
    justify-content: flex-start;
}

.toolbar-group-center {
    justify-content: center;
    margin: 0 auto;
}

.toolbar-group-right {
    justify-content: flex-end;
    margin-left: auto;
}

.toolbar::-webkit-scrollbar {
    height: 4px;
}

.toolbar::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.3);
    border-radius: 2px;
}

.toolbar button {
    background: transparent;
    border: none;
    color: #e8eaed;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    font-size: 20px;
    font-weight: 300;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Toolbar-Icons einheitlich auf Panel-Größe (18px), unabhängig vom width-Attribut im HTML */
.toolbar button > svg {
    width: 18px;
    height: 18px;
}

.toolbar button:focus {
    outline: none;
}

.toolbar button:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
}

/* Nur auf Desktop :active nutzen */
@media (hover: hover) and (pointer: fine) {
    .toolbar button:active,
    .toolbar button.active {
        background: rgba(255,255,255,0.2);
    }
}

/* Select-/Cursor-Modus-Button: aktiver Zustand (kein Zeichen-Tool aktiv) dauerhaft hervorgehoben,
   unabhängig vom Hover-Medium. Größe/Trefferziel wie die übrigen Toolbar-Buttons (Konsistenz). */
.toolbar #selectToolBtn.active {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

.toolbar button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.divider {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.2);
    margin: 0 4px;
}

/* Nur sichtbar wenn ein Markup geöffnet ist (Farbe, Löschen + zugehörige Divider). Im Startscreen
   ausgeblendet — wie Tools/Export/Drucken. body.has-markup wird beim Laden gesetzt. */
body:not(.has-markup) .markup-only {
    display: none !important;
}

/* ============================================================
   HIERARCHISCHE TOOL-LEISTE (Kategorien → Typen → Einstellungen)
   Flache Flex-Reihen innerhalb der ohnehin scrollbaren .toolbar.
   ============================================================ */
.tool-categories {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}
.tool-cat-row,
.tool-expand-row,
.tool-type-row,
.tool-settings-row {
    display: flex;
    align-items: center;
    /* 2px zwischen den direkten Einstellungs-Controls (Einheit/„+"/Einrasten/Transparenz), damit
       einzelne Buttons nicht aneinanderkleben — gleicher Abstand wie im schwebenden .format-panel
       und wie die B/I/U-Buttons innerhalb der Text-.control-group. */
    gap: 2px;
    flex-shrink: 0;
}

/* Visuelle Tiefe der 3 Ebenen über abgestufte Helligkeit (statt Pillen → platzsparend):
   Ebene 1 (Kategorien) = Toolbar-Dunkel, Ebene 2 (Typen) heller, Ebene 3 (Einstellungen) am
   hellsten. Kleiner Abstand + Rundung setzt die Ebenen optisch ab. */
/* .tool-expand-row:not(:empty) {
    margin-left: 1px;
} */
/* Ebene 2 teilt die Farbe mit der aktiven Kategorie, Ebene 3 mit dem aktiven Typ. Kein
   horizontales Padding → erstes Icon sitzt bündig am Block-Rand (sauber, kein Vor-Space). */
.tool-type-row {
    background: rgba(255,255,255,0.10);
    border-radius: 6px;
    padding: 0;
}
.tool-settings-row {
    background: rgba(0,0,0,0.28);
    border-radius: 6px;
    padding: 3px 6px;
    margin-left: 4px;
    gap: 4px;
}

/* Select-Modus: Tool-Kette bleibt offen, aber ausgegraut (Kontext sichtbar). Klick in den ausgegrauten
   Bereich re-aktiviert das letzte Tool → Kinder klick-inert (Klick landet auf der Reihe, die den Handler
   trägt); pro Kind ausgrauen, damit das freistehende × voll sichtbar/klickbar bleibt. */
.tool-expand-row.tool-chain-dimmed { cursor: pointer; }
.tool-expand-row.tool-chain-dimmed > *:not(.tool-close-btn) { opacity: 0.4; pointer-events: none; }

/* Kategorie- und Typ-Buttons: gleiche Optik wie die übrigen Toolbar-Buttons */
.tool-category-btn,
.tool-type-btn,
.tool-close-btn,
.tool-more-btn {
    background: transparent;
    border: none;
    color: #e8eaed;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.tool-category-btn svg,
.tool-type-btn svg,
.tool-close-btn svg,
.tool-more-btn svg { pointer-events: none; width: 18px; height: 18px; }

.tool-category-btn:hover:not(.disabled),
.tool-type-btn:hover,
.tool-close-btn:hover,
.tool-more-btn:hover {
    background: rgba(255,255,255,0.1);
}
/* Aktive Kategorie teilt die Farbe mit Ebene 2, aktiver Typ mit Ebene 3 → das Submenü wirkt wie
   eine Fortsetzung des gewählten Buttons ("man bewegt sich darin"). */
.tool-category-btn.active {
    background: rgba(255,255,255,0.10);
}
.tool-type-btn.active {
    background: rgba(255,255,255,0.18);
}
.tool-category-btn.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Schließen-Button: rundes, abgesetztes Icon. Eigener dunkler Kreis + heller Rand, damit er sich
   klar vom hellen Ebenen-Block (rgba .10/.18), in dem er sitzt, abhebt.
   Selektor mit .toolbar-Präfix → höhere Spezifität als die generische `.toolbar button`-Regel
   (die sonst width/border-radius/background überschreibt → Button blieb optisch unverändert). */
.toolbar .tool-close-btn {
    min-width: 22px;
    width: 22px;
    height: 22px;
    padding: 0;
    margin: 0 3px 0 4px;
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.35);
    color: #e8eaed;
}
.toolbar .tool-close-btn:hover { background: rgba(0,0,0,0.55); border-color: rgba(255,255,255,0.6); }
.toolbar .tool-close-btn svg { width: 12px; height: 12px; }

/* …-Button, ♥-Favorit und 📌-Pin platzsparend: schmaler als die 28px-Standardbuttons, enger
   beieinander. Runder Hover (wie bei den Farbkreisen) statt quadratisch. */
.toolbar .tool-more-btn,
.toolbar .tool-fav-btn,
.toolbar .tool-pin-btn {
    width: 26px;
    min-width: 26px;
    height: 26px;
    padding: 0;
    border-radius: 50%;
}
.toolbar .tool-more-btn svg,
.toolbar .tool-fav-btn svg,
.toolbar .tool-pin-btn svg { width: 16px; height: 16px; }
/* …-Button und 📌-Pin: KEINE dauerhafte Umrandung — nur bei Hover ein dezentes rundes Highlight. */
.toolbar .tool-more-btn,
.toolbar .tool-pin-btn { border: none; }
.toolbar .tool-more-btn:hover,
.toolbar .tool-pin-btn:hover { background: rgba(255,255,255,0.1); }
/* ♥-Favorit: KEIN Hintergrund/Umrandung beim Hover — stattdessen füllt sich das Herz mit dem
   Grau-Verlauf (dunkel oben → hell unten). */
.toolbar .tool-fav-btn,
.toolbar .tool-fav-btn:hover { background: transparent; border: none; }
.tool-fav-btn .fav-heart { transition: fill 0.15s; }
.tool-fav-btn:hover .fav-heart { fill: url(#favHeartGrad); stroke: none; }

/* Gruppen-/Multi-Selektion: "Gruppe (N)"-Indikator statt Kategorie/Typ-Dropdown. */
.toolbar .tool-group-badge {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 28px;
    width: auto;
    padding: 0 6px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.10);
    color: #e8eaed;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    cursor: pointer;
    transition: background 0.12s;
}
.toolbar .tool-group-badge:hover { background: rgba(255,255,255,0.20); }
.toolbar .tool-group-badge:active { background: rgba(255,255,255,0.28); }
/* Link-Icon füllt seine 24er-Viewbox stärker als die Tool-Icons → kleiner setzen, damit es
   optisch zu den 18px-Tool-Icons passt. Höhere Spezifität schlägt `.toolbar button > svg` (18px). */
.toolbar .tool-group-badge > svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Ebene-3-Controls (aus ControlRegistry) bündig einpassen */
.tool-settings-row > .opacity-control,
.tool-settings-row > .format-btn,
.tool-settings-row > .icon-dropdown,
.tool-settings-row > .control-group { flex-shrink: 0; }



#pageInfo,
#zoomLevel {
    color: #e8eaed;
    font-size: 13px;
    min-width: 50px;
    text-align: center;
}

#viewer {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    /* safe: zentriert nur solange der Inhalt passt; ist er breiter als der Viewer,
       wird am linken Rand verankert (sonst ist der linke Seitenrand unscrollbar
       und Zoom-zu-Cursor springt). */
    justify-content: safe center;
    position: relative;
    padding: 20px;
    touch-action: pan-x pan-y pinch-zoom;
    transition: margin-left 0.3s ease;
    overflow-anchor: none; /* Verhindert automatische Scroll-Anpassung bei Layout-Änderungen */
}

/* iOS Safari zoomt automatisch auf Inputs mit font-size < 16px beim Fokussieren.
   Auf Touch-Geräten alle Inputs auf 16px setzen um dieses Verhalten zu verhindern. */
@media (hover: none) and (pointer: coarse) {
    input, textarea, select {
        font-size: 16px;
    }
}

/* Reduziertes Padding für schmale Viewports */
@media (max-width: 768px) {
    #viewer {
        padding: 10px;
    }
}

@media (max-width: 480px) {
    #viewer {
        padding: 5px;
    }
}

#viewer.sidebar-open {
    margin-left: 250px;
}

#dropzone {
    position: fixed;
    inset: 48px 0 24px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    z-index: 1;
    pointer-events: auto;
    background: #525659;
    padding-top: 32px;
}

#dropzone.hidden {
    display: none;
}

.dropzone-content {
    text-align: center;
    color: #e8eaed;
    pointer-events: auto;
    max-width: 600px;
    margin: auto;
    padding: 40px 20px 56px;
    border: none;
    border-radius: 8px;
    background: rgba(50, 54, 57, 0.5);
    position: relative;
}

/* Border mit SVG - hat Lücke unten */
.dropzone-content::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 8px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="none" viewBox="0 0 600 400"><rect x="0.5" y="0.5" width="599" height="399" fill="none" stroke="%23676767" stroke-width="1" stroke-dasharray="3,3" rx="8" ry="8"/><rect x="282" y="397" width="36" height="4" fill="%23424649"/></svg>');
    background-size: 100% 100%;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 10;
}

/* Gestricheltes Außendreieck */
.dropzone-content::after {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="16"><path d="M 1 1 L 16 15 L 31 1" fill="none" stroke="%23676767" stroke-width="1" stroke-dasharray="3,3" stroke-linecap="square" stroke-linejoin="miter"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    z-index: 11;
}

/* Gefülltes Innendreieck */
.border-notch {
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 15px solid rgba(50, 54, 57, 0.5);
    z-index: 1;
}

.dropzone-title {
    font-size: 32px;
    font-weight: 400;
    color: #9aa0a6;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.dropzone-subtitle {
    font-size: 14px;
    color: #9aa0a6;
    margin-bottom: 12px;
    line-height: 1.5;
}

.dropzone-protip {
    font-size: 13px;
    color: #9aa0a6;
    margin-bottom: 32px;
    line-height: 1.4;
}

.dropzone-protip strong {
    font-weight: 600;
}

.upload-btn {
    background: #1a73e8;
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 500px;
    justify-content: center;
}

.upload-btn:hover {
    background: #1557b0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(26, 115, 232, 0.4);
}

.upload-btn svg {
    flex-shrink: 0;
}

.blank-canvas-container {
    display: flex;
    align-items: stretch;
    gap: 0;
    width: 100%;
    max-width: 500px;
    position: relative;
    margin: 0 auto;
}

.blank-canvas-btn {
    background: transparent;
    color: #e8eaed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: none;
    padding: 14px 28px;
    border-radius: 6px 0 0 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    justify-content: center;
}

.blank-canvas-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.blank-canvas-btn svg {
    flex-shrink: 0;
}

.blank-canvas-size-btn {
    background: transparent;
    color: #e8eaed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: none;
    border-radius: 0;
    padding: 14px 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    position: relative;
}

.blank-canvas-size-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.blank-canvas-size-btn svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.blank-canvas-orient-btn {
    background: transparent;
    color: #e8eaed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-right: none;
    padding: 0 9px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: background 0.15s;
}

.blank-canvas-orient-btn svg {
    opacity: 0.5;
    transition: opacity 0.15s;
}

.blank-canvas-orient-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.blank-canvas-orient-btn:hover svg {
    opacity: 0.9;
}

.blank-canvas-size-dropdown {
    display: none;
    flex-direction: column;
    background: rgba(50, 54, 57, 0.97);
    border-radius: 6px;
    padding: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1001;
    min-width: 200px;
    overflow-y: auto;
}

.blank-canvas-size-dropdown.show {
    display: flex;
}

.blank-canvas-size-dropdown.dropdown-above {
    top: auto;
    bottom: calc(100% + 8px);
}

.blank-canvas-size-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    background: transparent;
    border: none;
    color: #e8eaed;
    font-size: 13px;
    width: 100%;
    text-align: left;
    transition: background 0.15s;
}

.blank-canvas-size-option:hover {
    background: rgba(255, 255, 255, 0.08);
}

.blank-canvas-size-option.active {
    color: #8ab4f8;
}

.blank-canvas-size-option-name {
    font-weight: 600;
}

.blank-canvas-size-option-label {
    opacity: 0.55;
    font-size: 11px;
}

.blank-canvas-size-custom {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px;
}

.blank-canvas-size-custom input {
    width: 60px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #e8eaed;
    padding: 4px 6px;
    font-size: 13px;
    text-align: center;
}

.blank-canvas-size-custom span {
    opacity: 0.5;
    font-size: 13px;
}

.blank-canvas-size-custom button {
    background: rgba(138, 180, 248, 0.15);
    border: 1px solid rgba(138, 180, 248, 0.3);
    border-radius: 4px;
    color: #8ab4f8;
    padding: 4px 10px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s;
}

.blank-canvas-size-custom button:hover {
    background: rgba(138, 180, 248, 0.25);
}

.blank-canvas-color-btn {
    background: transparent;
    color: #e8eaed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 14px 12px;
    border-radius: 0 6px 6px 0;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.blank-canvas-color-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.paste-clipboard-btn {
    background: transparent;
    color: #e8eaed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 14px 28px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 500px;
    justify-content: center;
    font-family: inherit;
}

.paste-clipboard-btn:not(:disabled):hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.paste-clipboard-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.paste-clipboard-btn svg { flex-shrink: 0; }

.scan-btn {
    background: transparent;
    color: #e8eaed;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 14px 28px;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    width: 100%;
    max-width: 500px;
    justify-content: center;
}

.scan-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.3);
}

.scan-btn svg {
    flex-shrink: 0;
}

.blank-canvas-color-indicator {
    width: 20px;
    height: 20px;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: #FFFFFF;
}

.blank-canvas-color-btn svg {
    flex-shrink: 0;
    opacity: 0.6;
}

.blank-canvas-color-dropdown {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background: rgba(50, 54, 57, 0.95);
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 1000;
}

.blank-canvas-color-dropdown.dropdown-above {
    top: auto;
    bottom: calc(100% + 8px);
}

.blank-canvas-color-dropdown.show {
    display: grid;
}

.blank-canvas-color-option {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    border: 2px solid transparent;
    width: 32px;
    height: 32px;
}

.blank-canvas-color-option:hover {
    border-color: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.blank-canvas-color-preview {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#canvasContainer {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* gap wird per JS scale-abhängig gesetzt (PAGE_GAP_BASE * scale), damit der Abstand
       beim Phase-1-Transform und Phase-2-Layout identisch ist und beim Zoom nicht springt.
       Fallback 20px falls JS (noch) nicht gesetzt hat. */
    gap: 20px;
    box-shadow: none;
}

#canvasContainer.has-pdf {
    display: flex;
}

.page-wrapper {
    position: relative;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    line-height: 0;
    overflow: hidden;
    background: white;
}

.page-canvas {
    display: block;
}

.page-form-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 10;
    pointer-events: auto;
}

/* NEU: Canvas für Formularfeld-Editor (darüber!) */
.page-edit-form-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 15;
    pointer-events: none; /* Initial keine Klicks - wird per JS gesteuert */
}

.page-annotation-canvas {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 20;
    pointer-events: none;
}

.page-annotation-canvas.text-mode {
    pointer-events: auto;
    cursor: text;
}

.page-annotation-canvas.draw-mode {
    pointer-events: auto;
    cursor: crosshair;
}

.page-annotation-canvas.rectangle-mode {
    pointer-events: auto;
    cursor: crosshair;
}

.page-annotation-canvas.oval-mode {
    pointer-events: auto;
    cursor: crosshair;
}

.page-annotation-canvas.arrow-mode {
    pointer-events: auto;
    cursor: crosshair;
}

.page-annotation-canvas.has-selection {
    pointer-events: auto;
}

#formCanvas {
    z-index: 10;
    pointer-events: auto;
}

#annotationCanvas {
    z-index: 20;
    /* Standard: Events durchreichen an darunterliegende Layer */
    pointer-events: none;
}

/* Im aktiven Tool-Modus: Volle Interaktion nötig */
#annotationCanvas.text-mode,
#annotationCanvas.draw-mode,
#annotationCanvas.rectangle-mode,
#annotationCanvas.oval-mode,
#annotationCanvas.arrow-mode {
    pointer-events: auto;
}

/* Bei Selektion: Volle Interaktion zum Verschieben */
#annotationCanvas.has-selection {
    pointer-events: auto;
}

/* Wenn Annotationen existieren aber keine ausgewählt:
   pointer-events bleiben aus, damit Formularfelder klickbar sind.
   Annotationen werden über formCanvas-Handler angeklickt */

#annotationCanvas.text-mode {
    cursor: text;
}

#annotationCanvas.draw-mode,
#annotationCanvas.rectangle-mode,
#annotationCanvas.oval-mode,
#annotationCanvas.arrow-mode {
    cursor: crosshair;
}


.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #323639;
    padding: 4px;
    border-radius: 8px;
    border-style: dashed;
    border-width: 1px;
    border-color: #676767;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    width: min(400px, calc(100vw - 64px));
    max-width: 90vw;
    position: relative;
    box-sizing: border-box;
}

/* Dreieck unter dem Modal - nur bei Text-Editor */
/* Gestricheltes Dreieck mit SVG */
.modal-content::after {
    content: '';
    position: absolute;
    bottom: -16px;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="32" height="16"><path d="M 1 1 L 16 15 L 31 1" fill="none" stroke="%23676767" stroke-width="1" stroke-dasharray="3,3" stroke-linecap="square" stroke-linejoin="miter"/></svg>');
    background-repeat: no-repeat;
    background-position: center;
    display: none;
    z-index: 2;
}

/* Inneres gefülltes Dreieck */
.modal-content::before {
    content: '';
    position: absolute;
    bottom: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 15px solid transparent;
    border-right: 15px solid transparent;
    border-top: 15px solid #323639;
    z-index: 1;
    display: none;
}

/* Dreieck nur bei Text-Editor anzeigen */
.modal.show[data-text-editor-modal] .modal-content::after,
.modal.show[data-text-editor-modal] .modal-content::before {
    display: block;
}

/* Dreieck nur bei Unterschriften-Modal anzeigen */
#signatureModal.show .modal-content::after,
#signatureModal.show .modal-content::before {
    display: block;
}

.modal-close-btn {
    position: absolute !important;
    top: -1px !important;
    right: -1px !important;
    width: 40px !important;
    height: 40px !important;
    border: none !important;
    background: #202124 !important;
    color: white !important;
    border-radius: 0 8px 0 8px !important;
    cursor: pointer !important;
    font-size: 24px !important;
    line-height: 1 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    opacity: 0.7 !important;
    transition: opacity 0.2s !important;
    z-index: 10000 !important;
    padding: 0 !important;
    margin: 0 !important;
    font-weight: normal !important;
    user-select: none !important;
}

.modal-close-btn:hover {
    opacity: 1 !important;
}

.modal-insert-btn {
    position: absolute !important;
    bottom: -1px !important;
    right: -1px !important;
    width: 40px !important;
    height: 40px !important;
    padding: 0 !important;
    background: #1a73e8 !important;
    color: white !important;
    border: none !important;
    border-radius: 8px 0 8px 0 !important;
    cursor: pointer !important;
    font-size: 14px !important;
    font-weight: 500 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: opacity 0.2s !important;
    z-index: 10000 !important;
    margin: 0 !important;
}

.modal-insert-btn:hover {
    opacity: 0.9;
}

#signatureCanvas {
    background: #c1c1c1;
    border: 0px solid #5f6368;
    border-radius: 4px;
    cursor: crosshair;
    display: block;
    width: 100%;
}

.modal-buttons {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s, opacity 0.2s;
}

.modal-buttons button:hover {
    opacity: 0.9;
}

#clearSignature {
    background: transparent;
    color: #e8eaed;
}

#clearSignature:hover {
    background: rgba(255,255,255,0.1);
}

#cancelSignature {
    background: transparent;
    color: #e8eaed;
    margin-left: auto;
}

#cancelSignature:hover {
    background: rgba(255,255,255,0.1);
}

#saveSignature {
    background: #8ab4f8;
    color: #202124;
    font-weight: 500;
}

#saveSignature:hover {
    background: #aecbfa;
}

.signature-item {
    user-select: none;
}

.signature-item:hover {
    transform: translateY(-1px);
}

#signatureListContainer::-webkit-scrollbar {
    width: 8px;
}

#signatureListContainer::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#signatureListContainer::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

#signatureListContainer::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Loader */
.pdf-loader {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.pdf-loader.show {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #8ab4f8;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-text {
    color: #e8eaed;
    margin-top: 16px;
    font-size: 14px;
}

/* Color Picker */
.color-picker {
    position: relative;
    display: inline-block;
}

.color-btn {
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.color-indicator {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #000000;
    border: 2px solid #e8eaed;
    pointer-events: none;
}

/* Color Dropdown - STRIKT einzeilig */
.color-dropdown {
    display: none;
    position: fixed;
    background: #323639;
    border-radius: 8px;
    padding: 2px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 99999999;
    max-width: calc(100vw - 20px);
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    height: 38px;
    line-height: 26px;
}

.color-dropdown::-webkit-scrollbar {
    height: 6px;
}

.color-dropdown::-webkit-scrollbar-track {
    background: rgba(255,255,255,0.05);
    border-radius: 3px;
}

.color-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 3px;
}

.color-dropdown.show {
    display: block !important;
    visibility: visible !important;
}

.color-dropdown > * {
    display: inline-block !important;
    vertical-align: middle !important;
    margin: 0 2px !important;
}

.color-grid {
    display: inline-block !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
}

.color-grid > * {
    display: inline-block !important;
    vertical-align: middle !important;
    margin: 0 2px !important;
}

.color-option {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
    display: inline-block;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.color-option.selected {
    border-color: #8ab4f8;
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.3);
}

#customColorConfirm:hover {
    background: #2b7de9 !important;
}

.stroke-width-grid {
    display: inline-block !important;
    white-space: nowrap !important;
    vertical-align: middle !important;
}

.stroke-width-grid > * {
    display: inline-block !important;
    vertical-align: middle !important;
    margin: 0 2px !important;
}

.stroke-width-option {
    width: 26px;
    height: 26px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    background: #202124;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    flex-shrink: 0;
    padding: 2px;
}

.stroke-width-option svg {
    fill: #e8eaed;
}

.stroke-width-option:hover {
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.stroke-width-option.selected {
    border-color: #8ab4f8;
    box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.3);
}

.stroke-width-option svg {
    pointer-events: none;
}

/* Text Format Panel */
.format-panel,
.text-format-panel,
.rectangle-format-panel,
.arrow-format-panel {
    position: fixed;
    background: #323639;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    border: 1px solid rgba(255,255,255,0.1);
    font-size: 13px;
    pointer-events: none;
}

.text-format-panel,
.rectangle-format-panel,
.arrow-format-panel { padding: 1px; gap: 4px; }

/* ============================================================
   BASE-PANEL-DESIGN (generisches #formatPanel)
   Jedes Control ist ein direktes Panel-Kind mit einheitlicher Höhe (28px)
   und konstantem Abstand. Composite-Controls (Pfeil, Text) bündeln ihre
   Elemente in .control-group, damit sie ein einziges, gleichmäßiges Glied bilden.
   ============================================================ */
.format-panel {
    padding: 2px;
    gap: 2px;
}

/* Direkte Glieder + Glieder innerhalb einer Gruppe: gleiche Höhe, vertikal zentriert.
   Gilt im schwebenden Panel UND in der Toolbar-Ebene-3 (.tool-settings-row), damit
   Composite-Controls (Pfeil-Köpfe, Text-Format) NICHT vertikal stapeln. */
.format-panel > *,
.format-panel .control-group,
.tool-settings-row .control-group,
.annotation-edit-popup .aep-extras .control-group {
    pointer-events: auto;
    display: flex;
    align-items: center;
    height: 28px;
}

/* Composite-Control (Pfeil-Köpfe, Text-Format): innere Glieder gleichmäßig gruppiert */
.format-panel .control-group,
.tool-settings-row .control-group,
.annotation-edit-popup .aep-extras .control-group {
    gap: 2px;
}

/* Trenner zwischen Control-Gruppen */
.format-panel .control-group + .control-group::before,
.tool-settings-row .control-group + .control-group::before {
    content: '';
    width: 1px;
    height: 18px;
    background: rgba(255,255,255,0.18);
    margin: 0 1px;
}

/* Buttons exakt wie im Kontextmenü: 28×28, 18px-Icons, gleicher Rahmen/Radius */
.format-panel .format-btn,
.format-panel .icon-dd-trigger,
.tool-settings-row .format-btn,
.tool-settings-row .icon-dd-trigger,
.annotation-edit-popup .aep-extras .format-btn,
.annotation-edit-popup .aep-extras .icon-dd-trigger {
    width: 28px;
    height: 28px;
    padding: 6px;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    background: transparent;
}

.format-panel .format-btn svg,
.format-panel .icon-dd-trigger svg,
.tool-settings-row .format-btn svg,
.tool-settings-row .icon-dd-trigger svg,
.annotation-edit-popup .aep-extras .format-btn svg,
.annotation-edit-popup .aep-extras .icon-dd-trigger svg {
    width: 18px;
    height: 18px;
}

/* Aktive Toggle-Buttons (Bold/Italic/Underline, Rahmen): deutlich hervorgehoben, damit der
   Zustand sichtbar ist. */
.format-panel .format-btn.active,
.tool-settings-row .format-btn.active,
.annotation-edit-popup .aep-extras .format-btn.active {
    background: rgba(138,180,248,0.18);
    border-color: #8ab4f8;
}

/* AUSNAHME Füllen-Button: dessen Zustand trägt das Icon selbst (gefülltes vs. Outline-Quadrat) —
   daher kein aktiver Hintergrund, ruhige Optik. */
.format-panel .fill-toggle-btn.active,
.tool-settings-row .fill-toggle-btn.active,
.annotation-edit-popup .aep-extras .fill-toggle-btn.active {
    background: transparent;
    border-color: rgba(255,255,255,0.2);
}

.format-panel select,
.text-format-panel select,
.annotation-edit-popup .aep-extras select {
    background: #202124;
    color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 6px 8px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.format-panel select:hover,
.text-format-panel select:hover {
    background: #292b2e;
}

.format-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: #e8eaed;
    padding: 6px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    width: 28px;
    height: 28px;
}

.format-btn:hover {
    background: rgba(255,255,255,0.1);
}

.format-btn.active {
    background: #1a73e8;
    border-color: #1a73e8;
}

.format-btn svg {
    pointer-events: none;
}

.format-separator {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.2);
    margin: 0 2px;
}

.format-label-group {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 4px;
    color: #9aa0a6;
}

.format-select-small {
    background: #202124;
    color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    padding: 4px 4px;
    font-size: 12px;
    cursor: pointer;
    outline: none;
    width: 60px;
}

.format-select-small:hover {
    background: #292b2e;
}

.opacity-control {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-right: 8px;
    /* border-left: 1px solid rgba(255,255,255,0.2); */
}

/* Im Base-Panel UND in der Toolbar-Ebene-3 kompakt: schmaler Slider, minimaler Innenabstand,
   feste Höhe (28px) damit der 4px-Slider die Reihe nicht vertikal kollabieren lässt. */
.format-panel .opacity-control,
.tool-settings-row .opacity-control {
    gap: 0;
    padding: 0 4px;
    height: 28px;
}

.format-panel .opacity-control input[type="range"],
.tool-settings-row .opacity-control input[type="range"] {
    width: 64px;
}

.opacity-control label {
    display: flex;
    align-items: center;
    color: #e8eaed;
}

.opacity-control input[type="range"] {
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,0.2);
    outline: none;
    -webkit-appearance: none;
}

.opacity-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #1a73e8;
    cursor: pointer;
}

.opacity-control input[type="range"]::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #1a73e8;
    cursor: pointer;
    border: none;
}

.opacity-control span {
    color: #e8eaed;
    font-size: 12px;
    min-width: 38px;
    text-align: right;
}

/* ============================================================
   Annotation-Aktionsleiste (Bild 1) + Edit-Popup (Bild 2)
   Fixiert am Viewport-Boden, Mitbewerber-Stil.
   ============================================================ */

.annotation-action-bar {
    position: fixed;
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1002;
    display: none;
    align-items: center;
    gap: 6px;
    padding: 2px 4px 2px 8px;
    background: rgba(32, 33, 36, 0.96);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
    color: #e8eaed;
    max-width: calc(100vw - 24px);
}

.aab-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.aab-type-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
}

.aab-type-icon svg { width: 18px; height: 18px; }

.aab-meta-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    min-width: 0;
}

.aab-author {
    font-size: 12px;
    font-weight: 600;
    color: #e8eaed;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aab-date {
    font-size: 10px;
    color: #9aa0a6;
    white-space: nowrap;
}

.aab-divider {
    width: 1px;
    height: 22px;
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.aab-actions {
    display: flex;
    align-items: center;
    gap: 1px;
}

.aab-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 8px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #e8eaed;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}

.aab-btn-icon { display: flex; align-items: center; }
.aab-btn-icon svg { width: 16px; height: 16px; }

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

.aab-btn.active {
    background: rgba(138, 180, 248, 0.18);
    color: #8ab4f8;
}

.aab-btn[data-action="delete"]:hover:not(:disabled) {
    background: rgba(229, 57, 53, 0.2);
    color: #ff6b6b;
}

@media (hover: hover) and (pointer: fine) {
    .aab-btn:hover:not(:disabled) {
        background: rgba(255, 255, 255, 0.1);
    }
}

/* --- Edit-Popup --- */
.annotation-edit-popup {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1003;
    display: none;
    flex-direction: column;
    gap: 2px;
    width: 288px;
    max-width: calc(100vw - 24px);
    padding: 5px 6px;
    background: rgba(32, 33, 36, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    color: #e8eaed;
}

.aep-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0;
}

.aep-color-row { padding-top: 2px; }

/* Segmentierter „Rand | Füllung"-Umschalter (nur bei Formen) */
.aep-paint-toggle-row { padding: 2px 0 6px; }
.aep-seg {
    display: flex;
    gap: 2px;
    padding: 2px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
}
.aep-seg-btn {
    flex: 1;
    padding: 5px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #9aa0a6;
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}
.aep-seg-btn:hover { color: #e8eaed; }
.aep-seg-btn.active {
    background: #1a73e8;
    color: #ffffff;
}

.aep-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.aep-swatch {
    position: relative;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: none;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
    transition: transform 0.12s;
}

/* Aktive Farbe: sauberer weißer Ring mit Abstand zur Füllung (2px-Lücke), wie beim Vorbild.
   Ein einzelner box-shadow-Stack (Lücke in Panel-Farbe + weißer Ring außen) statt border+shadow-Mix. */
.aep-swatch.active {
    box-shadow:
        0 0 0 2px #202124,
        0 0 0 4px #ffffff;
}

/* „Keine"-Feld: leerer Kreis mit diagonaler roter Linie (Rand/Füllung aus). */
.aep-swatch-none {
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.aep-swatch-none::after {
    content: '';
    position: absolute;
    top: 50%;
    left: -2px;
    right: -2px;
    height: 2px;
    background: #e53935;
    transform: rotate(-45deg);
    transform-origin: center;
}
.aep-swatch-none.active {
    box-shadow:
        0 0 0 2px #202124,
        0 0 0 4px #ffffff;
}

/* <label> statt <button> (iOS-Farbwähler) → die button-Regeln oben greifen hier nicht mehr. */
.aep-swatch-more {
    background: rgba(255, 255, 255, 0.08);
    color: #e8eaed;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
    box-shadow: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
/* Trägt der …-Button eine eigene Farbe → Farbe als Hintergrund, die 3 Punkte bleiben SICHTBAR. */
.aep-swatch-more.has-color { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25); color: #fff; }
.aep-swatch-more.has-color svg { filter: drop-shadow(0 0 1.5px rgba(0,0,0,0.9)); }

/* Siehe .cpp-color-input: deckungsgleich über dem …-Feld, damit iOS den Tap als echte
   Nutzerinteraktion auf dem Control wertet. */
.aep-color-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}

@media (hover: hover) and (pointer: fine) {
    .aep-swatch:hover { transform: scale(1.12); }
}

.aep-label {
    font-size: 12px;
    color: #9aa0a6;
}

.aep-slider-track {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Slider + darunterliegende Skala; Höhe reserviert die Skalenzeile. */
.aep-slider-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    padding-bottom: 14px;
}

.aep-slider-wrap input[type="range"] {
    display: block;
    width: 100%;
    height: 4px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.2);
    outline: none;
    -webkit-appearance: none;
    margin: 0;
}

.aep-slider-wrap input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.aep-slider-wrap input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ffffff;
    cursor: pointer;
    border: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Skala unter dem Slider */
.aep-scale {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 12px;
    font-size: 9px;
    color: #80868b;
    pointer-events: none;
}

/* Absolute Beschriftung (Deckkraft: 25/50/75/100 an ihrer Prozent-Position) */
.aep-scale-abs span {
    position: absolute;
    transform: translateX(-50%);
    top: 0;
}

/* Gestufte Skala (Dicke): Ticks absolut an der exakten Thumb-Position (left inline gesetzt). */
.aep-scale-stepped {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
}
.aep-tick {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}
.aep-tick-dot {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
}
.aep-tick-num {
    color: #80868b;
    min-height: 9px;
}
.aep-tick.active .aep-tick-dot { background: #ffffff; }
.aep-tick.active .aep-tick-num { color: #e8eaed; font-weight: 700; }

/* Feinstufen unter 1pt: nur ein kleinerer, dezenter Punkt, keine Zahl. */
.aep-tick-minor .aep-tick-dot {
    width: 2px;
    height: 2px;
    background: rgba(255, 255, 255, 0.22);
}

/* Wert-Dropdown (Schnellauswahl) rechts */
.aep-value-dd {
    position: relative;
    flex-shrink: 0;
}
.aep-value-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    /* FESTE Breite: sonst wächst der Button bei breiteren Labels („0,25pt" vs. „1pt") und
       verschiebt den Slider-Track → Skala und Thumb würden auseinanderlaufen. */
    width: 68px;
    box-sizing: border-box;
    justify-content: space-between;
    font-size: 11px;
    font-weight: 600;
    color: #e8eaed;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 6px;
    padding: 4px 7px;
    cursor: pointer;
}
.aep-value-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.aep-value-btn:hover { background: rgba(255, 255, 255, 0.14); }
.aep-value-caret { display: flex; opacity: 0.7; }

.aep-value-menu {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 6px);
    flex-direction: column;
    min-width: 84px;
    background: #202124;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.6);
    padding: 4px;
    z-index: 10;
    max-height: 208px;
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.25) transparent;
}
.aep-value-dd.open .aep-value-menu { display: flex; }

/* Schlanke, dezente Scrollbar (WebKit) — nicht der fette OS-Default. */
.aep-value-menu::-webkit-scrollbar { width: 6px; }
.aep-value-menu::-webkit-scrollbar-track { background: transparent; }
.aep-value-menu::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.22);
    border-radius: 3px;
}
.aep-value-menu::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.35); }

.aep-value-item {
    text-align: left;
    font-size: 13px;
    color: #e8eaed;
    background: transparent;
    border: none;
    border-radius: 5px;
    padding: 7px 12px;
    cursor: pointer;
    white-space: nowrap;
}
.aep-value-item:hover { background: rgba(255, 255, 255, 0.08); }
/* Aktueller Wert hervorgehoben (Akzentfarbe wie beim Vorbild). */
.aep-value-item.active { color: #8ab4f8; font-weight: 700; }

.aep-extras {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 2px;
    padding-top: 8px;
}

/* Mobile: Aktionsleiste über die Bottom-Pills (bottom-left-bar / page-widget) heben. */
@media (max-width: 768px) {
    .annotation-action-bar {
        bottom: max(76px, calc(env(safe-area-inset-bottom) + 76px));
    }
    /* Nur das Label ausblenden — die kompakten Grundmaße (Padding/Icon-Größe) kommen aus den
       Desktop-Regeln und sollen NICHT durch größere Mobile-Werte überschrieben werden. */
    .aab-btn {
        gap: 0;
    }
    .aab-btn-label { display: none; }
    .annotation-edit-popup {
        bottom: max(126px, calc(env(safe-area-inset-bottom) + 126px));
    }
}

/* Hide mobile select on all devices */
.mobile-stroke-select {
    display: none !important;
}

/* Signature Modal Desktop Layout */
.signature-modal-layout {
    display: grid;
    grid-template-columns: 1fr 200px;
    gap: 12px;
    align-items: start;
}

.signature-canvas-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.signature-list-section {
    display: block;
}

/* Desktop: Modal Content max-width für Unterschriften */
#signatureModal .modal-content {
    max-width: 700px;
    width: auto;
}

/* Schmale Bildschirme/Fenster: Modal-Anpassungen */
@media (max-width: 600px) {
    .modal {
        padding: 16px !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }
    
    /* NUR Text-Editor Modal - behalte normale Breite */
    .modal[data-text-editor-modal] .modal-content {
        max-height: none !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }
    
    /* Text-Editor Toolbar anpassen */
    .modal[data-text-editor-modal] .text-editor-toolbar {
        flex-wrap: wrap !important;
    }
    
    /* Text-Editor Toolbar Elemente */
    .modal[data-text-editor-modal] .text-editor-toolbar select,
    .modal[data-text-editor-modal] .text-editor-toolbar button {
        flex-shrink: 0 !important;
    }
    
    /* Textarea im Text-Modal */
    .modal[data-text-editor-modal] .modal-content div[contenteditable] {
        max-height: 40vh !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }
    
    /* Unterschriften-Modal Layout Fix */
    .signature-modal-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .signature-canvas-section,
    .signature-list-section {
        width: 100% !important;
    }
    
    #signatureCanvas {
        max-width: 100% !important;
        height: auto !important;
    }
    
    #signatureListContainer {
        max-height: 150px !important;
        overflow-y: auto !important;
    }
    
    /* Dreieck bei schmalen Bildschirmen ZEIGEN (unten) */
    .modal.show[data-text-editor-modal] .modal-content::after,
    .modal.show[data-text-editor-modal] .modal-content::before,
    #signatureModal.show .modal-content::after,
    #signatureModal.show .modal-content::before {
        display: block !important;
    }
}

/* Mobile Responsive (Tablets & größere Phones) */
@media (min-width: 601px) and (max-width: 768px) {
    
    /* Toolbar scrollbar auf Mobile ausblenden */
    .toolbar::-webkit-scrollbar {
        display: none;
    }
    
    .toolbar {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    /* NUR Text-Editor Modal - behalte normale Breite */
    .modal[data-text-editor-modal] .modal-content {
        max-height: none !important;
        overflow: visible !important;
        box-sizing: border-box !important;
    }
    
    /* Text-Editor Toolbar anpassen */
    .modal[data-text-editor-modal] .text-editor-toolbar {
        flex-wrap: wrap !important;
    }
    
    /* Text-Editor Toolbar Elemente */
    .modal[data-text-editor-modal] .text-editor-toolbar select,
    .modal[data-text-editor-modal] .text-editor-toolbar button {
        flex-shrink: 0 !important;
    }
    
    /* Textarea im Text-Modal */
    .modal[data-text-editor-modal] .modal-content div[contenteditable] {
        max-height: 40vh !important;
        overflow-y: auto !important;
        box-sizing: border-box !important;
    }
    
    /* Unterschriften-Modal Layout Fix */
    .signature-modal-layout {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    .signature-canvas-section,
    .signature-list-section {
        width: 100% !important;
    }
    
    /* Dreieck bei Mobile auch anzeigen */
    .modal.show[data-text-editor-modal] .modal-content::after,
    .modal.show[data-text-editor-modal] .modal-content::before,
    #signatureModal.show .modal-content::after,
    #signatureModal.show .modal-content::before {
        display: block !important;
    }
    
    /* Grid Layout auf Mobile überschreiben */
    #signatureModal .modal-content > div[style] {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    #signatureCanvas {
        height: 180px !important;
        width: 100% !important;
    }
    
    #signatureListContainer {
        max-height: 120px !important;
        width: 100% !important;
    }
    
    .modal-content h4 {
        font-size: 13px !important;
    }
    
    .modal-buttons {
        flex-wrap: wrap;
    }
    
    .modal-buttons button {
        flex: 1;
        min-width: 100px;
    }
}

/* Arrow Format Panel — Icon-Dropdowns */
.arrow-format-panel {
    gap: 4px;
}

.icon-dropdown {
    position: relative;
}

.icon-dd-trigger {
    background: #202124;
    color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 5px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 10px;
    font-weight: 700;
    padding: 0;
    transition: background 0.15s;
}

.icon-dd-trigger:hover {
    background: #292b2e;
}

.icon-dd-menu {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #2a2d30;
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 4px;
    flex-direction: column;
    gap: 2px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.6);
    z-index: 1010;
    white-space: nowrap;
}

.icon-dropdown.open .icon-dd-menu {
    display: flex;
}

/* Hinweis: In der Toolbar werden Icon-Dropdown-Menüs per position:fixed positioniert
   (ArrowHeadControl/LineStyleControl), da das overflow der Toolbar absolut positionierte
   Menüs sonst abschneidet. Keine spezielle top/bottom-Regel hier nötig. */

/* ── Eingeklappte Ebenen (Kategorie/Typ als Dropdown) ─────────────────────────
   Trigger = Icon der aktiven Auswahl + Caret. Menü-Einträge = Icon + Name. */
.tool-collapsed-dd .icon-dd-trigger {
    width: auto;
    gap: 2px;
    padding: 0 4px;
}
.tool-collapsed-dd .icon-dd-trigger .dd-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}
.tool-collapsed-dd .icon-dd-trigger .dd-icon svg { width: 18px; height: 18px; }
.tool-collapsed-dd .icon-dd-trigger .dd-caret {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    line-height: 0;
}
/* Caret-Größe explizit erzwingen — sonst bläst die generische .tool-type-btn svg-Regel
   (18px) das Caret beim Typ-Dropdown-Trigger auf. */
.tool-collapsed-dd .icon-dd-trigger .dd-caret svg {
    width: 8px !important;
    height: 8px !important;
}

/* Menü mit Icon + Text-Label (linksbündig, kompakte Zeilen).
   Höhere Spezifität (.icon-dd-menu.icon-dd-menu-labeled), damit die generische
   .icon-dd-menu button { justify-content: center }-Regel sicher überschrieben wird. */
.icon-dd-menu.icon-dd-menu-labeled button {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 6px 10px 6px 8px;
    font-size: 13px;
    white-space: nowrap;
}
.icon-dd-menu-labeled .dd-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    flex-shrink: 0;
}
.icon-dd-menu-labeled .dd-icon svg { width: 18px; height: 18px; }
.icon-dd-menu.icon-dd-menu-labeled button.active {
    background: rgba(138,180,248,0.18);
    border-color: transparent;
}
.icon-dd-menu.icon-dd-menu-labeled button.disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.icon-dd-menu button {
    background: transparent;
    color: #e8eaed;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 4px 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s;
}

.icon-dd-menu button:hover {
    background: rgba(255,255,255,0.1);
}

.icon-dd-menu button.active {
    background: #1a73e8;
    border-color: #1a73e8;
}

#annotationCanvas.arrow-mode {
    pointer-events: auto;
    cursor: crosshair;
}

/* Bottom-Left Bar: Zoom + Undo/Redo */
.bottom-left-bar {
    position: fixed;
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    left:   max(20px, calc(env(safe-area-inset-left)   + 20px));
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Zoom Widget */
.zoom-widget {
    position: static;
    background: rgba(50, 54, 57, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 0px;
    display: flex;
    align-items: center;
    gap: 1px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.zoom-btn {
    background: transparent;
    border: none;
    color: #e8eaed;
    padding: 6px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Nur auf Desktop hover und active nutzen */
@media (hover: hover) and (pointer: fine) {
    .zoom-btn:hover {
        background: rgba(26, 115, 232, 0.2);
        color: #1a73e8;
    }
    
    .zoom-btn:active {
        background: rgba(26, 115, 232, 0.3);
        transform: scale(0.95);
    }
}

.zoom-level-container {
    position: relative;
}

.zoom-level {
    color: #e8eaed;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 10px;
    cursor: pointer;
    border-radius: 12px;
    transition: all 0.2s;
    user-select: none;
    display: inline-block;
    min-width: 45px;
    text-align: center;
}

.zoom-level:hover {
    background: rgba(26, 115, 232, 0.2);
    color: #1a73e8;
}

.zoom-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(50, 54, 57, 0.98);
    backdrop-filter: blur(10px);
    border-radius: 8px;
    padding: 4px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 140px;
}

.zoom-dropdown-item {
    background: transparent;
    border: none;
    color: #e8eaed;
    padding: 8px 12px;
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    font-size: 13px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Nur auf Desktop hover nutzen */
@media (hover: hover) and (pointer: fine) {
    .zoom-dropdown-item:hover {
        background: #1a73e8;
        color: #fff;
    }
}

.zoom-dropdown-item svg {
    flex-shrink: 0;
}

.zoom-dropdown-item span {
    flex: 1;
    text-align: left;
}

/* Mobile Anpassungen für Bottom-Left Bar */
@media (max-width: 768px) {
    .bottom-left-bar {
        bottom: max(16px, calc(env(safe-area-inset-bottom) + 16px));
        left:   max(16px, calc(env(safe-area-inset-left)   + 16px));
        gap: 6px;
    }
}

/* Undo/Redo Widget */
.undo-redo-widget {
    background: rgba(50, 54, 57, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 1px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
    padding: 0;
}

.undo-redo-btn {
    background: transparent;
    border: none;
    color: #e8eaed;
    padding: 6px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.undo-redo-btn:hover:not(:disabled) {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.undo-redo-btn:disabled {
    opacity: 0.3;
    cursor: default;
}

/* History Panel */
.history-panel-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.history-mode-row {
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.history-mode-label {
    color: #9aa0a6;
    font-size: 11px;
    margin-right: 8px;
    white-space: nowrap;
    flex-shrink: 0;
}

.history-mode-toggle {
    display: flex;
    background: rgba(255,255,255,0.06);
    border-radius: 5px;
    padding: 2px;
    gap: 2px;
}

.history-mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #9aa0a6;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.history-mode-btn--active {
    background: rgba(138,180,248,0.15);
    color: #8ab4f8;
}

.history-search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.history-search-icon {
    flex-shrink: 0;
    color: #9aa0a6;
    display: flex;
    align-items: center;
}

.history-search-icon svg { width: 14px; height: 14px; }

.history-search-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #e8eaed;
    font-size: 12px;
    padding: 2px 0;
    min-width: 0;
}

.history-search-input::placeholder { color: #5f6368; }

.history-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #5f6368;
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}
.history-search-clear:hover { color: #9aa0a6; }
.history-search-clear svg { width: 10px; height: 10px; }

.history-no-undo-banner {
    margin: 8px;
    padding: 8px 10px;
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid rgba(255, 193, 7, 0.28);
    border-radius: 4px;
    color: #ffc107;
    font-size: 11px;
    line-height: 1.5;
}

.history-page-group {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.history-page-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    cursor: pointer;
    background: #202124;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.history-page-header:hover {
    background: rgba(255,255,255,0.05);
}

.history-page-chevron {
    display: flex;
    align-items: center;
    color: #9aa0a6;
    flex-shrink: 0;
}
.history-page-chevron svg { width: 12px; height: 12px; }

.history-page-label {
    color: #e8eaed;
    font-size: 12px;
    font-weight: 500;
}

.history-page-count {
    color: #9aa0a6;
    font-size: 11px;
    flex: 1;
}

.history-page-lock {
    display: flex;
    align-items: center;
    color: #9aa0a6;
    opacity: 0.5;
}
.history-page-lock svg { width: 14px; height: 14px; }

.history-entry-list {}

/* Spalten-Header (Author / Datum) */
.history-column-header {
    display: grid;
    grid-template-columns: 28px 1fr 1fr 16px 18px;
    align-items: center;
    padding: 3px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.07);
    background: #202124;
}

.history-col-icon-space,
.history-col-preview-space,
.history-col-lock-space { display: block; }

.history-col-label {
    color: #5f6368;
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Eintrags-Zeilen */
.history-entry {
    display: grid;
    grid-template-columns: 28px 1fr 1fr 16px 18px;
    align-items: center;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    min-height: 30px;
}

.history-entry:last-child { border-bottom: none; }

.history-entry-icon {
    display: flex;
    align-items: center;
    color: #9aa0a6;
    flex-shrink: 0;
}
.history-entry-icon svg { width: 15px; height: 15px; }

.history-entry-author {
    color: #9aa0a6;
    font-size: 11px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-entry-date {
    color: #9aa0a6;
    font-size: 11px;
    white-space: nowrap;
}

/* Text-Preview Slot */
.history-entry-preview-slot {
    display: flex;
    align-items: center;
    justify-content: center;
}

.history-text-preview-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    color: #5f6368;
    cursor: pointer;
    border-radius: 3px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
}
.history-text-preview-btn svg { width: 13px; height: 13px; }
.history-text-preview-btn:hover { color: #8ab4f8; }

/* Tooltip */
.history-text-tooltip {
    display: none;
    position: absolute;
    right: 0;
    bottom: calc(100% + 4px);
    width: 180px;
    max-width: calc(100vw - 30px);
    background: #28292c;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    padding: 8px 10px;
    color: #e8eaed;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: 0 4px 14px rgba(0,0,0,0.5);
    z-index: 200;
    pointer-events: none;
}

/* Hover (Desktop) */
.history-text-preview-btn:hover .history-text-tooltip { display: block; }
/* Touch-Toggle */
.history-text-preview-btn.open .history-text-tooltip { display: block; }

.history-entry-lock {
    display: flex;
    align-items: center;
    color: #9aa0a6;
    opacity: 0.4;
    flex-shrink: 0;
}
.history-entry-lock svg { width: 13px; height: 13px; }

/* Klickbare Lock-Icons (Verlaufs-Eintrag, Gruppe, Seite) */
.history-lock--clickable {
    cursor: pointer;
    border-radius: 4px;
    transition: opacity 0.12s, color 0.12s, background 0.12s;
}
.history-lock--clickable:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}
/* Aktiv = gesperrt: deutlich sichtbar (nicht ausgegraut) */
.history-entry-lock.history-lock--active,
.history-page-lock.history-lock--active {
    opacity: 1;
    color: #8ab4f8;
}

/* History: Gruppen-Sub-Header (Flexbox — kein Grid, da Anzahl Spalten abweicht) */
.history-group-header {
    display: grid;
    grid-template-columns: 28px 1fr 18px;
    align-items: center;
    padding: 4px 10px;
    cursor: pointer;
    user-select: none;
    background: rgba(255,255,255,0.03);
    -webkit-tap-highlight-color: transparent;
    min-height: 30px;
}

.history-group-header:hover { background: rgba(255,255,255,0.06); }

.history-group-chevron-cell {
    display: flex;
    align-items: center;
    color: #9aa0a6;
}
.history-group-chevron-cell svg { width: 12px; height: 12px; }

.history-group-label-cell {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
}

.history-group-icon {
    display: flex;
    align-items: center;
    color: #9aa0a6;
    flex-shrink: 0;
}
.history-group-icon svg { width: 15px; height: 15px; }

.history-group-label {
    color: #e8eaed;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* History: Gruppen-Mitglieder-Einträge (eingerückt) */
.history-entry--active {
    background: rgba(26, 115, 232, 0.18);
    border-left: 2px solid #1a73e8;
}

.history-entry--member {
    background: rgba(255,255,255,0.015);
    /* Gruppen-Mitglieder minimal einrücken (Standard-Padding-left 10px → 20px) + dezenter
       linker Strich als Zugehörigkeits-Indikator. */
    padding-left: 20px;
    box-shadow: inset 2px 0 0 rgba(255,255,255,0.10);
}

/* ============================== Search Panel ============================== */

.search-input-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.search-input-icon {
    flex-shrink: 0;
    color: #9aa0a6;
    display: flex;
    align-items: center;
}

.search-text-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    color: #e8eaed;
    font-size: 12px;
    padding: 2px 0;
    min-width: 0;
    font-family: inherit;
}

.search-text-input::placeholder { color: #5f6368; }

/* Clear-Button: immer im Flow, Sichtbarkeit via Opacity */
.search-input-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #5f6368;
    cursor: pointer;
    padding: 2px;
    border-radius: 3px;
    opacity: 0;
    pointer-events: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    transition: opacity 0.15s;
}
.search-input-clear.visible {
    opacity: 1;
    pointer-events: auto;
}
.search-input-clear:hover { color: #9aa0a6; }

.search-status-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    flex-shrink: 0;
}

.search-status-text {
    color: #9aa0a6;
    font-size: 11px;
}

.search-nav-btns {
    display: flex;
    gap: 2px;
}

.search-nav-btn {
    background: transparent;
    border: none;
    color: #9aa0a6;
    cursor: pointer;
    padding: 3px 5px;
    border-radius: 3px;
    display: flex;
    align-items: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.search-nav-btn:hover { color: #e8eaed; background: rgba(255,255,255,0.07); }

.search-hint-row {
    padding: 8px 10px;
    color: #9aa0a6;
    font-size: 11px;
    flex-shrink: 0;
}

.search-results {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    min-height: 0;
}

.search-page-group {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.search-page-header {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 5px 10px;
    color: #e8eaed;
    font-size: 11px;
    font-weight: 500;
    background: #323639;
    position: sticky;
    top: 0;
    z-index: 1;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.search-page-header:hover { background: #3a3d41; }

.search-page-chevron {
    display: flex;
    align-items: center;
    color: #9aa0a6;
    flex-shrink: 0;
}
.search-page-chevron svg { width: 12px; height: 12px; }

.search-page-label { color: #e8eaed; }

.search-page-count {
    color: #9aa0a6;
    font-weight: 400;
}

.search-result-item {
    padding: 5px 10px;
    color: #9aa0a6;
    font-size: 11px;
    line-height: 1.5;
    cursor: pointer;
    border-bottom: 1px solid rgba(255,255,255,0.04);
    word-break: break-word;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.search-result-item:hover { background: rgba(255,255,255,0.05); }

.search-result-item--active {
    background: rgba(26, 115, 232, 0.15);
    border-left: 2px solid #1a73e8;
    padding-left: 8px;
}

.search-result-item mark {
    background: rgba(255, 220, 0, 0.35);
    color: #fff;
    border-radius: 2px;
    padding: 0 1px;
}

.search-result-item--active mark {
    background: rgba(255, 220, 0, 0.55);
}

/* Treffer aus einer Text-Annotation: kleines T-Icon vor dem Snippet */
.search-result-item--annotation {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}
.search-result-annot-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    border-radius: 3px;
    background: rgba(138, 180, 248, 0.18);
    color: #8ab4f8;
}
.search-result-annot-icon svg { width: 12px; height: 12px; }
.search-result-text { flex: 1; min-width: 0; }

/* Highlight-Overlay auf dem Seiten-Canvas */
.search-highlight-overlay {
    position: absolute;
    background: rgba(255, 220, 0, 0.45);
    border-radius: 2px;
    pointer-events: none;
    z-index: 20;
    opacity: 1;
    transition: opacity 0.5s ease;
}

/* Page Widget */
.page-widget {
    position: fixed;
    bottom: max(20px, calc(env(safe-area-inset-bottom) + 20px));
    right: max(20px, calc(env(safe-area-inset-right) + 20px));
    z-index: 1000;
    background: rgba(50, 54, 57, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 0px;
    display: flex;
    align-items: center;
    gap: 1px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.page-btn {
    background: transparent;
    border: none;
    color: #e8eaed;
    padding: 6px;
    cursor: pointer;
    border-radius: 50%;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    min-height: 28px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Nur auf Desktop hover und active nutzen */
@media (hover: hover) and (pointer: fine) {
    .page-btn:hover {
        background: rgba(26, 115, 232, 0.2);
        color: #1a73e8;
    }
    
    .page-btn:active {
        background: rgba(26, 115, 232, 0.3);
        transform: scale(0.95);
    }
}

.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.page-info-container {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 0px;
}

#pageInput {
    background: transparent;
    color: #e8eaed;
    border: none;
    border-radius: 8px;
    padding: 6px 8px;
    width: 45px;
    text-align: center;
    font-size: 12px;
    font-weight: 500;
    outline: none;
    transition: all 0.2s;
}

#pageInput:hover {
    background: rgba(26, 115, 232, 0.2);
}

#pageInput:focus {
    background: rgba(26, 115, 232, 0.2);
    color: #1a73e8;
}

.page-total {
    color: #e8eaed;
    font-size: 12px;
    font-weight: 500;
    opacity: 0.8;
    margin-bottom: 3px;
}

/* Mobile Anpassungen für Page Widget */
@media (max-width: 768px) {
    .page-widget {
        bottom: max(16px, calc(env(safe-area-inset-bottom) + 16px));
        right: max(16px, calc(env(safe-area-inset-right) + 16px));
    }
}

/* ============================================
   FORMULARFELD-EDITOR STYLES
   ============================================ */

/* Formular-Modus Toggle Button */
#formModeBtn {
    position: relative;
}

#formModeBtn.active {
    background: rgba(26, 115, 232, 0.25);
    color: #1a73e8;
}

#formModeBtn.active::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    transform: translateX(-50%);
    width: 20px;
    height: 2px;
    background: #1a73e8;
    border-radius: 1px;
}

/* Form Toolbar Group */
.form-toolbar-group {
    display: flex;
    align-items: center;
    gap: 2px;
    padding-left: 8px;
    margin-left: 4px;
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Form Tool Buttons */
.form-tool-btn {
    background: transparent;
    border: none;
    color: #e8eaed;
    padding: 8px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-tool-btn:hover {
    background: rgba(26, 115, 232, 0.15);
    color: #8ab4f8;
}

.form-tool-btn.active {
    background: rgba(26, 115, 232, 0.25);
    color: #1a73e8;
}

.form-tool-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Body-Klasse für Formular-Modus */
body.form-mode-active .canvas-container {
    cursor: crosshair;
}

/* BUGFIX v26: Im Formular-Modus muss editFormCanvas ÜBER formCanvas liegen! */
/* formCanvas pointer-events wird per JavaScript gesteuert, KEIN CSS-Override! */
body.form-mode-active .page-edit-form-canvas {
    z-index: 30 !important;
    pointer-events: auto !important;
    cursor: crosshair;
}

body.form-mode-active .page-annotation-canvas {
    z-index: 10 !important;
    pointer-events: none !important;
}

body.form-mode-active .canvas-container {
    z-index: 10 !important;
    pointer-events: none !important;
}

body.form-mode-active .tool-btn:not(#formModeBtn):not(.form-tool-btn):not(.detect-fields-btn) {
    opacity: 0.5;
    pointer-events: none;
}

body.form-mode-active #formModeBtn {
    opacity: 1;
    pointer-events: auto;
}

/* Formular-Modus Indikator in Toolbar */
body.form-mode-active .toolbar::before {
    content: 'Formular-Modus';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #1a73e8;
    color: white;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 0 0 6px 6px;
    white-space: nowrap;
}

/* Mobile Anpassungen für FormToolbar */
@media (max-width: 768px) {
    .form-toolbar-group {
        gap: 1px;
        padding-left: 4px;
        margin-left: 2px;
    }
    
    .form-tool-btn {
        padding: 6px;
    }
    
    .form-tool-btn svg {
        width: 18px;
        height: 18px;
    }
    
    body.form-mode-active .toolbar::before {
        font-size: 9px;
        padding: 1px 6px;
    }
}

/* ============================================
   MARKUP-BIBLIOTHEK
   ============================================ */

#markupLibrary[hidden] {
    display: none;
}

#markupLibrary {
    width: 100%;
    margin-top: 32px;
    display: flex;
    min-height: 400px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    pointer-events: auto;
    flex-shrink: 0;
}

/* Sidebar */
.ml-sidebar {
    width: 196px;
    flex-shrink: 0;
    background: #1a1d20;
    border-right: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 0;
    padding: 20px 10px 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ml-sidebar-section {
    display: flex;
    flex-direction: column;
}

.ml-sidebar-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #5f6368;
    margin: 0 0 6px 10px;
}

.ml-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border-radius: 7px;
    background: none;
    border: none;
    color: #9aa0a6;
    font-size: 13px;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    margin-bottom: 1px;
}

.ml-nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e8eaed;
}

.ml-nav-item.active {
    background: rgba(26, 115, 232, 0.15);
    color: #8ab4f8;
}

.ml-nav-count {
    margin-left: auto;
    font-size: 11px;
    background: rgba(255, 255, 255, 0.08);
    color: #9aa0a6;
    border-radius: 10px;
    padding: 1px 6px;
    min-width: 20px;
    text-align: center;
}

.ml-nav-item.active .ml-nav-count {
    background: rgba(26, 115, 232, 0.2);
    color: #8ab4f8;
}

/* Main */
.ml-main {
    flex: 1;
    min-width: 0;
    background: #1a1d20;
    padding: 20px 24px 48px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.ml-title {
    font-size: 22px;
    font-weight: 400;
    color: #9aa0a6;
    margin: 0 0 4px;
    letter-spacing: -0.3px;
}

.ml-subtitle {
    font-size: 13px;
    color: #9aa0a6;
    margin: 0;
    opacity: 0.75;
}

/* Search */
.ml-search-wrap {
    position: relative;
}

.ml-search-icon {
    position: absolute;
    left: 11px;
    top: 50%;
    transform: translateY(-50%);
    color: #9aa0a6;
    pointer-events: none;
}

.ml-search-input {
    width: 100%;
    background: #2a2d30;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px 8px 34px;
    color: #e8eaed;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.15s;
}

.ml-search-input:focus {
    border-color: rgba(138, 180, 248, 0.5);
}

.ml-search-input::placeholder {
    color: #5f6368;
}

/* Filter tabs */
.ml-filter-tabs {
    display: flex;
    gap: 7px;
    flex-wrap: wrap;
}

.ml-filter-tab {
    padding: 4px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: none;
    color: #9aa0a6;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.12s, color 0.12s, border-color 0.12s;
}

.ml-filter-tab:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #e8eaed;
}

.ml-filter-tab.active {
    background: #1a73e8;
    border-color: #1a73e8;
    color: #fff;
}

/* Grid */
.ml-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
}

.ml-empty {
    color: #5f6368;
    font-size: 13px;
    grid-column: 1 / -1;
    padding: 20px 0;
}

/* Card */
.ml-card {
    position: relative;
    background: #202124;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    overflow: visible;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.ml-card:hover {
    border-color: rgba(138, 180, 248, 0.35);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.45);
}

/* Thumbnail: square, document letterboxed inside */
.ml-card-thumb-wrap {
    aspect-ratio: 1 / 1;
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 9px 9px 0 0;
    cursor: pointer;
}

.ml-card-thumb {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ml-card-thumb--empty {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2a2d30 0%, #303336 100%);
}

.ml-card-star {
    position: absolute;
    top: 7px;
    left: 7px;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    border: none;
    color: rgba(255, 255, 255, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.ml-card:hover .ml-card-star {
    opacity: 1;
}

.ml-card-star:hover {
    color: #fbbc04;
}

.ml-card-star--active {
    opacity: 1;
    color: #fbbc04;
}

.ml-card-star--active:hover {
    color: #f29900;
}

.ml-filter-tab svg {
    vertical-align: middle;
    margin-right: 3px;
}

.ml-card-pages {
    position: absolute;
    bottom: 7px;
    right: 7px;
    background: #1a73e8;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
}

/* Card body */
.ml-card-body {
    padding: 9px 11px 10px;
}

.ml-card-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 4px;
}

.ml-card-info {
    flex: 1;
    min-width: 0;
}

.ml-card-menu-wrap {
    position: relative;
    flex-shrink: 0;
}

.ml-card-name {
    font-size: 12px;
    font-weight: 400;
    color: #9aa0a6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: text;
    border-radius: 4px;
    padding: 2px 3px;
    margin: 0 -3px 3px;
    outline: none;
    transition: background 0.12s;
}

.ml-card-name:hover {
    background: rgba(255, 255, 255, 0.06);
}

.ml-card-name[contenteditable="true"] {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    background: rgba(138, 180, 248, 0.1);
    border: 1px solid rgba(138, 180, 248, 0.4);
    box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.15);
}

.ml-card-time {
    font-size: 11px;
    color: #9aa0a6;
    margin-bottom: 1px;
}

.ml-card-date {
    font-size: 10px;
    color: #5f6368;
}

/* Three-dot menu */
.ml-card-menu-btn {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    background: none;
    border: none;
    color: #9aa0a6;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.12s;
    flex-shrink: 0;
}

.ml-card:hover .ml-card-menu-btn {
    opacity: 1;
}

.ml-card-menu-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e8eaed;
}

.ml-card-dropdown {
    position: absolute;
    bottom: calc(100% + 4px);
    right: 0;
    background: #2a2d30;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    padding: 4px;
    z-index: 200;
    min-width: 130px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55);
}

.ml-card-dropdown.hidden {
    display: none;
}

.ml-dropdown-item {
    display: block;
    width: 100%;
    padding: 7px 11px;
    border: none;
    background: none;
    color: #e8eaed;
    font-size: 13px;
    text-align: left;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.1s;
}

.ml-dropdown-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.ml-dropdown-delete {
    color: #f28b82;
}

.ml-dropdown-delete:hover {
    background: rgba(242, 139, 130, 0.1);
}

.ml-dropdown-export-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.ml-dropdown-export-sub {
    padding-left: 8px;
    border-left: 2px solid rgba(255,255,255,0.1);
    margin: 2px 0 2px 8px;
}

.ml-dropdown-export-sub.hidden {
    display: none;
}

/* Checkbox */
.ml-card-check {
    position: absolute;
    top: 7px;
    right: 7px;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.45);
    border: 2px solid rgba(255, 255, 255, 0.5);
    color: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
    z-index: 2;
}

.ml-card:hover .ml-card-check {
    opacity: 1;
}

.ml-card.selected .ml-card-check {
    opacity: 1;
    background: #1a73e8;
    border-color: #1a73e8;
    color: #fff;
}

/* Stern ausblenden wenn Karte selektiert — Favorit-Stern bleibt sichtbar */
.ml-card.selected .ml-card-star:not(.ml-card-star--active) {
    display: none;
}

/* Karte selektiert */
.ml-card.selected {
    border-color: #1a73e8;
    box-shadow: 0 0 0 2px rgba(26, 115, 232, 0.35);
}

.ml-card.selected .ml-card-thumb-wrap::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(26, 115, 232, 0.12);
    pointer-events: none;
}

/* Selektions-Toolbar */
.ml-sel-bar[hidden] {
    display: none;
}

.ml-sel-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(26, 115, 232, 0.1);
    border: 1px solid rgba(138, 180, 248, 0.22);
    border-radius: 8px;
    padding: 8px 14px;
    animation: ml-sel-in 0.15s ease;
}

@keyframes ml-sel-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ml-sel-count {
    font-size: 13px;
    color: #8ab4f8;
    font-weight: 500;
    flex: 1;
}

.ml-sel-clear {
    background: none;
    border: none;
    color: #9aa0a6;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 5px;
    transition: background 0.12s, color 0.12s;
}

.ml-sel-clear:hover {
    background: rgba(255, 255, 255, 0.07);
    color: #e8eaed;
}

.ml-sel-delete {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(242, 139, 130, 0.1);
    border: 1px solid rgba(242, 139, 130, 0.28);
    border-radius: 6px;
    color: #f28b82;
    font-size: 13px;
    padding: 5px 13px;
    cursor: pointer;
    transition: background 0.12s;
}

.ml-sel-delete:hover {
    background: rgba(242, 139, 130, 0.2);
}

.ml-sel-delete--confirm {
    background: rgba(242, 139, 130, 0.35) !important;
    border-color: rgba(242, 139, 130, 0.6) !important;
    font-weight: 500;
}

@media (hover: none) {
    .ml-card-menu-btn,
    .ml-card-star,
    .ml-card-check {
        opacity: 1;
    }
}

@media (max-width: 600px) {
    .ml-sidebar {
        display: none;
    }

    .ml-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

/* ── Dropzone: schmale Fenster ────────────────────────────── */
@media (max-width: 560px) {
    .dropzone-content {
        padding: 24px 16px 40px;
        max-width: calc(100% - 24px);
        margin: auto 12px;
    }

    .dropzone-title {
        font-size: 22px;
        margin-bottom: 10px;
    }

    .dropzone-protip {
        margin-bottom: 20px;
        font-size: 12px;
    }

    .upload-btn,
    .paste-clipboard-btn,
    .scan-btn,
    .blank-canvas-container {
        max-width: 100%;
    }
}

/* ── Dropzone: flache Fenster (geringe Höhe) ──────────────── */
@media (max-height: 560px) {
    #dropzone {
        padding-top: 12px;
    }

    .dropzone-content {
        padding: 16px 20px 32px;
    }

    .dropzone-title {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .dropzone-subtitle {
        margin-bottom: 6px;
    }

    .dropzone-protip {
        display: none;
    }

    .upload-btn,
    .paste-clipboard-btn,
    .scan-btn {
        padding: 10px 20px;
        font-size: 14px;
        margin-bottom: 10px;
    }

    .blank-canvas-btn,
    .blank-canvas-color-btn {
        padding: 10px 16px;
        font-size: 14px;
    }
}

/* ============================== Kalibrier-Dialog (Measure) ============================== */
.calib-overlay {
    position: fixed; inset: 0; z-index: 10001;
    display: none; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.5);
}
.calib-dialog {
    width: 340px; max-width: calc(100vw - 32px);
    background: #2a2d30; color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.12); border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    font-size: 13px; overflow: hidden;
}
.calib-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.calib-title { font-weight: 600; }
.calib-close {
    background: transparent; border: none; color: #9aa0a6; cursor: pointer;
    font-size: 16px; line-height: 1; padding: 2px 6px;
}
.calib-close:hover { color: #e8eaed; }
.calib-tabs { display: flex; gap: 4px; padding: 12px 14px 0; }
.calib-tab {
    flex: 1; padding: 7px; background: transparent; color: #9aa0a6;
    border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; cursor: pointer; font-size: 12px;
}
.calib-tab--active { background: rgba(138,180,248,0.18); color: #e8eaed; border-color: #8ab4f8; }
.calib-panel { padding: 12px 14px; }
.calib-pick-btn {
    width: 100%; padding: 8px; margin-bottom: 6px;
    background: rgba(255,255,255,0.06); color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; cursor: pointer;
}
.calib-pick-btn:hover { background: rgba(255,255,255,0.12); }
.calib-pick-status { font-size: 11px; color: #9aa0a6; margin-bottom: 10px; }
.calib-row { display: flex; align-items: center; gap: 6px; margin: 6px 0; }
.calib-row label { flex: 0 0 88px; color: #9aa0a6; }
.calib-row input, .calib-row select {
    background: #202124; color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.15); border-radius: 5px; padding: 6px;
}
.calib-row input { flex: 1; min-width: 0; }
.calib-row select { flex: 0 0 64px; }
.calib-unit-static { flex: 0 0 64px; color: #9aa0a6; font-size: 12px; padding: 6px 0; }
.calib-eq { text-align: center; color: #9aa0a6; font-weight: 700; margin: 2px 0; }
.calib-hint { font-size: 11px; color: #9aa0a6; margin: 4px 0 8px; }
.calib-effective {
    font-size: 12px; color: #81c995; margin: 2px 0 10px; min-height: 1em; line-height: 1.35;
}
.calib-effective--warn {
    color: #f0b429; background: rgba(240,180,41,0.10);
    padding: 7px 9px; border-radius: 6px;
}
.calib-save {
    width: 100%; padding: 9px; margin-top: 6px;
    background: #4CAF50; color: #fff; border: none; border-radius: 6px;
    cursor: pointer; font-weight: 600;
}
.calib-save:hover { background: #43a047; }
.calib-footer {
    display: flex; flex-direction: column; gap: 6px;
    padding: 10px 14px 14px; border-top: 1px solid rgba(255,255,255,0.08);
}
.calib-transfer, .calib-remove {
    padding: 7px; background: transparent; color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; cursor: pointer; font-size: 12px;
}
.calib-transfer:hover { background: rgba(255,255,255,0.08); }
.calib-remove { color: #f28b82; border-color: rgba(242,139,130,0.4); }
.calib-remove:hover { background: rgba(242,139,130,0.12); }

/* Measure-Kalibrier-Button in der Toolbar-Ebene-3: normaler quadratischer Icon-Button (Farbe grün/rot
   je nach Kalibrier-Status wird per JS gesetzt). */
.measure-unit-btn { display: inline-flex; align-items: center; justify-content: center; }

/* ============================================================
   SETTINGS-ZEILE PAINT-/STROKE-GROUP (Mitbewerber-Stil, Bild 2)
   ============================================================ */

/* Paint-Group: [Rand|Füllung] + 3 Farbkreise. Flach & luftig, wie beim Mitbewerber — KEINE Trenner. */
.tool-paint-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin: 0;
}
/* Strichstärke-Gruppe platzsparend: Balken + pt-Dropdown enger zusammen. */
.tool-stroke-group {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    margin: 0;
}

/* Rand/Füllung als EIN Umschalter (Segmented Control): gemeinsamer gerundeter Container, die
   beiden Hälften ohne Lücke aneinander; die aktive Hälfte dezent hell hinterlegt. Eigener, gegen
   den dunklen Zeilen-Hintergrund abgesetzter (hellerer) Container → wirkt als eigenständiges Control.
   .tool-settings-row-Präfix → schlägt die globalen `.toolbar button { min-width:28px }` und
   `.toolbar button > svg { width:18px }`, die sonst Größe/Icon zurücksetzen. */
.tool-paint-seg {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 2px;
    border-radius: 6px;
    background: rgba(255,255,255,0.05);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
    flex-shrink: 0;
}
.tool-settings-row .tool-paint-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 20px;
    min-width: 22px;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    cursor: pointer;
    transition: background 0.12s;
    -webkit-tap-highlight-color: transparent;
}
/* Außenkanten des Umschalters an den Container-Radius anpassen (nur außen gerundet, innen scharf). */
.tool-settings-row .tool-paint-btn:first-child { border-radius: 4px 0 0 4px; }
.tool-settings-row .tool-paint-btn:last-child  { border-radius: 0 4px 4px 0; }
.tool-settings-row .tool-paint-btn > svg {
    width: 14px;
    height: 14px;
    pointer-events: none;
    display: block;
}
.tool-settings-row .tool-paint-btn:hover:not(.active) { background: rgba(255,255,255,0.06); }
/* Aktive Hälfte des Umschalters: dezent hell hinterlegt (wie Vorbild). */
.tool-settings-row .tool-paint-btn.active { background: rgba(255,255,255,0.18); }
/* Dunkle Rand-/Füllfarbe → hellerer Button-Hintergrund, damit das dunkle Icon sichtbar bleibt.
   Aktiver Zustand etwas kräftiger als der inaktive. */
.tool-settings-row .tool-paint-btn.dark-paint { background: rgba(255,255,255,0.22); }
.tool-settings-row .tool-paint-btn.dark-paint.active { background: rgba(255,255,255,0.34); }
/* „Kein Rand/keine Füllung": diagonaler Strich, exakt über dem Quadrat (dessen Diagonale ~13px),
   nicht über die Icon-Kanten hinaus. */
.tool-paint-btn.paint-off { position: relative; }
.tool-paint-btn.paint-off::after {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: 13px;
    height: 1.5px;
    background: #e53935;
    transform: translate(-50%, -50%) rotate(-45deg);
}

/* 3 Farb-Buttons — Optik wie .tool-close-btn (runder Button mit hellem Rand). Farbe = Hintergrund.
   Aktiver zeigt ein kleines Dreieck; erneuter Klick öffnet die Farbauswahl. */
.tool-swatches {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}
.toolbar .tool-swatch {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    min-width: 18px;
    padding: 0;
    border-radius: 50%;
    border: none;
    /* Minimale helle Umrandung (wie die Linien-Balken) → dunkle/schwarze Kreise bleiben auf dem
       dunklen Ebene-3-Hintergrund sichtbar. Auf hellen Farben praktisch unsichtbar. */
    box-shadow: 0 0 0 0.5px rgba(255,255,255,0.35);
    cursor: pointer;
    flex-shrink: 0;
    transition: transform 0.12s;
    -webkit-tap-highlight-color: transparent;
}
/* Hover (nicht aktiv): hellgrauer Ring, gleiche Stärke wie der weiße Aktiv-Ring. Kein Hintergrund
   (:not(:disabled) schlägt die globale `.toolbar button:hover`-Regel). */
.toolbar .tool-swatch:hover:not(.active):not(:disabled) {
    box-shadow:
        0 0 0 0.5px rgba(255,255,255,0.35),
        0 0 0 1px rgba(0,0,0,0.5),
        0 0 0 2.5px rgba(189,193,198,0.95);
}
/* Aktiv (wie Mitbewerber): dünner schwarzer Ring direkt um die Farbe, dann deutlicherer weißer Ring. */
.toolbar .tool-swatch.active {
    box-shadow:
        0 0 0 0.5px rgba(255,255,255,0.35),
        0 0 0 1px rgba(0,0,0,0.5),
        0 0 0 2.5px rgba(255,255,255,0.95);
}
/* Dreieck nur beim aktiven Kreis; weißer Schatten, damit es auf jeder Farbe sichtbar bleibt. */
.tool-swatch-caret {
    display: none;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    filter: drop-shadow(0 0 1.5px rgba(0,0,0,0.9));
    pointer-events: none;
}
.tool-swatch.active .tool-swatch-caret { display: flex; }

/* Strichstärke-Presets: horizontale, gerundete Balken (wie beim Vorbild). Schmal, da kein
   Hintergrund → Balken sitzen enger beieinander (platzsparend). */
.toolbar .tool-stroke-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    min-width: 26px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 6px;
    background: transparent;
    cursor: pointer;
    transition: background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
/* Kein Hover-/Aktiv-Hintergrund — die Auswahl wird allein durch die Farbe des Balkens gezeigt.
   .toolbar-Präfix überschreibt die globalen `.toolbar button:hover` und `.toolbar button.active`
   (Zeile ~364), die sonst einen grauen Kasten setzen. */
/* Kein Hintergrund bei Hover/Aktiv/Focus. :not(:disabled) angehängt → schlägt die globale
   `.toolbar button:hover:not(:disabled)` (Zeile ~357), die sonst gewinnt. */
.toolbar .tool-stroke-btn:hover:not(:disabled),
.toolbar .tool-stroke-btn.active:not(:disabled),
.toolbar .tool-stroke-btn:active:not(:disabled) { background: transparent; }
.tool-stroke-bar {
    display: block;
    width: 22px;
    background: var(--bar-color, #9aa0a6);
    border-radius: 6px;
    flex-shrink: 0;
    transition: background 0.12s;
    /* Minimale helle Umrandung → dunkle Balken (z.B. schwarze Linie) bleiben auf dem dunklen
       Ebene-3-Hintergrund sichtbar/als selektiert erkennbar. Auf hellen Farben unsichtbar. */
    box-shadow: 0 0 0 0.5px rgba(255,255,255,0.35);
}
/* Hover: Balken in Strichfarbe füllen (kein Hintergrund) — das ist das gesamte Hover-Feedback. */
.toolbar .tool-stroke-btn:hover:not(.active) .tool-stroke-bar { background: var(--line-color, #e8eaed); }

/* Strichstärke-Wert-Dropdown („6pt") — weiche Pille, bricht nie um.
   Selektor mit .tool-settings-row-Präfix → schlägt die generische `.toolbar button { font-size:20px }`. */
.tool-width-dd { position: relative; flex-shrink: 0; }
.tool-settings-row .tool-width-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    width: auto;
    height: 28px;
    box-sizing: border-box;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    color: #e8eaed;
    background: rgba(255,255,255,0.08);
    border: none;
    border-radius: 14px;
    padding: 0 10px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.tool-width-btn .tool-width-text { white-space: nowrap; font-size: 13px; }
.tool-width-btn:hover { background: rgba(255,255,255,0.14); }
.tool-width-btn .dd-caret { display: flex; opacity: 0.7; }
.tool-width-menu {
    display: none;
    flex-direction: column;
    min-width: 96px;
    background: #202124;
    border: 1px solid rgba(255,255,255,0.14);
    border-radius: 8px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.6);
    padding: 4px;
}
.tool-width-dd.open .tool-width-menu { display: flex; }
.tool-width-menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    text-align: left;
    font-size: 13px;
    color: #e8eaed;
    background: transparent;
    border: none;
    border-radius: 5px;
    padding: 7px 10px;
    cursor: pointer;
    white-space: nowrap;
}
.tool-width-menu button:hover { background: rgba(255,255,255,0.08); }
.tool-width-menu .tool-stroke-bar { width: 28px; }

/* ♥-Favorit- und 📌-Pin-Button (beide noch ohne Funktion) — Optik wie .tool-more-btn. */
.tool-fav-btn,
.tool-pin-btn {
    background: transparent;
    border: none;
    color: #e8eaed;
    padding: 5px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    min-width: 28px;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}
.tool-fav-btn svg,
.tool-pin-btn svg { pointer-events: none; width: 18px; height: 18px; }
.tool-fav-btn:hover { background: rgba(255,255,255,0.1); }
.tool-pin-btn svg { pointer-events: none; }

/* Neue Direkt-Glieder der Settings-Zeile bündig einpassen */
.tool-settings-row > .tool-paint-group,
.tool-settings-row > .tool-stroke-group,
.tool-settings-row > .tool-fav-btn,
.tool-settings-row > .tool-pin-btn { flex-shrink: 0; }

@media (hover: hover) and (pointer: fine) {
    .tool-swatch:hover { transform: scale(1.12); }
}

/* ============================================================
   FARB-POPUP (ColorPalettePopup, Bild 3)
   ============================================================ */
.color-palette-popup {
    position: fixed;
    display: none;
    width: 244px;
    max-width: calc(100vw - 16px);
    padding: 12px;
    background: rgba(32, 33, 36, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.55);
    color: #e8eaed;
}
.cpp-section-title {
    font-size: 12px;
    font-weight: 600;
    color: #9aa0a6;
    margin: 4px 2px 8px;
}
/* „Keine Farbe"-Zeile (nur bei Rand/Füllung eingeblendet). */
.cpp-none-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 8px;
    margin-bottom: 10px;
    border: none;
    border-radius: 8px;
    background: rgba(255,255,255,0.06);
    color: #e8eaed;
    font-size: 13px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.cpp-none-btn:hover { background: rgba(255,255,255,0.12); }
.cpp-none-swatch {
    position: relative;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
    flex-shrink: 0;
    overflow: hidden;
}
.cpp-none-swatch::after {
    content: '';
    position: absolute;
    left: 50%; top: 50%;
    width: 22px; height: 1.5px;
    background: #e53935;
    transform: translate(-50%, -50%) rotate(-45deg);
}
.cpp-quick-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    margin-bottom: 12px;
}
.cpp-full-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
}
.cpp-swatch {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 50%;
    border: none;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s;
    -webkit-tap-highlight-color: transparent;
}
.cpp-swatch.active {
    box-shadow: 0 0 0 2px #202124, 0 0 0 4px #ffffff;
}
/* <label> statt <button> (iOS-Farbwähler) → die button-Regeln oben greifen hier nicht mehr. */
.cpp-swatch-more {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255,255,255,0.08);
    color: #e8eaed;
    box-shadow: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}
/* Trägt der …-Button eine eigene Farbe → Farbe als Hintergrund, die 3 Punkte bleiben SICHTBAR
   (Hinweis auf „custom"), mit weißem Schatten damit sie auf jeder Farbe lesbar sind. */
.cpp-swatch-more.has-color {
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.25);
    color: #fff;
}
.cpp-swatch-more.has-color svg { filter: drop-shadow(0 0 1.5px rgba(0,0,0,0.9)); }
/* Der Color-Input liegt unsichtbar, aber voll antippbar über dem …-Feld: iOS Safari öffnet den
   nativen Farbwähler nur bei echtem Tap auf das Control, nicht per synthetischem .click(). */
.cpp-color-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    opacity: 0;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
}
@media (hover: hover) and (pointer: fine) {
    .cpp-swatch:hover { transform: scale(1.12); }
}

/* ============================================================
   Bild-Einfügen-Modal (ImageInsertModal)
   ============================================================ */
.image-insert-content {
    width: min(620px, calc(100vw - 32px)) !important;
    max-width: 620px !important;
    padding: 16px !important;
}
.image-insert-modal.ii-dragover .image-insert-content {
    outline: 2px dashed #1a73e8;
    outline-offset: -6px;
}

.ii-title {
    color: #e8eaed;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 14px;
    text-align: center;
}

/* Quellen-Kacheln */
.ii-sources {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
}
.ii-source {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 18px 10px;
    background: #3c4043;
    color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.15s, border-color 0.15s;
}
.ii-source:hover:not(:disabled) {
    background: #45494d;
    border-color: rgba(255,255,255,0.28);
}
.ii-source:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.ii-source svg { color: #8ab4f8; }

/* Live-Status der Zwischenablage-Kachel */
.ii-clip-status {
    font-size: 10.5px;
    color: #9aa0a6;
    line-height: 1;
    margin-top: -2px;
}
.ii-source.ii-clip-ready {
    border-color: #34a853;
}
.ii-source.ii-clip-ready .ii-clip-status {
    color: #34a853;
}

.ii-hint {
    color: #9aa0a6;
    font-size: 12px;
    text-align: center;
    margin: 14px 0 0;
    min-height: 16px;
}

/* Crop-Ansicht */
.ii-crop-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
}
.ii-counter {
    color: #9aa0a6;
    font-size: 13px;
    min-width: 36px;
}
.ii-aspect {
    display: flex;
    gap: 4px;
}
.ii-aspect button {
    padding: 4px 9px;
    background: #3c4043;
    color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.ii-aspect button.active {
    background: #1a73e8;
    border-color: #1a73e8;
}

.ii-canvas-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: min(52vh, 420px);
    background: #202124;
    border-radius: 6px;
    overflow: hidden;
}
.ii-canvas-wrap canvas {
    display: block;
    touch-action: none;
    cursor: crosshair;
}

.ii-crop-tools {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
}
.ii-crop-tools button {
    padding: 8px 12px;
    background: #3c4043;
    color: #e8eaed;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ii-crop-tools button:hover { background: #45494d; }
.ii-crop-tools [data-role="back"] {
    font-size: 13px;
    margin-left: auto;
}
.ii-crop-tools .ii-insert {
    background: #1a73e8;
    border-color: #1a73e8;
    color: #fff;
}
.ii-crop-tools .ii-insert:hover { background: #1b66c9; }

@media (max-width: 640px) {
    .ii-canvas-wrap { height: 44vh; }
    .ii-crop-tools { flex-wrap: wrap; }
    .ii-crop-tools [data-role="back"] { margin-left: 0; }
}
