/* Custom Styles */
        #pdf-container {
            position: relative;
            background-color: #525659;
            overflow-y: auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 20px;
            padding: 20px;
            padding-top: 40px;
        }

        .page-wrapper {
            position: relative;
            box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
            background-color: white; 
            border-radius: 4px;
        }

        .text-layer {
            position: absolute;
            left: 0;
            top: 0;
            right: 0;
            bottom: 0;
            overflow: hidden;
            opacity: 0.8;
            line-height: 1.0;
            cursor: text; 
        }

        .text-layer > span {
            color: transparent; 
            position: absolute;
            white-space: pre;
            cursor: text;
            transform-origin: 0% 0%;
            border: 1px dashed transparent;
            transition: border 0.2s, background-color 0.2s, box-shadow 0.2s;
            box-sizing: border-box;
            border-radius: 2px;
        }

        .text-layer > span:hover {
            border: 1px dashed #3b82f6;
            background-color: rgba(59, 130, 246, 0.1);
            color: #000; 
        }

        .text-layer > span:focus {
            outline: none;
            border: 1px solid #3b82f6;
            background-color: white !important; 
            color: #000 !important;
            z-index: 10;
            overflow-y: hidden; 
            white-space: normal; 
            word-wrap: break-word;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }

        .text-modified {
            background-color: white !important; 
            color: black !important;
            z-index: 5;
        }

        /* Nuvolette sempre chiare */
        #floating-toolbar, #add-page-menu {
            display: none;
            position: absolute;
            z-index: 50;
            background: white !important;
            color: #111827 !important;
            border-radius: 8px;
            box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
            padding: 8px;
            border: 1px solid #e5e7eb !important;
        }

        #floating-toolbar {
            align-items: center;
            gap: 8px;
        }

        #add-page-menu {
            flex-direction: column;
            gap: 4px;
            padding: 4px;
            min-width: 150px;
        }

        .toolbar-btn {
            padding: 4px 8px;
            border-radius: 4px;
            cursor: pointer;
            transition: background 0.2s;
            color: #111827 !important;
        }
        .toolbar-btn:hover { background: #f3f4f6 !important; }

        .menu-btn {
            display: flex;
            align-items: center;
            gap: 8px;
            padding: 8px 12px;
            border-radius: 6px;
            cursor: pointer;
            transition: background 0.2s;
            font-size: 14px;
            text-align: left;
            width: 100%;
            color: #111827 !important;
            background: transparent;
        }
        .menu-btn:hover { background: #f3f4f6 !important; color: #3b82f6 !important; }

        .toolbar-select, .toolbar-input {
            border: 1px solid #d1d5db !important;
            border-radius: 4px;
            padding: 2px 4px;
            background: white !important;
            color: #111827 !important;
            font-size: 14px;
        }
        
        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: transparent; }
        ::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
        .dark ::-webkit-scrollbar-thumb { background: #475569; }

        .page-controls {
            position: absolute;
            top: -20px;
            left: 0;
            width: 100%;
            display: flex;
            justify-content: space-between;
            z-index: 20;
            opacity: 0;
            transition: opacity 0.2s;
        }
        .page-wrapper:hover .page-controls { opacity: 1; }
        
        .page-btn {
            background: white;
            border: 1px solid #e5e7eb;
            border-radius: 50%;
            width: 32px;
            height: 32px;
            display: flex;
            align-items: center;
            justify-content: center;
            cursor: pointer;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            color: #374151;
        }
        .dark .page-btn {
            background: #374151;
            border-color: #4b5563;
            color: white;
        }
        .page-btn:hover { transform: scale(1.1); }
        
        .tooltip { position: relative; }
        .tooltip::after {
            content: attr(data-tooltip);
            position: absolute;
            bottom: 100%; left: 50%; transform: translateX(-50%);
            background: rgba(0,0,0,0.8); color: white; padding: 4px 8px;
            border-radius: 4px; font-size: 12px; white-space: nowrap;
            opacity: 0; pointer-events: none; transition: opacity 0.2s;
            margin-bottom: 5px;
        }
        .tooltip:hover::after { opacity: 1; }