.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;
}

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;
    top: max(48px, calc(env(safe-area-inset-top) + 48px));
    bottom: max(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: 12px 16px;
    background: #202124;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.thumbnail-header span {
    color: #e8eaed;
    font-size: 14px;
    font-weight: 500;
}

.thumbnail-header button {
    background: transparent;
    border: none;
    color: #e8eaed;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.thumbnail-header button:hover {
    background: rgba(255,255,255,0.1);
}

.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: 48px;
}



.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: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    font-size: 20px;
    font-weight: 300;
    outline: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

.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);
    }
}

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

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



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

#viewer {
    flex: 1;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    position: relative;
    padding: 20px;
    touch-action: pan-x pan-y pinch-zoom;
    transition: margin-left 0.3s ease;
}

/* 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;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
    background: #525659;
}

#dropzone.hidden {
    display: none;
}

.dropzone-content {
    text-align: center;
    color: #e8eaed;
    pointer-events: auto;
    max-width: 600px;
    margin: 0 auto;
    padding: 40px 20px;
    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: center;
    justify-content: center;
    gap: 0;
    width: 100%;
    max-width: 500px;
    position: relative;
}

.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-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);
}

.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;
    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: visible;
    background: white;
}

.page-canvas {
    display: block;
}

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

.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;
}

#statusBar {
    background: #323639;
    padding: 4px 16px;
    color: #e8eaed;
    font-size: 12px;
    border-top: 1px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}

#statusText {
    opacity: 0.8;
}

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

/* Steuerelemente im Panel aktivieren */
.text-format-panel > *,
.rectangle-format-panel > *,
.arrow-format-panel > * {
    pointer-events: auto;
}

.text-format-panel 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;
}

.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;
}

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

.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;
}

/* 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 Spezifisch */
.arrow-format-panel {
    /* gap: 12px; */
}

.arrow-format-panel label {
    display: flex;
    align-items: center;
    color: #e8eaed;
}

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

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

.arrow-format-panel select:focus {
    border-color: #1a73e8;
}

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

/* Zoom Widget */
.zoom-widget {
    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;
    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 Zoom Widget */
@media (max-width: 768px) {
    .zoom-widget {
        bottom: max(16px, calc(env(safe-area-inset-bottom) + 16px));
        left: max(16px, calc(env(safe-area-inset-left) + 16px));
    }
}

/* 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));
    }
}
