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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-image: url('../../bg.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    background-color: #000;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    padding: 8px;
    padding-top: max(8px, env(safe-area-inset-top));
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
    color: #333;
    -webkit-tap-highlight-color: transparent;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('../../bg.jpg');
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    z-index: -1;
}

body.intro-overlay-active {
    overflow: hidden;
    background-image: none !important;
}

body.intro-overlay-active::before {
    background-image: none !important;
    background-color: #000;
}

.intro-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    background-color: #000;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}

.intro-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: none;
}

.intro-image {
    position: absolute;
    max-width: 100%;
    max-width: calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right));
    max-height: 100%;
    max-height: calc(100vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-height: calc(100% - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-touch-callout: none;
    opacity: 1;
    transition: opacity 0.5s ease-out;
}

.intro-image.hidden {
    opacity: 0;
    pointer-events: none;
    display: none !important;
}

.intro-progress-container {
    position: fixed;
    bottom: max(8px, env(safe-area-inset-bottom));
    left: 0;
    right: 0;
    width: 100%;
    height: 8px;
    background: transparent;
    z-index: 10002;
    padding: 0;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    box-sizing: border-box;
    display: block;
    pointer-events: none;
}

.intro-progress-bar {
    height: 100%;
    width: 0%;
    min-width: 0%;
    background: linear-gradient(90deg, #00d084 0%, #00ff88 50%, #00d084 100%);
    background-size: 200% 100%;
    animation: progressShimmer 2s linear infinite;
    transition: width 0.1s linear;
    box-shadow: 0 0 10px rgba(0, 208, 132, 0.6), 0 0 20px rgba(0, 255, 136, 0.4);
    display: block;
    opacity: 1;
    visibility: visible;
}

@keyframes progressShimmer {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

.container {
    max-width: 100%;
    margin: 0 auto;
}

header {
    text-align: center;
    color: white;
    margin-bottom: 12px;
    position: relative;
}

.header-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header-logo {
    max-width: 90%;
    max-width: min(90%, calc(100vw - 60px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    width: auto;
    height: auto;
    margin: 0 auto;
    display: block;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3)) drop-shadow(0 0 20px rgba(0, 255, 136, 0.4));
    transition: transform 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.header-logo:hover {
    transform: scale(1.05);
}

@media (hover: none) {
    .header-logo:hover {
        transform: none;
    }
}

/* Desktop-Anpassungen für Logo */
@media (min-width: 768px) {
    .header-logo {
        max-width: 400px;
        max-width: min(400px, calc(100vw - 60px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    }
}

@media (min-width: 1024px) {
    .header-logo {
        max-width: 350px;
        max-width: min(350px, calc(100vw - 60px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    }
}


.help-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    background: rgba(0, 208, 132, 0.3);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    transition: all 0.3s ease;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(0, 208, 132, 0.4);
}

.bookmark-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid white;
    background: #00d084;
    color: white;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    transition: all 0.3s ease;
    line-height: 1;
    flex-shrink: 0;
    box-shadow: 0 0 10px rgba(0, 208, 132, 0.4);
}

.help-btn:hover {
    background: rgba(0, 208, 132, 0.5);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.6);
}

.bookmark-btn:hover {
    background: #00b870;
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.6);
}

.help-btn:active {
    transform: scale(0.95);
    background: rgba(0, 208, 132, 0.6);
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.8);
}

.bookmark-btn:active {
    transform: scale(0.95);
    background: #00a05c;
    box-shadow: 0 0 20px rgba(0, 255, 136, 0.8);
}

main {
    background: white;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.upload-section {
    margin-bottom: 15px;
}

.upload-controls {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.main-buttons {
    display: flex;
    flex-direction: row;
    gap: 6px;
}

.main-buttons .btn {
    flex: 1;
}

.action-buttons {
    display: flex;
    flex-direction: row;
    gap: 6px;
}

.action-buttons .btn {
    flex: 1;
}

#file-input {
    display: none;
}

.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    touch-action: manipulation;
}

.btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    font-weight: 700;
    font-size: 12px;
    flex-shrink: 0;
}

.btn:active {
    transform: scale(0.98);
}

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

.btn-primary {
    background: #00d084;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 208, 132, 0.4), 0 0 20px rgba(0, 255, 136, 0.2);
}

.btn-primary:active {
    background: #00b870;
    box-shadow: 0 2px 8px rgba(0, 208, 132, 0.3);
}

.btn-secondary {
    background: #48bb78;
    color: white;
}

.btn-secondary:active {
    background: #38a169;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:active {
    background: #059669;
}

/* Schritt-Buttons mit Regenbogenfarben von Lila bis Grün */
.btn-step-1 {
    background: #8b5cf6;
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.btn-step-1:active {
    background: #7c3aed;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

.btn-step-2 {
    background: #3b82f6;
    color: white;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-step-2:active {
    background: #2563eb;
    box-shadow: 0 2px 8px rgba(59, 130, 246, 0.3);
}

.btn-step-3 {
    background: #06b6d4;
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

.btn-step-3:active {
    background: #0891b2;
    box-shadow: 0 2px 8px rgba(6, 182, 212, 0.3);
}

.btn-step-4 {
    background: #eab308;
    color: white;
    box-shadow: 0 4px 12px rgba(234, 179, 8, 0.4);
}

.btn-step-4:active {
    background: #ca8a04;
    box-shadow: 0 2px 8px rgba(234, 179, 8, 0.3);
}

.btn-step-5 {
    background: #10b981;
    color: white;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.btn-step-5:active {
    background: #059669;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:active {
    background: #dc2626;
}

.btn-small {
    padding: 10px 16px;
    font-size: 14px;
    min-height: 40px;
}

.canvas-section {
    margin-bottom: 15px;
}

.canvas-container {
    position: relative;
    width: 100%;
    max-width: 390px;
    margin: 0 auto;
    background: #f3f4f6;
    border-radius: 8px;
    overflow: visible;
    border: 2px solid #e5e7eb;
    -webkit-tap-highlight-color: transparent;
}

/* Safari-spezifische Anpassungen für iPhone */
@supports (-webkit-touch-callout: none) {
    .canvas-container {
        max-width: min(390px, calc(100vw - 16px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    }
}

#main-canvas {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    object-fit: contain;
}

.overlay-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

.overlay-item {
    position: absolute;
    pointer-events: auto;
    cursor: move;
    cursor: grab;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    border: 2px dashed #00d084;
    border-radius: 4px;
    /* Transparenter Hintergrund für bessere Touch-Erkennung */
    background: rgba(0, 0, 0, 0.001);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 10px rgba(0, 208, 132, 0.3);
    /* Z-Index für bessere Interaktion */
    z-index: 10;
}

.overlay-item:not(.locked) {
    touch-action: none;
    cursor: grab;
}

.overlay-item:not(.locked):active {
    cursor: grabbing;
}

.overlay-item.active {
    border-color: #00ff88;
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(0, 255, 136, 0.4), 0 0 20px rgba(0, 255, 136, 0.5);
}

.overlay-image-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.overlay-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    margin: 0 auto;
    -webkit-user-drag: none;
    user-drag: none;
}


.overlay-controls {
    margin-top: 10px;
    background: white;
    padding: 8px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.overlay-controls.hidden {
    display: none;
}

.rotation-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    padding: 10px 12px;
    min-width: 220px;
    max-width: 85%;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
    /* Stelle sicher, dass das Panel immer im Viewport bleibt */
    top: auto;
    right: auto;
}

.rotation-controls.hidden {
    display: none;
}

.rotation-control-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #e5e7eb;
}

.rotation-label {
    font-weight: 600;
    font-size: 14px;
    color: #1e293b;
}

.close-rotation-btn {
    background: none;
    border: none;
    font-size: 20px;
    color: #64748b;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.close-rotation-btn:hover {
    background-color: #f1f5f9;
    color: #1e293b;
}

.rotation-control-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rotation-input-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rotation-slider {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.rotation-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00d084;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rotation-slider::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0, 208, 132, 0.4);
}

.rotation-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00d084;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rotation-slider::-moz-range-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 8px rgba(0, 208, 132, 0.4);
}

.rotation-input {
    width: 55px;
    padding: 6px 8px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: #1e293b;
    outline: none;
    transition: border-color 0.2s ease;
}

.rotation-input:focus {
    border-color: #00d084;
}

.rotation-unit {
    font-size: 14px;
    font-weight: 600;
    color: #64748b;
    min-width: 18px;
}

.rotation-presets {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.rotation-preset-btn {
    flex: 1;
    padding: 6px 10px;
    background: #f1f5f9;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.2s ease;
}

.rotation-preset-btn:hover {
    background: #e2e8f0;
    border-color: #00d084;
    color: #00d084;
}

.rotation-preset-btn:active {
    background: #00d084;
    border-color: #00d084;
    color: white;
}

@media (max-width: 480px) {
    .rotation-controls {
        bottom: 10px;
        padding: 8px 10px;
        min-width: 200px;
    }
    
    .rotation-input-group {
        gap: 6px;
    }
    
    .rotation-input {
        width: 50px;
        padding: 5px 6px;
        font-size: 12px;
    }
    
    .rotation-preset-btn {
        padding: 5px 8px;
        font-size: 11px;
    }
    
    .rotation-label {
        font-size: 13px;
    }
    
    .rotation-unit {
        font-size: 12px;
    }
}

.control-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
}

.control-buttons .btn {
    flex: 1;
    min-width: 90px;
    padding: 8px 12px;
    font-size: 13px;
    min-height: 36px;
    white-space: nowrap;
}

.overlay-item.locked {
    border-color: #00ff88;
    border-style: solid;
    opacity: 0.9;
    touch-action: auto;
    box-shadow: 0 0 15px rgba(0, 255, 136, 0.4);
}

.overlay-item.locked .resize-handle {
    display: none;
}

.overlay-item.locked::after {
    content: '📌';
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0, 255, 136, 0.9);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.6);
}

.resize-handle {
    position: absolute;
    width: var(--overlay-handle-size, 24px);
    height: var(--overlay-handle-size, 24px);
    background: #00d084;
    border: 2px solid white;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100;
    touch-action: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 10px rgba(0, 208, 132, 0.5);
    transition: transform 0.1s ease;
    transform-origin: center center;
}

.resize-handle:hover,
.resize-handle:active {
    background: #00b870;
    transform: scale(1.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 208, 132, 0.7);
}

.resize-handle:active {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.resize-handle.rotate-handle {
    top: calc(var(--overlay-handle-size, 24px) * -1.5);
    left: 50%;
    transform: translateX(-50%);
    cursor: grab;
    background: #00d084;
    width: calc(var(--overlay-handle-size, 24px) * 1.2);
    height: calc(var(--overlay-handle-size, 24px) * 1.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--overlay-handle-size, 24px) * 0.75);
    transform-origin: center center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 208, 132, 0.6);
}

.resize-handle.rotate-handle::before {
    content: '↻';
    color: white;
    font-size: 18px;
}

.resize-handle.rotate-handle::after {
    display: none;
}

.resize-handle.rotate-handle:active {
    cursor: grabbing;
    background: #00b870;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 208, 132, 0.8);
}

.resize-handle.scale-handle {
    bottom: calc(var(--overlay-handle-size, 24px) * -0.4);
    right: calc(var(--overlay-handle-size, 24px) * -0.4);
    cursor: nwse-resize;
    background: #00ff88;
    width: calc(var(--overlay-handle-size, 24px) * 1.1);
    height: calc(var(--overlay-handle-size, 24px) * 1.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--overlay-handle-size, 24px) * 0.75);
    transform-origin: center center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 0 15px rgba(0, 255, 136, 0.6);
}

.resize-handle.scale-handle::before {
    content: '⤡';
    color: white;
    font-size: 18px;
}

.resize-handle.scale-handle:hover,
.resize-handle.scale-handle:active {
    background: #00cc6a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 20px rgba(0, 255, 136, 0.8);
}

.resize-handle.flip-handle {
    top: calc(var(--overlay-handle-size, 24px) * -0.4);
    right: calc(var(--overlay-handle-size, 24px) * -0.4);
    cursor: pointer;
    background: #f59e0b;
    width: calc(var(--overlay-handle-size, 24px));
    height: calc(var(--overlay-handle-size, 24px));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: calc(var(--overlay-handle-size, 24px) * 0.8);
    transform-origin: center center;
}

.resize-handle.flip-handle::before {
    content: '⇄';
    color: white;
    font-size: 20px;
    font-weight: bold;
}

.resize-handle.flip-handle::after {
    display: none;
}

.resize-handle.flip-handle:hover,
.resize-handle.flip-handle:active {
    background: #d97706;
    transform: scale(1.1);
}

.resize-handle.delete-handle {
    bottom: calc(var(--overlay-handle-size, 24px) * -0.4);
    left: calc(var(--overlay-handle-size, 24px) * -0.4);
    cursor: pointer;
    background: white;
    border: 2px solid white;
    width: calc(var(--overlay-handle-size, 24px));
    height: calc(var(--overlay-handle-size, 24px));
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    transform: none !important;
}

.resize-handle.delete-handle::before {
    content: '🗑️';
    font-size: 18px;
    line-height: 1;
}

.resize-handle.delete-handle:hover,
.resize-handle.delete-handle:active {
    background: #f3f4f6;
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.4);
}

.resize-handle.edit-handle {
    top: calc(var(--overlay-handle-size, 24px) * -0.4);
    left: calc(var(--overlay-handle-size, 24px) * -0.4);
    cursor: pointer;
    background: #00d084;
    border: 2px solid white;
    width: calc(var(--overlay-handle-size, 24px));
    height: calc(var(--overlay-handle-size, 24px));
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3), 0 0 10px rgba(0, 208, 132, 0.5);
    transform-origin: center center;
    z-index: 101;
}

.resize-handle.edit-handle::before {
    content: '✏️';
    font-size: 18px;
    line-height: 1;
}

.resize-handle.edit-handle:hover,
.resize-handle.edit-handle:active {
    background: #00b870;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 15px rgba(0, 208, 132, 0.7);
}

/* Hilfe Modal Styles */
.help-modal {
    flex-direction: column;
    padding: 20px;
    padding-top: max(20px, env(safe-area-inset-top));
}

.help-modal.active,
.help-modal[style*="display: flex"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

.help-modal-close {
    position: absolute;
    top: max(15px, env(safe-area-inset-top));
    right: max(15px, env(safe-area-inset-right));
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d084 0%, #00b870 100%);
    color: white;
    border: 3px solid white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 208, 132, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
}

.help-modal-close:hover {
    background: linear-gradient(135deg, #00b870 0%, #00a05c 100%);
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 208, 132, 0.6), 0 4px 12px rgba(0, 0, 0, 0.3);
}

.help-modal-close:active {
    transform: scale(0.95);
}

.help-modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: calc(100% - 60px);
}

.help-image {
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 100px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

@media (max-width: 480px) {
    .help-modal {
        padding: 15px;
    }
    
    .help-modal-close {
        top: max(10px, env(safe-area-inset-top));
        right: max(10px, env(safe-area-inset-right));
        width: 40px;
        height: 40px;
        font-size: 24px;
    }
    
    .help-image {
        max-width: calc(100vw - 30px);
        max-height: calc(100vh - 80px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        border-radius: 8px;
    }
}

/* Bookmark Modal Styles */
.bookmark-modal-content {
    max-width: 450px;
    animation: modalSlideIn 0.3s ease-out;
}

.bookmark-modal-header {
    background: linear-gradient(135deg, #00d084 0%, #00b870 100%);
    color: white;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
    position: relative;
    padding-top: 20px;
}

.bookmark-header-icon {
    position: absolute;
    top: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 3px solid white;
    background: white;
}

.bookmark-header-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bookmark-modal-header h2 {
    color: white;
    margin: 0;
    text-align: center;
    font-size: 18px;
}

.bookmark-modal-header .modal-close {
    color: white;
    position: absolute;
    top: 10px;
    right: 10px;
}

.bookmark-modal-header .modal-close:active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.bookmark-modal-body {
    padding: 20px;
}

.bookmark-intro {
    text-align: center;
    font-size: 15px;
    color: #374151;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

.bookmark-instructions {
    background: #f9fafb;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    border: 1px solid #e5e7eb;
}

.bookmark-instructions h3 {
    font-size: 16px;
    color: #1e293b;
    margin: 0 0 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.bookmark-steps {
    list-style: none;
    padding: 0;
    margin: 0;
}

.bookmark-steps li {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.bookmark-steps li:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.step-icon {
    font-size: 16px;
    flex-shrink: 0;
}

.step-text {
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
}

.step-text strong {
    color: #00b870;
}

.share-icon-ios,
.menu-icon-android {
    display: inline-block;
    background: #e5e7eb;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 14px;
}

.bookmark-tip {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 10px;
    padding: 12px 15px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-top: 15px;
}

.tip-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.tip-text {
    font-size: 13px;
    color: #92400e;
    line-height: 1.5;
}

.bookmark-modal-content .modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 15px 20px;
}

.bookmark-modal-content .modal-footer .btn {
    min-width: 150px;
}

/* Hide instructions based on device */
.bookmark-instructions {
    display: none;
}

.bookmark-instructions.active {
    display: block;
}

@media (max-width: 480px) {
    .bookmark-modal-content {
        max-width: calc(100% - 20px);
        margin: 10px;
    }
    
    .bookmark-modal-header {
        padding-top: 15px;
    }
    
    .bookmark-header-icon {
        width: 50px;
        height: 50px;
        top: -25px;
    }
    
    .bookmark-modal-header h2 {
        font-size: 16px;
    }
    
    .bookmark-modal-body {
        padding: 15px;
    }
    
    .bookmark-intro {
        font-size: 14px;
    }
    
    .bookmark-instructions {
        padding: 12px;
    }
    
    .bookmark-instructions h3 {
        font-size: 15px;
    }
    
    .step-text {
        font-size: 13px;
    }
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #e5e7eb;
    display: flex;
    justify-content: center;
    gap: 12px;
}

#text-modal .modal-footer {
    padding: 12px 15px;
    gap: 8px;
}

.modal-footer .btn {
    min-width: 120px;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100vh;
    height: -webkit-fill-available;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-sizing: border-box;
}

.modal.active,
.modal[style*="display: flex"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-width: min(500px, calc(100vw - 40px - env(safe-area-inset-left) - env(safe-area-inset-right)));
    max-height: 85vh;
    max-height: calc(85vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    -webkit-overflow-scrolling: touch;
}

#text-modal .modal-content {
    max-height: 90vh;
    max-height: calc(90vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    max-width: 95%;
    max-width: min(95%, calc(100vw - 20px - env(safe-area-inset-left) - env(safe-area-inset-right)));
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
}

#text-modal .modal-header {
    padding: 15px;
}

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #6b7280;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    touch-action: manipulation;
}

.modal-close:active {
    background: #f3f4f6;
    color: #374151;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

#text-modal .modal-body {
    padding: 15px;
}

.image-select-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-large {
    padding: 18px 24px;
    font-size: 18px;
    min-height: 60px;
}

.overlay-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 15px;
}

.overlay-item-preview {
    aspect-ratio: 4/3;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
    background: #f9fafb;
    touch-action: manipulation;
}

.overlay-item-preview:active {
    transform: scale(0.95);
    border-color: #00d084;
    box-shadow: 0 0 15px rgba(0, 208, 132, 0.4);
}

.overlay-item-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.overlay-folder-preview {
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 16px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    touch-action: manipulation;
    display: flex;
    flex-direction: column;
    position: relative;
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    min-height: 180px;
}

.overlay-folder-preview:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    border-color: #00d084;
}

.overlay-folder-preview:active {
    transform: translateY(-2px);
    transition: all 0.1s ease;
}

.folder-icon-container {
    width: 100%;
    min-height: 120px;
    background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.folder-icon {
    font-size: 64px;
    opacity: 0.8;
    transition: transform 0.3s ease;
}

.overlay-folder-preview:hover .folder-icon {
    transform: scale(1.1);
}

.folder-info-container {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: #ffffff;
}

.folder-name {
    font-weight: 600;
    font-size: 16px;
    color: #1e293b;
    text-align: left;
    word-break: break-word;
    line-height: 1.4;
    margin: 0;
    overflow-wrap: break-word;
    hyphens: auto;
}

.folder-count {
    font-size: 13px;
    color: #64748b;
    text-align: left;
    font-weight: 500;
    margin: 0;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e5e7eb;
    gap: 10px;
}

.btn-back {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    color: #6b7280;
    transition: all 0.2s;
    flex-shrink: 0;
    position: relative;
    z-index: 10;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-back:hover,
.btn-back:active {
    background: #f3f4f6;
    color: #374151;
}

.modal-header h2 {
    flex: 1;
    margin: 0;
}

.loading {
    text-align: center;
    color: #6b7280;
    padding: 20px;
}

.error {
    text-align: center;
    color: #ef4444;
    padding: 20px;
}

/* Download Success Modal Styles */
.download-success-content {
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.download-success-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-bottom: none;
    border-radius: 12px 12px 0 0;
}

.download-success-header h2 {
    color: white;
    margin: 0;
}

.download-success-header .modal-close {
    color: white;
}

.download-success-header .modal-close:active {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.download-success-body {
    text-align: center;
    padding: 30px 20px;
}

.success-message {
    font-size: 16px;
    color: #374151;
    line-height: 1.6;
    margin: 0 0 30px 0;
    padding: 0 10px;
}

/* Geschenk-Werbung */
.gift-promo {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 50%, #fcd34d 100%);
    border-radius: 16px;
    padding: 25px 20px;
    margin-top: 25px;
    box-shadow: 0 8px 24px rgba(251, 191, 36, 0.3), 0 0 0 2px rgba(251, 191, 36, 0.2);
    position: relative;
    overflow: hidden;
}

.gift-promo::before {
    content: '🎁';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 80px;
    opacity: 0.1;
    transform: rotate(15deg);
}

.gift-promo-image-container {
    margin: 0 auto 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 1;
}

.gift-promo-image {
    max-width: 200px;
    max-height: 200px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.gift-promo-title {
    font-size: 24px;
    font-weight: 700;
    color: #92400e;
    margin: 0 0 12px 0;
    text-shadow: 0 2px 4px rgba(146, 64, 14, 0.1);
    position: relative;
    z-index: 1;
}

.gift-promo-text {
    font-size: 16px;
    color: #78350f;
    line-height: 1.6;
    margin: 0;
    position: relative;
    z-index: 1;
}

.gift-promo-link {
    color: #d97706;
    font-weight: 600;
    text-decoration: none;
    border-bottom: 2px solid #f59e0b;
    transition: all 0.3s ease;
    display: inline-block;
    margin-top: 8px;
}

.gift-promo-link:hover {
    color: #b45309;
    border-bottom-color: #d97706;
    transform: translateY(-1px);
}

.gift-promo-link:active {
    transform: translateY(0);
}

.download-success-content .modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 20px;
}

.download-success-content .modal-footer .btn {
    min-width: 150px;
    font-size: 16px;
    padding: 12px 24px;
    min-height: 44px;
}

/* Share Options Modal */
.share-options-content {
    animation: modalSlideIn 0.3s ease-out;
    max-width: 500px;
}

.share-options-body {
    padding: 30px 20px;
}

.share-options-description {
    font-size: 16px;
    color: #374151;
    margin: 0 0 20px 0;
    text-align: center;
}

.share-options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.share-option-item {
    display: block;
    cursor: pointer;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s ease;
    background: white;
}

.share-option-item:hover {
    border-color: #3b82f6;
    background: #f0f9ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.share-option-item input[type="radio"] {
    display: none;
}

.share-option-item input[type="radio"]:checked + .share-option-content {
    color: #3b82f6;
}

.share-option-item.selected {
    border-color: #3b82f6;
    background: #eff6ff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.share-option-item.selected .share-option-title {
    color: #3b82f6;
}

.share-option-item.selected .share-option-size {
    background: #dbeafe;
    color: #1e40af;
}

.share-option-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.share-option-item.disabled .share-option-description {
    color: #ef4444;
}

.share-option-item input[type="radio"]:disabled {
    cursor: not-allowed;
}

.share-option-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.share-option-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.share-option-title {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
}

.share-option-item input[type="radio"]:checked + .share-option-content .share-option-title {
    color: #3b82f6;
}

.share-option-size {
    font-size: 14px;
    font-weight: 600;
    color: #6b7280;
    background: #f3f4f6;
    padding: 4px 12px;
    border-radius: 6px;
}

.share-option-item input[type="radio"]:checked + .share-option-content .share-option-size {
    background: #dbeafe;
    color: #1e40af;
}

.share-option-description {
    font-size: 14px;
    color: #6b7280;
    margin-top: 4px;
}

.share-options-content .modal-footer {
    border-top: 1px solid #e5e7eb;
    padding: 20px;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.share-options-content .modal-footer .btn {
    min-width: 120px;
    font-size: 16px;
    padding: 12px 24px;
    min-height: 44px;
}

/* Optimizing Modal */
.optimizing-content {
    animation: modalSlideIn 0.3s ease-out;
    max-width: 300px;
    text-align: center;
}

.optimizing-body {
    padding: 40px 30px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.optimizing-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.optimizing-text {
    font-size: 16px;
    color: #374151;
    margin: 0;
    font-weight: 500;
}

/* Responsive Anpassungen entfernt - feste iPhone-Größe für alle Bildschirme */

/* Text Overlay Styles */
.text-overlay-item {
    border: 2px dashed #00d084;
    box-shadow: 0 0 10px rgba(0, 208, 132, 0.3);
    min-width: 120px;
    min-height: 60px;
}

.text-overlay-item.active {
    border-color: #00ff88;
    border-width: 3px;
    box-shadow: 0 0 0 2px rgba(0, 255, 136, 0.4), 0 0 20px rgba(0, 255, 136, 0.5);
}

.text-overlay-container {
    word-wrap: break-word;
    overflow: hidden;
    text-align: center;
    white-space: nowrap;
    outline: none;
    border-radius: 8px;
    pointer-events: none;
    padding: 0 !important;
    margin: 0 !important;
}

.text-overlay-container.editing {
    outline: 2px solid #00d084;
    outline-offset: 2px;
    cursor: text;
    box-shadow: 0 0 15px rgba(0, 208, 132, 0.4);
    pointer-events: auto;
}

/* Textfeld-Handles: Größere Abstände außen für bessere Touch-Bedienbarkeit */
.text-overlay-item .resize-handle.scale-handle {
    bottom: calc(var(--overlay-handle-size, 24px) * -0.8);
    right: calc(var(--overlay-handle-size, 24px) * -0.8);
}

.text-overlay-item .resize-handle.flip-handle {
    top: calc(var(--overlay-handle-size, 24px) * -0.8);
    right: calc(var(--overlay-handle-size, 24px) * -0.8);
}

.text-overlay-item .resize-handle.delete-handle {
    bottom: calc(var(--overlay-handle-size, 24px) * -0.8);
    left: calc(var(--overlay-handle-size, 24px) * -0.8);
}

.text-overlay-item .resize-handle.edit-handle {
    top: calc(var(--overlay-handle-size, 24px) * -0.8);
    left: calc(var(--overlay-handle-size, 24px) * -0.8);
}

.text-overlay-item .resize-handle.rotate-handle {
    top: calc(var(--overlay-handle-size, 24px) * -1.5);
}

/* Flip-Handle bei Text-Overlays ausblenden */
.text-overlay-item .resize-handle.flip-handle {
    display: none !important;
}

/* Kleinere Icons in Textfeld-Handles */
.text-overlay-item .resize-handle.rotate-handle::before {
    font-size: 14px;
}

.text-overlay-item .resize-handle.scale-handle::before {
    font-size: 14px;
}

.text-overlay-item .resize-handle.flip-handle::before {
    font-size: 16px;
}

.text-overlay-item .resize-handle.delete-handle::before {
    font-size: 14px;
}

.text-overlay-item .resize-handle.edit-handle::before {
    font-size: 14px;
}

/* Text Modal Styles */
.text-form-group {
    margin-bottom: 12px;
}

.text-form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
}

.text-input {
    width: 100%;
    padding: 8px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 50px;
}

.text-input:focus {
    outline: none;
    border-color: #00d084;
    box-shadow: 0 0 0 3px rgba(0, 208, 132, 0.2), 0 0 10px rgba(0, 208, 132, 0.3);
}

.text-font-select {
    width: 100%;
    padding: 8px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    background-color: white;
    cursor: pointer;
}

.text-font-select:focus {
    outline: none;
    border-color: #00d084;
    box-shadow: 0 0 0 3px rgba(0, 208, 132, 0.2), 0 0 10px rgba(0, 208, 132, 0.3);
}

.text-size-input {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #e5e7eb;
    outline: none;
    -webkit-appearance: none;
}

.text-size-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00d084;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(0, 208, 132, 0.5);
}

.text-size-input::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #00d084;
    cursor: pointer;
    border: none;
    box-shadow: 0 0 10px rgba(0, 208, 132, 0.5);
}

.text-form-row {
    display: flex;
    gap: 10px;
}

.text-form-row .text-form-group {
    flex: 1;
}

.text-color-input {
    width: 100%;
    height: 40px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    padding: 2px;
}

.text-color-input:focus {
    outline: none;
    border-color: #00d084;
    box-shadow: 0 0 0 3px rgba(0, 208, 132, 0.2), 0 0 10px rgba(0, 208, 132, 0.3);
}

.text-preview-container {
    margin-top: 12px;
    padding: 10px;
    background: #f9fafb;
    border-radius: 6px;
    border: 2px solid #e5e7eb;
}

.text-preview-container label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 13px;
    color: #374151;
}

.text-preview {
    min-height: 50px;
    padding: 10px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    word-wrap: break-word;
    white-space: nowrap;
    text-align: center;
}

#text-size-value {
    font-weight: 600;
    color: #00d084;
    text-shadow: 0 0 5px rgba(0, 208, 132, 0.4);
}

/* Touch-Optimierungen */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 48px;
    }

    .overlay-item-preview {
        min-height: 100px;
    }

    .text-color-input {
        height: 48px;
    }

    #text-modal .modal-content {
        max-width: 100%;
        max-height: 95vh;
        max-height: calc(95vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        margin: 10px;
        margin-top: max(10px, env(safe-area-inset-top));
        margin-bottom: max(10px, env(safe-area-inset-bottom));
    }

    #text-modal .modal-body {
        padding: 12px;
    }

    .text-form-group {
        margin-bottom: 10px;
    }

    .text-input {
        min-height: 45px;
        padding: 8px;
    }
    
    /* Safari-spezifische iPhone-Anpassungen */
    body {
        padding-left: max(8px, env(safe-area-inset-left));
        padding-right: max(8px, env(safe-area-inset-right));
    }
    
    .container {
        max-width: min(100%, calc(100vw - env(safe-area-inset-left) - env(safe-area-inset-right)));
    }

    /* Kleinere Handles für Textfelder auf Touch-Geräten */
    .text-overlay-item {
        --overlay-handle-size: 28px;
    }

    .text-overlay-item .resize-handle {
        width: 28px;
        height: 28px;
        min-width: 28px;
        min-height: 28px;
    }

    .text-overlay-item .resize-handle.rotate-handle {
        width: 32px;
        height: 32px;
        min-width: 32px;
        min-height: 32px;
    }

    .text-overlay-item .resize-handle.scale-handle {
        width: 30px;
        height: 30px;
        min-width: 30px;
        min-height: 30px;
    }

    /* Kleinere Icons in Textfeld-Handles auf Touch-Geräten */
    .text-overlay-item .resize-handle.rotate-handle::before {
        font-size: 16px;
    }

    .text-overlay-item .resize-handle.scale-handle::before {
        font-size: 16px;
    }

    .text-overlay-item .resize-handle.flip-handle::before {
        font-size: 18px;
    }

    .text-overlay-item .resize-handle.delete-handle::before {
        font-size: 16px;
    }

    .text-overlay-item .resize-handle.edit-handle::before {
        font-size: 16px;
    }
}

/* Mobile optimizations for text modal */
@media (max-width: 480px) {
    #text-modal .modal-content {
        max-width: 100%;
        max-width: calc(100% - env(safe-area-inset-left) - env(safe-area-inset-right));
        max-height: 95vh;
        max-height: calc(95vh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
        border-radius: 8px;
    }

    #text-modal .modal-header {
        padding: 12px;
    }

    #text-modal .modal-header h2 {
        font-size: 18px;
    }

    #text-modal .modal-body {
        padding: 12px;
    }

    .text-form-group {
        margin-bottom: 10px;
    }

    .text-form-group label {
        font-size: 12px;
        margin-bottom: 3px;
    }

    .text-input {
        padding: 6px;
        font-size: 13px;
        min-height: 40px;
    }

    .text-font-select {
        padding: 6px;
        font-size: 13px;
    }

    .text-preview-container {
        padding: 8px;
        margin-top: 10px;
    }

    .text-preview {
        min-height: 40px;
        padding: 8px;
        font-size: 12px;
    }

    #text-modal .modal-footer {
        padding: 10px 12px;
    }

    #text-modal .modal-footer .btn {
        padding: 8px 12px;
        font-size: 13px;
        min-height: 40px;
    }

    /* Mobile Anpassungen für Ordner-Kacheln */
    .overlay-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
        gap: 15px !important;
    }

    .overlay-folder-preview {
        border-radius: 12px;
    }

    .folder-info-container {
        padding: 12px;
        gap: 6px;
    }

    .folder-name {
        font-size: 14px;
    }

    .folder-count {
        font-size: 12px;
    }

    .folder-icon-container {
        min-height: 100px;
    }
    
    .folder-icon {
        font-size: 48px;
    }
}

/* Sticky Buttons am unteren Rand */
.sticky-buttons-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    z-index: 1000;
    pointer-events: none;
}

.sticky-btn {
    pointer-events: auto;
    padding: 8px 18px;
    height: auto;
    min-height: 36px;
    border-radius: 18px;
    border: 2px solid white;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 208, 132, 0.5);
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.sticky-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 0 25px rgba(0, 255, 136, 0.7);
}

.sticky-btn:active {
    transform: scale(0.95);
}

.sticky-buttons-container .help-btn,
.sticky-buttons-container .bookmark-btn {
    width: auto !important;
    height: auto !important;
    min-width: auto !important;
    min-height: auto !important;
    border-radius: 18px !important;
    padding: 8px 18px !important;
    font-size: 13px !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
}

.sticky-buttons-container .help-btn {
    background: #8b5cf6;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(139, 92, 246, 0.5);
}

.sticky-buttons-container .help-btn:hover {
    background: #7c3aed;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 0 25px rgba(139, 92, 246, 0.7);
}

.sticky-buttons-container .help-btn:active {
    background: #6d28d9;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(139, 92, 246, 0.8);
}

.sticky-buttons-container .bookmark-btn {
    background: #00d084;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 208, 132, 0.5);
}

.sticky-buttons-container .bookmark-btn:hover {
    background: #00b870;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4), 0 0 25px rgba(0, 255, 136, 0.7);
}

.sticky-buttons-container .bookmark-btn:active {
    background: #00a05c;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 20px rgba(0, 208, 132, 0.8);
}

@media (max-width: 480px) {
    .sticky-buttons-container {
        padding: 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
        gap: 8px;
    }
    
    .sticky-btn {
        padding: 6px 14px;
        min-height: 32px;
        font-size: 12px;
        border-width: 2px;
        border-radius: 16px;
    }
    
    .sticky-buttons-container .help-btn,
    .sticky-buttons-container .bookmark-btn {
        padding: 6px 14px !important;
        font-size: 12px !important;
        border-radius: 16px !important;
        min-height: 32px !important;
    }
}
