body { background: #f0f2f5; user-select: none; }
        .toolbar-sticky {
            position: sticky;
            top: 0;
            z-index: 1000;
            display: flex;
            justify-content: center;
            padding: 10px 12px;
            background: #f0f2f5;
            margin-bottom: 10px;
        }
        .toolbar {
            background: white; border-radius: 8px; padding: 8px 15px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.1);
            display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
            justify-content: center; max-width: 100%; margin-bottom: 0;
        }
        .canvas-wrapper {
            position: relative; display: inline-block; margin: 0 auto; line-height: 0;
            box-shadow: 0 0 0 1px rgba(0,0,0,0.1); background: white; max-width: 100%;
        }
        #pdf-background { display: block; max-width: 100%; height: auto; }
        #overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; pointer-events: auto; }

        .text-box, .image-box {
            position: absolute; pointer-events: auto; word-wrap: break-word;
            font-family: Tahoma, 'Segoe UI', Arial, sans-serif; line-height: 1.4;
        }
        .text-box {
            min-width: 50px;
            min-height: 30px;
            padding: 4px 8px;
            border: 2px solid transparent;
            outline: none;
            background: transparent;
            cursor: move;
            direction: rtl;
            text-align: right;
            white-space: pre-wrap;
            word-wrap: break-word;
            box-sizing: border-box;
            user-select: none;
            font-size: 14px;
        }
        .text-box .text-content {
            width: 100%;
            min-height: 100%;
            word-wrap: break-word;
            white-space: pre-wrap;
            pointer-events: none;
        }
        .text-box.selected { border-color: #198754; box-shadow: 0 0 0 1px #198754; }
        .image-box { cursor: move; border: 2px solid transparent; }
        .image-box.selected { border-color: #198754; box-shadow: 0 0 0 1px #198754; }
        .image-box img { display: block; max-width: 100%; height: auto; }

        .resize-handle {
            position: absolute; width: 10px; height: 10px; background: #0d6efd;
            border: 1px solid white; display: none; z-index: 5; pointer-events: auto;
        }
        .selected .resize-handle { display: block; }
        .resize-handle.br { bottom: -5px; right: -5px; cursor: nwse-resize; }
        .resize-handle.bl { bottom: -5px; left: -5px; cursor: nesw-resize; }
        .resize-handle.tr { top: -5px; right: -5px; cursor: nesw-resize; }
        .resize-handle.tl { top: -5px; left: -5px; cursor: nwse-resize; }

        .text-editor-popup {
            position: fixed; z-index: 10000; background: white;
            border: 1px solid #aaa; border-radius: 6px; padding: 8px;
            box-shadow: 0 4px 12px rgba(0,0,0,0.2); display: none;
            width: 240px;
        }
        .text-editor-popup textarea {
            width: 100%;
            resize: both;
            overflow: auto;
            direction: rtl;
            text-align: right;
            unicode-bidi: embed;
            font-family: Tahoma;
            font-size: 14px;
            min-height: 50px;
            white-space: pre-wrap;
        }
        .text-editor-popup .buttons { margin-top: 6px; display: flex; gap: 3px; align-items: center; }
        .text-editor-popup .btn-xs { font-size: 11px; padding: 2px 6px; }

        .context-menu {
            position: fixed; background: #fff; border: 1px solid #ccc; border-radius: 6px;
            padding: 8px 0; z-index: 9999; box-shadow: 0 2px 10px rgba(0,0,0,0.15);
            display: none; min-width: 200px; direction: ltr;
        }
        .context-menu .menu-item {
            padding: 6px 15px; cursor: pointer; font-size: 14px; color: #333;
            display: flex; gap: 8px; align-items: center;
        }
        .context-menu .menu-item:hover { background: #e9ecef; }
        .context-menu .separator { height: 1px; background: #ddd; margin: 4px 0; }
        .page-nav { display: none; gap: 5px; }

        .fingerprint-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
        .fingerprint-grid canvas { border: 2px solid #ccc; cursor: pointer; max-width: 100%; }
        .fingerprint-grid canvas:hover { border-color: #0d6efd; }